Merge branch 'master' of github.com:SirSengir/BuildCraft
This commit is contained in:
commit
d333eafeeb
5 changed files with 33 additions and 17 deletions
|
@ -2,6 +2,7 @@ package buildcraft.core;
|
||||||
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import buildcraft.api.tools.IToolWrench;
|
import buildcraft.api.tools.IToolWrench;
|
||||||
|
|
||||||
public class ItemWrench extends ItemBuildCraft implements IToolWrench {
|
public class ItemWrench extends ItemBuildCraft implements IToolWrench {
|
||||||
|
@ -19,4 +20,10 @@ public class ItemWrench extends ItemBuildCraft implements IToolWrench {
|
||||||
@Override
|
@Override
|
||||||
public void wrenchUsed(EntityPlayer player, int x, int y, int z) {
|
public void wrenchUsed(EntityPlayer player, int x, int y, int z) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldPassSneakingClickToBlock(World par2World, int par4, int par5, int par6)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,35 +68,34 @@ public class TransactorSimple extends Transactor {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int addToSlot(int slot, ItemStack stack, int injected, boolean doAdd) {
|
protected int addToSlot(int slot, ItemStack stack, int injected, boolean doAdd) {
|
||||||
int remaining = stack.stackSize - injected;
|
int available = stack.stackSize - injected;
|
||||||
|
int max = Math.min(stack.getMaxStackSize(), inventory.getInventoryStackLimit());
|
||||||
|
|
||||||
ItemStack stackInSlot = inventory.getStackInSlot(slot);
|
ItemStack stackInSlot = inventory.getStackInSlot(slot);
|
||||||
if (stackInSlot == null) {
|
if (stackInSlot == null) {
|
||||||
|
int wanted = Math.min(available, max);
|
||||||
if (doAdd) {
|
if (doAdd) {
|
||||||
stackInSlot = stack.copy();
|
stackInSlot = stack.copy();
|
||||||
stackInSlot.stackSize = remaining;
|
stackInSlot.stackSize = wanted;
|
||||||
inventory.setInventorySlotContents(slot, stackInSlot);
|
inventory.setInventorySlotContents(slot, stackInSlot);
|
||||||
}
|
}
|
||||||
return remaining;
|
return wanted;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stackInSlot.isItemEqual(stack) || !ItemStack.areItemStackTagsEqual(stackInSlot, stack))
|
if (!stackInSlot.isItemEqual(stack) || !ItemStack.areItemStackTagsEqual(stackInSlot, stack))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int space = stackInSlot.getMaxStackSize() - stackInSlot.stackSize;
|
int wanted = max - stackInSlot.stackSize;
|
||||||
if (space <= 0)
|
if (wanted <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (space >= remaining) {
|
if (wanted > available)
|
||||||
if (doAdd) {
|
wanted = available;
|
||||||
stackInSlot.stackSize += remaining;
|
|
||||||
}
|
if (doAdd) {
|
||||||
return remaining;
|
stackInSlot.stackSize += wanted;
|
||||||
} else {
|
inventory.setInventorySlotContents(slot, stackInSlot);
|
||||||
if (doAdd) {
|
|
||||||
stackInSlot.stackSize = stackInSlot.getMaxStackSize();
|
|
||||||
}
|
|
||||||
return space;
|
|
||||||
}
|
}
|
||||||
|
return wanted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,7 @@ public class InventoryUtil {
|
||||||
int itemsToMove = stack.getMaxStackSize() - stack.stackSize;
|
int itemsToMove = stack.getMaxStackSize() - stack.stackSize;
|
||||||
stack.stackSize += itemsToMove;
|
stack.stackSize += itemsToMove;
|
||||||
stackToMove.stackSize -= itemsToMove;
|
stackToMove.stackSize -= itemsToMove;
|
||||||
|
_inventory.setInventorySlotContents(i, stackToMove);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return stackToMove;
|
return stackToMove;
|
||||||
|
|
|
@ -58,6 +58,15 @@ public class BlockEngine extends BlockContainer {
|
||||||
return new TileEngine();
|
return new TileEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side) {
|
||||||
|
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||||
|
if (tile instanceof TileEngine) {
|
||||||
|
return ForgeDirection.getOrientation(((TileEngine) tile).orientation).getOpposite() == side;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, int x, int y, int z, int par5, int par6) {
|
public void breakBlock(World world, int x, int y, int z, int par5, int par6) {
|
||||||
TileEngine engine = ((TileEngine) world.getBlockTileEntity(x, y, z));
|
TileEngine engine = ((TileEngine) world.getBlockTileEntity(x, y, z));
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class TileEngine extends TileBuildCraft implements IPowerReceptor, IInven
|
||||||
createEngineIfNeeded();
|
createEngineIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
engine.orientation = ForgeDirection.values()[orientation];
|
engine.orientation = ForgeDirection.VALID_DIRECTIONS[orientation];
|
||||||
provider.configure(0, engine.minEnergyReceived(), engine.maxEnergyReceived(), 1, engine.maxEnergy);
|
provider.configure(0, engine.minEnergyReceived(), engine.maxEnergyReceived(), 1, engine.maxEnergy);
|
||||||
checkRedstonePower();
|
checkRedstonePower();
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ public class TileEngine extends TileBuildCraft implements IPowerReceptor, IInven
|
||||||
|
|
||||||
engine = newEngine(kind);
|
engine = newEngine(kind);
|
||||||
|
|
||||||
engine.orientation = ForgeDirection.values()[orientation];
|
engine.orientation = ForgeDirection.VALID_DIRECTIONS[orientation];
|
||||||
worldObj.notifyBlockChange(xCoord, yCoord, zCoord, BuildCraftEnergy.engineBlock.blockID);
|
worldObj.notifyBlockChange(xCoord, yCoord, zCoord, BuildCraftEnergy.engineBlock.blockID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue