Jump to content

sanman00

Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by sanman00

  1. @diesieben07 Thanks, that helped. It turns out that that annotation needed to be added to the entity class: @OnlyIn( value = Dist.CLIENT, _interface = IRendersAsItem.class ) public class EntityExplosivePotion extends ThrowableEntity implements IRendersAsItem { // ... }
  2. I have an entity that implements IRendersAsItem so that it can be used with SpriteRenderer. However, when this entity is registered, it causes the server (but not the client) to crash with a NoClassDefFoundError saying that it cannot find this interface (which makes sense since it is annotated to indicate that it can only be loaded on the client). I could remove the entity's implementation of IRendersAsItem and replace how it is currently rendered with an emulation of SpriteRenderer but I'm not sure if this would the correct way to solve this issue. Current implementation of entity class: public class EntityExplosivePotion extends ThrowableEntity implements IRendersAsItem { public EntityExplosivePotion(EntityType<? extends ThrowableEntity> type, World worldIn) { super(type, worldIn); } @Override public ItemStack getItem() { return new ItemStack(this.isSpicy() ? ModItems.SPICY_THROWABLE_EXPLOSIVE_POTION : ModItems.THROWABLE_EXPLOSIVE_POTION); } @Override public IPacket<?> createSpawnPacket() { return NetworkHooks.getEntitySpawningPacket(this); } } Registration of entity: @EventBusSubscriber(modid = Main.MOD_ID, bus = EventBusSubscriber.Bus.MOD) class ModSetup { @SubscribeEvent static void registerEntities(RegistryEvent.Register<EntityType<?>> event) { event.getRegistry().register(EntityType.Builder.<EntityExplosivePotion>create(EntityExplosivePotion::new, EntityClassification.MISC) .size(0.25f, 0.25f).setTrackingRange(2).setUpdateInterval(5).setShouldReceiveVelocityUpdates(true) .build(ModUtil.qualify(ModUtil.THROWABLE_EXPLOSIVE_POTION_NAME)).setRegistryName(ModUtil.qualify(ModUtil.THROWABLE_EXPLOSIVE_POTION_NAME))); } } Registration of entity renderer: @EventBusSubscriber(modid = Main.MOD_ID, value = {Dist.CLIENT}, bus = EventBusSubscriber.Bus.MOD) public class ClientProxy { @SubscribeEvent public static void init(FMLClientSetupEvent event) { RenderingRegistry.registerEntityRenderingHandler(EntityExplosivePotion.class, m -> new SpriteRenderer<>(m, Minecraft.getInstance().getItemRenderer())); } } Here is my latest.log file: https://pastebin.com/19uFbBQb
  3. I have managed to solve the issue. It appears to have been fixed by replacing default values in places like build.gradle and mods.toml (e.g. "examplemod") with the proper values, such as the mod ID.
  4. The TranslationTextComponent version? It's still not translating it for me. It seems that the key is not being registered as I18n.hasKey() returns false for it but not for the other keys defined in the same file. Here is a log containing the value of Locale.properties field which appears to hold the translations of the game and mod: https://pastebin.com/63kmzHDx
  5. I am trying to add lore to my potion items indicating their strength which determines the size of their explosions.This strength value is an integer between 1 and 10. I want this lore to be translatable and so have provided a key for it at the bottom of my en_us.json file: { "item.expotions.potion_explosive" : "Explosive Potion", "item.expotions.potion_explosive_throwable" : "Throwable Explosive Potion", "item.expotions.potion_explosive_spicy" : "Spicy Explosive Potion", "item.expotions.potion_explosive_throwable_spicy" : "Throwable Spicy Explosive Potion", "entity.expotions:potion_explosive_throwable" : "Throwable Explosive Potion", "death.attack.potion_explosive_throwable" : "%1$s has been killed by an exploding potion", "itemGroup.expotions" : "Explosive Potions", "tooltip.expotions.strength" : "Strength: %1$s" } The lore is added to an itemstack with the below code (which is called by the addInformation() method): public static void addTooltip(ItemStack stack, List<ITextComponent> tooltip) { tooltip.add(new TranslationTextComponent("tooltip.expotions.strength", getStrength(stack)).applyTextStyle(TextFormatting.GRAY)); } The problem with this code is that, while the styling is applied, the text is not translated and the key is displayed instead: https://imgur.com/0JhOqye If a StringTextComponent is used instead, the lore is displayed correctly: public static void addTooltip(ItemStack stack, List<ITextComponent> tooltip) { tooltip.add(new StringTextComponent("Strength: " + getStrength(stack)).applyTextStyle(TextFormatting.GRAY)); } https://imgur.com/MHlyXyy Since the lore should be translatable, the second version of this function is not acceptable as is. But the first version does not work and I am not sure what's gone wrong with it. My most recent latest.log file is here: https://pastebin.com/bjhHj4ny
  6. I am trying to make an entity which works and renders in a similar fashion to a splash potion. It is defined thus: https://pastebin.com/edkgrnYW To render it, I am using the SpriteRenderer class like so: @EventBusSubscriber(modid = Main.MOD_ID, value = {Dist.CLIENT}, bus = EventBusSubscriber.Bus.MOD) public class ClientProxy { @SubscribeEvent public static void init(FMLClientSetupEvent event) { RenderingRegistry.registerEntityRenderingHandler(EntityExplosivePotion.class, m -> new SpriteRenderer<>(m, Minecraft.getInstance().getItemRenderer())); //RenderingRegistry.registerEntityRenderingHandler(EntitySpicyExplosivePotion.class, RenderSpicyExplosivePotion::new); getItemModelMesher().register(ModItems.EXPLOSIVE_POTION, new ModelResourceLocation("expotions:potion_explosive", "inventory")); getItemModelMesher().register(ModItems.THROWABLE_EXPLOSIVE_POTION, new ModelResourceLocation("expotions:potion_explosive_throwable", "inventory")); getItemModelMesher().register(ModItems.SPICY_EXPLOSIVE_POTION, new ModelResourceLocation("expotions:potion_explosive_spicy", "inventory")); getItemModelMesher().register(ModItems.SPICY_THROWABLE_EXPLOSIVE_POTION, new ModelResourceLocation("expotions:potion_explosive_throwable_spicy", "inventory")); } /** * Convenience function for getting the {@code ItemModelMesher}. * @return The {@code ItemModelMesher} from {@link RenderItem#getItemModelMesher()} via {@link Minecraft#getItemRenderer()} */ public static ItemModelMesher getItemModelMesher() { return Minecraft.getInstance().getItemRenderer().getItemModelMesher(); } } When the entity is spawned it is spawned like so: EntityExplosivePotion potion = new EntityExplosivePotion(player, world); potion.setStrength(getStrength(stack)); potion.setSpicy(spicy); potion.shoot(player, player.rotationPitch, player.rotationYaw, -20.0F, 0.5F, 1.0F); world.addEntity(potion); The problem that I am having is that the entity is not rendering. It functions but no model appears when it is spawned and no output appears in the log either. The event handler for FMLClientSetupEvent is called but the renderer still does not appear to be registered. Here is a copy of my latest.log: https://pastebin.com/ftE0Ffag
  7. A mod that adds explosive potions to Minecraft! Licence This mod is licensed under the MIT licence. You can freely use it in modpacks. Github https://github.com/sanman00/ExplosivePotions Downloads https://github.com/sanman00/ExplosivePotions/releases
×
×
  • Create New...

Important Information

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