Attempt to make pickBlock supports Gate/Plugs
Whether a Gate is an Autoarchic Gate or not is not sync to the client unfortunately.
This commit is contained in:
parent
6fdbd8c525
commit
4a9eb69b91
4 changed files with 31 additions and 6 deletions
|
@ -576,6 +576,23 @@ public class BlockGenericPipe extends BlockContainer {
|
||||||
return pipe.itemID;
|
return pipe.itemID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
|
||||||
|
RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, Minecraft.getMinecraft().thePlayer);
|
||||||
|
|
||||||
|
if (rayTraceResult != null && rayTraceResult.boundingBox != null) {
|
||||||
|
switch (rayTraceResult.hitPart) {
|
||||||
|
case Gate:
|
||||||
|
Pipe pipe = getPipe(world, x, y, z);
|
||||||
|
return pipe.gate.getGateItem();
|
||||||
|
case Plug:
|
||||||
|
return new ItemStack(BuildCraftTransport.plugItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.getPickBlock(target, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
/* Wrappers ************************************************************ */
|
/* Wrappers ************************************************************ */
|
||||||
@Override
|
@Override
|
||||||
public void onNeighborBlockChange(World world, int x, int y, int z, int id) {
|
public void onNeighborBlockChange(World world, int x, int y, int z, int id) {
|
||||||
|
|
|
@ -153,7 +153,11 @@ public abstract class Gate {
|
||||||
// / UPDATING
|
// / UPDATING
|
||||||
public abstract void update();
|
public abstract void update();
|
||||||
|
|
||||||
public abstract void dropGate();
|
public abstract ItemStack getGateItem();
|
||||||
|
|
||||||
|
public void dropGate() {
|
||||||
|
pipe.dropItem(getGateItem());
|
||||||
|
}
|
||||||
|
|
||||||
public void resetGate() {
|
public void resetGate() {
|
||||||
if (broadcastRedstone) {
|
if (broadcastRedstone) {
|
||||||
|
|
|
@ -140,7 +140,7 @@ public class GateVanilla extends Gate {
|
||||||
* @param k
|
* @param k
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void dropGate() {
|
public ItemStack getGateItem() {
|
||||||
|
|
||||||
int gateDamage;
|
int gateDamage;
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
|
@ -175,7 +175,7 @@ public class GateVanilla extends Gate {
|
||||||
gateItem = BuildCraftTransport.pipeGate;
|
gateItem = BuildCraftTransport.pipeGate;
|
||||||
}
|
}
|
||||||
|
|
||||||
pipe.dropItem(new ItemStack(gateItem, 1, gateDamage));
|
return new ItemStack(gateItem, 1, gateDamage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -216,13 +216,13 @@ public class ItemFacade extends ItemBuildCraft {
|
||||||
Block bl = Block.blocksList[blockId];
|
Block bl = Block.blocksList[blockId];
|
||||||
// No Meta
|
// No Meta
|
||||||
if (bl != null && bl.getRenderType() == 31 && (blockMeta & 0xC) == 0)
|
if (bl != null && bl.getRenderType() == 31 && (blockMeta & 0xC) == 0)
|
||||||
return getStack(blockId, (blockMeta & 0x3) | 4);
|
return getStack(bl, (blockMeta & 0x3) | 4);
|
||||||
// Meta | 4 = true
|
// Meta | 4 = true
|
||||||
if (bl != null && bl.getRenderType() == 31 && (blockMeta & 0x8) == 0)
|
if (bl != null && bl.getRenderType() == 31 && (blockMeta & 0x8) == 0)
|
||||||
return getStack(blockId, (blockMeta & 0x3) | 8);
|
return getStack(bl, (blockMeta & 0x3) | 8);
|
||||||
// Meta | 8 = true
|
// Meta | 8 = true
|
||||||
if (bl != null && bl.getRenderType() == 31 && (blockMeta & 0x4) == 0)
|
if (bl != null && bl.getRenderType() == 31 && (blockMeta & 0x4) == 0)
|
||||||
return getStack(blockId, (blockMeta & 0x3));
|
return getStack(bl, (blockMeta & 0x3));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -250,6 +250,10 @@ public class ItemFacade extends ItemBuildCraft {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ItemStack getStack(Block block, int metadata) {
|
||||||
|
return getStack(block.blockID, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
public static ItemStack getStack(int blockID, int metadata) {
|
public static ItemStack getStack(int blockID, int metadata) {
|
||||||
ItemStack stack = new ItemStack(BuildCraftTransport.facadeItem, 1, 0);
|
ItemStack stack = new ItemStack(BuildCraftTransport.facadeItem, 1, 0);
|
||||||
NBTTagCompound nbt = new NBTTagCompound("tag");
|
NBTTagCompound nbt = new NBTTagCompound("tag");
|
||||||
|
|
Loading…
Reference in a new issue