Jump to content

MisterGamer _

Members
  • Posts

    27
  • Joined

  • Last visited

Everything posted by MisterGamer _

  1. Ok, my error, i registered it in a different way than the other Tile Entities. I fixed it. Thank you anyway.
  2. I created a directional block. I attached a Tile Entity to it and when I run the game, the message appears in the console: "(TileEntity name) is missing a mapping!", But I registered the Tile Entity correctly. Also when I break the block with this Tile Entity, the Collision Box remains and I get stuck in an invisible block. When I place a block instead of the one just broken, the just broken block reappears, and if I break it again, it disappears forever. I have another block that uses TileEntity and I have done all the steps I did when I created that block, but this gives problems. How can I solve it? P.S. This problem occurs only if my block is directional, even if the message "(TileEntity name) is missing a mapping!" still appears. A brief video of the problem: (password is: minecraftisgood)
  3. Ok, I removed "static", but now the block isn't in the game.
  4. ModBlocks line 41 is this: public static final Block REVERSING_FURNACE = new ReversingFurnaceBlock("reversing_furnace", Material.IRON);
  5. Hi I was creating a Directional Block (a Furnace) and i received an exception. Console Error: Even if the Error says: "Caused by: at com.mistergamer.mysticalmod.world.biome.BiomeMystical.<init>(BiomeMystical.java:14), at com.mistergamer.mysticalmod.init.BiomeInit.<clinit>(BiomeInit.java:15), at com.mistergamer.mysticalmod.Main.PreInit(Main.java:58)", there are no errors here, so it's a createBlockState() method error. Here it is the code: public final PropertyDirection FACING = PropertyDirection.create("facing"); public ReversingFurnaceBlock(String name, Material material) { super(name, material); setSoundType(SoundType.METAL); setHardness(12.0F); setResistance(52.0F); setHarvestLevel("pickaxe", 2); setCreativeTab(Main.tabMystical); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {FACING}); } @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing())); } public int getMetaFromState(IBlockState state) { return ((EnumFacing)state.getValue(FACING)).getIndex(); } public IBlockState getStateFromMeta(int meta) { EnumFacing enumfacing = EnumFacing.getFront(meta); if (enumfacing.getAxis() == EnumFacing.Axis.Y) { enumfacing = EnumFacing.NORTH; } return this.getDefaultState().withProperty(FACING, enumfacing); } @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ReversingFurnaceTileEntity te = (ReversingFurnaceTileEntity)world.getTileEntity(pos); if(te != null && te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.NORTH)) { player.openGui(Main.instance, GuiHandler.REVERSING_FURNACE_GUI, world, pos.getX(), pos.getY(), pos.getZ()); return true; } return super.onBlockActivated(world, pos, state, player, hand, facing, hitX, hitY, hitZ); } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new ReversingFurnaceTileEntity(); } Thank you very much.
  6. I have a Container with 2 slots; one for input and one for output. The Output Slot is a custom-made Slot and here is it's code: import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.SlotItemHandler; public class CompactorOutputSlot extends SlotItemHandler{ private int removeCount; public CompactorOutputSlot(IItemHandler itemHandler, int index, int xPosition, int yPosition) { super(itemHandler, index, xPosition, yPosition); } @Override public ItemStack onTake(EntityPlayer thePlayer, ItemStack stack) { this.onCrafting(stack); super.onTake(thePlayer, stack); return stack; } @Override public boolean isItemValid(ItemStack stack) { return false; } @Override public ItemStack decrStackSize(int amount) { if(this.getHasStack()) this.removeCount += Math.min(amount, this.getStack().getCount()); return super.decrStackSize(amount); } } How can I specify which of the two slots the hopper can take?
  7. Hello, i created a Tile Entity with capabilities and i searched for the update() method, but there isn't even if i implemented ITickable interface. I found tick() and i think it does the same of update(). Then i tried to create a "machine style" Tile Entity, to process items, but i failed. How can I create a Machine Block with a Tile Entity based on Capabilities? Thank you.
  8. I had a look at the Beacon GUI and it works now! Thank you so much!
  9. Here it is: package com.mistergamer.mysticalmod.gui; public class CompactorGui extends GuiContainer{ public static final int WIDTH = 176; public static final int HEIGHT = 166; public GuiButton button1; public String crafting; BlockPos pos = Minecraft.getMinecraft().player.getPosition(); World world = Minecraft.getMinecraft().world; EntityPlayer player = Minecraft.getMinecraft().player; Entity entity; public static final ResourceLocation background = new ResourceLocation(Reference.MOD_ID, "textures/gui/container/compactor_gui.png"); public static final int GUI_ID = 2; public CompactorGui(CompactorTileEntity tileEntity, CompactorContainer container) { super(container); xSize = WIDTH; ySize = HEIGHT; } @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); GL11.glDisable(GL11.GL_LIGHTING); mc.getTextureManager().bindTexture(background); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); this.renderHoveredToolTip (mouseX, mouseY); } protected void drawGuiContainerForegroundLayer(float partialTicks, int mouseX, int mouseY) { this.renderHoveredToolTip(mouseX, mouseY); } @Override public boolean doesGuiPauseGame() { return false; } @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { this.drawDefaultBackground(); super.drawScreen(mouseX, mouseY, partialTicks); this.renderHoveredToolTip(mouseX, mouseY); fontRenderer.drawString("Inventory", this.getGuiLeft() + 8, this.getGuiTop() + 72, 4210752); //Draw the Help button this.buttonList.add(new GuiButton(1, this.getGuiLeft() + 128, this.getGuiTop() + 62, 20, 20, "?")); //Draw the Mystical Ingot button and icon this.buttonList.add(new GuiButton(2, this.getGuiLeft() + 8, this.getGuiTop() + 8, 20, 20, "")); mc.getRenderItem().renderItemAndEffectIntoGUI(new ItemStack(ModItems.MYSTICAL_INGOT), this.getGuiLeft() + 10, this.getGuiTop() + 10); //Draw the Mystical Fuel button and icon this.buttonList.add(new GuiButton(3, this.getGuiLeft() + 29, this.getGuiTop() + 8, 20, 20, "")); mc.getRenderItem().renderItemAndEffectIntoGUI(new ItemStack(ModItems.MYSTICAL_FUEL), this.getGuiLeft() + 31, this.getGuiTop() + 10); } @Override protected void actionPerformed(GuiButton button) throws IOException { if(button.id == 1) { if(world.isRemote) { Minecraft.getMinecraft().displayGuiScreen(new CompactorHelpGui()); Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F)); } }else if(button.id == 2) { if(world.isRemote) { Minecraft.getMinecraft().player.sendChatMessage("/give @p " + Reference.MOD_ID + ":mystical_ingot 1"); } Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F)); }else if(button.id == 3) { if(world.isRemote) { Minecraft.getMinecraft().player.sendChatMessage("/give @p " + Reference.MOD_ID + ":mystical_fuel 1"); } Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F)); } } }
  10. button.id.isPressed() doesn't exists. A little info I didn't remember: this if statement is in the actionPerformed method of a GUI.
  11. Hi, I have a problem with GuiButton. First the code: if(button.id == 2) { if(world.isRemote) { Minecraft.getMinecraft().player.sendChatMessage("/give @p " + Reference.MOD_ID + ":mystical_ingot 1"); } Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F)); } The code works very well, but instead of one ingot, i receive many ingots. So I tried to send a chat message without a command but it appears many times instead of one. Some fixes?
  12. Ok I tried this, but same result... Minecraft.getMinecraft().displayGuiScreen(new CompactorHelpGui());
  13. Hi, I want to open a containerless GUI from another GUI at the push of a button. I tried this code in the actionPerformed () event of the main GUI: if(button.id == 1) { if(!(Minecraft.getMinecraft().world.isRemote)) { Minecraft.getMinecraft().player.sendChatMessage("Help clicked"); }else { Minecraft.getMinecraft().player.openGui(Main.instance, GUI_ID, world, pos.getX(), pos.getY(), pos.getZ()); } } But no GUI opens and the game crashes. Thank you!
  14. So what should I do to manipulate the player's inventory on the server side?
  15. Ok, here it is: @Override protected void actionPerformed(GuiButton button) throws IOException { if(button.id == 1) { Minecraft.getMinecraft().player.sendChatMessage("Click on the button of the item you want to craft."); Minecraft.getMinecraft().player.sendChatMessage("At the amount of items you should receive, there are some extra items! Enjoy the prize."); }else if(button.id == 2) { for(int i = 0; i < Minecraft.getMinecraft().player.inventory.getSizeInventory(); i++) { if(Minecraft.getMinecraft().player.inventory.getStackInSlot(i).equals(new ItemStack(ModItems.MYSTICAL_POWDER, 3))) { Minecraft.getMinecraft().player.inventory.addItemStackToInventory(new ItemStack(ModItems.MYSTICAL_INGOT)); Minecraft.getMinecraft().player.inventory.decrStackSize(i, 3); } } }else if(button.id == 3) { for(int i = 0; i < Minecraft.getMinecraft().player.inventory.getSizeInventory(); i++) { if(Minecraft.getMinecraft().player.inventory.getStackInSlot(i).equals(new ItemStack(ModItems.MYSTICAL_INGOT, 3))) { Minecraft.getMinecraft().player.inventory.addItemStackToInventory(new ItemStack(ModItems.MYSTICAL_FUEL)); Minecraft.getMinecraft().player.inventory.decrStackSize(i, 3); } } } }
  16. Thanks, I labeled it as solved, but I didn't find something helpful... After The School i will try it.
  17. Hi everyone, I would have gotten the index of a player's inventory space if it contains a certain item. I looked a bit if there was something that solved my problem, but I didn't find anything. Thank you all!
  18. Hello everyone! In my GUI i have two slots, one for input and one for output like this: But when i open the GUI, the input slot is filled with the Item i have in the second hotbar slot. I think that the problem is in the container code, here it is: public class CompactorContainer extends Container{ private CompactorTileEntity te; public CompactorContainer(IInventory playerInventory, CompactorTileEntity te) { this.te = te; addOwnSlots(playerInventory); addPlayerSlots(playerInventory); } private void addPlayerSlots(IInventory playerInventory) { for (int row = 0; row < 3; ++row) { for (int col = 0; col < 9; ++col) { int x = 8 + col * 18; int y = row * 18 + 84; this.addSlotToContainer(new Slot(playerInventory, col + row * 9 + 10, x, y)); } } //add the slots for the hotbar for (int col = 0; col < 9; ++col) { int x = 8 + col * 18; int y = 72 + 70; this.addSlotToContainer(new Slot(playerInventory, col, x, y)); } } private void addOwnSlots(IInventory pInv) { addSlotToContainer(new Slot(pInv, 1, 48, 34)); addSlotToContainer(new Slot(pInv, 1, 110, 35)); } @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (index < CompactorTileEntity.SIZE) { if (!this.mergeItemStack(itemstack1, CompactorTileEntity.SIZE, this.inventorySlots.size(), true)) { return ItemStack.EMPTY; } } else if (!this.mergeItemStack(itemstack1, 0, CompactorTileEntity.SIZE, false)) { return ItemStack.EMPTY; } if (itemstack1.isEmpty()) { slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } } return itemstack; } @Override public boolean mergeItemStack(ItemStack stack, int start, int end, boolean reverse){ return super.mergeItemStack(stack,start,end,reverse); } @Override public boolean canInteractWith(EntityPlayer playerIn) { return te.canInteractWith(playerIn); } } Thanks you all!
  19. Ok i did understand this. I resolved The problem and Now The container works properly eith the GUI. But there's another problem: i click on a item in The Player inventory but it doesn't move. How do I resolve that? Thank you so much!
  20. Ok so I did debugging and I discovered that the error occurs at the world loading. I don't know what to do =(
×
×
  • Create New...

Important Information

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