Posted August 27, 201411 yr The title kind of describes the issue. I have a machine that has a custom block model. For some reason, when I place it, it will not face the player. Im pretty sure ive just missed something but I cant seem to figure it out. Any help would be greatly appreciated. BlockEnditeReactor package blocks; import gui.GuiID; import java.util.Random; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import tileentity.TileEntityEnditeReactor; import main.RunicScrolls; 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.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class BlockEnditeReactor extends BlockContainer{ private final boolean isActive; private static boolean keepInventory; public TileEntityEnditeReactor enditeReactor; private Random rand = new Random(); public static boolean isParticle; public BlockEnditeReactor(boolean isActive) { super(Material.iron); this.isActive = isActive; } public int getRenderType() { return -1; } public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } @Override public TileEntity createNewTileEntity(World world, int i) { return new TileEntityEnditeReactor(); } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { this.blockIcon = iconRegister.registerIcon(RunicScrolls.modid + ":" + this.getUnlocalizedName().substring(5)); } public void onBlockAdded(World world, int x, int y, int z) { super.onBlockAdded(world, x, y, z); this.setDefaultDirection(world, x, y, z); } public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityplayer, ItemStack itemstack) { int l = MathHelper.floor_double((double)(entityplayer.rotationYaw * 4.0F / 360.F) + 0.5D) & 3; if(l == 0) { world.setBlockMetadataWithNotify(x, y, z, 2, 2); } if(l == 1) { world.setBlockMetadataWithNotify(x, y, z, 5, 2); } if(l == 2) { world.setBlockMetadataWithNotify(x, y, z, 3, 2); } if(l == 3) { world.setBlockMetadataWithNotify(x, y, z, 4, 2); } if(itemstack.hasDisplayName()) { ((TileEntityEnditeReactor)world.getTileEntity(x, y, z)).setGuiDisplayName(itemstack.getDisplayName()); } } private void setDefaultDirection(World world, int x, int y, int z) { if(!world.isRemote) { Block b1 = world.getBlock(x, y, z - 1); Block b2 = world.getBlock(x, y, z + 1); Block b3 = world.getBlock(x - 1, y, z); Block b4 = world.getBlock(x + 1, y, z); byte b0 = 3; if(b1.func_149730_j() && !b2.func_149730_j()) { b0 = 3; } if(b2.func_149730_j() && !b1.func_149730_j()) { b0 = 2; } if(b3.func_149730_j() && !b4.func_149730_j()) { b0 = 5; } if(b4.func_149730_j() && !b3.func_149730_j()) { b0 = 4; } world.setBlockMetadataWithNotify(x, y, x, b0, 2); } } public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if(!world.isRemote) { FMLNetworkHandler.openGui(player, RunicScrolls.instance, GuiID.guiIDEnditeReactor, world, x, y, z); } return true; } public static void updateEnditeReactorBlockState(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, RunicScrolls.blockEnditeReactor); BlockEnditeReactor.isParticle = true; } else { worldObj.setBlock(xCoord, yCoord, zCoord, RunicScrolls.blockEnditeReactor); BlockEnditeReactor.isParticle = false; } 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) { TileEntityEnditeReactor tileentity = (TileEntityEnditeReactor) 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()); } world.spawnEntityInWorld(item); } } } world.func_147453_f(x, y, z, oldblock); } } super.breakBlock(world, x, y, z, oldblock, oldMetaData); } } ModelBlockEnditeReactor package model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelBlockEnditeReactor extends ModelBase { ModelRenderer Bottom; ModelRenderer Stand; ModelRenderer Main; ModelRenderer Left; ModelRenderer Right; ModelRenderer Back; ModelRenderer Interface; public ModelBlockEnditeReactor() { textureWidth = 128; textureHeight = 64; Bottom = new ModelRenderer(this, 0, 0); Bottom.addBox(0F, 0F, 0F, 14, 1, 14); Bottom.setRotationPoint(-7F, 23F, -7F); Bottom.setTextureSize(128, 64); Bottom.mirror = true; setRotation(Bottom, 0F, 0F, 0F); Stand = new ModelRenderer(this, 0, 16); Stand.addBox(0F, 0F, 0F, 8, 2, ; Stand.setRotationPoint(-4F, 21F, -4F); Stand.setTextureSize(128, 64); Stand.mirror = true; setRotation(Stand, 0F, 0F, 0F); Main = new ModelRenderer(this, 0, 27); Main.addBox(0F, 0F, 0F, 10, 10, 10); Main.setRotationPoint(-5F, 11F, -5F); Main.setTextureSize(128, 64); Main.mirror = true; setRotation(Main, 0F, 0F, 0F); Left = new ModelRenderer(this, 0, 48); Left.addBox(0F, 0F, 0F, 3, 4, 4); Left.setRotationPoint(-8F, 14F, -2F); Left.setTextureSize(128, 64); Left.mirror = true; setRotation(Left, 0F, 0F, 0F); Right = new ModelRenderer(this, 15, 48); Right.addBox(0F, 0F, 0F, 3, 4, 4); Right.setRotationPoint(5F, 14F, -2F); Right.setTextureSize(128, 64); Right.mirror = true; setRotation(Right, 0F, 0F, 0F); Back = new ModelRenderer(this, 30, 48); Back.addBox(0F, 0F, 0F, 4, 4, 3); Back.setRotationPoint(-2F, 14F, 5F); Back.setTextureSize(128, 64); Back.mirror = true; setRotation(Back, 0F, 0F, 0F); Interface = new ModelRenderer(this, 33, 16); Interface.addBox(0F, 0F, 0F, 8, 8, 1); Interface.setRotationPoint(-4F, 12F, -6F); Interface.setTextureSize(128, 64); Interface.mirror = true; setRotation(Interface, 0F, 0F, 0F); } public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); Bottom.render(f5); Stand.render(f5); Main.render(f5); Left.render(f5); Right.render(f5); Back.render(f5); Interface.render(f5); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } public void renderModel(float f) { Bottom.render(f); Stand.render(f); Main.render(f); Left.render(f); Right.render(f); Back.render(f); Interface.render(f); } } RenderEnditeReactor package renderer; import org.lwjgl.opengl.GL11; import tileentity.TileEntityEnditeReactor; import cpw.mods.fml.relauncher.SideOnly; import main.RunicScrolls; import model.ModelBlockEnditeReactor; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; public class RenderEnditeReactor extends TileEntitySpecialRenderer { private static final ResourceLocation texture = new ResourceLocation(RunicScrolls.modid + ":" + "textures/model/BlockEnditeReactor.png"); private ModelBlockEnditeReactor model; public RenderEnditeReactor() { this.model = new ModelBlockEnditeReactor(); } @Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { int i; if (tileentity.getWorldObj() == null) { i = 0; } else { Block block = tileentity.getBlockType(); i = tileentity.getBlockMetadata(); if (block != null && i == 0) { i = tileentity.getBlockMetadata(); } } GL11.glPushMatrix(); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); Minecraft.getMinecraft().renderEngine.bindTexture(texture); GL11.glPushMatrix(); GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); int j = 0; if (i == 3) { j = 270; } if (i == 2) { j = 180; } if (i == 1) { j = 90; } if (i == 0) { j = 360; } GL11.glRotatef(j, 0.0F, 1.0F, 0F); this.model.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); GL11.glPopMatrix(); } } TileEntityEnditeReactor package tileentity; import java.awt.List; import recipes.RecipesEnditeReactor; import cpw.mods.fml.common.registry.GameRegistry; import blocks.BlockEnditeReactor; import main.RunicScrolls; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; 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 TileEntityEnditeReactor extends TileEntity implements ISidedInventory { public int direction; private ItemStack[] slots = new ItemStack [12]; 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_side = new int[]{1}; public int furnaceSpeed = 400; public int burnTime; public int currentItemBurnTime; public int cookTime; public void setGuiDisplayName(String displayName) { this.localizedName = displayName; } public String getInventoryName() { return this.hasCustomInventoryName() ? this.localizedName : "container.enditeReactor"; } public boolean hasCustomInventoryName() { return this.localizedName != null && this.localizedName.length() > 0; } public int getSizeInventory() { return this.slots.length; } @Override public ItemStack getStackInSlot(int var1) { return this.slots[var1]; } @Override public ItemStack decrStackSize(int var1, int var2) { if(this.slots[var1] != null) { ItemStack itemstack; if(this.slots[var1].stackSize <= var2 ) { itemstack = this.slots[var1]; this.slots[var1] = null; return itemstack; } else { itemstack = this.slots[var1].splitStack(var2); if(this.slots[var1].stackSize == 0) { this.slots[var1] = null; } return itemstack; } } else { return null; } } @Override public ItemStack getStackInSlotOnClosing(int var1) { if(this.slots[var1]!= null) { ItemStack itemstack = this.slots[var1]; this.slots[var1] = null; } 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 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 void openInventory() {} public void closeInventory() {} @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { return i == 2 || i == 3 ? false : (i == 1 ? isItemFuel(itemstack) : true); } public static boolean isItemFuel(ItemStack itemstack) { return getItemBurnTime(itemstack) > 0; } private 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(item == RunicScrolls.itemShardEndite) return 400; } return GameRegistry.getFuelValue(itemstack); } public boolean isBurning() { return this.burnTime > 0; } public void updateEntity() { boolean flag = this.burnTime > 0; boolean flag1 = false; if(this.isBurning()) { this.burnTime--; } if(!this.worldObj.isRemote) { if(this.burnTime == 0 && this.canSmelt()) { this.currentItemBurnTime = this.burnTime = getItemBurnTime(this.slots[1]); if(this.isBurning()) { 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.isBurning()) { flag1 = true; BlockEnditeReactor.updateEnditeReactorBlockState(this.burnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord); } } if(flag1) { this.markDirty(); } } public boolean canSmelt() { if (this.slots[0] == null) { return false; } else { ItemStack itemstack = RecipesEnditeReactor.react().getReactResult(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 = RecipesEnditeReactor.react().getReactResult(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; } } } @Override public int[] getAccessibleSlotsFromSide(int var1) { return var1 == 0 ? slots_bottom : (var1 == 1 ? slots_top : slots_side); } @Override public boolean canInsertItem(int i, ItemStack itemstack, int var3) { return this.isItemValidForSlot(i, itemstack); } @Override public boolean canExtractItem(int i, ItemStack itemstack, int j) { return true; } 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 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("CurrentItemBurnTime"); 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("CurrentItemBurnTime", (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); } } } I think thats everything needed. If you need any other classes, i can post them
August 27, 201411 yr You have to methods in your block class: public void onBlockAdded(World world, int x, int y, int z) { super.onBlockAdded(world, x, y, z); this.setDefaultDirection(world, x, y, z); } & public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityplayer, ItemStack itemstack) { int l = MathHelper.floor_double((double)(entityplayer.rotationYaw * 4.0F / 360.F) + 0.5D) & 3; if(l == 0) { world.setBlockMetadataWithNotify(x, y, z, 2, 2); } if(l == 1) { world.setBlockMetadataWithNotify(x, y, z, 5, 2); } if(l == 2) { world.setBlockMetadataWithNotify(x, y, z, 3, 2); } if(l == 3) { world.setBlockMetadataWithNotify(x, y, z, 4, 2); } if(itemstack.hasDisplayName()) { ((TileEntityEnditeReactor)world.getTileEntity(x, y, z)).setGuiDisplayName(itemstack.getDisplayName()); } } Both are called at the same time, namely when the block is placed. In one you're setting the direction towards the player and the other method is happily overriding that metadata with the default direction. I know it is sometimes tempting to add several functions, certainly when minecraft has about 101 methods for the things you don't really need and zero for the ones you do but here you're just fine with deleting the 'OnBlockAdded' method.
August 27, 201411 yr The onBlockPlacedBy is called if a entity has placed the block, and onBlockAdded will always be called when to block places, so need both if you want the block to be rotated if a machines places it. Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
August 27, 201411 yr Hmm, I did not think of that, but a very good point. Nonetheless, the solution is still equally as simple. Simply check if the metadata is 0. And if it is, set the default position. If it isn't, that means the player has put the block down and the metadata has been filled, if at least, you didn't set a side except the default position to metadata 0.
August 27, 201411 yr Author Thank you so much! This is my updated block class and it works perfectly! Thanks! package blocks; import gui.GuiID; import java.util.Random; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import tileentity.TileEntityEnditeReactor; import main.RunicScrolls; 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.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class BlockEnditeReactor extends BlockContainer{ private final boolean isActive; private static boolean keepInventory; public TileEntityEnditeReactor enditeReactor; private Random rand = new Random(); public static boolean isParticle; public BlockEnditeReactor(boolean isActive) { super(Material.iron); this.isActive = isActive; } public int getRenderType() { return -1; } public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } @Override public TileEntity createNewTileEntity(World world, int i) { return new TileEntityEnditeReactor(); } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { this.blockIcon = iconRegister.registerIcon(RunicScrolls.modid + ":" + this.getUnlocalizedName().substring(5)); } public void onBlockAdded(World world, int x, int y, int z) { super.onBlockAdded(world, x, y, z); if(world.getBlockMetadata(x, y, z) == 0) { this.setDefaultDirection(world, x, y, z); } } public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityplayer, ItemStack itemstack) { int l = MathHelper.floor_double((double)(entityplayer.rotationYaw * 4.0F / 360.F) + 0.5D) & 3; if(l == 0) { world.setBlockMetadataWithNotify(x, y, z, 4, 2); //2 } if(l == 1) { world.setBlockMetadataWithNotify(x, y, z, 1, 2); //5 } if(l == 2) { world.setBlockMetadataWithNotify(x, y, z, 2, 2); } if(l == 3) { world.setBlockMetadataWithNotify(x, y, z, 3, 2); } if(itemstack.hasDisplayName()) { ((TileEntityEnditeReactor)world.getTileEntity(x, y, z)).setGuiDisplayName(itemstack.getDisplayName()); } } private void setDefaultDirection(World world, int x, int y, int z) { if(!world.isRemote) { Block b1 = world.getBlock(x, y, z - 1); Block b2 = world.getBlock(x, y, z + 1); Block b3 = world.getBlock(x - 1, y, z); Block b4 = world.getBlock(x + 1, y, z); byte b0 = 3; if(b1.func_149730_j() && !b2.func_149730_j()) { b0 = 3; } if(b2.func_149730_j() && !b1.func_149730_j()) { b0 = 2; } if(b3.func_149730_j() && !b4.func_149730_j()) { b0 = 5; } if(b4.func_149730_j() && !b3.func_149730_j()) { b0 = 4; } world.setBlockMetadataWithNotify(x, y, x, b0, 2); } } public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if(!world.isRemote) { FMLNetworkHandler.openGui(player, RunicScrolls.instance, GuiID.guiIDEnditeReactor, world, x, y, z); } return true; } public static void updateEnditeReactorBlockState(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, RunicScrolls.blockEnditeReactor); BlockEnditeReactor.isParticle = true; } else { worldObj.setBlock(xCoord, yCoord, zCoord, RunicScrolls.blockEnditeReactor); BlockEnditeReactor.isParticle = false; } 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) { TileEntityEnditeReactor tileentity = (TileEntityEnditeReactor) 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()); } world.spawnEntityInWorld(item); } } } world.func_147453_f(x, y, z, oldblock); } } super.breakBlock(world, x, y, z, oldblock, oldMetaData); } }
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.