mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-21 04:32:24 +00:00
Started work on Levers
Made part conversion send the desc packet to the client rather than do a local conversion
This commit is contained in:
1 parent
ae74440783
commit
931da01077
10 files changed
+246
-91
No files matched your search
@@ -5,26 +5,19 @@ import java.util.Random;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockTorch;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import codechicken.multipart.IRandomDisplayTick;
|
||||
import codechicken.multipart.TileMultipartObj;
|
||||
import codechicken.core.data.MCDataInput;
|
||||
import codechicken.core.data.MCDataOutput;
|
||||
import codechicken.core.lighting.LazyLightMatrix;
|
||||
import codechicken.core.vec.BlockCoord;
|
||||
import codechicken.core.vec.Cuboid6;
|
||||
import codechicken.core.vec.Vector3;
|
||||
|
||||
public class TorchPart extends McBlockPart implements IPartMeta, IRandomDisplayTick
|
||||
public class TorchPart extends McSidedMetaPart implements IRandomDisplayTick
|
||||
{
|
||||
public static BlockTorch torch = (BlockTorch) Block.torchWood;
|
||||
public static int[] metaSideMap = new int[]{-1, 4, 5, 2, 3, 0};
|
||||
public static int[] sideMetaMap = new int[]{5, 0, 3, 4, 1, 2};
|
||||
public byte meta;
|
||||
|
||||
public TorchPart()
|
||||
{
|
||||
@@ -32,7 +25,7 @@ public class TorchPart extends McBlockPart implements IPartMeta, IRandomDisplayT
|
||||
|
||||
public TorchPart(int meta)
|
||||
{
|
||||
this.meta = (byte)meta;
|
||||
super(meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,82 +40,27 @@ public class TorchPart extends McBlockPart implements IPartMeta, IRandomDisplayT
|
||||
return "mc_torch";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(NBTTagCompound tag)
|
||||
{
|
||||
tag.setByte("meta", meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(NBTTagCompound tag)
|
||||
{
|
||||
meta = tag.getByte("meta");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDesc(MCDataOutput packet)
|
||||
{
|
||||
packet.writeByte(meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readDesc(MCDataInput packet)
|
||||
{
|
||||
meta = packet.readByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cuboid6 getBounds()
|
||||
{
|
||||
double d = 0.15;
|
||||
if (meta == 1)
|
||||
return new Cuboid6(0, 0.2, 0.5 - d, d * 2, 0.8, 0.5 + d);
|
||||
else if (meta == 2)
|
||||
if (meta == 2)
|
||||
return new Cuboid6(1 - d * 2, 0.2, 0.5 - d, 1, 0.8, 0.5 + d);
|
||||
else if (meta == 3)
|
||||
if (meta == 3)
|
||||
return new Cuboid6(0.5 - d, 0.2, 0, 0.5 + d, 0.8, d * 2);
|
||||
else if (meta == 4)
|
||||
if (meta == 4)
|
||||
return new Cuboid6(0.5 - d, 0.2, 1 - d * 2, 0.5 + d, 0.8, 1);
|
||||
else
|
||||
{
|
||||
d = 0.1;
|
||||
return new Cuboid6(0.5 - d, 0, 0.5 - d, 0.5 + d, 0.6, 0.5 + d);
|
||||
}
|
||||
}
|
||||
|
||||
public void onNeighbourChanged()
|
||||
{
|
||||
TileEntity tile = getTile();
|
||||
if(!tile.worldObj.isRemote)
|
||||
{
|
||||
BlockCoord pos = new BlockCoord(tile).offset(metaSideMap[meta]);
|
||||
if(!tile.worldObj.isBlockSolidOnSide(pos.x, pos.y, pos.z, ForgeDirection.getOrientation(metaSideMap[meta]^1)))
|
||||
drop();
|
||||
}
|
||||
}
|
||||
|
||||
public void drop()
|
||||
{
|
||||
tile().remPart(this);
|
||||
TileMultipartObj.dropItem(new ItemStack(torch), getTile().worldObj, Vector3.fromTileEntityCenter(getTile()));
|
||||
|
||||
d = 0.1;
|
||||
return new Cuboid6(0.5 - d, 0, 0.5 - d, 0.5 + d, 0.6, 0.5 + d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld()
|
||||
public int sideForMeta(int meta)
|
||||
{
|
||||
return getTile().worldObj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata()
|
||||
{
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockId()
|
||||
{
|
||||
return torch.blockID;
|
||||
return metaSideMap[meta];
|
||||
}
|
||||
|
||||
public static McBlockPart placement(World world, BlockCoord pos, int side)
|
||||
|
||||
Reference in new issue
Block a user