Jump to content

Arthur Wesley

Members
  • Posts

    32
  • Joined

  • Last visited

Everything posted by Arthur Wesley

  1. I'm trying to render a custom [chestplate] but it won't work properly. I made the code using Tabula mod, but what happens is that the rendered parts connected to the arms won't move, they just stay static. Anything I miss? Model class: import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.client.renderer.GlStateManager; public class ModelMSapphireArmor extends ModelBiped { public ModelRenderer Chestplate; public ModelRenderer ShoulderRight; public ModelRenderer MegaRight; public ModelRenderer MegaRight_1; public ModelRenderer MegaRight_2; public ModelMSapphireArmor() { this.textureWidth = 128; this.textureHeight = 128; this.MegaRight = new ModelRenderer(this, 110, 32); this.MegaRight.setRotationPoint(-3.0F, -2.0F, -2.0F); this.MegaRight.addBox(-9.0F, -4.8F, 0.9F, 2, 3, 2, 0.0F); this.MegaRight_1 = new ModelRenderer(this, 92, 32); this.MegaRight_1.setRotationPoint(-3.0F, -2.0F, -2.0F); this.MegaRight_1.addBox(-7.0F, -0.1F, 0.1F, 3, 3, 4, 0.0F); this.ShoulderRight = new ModelRenderer(this, 74, 42); this.ShoulderRight.setRotationPoint(-3.0F, -2.0F, -2.0F); this.ShoulderRight.addBox(-8.5F, 3.6F, -1.0F, 8, 10, 8, 0.0F); this.Chestplate = new ModelRenderer(this, 73, -4); this.Chestplate.setRotationPoint(-4.0F, 0.0F, -2.0F); this.Chestplate.addBox(-1.7F, 0.0F, -1.0F, 16, 22, 8, 0.0F); this.MegaRight_2 = new ModelRenderer(this, 76, 32); this.MegaRight_2.setRotationPoint(-3.0F, -2.0F, -2.0F); this.MegaRight_2.addBox(-8.5F, -2.5F, 0.5F, 3, 3, 3, 0.0F); this.bipedBody.addChild(Chestplate); this.bipedRightArm.addChild(ShoulderRight); this.bipedRightArm.addChild(MegaRight); this.bipedRightArm.addChild(MegaRight_1); this.bipedRightArm.addChild(MegaRight_2); } @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { this.MegaRight.render(f5); this.MegaRight_1.render(f5); GlStateManager.pushMatrix(); GlStateManager.translate(this.ShoulderRight.offsetX, this.ShoulderRight.offsetY, this.ShoulderRight.offsetZ); GlStateManager.translate(this.ShoulderRight.rotationPointX * f5, this.ShoulderRight.rotationPointY * f5, this.ShoulderRight.rotationPointZ * f5); GlStateManager.scale(0.65D, 0.55D, 0.7D); GlStateManager.translate(-this.ShoulderRight.offsetX, -this.ShoulderRight.offsetY, -this.ShoulderRight.offsetZ); GlStateManager.translate(-this.ShoulderRight.rotationPointX * f5, -this.ShoulderRight.rotationPointY * f5, -this.ShoulderRight.rotationPointZ * f5); this.ShoulderRight.render(f5); GlStateManager.popMatrix(); GlStateManager.pushMatrix(); GlStateManager.translate(this.Chestplate.offsetX, this.Chestplate.offsetY, this.Chestplate.offsetZ); GlStateManager.translate(this.Chestplate.rotationPointX * f5, this.Chestplate.rotationPointY * f5, this.Chestplate.rotationPointZ * f5); GlStateManager.scale(0.65D, 0.55D, 0.7D); GlStateManager.translate(-this.Chestplate.offsetX, -this.Chestplate.offsetY, -this.Chestplate.offsetZ); GlStateManager.translate(-this.Chestplate.rotationPointX * f5, -this.Chestplate.rotationPointY * f5, -this.Chestplate.rotationPointZ * f5); this.Chestplate.render(f5); GlStateManager.popMatrix(); this.MegaRight_2.render(f5); } public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { modelRenderer.rotateAngleX = x; modelRenderer.rotateAngleY = y; modelRenderer.rotateAngleZ = z; } } Armor Render class: import net.minecraft.client.model.ModelBiped; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import tutuicraft3.sapphirecraft.Main; import tutuicraft3.sapphirecraft.init.ItemInit; import tutuicraft3.sapphirecraft.util.interfaces.IHasModel; public class ArmorModel extends ItemArmor implements IHasModel { public ArmorModel(String name, CreativeTabs tab, ArmorMaterial materialIn, EntityEquipmentSlot equipmentSlotIn) { super(materialIn, 1, equipmentSlotIn); setUnlocalizedName(name); setRegistryName(name); setCreativeTab(tab); setMaxStackSize(1); ItemInit.ITEMS.add(this); } @Override public boolean hasEffect(ItemStack stack) { return true; } @Override public void registerModels() { Main.proxy.registerModel(this, 0); } @Override public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, ModelBiped _default) { if(itemStack != ItemStack.EMPTY) { if(itemStack.getItem() instanceof ItemArmor) { ModelMSapphireArmor model = new ModelMSapphireArmor(); model.bipedHead.showModel = armorSlot == EntityEquipmentSlot.HEAD; model.isChild = _default.isChild; model.isRiding = _default.isRiding; model.isSneak = _default.isSneak; model.rightArmPose = _default.rightArmPose; model.leftArmPose = _default.leftArmPose; return model; } } return null; } } VIDEO
  2. Oops, I'm sorry, those github code were outdated, I just posted my actual one
  3. This is my container class: package tutuicraft3.sapphirecraft.blocks.msinfusortileentity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryBasic; import net.minecraft.inventory.InventoryCraftResult; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class ContainerMSInfusor extends Container { private final IInventory tileMSInfusor; private final IInventory outputSlot; private final IInventory inputSlots; private final World world; public ContainerMSInfusor(InventoryPlayer playerInv, final TileEntityMSInfusor infusor, IInventory mSInfusorInv, World world) { this.outputSlot = new InventoryCraftResult(); this.inputSlots = new InventoryBasic("Infuse", true, 2); this.world = world; this.tileMSInfusor = mSInfusorInv; addSlotToContainer(new Slot(inputSlots, 0, 27, 40)); addSlotToContainer(new Slot(inputSlots, 1, 76, 40)); addSlotToContainer(new Slot(outputSlot, 2, 134, 40) { public boolean isItemValid(ItemStack stack) { return false; } }); for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (int k = 0; k < 9; k++) { addSlotToContainer(new Slot(playerInv, k, 8 + k * 18, 142)); } } public void onContainerClosed(EntityPlayer playerIn) { super.onContainerClosed(playerIn); if (!this.world.isRemote) { this.clearContainer(playerIn, this.world, this.inputSlots); } } @Override public boolean canInteractWith(EntityPlayer player) { return true; } @Override public ItemStack transferStackInSlot(EntityPlayer player, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); int containerSlots = inventorySlots.size() - player.inventory.mainInventory.size(); if (index < containerSlots) { if (!this.mergeItemStack(itemstack1, containerSlots, inventorySlots.size(), true)) { return ItemStack.EMPTY; } } else if (!this.mergeItemStack(itemstack1, 0, containerSlots, false)) { return ItemStack.EMPTY; } if (itemstack1.getCount() == 0) { slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } if (itemstack1.getCount() == itemstack.getCount()) { return ItemStack.EMPTY; } slot.onTake(player, itemstack1); } return itemstack; } } Now I need a Recipes class, that can detect the input and output slots of my container class?, then detect the recipes items like I said before and then it outputs the result?
  4. And how should I add slots to my container class, like, which method to use? public class MSInfusorContainer extends Container { private final IInventory tileFurnace; private int cookTime; private int totalCookTime; private int furnaceBurnTime; private int currentItemBurnTime; public MSInfusorContainer(InventoryPlayer playerInventory, IInventory furnaceInventory) { this.tileFurnace = furnaceInventory; this.addSlotToContainer(new Slot(furnaceInventory, 0, 27, 40)); //<-- I'm talking about this, they are in the correct position in GUI, //but I should add what kind of slot, this furnace itself? this.addSlotToContainer(new SlotFurnaceFuel(furnaceInventory, 1, 76, 40)); this.addSlotToContainer(new SlotFurnaceOutput(playerInventory.player, furnaceInventory, 2, 134, 40)); //... } And to call each slot in my MSInfusorRecipes class, how could I do that?
  5. I really don't know how to make custom recipes for my TileEntity, so what I want is to make Mega Sapphire items by placeing a normal sapphire tool in the first slot and a mega sapphire in the second slot of my sapphire infusor: https://github.com/Arthgames3/1.12.2-SapphireCraft
  6. I've made it. Just had to add drawDefaultBackground(); to my GUI class on drawGuiContainerBackgroundLayer method: @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { drawDefaultBackground(); GlStateManager.color(1, 1, 1, 1); mc.getTextureManager().bindTexture(BG_TEXTURE); int x = (width - xSize) / 2; int y = (height - ySize) / 2; drawTexturedModalRect(x, y, 0, 0, xSize, ySize); }
  7. One little thing, I noticed that my GUI is different from the others in one aspect, it doesn't get it's outer part darker. Normal GUIs have its "focus", making everything around it draker, but mine just opens the GUI and don't get darker, strange because I followed correctly the tutorial, and in there his GUI was darker around.
  8. Yay, the slots are worknig. I only need now a recipe system. package tutuicraft3.sapphirecraft.blocks.msinfusortileentity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.InventoryCraftResult; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.Slot; import net.minecraft.inventory.SlotCrafting; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; public class MSInfusorContainer extends Container { public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3); public InventoryCraftResult craftResult = new InventoryCraftResult(); private final World world; public MSInfusorContainer(InventoryPlayer playerInv, World worldIn, final TileEntityMSInfusor infusor) { this.world = worldIn; IItemHandler inventory = infusor.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.NORTH); addSlotToContainer(new SlotCrafting(playerInv.player, this.craftMatrix, this.craftResult, 0, 134, 40)); addSlotToContainer(new Slot(this.craftMatrix, 0, 27, 40)); addSlotToContainer(new Slot(this.craftMatrix, 1, 76, 40) { @Override public void onSlotChanged() { infusor.markDirty(); } }); for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (int k = 0; k < 9; k++) { addSlotToContainer(new Slot(playerInv, k, 8 + k * 18, 142)); } } @Override public void onContainerClosed(EntityPlayer playerIn) { super.onContainerClosed(playerIn); if (!this.world.isRemote) { this.clearContainer(playerIn, this.world, this.craftMatrix); } } @Override public boolean canInteractWith(EntityPlayer player) { return true; } @Override public ItemStack transferStackInSlot(EntityPlayer player, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); int containerSlots = inventorySlots.size() - player.inventory.mainInventory.size(); if (index < containerSlots) { if (!this.mergeItemStack(itemstack1, containerSlots, inventorySlots.size(), true)) { return ItemStack.EMPTY; } } else if (!this.mergeItemStack(itemstack1, 0, containerSlots, false)) { return ItemStack.EMPTY; } if (itemstack1.getCount() == 0) { slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } if (itemstack1.getCount() == itemstack.getCount()) { return ItemStack.EMPTY; } slot.onTake(player, itemstack1); } return itemstack; } }
  9. And how can I implement some code that makes the items inside the Container to go back to the player's inventory, when the container is closed? I can't manage to find any clue in the vanilla classes.
  10. Thanks for now, I'll see if my noob skills will be able to do it.
  11. And how about the processing, recipes? Like I put two items in the first two slots and it creates a new one... Like the anvil
  12. So, I want to do my own Tile Entity that works exactly like the vanilla furnace/anvil, but with a diferent GUI and my own recipes. I was wondering if someone could help me, please. https://github.com/Arthgames3/1.12.2-SapphireCraft
  13. So, I'll create a new, fresh workspace and start everything from 0 following a more advanced tutorial. Thanks for all the help. "By the way, I'm 14 years old, I chose start programming Java with minecraft because I thought it was going to be interesting, because it's something I like. I choose to ask help for advanced modders because I thought I could learn more that way. Yes, I have done an algoritm course and I am actually making a Basic Java course, even if I know the real basicalready. I just think even if I learn advanced Java I couldn't just go and make a mod, I still should need to search, because it's minecraft forge, with it's own methods and callings ways. So yeah, call me noob, call me odd, call me wathever you want, I am just entering the programming world, and maybe I've done it in the wrong way..."
  14. I'm sorry, I cannot read anything more right now, I'm back in the evening. By the way, here is my repository: https://github.com/Arthgames3/-1.12.2-SapphireCraft
  15. I call it on each blockclass, like this: package tutuicraft3.sapphirecraft.blocks; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import tutuicraft3.sapphirecraft.Main; public class BlockBase extends Block { protected String name; public BlockBase(Material material, String name) { super(material); this.name = name; setUnlocalizedName(name); setRegistryName(name); } public void registerItemModel(Item itemBlock) { Main.proxy.registerItemRenderer(itemBlock, 0, name); } public Item createItemBlock() { return new ItemBlock(this).setRegistryName(getRegistryName()); } @Override public BlockBase setCreativeTab(CreativeTabs tab) { super.setCreativeTab(tab); return this; } }
  16. But where am I using it? I don't know what happened, my mod was working perfectly this afternoon, and it suddenly started to occur this error... Strange.
  17. I've found out that the error occur when the ModBlocks class is registering the first block: @SubscribeEvent public static void registerBlocks(RegistryEvent.Register<Block> event) { System.out.println("ModBlocks registerBlocks -------------------------------------"); System.out.println("register Sapphire Block -----------------------------------"); event.getRegistry().registerAll(Sapphire_Block); //<-- THE ERROR STARTS HERE ================ <-- System.out.println("register Sapphire Ore ----------------------------------------"); event.getRegistry().registerAll(Sapphire_Ore); event.getRegistry().registerAll(MSapphire_Block); event.getRegistry().registerAll(infusor); GameRegistry.registerTileEntity(infusor.getTileEntityClass(), infusor.getRegistryName().toString()); } with the same error lines: [21:41:55] [main/ERROR] [FML]: Exception caught during firing event net.minecraftforge.event.RegistryEvent$Register@447bf09d: java.lang.NullPointerException: Can't use a null-name for the registry, object null.
  18. Anyway, it looks like that didn't solve the crash. This line calls my attention: java.lang.NullPointerException: Can't use a null-name for the registry, object null. What could that mean?
  19. This error is driving me crazy! I can't figure out what is it. Error Log: ---- Minecraft Crash Report ---- // I just don't know what went wrong :( Time: 4/11/18 5:38 PM Description: Initializing game java.lang.NullPointerException: Can't use a null-name for the registry, object null. at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:864) at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:287) at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:281) at net.minecraftforge.registries.ForgeRegistry.register(ForgeRegistry.java:114) at net.minecraftforge.registries.ForgeRegistry.registerAll(ForgeRegistry.java:155) at tutuicraft3.sapphirecraft.init.ModBlocks.registerBlocks(ModBlocks.java:49) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_4_ModBlocks_registerBlocks_Register.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:143) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:179) at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:736) at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:604) at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:270) at net.minecraft.client.Minecraft.init(Minecraft.java:513) at net.minecraft.client.Minecraft.run(Minecraft.java:421) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Client thread Stacktrace: at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:864) at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:287) at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:281) at net.minecraftforge.registries.ForgeRegistry.register(ForgeRegistry.java:114) at net.minecraftforge.registries.ForgeRegistry.registerAll(ForgeRegistry.java:155) at tutuicraft3.sapphirecraft.init.ModBlocks.registerBlocks(ModBlocks.java:49) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_4_ModBlocks_registerBlocks_Register.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:143) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:179) at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:736) at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:604) at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:270) at net.minecraft.client.Minecraft.init(Minecraft.java:513) -- Initialization -- Details: Stacktrace: at net.minecraft.client.Minecraft.run(Minecraft.java:421) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) -- System Details -- Details: Minecraft Version: 1.12.2 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.8.0_162, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 350758720 bytes (334 MB) / 504365056 bytes (481 MB) up to 954728448 bytes (910 MB) JVM Flags: 0 total; IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP 9.42 Powered by Forge 14.23.2.2627 6 mods loaded, 6 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored | State | ID | Version | Source | Signature | |:----- |:--------- |:------------ |:-------------------------------- |:--------- | | UCH | minecraft | 1.12.2 | minecraft.jar | None | | UCH | mcp | 9.42 | minecraft.jar | None | | UCH | FML | 8.0.99.99 | forgeSrc-1.12.2-14.23.2.2627.jar | None | | UCH | forge | 14.23.2.2627 | forgeSrc-1.12.2-14.23.2.2627.jar | None | | UCH | sc | 1.0 | bin | None | | UCH | xray | 1.4.0 | xray-1.12.2-1.4.0.jar | None | Loaded coremods (and transformers): GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 391.24' Renderer: 'GeForce GT 430/PCIe/SSE2' Launched Version: 1.12.2 LWJGL: 2.9.4 OpenGL: GeForce GT 430/PCIe/SSE2 GL version 4.6.0 NVIDIA 391.24, NVIDIA Corporation GL Caps: Using GL 1.3 multitexturing. Using GL 1.3 texture combiners. Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported. Shaders are available because OpenGL 2.1 is supported. VBOs are available because OpenGL 1.5 is supported. Using VBOs: Yes Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: Current Language: English (US) Profiler Position: N/A (disabled) CPU: 3x AMD Phenom(tm) 8400 Triple-Core Processor My ModBlocks class: package tutuicraft3.sapphirecraft.init; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.registries.IForgeRegistry; import tutuicraft3.sapphirecraft.Reference; import tutuicraft3.sapphirecraft.blocks.BlockOre; import tutuicraft3.sapphirecraft.blocks.MSapphire_Block; import tutuicraft3.sapphirecraft.blocks.Sapphire_Block; import tutuicraft3.sapphirecraft.blocks.tileentity.MSapphire_Infusor; @Mod.EventBusSubscriber(modid=Reference.MODID) public class ModBlocks { static Block Sapphire_Block; public static Block Sapphire_Ore; static Block MSapphire_Block; public static MSapphire_Infusor infusor; public static void init() { Sapphire_Block = new Sapphire_Block("sapphire_block", Material.IRON); Sapphire_Ore = new BlockOre("sapphire_ore", Material.ROCK, ModItems.Sapphire, 1).setHardness(3.0F).setCreativeTab(ModItems.TabSapphireCraft); Sapphire_Ore.setHarvestLevel("pickaxe", 2); Sapphire_Ore.setResistance(5.0f); MSapphire_Block = new MSapphire_Block("msapphire_block", Material.IRON); infusor = new MSapphire_Infusor("msapphire_infusor", Material.IRON); } @SubscribeEvent public static void registerBlocks(RegistryEvent.Register<Block> event) { event.getRegistry().registerAll(Sapphire_Block); event.getRegistry().registerAll(Sapphire_Ore); event.getRegistry().registerAll(MSapphire_Block); event.getRegistry().registerAll(infusor); GameRegistry.registerTileEntity(infusor.getTileEntityClass(), infusor.getRegistryName().toString()); } @SubscribeEvent public static void registerItemBlocks(RegistryEvent.Register<Item> event) { event.getRegistry().registerAll(new ItemBlock(Sapphire_Block).setRegistryName(Sapphire_Block.getRegistryName())); event.getRegistry().registerAll(new ItemBlock(Sapphire_Ore).setRegistryName(Sapphire_Ore.getRegistryName())); event.getRegistry().registerAll(new ItemBlock(MSapphire_Block).setRegistryName(MSapphire_Block.getRegistryName())); event.getRegistry().registerAll(new ItemBlock(infusor).setRegistryName(infusor.getRegistryName())); } @SubscribeEvent public static void registerRenders(ModelRegistryEvent event) { registerRender(Item.getItemFromBlock(Sapphire_Block)); registerRender(Item.getItemFromBlock(Sapphire_Ore)); registerRender(Item.getItemFromBlock(MSapphire_Block)); registerRender(Item.getItemFromBlock(infusor)); } public static void registerRender(Item item) { ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory")); } } I was wondering if someone could help me, please?
  20. So I'm following a tutorial on how to create a TileEntity, but for some reason I got an error with the method heldItem: package tutuicraft3.sapphirecraft.blocks; import javax.annotation.Nullable; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentString; import net.minecraft.world.World; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import tutuicraft3.sapphirecraft.Main; public class MSapphire_Infusor extends BlockTileEntity<TileEntityInfusor> { public MSapphire_Infusor() { super("msapphire_infusor", Material.IRON); } @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (!world.isRemote) { TileEntityInfusor tile = getTileEntity(world, pos); IItemHandler itemHandler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side); if (!player.isSneaking()) { if (heldItem.isEmpty()) { player.setHeldItem(hand, itemHandler.extractItem(0, 64, false)); } else { player.setHeldItem(hand, itemHandler.insertItem(0, heldItem, false)); } tile.markDirty(); } else { ItemStack stack = itemHandler.getStackInSlot(0); if (!stack.isEmpty()) { String localized = Main.proxy.localize(stack.getUnlocalizedName() + ".name"); player.sendMessage(new TextComponentString(stack.getCount() + "x " + localized)); } else { player.sendMessage(new TextComponentString("Empty")); } } } return true; } @Override public void breakBlock(World world, BlockPos pos, IBlockState state) { TileEntityInfusor tile = getTileEntity(world, pos); IItemHandler itemHandler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.NORTH); ItemStack stack = itemHandler.getStackInSlot(0); if (!stack.isEmpty()) { EntityItem item = new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), stack); world.spawnEntity(item); } super.breakBlock(world, pos, state); } @Override public Class<TileEntityInfusor> getTileEntityClass() { return TileEntityInfusor.class; } @Nullable @Override public TileEntityInfusor createTileEntity(World world, IBlockState state) { return new TileEntityInfusor(); } } I was wondering if someone could help me, please. Thanks in advance.
  21. So, I want to do my own Tile Entity that works exactly like the vanilla furnace, but with a diferent GUI and my own recipes. I was wondering if someone could help me, please.
×
×
  • Create New...

Important Information

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