Fixed an issue with multi-block code
This commit is contained in:
parent
f3d0abd2b1
commit
7df7a141e8
3 changed files with 34 additions and 48 deletions
|
@ -27,20 +27,12 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||||
public class BlockMulti extends BlockContainer implements IExtraBlockInfo
|
public class BlockMulti extends BlockContainer implements IExtraBlockInfo
|
||||||
{
|
{
|
||||||
public String textureName = null;
|
public String textureName = null;
|
||||||
public String channel = "";
|
|
||||||
|
|
||||||
public BlockMulti()
|
public BlockMulti()
|
||||||
{
|
{
|
||||||
super(DarkCore.CONFIGURATION.getBlock("MultiBlock", DarkCore.getNextID()).getInt(), UniversalElectricity.machine);
|
super(DarkCore.CONFIGURATION.getBlock("MultiBlock", DarkCore.getNextID()).getInt(), UniversalElectricity.machine);
|
||||||
this.setHardness(0.8F);
|
this.setHardness(0.8F);
|
||||||
this.setUnlocalizedName("multiBlock");
|
this.setUnlocalizedName("multiBlock");
|
||||||
this.setChannel(DarkCore.CHANNEL);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockMulti setChannel(String channel)
|
|
||||||
{
|
|
||||||
this.channel = channel;
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -121,22 +113,25 @@ public class BlockMulti extends BlockContainer implements IExtraBlockInfo
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createNewTileEntity(World var1)
|
public TileEntity createNewTileEntity(World var1)
|
||||||
{
|
{
|
||||||
return new TileEntityMulti(this.channel);
|
return new TileEntityMulti();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getPickBlock(MovingObjectPosition target, World par1World, int x, int y, int z)
|
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
|
||||||
{
|
{
|
||||||
TileEntity tileEntity = par1World.getBlockTileEntity(x, y, z);
|
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||||
Vector3 mainBlockPosition = ((TileEntityMulti) tileEntity).mainBlockPosition;
|
if (tileEntity instanceof TileEntityMulti)
|
||||||
|
|
||||||
if (mainBlockPosition != null)
|
|
||||||
{
|
{
|
||||||
int mainBlockID = par1World.getBlockId(mainBlockPosition.intX(), mainBlockPosition.intY(), mainBlockPosition.intZ());
|
Vector3 mainBlockPosition = ((TileEntityMulti) tileEntity).mainBlockPosition;
|
||||||
|
|
||||||
if (mainBlockID > 0)
|
if (mainBlockPosition != null && !mainBlockPosition.equals(new Vector3(x, y, z)))
|
||||||
{
|
{
|
||||||
return Block.blocksList[mainBlockID].getPickBlock(target, par1World, mainBlockPosition.intX(), mainBlockPosition.intY(), mainBlockPosition.intZ());
|
int mainBlockID = mainBlockPosition.getBlockID(world);
|
||||||
|
|
||||||
|
if (mainBlockID > 0)
|
||||||
|
{
|
||||||
|
return Block.blocksList[mainBlockID].getPickBlock(target, world, mainBlockPosition.intX(), mainBlockPosition.intY(), mainBlockPosition.intZ());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,7 @@ public abstract class TileEntityEnergyMachine extends TileEntityMachine implemen
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Called to produce power using the output enumset for directions to output in */
|
||||||
protected void produce()
|
protected void produce()
|
||||||
{
|
{
|
||||||
for (ForgeDirection direction : this.getOutputDirections())
|
for (ForgeDirection direction : this.getOutputDirections())
|
||||||
|
|
|
@ -7,6 +7,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import universalelectricity.api.vector.Vector3;
|
import universalelectricity.api.vector.Vector3;
|
||||||
|
|
||||||
|
import com.builtbroken.minecraft.DarkCore;
|
||||||
import com.builtbroken.minecraft.interfaces.IMultiBlock;
|
import com.builtbroken.minecraft.interfaces.IMultiBlock;
|
||||||
import com.builtbroken.minecraft.network.ISimplePacketReceiver;
|
import com.builtbroken.minecraft.network.ISimplePacketReceiver;
|
||||||
import com.builtbroken.minecraft.network.PacketHandler;
|
import com.builtbroken.minecraft.network.PacketHandler;
|
||||||
|
@ -21,18 +22,12 @@ public class TileEntityMulti extends TileEntity implements ISimplePacketReceiver
|
||||||
{
|
{
|
||||||
// The the position of the main block
|
// The the position of the main block
|
||||||
public Vector3 mainBlockPosition;
|
public Vector3 mainBlockPosition;
|
||||||
public String channel;
|
|
||||||
|
|
||||||
public TileEntityMulti()
|
public TileEntityMulti()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TileEntityMulti(String channel)
|
|
||||||
{
|
|
||||||
this.channel = channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMainBlock(Vector3 mainBlock)
|
public void setMainBlock(Vector3 mainBlock)
|
||||||
{
|
{
|
||||||
this.mainBlockPosition = mainBlock;
|
this.mainBlockPosition = mainBlock;
|
||||||
|
@ -43,18 +38,31 @@ public class TileEntityMulti extends TileEntity implements ISimplePacketReceiver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean simplePacket(String id, ByteArrayDataInput data, Player player)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (id.equalsIgnoreCase("MainBlock"))
|
||||||
|
{
|
||||||
|
this.mainBlockPosition = new Vector3(data.readInt(), data.readInt(), data.readInt());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Packet getDescriptionPacket()
|
public Packet getDescriptionPacket()
|
||||||
{
|
{
|
||||||
if (this.mainBlockPosition != null)
|
if (this.mainBlockPosition != null)
|
||||||
{
|
{
|
||||||
if (this.channel == null || this.channel == "" && this.getBlockType() instanceof BlockMulti)
|
return PacketHandler.instance().getTilePacket(DarkCore.CHANNEL, "MainBlock", this, this.mainBlockPosition.intX(), this.mainBlockPosition.intY(), this.mainBlockPosition.intZ());
|
||||||
{
|
|
||||||
this.channel = ((BlockMulti) this.getBlockType()).channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
return PacketHandler.instance().getTilePacket(this.channel, "MainBlock", this, this.mainBlockPosition.intX(), this.mainBlockPosition.intY(), this.mainBlockPosition.intZ());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -125,22 +133,4 @@ public class TileEntityMulti extends TileEntity implements ISimplePacketReceiver
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean simplePacket(String id, ByteArrayDataInput data, Player player)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (id.equalsIgnoreCase("MainBlock"))
|
|
||||||
{
|
|
||||||
this.mainBlockPosition = new Vector3(data.readInt(), data.readInt(), data.readInt());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue