Parcival Posted September 10, 2022 Share Posted September 10, 2022 This is the code for the custom item entity: Spoiler public class CustomItemEntity extends ItemEntity { public CustomItemEntity(Level pLevel, double pPosX, double pPosY, double pPosZ, ItemStack pItemStack) { super(pLevel, pPosX, pPosY, pPosZ, pItemStack); FireCases.LOGGER.info("new Entity from constructor"); } @Override public void setInvulnerable(boolean pIsInvulnerable) { FireCases.LOGGER.info("setInvulnerable is used"); super.setInvulnerable(true); } @Override public boolean isInvulnerable() { FireCases.LOGGER.info("isInvulnerable was checked"); return true; } @Override public boolean isInvulnerableTo(DamageSource pSource) { FireCases.LOGGER.info("checked isVulnerableTo"); return super.isInvulnerableTo(pSource) || pSource.isFire(); } @Override public void lavaHurt() { } @Override public boolean hurt(DamageSource pSource, float pAmount) { if (pSource.isFire()) { return false;} return super.hurt(pSource, pAmount); } } This is the code for handling the spawning of the custom entity: Spoiler public class EntityJoinWorldEventSubscriber { @SubscribeEvent() public static void onEntityJoinWorld(EntityJoinWorldEvent event) { Entity entity = event.getEntity(); if (entity.getClass().equals(ItemEntity.class)) { ItemStack entityItemStack = ((ItemEntity) entity).getItem(); CompoundTag compoundTag = entityItemStack.getOrCreateTag(); if (compoundTag.getBoolean("fireResistant")) { Entity newEntity = new CustomItemEntity(entity.getLevel(), entity.getX(), entity.getY(), entity.getY(), entityItemStack); var executor = LogicalSidedProvider.WORKQUEUE.get(event.getWorld().isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER); executor.tell(new TickTask(0, () -> event.getWorld().addFreshEntity(newEntity))); FireCases.LOGGER.info("spawned new entity from subscriber"); } } } } The log only shows that the "subscriber" method spawned a new entity using the custom constructor. If I throw the item into fire or lava, none of the "logger infos" from any of the methods exept the constructor and the subscriber class appear. Also, the item disappears like it normally should. My conclusion is that my custom constructor is used, but any of the overridden methods are not used, but replaced with vanilla ones. My goal is to make the ItemEntity invulnerable to fire or lava. Quote Link to comment Share on other sites More sharing options...
warjort Posted September 10, 2022 Share Posted September 10, 2022 On your previous thread, I told you to look at this: https://github.com/MinecraftForge/MinecraftForge/blob/73c1934e7ef931bafbafd0ceb6dce4cdd5dc02a2/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java#L36 That method discards the old entity and cancels the event to stop the original item entity spawning. Without that, what you are seeing getting destroyed is the old ItemEntity. Why you can't see your new entity I can't say. You don't show all the relevant information, e.g. your entity type registration or the log. You should be able to detect to see if your entity is getting spawned by adding a log statement to the top of your event handler. Quote Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post. Link to comment Share on other sites More sharing options...
warjort Posted September 10, 2022 Share Posted September 10, 2022 super(pLevel, pPosX, pPosY, pPosZ, pItemStack); You can't use this constructor. It will use the vanilla EntityType Quote Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.