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.

Leronus

Members
  • Joined

  • Last visited

Everything posted by Leronus

  1. I mentioned before my knowledge of Java is basic. I'm currently still in my first year of studying. I have read the doc, but there is a difference in not reading it and not understanding it. I simply don't understand it, English not being my mother language could be the main cause idk. Are there any tutorials going into further detail about how the events work?
  2. I've read the documentation, but it does not clarify things for me. I tried adding the bus annotations but it did not help in any way. This is noted in the Java documentation of the HarvestCheck class: This event is fired whenever a player attempts to harvest a block in EntityPlayer.canHarvestBlock(IBlockState). This event is fired via the ForgeEventFactory.doPlayerHarvestCheck(EntityPlayer, IBlockState, boolean). This event is fired on the MinecraftForge.EVENT_BUS. I can't add subscribe events to constructor methods, but if I don't use the constructor then I can't call the setCanHarvest method in the HarvestCheck class. Could you please clarify how to create your own event and have it override an existing one? I don't comprehend the Forge documentation as is...
  3. How do I go about doing this? public class HarvestLevel extends PlayerEvent.HarvestCheck { private boolean isHarvestable = true; public HarvestLevel(PlayerEntity player, BlockState state, boolean success) { super(player, state, success); if (player.getMainHandItem().getItem() == Items.DIAMOND_PICKAXE){ if (super.getTargetBlock().getHarvestLevel() <= 5){ success = isHarvestable; } } super.setCanHarvest(success); } } This is what I've tried so far, but I'm not sure where to implement this class...
  4. Without any context this does not make any sense to me... How can I possibly change a value of a vanilla TieredItem (in this case diamond_pickaxe) by using a method that checks whether a block can be harvested?
  5. I would like to change the harvestLevels of the diamond pickaxe and iron pickaxe. How would I go about doing this? I tried to look at the item property changer mods source code, but I honestly didn't quite comprehend what was happening there. My knowledge of Java is very basic, so that's why I've struggled finding a good solution for this. Still in my first year of studying and experimenting with Java. I am modding for Minecraft 1.16.5
  6. package mod.mores.objects.blocks.machines; import mod.mores.init.BlockInit; import mod.mores.util.Reference; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemHoe; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraft.item.ItemTool; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemStackHandler; import java.util.ArrayList; public class TileEntityAlloyFurnace extends TileEntity implements ITickable { private ItemStackHandler inventory = new ItemStackHandler(NonNullList.withSize(4, ItemStack.EMPTY)); private String customName; private ItemStack smelting = ItemStack.EMPTY; private static final String BURNTIME_KEY = "BurnTime"; private static final String COOKTIME_KEY = "CookTime"; private static final String COOKTIMETOTAL_KEY = "CookTimeTotal"; private static final String INVENTORY_KEY = "inventory"; private static final String CUSTOMNAME_KEY = "CustomName"; public static final int INPUT_LEFT = 0; public static final int INPUT_RIGHT = 1; public static final int INPUT_FUEL = 2; public static final int OUTPUT = 3; public int burnTime = 0; public int currentBurnTime = 0; public int cookTime = 0; public int totalCookTime = 600; public TileEntityAlloyFurnace() { Reference.LOGGER.info("TileEntity is successfully bound to a block"); } @Override public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState) { return (oldState.getBlock() != newState.getBlock()); } @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { // TODO Auto-generated method stub if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return true; return super.hasCapability(capability, facing); } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { // TODO Auto-generated method stub if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return (T) this.inventory; return super.getCapability(capability, facing); } public boolean hasCustomName() { return customName != null && !customName.isEmpty(); } public void setCustomName(String customname) { this.customName = customname; } @Override public ITextComponent getDisplayName() { return this.hasCustomName() ? new TextComponentString(this.customName) : new TextComponentTranslation("container.alloy_furnace"); } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); this.inventory.deserializeNBT(compound.getCompoundTag(INVENTORY_KEY)); burnTime = compound.getInteger(BURNTIME_KEY); cookTime = compound.getInteger(COOKTIME_KEY); totalCookTime = compound.getInteger(COOKTIMETOTAL_KEY); currentBurnTime = getItemBurnTime((ItemStack) inventory.getStackInSlot(1)); if (compound.hasKey(CUSTOMNAME_KEY, 8)) setCustomName(compound.getString(CUSTOMNAME_KEY)); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setInteger(BURNTIME_KEY, (short) burnTime); compound.setInteger(COOKTIME_KEY, (short) cookTime); compound.setInteger(COOKTIMETOTAL_KEY, (short) totalCookTime); compound.setTag(INVENTORY_KEY, this.inventory.serializeNBT()); if (hasCustomName()) compound.setString(CUSTOMNAME_KEY, customName); return compound; } public boolean isBurning() { return burnTime > 0; } @SideOnly(Side.CLIENT) public static boolean isBurning(TileEntityAlloyFurnace te) { return te.burnTime > 0; } public static void setState(boolean active, World worldIn, BlockPos pos) { IBlockState state = worldIn.getBlockState(pos); TileEntity tileentity = worldIn.getTileEntity(pos); if (active) worldIn.setBlockState(pos, BlockInit.ALLOY_FURNACE.getDefaultState() .withProperty(BlockAlloyFurnace.FACING, state.getValue(BlockAlloyFurnace.FACING)).withProperty(BlockAlloyFurnace.BURNING, true), 1 | 2); else worldIn.setBlockState(pos, BlockInit.ALLOY_FURNACE.getDefaultState() .withProperty(BlockAlloyFurnace.FACING, state.getValue(BlockAlloyFurnace.FACING)).withProperty(BlockAlloyFurnace.BURNING, false), 1 | 2); if (tileentity != null) { tileentity.validate(); worldIn.setTileEntity(pos, tileentity); } } @Override public void update() { boolean wasBurning = isBurning(); boolean flag1 = false; if(this.isBurning()) { --this.burnTime; setState(true, world, pos); } ItemStack[] inputs = new ItemStack[] {inventory.getStackInSlot(INPUT_LEFT), inventory.getStackInSlot(INPUT_RIGHT)}; ItemStack fuel = this.inventory.getStackInSlot(INPUT_FUEL); if(this.isBurning() || !fuel.isEmpty() && !this.inventory.getStackInSlot(INPUT_LEFT).isEmpty() || !this.inventory.getStackInSlot(INPUT_RIGHT).isEmpty()) { if(!this.isBurning() && this.canSmelt()) { this.burnTime = getItemBurnTime(fuel); this.currentBurnTime = burnTime; if(this.isBurning() && !fuel.isEmpty()) { Item item = fuel.getItem(); fuel.shrink(1); if(fuel.isEmpty()) { ItemStack item1 = item.getContainerItem(fuel); this.inventory.setStackInSlot(2, item1); } } } } if(this.isBurning() && this.canSmelt() && cookTime > 0) { cookTime++; if(cookTime == totalCookTime) { if(inventory.getStackInSlot(3).getCount() > 0) { inventory.getStackInSlot(3).grow(1); } else { inventory.insertItem(3, smelting, false); } smelting = ItemStack.EMPTY; cookTime = 0; return; } } else { if(this.canSmelt() && this.isBurning()) { ItemStack output = AlloyFurnaceRecipes.getInstance().getAlloyResult(inputs[0], inputs[1]); if(!output.isEmpty()) { smelting = output; cookTime++; inputs[0].shrink(1); inputs[1].shrink(1); inventory.setStackInSlot(0, inputs[0]); inventory.setStackInSlot(1, inputs[1]); } } } } private boolean canSmelt() { if (((ItemStack) inventory.getStackInSlot(INPUT_LEFT)).isEmpty() || ((ItemStack) inventory.getStackInSlot(INPUT_RIGHT)).isEmpty()) return false; else { ItemStack result1 = AlloyFurnaceRecipes.getInstance().getAlloyResult((ItemStack) inventory.getStackInSlot(INPUT_LEFT), (ItemStack) inventory.getStackInSlot(INPUT_RIGHT)); if (result1.isEmpty()) return false; else { ItemStack fuel = (ItemStack) inventory.getStackInSlot(INPUT_FUEL); ItemStack output = (ItemStack) inventory.getStackInSlot(OUTPUT); if(output.isEmpty()) return true; if(!output.isItemEqual(result1)) return false; int res1 = output.getCount() + result1.getCount(); int res2 = fuel.getCount() + 1; return (res1 <= 64 && res1 <= output.getMaxStackSize()) || (res2 <= 64 && res2 <= fuel.getMaxStackSize()); } } } public static int getItemBurnTime(ItemStack fuel) { if (fuel.isEmpty()) return 0; else { Item item = fuel.getItem(); if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.AIR) { Block block = Block.getBlockFromItem(item); if (block == Blocks.WOODEN_SLAB) return 100; if (block == Blocks.ACACIA_STAIRS || block == Blocks.OAK_STAIRS || block == Blocks.JUNGLE_STAIRS || block == Blocks.BIRCH_STAIRS || block == Blocks.DARK_OAK_STAIRS || block == Blocks.SPRUCE_STAIRS) return 150; if (block.getDefaultState().getMaterial() == Material.WOOD) return 200; if (block == Blocks.COAL_BLOCK) return 14400; } if (item instanceof ItemTool && "WOOD".contentEquals(((ItemTool) item).getToolMaterialName())) return 180; if (item instanceof ItemSword && "WOOD".contentEquals(((ItemTool) item).getToolMaterialName())) return 180; if (item instanceof ItemHoe && "WOOD".contentEquals(((ItemTool) item).getToolMaterialName())) return 180; if (item == Items.STICK) return 50; if (item == Items.COAL) return 1600; if (item == Items.LAVA_BUCKET) return 20000; if (item == Item.getItemFromBlock(Blocks.SAPLING)) return 70; if (item == Items.BLAZE_ROD) return 1600; return ForgeEventFactory.getItemBurnTime(fuel); } } public static boolean isItemFuel(ItemStack fuel) { return getItemBurnTime(fuel) > 0; } public boolean isUsableByPlayer(EntityPlayer player) { return world.getTileEntity(pos) == this && player.getDistanceSq((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D) <= 64.0D; } public boolean isItemValidForSlot(int index, ItemStack stack) { if (index == 2 || index == 3) return false; if (index != 1) return true; else { return isItemFuel(stack); } } public final ArrayList<ItemStack> containerLists() { ArrayList<ItemStack> stackList = new ArrayList(inventory.getSlots()); for (int i = 0; i < inventory.getSlots(); i++) { stackList.add(inventory.getStackInSlot(i)); } return stackList; } public int getField(int id) { switch(id) { case 0: return this.burnTime; case 1: return this.currentBurnTime; case 2: return this.cookTime; case 3: return this.totalCookTime; default: return 0; } } public void setField(int id, int value) { switch(id) { case 0: this.burnTime = value; break; case 1: this.currentBurnTime = value; break; case 2: this.cookTime = value; break; case 3: this.totalCookTime = value; } } /* @Override public NBTTagCompound getUpdateTag() { return writeToNBT(new NBTTagCompound()); } */ /* @Override public SPacketUpdateTileEntity getUpdatePacket() { return null; } */ } package mod.mores.objects.blocks.machines; import mod.mores.init.BlockInit; import mod.mores.init.ItemInit; import mod.mores.modid.Mores; import mod.mores.objects.BlockBase; import mod.mores.particle.FlameParticle; import mod.mores.particle.ParticleCustom; import mod.mores.util.Reference; import net.minecraft.block.Block; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.Particle; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemBucket; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidActionResult; import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fluids.UniversalBucket; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.CapabilityItemHandler; import java.util.Random; public class BlockAlloyFurnace extends Block { public static final PropertyDirection FACING = BlockHorizontal.FACING; public static final PropertyBool BURNING = PropertyBool.create("burning"); public BlockAlloyFurnace(String name, Material material, CreativeTabs creativeTab) { super(material); setUnlocalizedName(name); setRegistryName(name); setCreativeTab(creativeTab); setSoundType(SoundType.ANVIL); setHardness(5.0f); setResistance(30.0f); setHarvestLevel("pickaxe", 1); setLightLevel(0.0f); // setLightOpacity(1); // setBlockUnbreakable(); this.setDefaultState( this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(BURNING, false)); BlockInit.BLOCKS.add(this); ItemInit.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName())); } @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Item.getItemFromBlock(BlockInit.ALLOY_FURNACE); } @Override public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) { return new ItemStack(BlockInit.ALLOY_FURNACE); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if(!worldIn.isRemote) { playerIn.openGui(Mores.instance, Reference.GUI_ALLOY_FURNACE, worldIn, pos.getX(), pos.getY(), pos.getZ()); } return true; } @Override public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { // TODO Auto-generated method stub if (!worldIn.isRemote) { IBlockState north = worldIn.getBlockState(pos.north()); IBlockState south = worldIn.getBlockState(pos.south()); IBlockState west = worldIn.getBlockState(pos.west()); IBlockState east = worldIn.getBlockState(pos.east()); EnumFacing face = (EnumFacing) state.getValue(FACING); if (face == EnumFacing.NORTH) face = EnumFacing.SOUTH; if (face == EnumFacing.SOUTH) face = EnumFacing.NORTH; if (face == EnumFacing.WEST) face = EnumFacing.EAST; if (face == EnumFacing.EAST) face = EnumFacing.WEST; worldIn.setBlockState(pos, state.withProperty(FACING, face), 2); } } @Override public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) { // TODO Auto-generated method stub return state.getValue(BURNING).booleanValue() ? 15 : 0; } @Override public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { // TODO Auto-generated method stub return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); } @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { // TODO Auto-generated method stub worldIn.setBlockState(pos, this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2); } @Override public IBlockState withRotation(IBlockState state, Rotation rot) { // TODO Auto-generated method stub return state.withProperty(FACING, rot.rotate((EnumFacing) state.getValue(FACING))); } @Override public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { // TODO Auto-generated method stub return state.withRotation(mirrorIn.toRotation((EnumFacing) state.getValue(FACING))); } @Override protected BlockStateContainer createBlockState() { // TODO Auto-generated method stub return new BlockStateContainer(this, new IProperty[] { BURNING, FACING }); } @Override public IBlockState getStateFromMeta(int meta) { // TODO Auto-generated method stub EnumFacing facing = EnumFacing.getFront(meta); if (facing.getAxis() == EnumFacing.Axis.Y) facing = EnumFacing.NORTH; return this.getDefaultState().withProperty(FACING, facing); } @Override public int getMetaFromState(IBlockState state) { // TODO Auto-generated method stub return ((EnumFacing) state.getValue(FACING)).getIndex(); } @Override public boolean hasTileEntity(IBlockState state) { // TODO Auto-generated method stub return true; } @Override public TileEntityAlloyFurnace createTileEntity(World world, IBlockState state) { // TODO Auto-generated method stub return new TileEntityAlloyFurnace(); } @Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { // TODO Auto-generated method stub TileEntity te = worldIn.getTileEntity(pos); if (te instanceof TileEntityAlloyFurnace) { for (ItemStack stack : ((TileEntityAlloyFurnace) te).containerLists()) { spawnAsEntity(worldIn, pos, stack); } } super.breakBlock(worldIn, pos, state); } @SideOnly(Side.CLIENT) @SuppressWarnings("incomplete-switch") public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { if (stateIn.getValue(BURNING)) { EnumFacing enumfacing = (EnumFacing)stateIn.getValue(FACING); double d0 = (double)pos.getX() + 0.5D; double d1 = (double)pos.getY() + rand.nextDouble() * 6.0D / 16.0D; double d2 = (double)pos.getZ() + 0.5D; double d3 = 0.52D; double d4 = rand.nextDouble() * 0.6D - 0.3D; if (rand.nextDouble() < 0.1D) { worldIn.playSound((double)pos.getX() + 0.5D, (double)pos.getY(), (double)pos.getZ() + 0.5D, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false); } switch (enumfacing) { case WEST: worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 - 0.52D, d1, d2 + d4, 0.0D, 0.0D, 0.0D); Particle newEffectWest = new ParticleCustom(new ParticleCustom.TextureDefinition("flame_fx"), worldIn, d0 - 0.52D, d1, d2 + d4, 0.0D, 0.0D, 0.0D); Minecraft.getMinecraft().effectRenderer.addEffect(newEffectWest); break; case EAST: worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + 0.52D, d1, d2 + d4, 0.0D, 0.0D, 0.0D); Particle newEffectEast = new ParticleCustom(new ParticleCustom.TextureDefinition("flame_fx"), worldIn, d0 + 0.52D, d1, d2 + d4, 0.0D, 0.0D, 0.0D); Minecraft.getMinecraft().effectRenderer.addEffect(newEffectEast); break; case NORTH: worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 - 0.52D, 0.0D, 0.0D, 0.0D); Particle newEffectNorth = new ParticleCustom(new ParticleCustom.TextureDefinition("flame_fx"), worldIn, d0 + d4, d1, d2 - 0.52D, 0.0D, 0.0D, 0.0D); Minecraft.getMinecraft().effectRenderer.addEffect(newEffectNorth); break; case SOUTH: worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 + 0.52D, 0.0D, 0.0D, 0.0D); Particle newEffectSouth = new ParticleCustom(new ParticleCustom.TextureDefinition("flame_fx"), worldIn, d0 + d4, d1, d2 + 0.52D, 0.0D, 0.0D, 0.0D); Minecraft.getMinecraft().effectRenderer.addEffect(newEffectSouth); } } } } This is what my code looks like, in case anyone does decide to help The issues I have as of now is that removing the output items freezes all entities and removing an input or fuel will have the Furnace remaining in its burning state Have tried everything I could think of, searched every known 1.12.2 post known to man but to no avail *cries in 1.12.2*
  7. 1.12.2.... I know it's unsupported ;-;
  8. Please share your code.... Having the exact same issues you mentioned but even with those answers I can't figure it out...
  9. Hey guys, I'm new to the forum. I have done some Minecraft modding in the past, specifically on version 1.7.2 I tried to get back into the modding on version 1.12.2 to find that things are (in my opinion) a lot more complicated and difficult. I believe I have done all the file naming right but for some reason the language file (en_us.lang) and the texture for my first item (ruby_gem) won't load. The exception it gives me is that the file is not found. I've tried searching everywhere but can't find out what I did wrong. I may have some bad practice here and there, feel free to correct me on that. But please do it in the most comprehensive way, because simply reading the Forge documentation has got me all dizzy and confused lol. I have basic Java understanding, as in, I know the basics of object oriented programming, but I'm still very new to this. ItemInit: package mod.mores.init; import mod.mores.objects.ItemBase; import net.minecraft.item.Item; import net.minecraft.item.ItemAir; import java.util.ArrayList; import java.util.List; public class ItemInit { public static final List<Item> ITEMS = new ArrayList<Item>(); public static final Item RUBY_GEM = new ItemBase("ruby_gem"); } ItemBase: package mod.mores.objects; import mod.mores.init.ItemInit; import mod.mores.modid.Mores; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; public class ItemBase extends Item { public ItemBase(String name) { setRegistryName(name); setUnlocalizedName(name); setCreativeTab(CreativeTabs.MATERIALS); ItemInit.ITEMS.add(this); } public void registerModels() { Mores.proxy.registerItemRenderer(this, 0, "inventory"); } } Main: package mod.mores.modid; import mod.mores.items.swords.RubySword; import mod.mores.proxy.CommonProxy; import mod.mores.util.Reference; import mod.mores.util.handlers.RegistryHandler; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLServerStartingEvent; @Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION) public class Mores { @Mod.Instance public static Mores instance; @SidedProxy(clientSide = Reference.CLIENT, serverSide = Reference.COMMON) public static CommonProxy proxy; public static ToolMaterial ruby; @EventHandler public void preInit(FMLPreInitializationEvent event) { RegistryHandler.preInitRegistries(); //ToolMaterials ruby = EnumHelper.addToolMaterial("ruby", 3, 1345, 8.0F, 2.5F, 14); } @EventHandler public void init(FMLInitializationEvent event) { RegistryHandler.initRegistries(); } @EventHandler public void postInit(FMLPostInitializationEvent event) { RegistryHandler.postInitRegistries(); } @EventHandler public static void serverInit(FMLServerStartingEvent event) { RegistryHandler.serverRegistries(); } } ClientProxy: package mod.mores.proxy; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraftforge.client.model.ModelLoader; public class ClientProxy extends CommonProxy { @Override public void registerItemRenderer(Item item, int meta, String id) { ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(item.getRegistryName(), "inventory")); } @Override public void render() { } } CommonProxy: package mod.mores.proxy; import net.minecraft.item.Item; public class CommonProxy { public void registerItemRenderer(Item item, int meta, String id) { } public void render() { } } RegistryHandler: package mod.mores.util.handlers; import mod.mores.init.BlockInit; import mod.mores.init.ItemInit; import mod.mores.modid.Mores; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @Mod.EventBusSubscriber public class RegistryHandler { @SubscribeEvent public static void onItemRegister(RegistryEvent.Register<Item> event) { event.getRegistry().registerAll(ItemInit.ITEMS.toArray(new Item[0])); } @SubscribeEvent public static void onModelRegister(ModelRegistryEvent event) { for(Item item : ItemInit.ITEMS) { Mores.proxy.registerItemRenderer(item, 0, "inventory"); } for(Block block : BlockInit.BLOCKS) { Mores.proxy.registerItemRenderer(Item.getItemFromBlock(block), 0, "inventory"); } } @SubscribeEvent public static void onBlockRegister(RegistryEvent.Register<Block> event) { event.getRegistry().registerAll(BlockInit.BLOCKS.toArray(new Block[0])); } public static void preInitRegistries() { Mores.proxy.render(); } public static void initRegistries() { } public static void postInitRegistries() { } public static void serverRegistries() { } } Loading errors: [20:50:41] [Client thread/ERROR] [FML]: Exception loading model for variant mores:ruby_gem#inventory for item "mores:ruby_gem", normal location exception: net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model mores:item/ruby_gem with loader VanillaLoader.INSTANCE, skipping at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:161) ~[ModelLoaderRegistry.class:?] at net.minecraftforge.client.model.ModelLoader.loadItemModels(ModelLoader.java:302) ~[ModelLoader.class:?] at net.minecraft.client.renderer.block.model.ModelBakery.loadVariantItemModels(ModelBakery.java:175) ~[ModelBakery.class:?] at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:151) ~[ModelLoader.class:?] at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?] at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:121) [SimpleReloadableResourceManager.class:?] at net.minecraft.client.Minecraft.init(Minecraft.java:513) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:378) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_275] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_275] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_275] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_275] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_275] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_275] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_275] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_275] at net.minecraftforge.legacydev.Main.start(Main.java:86) [legacydev-0.2.3.1-fatjar.jar:0.2.3.1+4+372be23] at net.minecraftforge.legacydev.MainClient.main(MainClient.java:29) [legacydev-0.2.3.1-fatjar.jar:0.2.3.1+4+372be23] Caused by: java.io.FileNotFoundException: mores:models/item/ruby_gem.json at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:69) ~[SimpleReloadableResourceManager.class:?] at net.minecraft.client.renderer.block.model.ModelBakery.loadModel(ModelBakery.java:334) ~[ModelBakery.class:?] at net.minecraftforge.client.model.ModelLoader.access$1400(ModelLoader.java:115) ~[ModelLoader.class:?] at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:861) ~[ModelLoader$VanillaLoader.class:?] at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:157) ~[ModelLoaderRegistry.class:?] ... 20 more [20:50:41] [Client thread/ERROR] [FML]: Exception loading model for variant mores:ruby_gem#inventory for item "mores:ruby_gem", blockstate location exception: net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model mores:ruby_gem#inventory with loader VariantLoader.INSTANCE, skipping at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:161) ~[ModelLoaderRegistry.class:?] at net.minecraftforge.client.model.ModelLoader.loadItemModels(ModelLoader.java:296) ~[ModelLoader.class:?] at net.minecraft.client.renderer.block.model.ModelBakery.loadVariantItemModels(ModelBakery.java:175) ~[ModelBakery.class:?] at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:151) ~[ModelLoader.class:?] at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?] at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:121) [SimpleReloadableResourceManager.class:?] at net.minecraft.client.Minecraft.init(Minecraft.java:513) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:378) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_275] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_275] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_275] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_275] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_275] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_275] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_275] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_275] at net.minecraftforge.legacydev.Main.start(Main.java:86) [legacydev-0.2.3.1-fatjar.jar:0.2.3.1+4+372be23] at net.minecraftforge.legacydev.MainClient.main(MainClient.java:29) [legacydev-0.2.3.1-fatjar.jar:0.2.3.1+4+372be23] Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException at net.minecraft.client.renderer.block.model.ModelBlockDefinition.getVariant(ModelBlockDefinition.java:83) ~[ModelBlockDefinition.class:?] at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1175) ~[ModelLoader$VariantLoader.class:?] at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:157) ~[ModelLoaderRegistry.class:?] ... 20 more My main is located at mod/src/main/java/mod/mores/modid/mores.java My language file is located at mod/src/main/resources/assets/mores/lang/en_us.lang My texture is located at mod/src/main/resources/assets/mores/textures/items/ruby_gem.png My model JSON is located at mod/src/main/resources/assets/mores/models/item/ruby_gem.json

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.