Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

urbanxx001

Members
  • Posts

    181
  • Joined

  • Last visited

Everything posted by urbanxx001

  1. The condition is from a scrollbar. I can do changes there, however I don't what actual methods exist to either remove or update the buttons.
  2. You could try "Invalidate Caches/Restart" under File.
  3. According to several sources, it's difficult to update widgets when you're not directly clicking/interacting with them. In my case I'd like to change the text displayed by buttons. I've considered a few solutions. One is to call drawing events in GuiScreenEvent to get the widgets and replace them. However these events are only called when the screen is instantiated. Another is to use the updateScreen() method in the custom screen class, however I can't seem to find it so I believe I'm not calling it correctly or it's deprecated. Finally I could manually close and reopen the screen with updated fields for the buttons, but this seems expensive.
  4. Thank you so much, I'll use GlobalEntityTypeAttributes then. The EntityType (a set of them actually) isn't being grabbed from an Entity in the world, but instead from the ForgeRegistry. It's being used for a database. I may still need the actual class, as I need to check if IAngerable is extended by it (to determine if mobs are Neutral or not; isPeacefulCreature only checks if the mob is peaceful or hostile).
  5. I see that lol. Unfortunately it seems like the crash report makes no reference to a specific mod, unless I overlooked it. You may have to remove the mods one by one to see where the trouble lies.
  6. For an EntityType<?> I can use getClass(), but the methods available are generic, since it's a wildcard. I would like the specific entity class in order to retrieve attributes and check a few other data. Since methods like getAttribute() aren't directly available, this can (probably?) be accomplished with: if (MobEntity.class.isAssignableFrom(entityType.getClass())) { EntityType<? extends MobEntity> entityType1 = (EntityType<? extends MobEntity>) entityType; AttributeModifierMap.MutableAttribute attributeMap = null; Method[] methods = entityType1.getClass().getMethods(); for (Method method : methods) { if (method.getReturnType() == AttributeModifierMap.MutableAttribute.class) { attributeMap = (AttributeModifierMap.MutableAttribute) method.getDefaultValue(); } } } However this seems over-complicated. Alternatively I can cast ? to type T with a helper method, and then would somehow need to instantiate it: T entity = new T(entityType1, world) {}; But obviously T can't be used in that manner. Am I overthinking this?
  7. I have the following event class, which should change the rendering type of a vanilla mob when it's capability is updated. The capability itself works, however the events don't seem to be firing. Edit1: Actually it doesn't seem like the events are necessary. So the issue is updating the capability, which probably requires sending a packet when the item that sets the capability is used. Edit2: Since it's being sent and received client side, I probably need a C2S packet and then S2C one. Edit3: Got it working! It was updating on server and not client [Classes removed as the mod isn't released yet]
  8. Woo got it to sync by setting the pos in the read/write methods, which are called by getUpdateTag().
  9. I'll definitely consider IItemHandler down the line, thanks. With openGui() I was passing the block pos: NetworkHooks.openGui((ServerPlayerEntity) player, ((INamedContainerProvider) tileentity), t -> t.writeBlockPos(pos)); So the problem is this isn't synced with the client. I'll try getUpdatePacket() and onDataPacket() in the te then.
  10. Alright I've redone a bit and it's working as long as the block position is given manually in the packet handler. I've been trying to pass it from the tile entity => container => screen instead, however something strange occurs in the container. It receives the correct te and block position, but then a second te with null position is detected. Classes below. ModBlock ModTileEntity ModContainer
  11. That looks right. You can test it and see if everything is functioning correctly. There might also be a way to read/write the ingredients as a single array, but it would be the same amount of code.
  12. Reading those variables entirely depends on how you created the write() method. For reference, the vanilla classes such as CookingRecipeSerializer are a good template. The only difference is they return the recipe from factory: return this.factory.create(recipeId, etc.) If you have variables such as cooking time and experience returned, they should also be written and read.
  13. Right it's being sent in two places, idk why I sent a second one in PacketUpdateContainer. I'll fix the argument mismatch as well. Thanks for catching those.
  14. Ah that makes sense. I replaced it with that, but receive the same error. Hopefully it's not an issue on the receiving end (container).
  15. It's called in: private static void commonSetup(FMLCommonSetupEvent event) { DeferredWorkQueue.runLater(() -> { CapCompScreen.register(); PacketHandler.register(); }); } which in turn is called in the Common Proxy class as: final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); modEventBus.addListener(CommonProxy::commonSetup);
  16. I have a button in my screen class to send a packet to the container in order to update the inventory (client to server), according to this. Opening the gui and clicking the button in-game, I receive an invalid message error that originates from: PacketHandler.CHANNEL.send(PacketDistributor.ALL.noArg(), new CapCompContainer(ModContainerTypes.MULTI_9X3.get(), containerID, containerInd, senderInv, 3)); According to this the issue could stem from registration, but I ensured that the packet is registered in FMLCommonSetup and specified the network direction PLAY_TO_SERVER. Classes: PacketHandler PacketUpdateContainer CapCompContainer CapCompScreen
  17. Of course: IModTag ModTagItem ModTagProvider ModTagStorage ModEvents CommonProxy Main
  18. Alright I tried: @Mod.EventBusSubscriber(modid = Main.MOD_ID) And added a log inside the event: Main.LOGGER.info("Logged capability event"); But the info wasn't generated in latest.log or debug.log.
  19. Ok. Sorry for how tedious this has been. I removed the @Mod.EventBusSubscriber line and tried MinecraftForge.EVENT_BUS.register(ModSubscribeEvents.class); and FMLJavaModLoadingContext.get().getModEventBus().register(ModSubscribeEvents.class); But throws the same error in-game.
  20. After checking the capability register is in FMLCommonSetupEvent: CapabilityManager.INSTANCE.register(IModCap.class, new ModCapStorage(), ModCapMethods::new); And the event in: @Mod.EventBusSubscriber(modid = Main.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public class ModSubscribeEvents { @SubscribeEvent public void attachCapabilitiesEntity(final AttachCapabilitiesEvent<Entity> event) { if ((event.getObject() instanceof LivingEntity) && !(event.getObject() instanceof PlayerEntity)) event.addCapability(new ResourceLocation(Main.MOD_ID, "mod_cap"), new ModCap()); } } orElseThrow() still throws an error. I'm in the same boat as this guy, I don't think he resolved it. Out of curiosity, does anything need to be created in the data folder?
  21. Apologies I understand what you mean now, orElse was giving a false positive with a temporary object that it was registered, which means I should inspect the register again. Will use .orElseThrow(() -> new IllegalArgumentException("Illegal argument")) instead. Thank you for your help.
  22. The orElse line isn't the one I'm using to set the capability, it's the .ifPresent(IModCap::set) Ah ok. I checked and fixed the register method and the AttachCapabilityEvent, but still receive the default value. Should all entities automatically receive the capability through that event? If not, does it need to initially be attached to them with something like EntityJoinWorldEvent?
  23. Ahh it's a Shader. I'm familiar with the terrain-warping ones, made one a long time ago for bedrock. The closest thing I can think of that physically alters blocks is the No Cubes mod, but that's a static change to the terrain, not a constantly-updating one that occurs with shaders when it's a certain radius from the player. Perhaps you can adapt that type of code to work in an event that constantly detects the radius, to mirror the hitboxes with your rendering. Although that would most likely be very laggy. Again hopefully someone else can give input, but asm might be your best bet.
  24. I would take a look at how the Never Needed or Wanted (NNOW) mod handles new villagers, PoI blocks, and trades. The unique villager textures are based on the names when you register the profession (here), which points to the corresponding file in your textures/entity. The mod creator also made some nifty reference classes, VillagerUtil and RandomTradeBuilder, that reduces some repetitive code when making multiple villager types.
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.