28Smiles Posted February 27, 2015 Posted February 27, 2015 I've programmed an Multiblock but my variable is empty public class Boiler extends Block implements ITileEntityProvider { public static final PropertyInteger STATE = PropertyInteger.create("state", 0, 15); protected Boiler() { super(Material.iron); setUnlocalizedName("boiler"); this.setDefaultState(this.blockState.getBaseState().withProperty(STATE, 0)); } @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing arg4, float arg5, float arg6, float arg7) { TileEntity tile = world.getTileEntity(pos); if(tile != null) return ((TileEntityBoiler)tile).onBlockActivated(world, pos, state, player, arg4, arg5, arg6, arg7); else return false; } @Override public void onNeighborBlockChange(World world, BlockPos pos, IBlockState bs, Block block) { TileEntity tile = world.getTileEntity(pos); if(tile != null) { ((TileEntityBoiler)tile).onNeighborBlockChange(world, pos, bs, block); } } @Override public void onBlockAdded(World world, BlockPos pos, IBlockState arg2) { TileEntity tile = world.getTileEntity(pos); if(tile != null) { ((TileEntityBoiler)tile).onBlockPlaced(world, pos); } } @Override public void onBlockHarvested(World arg0, BlockPos arg1, IBlockState arg2, EntityPlayer arg3) { TileEntity tile = arg0.getTileEntity(arg1); if(tile != null) { ((TileEntityBoiler)tile).onBlockDestroyed(arg0, arg1);; } } @Override public boolean isOpaqueCube() { return false; } @Override public boolean isFullCube() { return false; } @Override public int getMetaFromState(IBlockState state) { return ((Integer) state.getValue(STATE)).intValue(); } @Override protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { STATE }); } @Override public TileEntity createNewTileEntity(World world, int i) { return new TileEntityBoiler(); } } public class TileEntityBoiler extends TileEntity implements IHeatSink, IUpdatePlayerListBox { private int waterTemp = 0; private int waterHeat = 0; private int waterAmmount = 0; private static final int MJpKpmB = 1000; private boolean isInventoryOpen = false; @Override public void readFromNBT(NBTTagCompound nbttc) { waterTemp = nbttc.getInteger("waterTemp"); waterHeat = nbttc.getInteger("waterHeat"); waterAmmount = nbttc.getInteger("waterAmmount"); int j = nbttc.getInteger("boiler_contingent_size"); boiler_contingent = new ArrayList<BlockPos>(); for(int i = 0; i < j; i++) boiler_contingent.add(new BlockPos(nbttc.getInteger("boiler_contingent_x_" + i), nbttc.getInteger("boiler_contingent_y_" + i), nbttc.getInteger("boiler_contingent_z_" + i))); super.readFromNBT(nbttc); for(BlockPos bpos : boiler_contingent) System.out.println(bpos); System.out.println(j); System.out.println(waterTemp); System.out.println(waterHeat); System.out.println(waterAmmount); } @Override public void writeToNBT(NBTTagCompound nbttc) { nbttc.setInteger("waterTemp", waterTemp); nbttc.setInteger("waterHeat", waterHeat); nbttc.setInteger("waterAmmount", waterAmmount); for(int i = 0; i < boiler_contingent.size(); i++) { nbttc.setInteger("boiler_contingent_x_" + i, boiler_contingent.get(i).getX()); nbttc.setInteger("boiler_contingent_y_" + i, boiler_contingent.get(i).getY()); nbttc.setInteger("boiler_contingent_z_" + i, boiler_contingent.get(i).getZ()); } nbttc.setInteger("boiler_contingent_size", boiler_contingent.size()); super.writeToNBT(nbttc); } public void onNeighborBlockChange(World world, BlockPos newPos, IBlockState bs, Block block) { int i = 0; if(world.getBlockState(pos.north()).getBlock() instanceof Boiler) i += 1; if(world.getBlockState(pos.south()).getBlock() instanceof Boiler) i += 2; if(world.getBlockState(pos.east()).getBlock() instanceof Boiler) i += 4; if(world.getBlockState(pos.west()).getBlock() instanceof Boiler) i += 8; world.setBlockState(pos, world.getBlockState(pos).withProperty(Boiler.STATE, i)); } public void onBlockPlaced(World world, BlockPos pos) { createNewBoilerContingent(world, pos, world.getBlockState(pos)); } public List<BlockPos> boiler_contingent = new ArrayList<BlockPos>(); private boolean master = false; public void createNewBoilerContingent(World world, BlockPos pos, IBlockState bs) { master = true; boiler_contingent = new ArrayList<BlockPos>(); searchForBoilers(world, pos); for(BlockPos bp : boiler_contingent) { TileEntityBoiler boiler = (TileEntityBoiler)world.getTileEntity(bp); boiler.boiler_contingent = boiler_contingent; boiler.resetSearch(); } master = false; System.out.println("New Boiler Contingent size:" + boiler_contingent.size()); for(BlockPos bPos: boiler_contingent) ((TileEntityBoiler)world.getTileEntity(bPos)).boiler_contingent = boiler_contingent; } public void onBlockDestroyed(World world, BlockPos pos) { System.out.println("Destroyed!"); this.founded = true; for(BlockPos bpos: boiler_contingent) { System.out.println("Old Boiler: " + bpos); if(bpos != pos) if(world.getBlockState(bpos).getBlock() instanceof Boiler) { System.out.println("Found Boiler for new Contingent: " + bpos); ((TileEntityBoiler)world.getTileEntity(bpos)).createNewBoilerContingent(world, bpos, world.getBlockState(bpos)); break; } } } public int getWaterTemp() { return waterTemp; } public void setWaterTemp(int waterTemp) { this.waterTemp = waterTemp; } public int getWaterHeat() { return waterHeat; } public void setWaterHeat(int waterHeat) { this.waterHeat = waterHeat; } public int getWaterAmmount() { return waterAmmount; } public void setWaterAmmount(int waterAmmount) { this.waterAmmount = waterAmmount; } public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing facing, float arg5, float arg6, float arg7) { for(BlockPos bpos : boiler_contingent) System.out.println(bpos); return true; } private boolean founded = false; public void searchForBoilers(World world, BlockPos sourceBlock) { if(!founded) ((TileEntityBoiler)world.getTileEntity(sourceBlock)).boiler_contingent.add(pos); founded = true; BlockPos bPos = new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ()); if(world.getBlockState(bPos).getBlock() instanceof Boiler) if(!((TileEntityBoiler)world.getTileEntity(bPos)).isMaster()) if(!((TileEntityBoiler)world.getTileEntity(bPos)).isInContingent()) ((TileEntityBoiler)world.getTileEntity(bPos)).searchForBoilers(world, sourceBlock); bPos = new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ()); if(world.getBlockState(bPos).getBlock() instanceof Boiler) if(!((TileEntityBoiler)world.getTileEntity(bPos)).isMaster()) if(!((TileEntityBoiler)world.getTileEntity(bPos)).isInContingent()) ((TileEntityBoiler)world.getTileEntity(bPos)).searchForBoilers(world, sourceBlock); bPos = new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ()); if(world.getBlockState(bPos).getBlock() instanceof Boiler) if(!((TileEntityBoiler)world.getTileEntity(bPos)).isMaster()) if(!((TileEntityBoiler)world.getTileEntity(bPos)).isInContingent()) ((TileEntityBoiler)world.getTileEntity(bPos)).searchForBoilers(world, sourceBlock); bPos = new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()); if(world.getBlockState(bPos).getBlock() instanceof Boiler) if(!((TileEntityBoiler)world.getTileEntity(bPos)).isMaster()) if(!((TileEntityBoiler)world.getTileEntity(bPos)).isInContingent()) ((TileEntityBoiler)world.getTileEntity(bPos)).searchForBoilers(world, sourceBlock); bPos = new BlockPos(pos.getX(), pos.getY(), pos.getZ() - 1); if(world.getBlockState(bPos).getBlock() instanceof Boiler) if(!((TileEntityBoiler)world.getTileEntity(bPos)).isMaster()) if(!((TileEntityBoiler)world.getTileEntity(bPos)).isInContingent()) ((TileEntityBoiler)world.getTileEntity(bPos)).searchForBoilers(world, sourceBlock); bPos = new BlockPos(pos.getX(), pos.getY(), pos.getZ() + 1); if(world.getBlockState(bPos).getBlock() instanceof Boiler) if(!((TileEntityBoiler)world.getTileEntity(bPos)).isMaster()) if(!((TileEntityBoiler)world.getTileEntity(bPos)).isInContingent()) ((TileEntityBoiler)world.getTileEntity(bPos)).searchForBoilers(world, sourceBlock); } public void resetSearch() { founded = false; } public boolean isInContingent() { return founded; } public boolean isMaster() { return master; } @Override public void update() { } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { System.out.println("Packet received! At: " + pkt.func_179823_a()); NBTTagCompound tagCom = pkt.getNbtCompound(); this.readFromNBT(tagCom); } @Override public Packet getDescriptionPacket() { NBTTagCompound tagCom = new NBTTagCompound(); this.writeToNBT(tagCom); return new S35PacketUpdateTileEntity(pos, getBlockMetadata(), tagCom); } @Override public boolean canHeatUp(int temp) { return false; } @Override public int heatUp(int heat, int temp) { return 0; } } If I build an 1x2x2 boiler and ownly the upper blocks have the filled boiler_contingent variable, if the last placed block is the deeper block. Or if I place the upper last ownly the deeper have a filled Array. Console: [16:02:29] [server thread/INFO]: [de.ecraft.tileentitys.TileEntityBoiler:createNewBoilerContingent:109]: New Boiler Contingent size:4 [16:02:29] [Client thread/INFO]: [de.ecraft.tileentitys.TileEntityBoiler:onDataPacket:215]: Packet received! At: BlockPos{x=-253, y=71, z=183} 0 0 0 0 [16:02:29] [Client thread/INFO]: [de.ecraft.tileentitys.TileEntityBoiler:onDataPacket:215]: Packet received! At: BlockPos{x=-254, y=71, z=183} 0 0 0 0 !! 4 Blocks: 1. BlockPos{x=-253, y=70, z=183} 2. BlockPos{x=-254, y=70, z=183} 3. BlockPos{x=-253, y=71, z=183} 4. BlockPos{x=-254, y=71, z=183} Quote
Draco18s Posted February 27, 2015 Posted February 27, 2015 onNeighborBlockChange is a Block function, not a TileEntity function. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
28Smiles Posted February 27, 2015 Author Posted February 27, 2015 I know.... Oh sorry here See: public class Boiler extends Block implements ITileEntityProvider { public static final PropertyInteger STATE = PropertyInteger.create("state", 0, 15); protected Boiler() { super(Material.iron); setUnlocalizedName("boiler"); this.setDefaultState(this.blockState.getBaseState().withProperty(STATE, 0)); } @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing arg4, float arg5, float arg6, float arg7) { TileEntity tile = world.getTileEntity(pos); if(tile != null) return ((TileEntityBoiler)tile).onBlockActivated(world, pos, state, player, arg4, arg5, arg6, arg7); else return false; } @Override public void onNeighborBlockChange(World world, BlockPos pos, IBlockState bs, Block block) { TileEntity tile = world.getTileEntity(pos); if(tile != null) { ((TileEntityBoiler)tile).onNeighborBlockChange(world, pos, bs, block); } } @Override public void onBlockAdded(World world, BlockPos pos, IBlockState arg2) { TileEntity tile = world.getTileEntity(pos); if(tile != null) { ((TileEntityBoiler)tile).onBlockPlaced(world, pos); } } @Override public void onBlockHarvested(World arg0, BlockPos arg1, IBlockState arg2, EntityPlayer arg3) { TileEntity tile = arg0.getTileEntity(arg1); if(tile != null) { ((TileEntityBoiler)tile).onBlockDestroyed(arg0, arg1);; } } @Override public boolean isOpaqueCube() { return false; } @Override public boolean isFullCube() { return false; } @Override public int getMetaFromState(IBlockState state) { return ((Integer) state.getValue(STATE)).intValue(); } @Override protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { STATE }); } @Override public TileEntity createNewTileEntity(World world, int i) { return new TileEntityBoiler(); } } I had implemented this, so this is not the problem! Quote
Recommended Posts
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.