mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Dupe fix!!!
This commit is contained in:
parent
fa6d2a4e56
commit
aaff6b9b70
@ -2,6 +2,9 @@ package com.hbm.inventory;
|
|||||||
|
|
||||||
import com.hbm.interfaces.NotableComments;
|
import com.hbm.interfaces.NotableComments;
|
||||||
|
|
||||||
|
import com.hbm.inventory.container.ContainerCrateBase;
|
||||||
|
import com.hbm.items.block.ItemBlockStorageCrate;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
@ -33,4 +36,17 @@ public class SlotNonRetarded extends Slot {
|
|||||||
public int getSlotStackLimit() {
|
public int getSlotStackLimit() {
|
||||||
return Math.max(this.inventory.getInventoryStackLimit(), this.getHasStack() ? this.getStack().stackSize : 1);
|
return Math.max(this.inventory.getInventoryStackLimit(), this.getHasStack() ? this.getStack().stackSize : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This prevents the player from moving containers that are being held *at all*, fixing a decently big dupe.
|
||||||
|
* I hate that this has to be here but... It is what it is.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean canTakeStack(EntityPlayer player) {
|
||||||
|
if(player.inventory.currentItem == this.getSlotIndex() && // If this slot is the current held slot.
|
||||||
|
this.getStack() != null && this.getStack().getItem() instanceof ItemBlockStorageCrate && // If the slot contains a storage crate.
|
||||||
|
player.openContainer instanceof ContainerCrateBase) // If the player is currently inside a crate container.
|
||||||
|
return false;
|
||||||
|
return super.canTakeStack(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.hbm.inventory.container;
|
package com.hbm.inventory.container;
|
||||||
|
|
||||||
|
import com.hbm.inventory.SlotNonRetarded;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
@ -61,12 +62,12 @@ public class ContainerBase extends Container {
|
|||||||
public void playerInv(InventoryPlayer invPlayer, int playerInvX, int playerInvY, int playerHotbarY) {
|
public void playerInv(InventoryPlayer invPlayer, int playerInvX, int playerInvY, int playerHotbarY) {
|
||||||
for(int i = 0; i < 3; i++) {
|
for(int i = 0; i < 3; i++) {
|
||||||
for(int j = 0; j < 9; j++) {
|
for(int j = 0; j < 9; j++) {
|
||||||
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, playerInvX + j * 18, playerInvY + i * 18));
|
this.addSlotToContainer(new SlotNonRetarded(invPlayer, j + i * 9 + 9, playerInvX + j * 18, playerInvY + i * 18));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < 9; i++) {
|
for(int i = 0; i < 9; i++) {
|
||||||
this.addSlotToContainer(new Slot(invPlayer, i, playerInvX + i * 18, playerHotbarY));
|
this.addSlotToContainer(new SlotNonRetarded(invPlayer, i, playerInvX + i * 18, playerHotbarY));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +84,7 @@ public class ContainerBase extends Container {
|
|||||||
int slotSize = 18;
|
int slotSize = 18;
|
||||||
for(int row = 0; row < rows; row++) {
|
for(int row = 0; row < rows; row++) {
|
||||||
for(int col = 0; col < cols; col++) {
|
for(int col = 0; col < cols; col++) {
|
||||||
this.addSlotToContainer(new Slot(inv, col + row * cols + from, x + col * slotSize, y + row * slotSize));
|
this.addSlotToContainer(new SlotNonRetarded(inv, col + row * cols + from, x + col * slotSize, y + row * slotSize));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user