This commit is contained in:
Boblet 2025-02-06 16:48:29 +01:00
parent fe9808f621
commit b60db5b911
3 changed files with 89 additions and 73 deletions

View File

@ -33,14 +33,28 @@ public abstract class ContainerNT extends Container {
return null; return null;
} }
// fuck you mojang
@Override @Override
public ItemStack slotClick(int index, int button, int mode, EntityPlayer player) { public ItemStack slotClick(int index, int button, int mode, EntityPlayer player) {
ItemStack itemstack = null; /*
* INDEX
* -999: Mouse outside GUI
* MODE
* 2: Hotbar keys
* 3: Duplicate item
* 4: Drop item
* 5: Drag
*/
ItemStack returnStack = null;
InventoryPlayer invPlayer = player.inventory; InventoryPlayer invPlayer = player.inventory;
Slot slot = index >= 0 && index < this.inventorySlots.size() ? (Slot) this.inventorySlots.get(index) : null;
int i1; int i1;
ItemStack itemstack3; ItemStack itemstack3;
/// DRAG ///
if(mode == 5) { if(mode == 5) {
int l = this.field_94536_g; int l = this.field_94536_g;
this.field_94536_g = func_94532_c(button); this.field_94536_g = func_94532_c(button);
@ -59,7 +73,6 @@ public abstract class ContainerNT extends Container {
this.func_94533_d(); this.func_94533_d();
} }
} else if(this.field_94536_g == 1) { } else if(this.field_94536_g == 1) {
Slot slot = (Slot) this.inventorySlots.get(index);
if(slot != null && func_94527_a(slot, invPlayer.getItemStack(), true) && slot.isItemValid(invPlayer.getItemStack()) if(slot != null && func_94527_a(slot, invPlayer.getItemStack(), true) && slot.isItemValid(invPlayer.getItemStack())
&& invPlayer.getItemStack().stackSize > this.field_94537_h.size() && this.canDragIntoSlot(slot)) { && invPlayer.getItemStack().stackSize > this.field_94537_h.size() && this.canDragIntoSlot(slot)) {
@ -106,13 +119,17 @@ public abstract class ContainerNT extends Container {
} else { } else {
this.func_94533_d(); this.func_94533_d();
} }
/// NOBODY KNOWS ///
} else if(this.field_94536_g != 0) { } else if(this.field_94536_g != 0) {
this.func_94533_d(); this.func_94533_d();
/// NON-DRAG ///
} else { } else {
Slot slot2;
int l1; int l1;
ItemStack itemstack5; ItemStack itemstack5;
/// LMB/RMB ///
if((mode == 0 || mode == 1) && (button == 0 || button == 1)) { if((mode == 0 || mode == 1) && (button == 0 || button == 1)) {
if(index == -999) { if(index == -999) {
if(invPlayer.getItemStack() != null && index == -999) { if(invPlayer.getItemStack() != null && index == -999) {
@ -134,16 +151,16 @@ public abstract class ContainerNT extends Container {
return null; return null;
} }
slot2 = (Slot) this.inventorySlots.get(index); slot = (Slot) this.inventorySlots.get(index);
if(slot2 != null && slot2.canTakeStack(player)) { if(slot != null && slot.canTakeStack(player)) {
itemstack3 = this.transferStackInSlot(player, index); itemstack3 = this.transferStackInSlot(player, index);
if(itemstack3 != null) { if(itemstack3 != null) {
Item item = itemstack3.getItem(); Item item = itemstack3.getItem();
itemstack = itemstack3.copy(); returnStack = itemstack3.copy();
if(slot2.getStack() != null && slot2.getStack().getItem() == item) { if(slot.getStack() != null && slot.getStack().getItem() == item) {
this.retrySlotClick(index, button, true, player); this.retrySlotClick(index, button, true, player);
} }
} }
@ -153,93 +170,93 @@ public abstract class ContainerNT extends Container {
return null; return null;
} }
slot2 = (Slot) this.inventorySlots.get(index); slot = (Slot) this.inventorySlots.get(index);
if(slot2 != null) { if(slot != null) {
itemstack3 = slot2.getStack(); itemstack3 = slot.getStack();
ItemStack itemstack4 = invPlayer.getItemStack(); ItemStack draggedStack = invPlayer.getItemStack();
if(itemstack3 != null) { if(itemstack3 != null) {
itemstack = itemstack3.copy(); returnStack = itemstack3.copy();
} }
if(itemstack3 == null) { if(itemstack3 == null) {
if(itemstack4 != null && slot2.isItemValid(itemstack4)) { if(draggedStack != null && slot.isItemValid(draggedStack)) {
l1 = button == 0 ? itemstack4.stackSize : 1; l1 = button == 0 ? draggedStack.stackSize : 1;
if(l1 > slot2.getSlotStackLimit()) { if(l1 > slot.getSlotStackLimit()) {
l1 = slot2.getSlotStackLimit(); l1 = slot.getSlotStackLimit();
} }
if(itemstack4.stackSize >= l1) { if(draggedStack.stackSize >= l1) {
slot2.putStack(itemstack4.splitStack(l1)); slot.putStack(draggedStack.splitStack(l1));
} }
if(itemstack4.stackSize == 0) { if(draggedStack.stackSize == 0) {
invPlayer.setItemStack((ItemStack) null); invPlayer.setItemStack((ItemStack) null);
} }
} }
} else if(slot2.canTakeStack(player)) { } else if(slot.canTakeStack(player)) {
if(itemstack4 == null) { if(draggedStack == null) {
l1 = button == 0 ? itemstack3.stackSize : (itemstack3.stackSize + 1) / 2; l1 = button == 0 ? itemstack3.stackSize : (itemstack3.stackSize + 1) / 2;
itemstack5 = slot2.decrStackSize(l1); itemstack5 = slot.decrStackSize(l1);
invPlayer.setItemStack(itemstack5); invPlayer.setItemStack(itemstack5);
if(itemstack3.stackSize == 0) { if(itemstack3.stackSize == 0) {
slot2.putStack((ItemStack) null); slot.putStack((ItemStack) null);
} }
slot2.onPickupFromSlot(player, invPlayer.getItemStack()); slot.onPickupFromSlot(player, invPlayer.getItemStack());
} else if(slot2.isItemValid(itemstack4)) { } else if(slot.isItemValid(draggedStack)) {
if(itemstack3.getItem() == itemstack4.getItem() && itemstack3.getItemDamage() == itemstack4.getItemDamage() if(itemstack3.getItem() == draggedStack.getItem() && itemstack3.getItemDamage() == draggedStack.getItemDamage()
&& ItemStack.areItemStackTagsEqual(itemstack3, itemstack4)) { && ItemStack.areItemStackTagsEqual(itemstack3, draggedStack)) {
l1 = button == 0 ? itemstack4.stackSize : 1; l1 = button == 0 ? draggedStack.stackSize : 1;
if(l1 > slot2.getSlotStackLimit() - itemstack3.stackSize) { if(l1 > slot.getSlotStackLimit() - itemstack3.stackSize) {
l1 = slot2.getSlotStackLimit() - itemstack3.stackSize; l1 = slot.getSlotStackLimit() - itemstack3.stackSize;
} }
if(l1 > itemstack4.getMaxStackSize() - itemstack3.stackSize) { if(l1 > draggedStack.getMaxStackSize() - itemstack3.stackSize) {
l1 = itemstack4.getMaxStackSize() - itemstack3.stackSize; l1 = draggedStack.getMaxStackSize() - itemstack3.stackSize;
} }
itemstack4.splitStack(l1); draggedStack.splitStack(l1);
if(itemstack4.stackSize == 0) { if(draggedStack.stackSize == 0) {
invPlayer.setItemStack((ItemStack) null); invPlayer.setItemStack((ItemStack) null);
} }
itemstack3.stackSize += l1; itemstack3.stackSize += l1;
} else if(itemstack4.stackSize <= slot2.getSlotStackLimit()) { } else if(draggedStack.stackSize <= slot.getSlotStackLimit()) {
slot2.putStack(itemstack4); slot.putStack(draggedStack);
invPlayer.setItemStack(itemstack3); invPlayer.setItemStack(itemstack3);
} }
} else if(itemstack3.getItem() == itemstack4.getItem() && itemstack4.getMaxStackSize() > 1 } else if(itemstack3.getItem() == draggedStack.getItem() && draggedStack.getMaxStackSize() > 1
&& (!itemstack3.getHasSubtypes() || itemstack3.getItemDamage() == itemstack4.getItemDamage()) && ItemStack.areItemStackTagsEqual(itemstack3, itemstack4)) { && (!itemstack3.getHasSubtypes() || itemstack3.getItemDamage() == draggedStack.getItemDamage()) && ItemStack.areItemStackTagsEqual(itemstack3, draggedStack)) {
l1 = itemstack3.stackSize; l1 = itemstack3.stackSize;
if(l1 > 0 && l1 + itemstack4.stackSize <= itemstack4.getMaxStackSize()) { if(l1 > 0 && l1 + draggedStack.stackSize <= draggedStack.getMaxStackSize()) {
itemstack4.stackSize += l1; draggedStack.stackSize += l1;
itemstack3 = slot2.decrStackSize(l1); itemstack3 = slot.decrStackSize(l1);
if(itemstack3.stackSize == 0) { if(itemstack3.stackSize == 0) {
slot2.putStack((ItemStack) null); slot.putStack((ItemStack) null);
} }
slot2.onPickupFromSlot(player, invPlayer.getItemStack()); slot.onPickupFromSlot(player, invPlayer.getItemStack());
} }
} }
} }
slot2.onSlotChanged(); slot.onSlotChanged();
} }
} }
} else if(mode == 2 && button >= 0 && button < 9) { } else if(mode == 2 && button >= 0 && button < 9) {
slot2 = (Slot) this.inventorySlots.get(index); slot = (Slot) this.inventorySlots.get(index);
if(slot2.canTakeStack(player)) { if(slot.canTakeStack(player)) {
itemstack3 = invPlayer.getStackInSlot(button); itemstack3 = invPlayer.getStackInSlot(button);
boolean flag = itemstack3 == null || slot2.inventory == invPlayer && slot2.isItemValid(itemstack3); boolean flag = itemstack3 == null || slot.inventory == invPlayer && slot.isItemValid(itemstack3);
l1 = -1; l1 = -1;
if(!flag) { if(!flag) {
@ -247,48 +264,48 @@ public abstract class ContainerNT extends Container {
flag |= l1 > -1; flag |= l1 > -1;
} }
if(slot2.getHasStack() && flag) { if(slot.getHasStack() && flag) {
itemstack5 = slot2.getStack(); itemstack5 = slot.getStack();
invPlayer.setInventorySlotContents(button, itemstack5.copy()); invPlayer.setInventorySlotContents(button, itemstack5.copy());
if((slot2.inventory != invPlayer || !slot2.isItemValid(itemstack3)) && itemstack3 != null) { if((slot.inventory != invPlayer || !slot.isItemValid(itemstack3)) && itemstack3 != null) {
if(l1 > -1) { if(l1 > -1) {
invPlayer.addItemStackToInventory(itemstack3); invPlayer.addItemStackToInventory(itemstack3);
slot2.decrStackSize(itemstack5.stackSize); slot.decrStackSize(itemstack5.stackSize);
slot2.putStack((ItemStack) null); slot.putStack((ItemStack) null);
slot2.onPickupFromSlot(player, itemstack5); slot.onPickupFromSlot(player, itemstack5);
} }
} else { } else {
slot2.decrStackSize(itemstack5.stackSize); slot.decrStackSize(itemstack5.stackSize);
slot2.putStack(itemstack3); slot.putStack(itemstack3);
slot2.onPickupFromSlot(player, itemstack5); slot.onPickupFromSlot(player, itemstack5);
} }
} else if(!slot2.getHasStack() && itemstack3 != null && slot2.isItemValid(itemstack3)) { } else if(!slot.getHasStack() && itemstack3 != null && slot.isItemValid(itemstack3)) {
invPlayer.setInventorySlotContents(button, (ItemStack) null); invPlayer.setInventorySlotContents(button, (ItemStack) null);
slot2.putStack(itemstack3); slot.putStack(itemstack3);
} }
} }
} else if(mode == 3 && player.capabilities.isCreativeMode && invPlayer.getItemStack() == null && index >= 0) { } else if(mode == 3 && player.capabilities.isCreativeMode && invPlayer.getItemStack() == null && index >= 0) {
slot2 = (Slot) this.inventorySlots.get(index); slot = (Slot) this.inventorySlots.get(index);
if(slot2 != null && slot2.getHasStack()) { if(slot != null && slot.getHasStack()) {
itemstack3 = slot2.getStack().copy(); itemstack3 = slot.getStack().copy();
itemstack3.stackSize = itemstack3.getMaxStackSize(); itemstack3.stackSize = itemstack3.getMaxStackSize();
invPlayer.setItemStack(itemstack3); invPlayer.setItemStack(itemstack3);
} }
} else if(mode == 4 && invPlayer.getItemStack() == null && index >= 0) { } else if(mode == 4 && invPlayer.getItemStack() == null && index >= 0) {
slot2 = (Slot) this.inventorySlots.get(index); slot = (Slot) this.inventorySlots.get(index);
if(slot2 != null && slot2.getHasStack() && slot2.canTakeStack(player)) { if(slot != null && slot.getHasStack() && slot.canTakeStack(player)) {
itemstack3 = slot2.decrStackSize(button == 0 ? 1 : slot2.getStack().stackSize); itemstack3 = slot.decrStackSize(button == 0 ? 1 : slot.getStack().stackSize);
slot2.onPickupFromSlot(player, itemstack3); slot.onPickupFromSlot(player, itemstack3);
player.dropPlayerItemWithRandomChoice(itemstack3, true); player.dropPlayerItemWithRandomChoice(itemstack3, true);
} }
} else if(mode == 6 && index >= 0) { } else if(mode == 6 && index >= 0) {
slot2 = (Slot) this.inventorySlots.get(index); slot = (Slot) this.inventorySlots.get(index);
itemstack3 = invPlayer.getItemStack(); itemstack3 = invPlayer.getItemStack();
if(itemstack3 != null && (slot2 == null || !slot2.getHasStack() || !slot2.canTakeStack(player))) { if(itemstack3 != null && (slot == null || !slot.getHasStack() || !slot.canTakeStack(player))) {
i1 = button == 0 ? 0 : this.inventorySlots.size() - 1; i1 = button == 0 ? 0 : this.inventorySlots.size() - 1;
l1 = button == 0 ? 1 : -1; l1 = button == 0 ? 1 : -1;
@ -316,6 +333,6 @@ public abstract class ContainerNT extends Container {
} }
} }
return itemstack; return returnStack;
} }
} }

View File

@ -114,11 +114,12 @@ public class TileEntityPADetector extends TileEntityCooledBase implements IGUIPr
if(particle.defocus > 0) { particle.crash(PAState.CRASH_DEFOCUS); return; } if(particle.defocus > 0) { particle.crash(PAState.CRASH_DEFOCUS); return; }
if(this.power < usage) { particle.crash(PAState.CRASH_NOPOWER); return; } if(this.power < usage) { particle.crash(PAState.CRASH_NOPOWER); return; }
if(!isCool()) { particle.crash(PAState.CRASH_NOCOOL); return; } if(!isCool()) { particle.crash(PAState.CRASH_NOCOOL); return; }
this.power -= usage;
for(ParticleAcceleratorRecipe recipe : ParticleAcceleratorRecipes.recipes) { for(ParticleAcceleratorRecipe recipe : ParticleAcceleratorRecipes.recipes) {
if(!recipe.matchesRecipe(particle.input1, particle.input2)) continue; // another W for continue if(!recipe.matchesRecipe(particle.input1, particle.input2)) continue; // another W for continue
if(particle.momentum < recipe.momentum) { if(particle.momentum < recipe.momentum) {
this.power -= usage;
particle.crash(PAState.CRASH_UNDERSPEED); particle.crash(PAState.CRASH_UNDERSPEED);
return; return;
} }
@ -141,12 +142,10 @@ public class TileEntityPADetector extends TileEntityCooledBase implements IGUIPr
} }
} }
} }
this.power -= usage;
particle.crash(PAState.SUCCESS); particle.crash(PAState.SUCCESS);
return; return;
} }
this.power -= usage;
particle.crash(PAState.CRASH_NORECIPE); particle.crash(PAState.CRASH_NORECIPE);
} }

View File

@ -4866,9 +4866,9 @@ pa.crash_nocoil.desc=The particle has entered a dipole$or quadrupole which lacks
pa.crash_overspeed=Overspeed! pa.crash_overspeed=Overspeed!
pa.crash_overspeed.desc=The particle has entered a dipole$or quadrupole, while its speed exceeded$the coil's rating. Install higher$tier coils, or configure the dipoles$to leave the accelerator ring sooner. pa.crash_overspeed.desc=The particle has entered a dipole$or quadrupole, while its speed exceeded$the coil's rating. Install higher$tier coils, or configure the dipoles$to leave the accelerator ring sooner.
pa.crash_norecipe=No recipe! pa.crash_norecipe=No recipe!
pa.crash_norecipe.desc=The particle entered a detector with an invalid set of inputs. Ensure the particle source inputs match a valid recipe. pa.crash_norecipe.desc=The particle entered a detector$with an invalid set of inputs.$Ensure the particle source inputs$match a valid recipe.
pa.crash_underspeed=Underspeed! pa.crash_underspeed=Underspeed!
pa.crash_underspeed.desc=The particle entered a detector with insufficient speed to perform the current recipe. Ensure the accelerator is configured correctly for the recipe. pa.crash_underspeed.desc=The particle entered a detector$with insufficient speed to perform$the current recipe. Ensure the$accelerator is configured$correctly for the recipe.
potion.hbm_bang=! ! ! potion.hbm_bang=! ! !
potion.hbm_death=Astolfization potion.hbm_death=Astolfization