Jump to content

Fuffles

Members
  • Posts

    38
  • Joined

  • Last visited

Posts posted by Fuffles

  1. hit a roadblock
    Xz7R4vd.png

    IgniterStorage code

    Quote


    [...]
    import net.minecraftforge.common.capabilities.Capability;
    import net.minecraftforge.common.capabilities.Capability.IStorage;

    public class IgniterStorage implements IStorage<IBasic>
    {
        @Override
        public INBT writeNBT(Capability<IBasic> capability, IBasic instance, Direction side) 
        {
            CompoundNBT nbts = new CompoundNBT();
            nbts.putUniqueId("igniter", instance.getUUID());
            return nbts;
        }

        @Override
        public void readNBT(Capability<IBasic> capability, IBasic instance, Direction side, INBT nbt) 
        {
            instance.setUUID(((CompoundNBT)nbt).getUniqueId("igniter"));
        }
    }

  2. 11 hours ago, ChampionAsh5357 said:

    This is not a capability, the nbt data is only useful when saving or loading a world in this case. What you've done is literally nothing since the data will never be read.

    Then how could I store it somehow in the creeper entity?

  3. 7 hours ago, ChampionAsh5357 said:

    Would you happen to be able to show your code? This is a very general statement. You should only need to store the UUID of the player.

     

    Quote

    public static void onPlayerInteractEvent(PlayerInteractEvent.EntityInteract interactEvent)
        {
            Entity interactee = interactEvent.getTarget();
            if (interactee instanceof CreeperEntity)
            {
                if (interactEvent.getItemStack().getItem() == Items.FLINT_AND_STEEL)
                {
                    CompoundNBT nbts = interactee.writeWithoutTypeId(new CompoundNBT());
                    nbts.putString("id", interactee.getEntityString());
                    UUID interactor = PlayerEntity.getUUID(interactEvent.getPlayer().getGameProfile());
                    nbts.putUniqueId("ignitorUUID", interactor);
                    ((CreeperEntity)interactee).readAdditional(nbts);
                }
            }
        }
        
        public static void onKillEvent(LivingDeathEvent deathEvent)
        {
            Entity srcEnt = deathEvent.getSource().getTrueSource();
            if (srcEnt instanceof CreeperEntity)
            {
                //check if srcEnt has the tag with a value and then give an advancement to the 'ignitor';
            }
        }

    Tried with multiple read/write fns but whenever I got the data per cmd I always got nothing

  4. 4 hours ago, ChampionAsh5357 said:

    PlayerInteractEvent#EntityInteract with some clever usage of a capability on the creeper probably would work.

    Im attempting that but I can not save who did it. I need to have the 'igniter' during the entity death event. For some reason Im unable to add a NBT tag for this

  5. Hey all,

    I'd love to have a Creeper keep track of who ignited it (Flint & Steel), but to do that Im pretty sure I'd have to edit how Creepers work, right? Correct me if Im wrong here ofc, but if there aint any way, how would one exactly edit a mob's class?

  6. Would help me a lot if render(...) in HeadLayer:

    Quote

    else if (!(item instanceof ArmorItem) || ((ArmorItem)item).getEquipmentSlot() != EquipmentSlotType.HEAD) {
                float f2 = 0.625F;
                matrixStackIn.translate(0.0D, -0.25D, 0.0D);
                matrixStackIn.rotate(Vector3f.YP.rotationDegrees(180.0F));
                matrixStackIn.scale(0.625F, -0.625F, -0.625F);
                if (flag) {
                   matrixStackIn.translate(0.0D, 0.1875D, 0.0D);
                }

                Minecraft.getInstance().getFirstPersonRenderer().renderItemSide(entitylivingbaseIn, itemstack, ItemCameraTransforms.TransformType.HEAD, false, matrixStackIn, bufferIn, packedLightIn);
             }

    had some kind of prevention available, such as a new method in IForgeItem that prevents this from rendering too, something like boolean shouldRenderOnHead() with a default return value of true but could be changed

  7. Bump
    Alright maybe more info is needed;
    My Item  is a Block that you can place in the world, but also equipable on the head. It uses an ISTER (ItemStackTileEntityRegister) and as with all blocks/items it displays on your head. Due to the fact that I am using an LivingEntRenderer and a Layer, like the Elytra, Head or HeldItem it displays it twice, the actual Layer that  I want and the displayed Item/Block which is unwanted. I'd like to get rid of that display, but I dont know how to.

    On the other hand, whenever I equip the item, lags seem to spike, I believe this is due to the fact that the renderEvent happens constantly which adds infinite layers. If it would be possible to get the Layer data, which its not since it has not a get() and it's protected, this wouldnt be a problem. Is there any way to add the layer otherwise or should I look into a different method? I'd prefer not to have to make 20 BipedModel extensions for all the forms the Item has and use the ModelBases

  8. Hey all,
    Im currently trying to make a special armor using an Entity Layer (Long Story/Short, it uses a Tile Ent renderer and I want to display that, and I kinda dont wanna make a new BipedModel extension for all the models it uses...) and it all works super well, but the Item still displays on the head for some reason, resulting in the proper one (The Layer) and the other one (The Item in its block state) to show...
    Is there a way to force stop it from rendering on the Head? Or do I have to scrap the Entity Layer idea and go with a different way?

    Also, is it possible to make the Event only add the layer once? Im pretty sure with this:

    Quote

    private static Class<?>[] armorWearers =
        {
            ClientPlayerEntity.class,
            DrownedEntity.class,
            GiantEntity.class,
            HuskEntity.class,
            SkeletonEntity.class,
            StrayEntity.class,
            PlayerEntity.class,
            WitherSkeletonEntity.class,
            ZombieEntity.class,
            ZombiePigmanEntity.class,
            ZombieVillagerEntity.class,
        };
        
        public static void onLivingRender(final RenderLivingEvent.Post<?, ?> renderLivingEvent)
        {
            LivingEntity entity = renderLivingEvent.getEntity();
            LivingRenderer<?, ?> entityRenderer = renderLivingEvent.getRenderer();
            for (Class<?> entityClass : armorWearers)
            {
                if (entity.getClass() == entityClass)
                {
                    if (entity.isAddedToWorld())
                    {
                        JustAnotherHeadMod.LOGGER.info("PUSH FOR " + entity.getClass().toString());
                        entityRenderer.addLayer(new AnotherHeadLayer(entityRenderer));
                    }
                }
            }
        }

    It's generating more than 1 of these layers, creating lag when you wear it on your head

  9. 27 minutes ago, DavidM said:

    All loot should be added via loot table. This makes it data pack friendly, as the owner of a world save can alter the content.

    Modding has been increasingly datapack oriented (i.e. crafting recipes, block drops, mob drops, etc).

    Yeah sure, but if another modder or res pack alters the vanilla entities loot table as well then either my changes will become redundant or theirs will... (Depends what loads last I guess) I want to avoid that...

  10. Heyo, again... again y'all wonderful people,

    So I wanted to edit an Entity's Loot Table to include a new item, but I noticed that the way you do it is very Mod/Resource Pack unfriendly if they change the mob's loot table too... Is there any other way that's more Mod/Resource Pack Friendly or should I just hope that nobody uses a Res Pack or another Mod that edits the entity's loot table?

  11. 1 minute ago, Animefan8888 said:

    The log methods not logging is an identifier that the method isn't running at all. Which means you didn't register it correctly. How did you register it.

     

    3 minutes ago, Fuffles said:

    //[...]
    public static final Logger LOGGER = LogManager.getLogger();
    public static IEventBus MOD_EVENT_BUS;

    public FuffledKitchenMod() 
        {
            MOD_EVENT_BUS = FMLJavaModLoadingContext.get().getModEventBus();
            
            MOD_EVENT_BUS.addListener(Entities::onCreeperExplosion);
    //[...]

     

  12. So hey, again,
    Im trying to drop a certain item when a creeper explodes around a pig, so I wanted to use an event for that, here's the code.
     

    Quote

    //[...]
    public static final Logger LOGGER = LogManager.getLogger();
    public static IEventBus MOD_EVENT_BUS;

    public FuffledKitchenMod() 
        {
            MOD_EVENT_BUS = FMLJavaModLoadingContext.get().getModEventBus();
            
            MOD_EVENT_BUS.addListener(Entities::onCreeperExplosion);
    //[...]

    Quote

    //[...]
    public class Entities 
    {
        public static void onCreeperExplosion(LivingDeathEvent deathEvent)
        {
            
            FuffledKitchenMod.LOGGER.info("Mob Drop.");
            if (deathEvent.getEntityLiving() instanceof PigEntity)
            {
                FuffledKitchenMod.LOGGER.info("Is Pig, yes!");
                Entity entity = deathEvent.getSource().getTrueSource();
                if (entity instanceof CreeperEntity) 
                {
                    FuffledKitchenMod.LOGGER.info("Source is Creeper, yes!");
                    FuffledKitchenMod.LOGGER.info("Can drop item, did it drop?");
                    deathEvent.getEntityLiving().entityDropItem(Items.BACON); //Item exists, that's certain
                }
            }
        }
    }


    Ofc it doesn't work... unsure why, neither does the Logger Log anything... Please just tell me how stupid I am with this

  13. 8 hours ago, Animefan8888 said:

    Yes there is. You must also have an ItemStackTileEntityRenderer and you must bind it to your item via Item.Properties::setISTER

    Oh, thanks! This really helps a ton ❤️ If I may ask, what does the setISTER(Supplier<Callable<ItemStackTileEntityRenderer>> ister) exactly want? The amount of bracketing for it is kinda confusing

  14. Hello again,
    Im making a block that uses tile entities as well as tile entity rendering to make it visible in the world, whenever I place it down, it clearly works, its all visible and is perfect. Yet the issue comes from the Item for this block, it doesn't render for some reason. I've tried to use builtin/entity to make it easier on myself instead of making a few models. Im unsure what to do, is there some kind of hook that I need to use to make it know to use the TileEntityRender for rendering? Or does builtin/entity simply not support TileEntityRenderers? As a reference point I used Skulls, since they were quite close to what I was after and Im using p. much the same TileEntityRender methods from it

  15. Hey all,

    it's been a while since I've last modded this game and Im kinda struggling, Im trying to register a Tile Entity and then attach it to a block. Unsure if the way Im doing this is outdated, wrong or what, but enough babblin', here's the code.
    (Items and Blocks all work, its just when I try to meddle with the Tile Ent stuffs)

    Main File

    Quote

    // ...
        public static CookieJarMod instance;
     

        public CookieJarMod() 
        {
            final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
            modEventBus.addListener(this::setup);
            modEventBus.addListener(this::doClientStuff);
            
            instance = this;
            
            MinecraftForge.EVENT_BUS.register(this);
        }

        private void setup(final FMLCommonSetupEvent event)
        {
        }

        private void doClientStuff(final FMLClientSetupEvent event) 
        {
            ClientRegistry.bindTileEntityRenderer(/*unsure what to do here... JAR_TILE_ENT is a ? while this needs a specific one*/, JarContainerTileEntityRenderer::new);
        }
     

    @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
        public static class RegistryEvents 
        {
            @SubscribeEvent
            public static void registerItems(final RegistryEvent.Register<Item> event) 
            {
                event.getRegistry().registerAll(
                    ObjectList.DEBUG_STAR, //First Item Test, remove later
                    ObjectList.COOKIE_JAR_ITEM
                );
            }
            
            @SubscribeEvent
            public static void registerBlocks(final RegistryEvent.Register<Block> event)
            {
                event.getRegistry().registerAll(
                    ObjectList.COOKIE_JAR
                );
            }
            
            @SubscribeEvent
            public static void onTileEntitiesTypeRegistry(final RegistryEvent.Register<TileEntityType<?>> event) 
            {
                event.getRegistry().registerAll(
                    ObjectList.JAR_TILE_ENT
                );
            }
        }

    ObjectList

    Quote

    // ...
    public class ObjectList 
    {
        // ...
        private static final Block JAR_TILE_ENT_TILES[] = new Block[] 

        {
            ObjectList.COOKIE_JAR
        };
        public static TileEntityType<?> JAR_TILE_ENT = TileEntityType.Builder.create(JarContainerTileEntity::new, ObjectList.JAR_TILE_ENT_TILES).build(null);
    }


     

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.