Jump to content

Whyneb360

Members
  • Posts

    84
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • Personal Text
    Author of Designers' Cosntruct

Whyneb360's Achievements

Stone Miner

Stone Miner (3/8)

0

Reputation

  1. Thank you for your response, however I'm not sure where to put the the if statement you mentioned, or what the default value would be. Sorry if this seems like an obvious question
  2. The crash report is as follows: [17:31:43] [Client thread/FATAL]: Reported exception thrown! net.minecraft.util.ReportedException: Rendering item at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:624) ~[RenderItem.class:?] at net.minecraft.client.gui.GuiIngame.renderInventorySlot(GuiIngame.java:973) ~[GuiIngame.class:?] at net.minecraftforge.client.GuiIngameForge.renderHotbar(GuiIngameForge.java:209) ~[GuiIngameForge.class:?] at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:144) ~[GuiIngameForge.class:?] at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1114) ~[EntityRenderer.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1056) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:951) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_45] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) [start/:?] at GradleStart.main(GradleStart.java:45) [start/:?] Caused by: java.lang.NullPointerException at com.descon.renderer.RenderPottedPlant.renderTileEntityAt(RenderPottedPlant.java:27) ~[RenderPottedPlant.class:?] //int dir = world.getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); at com.descon.itemrenderer.ItemRenderPottedPlant.renderItem(ItemRenderPottedPlant.java:35) ~[itemRenderPottedPlant.class:?] //this.render.renderTileEntityAt(this.entity, 0.0D, 0.0D, 0.0D, 0.0F); at net.minecraftforge.client.ForgeHooksClient.renderInventoryItem(ForgeHooksClient.java:183) ~[ForgeHooksClient.class:?] at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:583) ~[RenderItem.class:?] ... 15 more [17:31:43] [Client thread/INFO] [sTDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: ---- Minecraft Crash Report ---- Time: 18/05/15 5:31 PM Description: Rendering item java.lang.NullPointerException: Rendering item at com.descon.renderer.RenderPottedPlant.renderTileEntityAt(RenderPottedPlant.java:27) at com.descon.itemrenderer.ItemRenderPottedPlant.renderItem(ItemRenderPottedPlant.java:35) at net.minecraftforge.client.ForgeHooksClient.renderInventoryItem(ForgeHooksClient.java:183) at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:583) at net.minecraft.client.gui.GuiIngame.renderInventorySlot(GuiIngame.java:973) at net.minecraftforge.client.GuiIngameForge.renderHotbar(GuiIngameForge.java:209) at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:144) at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1114) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1056) at net.minecraft.client.Minecraft.run(Minecraft.java:951) at net.minecraft.client.main.Main.main(Main.java:164) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) at GradleStart.main(GradleStart.java:45) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at com.descon.renderer.RenderPottedPlant.renderTileEntityAt(RenderPottedPlant.java:27) at com.descon.itemrenderer.ItemRenderPottedPlant.renderItem(ItemRenderPottedPlant.java:35) at net.minecraftforge.client.ForgeHooksClient.renderInventoryItem(ForgeHooksClient.java:183) -- Item being rendered -- Details: Item Type: net.minecraft.item.ItemBlock@34d644b5 Item Aux: 0 Item NBT: null Item Foil: false Stacktrace: at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:583) at net.minecraft.client.gui.GuiIngame.renderInventorySlot(GuiIngame.java:973) at net.minecraftforge.client.GuiIngameForge.renderHotbar(GuiIngameForge.java:209) at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:144) -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityClientPlayerMP['Player37'/264, l='MpServer', x=59.02, y=70.62, z=232.56]] Chunk stats: MultiplayerChunkCache: 10, 10 Level seed: 0 Level generator: ID 00 - default, ver 1. Features enabled: false Level generator options: Level spawn location: World: (56,64,248), Chunk: (at 8,4,8 in 3,15; contains blocks 48,0,240 to 63,255,255), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511) Level time: 1321 game time, 1321 day time Level dimension: 0 Level storage version: 0x00000 - Unknown? Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false Forced entities: 6 total; [EntityItem['item.item.seeds'/114, l='MpServer', x=32.81, y=63.13, z=212.25], EntitySquid['Squid'/115, l='MpServer', x=41.59, y=59.28, z=217.16], EntitySquid['Squid'/116, l='MpServer', x=47.94, y=55.34, z=209.31], EntityClientPlayerMP['Player37'/264, l='MpServer', x=59.02, y=70.62, z=232.56], EntitySquid['Squid'/125, l='MpServer', x=51.97, y=55.00, z=212.94], EntitySquid['Squid'/126, l='MpServer', x=52.84, y=54.00, z=209.50]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:415) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2555) at net.minecraft.client.Minecraft.run(Minecraft.java:973) at net.minecraft.client.main.Main.main(Main.java:164) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) at GradleStart.main(GradleStart.java:45) This... ...is where my code is first referenced in the crash log I believe Thanks, -Whyneb360 P.S. In the above crash report, I annotated which line of code related to the reference.
  3. Hello all, I am having trouble rendering my custom modeled block - I wanted my block's model to face different directions depending on which way the player is facing, which works. The problem arises when I try and make and render my block as an item as well. Whenever I enter the game and the item is visible, the game crashes immediately. I believe I am doing it right, because when I remove the directional code, it renders fine with no crashes. How would I make these two functions work together? My code is as follows: Block Class public class PottedPlantProp extends BlockContainer { public PottedPlantProp(Material material) { super(material); this.setCreativeTab(DesconCreativeTabs.tabExterior); this.setHarvestLevel("", 1); this.setHardness(1F); this.setBlockBounds(0.0625F, 0F, 0.0625F, 0.9375F, 0.750F, 0.9375F); this.setBlockTextureName(Main.modID + ":" + "textures/blocks/pottedplant.png"); } public int getRenderType() { return -1; } public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } @Override public TileEntity createNewTileEntity(World var1, int var2) { return new TileEntityPottedPlant(); } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { this.blockIcon = iconRegister.registerIcon(Main.modID + ":" + this.getUnlocalizedName().substring(5)); } //Directional Code /*public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) { int l = MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; world.setBlockMetadataWithNotify(x, y, z, l, 3); }*/ } ClientProxy //Potted Plant TileEntitySpecialRenderer renderPottedPlant = new RenderPottedPlant(); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPottedPlant.class, renderPottedPlant); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(PropsGeneral.pottedplant), new ItemRenderPottedPlant(renderPottedPlant, new TileEntityPottedPlant())); ItemRenderer public class ItemRenderPottedPlant implements IItemRenderer { TileEntitySpecialRenderer render; private TileEntity entity; public ItemRenderPottedPlant(TileEntitySpecialRenderer render, TileEntity entity) { this.entity = entity; this.render = render; } @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { return true; } @Override public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { return true; } @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { if(type == IItemRenderer.ItemRenderType.ENTITY) GL11.glTranslatef(-0.5F, 0.0F, -0.5F); this.render.renderTileEntityAt(this.entity, 0.0D, 0.0D, 0.0D, 0.0F); } } Block Renderer public class RenderPottedPlant extends TileEntitySpecialRenderer { private static final ResourceLocation texture = new ResourceLocation(Main.modID + ":" + "textures/props/PottedPlantTexture.png"); private ModelPottedPlant model; public RenderPottedPlant() { this.model = new ModelPottedPlant(); } @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) { /*World world = tileEntity.getWorldObj(); int dir = world.getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); */ GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); GL11.glRotatef(180, 0F, 0F, 1F); //GL11.glRotatef(dir * (90F), 0F, 1F, 0F); this.bindTexture(texture); GL11.glPushMatrix(); this.model.renderModel(0.0625F); GL11.glPopMatrix(); GL11.glPopMatrix(); } } P.S. In the state the code is in above, the directional code has been commented out, so that the rendering works
  4. I hate to double post, but I'd still love some help with this
  5. Sorry if this is an obvious question, but where and how would I set and use the metadata. Note that I am not just trying to texture the blocks differently, but I want one to have a model, and the others to not. I looked through the bed code, and found this: (warning, copy pasta ahead) @SideOnly(Side.CLIENT) public IIcon getIcon(int p_149691_1_, int p_149691_2_) { if (p_149691_1_ == 0) { return Blocks.planks.getBlockTextureFromSide(p_149691_1_); } else { int k = getDirection(p_149691_2_); int l = Direction.bedDirection[k][p_149691_1_]; int i1 = isBlockHeadOfBed(p_149691_2_) ? 1 : 0; return (i1 != 1 || l != 2) && (i1 != 0 || l != 3) ? (l != 5 && l != 4 ? this.field_149983_N[i1] : this.field_149982_M[i1]) : this.field_149980_b[i1]; } } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister p_149651_1_) { this.field_149983_N = new IIcon[] {p_149651_1_.registerIcon(this.getTextureName() + "_feet_top"), p_149651_1_.registerIcon(this.getTextureName() + "_head_top")}; this.field_149980_b = new IIcon[] {p_149651_1_.registerIcon(this.getTextureName() + "_feet_end"), p_149651_1_.registerIcon(this.getTextureName() + "_head_end")}; this.field_149982_M = new IIcon[] {p_149651_1_.registerIcon(this.getTextureName() + "_feet_side"), p_149651_1_.registerIcon(this.getTextureName() + "_head_side")}; } Which is how the textures are set, but I'm not sure how I'd change this to set a model for one, and an invisible texture for another (Just in the case of 2 blocks) If needed, this is the code in my Workbench class, and my WorkbenchItem class (again, a bit of a copy pasta warning) Workbench: public class Workbench extends BlockContainer { public static final int[][] thing = new int[][] {{0, 1}, { -1, 0}, {0, -1}, {1, 0}}; @SideOnly(Side.CLIENT) private IIcon[] field_149980_b; @SideOnly(Side.CLIENT) private IIcon[] field_149982_M; @SideOnly(Side.CLIENT) private IIcon[] field_149983_N; public Workbench(Material material) { super(material); this.setCreativeTab(DesconCreativeTabs.tabInterior); this.setHarvestLevel("axe", 1); this.setBlockBounds(0F, 0F, 0F, 1F, 1F, 1F); this.setHardness(3F); } public int getRenderType() { return -1; } public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } public TileEntity createNewTileEntity(World var1, int var2) { return new TileEntityWorkbench(); } /*@SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { this.blockIcon = iconRegister.registerIcon(Main.modID + ":" + this.getUnlocalizedName().substring(5)); } */ //Directional Bollocks public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) { int l = MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; world.setBlockMetadataWithNotify(x, y, z, l, 3); } public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) { if(!player.isSneaking()) { player.openGui(Main.instance, PropsGeneral.guiIDdesignersworkbench, world, x, y, z); return true; }else{ return false; } } public static boolean isBlockWorkbench(int isBlock) { return (isBlock & != 0; } public static int getDirection(int direction) { return direction & 3; } public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { int l = world.getBlockMetadata(x, y, z); int i1 = getDirection(l); if (isBlockWorkbench(l)) { if (world.getBlock(x - thing[i1][0], y, z - thing[i1][1]) != this) { world.setBlockToAir(x, y, z); } } else if (world.getBlock(x + thing[i1][0], y, z + thing[i1][1]) != this) { world.setBlockToAir(x, y, z); if (!world.isRemote) { this.dropBlockAsItem(world, x, y, z, l, 0); } } } public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { return isBlockWorkbench(p_149650_1_) ? Item.getItemById(0) : DesconItems.workbench; } @SideOnly(Side.CLIENT) public IIcon getIcon(int p_149691_1_, int p_149691_2_) { if (p_149691_1_ == 0) { return Blocks.planks.getBlockTextureFromSide(p_149691_1_); } else { int k = getDirection(p_149691_2_); int l = Direction.bedDirection[k][p_149691_1_]; int i1 = isBlockWorkbench(p_149691_2_) ? 1 : 0; return (i1 != 1 || l != 2) && (i1 != 0 || l != 3) ? (l != 5 && l != 4 ? this.field_149983_N[i1] : this.field_149982_M[i1]) : this.field_149980_b[i1]; } } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister p_149651_1_) { this.field_149983_N = new IIcon[] {p_149651_1_.registerIcon(this.getTextureName() + "_feet_top"), p_149651_1_.registerIcon(this.getTextureName() + "_head_top")}; this.field_149980_b = new IIcon[] {p_149651_1_.registerIcon(this.getTextureName() + "_feet_end"), p_149651_1_.registerIcon(this.getTextureName() + "_head_end")}; this.field_149982_M = new IIcon[] {p_149651_1_.registerIcon(this.getTextureName() + "_feet_side"), p_149651_1_.registerIcon(this.getTextureName() + "_head_side")}; } } WorkbenchItem: public class WorkbenchItem extends Item { private static final String __OBFID = "CL_00001771"; public WorkbenchItem() { } /** * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return * True if something happen and false if it don't. This is for ITEMS, not BLOCKS */ public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int i, float x1, float y1, float z1) { if (world.isRemote) { return true; } else if (i != 1) { return false; } else { ++y; Workbench workbench = (Workbench)PropsGeneral.designersworkbench; int i1 = MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; byte b0 = 0; byte b1 = 0; if (i1 == 0) { b1 = 1; } if (i1 == 1) { b0 = -1; } if (i1 == 2) { b1 = -1; } if (i1 == 3) { b0 = 1; } if (player.canPlayerEdit(x, y, z, i, itemstack) && player.canPlayerEdit(x + b0, y, z + b1, i, itemstack)) { if (world.isAirBlock(x, y, z) && world.isAirBlock(x + b0, y, z + b1) && World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) && World.doesBlockHaveSolidTopSurface(world, x + b0, y - 1, z + b1)) { world.setBlock(x, y, z, workbench, i1, 3); if (world.getBlock(x, y, z) == workbench) { world.setBlock(x + b0, y, z + b1, workbench, i1 + 8, 3); } --itemstack.stackSize; return true; } else { return false; } } else { return false; } } } } -Whyneb360
  6. Okay, so my block spawns in with the second one attached (and gets destroyed as well), but how do I make it two different blocks? At the moment its the same block that spawns in, so I think it might have something to do with metadata in the case of the bed, so do I have to set up some metadata? All I want is for the model to only spawn on the first block, not the second -Whyneb360
  7. Could you please explain this in a bit more detail? I am somewhat new to modding, but very new to the more complicated aspects of block placement (which this query seems to be). I looked through the bed and door code, but I couldn't find anything that uses the 'onBlockPlacedinWorld' method -Whyneb360
  8. So I have a modeled block that is, as said above, 3x1x1 (3 blocks wide, 1 block high, and 1 block in depth) and it looks fine, but the hit-box only works for the center block. Through a bit of research I found out that I need to create two other blocks that 'spawn in' on either side when I place the main block, but I'm not sure how to go about this. Any help would be greatly appreciated, -Whyneb360
  9. I am trying to make a 2x1x1 Block, and have managed that, but the block bounds don't work for it. When looking a the left half of the block, you can interact with it and break it and even see that the bounds are 2x1x1, but when I move my mouse over to the right side of the block the hitbox disappears and I can even place a block in the right half. Any idea on how to fix this? -Whyneb360 P.S. I know I'll need to rotate the hitbox, and that parts all settled. Just trying to figure out how to make a functional 2x1x1 hitbox first this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 2.0F);
  10. Okay, so I can see what you're doing wrong, but I'm not confident in my ability to explain it - bear with me. I hate to post code, but I hope that in making it not 'copy-pastable', you will still need to learn and understand it. Where you have your first method and resource location, try using this: private static final ResourceLocation textureLocation = new ResourceLocation([mainclass.modid + ":" + "textures/entity/yourtexture.png"); and then where you've said this.bindtexture... down the bottom, get ride of the object (this.). I think the problem you're having is that you might have been using an outdated thread? Anyway. See if this works. If it doesn't then restart following this: (Part 1 - Model itself) and (Part 2 - Coding it in) P.S. Make sure the resource location variable is the same as your bind texture variable and that your texture file is inside the textures/entity path - entity being a folder.
  11. I have made a breakthrough. When I tested the crafting originally, I just put the recipe into the custom crafting table and since no icon appeared in the output slot, I assumed it didn't work. Just now I tried clicking that empty slot, and the materials disappeared and I got the item(successful crafting procedure). Then I tried a vanilla crafting recipe (wooden button for example) and even though that output icon (of the wooden button) does appear in the output slot, I can't craft it/take it out of the output slot. So my new problem is making the icon for my custom recipes appear, and the icon for the old recipes disappear. Tell me if I need to clarify anything
  12. Here you go: GUIHandler public class GuiHandler implements IGuiHandler { @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity entity = world.getTileEntity(x, y, z); if(entity != null) { switch(ID) { case PropsGeneral.guiIDdesignersworkbench: if (entity instanceof TileEntityWorkbench) { return new ContainerWorkbench(player.inventory, (TileEntityWorkbench) entity, world, x, y, z); } return null; } } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity entity = world.getTileEntity(x, y, z); if(entity != null) { switch(ID) { case PropsGeneral.guiIDdesignersworkbench: if (entity instanceof TileEntityWorkbench) { return new GuiWorkbench(player.inventory, world, x, z, z); } } } return null; } } GUIWorkbench public class GuiWorkbench extends GuiContainer{ private ResourceLocation texture = new ResourceLocation(Main.modID + ":" + "textures/gui/WorkbenchTexture.png"); public GuiWorkbench(InventoryPlayer invPlayer, World world, int x, int y, int z) { super(new ContainerWorkbench(invPlayer, world, x, y, z)); // TODO Auto-generated constructor stub this.xSize = 176; this.ySize = 166; } public void onGuiClosed() { super.onGuiClosed(); } protected void drawGuiContainerForegroundLayer(int i, int j) { this.fontRendererObj.drawString(StatCollector.translateToLocal("Designer's Workbench"), 20, 10, 0xFFFFFF); } @Override protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) { GL11.glColor4f(1F, 1F, 1F, 1F); Minecraft.getMinecraft().getTextureManager().bindTexture(texture); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); } }
  13. Sure thing: ContainerWorkbench class (Where the onCraftMatricChanged method is) public class ContainerWorkbench extends Container { public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3); public IInventory craftResult = new InventoryCraftResult(); private World worldObj; private int posX; private int posY; private int posZ; private static final String __OBFID = "CL_00001744"; public ContainerWorkbench(InventoryPlayer invplayer, TileEntityWorkbench entity, World world, int x, int y, int z) { this.worldObj = world; this.posX = x; this.posY = y; this.posZ = z; this.addSlotToContainer(new SlotCrafting(invplayer.player, this.craftMatrix, this.craftResult, 0, 124, 35)); int l; int i1; for (l = 0; l < 3; ++l) { for (i1 = 0; i1 < 3; ++i1) { this.addSlotToContainer(new Slot(this.craftMatrix, i1 + l * 3, 30 + i1 * 18, 17 + l * 18)); } } for (l = 0; l < 3; ++l) { for (i1 = 0; i1 < 9; ++i1) { this.addSlotToContainer(new Slot(invplayer, i1 + l * 9 + 9, 8 + i1 * 18, 84 + l * 18)); } } for (l = 0; l < 9; ++l) { this.addSlotToContainer(new Slot(invplayer, l, 8 + l * 18, 142)); } this.onCraftMatrixChanged(this.craftMatrix); } public void onCraftMatrixChanged(IInventory inventory) { this.craftResult.setInventorySlotContents(0, WorkBenchCraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj)); } public boolean canInteractWith(EntityPlayer player) { return this.worldObj.getBlock(this.posX, this.posY, this.posZ) != PropsGeneral.designersworkbench ? false : player.getDistanceSq((double)this.posX + 0.5D, (double)this.posY + 0.5D, (double)this.posZ + 0.5D) <= 64.0D; } public void onContainerClosed(EntityPlayer player) { super.onContainerClosed(player); if (!this.worldObj.isRemote) { for (int i = 0; i < 9; ++i) { ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i); if (itemstack != null) { player.dropPlayerItemWithRandomChoice(itemstack, false); } } } } public ItemStack transferStackInSlot(EntityPlayer entityplayer, int q) { ItemStack itemstack = null; Slot slot = (Slot)this.inventorySlots.get(q); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (q == 0) { if (!this.mergeItemStack(itemstack1, 10, 46, true)) { return null; } slot.onSlotChange(itemstack1, itemstack); } else if (q >= 10 && q < 37) { if (!this.mergeItemStack(itemstack1, 37, 46, false)) { return null; } } else if (q >= 37 && q < 46) { if (!this.mergeItemStack(itemstack1, 10, 37, false)) { return null; } } else if (!this.mergeItemStack(itemstack1, 10, 46, false)) { return null; } if (itemstack1.stackSize == 0) { slot.putStack((ItemStack)null); } else { slot.onSlotChanged(); } if (itemstack1.stackSize == itemstack.stackSize) { return null; } slot.onPickupFromSlot(entityplayer, itemstack1); } return itemstack; } } WorkBenchShapedRecipes and its shapless counterpart is directly from the vanilla code Workbench class public class Workbench extends BlockContainer { public Workbench(Material material) { super(material); this.setCreativeTab(DesconCreativeTabs.tabGeneral); this.setHarvestLevel("axe", 1); this.setHardness(3F); this.setBlockBounds(0F, 0F, 0F, 1F, 1F, 2F); } public int getRenderType() { return -1; } public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } public TileEntity createNewTileEntity(World var1, int var2) { return new TileEntityWorkbench(); } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { this.blockIcon = iconRegister.registerIcon(Main.modID + ":" + this.getUnlocalizedName().substring(5)); } //Directional Bollocks public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) { int l = MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; world.setBlockMetadataWithNotify(x, y, z, l, 3); } public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) { if(!player.isSneaking()) { player.openGui(Main.instance, PropsGeneral.guiIDdesignersworkbench, world, x, y, z); return true; }else{ return false; } } }
  14. Exactly. In my custom crafting manager, all the normal crafting recipes shouldn't work, and the ones I've put in should. In reality, it's the other way around - all the normal ones work (vanilla recipes that is), but the ones I've put in don't.
×
×
  • Create New...

Important Information

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