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


  • Posts

  • Joined

  • Last visited

Posts posted by urbanxx001

  1. 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. 

  2. 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). 

  3. 7 minutes ago, miguelangelo22x@gmail.com said:

    uhhhhhh the post got duplicated


    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.

  4. 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?

  5. 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]

  6. 2 hours ago, vemerion said:

    I would encourage you to stay away from LockableLootTileEntity and IInventory, and instead use the recommended forge alternative IItemHandler.

    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.

  7. 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.





  8. 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.

  9. It's called in:

    private static void commonSetup(FMLCommonSetupEvent event) {
        DeferredWorkQueue.runLater(() -> {

    which in turn is called in the Common Proxy class as:

    final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
  10. 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.







  11. Ok. Sorry for how tedious this has been. I removed the @Mod.EventBusSubscriber line and tried




    But throws the same error in-game.


  12. 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 {
        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?

  13. 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.

  14. 2 hours ago, poopoodice said:
    .orElse(new ModCapMethods()

    This won't assign the living entity a new instance of your capability.

    The orElse line isn't the one I'm using to set the capability, it's the .ifPresent(IModCap::set)


    2 hours ago, poopoodice said:

    If the capability does not exist on the entity, it prints the default value (of the new instance).

    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?

  15. 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. 

  16. 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. 



    • Like 1
  • Create New...

Important Information

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