Fixed pipes replacing other blocks in certain instances.

This commit is contained in:
SirSengir 2012-09-08 15:58:30 +02:00
parent 5a6fcf03d2
commit 5059cd9abe
4 changed files with 25 additions and 15 deletions

View file

@ -0,0 +1,10 @@
package buildcraft.core.inventory;
import net.minecraft.src.ItemStack;
import buildcraft.api.core.Orientations;
public interface ITransactor {
ItemStack add(ItemStack stack, Orientations orientation, boolean doAdd);
}

View file

@ -6,8 +6,9 @@ import net.minecraft.src.IInventory;
import net.minecraft.src.ItemStack;
import net.minecraftforge.common.ISidedInventory;
public abstract class Transactor {
public abstract class Transactor implements ITransactor {
@Override
public ItemStack add(ItemStack stack, Orientations orientation, boolean doAdd) {
ItemStack added = stack.copy();
added.stackSize = inject(stack, orientation, doAdd);
@ -16,7 +17,7 @@ public abstract class Transactor {
public abstract int inject(ItemStack stack, Orientations orientation, boolean doAdd);
public static Transactor getTransactorFor(Object object) {
public static ITransactor getTransactorFor(Object object) {
if(object instanceof ISpecialInventory)
return new TransactorSpecial((ISpecialInventory)object);

View file

@ -136,7 +136,7 @@ public class BlockGenericPipe extends BlockContainer {
}
@SuppressWarnings({ "all" })
// @Override (client only)
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int i, int j, int k) {
return getCollisionBoundingBoxFromPool(world, i, j, k);
}
@ -472,7 +472,7 @@ public class BlockGenericPipe extends BlockContainer {
}
@SuppressWarnings({ "all" })
// @Override (client only)
@Override
public void randomDisplayTick(World world, int i, int j, int k, Random random) {
Pipe pipe = getPipe(world, i, j, k);

View file

@ -30,35 +30,34 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe {
}
@Override
public boolean tryPlaceIntoWorld(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l, float par8, float par9, float par10) {
public boolean tryPlaceIntoWorld(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int side, float par8, float par9, float par10) {
int blockID = BuildCraftTransport.genericPipeBlock.blockID;
if (world.getBlockId(i, j, k) == Block.snow.blockID)
l = 0;
side = 0;
else {
if (l == 0)
if (side == 0)
j--;
if (l == 1)
if (side == 1)
j++;
if (l == 2)
if (side == 2)
k--;
if (l == 3)
if (side == 3)
k++;
if (l == 4)
if (side == 4)
i--;
if (l == 5)
if (side == 5)
i++;
}
if (itemstack.stackSize == 0)
return false;
if (entityplayer.canPlayerEdit(i, j, k)){
// if (world.canBlockBePlacedAt(blockID, i, j, k, false, l)) {
if (entityplayer.canPlayerEdit(i, j, k)
&& world.canPlaceEntityOnSide(blockID, i, j, k, false, side, entityplayer)) {
Pipe pipe = BlockGenericPipe.createPipe(shiftedIndex);
if (BlockGenericPipe.placePipe(pipe, world, i, j, k, blockID, 0)) {
//Block.blocksList[blockID].onBlockPlaced(world, i, j, k, l);
Block.blocksList[blockID].onBlockPlacedBy(world, i, j, k, entityplayer);
// To move to a proxt
// world.playSoundEffect((float)i + 0.5F, (float)j + 0.5F,