Everything posted by IvanTune
-
[1.7.10] Save NBT data to block when broken and placed
Oooooooohhhhhh! Now it works perfectly, thanks ernio <3
-
[1.7.10] Save NBT data to block when broken and placed
Hi there! So I want to save NBT to my solar panel when its broken and placed again. What the code below does is it works when I break and place the solarpanel in the same place, but if I place the solar panel somewhere else it places a solar panel with no Gui or data. Any help is much appriciated. BlockSolarPanel @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) { TileEntitySolarPanel te = (TileEntitySolarPanel) world.getTileEntity(x, y, z); if (te instanceof TileEntitySolarPanel && stack.getTagCompound() != null) { te.readFromNBT(stack.getTagCompound()); } } @Override public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) { ArrayList<ItemStack> ret = new ArrayList<ItemStack>(); ItemStack stack = new ItemStack(world.getBlock(x, y, z), 1, metadata); TileEntitySolarPanel te = (TileEntitySolarPanel) world.getTileEntity(x, y, z); if (te instanceof TileEntitySolarPanel) { NBTTagCompound tag = new NBTTagCompound(); ((TileEntitySolarPanel)te).writeToNBT(tag); if (!stack.hasTagCompound()) { stack.setTagCompound(tag); } ret.add(stack); } return ret; } @Override public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) { if (willHarvest) { return true; // If it will harvest, delay deletion of the block // until after getDrops } return super.removedByPlayer(world, player, x, y, z, willHarvest); } @Override public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) { super.harvestBlock(world, player, x, y, z, meta); world.setBlockToAir(x, y, z); }
-
[1.7.10] Sending RF storage to client(gui) & sending packet from gui to server
Hello there! 1. So been having a lot of trouble with tileentity syncing and packets. The first thing i I am trying to do is send the RF storage from the server to the client so that the player can see in the GUI what the storage is at. It works fine on a SP world, but when I tried on a server the RF would go up to 32k, then reset itself and stay at 0, then go up to 32k and reset itself again in the gui. TileEntitySolarPanel public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); storage.writeToNBT(nbt); } public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); storage.readFromNBT(nbt); } public void updateEntity() { if (!worldObj.isRemote) { if(storage.getEnergyStored() < storage.getMaxEnergyStored()) { int i = storage.getEnergyStored() + currentRfgeneration; storage.setEnergyStored(i); } } } ContainerSolarPanel private TileEntitySolarPanel solarPanel; int lastEnergyStored; @Override public void addCraftingToCrafters(ICrafting icrafting) { super.addCraftingToCrafters(icrafting); icrafting.sendProgressBarUpdate(this, 0, this.solarPanel.getEnergyStored()); } public void detectAndSendChanges() { super.detectAndSendChanges(); for (int i = 0; i < this.crafters.size(); i++) { ICrafting icrafting = (ICrafting) this.crafters.get(i); if (this.lastEnergyStored != this.solarPanel.getEnergyStored()) { icrafting.sendProgressBarUpdate(this, 0, this.solarPanel.getEnergyStored()); } } this.lastEnergyStored = this.solarPanel.getEnergyStored(); } @SideOnly(Side.CLIENT) @Override public void updateProgressBar(int slot, int newValue) { if (slot == 0) { this.solarPanel.setEnergyStored(newValue); } } 2. Also when a player does changes to stuff in GUI (ints), i want these to be sent to the server. I'm not quite sure if I am doing packets right and I am not sure what to put in the OnMessage so that the int is sent right. I also want the int to be sent back to the client so that other people can see it, is it ok to just do it through the container? MessageGuiSolarTab1Height package com.EvanTune.futuregate.network; import com.EvanTune.futuregate.block.machine.solar_panel.tab.TestTab; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; public class MessageGuiSolarTab1Height implements IMessage, IMessageHandler<MessageGuiSolarTab1Height, IMessage> { private int tabHeight; public MessageGuiSolarTab1Height() {} public MessageGuiSolarTab1Height(int value) { this.tabHeight = value; } @Override public void toBytes(ByteBuf buffer) { buffer.writeInt(tabHeight); } @Override public void fromBytes(ByteBuf buffer) { this.tabHeight = buffer.readInt(); } @Override public IMessage onMessage(MessageGuiSolarTab1Height message, MessageContext ctx) { TestTab heighty = new TestTab(tabHeight); heighty.tempHeightSetting = message.tabHeight; return null; } } NetworkHandler package com.EvanTune.futuregate.network; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import cpw.mods.fml.relauncher.Side; public class NetworkHandler { public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(Reference.CHANNEL); private static int id = 0; public static void init() { INSTANCE.registerMessage(MessageGuiSolarTab1Height.class, MessageGuiSolarTab1Height.class, id++, Side.SERVER); } } TestTab @Override public void mouseReleased(GuiSolarPanel gui, int x, int y, int button) { NetworkHandler.INSTANCE.sendToServer(new MessageGuiSolarTab1Height(tempHeightSetting)); isDragging = false; } Thanks in advance for any help or tips!
-
[1.7.10] MouseEvent does not fire when inside gui
Thanks for replies! So I am using GuiContainer for the gui and forge version 1517 for 1.7.10. Also a bit confused because I don't see MouseInputEvent in the GuiScreenEvent. Any idea what I could do for GuiContainer? Just need it to detect that someone is scrolling then fire some code and work in gui.
-
[1.7.10] MouseEvent does not fire when inside gui
Hello folks! So I am making scrollable windows in my gui and I want to use the scrollwheel on mouse to move them up and down. Everything works fine when gui is not open, but with gui open the MouseEvent does not fire for some reason. Any help on how to solve it is much appriciated. Thanks!
-
[1.7.10] Tooltips on gui, also change texture
Hello! So I added tooltips to my gui so when a player hovers over a bar it displays sun intesity on solar panel. This all works fine, but what if I also want the texture to change on that area when player hovers mouse there. What I did below works when mouse is hovered over, but if I pick up 1 of an item then the texture goes white. If I pick up 64 or 12 of an item then everything works, but this only happens when 1 item is picked up. Here is what happens: Any help is appriciated. public void drawScreen(int x, int y, float f) { super.drawScreen(x, y, f); this.drawToolTipsSunIntensity(x, y); } public void drawToolTipsSunIntensity(int mouseX, int mouseY) { int boxX = (this.width - this.xSize) / 2 + 28; int boxY = (this.height - this.ySize) / 2 + 6; int defaultX = 19; int defaultY = 48; if(mouseX > boxX && mouseX < boxX + defaultX && mouseY > boxY && mouseY < boxY + defaultY) { List list = new ArrayList(); int currentPower = solarPanel.getSunIntensityPercent(); int rf = solarPanel.getCurrentRfgeneration(); list.add("\u00a7eSun Intensity:"); list.add(currentPower + "%"); Minecraft.getMinecraft().getTextureManager().bindTexture(texture); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(2896); drawTexturedModalRect(guiLeft + 29, guiTop + 7, 194, 62, 18, 47); GuiScreen.drawRect(20, 22, 22, 22, 22); this.drawHoveringText(list, mouseX, mouseY, fontRendererObj); } else{ Minecraft.getMinecraft().getTextureManager().bindTexture(texture); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(2896); drawTexturedModalRect(guiLeft + 29, guiTop + 7, 176, 62, 18, 47); } }
-
[1.7.10] Question about sending RF out of storage
Thank you! Works like a charm.
-
[1.7.10] Question about sending RF out of storage
Hello! So I made a solar panel that is supposed to send RF out of its storage and into blocks that wants to receive. I made the panel start generating energy if sun is up, but why is it it not sending the storage into other blocks like a Leadstone Energy Cell etc? I saved storage to NBT and tile is implementing IEnergyProvider. Any help and/or tips are very much appriciated! TileSolarPanel: // RF Stuff public EnergyStorage storage; public static int CAPACITY = 100000; public static int MAX_RECEIVE = 0; public static int MAX_EXTRACT = 512; public TileEntitySolarPanel(){ storage = new EnergyStorage(CAPACITY, MAX_RECEIVE, MAX_EXTRACT); } @Override public boolean canConnectEnergy(ForgeDirection from) { return true; } @Override public int getEnergyStored(ForgeDirection from){ return storage.getEnergyStored(); } public int getEnergyStored(){ return storage.getEnergyStored(); } @Override public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { return storage.extractEnergy(maxExtract, simulate); } public int getMaxEnergyStored(){ return storage.getMaxEnergyStored(); } @Override public int getMaxEnergyStored(ForgeDirection from){ return storage.getMaxEnergyStored(); }
-
[1.7.10] Make block save data values when block is broken and placed again
Really appricate the answers diesieben07. You mean something like this? @Override public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) { ArrayList<ItemStack> ret = new ArrayList<ItemStack>(); ItemStack stack = new ItemStack(world.getBlock(x, y, z), 1, metadata); TileEntityRedstoneMacerator te = (TileEntityRedstoneMacerator)world.getTileEntity(x, y, z); int i = te.cookTime; if (te instanceof TileEntityRedstoneMacerator){ if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } stack.getTagCompound().setInteger("CookTime", i); ret.add(stack); } return ret; }
-
[1.7.10] Make block save data values when block is broken and placed again
I am probably missing something, but I thought the ret.add was adding my block to the itemstack, then adding the data to the block and returning the itemstack as a drop with the data. @Override public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) { ArrayList<ItemStack> ret = new ArrayList<ItemStack>(); TileEntityRedstoneMacerator te = (TileEntityRedstoneMacerator)world.getTileEntity(x, y, z); if (te instanceof TileEntityRedstoneMacerator) ret.add(new ItemStack(ModBlocks.blockRedstoneMaceratorIdle, 1, te.getEnergyStored())); return ret; }
-
[1.7.10] Make block save data values when block is broken and placed again
Do you mean changing it to ArrayList<ItemStack> ret = new ArrayList<ItemStack>();? I tried that also but when I break the block and pick it back up again it goes back into the same stack it was in. I also tried adding other data into it but it didn't go into its own stack when picked up. Like when I try to add te.cookTime() same thing happens. Does the data need to be done in a special way in the tileentity in order to be stored? For cooktime all I did was make the int, store it in NBT, then change its value depending on what machine was doing. nbt.setShort("CookTime", (short) this.cookTime); this.cookTime = (int) nbt.getShort("CookTime");
-
[1.7.10] Make block save data values when block is broken and placed again
Since I was getting 2 items I set the getItemDropped to null, and this is code so far, is it now storing the data in the block that gets dropped? The te.getEnergyStored() is returning the internal storage the tileentity has. @Override public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) { ArrayList<ItemStack> ret = super.getDrops(world, x, y, z, metadata, fortune); TileEntityRedstoneMacerator te = (TileEntityRedstoneMacerator)world.getTileEntity(x, y, z); if (te != null && te instanceof TileEntityRedstoneMacerator) ret.add(new ItemStack(ModBlocks.blockRedstoneMaceratorIdle, 1, te.getEnergyStored())); return ret; } @Override public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) { if (willHarvest){ return true; //If it will harvest, delay deletion of the block until after getDrops } return super.removedByPlayer(world, player, x, y, z, willHarvest); } @Override public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) { super.harvestBlock(world, player, x, y, z, meta); world.setBlockToAir(x, y, z); }
-
[1.7.10] Make block save data values when block is broken and placed again
Thanks for the reply, and yes the data is stored in a tileentity. I had a look at the getDrops method (which I assume is the only one I need from the BlockFlowerPot class?), and this is what I got from it. It does drop an extra block when broken, but did it apply the data to the dropped block like this? @Override public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) { ArrayList<ItemStack> ret = super.getDrops(world, x, y, z, metadata, fortune); TileEntityRedstoneMacerator te = (TileEntityRedstoneMacerator)world.getTileEntity(x, y, z); if (te != null && te instanceof TileEntityRedstoneMacerator) ret.add(new ItemStack(ModBlocks.blockRedstoneMaceratorIdle, 1, te.getEnergyStored())); return ret; }
-
[1.7.10] Make block save data values when block is broken and placed again
Hello! I was wondering how you would go about allowing an int value to be saved to a specific block, so when a player breaks the block and places it again the block contains the storage (rf) it had before (and this block can now not be stacked any more with the same blocks). I have saved the rf storage to NBT, and logging out and in again works fine, but I am not sure how to save the storage to an instanced block. Thanks.
-
[1.7.10] Questions about multiblock structures
That is precisely what's happening. It's called z-fighting. Most mods avoid this problem by not using vanilla blocks in their structures. Your best bet is to create an invisible (but solid) block that replaces the redstone (or whatever) so that the original block doesn't render. But when broken, it drops the original and kills the multiblock. Thanks for the help to all of you, appriciate it. So the code below is what I got so far, it's a complete mess. I want to have a multiblock that I can set to any size with different blocks everywhere, but checking that will require thousands of if statements. So how I understand it is if isMultiBlock is true set the blocks to their invisible state. But then it has to know which of the blocks the player breaks and set the invisible blocks back to the solid textured ones. Also if the player breaks the main block, how do you then set the blocks from invisible to solid textured? BreakEvents? I just started school learning java so that and some tips here will hopefully get me where I want. Edit: A friend told me about an api called beefcore for making multiblocks, might try it: https://github.com/erogenousbeef/BeefCore public boolean isMultiBlockStructure(World world, int x, int y, int z) { if (checkMulti(world, x, y, z)){ world.setBlock(x + 1, y + 0, z + 0, ModBlocks.blockInvBedrock); world.setBlock(x + 2, y + 0, z + 0, ModBlocks.blockInvCoal); world.setBlock(x + 3, y + 0, z + 0, ModBlocks.blockInvDiamond); world.setBlock(x + 4, y + 0, z + 0, ModBlocks.blockInvGravel); world.setBlock(x + 5, y + 0, z + 0, ModBlocks.blockInvMelon); /* North */ return true; } if (checkIfMelonIsAir(world, x, y, z)){ world.setBlock(x + 1, y + 0, z + 0, Blocks.bedrock); world.setBlock(x + 2, y + 0, z + 0, Blocks.coal_block); world.setBlock(x + 3, y + 0, z + 0, Blocks.diamond_block); world.setBlock(x + 4, y + 0, z + 0, Blocks.gravel); // world.setBlock(x + 5, y + 0, z + 0, Blocks.melon_block); /* North */ return true; } if (checkIfGravelIsAir(world, x, y, z)){ world.setBlock(x + 1, y + 0, z + 0, Blocks.bedrock); world.setBlock(x + 2, y + 0, z + 0, Blocks.coal_block); world.setBlock(x + 3, y + 0, z + 0, Blocks.diamond_block); // world.setBlock(x + 4, y + 0, z + 0, Blocks.gravel); world.setBlock(x + 5, y + 0, z + 0, Blocks.melon_block); /* North */ return true; } if (checkIfDiamondIsAir(world, x, y, z)){ world.setBlock(x + 1, y + 0, z + 0, Blocks.bedrock); world.setBlock(x + 2, y + 0, z + 0, Blocks.coal_block); // world.setBlock(x + 3, y + 0, z + 0, Blocks.diamond_block); world.setBlock(x + 4, y + 0, z + 0, Blocks.gravel); world.setBlock(x + 5, y + 0, z + 0, Blocks.melon_block); /* North */ return true; } if (checkIfCoalIsAir(world, x, y, z)){ world.setBlock(x + 1, y + 0, z + 0, Blocks.bedrock); // world.setBlock(x + 2, y + 0, z + 0, Blocks.coal_block); world.setBlock(x + 3, y + 0, z + 0, Blocks.diamond_block); world.setBlock(x + 4, y + 0, z + 0, Blocks.gravel); world.setBlock(x + 5, y + 0, z + 0, Blocks.melon_block); /* North */ return true; } if (checkIfBedrockIsAir(world, x, y, z)){ // world.setBlock(x + 1, y + 0, z + 0, Blocks.bedrock); world.setBlock(x + 2, y + 0, z + 0, Blocks.coal_block); world.setBlock(x + 3, y + 0, z + 0, Blocks.diamond_block); world.setBlock(x + 4, y + 0, z + 0, Blocks.gravel); world.setBlock(x + 5, y + 0, z + 0, Blocks.melon_block); /* North */ return true; } return false; } private static boolean checkMulti(World world, int x, int y, int z) { if (world.getBlock(x + 1, y + 0, z + 0) == Blocks.bedrock || world.getBlock(x + 1, y + 0, z + 0) == ModBlocks.blockInvBedrock){ if (world.getBlock(x + 2, y + 0, z + 0) == Blocks.coal_block || world.getBlock(x + 2, y + 0, z + 0) == ModBlocks.blockInvCoal) { if (world.getBlock(x + 3, y + 0, z + 0) == Blocks.diamond_block || world.getBlock(x + 3, y + 0, z + 0) == ModBlocks.blockInvDiamond) { if (world.getBlock(x + 4, y + 0, z + 0) == Blocks.gravel || world.getBlock(x + 4, y + 0, z + 0) == ModBlocks.blockInvGravel) { if (world.getBlock(x + 5, y + 0, z + 0) == Blocks.melon_block || world.getBlock(x + 5, y + 0, z + 0) == ModBlocks.blockInvMelon) { return true; } } } } } return false; } private static boolean checkIfMelonIsAir(World world, int x, int y, int z) { if (world.getBlock(x + 1, y + 0, z + 0) == ModBlocks.blockInvBedock){ if (world.getBlock(x + 2, y + 0, z + 0) == ModBlocks.blockInvCoal) { if (world.getBlock(x + 3, y + 0, z + 0) == ModBlocks.blockInvDiamond) { if (world.getBlock(x + 4, y + 0, z + 0) == ModBlocks.blockInvGravel) { if (world.getBlock(x + 5, y + 0, z + 0) == Blocks.air) { return true; } } } } } return false; } private static boolean checkIfGravelIsAir(World world, int x, int y, int z) { if (world.getBlock(x + 1, y + 0, z + 0) == ModBlocks.blockInvBedrock){ if (world.getBlock(x + 2, y + 0, z + 0) == ModBlocks.blockInvCoal) { if (world.getBlock(x + 3, y + 0, z + 0) == ModBlocks.blockInvDiamond) { if (world.getBlock(x + 4, y + 0, z + 0) == Blocks.air) { if (world.getBlock(x + 5, y + 0, z + 0) == ModBlocks.blockInvMelon) { return true; } } } } } return false; } private static boolean checkIfDiamondIsAir(World world, int x, int y, int z) { if (world.getBlock(x + 1, y + 0, z + 0) == ModBlocks.blockInvbedrock){ if (world.getBlock(x + 2, y + 0, z + 0) == ModBlocks.blockInvCoal) { if (world.getBlock(x + 3, y + 0, z + 0) == Blocks.air) { if (world.getBlock(x + 4, y + 0, z + 0) == ModBlocks.blockInvGravel) { if (world.getBlock(x + 5, y + 0, z + 0) == ModBlocks.blockInvMelon) { return true; } } } } } return false; } private static boolean checkIfCoalIsAir(World world, int x, int y, int z) { if (world.getBlock(x + 1, y + 0, z + 0) == ModBlocks.blockInvbedrock){ if (world.getBlock(x + 2, y + 0, z + 0) == Blocks.air) { if (world.getBlock(x + 3, y + 0, z + 0) == ModBlocks.blockInvDiamond) { if (world.getBlock(x + 4, y + 0, z + 0) == ModBlocks.blockInvGravel) { if (world.getBlock(x + 5, y + 0, z + 0) == ModBlocks.blockInvMelon) { return true; } } } } } return false; } private static boolean checkIfBedrockIsAir(World world, int x, int y, int z) { if (world.getBlock(x + 1, y + 0, z + 0) == Blocks.air){ if (world.getBlock(x + 2, y + 0, z + 0) == ModBlocks.blockInvCoal) { if (world.getBlock(x + 3, y + 0, z + 0) == ModBlocks.blockInvDiamond) { if (world.getBlock(x + 4, y + 0, z + 0) == ModBlocks.blockInvGravel) { if (world.getBlock(x + 5, y + 0, z + 0) == ModBlocks.blockInvMelon) { return true; } } } } } return false; }
-
[1.7.10] Questions about multiblock structures
Basically when I add the model directly over the redstone blocks, the texture flickers as you move around looking at it. I'm assuming this is because there are now 2 textures fighting ontop of eachother. Trying to figure out what the best way is to only show the model texture, and hide/remove the 3x3x3 blocks under it. I can make the model bigger and 1 pixel into the sourrounding blocks, but that doesn't look right.
-
[1.7.10] Questions about multiblock structures
Hello there lovely people! Been messing with multiblock structures and had a few questions. 1: Is having a crazy amount of if statements "bad" (server-wise) when dealing with multiblocks? (i have 26x4 if statements checking, 26 for each direction the block is facing.) 2: How I have it now is if(multiblock == true) it makes right clicking the furnace block open the gui. Is it possible to extend it so when any of the 3x3x3 blocks are right clicked it opens the gui? Make block hitbox into 3x3x3 or something? 3: As image below shows, when putting a model with a texture over blocks like that, is there a way to either hide the blocks (setting them to Blocks.air?) under or make model texture dominant over block textures there somehow? At first I made the model 1 pixel longer on each side so it just got above the redstone block texture, but then the model take up half a pixel more on all sides and it looked bad. Any help or tips are appriciated!
-
[1.7.10] Why can't access variable changes from inside !this.worldObj.isRemote
If cookTime only updates when I am inside the gui is problem still with the container? TileEntity public boolean isActive() { System.out.println(this.cookTime); return this.cookTime > 0; } BlockClass @Override @SideOnly(Side.CLIENT) public void randomDisplayTick(World world, int x, int y, int z, Random random) { TileEntityCustomMacerator te = (TileEntityCustomMacerator) world.getTileEntity(x, y, z); if (te.isActive()) { stuff }
-
[1.7.10] Why can't access variable changes from inside !this.worldObj.isRemote
Shouldn't cookTime be updated on client when I have container like this? public void addCraftingToCrafters(ICrafting icrafting){ super.addCraftingToCrafters(icrafting); icrafting.sendProgressBarUpdate(this, 0, this.customMacerator.cookTime); icrafting.sendProgressBarUpdate(this, 1, this.customMacerator.power); } public void detectAndSendChanges(){ super.detectAndSendChanges(); for(int i = 0; i < this.crafters.size(); i++){ ICrafting icrafting = (ICrafting) this.crafters.get(i); if(this.lastCookTime != this.customMacerator.cookTime){ icrafting.sendProgressBarUpdate(this, 0, this.customMacerator.cookTime); } if(this.lastBurnTime != this.customMacerator.power){ icrafting.sendProgressBarUpdate(this, 1, this.customMacerator.power); } } this.lastCookTime = this.customMacerator.cookTime; this.lastBurnTime = this.customMacerator.power; } @SideOnly(Side.CLIENT) public void updateProgressBar(int slot, int newValue){ if(slot == 0) this.customMacerator.cookTime = newValue; if(slot == 1) this.customMacerator.power = newValue; }
-
[1.7.10] Why can't access variable changes from inside !this.worldObj.isRemote
Thanks for reply! I googled syncing client and server and got receiveClientEvent and addBlockEvent. Am I doing anything right or am I way off? I got kinda stuck now, all I need is the cookTime variable, hmm. TileEntityCustomFurnace public int eventData; private int ticksSinceSync; private int field_145974_k; @Override public boolean receiveClientEvent(int eventID, int eventData) { if (eventID == 1) { this.eventData = eventData; return true; } else { return super.receiveClientEvent(eventID, eventData); } } public void updateEntity() { boolean flag = this.hasPower(); boolean flag1 = false; if (++this.field_145974_k % 20 * 4 == 0){ worldObj.addBlockEvent(xCoord, yCoord, zCoord, ModBlocks.blockCustomFurnaceIdle, 1, this.cookTime); } if(this.hasPower() && this.isMacerating()){ this.power--; } if (!this.worldObj.isRemote) { if (this.hasItemPower(this.slots[1]) && this.power <= (this.maxPower - this.getItemPower(this.slots[1]))) { this.power += getItemPower(this.slots[1]); if(this.slots[1] != null){ flag1 = true; this.slots[1].stackSize--; if(this.slots[1].stackSize == 0){ this.slots[1] = this.slots[1].getItem().getContainerItem(this.slots[1]); } } } if (this.hasPower() && this.canMacerate()) { this.cookTime++; //System.out.println(this.isActive); if (this.cookTime== this.maceratingSpeed) { this.cookTime = 0; this.macerateItem(); flag1 = true; } } else { this.cookTime = 0; } if (flag != this.cookTime > 0) { flag1 = true; BlockCustomMacerator.updateCustomMaceratorBlock(this.cookTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord); } } if (flag1) { this.markDirty(); } }
-
[1.7.10] Why can't access variable changes from inside !this.worldObj.isRemote
Hello! I was just wondering why I can't access the changes done to the variable cookTime when it is inside a !this.worldObj.isRemote if statement. If I remove the !this.worldObj.isRemote I am able to get changes done to it and all is fine. What happens is that with that if statement in there, I dont get access to the code saying "this.cookTime++;", the cookTime variable only works when I am right clicking inside the gui (this is only for when I try to access it with sysout to console), when I leave the gui the variable freezes. Do I need the !this.worldObj.isRemote in the code below, or is it ok if I remove it? Or does code like that have to be done ONLY on server? I'm new to java and still learning, sorry if it is obvious, thanks. TileEntityCustomFurnace public void updateEntity() { boolean flag = this.burnTime > 0; boolean flag1 = false; if (this.burnTime > 0) { this.burnTime--; } if (!this.worldObj.isRemote) { if (this.burnTime == 0 && this.canSmelt()) { this.currentItemBurnTime = this.burnTime = getItemBurnTime(this.slots[1]); if (this.burnTime > 0) { flag1 = true; if (this.slots[1] != null) { this.slots[1].stackSize--; if (this.slots[1].stackSize == 0) { this.slots[1] = this.slots[1].getItem().getContainerItem(this.slots[1]); } } } } if (this.isBurning() && this.canSmelt()) { this.cookTime++; if (this.cookTime == this.furnaceSpeed) { this.cookTime = 0; this.smeltItem(); flag1 = true; } } else { this.cookTime = 0; } if (flag != this.burnTime > 0) { flag1 = true; BlockCustomFurnace.updateCustomFurnaceBlock(this.burnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord); } } if (flag1) { this.markDirty(); } }
-
[1.7.10] isActive state on blocks to spawn particles
@diesieben07 Thanks for the reply! I had it set like that and used this.isActive on the randomDisplayTick method to spawn the particles on the furnace and all was fine and dandy. Then I started making other machines with different slots and all that, and then the block went active when I didn't want to (When it got power it went active, not when doing an operation). I'm sorry if this question sounds stupid, but what determines whether or not the block turns active? Any way to control it? @jabelar Thanks for taking the time to explain that! I tried using the isBurning() method, which returns the same as the isActive method I made in tileentity (this.cookTime > 0), but cookTime only works when I am inside the gui, so I was thinking it has something to do with client and server not beeing synced or something, but I have not been able to figure it out.
-
[1.7.10] isActive state on blocks to spawn particles
Hello there! I want to be able to spawn particles if a machine or block isActive. I made a custom furnace and told it to spawn particles if IsActive(), and set this method in the tileentity class and returned this.cookTime > 0. When I right click and access the gui everything is fine and dandy, but if I put ores into the furnace and go out of the gui, the isActive stays true forever, until I right click and access the gui again, then it updates and particles turn off. So cookTime only changes its numbers when I am inside the gui. If I leave the gui, cookTime stops at the last number it was at. I'm assuming this is a server/client thing and needs to be resolved in the container class, but I am confused as to how to do it. I tried using the IsActive thing the tutorial used in the block class, but for other machines I want to use things like cookTime to determine whether or not a machine is active. Any tips on how I should move forward is greatly appriciated! Block class: package com.IvanTune.futuregate.block; import java.util.Random; import javax.swing.Icon; import com.IvanTune.futuregate.FutureGate; import com.IvanTune.futuregate.init.ModBlocks; import com.IvanTune.futuregate.reference.Reference; import com.IvanTune.futuregate.tileentity.TileEntityCustomFurnace; import com.IvanTune.futuregate.tileentity.TileEntityCustomMacerator; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class BlockCustomFurnace extends BlockContainer { private Random rand = new Random(); private final boolean isActive; private static boolean keepInventory; public BlockCustomFurnace(boolean isActive) { super(Material.rock); this.isActive = isActive; } public int getRenderType() { return -1; } public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } public Item getItemDropped(int par1, Random random, int par3) { return Item.getItemFromBlock(ModBlocks.blockCustomFurnaceIdle); } public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if (world.isRemote) { return true; } else { TileEntityCustomFurnace tileentityCustomFurnace = (TileEntityCustomFurnace) world.getTileEntity(x, y, z); if (tileentityCustomFurnace != null) { player.openGui(FutureGate.instance, 0, world, x, y, z); } return true; } } public TileEntity createNewTileEntity(World world, int i) { return new TileEntityCustomFurnace(); } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister){ this.blockIcon = iconRegister.registerIcon(Reference.MOD_ID + ":" + this.getUnlocalizedName().substring(5)); } @SideOnly(Side.CLIENT) public void randomDisplayTick(World world, int x, int y, int z, Random random) { TileEntityCustomFurnace te = (TileEntityCustomFurnace) world.getTileEntity(x, y, z); if (te.isActive()) { int dir = world.getBlockMetadata((int)x, (int)y, (int)z); float x1 = (float) x + 0.5F; float y1 = (float) ((float) y + random.nextInt(4) * 0.1); float z1 = (float) z + 0.5F; float f = 0.52F; float f1 = random.nextFloat() * 0.6F - 0.3F; if (dir == 1) { world.spawnParticle("smoke", (double) (x1 + f), (double) (y1), (double) (z1 + f1), 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", (double) (x1 + f), (double) (y1), (double) (z1 + f1), 0.0D, 0.0D, 0.0D); } else if (dir == 0) { world.spawnParticle("smoke", (double) (x1 + f1), (double) (y1), (double) (z1 + f-1), 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", (double) (x1 + f1), (double) (y1), (double) (z1 + f-1), 0.0D, 0.0D, 0.0D); } else if (dir == 2) { world.spawnParticle("smoke", (double) (x1 + f1), (double) (y1), (double) (z1 + f), 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", (double) (x1 + f1), (double) (y1), (double) (z1 + f), 0.0D, 0.0D, 0.0D); } else if (dir == 3) { world.spawnParticle("smoke", (double) (x1 + f - 1), (double) (y1), (double) (z1 + f1), 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", (double) (x1 + f - 1), (double) (y1), (double) (z1 + f1), 0.0D, 0.0D, 0.0D); } } } @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack par6ItemStack) { int dir = MathHelper.floor_double((double) ((player.rotationYaw * 4F) / 360F) + 0.5D) & 3; world.setBlockMetadataWithNotify(x, y, z, dir, 0); } public static void updateCustomFurnaceBlock(boolean active, World worldObj, int xCoord, int yCoord, int zCoord) { int i = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); TileEntity tileentity = worldObj.getTileEntity(xCoord, yCoord, zCoord); keepInventory = true; if (active) { worldObj.setBlock(xCoord, yCoord, zCoord, ModBlocks.blockCustomFurnaceActive); } else { worldObj.setBlock(xCoord, yCoord, zCoord, ModBlocks.blockCustomFurnaceIdle); } keepInventory = false; worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, i, 2); if (tileentity != null) { tileentity.validate(); worldObj.setTileEntity(xCoord, yCoord, zCoord, tileentity); } } public void breakBlock(World world, int x, int y, int z, Block oldBlock, int oldMetadata) { if (!keepInventory) { TileEntityCustomFurnace tileentity = (TileEntityCustomFurnace) world.getTileEntity(x, y, z); if (tileentity != null) { for (int i = 0; i < tileentity.getSizeInventory(); i++) { ItemStack itemstack = tileentity.getStackInSlot(i); if (itemstack != null) { float f = this.rand.nextFloat() * 0.8F + 0.1F; float f1 = this.rand.nextFloat() * 0.8F + 0.1F; float f2 = this.rand.nextFloat() * 0.8F + 0.1F; while (itemstack.stackSize > 0) { int j = this.rand.nextInt(21) + 10; if (j > itemstack.stackSize) { j = itemstack.stackSize; } itemstack.stackSize -= j; EntityItem item = new EntityItem(world, (double) ((float) x + f), (double) ((float) y + f1), (double) ((float) z + f2), new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage())); if (itemstack.hasTagCompound()) { item.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy()); } float f3 = 0.05F; item.motionX = (double) ((float) this.rand.nextGaussian() * f3); item.motionY = (double) ((float) this.rand.nextGaussian() * f3 + 0.2F); item.motionZ = (double) ((float) this.rand.nextGaussian() * f3); world.spawnEntityInWorld(item); } } } world.func_147453_f(x, y, z, oldBlock); } } super.breakBlock(world, x, y, z, oldBlock, oldMetadata); } public boolean hasComparatorInputOverride() { return true; } public int getComparatorInputOverride(World world, int x, int y, int z, int i) { return Container.calcRedstoneFromInventory((IInventory) world.getTileEntity(x, y, z)); } public Item getItem(World world, int x, int y, int z) { return Item.getItemFromBlock(ModBlocks.blockCustomFurnaceIdle); } } TileEntityFurnace: package com.IvanTune.futuregate.tileentity; import com.IvanTune.futuregate.block.BlockCustomFurnace; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.ISidedInventory; 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.item.crafting.FurnaceRecipes; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; public class TileEntityCustomFurnace extends TileEntity implements ISidedInventory { private String localizedName; private static final int[] slots_top = new int[] { 0 }; private static final int[] slots_bottom = new int[] { 2 }; private static final int[] slots_sides = new int[] { 1 }; private ItemStack[] slots = new ItemStack[3]; public int furnaceSpeed = 100; public int burnTime; public int currentItemBurnTime; public int cookTime; public int getSizeInventory() { return this.slots.length; } public String getInventoryName() { return this.hasCustomInventoryName() ? this.localizedName : "container.customFurnace"; } public boolean hasCustomInventoryName() { return this.localizedName != null && this.localizedName.length() > 0; } public void setGuiDisplayName(String displayName) { this.localizedName = displayName; } public ItemStack getStackInSlot(int i) { return this.slots[i]; } public ItemStack decrStackSize(int i, int j) { if (this.slots[i] != null) { ItemStack itemstack; if (this.slots[i].stackSize <= j) { itemstack = this.slots[i]; this.slots[i] = null; return itemstack; } else { itemstack = this.slots[i].splitStack(j); if (this.slots[i].stackSize == 0) { this.slots[i] = null; } return itemstack; } } return null; } public ItemStack getStackInSlotOnClosing(int i) { if (this.slots[i] != null) { ItemStack itemstack = this.slots[i]; this.slots[i] = null; return itemstack; } return null; } public void setInventorySlotContents(int i, ItemStack itemstack) { this.slots[i] = itemstack; if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) { itemstack.stackSize = this.getInventoryStackLimit(); } } public int getInventoryStackLimit() { return 64; } public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); NBTTagList list = nbt.getTagList("Items", 10); this.slots = new ItemStack[this.getSizeInventory()]; for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound compound = (NBTTagCompound) list.getCompoundTagAt(i); byte b = compound.getByte("Slot"); if (b >= 0 && b < this.slots.length) { this.slots[b] = ItemStack.loadItemStackFromNBT(compound); } } this.burnTime = (int) nbt.getShort("BurnTime"); this.cookTime = (int) nbt.getShort("CookTime"); this.currentItemBurnTime = (int) nbt.getShort("CurrentBurnTime"); if (nbt.hasKey("CustomName")) { this.localizedName = nbt.getString("CustomName"); } } public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setShort("BurnTime", (short) this.burnTime); nbt.setShort("CookTime", (short) this.cookTime); nbt.setShort("CurrentBurnTime", (short) this.currentItemBurnTime); NBTTagList list = new NBTTagList(); for (int i = 0; i < this.slots.length; i++) { if (this.slots[i] != null) { NBTTagCompound compound = new NBTTagCompound(); compound.setByte("Slot", (byte) i); this.slots[i].writeToNBT(compound); list.appendTag(compound); } } nbt.setTag("Items", list); if (this.hasCustomInventoryName()) { nbt.setString("CustomName", this.localizedName); } } public boolean isUseableByPlayer(EntityPlayer entityplayer) { return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : entityplayer.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D, (double) this.zCoord + 0.5D) <= 64.0D; } public boolean isBurning() { return this.burnTime > 0; } public void updateEntity() { boolean flag = this.burnTime > 0; boolean flag1 = false; if (this.burnTime > 0) { this.burnTime--; } if (!this.worldObj.isRemote) { if (this.burnTime == 0 && this.canSmelt()) { this.currentItemBurnTime = this.burnTime = getItemBurnTime(this.slots[1]); if (this.burnTime > 0) { flag1 = true; if (this.slots[1] != null) { this.slots[1].stackSize--; if (this.slots[1].stackSize == 0) { this.slots[1] = this.slots[1].getItem().getContainerItem(this.slots[1]); } } } } if (this.isBurning() && this.canSmelt()) { this.cookTime++; if (this.cookTime == this.furnaceSpeed) { this.cookTime = 0; this.smeltItem(); flag1 = true; } } else { this.cookTime = 0; } if (flag != this.burnTime > 0) { flag1 = true; BlockCustomFurnace.updateCustomFurnaceBlock(this.burnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord); } } if (flag1) { this.markDirty(); } } private boolean canSmelt() { if (this.slots[0] == null) { return false; } else { ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.slots[0]); if (itemstack == null) return false; if (this.slots[2] == null) return true; if (!this.slots[2].isItemEqual(itemstack)) return false; int result = this.slots[2].stackSize + itemstack.stackSize; return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize()); } } public void smeltItem() { if (this.canSmelt()) { ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.slots[0]); if (this.slots[2] == null) { this.slots[2] = itemstack.copy(); } else if (this.slots[2].isItemEqual(itemstack)) { this.slots[2].stackSize += itemstack.stackSize; } this.slots[0].stackSize--; if (this.slots[0].stackSize <= 0) { this.slots[0] = null; } } } public static int getItemBurnTime(ItemStack itemstack) { if (itemstack == null) { return 0; } else { Item item = itemstack.getItem(); if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) { Block block = Block.getBlockFromItem(item); if (block == Blocks.wooden_slab) { return 150; } if (block.getMaterial() == Material.wood) { return 300; } if (block == Blocks.coal_block) { return 16000; } } if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD")) return 200; if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD")) return 200; if (item instanceof ItemHoe && ((ItemHoe) item).getToolMaterialName().equals("WOOD")) return 200; if (item == Items.stick) return 100; if (item == Items.coal) return 1600; if (item == Items.lava_bucket) return 100; if (item == Item.getItemFromBlock(Blocks.sapling)) return 100; if (item == Items.blaze_rod) return 100; return GameRegistry.getFuelValue(itemstack); } } public static boolean isItemFuel(ItemStack itemstack) { return getItemBurnTime(itemstack) > 0; } public boolean isItemValidForSlot(int i, ItemStack itemstack) { return i == 2 ? false : (i == 1 ? isItemFuel(itemstack) : true); } public int[] getAccessibleSlotsFromSide(int var1) { return var1 == 0 ? slots_bottom : (var1 == 1 ? slots_top : slots_sides); } public boolean canInsertItem(int i, ItemStack itemstack, int j) { return this.isItemValidForSlot(i, itemstack); } public boolean canExtractItem(int i, ItemStack itemstack, int j) { return j != 0 || i != 1 || itemstack.getItem() == Items.bucket; } public int getBurnTimeRemainingScaled(int i) { if (this.currentItemBurnTime == 0) { this.currentItemBurnTime = this.furnaceSpeed; } return this.burnTime * i / this.currentItemBurnTime; } public int getCookProgressScaled(int i) { return this.cookTime * i / this.furnaceSpeed; } public void openInventory() { } public void closeInventory() { } public boolean isActive() { return this.cookTime > 0; } } Container: package com.IvanTune.futuregate.gui; import com.IvanTune.futuregate.tileentity.TileEntityCustomFurnace; import com.IvanTune.futuregate.tileentity.TileEntityCustomMacerator; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.inventory.SlotFurnace; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; public class ContainerCustomMacerator extends Container { private TileEntityCustomMacerator customMacerator; public int lastBurnTime; public int lastItemBurnTime; public int lastCookTime; public ContainerCustomMacerator(InventoryPlayer inventory, TileEntityCustomMacerator tileentity){ this.customMacerator = tileentity; this.addSlotToContainer(new Slot(tileentity, 0, 56, 35)); this.addSlotToContainer(new Slot(tileentity, 1, 8, 56)); this.addSlotToContainer(new SlotFurnace(inventory.player, tileentity, 2, 116, 35)); for(int i = 0; i < 3; i++){ for(int j = 0; j < 9; j++){ this.addSlotToContainer(new Slot(inventory, j + i*9 + 9, 8 + j*18, 84 + i*18)); } } for(int i = 0; i < 9; i++){ this.addSlotToContainer(new Slot(inventory, i, 8 + i*18, 142)); } } public void addCraftingToCrafters(ICrafting icrafting){ super.addCraftingToCrafters(icrafting); icrafting.sendProgressBarUpdate(this, 0, this.customMacerator.cookTime); icrafting.sendProgressBarUpdate(this, 1, this.customMacerator.power); } public void detectAndSendChanges(){ super.detectAndSendChanges(); for(int i = 0; i < this.crafters.size(); i++){ ICrafting icrafting = (ICrafting) this.crafters.get(i); if(this.lastCookTime != this.customMacerator.cookTime){ icrafting.sendProgressBarUpdate(this, 0, this.customMacerator.cookTime); } if(this.lastBurnTime != this.customMacerator.power){ icrafting.sendProgressBarUpdate(this, 1, this.customMacerator.power); } } this.lastCookTime = this.customMacerator.cookTime; this.lastBurnTime = this.customMacerator.power; } @SideOnly(Side.CLIENT) public void updateProgressBar(int slot, int newValue){ if(slot == 0) this.customMacerator.cookTime = newValue; if(slot == 1) this.customMacerator.power = newValue; } public ItemStack transferStackInSlot(EntityPlayer player, int clickedSlotNumber){ ItemStack itemstack = null; Slot slot = (Slot) this.inventorySlots.get(clickedSlotNumber); if(slot != null && slot.getHasStack()){ ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if(clickedSlotNumber == 2){ if(!this.mergeItemStack(itemstack1, 3, 39, true)){ return null; } slot.onSlotChange(itemstack1, itemstack); } else if(clickedSlotNumber != 1 && clickedSlotNumber != 0){ if(FurnaceRecipes.smelting().getSmeltingResult(itemstack1) != null){ if(!this.mergeItemStack(itemstack1, 0, 1, false)){ return null; } } else if(TileEntityCustomMacerator.hasItemPower(itemstack1)){ if(!this.mergeItemStack(itemstack1, 1, 2, false)){ return null; } } else if(clickedSlotNumber >= 3 && clickedSlotNumber < 30){ if(!this.mergeItemStack(itemstack1, 30, 39, false)){ return null; } } else if(clickedSlotNumber >= 30 && clickedSlotNumber < 39){ if(!this.mergeItemStack(itemstack1, 3, 29, false)){ return null; } } } else if(!this.mergeItemStack(itemstack1, 3, 38, false)){ return null; } if(itemstack1.stackSize == 0){ slot.putStack((ItemStack)null); } else{ slot.onSlotChanged(); } if(itemstack1.stackSize == itemstack.stackSize){ return null; } slot.onPickupFromSlot(player, itemstack1); } return itemstack; } public boolean canInteractWith(EntityPlayer entityplayer) { return this.customMacerator.isUseableByPlayer(entityplayer); } }
-
[1.7.10] Rotation on blocks resets when logging out
That might have been a big rookie mistake by me earier there... Added this in ItemRendererCustomFurnace class: public ModelCustomFurnace model = new ModelCustomFurnace(); private static final ResourceLocation texture = new ResourceLocation(Reference.MOD_ID, "textures/model/customFurnace.png"); Then in same class to render it out in hand: GL11.glPushMatrix(); GL11.glScalef(1.0F, 1.0F, 1.0F); GL11.glRotatef(180, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(0.0F, -1.F, 0.0F); Minecraft.getMinecraft().renderEngine.bindTexture(texture); model.renderModel(0.0625F); GL11.glPopMatrix(); Probably not the best way to do it but now the block renders in hand and block rotation on logout stays the same.
-
[1.7.10] Rotation on blocks resets when logging out
Got it working by removing the ItemRenderer in hand code, now block rotation stays put on login. Who needs a beautiful, delicious, 3d model rendered in hand, on the go? Like.. yeah... But yeah thanks for the help diesieben07, gonna figure it out eventually
IPS spam blocked by CleanTalk.