• Recently Browsing

    No registered users viewing this page.

  • Posts

    • Hi   I got this item that stores a single stack of something else, and a glass variant of it should render the stack inside, but according to the docs I just need to set the renderer on the item and it should work but as far as I can see nothing happens, not even the console prints anything:   ItemSingleStackGlassContainer.java public class ItemSingleStackGlassContainer extends ItemSingleStackContainer { public ItemSingleStackGlassContainer(String name, float isolation, int tint) { super(new Item.Properties().setTEISR(() -> SingleStackGlassContainerItemRender::new),name,isolation,tint); } ... }   The superclass: ItemSingleStackContainer.java public class ItemSingleStackContainer extends Item { public static final ResourceLocation open = new ResourceLocation(Reference.MODID,"open"); private final float isolation; private final int tint; private static short failedToOpen = 0; private boolean isOpen = false; public ItemSingleStackContainer(Item.Properties properties,String name, float isolation, int tint) { super(properties.maxStackSize(1).group(ItemGroup.TOOLS)); if (isolation < 0 || isolation > 1) throw new IllegalArgumentException("Can only be between 0 and 1!"); addPropertyOverride(open,(itemStack, worldIn, entityLivingBase) -> isOpen ? 1 : 0); this.isolation = isolation; this.tint = tint; setRegistryName(name); } public static ItemStack getContainedItemStack(ItemStack stack) { IItemHandler handler = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElseThrow(NullPointerException::new); return handler.getStackInSlot(0); } ... }   The renderer that should just render the stack somewhere visible on the camera for now and print out to the console: SingleStackGlassContainerItemRender.java @OnlyIn(Dist.CLIENT) public class SingleStackGlassContainerItemRender extends ItemStackTileEntityRenderer { @Override public void renderByItem(ItemStack itemStackIn) { System.out.println("Rendering it I guess."); // Doesn't get printed out to the console. if (itemStackIn.getItem() instanceof ItemSingleStackGlassContainer) { ItemStack itemStack = ItemSingleStackContainer.getContainedItemStack(itemStackIn); if (itemStack != ItemStack.EMPTY) { GlStateManager.pushMatrix(); Minecraft.getInstance().getItemRenderer().renderItem(itemStack, ItemCameraTransforms.TransformType.FIXED); GlStateManager.popMatrix(); } } } }  
    • Well aren't I the stupid idiot! Much appreciated for your time! ❤️
    • You are missing a mod that LittleTiles depends on, please re-read the mod’s CurseForge page
    • @LexManos I think I've made a lot more concise!!!!   package jetcobblestone.firstmod; import jetcobblestone.firstmod.lists.itemList; import net.minecraft.item.Foods; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.util.ResourceLocation; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) public class ItemsLoader { @SubscribeEvent public static void registerItems(final RegistryEvent.Register<Item> event) { event.getRegistry().registerAll ( itemList.hair_fibre = new Item(new Item.Properties().food(Foods.COOKIE).group(ItemGroup.FOOD).maxStackSize(1)).setRegistryName(location("hair_fibre")) ); } private static ResourceLocation location(String name) { return new ResourceLocation(FirstMod.modid, name); } }   I didn't realise you could have the @Mod.EventBus... outside of a class, but I understand now that it's meant to go outside a class, thanks to your reply   Also I think you have a few haters     Don't know why though... you've been really helpful   Also, do you have any suggested improvements? Like for efficiency or smmin. For example I don't know if there is a better way to do that helper method at the end, or if it's even advised. I'm really happy I got this to work without copying code straight from a tutorial! I'm now really excited for this, as it will be really easy to navigate in the future. Again, is it advised to separate everything into different classes for efficiency? It certainly makes code easier to navigate.   Edit: I only just realised ur the guy who makes forge lmao   Really nice to see somebody so high up in the community help on small posts like this one!
    • I have good python knowledge and watched about 20 episodes of a good java tutorial, however I don't know I watched enough to get onto important things like class structure etc. I was hoping that it would mainly be different syntax, and a lot of it is. However, what I have found is that java is quite different. It's been very frustrating, but I feel like I'm learning a lot about java but also how minecraft and mc mods work by trying to make a modpack - something I've always wanted to do. I agree that there are quite a lot of confusions, but I'm knocking them out one by one and the response I've had on these forums has been really encouraging and helpful.
  • Topics

  • Who's Online (See full list)