Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Raddari

Members
  • Joined

  • Last visited

Everything posted by Raddari

  1. So I managed to solve it. I was using Choonster's TestMod3 for reference. However, I did not have the @MethodsReturnNonnullByDefault applied to the InjectionUtil class, which contains the Null() method. Adding in this annotation stopped the crashes, so I'm assuming it was a problem with the compiler itself rather than the item actually being null. Thank you, Raddari
  2. Hello, I am having great difficulties trying to render a custom, 2D entity - pretty much exactly like a snowball. Seeing as I want it to render and behave like a snowball, I figured that I would instantiate the RenderSnowball class to render my own entity, as the class accepts subclasses of Entity. However, when I spawn it in by right clicking with an item, the game crashes with a NullPointerException. Now, looking through the crash report in the console, one line immediately stands out: -- Head -- Thread: Client thread Stacktrace: at net.minecraft.client.renderer.entity.RenderSnowball.doRender(RenderSnowball.java:46) As line 46 involves rendering an ItemStack, I assumed that I passed in an Item incorrectly into the constructor for the RenderSnowball. IntelliJ warns me that ModItems::PING_PONG_BALL might be null, but I thought that this was to be expected as a result of using @ObjectHolder annotations. So, do I need to give the constructor my ItemPingPongBall from the GameRegistry instead? Or is there something else going on here that I am completely overlooking? All relevant classes can be found below, and a crash log is attached. ClientProxy: public class ClientProxy{ public void preInit(){ ModRenderers.register(); } public void init(){ } public void postInit(){ } } ModRenderers: public final class ModRenderers{ private static RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); public static void register(){ RenderingRegistry.registerEntityRenderingHandler(EntityPingPongBall.class, renderManager -> new RenderSnowball<>(renderManager, ModItems.PING_PONG_BALL, renderItem)); } } ModItems: @ObjectHolder(RaddariMod.MOD_ID) public final class ModItems{ @ObjectHolder("pingpong_ball") public static final ItemPingPongBall PING_PONG_BALL = Null(); @Mod.EventBusSubscriber(modid = RaddariMod.MOD_ID) public static class RegistrationHandler{ public static final Set<Item> ITEMS = new HashSet<>(); @SubscribeEvent public static void registerItems(RegistryEvent.Register<Item> event){ final Item[] items = { new ItemPingPongBall(), }; final IForgeRegistry<Item> registry = event.getRegistry(); for(Item item : items){ registry.register(item); ITEMS.add(item); } } } } ModEntities: @ObjectHolder(RaddariMod.MOD_ID) public final class ModEntities{ @ObjectHolder("pingpong_ball") public static final EntityEntry PING_PONG_BALL = Null(); @Mod.EventBusSubscriber(modid = RaddariMod.MOD_ID) public static class RegistrationHandler{ @SubscribeEvent public static void registerEntities(RegistryEvent.Register<EntityEntry> event){ final EntityEntry[] entities = { createBuilder("pingpong_ball") .entity(EntityPingPongBall.class) .tracker(32, 20, true) .build(), }; final IForgeRegistry<EntityEntry> registry = event.getRegistry(); registry.registerAll(entities); } private static int entityID = 0; private static <E extends Entity> EntityEntryBuilder<E> createBuilder(String name){ EntityEntryBuilder<E> builder = EntityEntryBuilder.create(); ResourceLocation registryName = new ResourceLocation(RaddariMod.MOD_ID, name); return builder.id(registryName, entityID++).name(registryName.toString()); } } } And finally, ItemRaddari, which my ItemPingPongBall class extends: public class ItemRaddari extends Item{ public ItemRaddari(String registryName){ if(StringHelper.hasContent(registryName)){ ItemRaddari.setItemName(this, registryName); }else{ throw new RuntimeException("Item " + this.getClass().getName() + " has an invalid name!"); } } private static void setItemName(Item item, String registryName){ item.setRegistryName(RaddariMod.MOD_ID, registryName); item.setUnlocalizedName(item.getRegistryName().toString()); //System.out.println(String.format("Item name assigned: [%s] [%s} [%s]", item.getClass().getName(), item.getRegistryName(), item.getUnlocalizedName())); } } Thank you, Raddari crash-2018-02-04_16.47.57-client.txt
  3. Got it, thank you for your help
  4. Thank you for the reply, For clarification, does this mean that I should modify location.posX, location.posY and location.posZ in the method createEntity using values from location.getPositionVector()?
  5. Hello, I have created an Item named "Potassium" which extends the Item class. I have overridden the methods Item#hasCustomEntity and Item#createEntity in order for it to drop a custom EntityItem. In full, the class appears as below: This EntityItem will explode and delete itself when it touches water, and the code for the EntityItemPotassium class appears as below: The item works as intended, and when thrown into water, it explodes and removes itself as required. However, when the item is dropped by pressing 'Q' or dragged and dropped outside of the inventory, it drops randomly around the player as if it were dropped from a block, rather than dropped by the player. I have added lines which print the motion in which the item is dropped, and the results from 20 drops are in the spoiler below: It appears that the item is always dropped as if it were dropped from the block, but I am unable to find reference code that differentiates between a player throwing an item and a block dropping an item within the EntityItem class. I feel like I'm missing something very obvious here, so any help would be gladly appreciated.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.