mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-21 12:42:57 +00:00
Seared Tank more often provides an empty container when filled.
This commit is contained in:
1 parent
5b9d62f5c5
commit
f5e67dd529
1 file changed
+30
-14
@@ -150,8 +150,8 @@ public class LavaTankBlock extends BlockContainer {
|
||||
int amount = logic.fill(ForgeDirection.UNKNOWN, liquid, false);
|
||||
if (amount == liquid.amount) {
|
||||
logic.fill(ForgeDirection.UNKNOWN, liquid, true);
|
||||
if (!entityplayer.capabilities.isCreativeMode) entityplayer.inventory
|
||||
.setInventorySlotContents(entityplayer.inventory.currentItem, consumeItem(current));
|
||||
if (!entityplayer.capabilities.isCreativeMode)
|
||||
replaceHeldItem(entityplayer, getEmptyContainer(entityplayer.inventory.getCurrentItem()));
|
||||
|
||||
// update
|
||||
entityplayer.inventoryContainer.detectAndSendChanges();
|
||||
@@ -172,18 +172,7 @@ public class LavaTankBlock extends BlockContainer {
|
||||
FluidContainerRegistry.getFluidForFilledItem(fillStack).amount,
|
||||
true);
|
||||
if (!entityplayer.capabilities.isCreativeMode && !world.isRemote) {
|
||||
if (current.stackSize == 1) {
|
||||
entityplayer.inventory
|
||||
.setInventorySlotContents(entityplayer.inventory.currentItem, fillStack);
|
||||
} else {
|
||||
entityplayer.inventory.setInventorySlotContents(
|
||||
entityplayer.inventory.currentItem,
|
||||
consumeItem(current));
|
||||
|
||||
if (!entityplayer.inventory.addItemStackToInventory(fillStack)) {
|
||||
entityplayer.dropPlayerItemWithRandomChoice(fillStack, false);
|
||||
}
|
||||
}
|
||||
replaceHeldItem(entityplayer, fillStack);
|
||||
|
||||
// update inventory
|
||||
entityplayer.inventoryContainer.detectAndSendChanges();
|
||||
@@ -200,6 +189,33 @@ public class LavaTankBlock extends BlockContainer {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static ItemStack getEmptyContainer(ItemStack stack) {
|
||||
Item item = stack.getItem();
|
||||
if (item != null && item.hasContainerItem(stack)) return item.getContainerItem(stack);
|
||||
else if (FluidContainerRegistry.isFilledContainer(stack))
|
||||
return FluidContainerRegistry.drainFluidContainer(stack);
|
||||
else return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace one currently held item for a given player.
|
||||
*
|
||||
* @param player A player
|
||||
* @param replacement An ItemStack that will replace one of the items in the player's currently held ItemStack.
|
||||
*/
|
||||
private static void replaceHeldItem(EntityPlayer player, ItemStack replacement) {
|
||||
ItemStack current = player.inventory.getCurrentItem();
|
||||
if (current.stackSize == 1) {
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, replacement);
|
||||
} else {
|
||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
|
||||
if (!player.inventory.addItemStackToInventory(replacement)) {
|
||||
player.dropPlayerItemWithRandomChoice(replacement, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack consumeItem(ItemStack stack) {
|
||||
if (stack.stackSize == 1) {
|
||||
if (stack.getItem().hasContainerItem()) return stack.getItem().getContainerItem(stack);
|
||||
|
||||
Reference in new issue
Block a user