mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Merge pull request #2158 from MellowArpeggiation/master
the five hundredth crate dupe fix
This commit is contained in:
commit
c7f570706d
@ -7,6 +7,7 @@ import api.hbm.conveyor.IEnterableBlock;
|
|||||||
import com.hbm.blocks.IBlockMultiPass;
|
import com.hbm.blocks.IBlockMultiPass;
|
||||||
import com.hbm.blocks.ITooltipProvider;
|
import com.hbm.blocks.ITooltipProvider;
|
||||||
import com.hbm.entity.item.EntityMovingItem;
|
import com.hbm.entity.item.EntityMovingItem;
|
||||||
|
import com.hbm.items.tool.ItemConveyorWand;
|
||||||
import com.hbm.lib.RefStrings;
|
import com.hbm.lib.RefStrings;
|
||||||
import com.hbm.main.MainRegistry;
|
import com.hbm.main.MainRegistry;
|
||||||
import com.hbm.module.ModulePatternMatcher;
|
import com.hbm.module.ModulePatternMatcher;
|
||||||
@ -61,7 +62,9 @@ public class CraneRouter extends BlockContainer implements IBlockMultiPass, IEnt
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||||
if(world.isRemote) {
|
if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemConveyorWand) {
|
||||||
|
return false;
|
||||||
|
} else if(world.isRemote) {
|
||||||
return true;
|
return true;
|
||||||
} else if(!player.isSneaking()) {
|
} else if(!player.isSneaking()) {
|
||||||
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
|
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
|
||||||
|
|||||||
@ -17,7 +17,7 @@ public class ServerConfig extends RunningConfig {
|
|||||||
public static ConfigWrapper<Float> MINE_NUKE_DAMAGE = new ConfigWrapper(100F);
|
public static ConfigWrapper<Float> MINE_NUKE_DAMAGE = new ConfigWrapper(100F);
|
||||||
public static ConfigWrapper<Float> MINE_NAVAL_DAMAGE = new ConfigWrapper(60F);
|
public static ConfigWrapper<Float> MINE_NAVAL_DAMAGE = new ConfigWrapper(60F);
|
||||||
public static ConfigWrapper<Boolean> TAINT_TRAILS = new ConfigWrapper(false);
|
public static ConfigWrapper<Boolean> TAINT_TRAILS = new ConfigWrapper(false);
|
||||||
public static ConfigWrapper<Boolean> CRATE_ALLOW_OPEN_HELD = new ConfigWrapper(false);
|
public static ConfigWrapper<Boolean> CRATE_ALLOW_OPEN_HELD = new ConfigWrapper(true);
|
||||||
public static ConfigWrapper<Boolean> CRATE_KEEP_CONTENTS = new ConfigWrapper(true);
|
public static ConfigWrapper<Boolean> CRATE_KEEP_CONTENTS = new ConfigWrapper(true);
|
||||||
public static ConfigWrapper<Integer> ITEM_HAZARD_DROP_TICKRATE = new ConfigWrapper(2);
|
public static ConfigWrapper<Integer> ITEM_HAZARD_DROP_TICKRATE = new ConfigWrapper(2);
|
||||||
|
|
||||||
|
|||||||
@ -10,9 +10,6 @@ import net.minecraft.tileentity.TileEntity;
|
|||||||
|
|
||||||
public class ContainerCrateBase extends ContainerBase {
|
public class ContainerCrateBase extends ContainerBase {
|
||||||
|
|
||||||
//just there so prev stuff doesnt break
|
|
||||||
protected IInventory crate = tile;
|
|
||||||
|
|
||||||
public ContainerCrateBase(InventoryPlayer invPlayer, IInventory tedf) {
|
public ContainerCrateBase(InventoryPlayer invPlayer, IInventory tedf) {
|
||||||
super(invPlayer, tedf);
|
super(invPlayer, tedf);
|
||||||
tile.openInventory();
|
tile.openInventory();
|
||||||
@ -35,7 +32,7 @@ public class ContainerCrateBase extends ContainerBase {
|
|||||||
public ItemStack slotClick(int index, int button, int mode, EntityPlayer player) {
|
public ItemStack slotClick(int index, int button, int mode, EntityPlayer player) {
|
||||||
// prevents the player from moving around the currently open box
|
// prevents the player from moving around the currently open box
|
||||||
if(player.inventory.getStackInSlot(player.inventory.currentItem) != null &&
|
if(player.inventory.getStackInSlot(player.inventory.currentItem) != null &&
|
||||||
player.inventory.getStackInSlot(player.inventory.currentItem).getItem() instanceof ItemBlockStorageCrate && !(this.crate instanceof TileEntity)) {
|
player.inventory.getStackInSlot(player.inventory.currentItem).getItem() instanceof ItemBlockStorageCrate && !(this.tile instanceof TileEntity)) {
|
||||||
if (mode == 2 && button == player.inventory.currentItem) {
|
if (mode == 2 && button == player.inventory.currentItem) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -66,7 +63,7 @@ public class ContainerCrateBase extends ContainerBase {
|
|||||||
public boolean canTakeStack(EntityPlayer player) {
|
public boolean canTakeStack(EntityPlayer player) {
|
||||||
if(player.inventory.currentItem == this.getSlotIndex() && // If this slot is the current held slot.
|
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.
|
this.getStack() != null && this.getStack().getItem() instanceof ItemBlockStorageCrate && // If the slot contains a storage crate.
|
||||||
player.openContainer instanceof ContainerCrateBase && !(ContainerCrateBase.this.crate instanceof TileEntity)) // If the player is currently inside a crate container.
|
player.openContainer instanceof ContainerCrateBase && !(ContainerCrateBase.this.tile instanceof TileEntity)) // If the player is currently inside a crate container.
|
||||||
return false;
|
return false;
|
||||||
return super.canTakeStack(player);
|
return super.canTakeStack(player);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,11 +39,11 @@ public class ContainerDroneRequester extends ContainerCrateBase {
|
|||||||
|
|
||||||
if(par2 < 9) return null; //ignore filters
|
if(par2 < 9) return null; //ignore filters
|
||||||
|
|
||||||
if(par2 <= crate.getSizeInventory() - 1) {
|
if(par2 <= tile.getSizeInventory() - 1) {
|
||||||
if(!this.mergeItemStack(var5, crate.getSizeInventory(), this.inventorySlots.size(), true)) {
|
if(!this.mergeItemStack(var5, tile.getSizeInventory(), this.inventorySlots.size(), true)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} else if(!this.mergeItemStack(var5, 9, crate.getSizeInventory(), false)) {
|
} else if(!this.mergeItemStack(var5, 9, tile.getSizeInventory(), false)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ public class ContainerDroneRequester extends ContainerCrateBase {
|
|||||||
|
|
||||||
ItemStack ret = null;
|
ItemStack ret = null;
|
||||||
ItemStack held = player.inventory.getItemStack();
|
ItemStack held = player.inventory.getItemStack();
|
||||||
TileEntityDroneRequester requester = (TileEntityDroneRequester) crate;
|
TileEntityDroneRequester requester = (TileEntityDroneRequester) tile;
|
||||||
|
|
||||||
if(slot.getHasStack())
|
if(slot.getHasStack())
|
||||||
ret = slot.getStack().copy();
|
ret = slot.getStack().copy();
|
||||||
|
|||||||
@ -28,6 +28,12 @@ public class ItemBlockStorageCrate extends ItemBlockBase implements IGUIProvider
|
|||||||
super(block);
|
super(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IF WE PUT ROCKS IN THE SHAPE OF A RUNWAY GOD WILL GIVE US HIGH-FRUCTOSE CORN SYRUP
|
||||||
|
@Override
|
||||||
|
public int getMaxItemUseDuration(ItemStack stack) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||||
if(!ServerConfig.CRATE_ALLOW_OPEN_HELD.get()) return stack;
|
if(!ServerConfig.CRATE_ALLOW_OPEN_HELD.get()) return stack;
|
||||||
@ -36,13 +42,13 @@ public class ItemBlockStorageCrate extends ItemBlockBase implements IGUIProvider
|
|||||||
if(block == ModBlocks.mass_storage) return stack; // Genuinely can't figure out how to make this part work, so I'm just not gonna mess with it.
|
if(block == ModBlocks.mass_storage) return stack; // Genuinely can't figure out how to make this part work, so I'm just not gonna mess with it.
|
||||||
|
|
||||||
if(!world.isRemote && stack.stackSize == 1) {
|
if(!world.isRemote && stack.stackSize == 1) {
|
||||||
if (stack.stackTagCompound != null && stack.stackTagCompound.hasKey("lock")) {
|
if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("lock")) {
|
||||||
for (ItemStack item : player.inventory.mainInventory) {
|
for(ItemStack item : player.inventory.mainInventory) {
|
||||||
|
|
||||||
if(item == null) continue; // Skip if no item.
|
if(item == null) continue; // Skip if no item.
|
||||||
if(!(item.getItem() instanceof ItemKey)) continue; // Skip if item isn't a key.
|
if(!(item.getItem() instanceof ItemKey)) continue; // Skip if item isn't a key.
|
||||||
if(item.stackTagCompound == null) continue; // Skip if there is no NBT (wouldn't open it anyway).
|
if(item.stackTagCompound == null) continue; // Skip if there is no NBT (wouldn't open it anyway).
|
||||||
if (item.stackTagCompound.getInteger("pins") == stack.stackTagCompound.getInteger("lock")) { // Check if pins are equal (if it can open it)
|
if(item.stackTagCompound.getInteger("pins") == stack.stackTagCompound.getInteger("lock")) { // Check if pins are equal (if it can open it)
|
||||||
TileEntityCrateBase.spawnSpiders(player, world, stack);
|
TileEntityCrateBase.spawnSpiders(player, world, stack);
|
||||||
player.openGui(MainRegistry.instance, 0, world, 0, 0, 0);
|
player.openGui(MainRegistry.instance, 0, world, 0, 0, 0);
|
||||||
break;
|
break;
|
||||||
@ -84,13 +90,9 @@ public class ItemBlockStorageCrate extends ItemBlockBase implements IGUIProvider
|
|||||||
|
|
||||||
public static class InventoryCrate extends ItemInventory {
|
public static class InventoryCrate extends ItemInventory {
|
||||||
|
|
||||||
public int heldIndex;
|
|
||||||
|
|
||||||
public InventoryCrate(EntityPlayer player, ItemStack crate) {
|
public InventoryCrate(EntityPlayer player, ItemStack crate) {
|
||||||
|
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.target = crate;
|
this.target = crate;
|
||||||
this.heldIndex = player.inventory.currentItem;
|
|
||||||
|
|
||||||
this.slots = new ItemStack[this.getSizeInventory()];
|
this.slots = new ItemStack[this.getSizeInventory()];
|
||||||
if(target.stackTagCompound == null) {
|
if(target.stackTagCompound == null) {
|
||||||
@ -129,42 +131,35 @@ public class ItemBlockStorageCrate extends ItemBlockBase implements IGUIProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void markDirty() { // I HATE THIS SO MUCH
|
public void markDirty() { // You have been blessed by the unfuck
|
||||||
NBTTagCompound nbt = new NBTTagCompound();
|
|
||||||
|
// Preserve existing NBT so we keep lock data and piders
|
||||||
|
NBTTagCompound nbt = target.stackTagCompound != null ? target.stackTagCompound : new NBTTagCompound();
|
||||||
int invSize = this.getSizeInventory();
|
int invSize = this.getSizeInventory();
|
||||||
|
|
||||||
for(int i = 0; i < invSize; i++) {
|
for(int i = 0; i < invSize; i++) {
|
||||||
|
|
||||||
ItemStack stack = this.getStackInSlot(i);
|
ItemStack stack = this.getStackInSlot(i);
|
||||||
if(stack == null) continue;
|
if(stack == null) {
|
||||||
|
nbt.removeTag("slot" + i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
NBTTagCompound slot = new NBTTagCompound();
|
NBTTagCompound slot = new NBTTagCompound();
|
||||||
stack.writeToNBT(slot);
|
stack.writeToNBT(slot);
|
||||||
nbt.setTag("slot" + i, slot);
|
nbt.setTag("slot" + i, slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if(target.stackTagCompound != null) { // yes it's a bit jank, but it wants to clear otherwise so...
|
target.setTagCompound(nbt);
|
||||||
if(target.stackTagCompound.hasKey("lock")) nbt.setInteger("lock", target.stackTagCompound.getInteger("lock"));
|
|
||||||
if(target.stackTagCompound.hasKey("lockMod")) nbt.setDouble("lockMod", target.stackTagCompound.getDouble("lockMod"));
|
|
||||||
if(target.stackTagCompound.hasKey("spiders")) nbt.setBoolean("spiders", target.stackTagCompound.getBoolean("spiders")); // fuck you!!
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// i have completely given up
|
|
||||||
if(player.getHeldItem() != null && player.getHeldItem().getItem() == this.target.getItem() && player.inventory.currentItem == this.heldIndex) {
|
|
||||||
player.getHeldItem().setTagCompound(nbt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void closeInventory() {
|
public void closeInventory() {
|
||||||
player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "hbm:block.crateClose", 1.0F, 0.8F);
|
super.closeInventory();
|
||||||
|
|
||||||
/*
|
// Check for 6kb item vomit
|
||||||
* realistically, we only need one NBT size check (and we only *want* one because CompressedStreamTools is expensive) so we do that part only when closing
|
target.setTagCompound(checkNBT(target.getTagCompound()));
|
||||||
*/
|
player.inventoryContainer.detectAndSendChanges();
|
||||||
if(player.getHeldItem() != null && player.getHeldItem().getItem() == this.target.getItem() && player.inventory.currentItem == this.heldIndex) {
|
|
||||||
player.getHeldItem().setTagCompound(checkNBT(player.getHeldItem().getTagCompound()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import com.hbm.tileentity.IGUIProvider;
|
|||||||
import com.hbm.util.ItemStackUtil;
|
import com.hbm.util.ItemStackUtil;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
@ -35,6 +36,11 @@ public class ItemToolBox extends Item implements IGUIProvider {
|
|||||||
this.setMaxStackSize(1);
|
this.setMaxStackSize(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxItemUseDuration(ItemStack stack) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void registerIcons(IIconRegister iconRegister) {
|
public void registerIcons(IIconRegister iconRegister) {
|
||||||
@ -285,9 +291,11 @@ public class ItemToolBox extends Item implements IGUIProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void closeInventory() {
|
public void closeInventory() {
|
||||||
this.target.getTagCompound().removeTag("isOpen");
|
|
||||||
this.player.inventory.setInventorySlotContents(this.player.inventory.currentItem, this.target);
|
|
||||||
super.closeInventory();
|
super.closeInventory();
|
||||||
|
|
||||||
|
this.target.getTagCompound().removeTag("isOpen");
|
||||||
|
this.target.getTagCompound().setInteger("rand", player.worldObj.rand.nextInt()); // a boolean changing isn't sufficient to detect the change
|
||||||
|
player.inventoryContainer.detectAndSendChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user