make wrenching a pipe acknowledge the side hit for smarter direction setting
This commit is contained in:
parent
5f21c701cb
commit
29970dc618
13 changed files with 58 additions and 26 deletions
|
@ -129,7 +129,6 @@ public class BuildCraftMod {
|
|||
|
||||
while (!packets.isEmpty()) {
|
||||
SendRequest r = packets.remove();
|
||||
S3FPacketCustomPayload packetCustomPayload = new S3FPacketCustomPayload();
|
||||
net.minecraft.network.Packet p = r.source.channels.get(Side.SERVER).generatePacketFrom(r.packet);
|
||||
List<EntityPlayerMP> playerList = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
|
||||
for (EntityPlayerMP player : playerList.toArray(new EntityPlayerMP[playerList.size()])) {
|
||||
|
|
|
@ -617,7 +617,13 @@ public class BlockGenericPipe extends BlockBuildCraft implements IColorRemovable
|
|||
} else if (currentItem.getItem() instanceof IToolWrench) {
|
||||
// Only check the instance at this point. Call the IToolWrench
|
||||
// interface callbacks for the individual pipe/logic calls
|
||||
return pipe.blockActivated(player);
|
||||
if (pipe.blockActivated(player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player);
|
||||
ForgeDirection hitSide = rayTraceResult.hitPart == Part.Pipe ? rayTraceResult.sideHit : ForgeDirection.UNKNOWN;
|
||||
return pipe.blockActivated(player, hitSide);
|
||||
} else if (currentItem.getItem() instanceof IMapLocation) {
|
||||
// We want to be able to record pipe locations
|
||||
return false;
|
||||
|
@ -661,7 +667,12 @@ public class BlockGenericPipe extends BlockBuildCraft implements IColorRemovable
|
|||
clickedGate.openGui(player);
|
||||
return true;
|
||||
} else {
|
||||
return pipe.blockActivated(player);
|
||||
if (pipe.blockActivated(player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ForgeDirection hitSide = rayTraceResult.hitPart == Part.Pipe ? rayTraceResult.sideHit : ForgeDirection.UNKNOWN;
|
||||
return pipe.blockActivated(player, hitSide);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,6 +77,11 @@ public abstract class Pipe<T extends PipeTransport> implements IDropControlInven
|
|||
}
|
||||
}
|
||||
|
||||
public boolean blockActivated(EntityPlayer player, ForgeDirection side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean blockActivated(EntityPlayer entityplayer) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -65,14 +65,14 @@ public class PipeFluidsEmerald extends PipeFluidsWood implements ISerializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean blockActivated(EntityPlayer entityplayer) {
|
||||
public boolean blockActivated(EntityPlayer entityplayer, ForgeDirection side) {
|
||||
if (entityplayer.getCurrentEquippedItem() != null) {
|
||||
if (Block.getBlockFromItem(entityplayer.getCurrentEquippedItem().getItem()) instanceof BlockGenericPipe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (super.blockActivated(entityplayer)) {
|
||||
if (super.blockActivated(entityplayer, side)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,8 +56,8 @@ public class PipeFluidsIron extends Pipe<PipeTransportFluids> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean blockActivated(EntityPlayer entityplayer) {
|
||||
return logic.blockActivated(entityplayer);
|
||||
public boolean blockActivated(EntityPlayer entityplayer, ForgeDirection side) {
|
||||
return logic.blockActivated(entityplayer, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -58,8 +58,8 @@ public class PipeFluidsWood extends Pipe<PipeTransportFluids> implements IEnergy
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean blockActivated(EntityPlayer entityplayer) {
|
||||
return logic.blockActivated(entityplayer);
|
||||
public boolean blockActivated(EntityPlayer entityplayer, ForgeDirection side) {
|
||||
return logic.blockActivated(entityplayer, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -84,7 +84,7 @@ public class PipeItemsDaizuli extends Pipe<PipeTransportItems> implements ISeria
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean blockActivated(EntityPlayer player) {
|
||||
public boolean blockActivated(EntityPlayer player, ForgeDirection side) {
|
||||
if (player.isSneaking()) {
|
||||
Item equipped = player.getCurrentEquippedItem() != null ? player.getCurrentEquippedItem().getItem() : null;
|
||||
if (equipped instanceof IToolWrench && ((IToolWrench) equipped).canWrench(player, container.xCoord, container.yCoord, container.zCoord)) {
|
||||
|
@ -100,7 +100,7 @@ public class PipeItemsDaizuli extends Pipe<PipeTransportItems> implements ISeria
|
|||
return true;
|
||||
}
|
||||
|
||||
return logic.blockActivated(player);
|
||||
return logic.blockActivated(player, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -76,14 +76,14 @@ public class PipeItemsEmerald extends PipeItemsWood implements ISerializable, IG
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean blockActivated(EntityPlayer entityplayer) {
|
||||
public boolean blockActivated(EntityPlayer entityplayer, ForgeDirection side) {
|
||||
if (entityplayer.getCurrentEquippedItem() != null) {
|
||||
if (Block.getBlockFromItem(entityplayer.getCurrentEquippedItem().getItem()) instanceof BlockGenericPipe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (super.blockActivated(entityplayer)) {
|
||||
if (super.blockActivated(entityplayer, side)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,14 +52,14 @@ public class PipeItemsEmzuli extends PipeItemsWood implements IGuiReturnHandler
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean blockActivated(EntityPlayer entityplayer) {
|
||||
public boolean blockActivated(EntityPlayer entityplayer, ForgeDirection side) {
|
||||
if (entityplayer.getCurrentEquippedItem() != null) {
|
||||
if (Block.getBlockFromItem(entityplayer.getCurrentEquippedItem().getItem()) instanceof BlockGenericPipe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (super.blockActivated(entityplayer)) {
|
||||
if (super.blockActivated(entityplayer, side)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,8 +60,8 @@ public class PipeItemsIron extends Pipe<PipeTransportItems> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean blockActivated(EntityPlayer entityplayer) {
|
||||
return logic.blockActivated(entityplayer);
|
||||
public boolean blockActivated(EntityPlayer entityplayer, ForgeDirection side) {
|
||||
return logic.blockActivated(entityplayer, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -58,8 +58,8 @@ public class PipeItemsWood extends Pipe<PipeTransportItems> implements IEnergyHa
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean blockActivated(EntityPlayer entityplayer) {
|
||||
return logic.blockActivated(entityplayer);
|
||||
public boolean blockActivated(EntityPlayer entityplayer, ForgeDirection side) {
|
||||
return logic.blockActivated(entityplayer, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -89,10 +89,14 @@ public abstract class PipeLogicIron {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean blockActivated(EntityPlayer entityplayer) {
|
||||
public boolean blockActivated(EntityPlayer entityplayer, ForgeDirection side) {
|
||||
Item equipped = entityplayer.getCurrentEquippedItem() != null ? entityplayer.getCurrentEquippedItem().getItem() : null;
|
||||
if (equipped instanceof IToolWrench && ((IToolWrench) equipped).canWrench(entityplayer, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord)) {
|
||||
switchPosition();
|
||||
if (side == ForgeDirection.UNKNOWN) {
|
||||
switchPosition();
|
||||
} else {
|
||||
setFacing(side);
|
||||
}
|
||||
pipe.container.scheduleRenderUpdate();
|
||||
((IToolWrench) equipped).wrenchUsed(entityplayer, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord);
|
||||
|
||||
|
|
|
@ -36,13 +36,22 @@ public abstract class PipeLogicWood {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (newFacing == null) {
|
||||
newFacing = ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
if (newFacing.ordinal() != meta) {
|
||||
pipe.container.getWorldObj().setBlockMetadataWithNotify(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, newFacing.ordinal(), 3);
|
||||
pipe.container.scheduleRenderUpdate();
|
||||
setSource(newFacing);
|
||||
}
|
||||
|
||||
private void setSource(ForgeDirection newFacing) {
|
||||
if (newFacing == ForgeDirection.UNKNOWN || isValidFacing(newFacing)) {
|
||||
int meta = pipe.container.getBlockMetadata();
|
||||
|
||||
if (newFacing.ordinal() != meta) {
|
||||
pipe.container.getWorldObj().setBlockMetadataWithNotify(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, newFacing.ordinal(), 3);
|
||||
pipe.container.scheduleRenderUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,10 +94,14 @@ public abstract class PipeLogicWood {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean blockActivated(EntityPlayer entityplayer) {
|
||||
public boolean blockActivated(EntityPlayer entityplayer, ForgeDirection side) {
|
||||
Item equipped = entityplayer.getCurrentEquippedItem() != null ? entityplayer.getCurrentEquippedItem().getItem() : null;
|
||||
if (equipped instanceof IToolWrench && ((IToolWrench) equipped).canWrench(entityplayer, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord)) {
|
||||
switchSource();
|
||||
if (side != ForgeDirection.UNKNOWN) {
|
||||
setSource(side);
|
||||
} else {
|
||||
switchSource();
|
||||
}
|
||||
((IToolWrench) equipped).wrenchUsed(entityplayer, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue