mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-08-10 17:55:44 +00:00
i think these are called hoovsies
This commit is contained in:
parent
a186c75111
commit
2c68d2ab9a
@ -14,6 +14,12 @@
|
||||
* The maximum character limit on RoR channels is now the same for all RoR devices, being 15
|
||||
* This does not include special RoR interactive devices that don't use GUI text fields like the RoR terminal or the AUTOCAL units
|
||||
* Pile output rods like the bred uranium and the plutonium rods can no longer be dismantled using the anvil, the PUREX is now mandatory
|
||||
* If too many conveyor item entities intersect with one another, they explode
|
||||
* The conveyor belt the items were on is broken, preventing further item buildup
|
||||
* Items that leave the covneyor belt, usually by trying to enter a full inserter, now have a shortened lifespan of 1 minute instead of 5
|
||||
* Base steam production per consumed heat has been increased by 50% on the ZIRNOX
|
||||
* Both radioisotope cell variants have been finally removed after being deprecated for a while
|
||||
* Selfchargers now have a tooltip explaining the hazards of using them in a battery socket
|
||||
|
||||
## Fixed
|
||||
* Fixed AUTOCAL's number comparison functions not working with variable substitution as advertised
|
||||
|
||||
@ -914,9 +914,7 @@ public class ModBlocks {
|
||||
public static Block teleanchor;
|
||||
public static Block field_disturber;
|
||||
|
||||
public static Block machine_rtg_grey;
|
||||
@Deprecated public static Block machine_minirtg;
|
||||
@Deprecated public static Block machine_powerrtg;
|
||||
public static Block machine_rtg;
|
||||
public static Block machine_radiolysis;
|
||||
public static Block machine_hephaestus;
|
||||
|
||||
@ -1840,9 +1838,7 @@ public class ModBlocks {
|
||||
teleanchor = new MachineTeleanchor().setBlockName("teleanchor").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
|
||||
field_disturber = new MachineFieldDisturber().setBlockName("field_disturber").setHardness(5.0F).setResistance(200.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":field_disturber");
|
||||
|
||||
machine_rtg_grey = new MachineRTG(Material.iron).setBlockName("machine_rtg_grey").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":rtg");
|
||||
machine_minirtg = new MachineMiniRTG(Material.iron).setBlockName("machine_minirtg").setHardness(5.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":rtg_cell");
|
||||
machine_powerrtg = new MachineMiniRTG(Material.iron).setBlockName("machine_powerrtg").setHardness(5.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":rtg_polonium");
|
||||
machine_rtg = new MachineRTG(Material.iron).setBlockName("machine_rtg_grey").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":rtg");
|
||||
machine_radiolysis = new MachineRadiolysis(Material.iron).setBlockName("machine_radiolysis").setHardness(10.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel_machine");
|
||||
machine_hephaestus = new MachineHephaestus(Material.iron).setBlockName("machine_hephaestus").setHardness(10.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel_machine");
|
||||
|
||||
@ -1910,11 +1906,11 @@ public class ModBlocks {
|
||||
drone_crate_provider = new DroneDock().setBlockName("drone_crate_provider").setHardness(0.1F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":drone_crate_provider");
|
||||
drone_crate_requester = new DroneDock().setBlockName("drone_crate_requester").setHardness(0.1F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":drone_crate_requester");
|
||||
|
||||
pneumatic_tube = new PneumoTube().setBlockName("pneumatic_tube").setStepSound(ModSoundTypes.pipe).setHardness(0.1F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":pneumatic_tube");
|
||||
pneumatic_tube = new PneumoTube().setBlockName("pneumatic_tube").setStepSound(ModSoundTypes.pipe).setHardness(2F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":pneumatic_tube");
|
||||
pneumatic_tube_paintable = new PneumoTubePaintableBlock().setBlockName("pneumatic_tube_paintable").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
|
||||
pneumatic_storage_access = new PneumoStorageAccess().setBlockName("pneumatic_storage_access").setStepSound(ModSoundTypes.pipe).setHardness(0.1F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":pneumatic_storage_access");
|
||||
pneumatic_storage_clutter = new PneumoStorageClutter().setBlockName("pneumatic_storage_clutter").setStepSound(ModSoundTypes.pipe).setHardness(0.1F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":pneumatic_storage_clutter");
|
||||
pneumatic_storage_mono = new PneumoStorageMono().setBlockName("pneumatic_storage_mono").setStepSound(ModSoundTypes.pipe).setHardness(0.1F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":pneumatic_storage_mono");
|
||||
pneumatic_storage_access = new PneumoStorageAccess().setBlockName("pneumatic_storage_access").setStepSound(ModSoundTypes.pipe).setHardness(5.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":pneumatic_storage_access");
|
||||
pneumatic_storage_clutter = new PneumoStorageClutter().setBlockName("pneumatic_storage_clutter").setStepSound(ModSoundTypes.pipe).setHardness(5.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":pneumatic_storage_clutter");
|
||||
pneumatic_storage_mono = new PneumoStorageMono().setBlockName("pneumatic_storage_mono").setStepSound(ModSoundTypes.pipe).setHardness(5.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":pneumatic_storage_mono");
|
||||
|
||||
chain = new BlockChain(Material.iron).setBlockName("dungeon_chain").setHardness(0.25F).setResistance(2.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":chain");
|
||||
|
||||
@ -2348,7 +2344,6 @@ public class ModBlocks {
|
||||
|
||||
logic_block = new LogicBlock().setBlockName("logic_block").setBlockTextureName(RefStrings.MODID + ":logic_block");
|
||||
logic_block_invis = new LogicBlockInvis().setBlockName("logic_block_invis").setBlockTextureName(RefStrings.MODID + ":logic_block");
|
||||
|
||||
}
|
||||
|
||||
private static void registerBlock() {
|
||||
@ -3056,9 +3051,7 @@ public class ModBlocks {
|
||||
GameRegistry.registerBlock(machine_radgen, machine_radgen.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(machine_cyclotron, machine_cyclotron.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(machine_exposure_chamber, machine_exposure_chamber.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(machine_rtg_grey, machine_rtg_grey.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(machine_minirtg, machine_minirtg.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(machine_powerrtg, machine_powerrtg.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(machine_rtg, machine_rtg.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(machine_radiolysis, machine_radiolysis.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(machine_hephaestus, machine_hephaestus.getUnlocalizedName());
|
||||
|
||||
|
||||
@ -104,7 +104,7 @@ public class BlockCrate extends BlockFalling {
|
||||
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_reactor_breeding), 6);
|
||||
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_wood_burner), 10);
|
||||
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_diesel), 8);
|
||||
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_rtg_grey), 4);
|
||||
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_rtg), 4);
|
||||
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.red_pylon), 9);
|
||||
BlockCrate.addToListWithWeight(metalList, new ItemStack(ModItems.battery_pack, 1, EnumBatteryPack.BATTERY_LEAD.ordinal()), 10);
|
||||
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_electric_furnace_off), 8);
|
||||
|
||||
@ -1,36 +0,0 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import com.hbm.tileentity.machine.TileEntityMachineMiniRTG;
|
||||
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class MachineMiniRTG extends BlockContainer {
|
||||
|
||||
public MachineMiniRTG(Material mat) {
|
||||
super(mat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
|
||||
return new TileEntityMachineMiniRTG();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return MachineRTG.renderID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@ -47,7 +47,7 @@ public class MachineRTG extends BlockContainer {
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
|
||||
|
||||
if(this == ModBlocks.machine_rtg_grey)
|
||||
if(this == ModBlocks.machine_rtg)
|
||||
return new TileEntityMachineRTG();
|
||||
|
||||
return null;
|
||||
@ -60,7 +60,7 @@ public class MachineRTG extends BlockContainer {
|
||||
return true;
|
||||
} else if(!player.isSneaking())
|
||||
{
|
||||
if(this == ModBlocks.machine_rtg_grey) {
|
||||
if(this == ModBlocks.machine_rtg) {
|
||||
TileEntityMachineRTG entity = (TileEntityMachineRTG) world.getTileEntity(x, y, z);
|
||||
if(entity != null)
|
||||
{
|
||||
@ -78,7 +78,7 @@ public class MachineRTG extends BlockContainer {
|
||||
{
|
||||
if (!keepInventory)
|
||||
{
|
||||
if (this == ModBlocks.machine_rtg_grey) {
|
||||
if (this == ModBlocks.machine_rtg) {
|
||||
TileEntityMachineRTG tileentityfurnace = (TileEntityMachineRTG) p_149749_1_.getTileEntity(p_149749_2_,
|
||||
p_149749_3_, p_149749_4_);
|
||||
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
package com.hbm.blocks.network.pneumatic;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.config.ServerConfig;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.network.pneumatic.TileEntityPneumoStorageClutter;
|
||||
|
||||
@ -7,12 +11,16 @@ import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class PneumoStorageClutter extends BlockContainer {
|
||||
@ -39,32 +47,120 @@ public class PneumoStorageClutter extends BlockContainer {
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(!(te instanceof ISidedInventory)) return;
|
||||
ISidedInventory tileentityfurnace = (ISidedInventory) te;
|
||||
if(tileentityfurnace != null) {
|
||||
for(int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1) {
|
||||
ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);
|
||||
if(itemstack != null) {
|
||||
float f = world.rand.nextFloat() * 0.8F + 0.1F;
|
||||
float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
|
||||
float f2 = world.rand.nextFloat() * 0.8F + 0.1F;
|
||||
while(itemstack.stackSize > 0) {
|
||||
int j1 = world.rand.nextInt(21) + 10;
|
||||
if(j1 > itemstack.stackSize) j1 = itemstack.stackSize;
|
||||
itemstack.stackSize -= j1;
|
||||
EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
|
||||
if(itemstack.hasTagCompound()) entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
|
||||
float f3 = 0.05F;
|
||||
entityitem.motionX = world.rand.nextGaussian() * f3;
|
||||
entityitem.motionY = world.rand.nextGaussian() * f3 + 0.2F;
|
||||
entityitem.motionZ = world.rand.nextGaussian() * f3;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
if(dropInv) {
|
||||
TileEntityPneumoStorageClutter storage = (TileEntityPneumoStorageClutter) world.getTileEntity(x, y, z);
|
||||
Random rand = world.rand;
|
||||
if(storage != null) {
|
||||
for(int i = 0; i < storage.getSizeInventory(); ++i) {
|
||||
ItemStack itemstack = storage.getStackInSlot(i);
|
||||
if(itemstack != null) {
|
||||
float offsetX = rand.nextFloat() * 0.8F + 0.1F;
|
||||
float offsetY = rand.nextFloat() * 0.8F + 0.1F;
|
||||
float offsetZ = rand.nextFloat() * 0.8F + 0.1F;
|
||||
|
||||
while(itemstack.stackSize > 0) {
|
||||
int split = rand.nextInt(21) + 10;
|
||||
if(split > itemstack.stackSize) split = itemstack.stackSize;
|
||||
itemstack.stackSize -= split;
|
||||
EntityItem entityitem = new EntityItem(world, x + offsetX, y + offsetY, z + offsetZ, new ItemStack(itemstack.getItem(), split, itemstack.getItemDamage()));
|
||||
|
||||
if(itemstack.hasTagCompound()) {
|
||||
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
|
||||
}
|
||||
float intensity = 0.05F;
|
||||
entityitem.motionX = rand.nextGaussian() * intensity;
|
||||
entityitem.motionY = rand.nextGaussian() * intensity + 0.2F;
|
||||
entityitem.motionZ = rand.nextGaussian() * intensity;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
world.func_147453_f(x, y, z, block);
|
||||
}
|
||||
world.func_147453_f(x, y, z, block);
|
||||
}
|
||||
|
||||
super.breakBlock(world, x, y, z, block, meta);
|
||||
}
|
||||
|
||||
private static boolean dropInv = true;
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
|
||||
|
||||
if(!world.isRemote && !ServerConfig.CRATE_KEEP_CONTENTS.get()) {
|
||||
if(!player.capabilities.isCreativeMode) {
|
||||
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(this)));
|
||||
}
|
||||
dropInv = true;
|
||||
boolean flag = world.setBlockToAir(x, y, z);
|
||||
return flag;
|
||||
}
|
||||
|
||||
if(!player.capabilities.isCreativeMode && !world.isRemote && willHarvest) {
|
||||
|
||||
ItemStack drop = new ItemStack(this);
|
||||
ISidedInventory inv = (ISidedInventory)world.getTileEntity(x, y, z);
|
||||
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
|
||||
if(inv != null) {
|
||||
|
||||
for(int i = 0; i < inv.getSizeInventory(); i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
if(stack == null) continue;
|
||||
NBTTagCompound slot = new NBTTagCompound();
|
||||
stack.writeToNBT(slot);
|
||||
nbt.setTag("slot" + i, slot);
|
||||
}
|
||||
}
|
||||
|
||||
if(!nbt.hasNoTags()) {
|
||||
drop.stackTagCompound = nbt;
|
||||
}
|
||||
|
||||
if(inv instanceof TileEntityPneumoStorageClutter) {
|
||||
TileEntityPneumoStorageClutter crate = (TileEntityPneumoStorageClutter) inv;
|
||||
if (crate.hasCustomInventoryName()) {
|
||||
drop.setStackDisplayName(crate.getInventoryName());
|
||||
}
|
||||
}
|
||||
|
||||
if(drop.hasTagCompound()) {
|
||||
try {
|
||||
byte[] abyte = CompressedStreamTools.compress(drop.stackTagCompound);
|
||||
|
||||
if(abyte.length > 6000) {
|
||||
player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + "Warning: Container NBT exceeds 6kB, contents will be ejected!"));
|
||||
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(this)));
|
||||
return world.setBlockToAir(x, y, z);
|
||||
}
|
||||
|
||||
} catch(IOException e) { }
|
||||
}
|
||||
|
||||
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, drop));
|
||||
}
|
||||
|
||||
dropInv = false;
|
||||
boolean flag = world.setBlockToAir(x, y, z);
|
||||
dropInv = true;
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
|
||||
|
||||
TileEntityPneumoStorageClutter inv = (TileEntityPneumoStorageClutter) world.getTileEntity(x, y, z);
|
||||
|
||||
if(inv != null && stack.hasTagCompound()) {
|
||||
for(int i = 0; i < inv.getSizeInventory(); i++) {
|
||||
inv.setInventorySlotContents(i, ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("slot" + i)));
|
||||
}
|
||||
if(stack.hasDisplayName()) inv.setCustomName(stack.getDisplayName());
|
||||
}
|
||||
|
||||
super.onBlockPlacedBy(world, x, y, z, player, stack);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ public class VersatileConfig {
|
||||
|
||||
public static int getSchrabOreChance() {
|
||||
if(GeneralConfig.enableLBSM) return GeneralConfig.schrabRate;
|
||||
return 100;
|
||||
return 250;
|
||||
}
|
||||
|
||||
public static void applyPotionSickness(EntityLivingBase entity, int duration) {
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
package com.hbm.entity.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.explosion.vanillant.ExplosionVNT;
|
||||
import com.hbm.explosion.vanillant.standard.ExplosionEffectTiny;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
|
||||
@ -77,6 +81,21 @@ public abstract class EntityMovingConveyorObject extends Entity {
|
||||
return;
|
||||
}
|
||||
|
||||
// cram check every 20s
|
||||
if((ticksExisted + this.getEntityId()) % 400 == 0) {
|
||||
List<EntityMovingConveyorObject> objs = worldObj.getEntitiesWithinAABB(EntityMovingConveyorObject.class, this.boundingBox.expand(0.125, 0.125, 0.125));
|
||||
if(objs.size() >= 25) {
|
||||
for(EntityMovingConveyorObject obj : objs) obj.setDead();
|
||||
ExplosionVNT vnt = new ExplosionVNT(worldObj, posX, posY + 0.125, posZ, 1, this);
|
||||
vnt.setSFX(new ExplosionEffectTiny());
|
||||
vnt.explode();
|
||||
int x = (int) Math.floor(posX);
|
||||
int y = (int) Math.floor(posY);
|
||||
int z = (int) Math.floor(posZ);
|
||||
if(worldObj.getBlock(x, y, z) instanceof IConveyorBelt) worldObj.func_147480_a(x, y, z, false);
|
||||
}
|
||||
}
|
||||
|
||||
int blockX = (int) Math.floor(posX);
|
||||
int blockY = (int) Math.floor(posY);
|
||||
int blockZ = (int) Math.floor(posZ);
|
||||
|
||||
@ -122,6 +122,7 @@ public class EntityMovingItem extends EntityMovingConveyorObject implements ICon
|
||||
|
||||
this.setDead();
|
||||
EntityItem item = new EntityItem(worldObj, posX + motionX * 2, posY + motionY * 2, posZ + motionZ * 2, this.getItemStack());
|
||||
item.lifespan = 60 * 20;
|
||||
item.motionX = this.motionX * 2;
|
||||
item.motionY = 0.1;
|
||||
item.motionZ = this.motionZ * 2;
|
||||
|
||||
@ -160,9 +160,7 @@ public class EntityFBI extends EntityMob implements IRangedAttackMob {
|
||||
canDestroy.add(ModBlocks.crate_iron);
|
||||
canDestroy.add(ModBlocks.crate_steel);
|
||||
canDestroy.add(ModBlocks.machine_diesel);
|
||||
canDestroy.add(ModBlocks.machine_rtg_grey);
|
||||
canDestroy.add(ModBlocks.machine_minirtg);
|
||||
canDestroy.add(ModBlocks.machine_powerrtg);
|
||||
canDestroy.add(ModBlocks.machine_rtg);
|
||||
canDestroy.add(ModBlocks.machine_cyclotron);
|
||||
canDestroy.add(Blocks.chest);
|
||||
canDestroy.add(Blocks.trapped_chest);
|
||||
|
||||
@ -9,7 +9,7 @@ public class RTGRecipeHandler extends NEIUniversalHandler {
|
||||
|
||||
public RTGRecipeHandler() {
|
||||
super("RTG", new ItemStack[] {
|
||||
new ItemStack(ModBlocks.machine_rtg_grey),
|
||||
new ItemStack(ModBlocks.machine_rtg),
|
||||
new ItemStack(ModBlocks.machine_difurnace_rtg_off)
|
||||
}, ItemRTGPellet.getRecipeMap());
|
||||
}
|
||||
|
||||
@ -3,10 +3,14 @@ package com.hbm.inventory.container;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.hbm.interfaces.NotableComments;
|
||||
import com.hbm.inventory.SlotNonRetarded;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.packet.toclient.ContainerNBTCommsPacket;
|
||||
import com.hbm.tileentity.network.pneumatic.TileEntityPneumoStorageAccess;
|
||||
@ -23,104 +27,159 @@ import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
@NotableComments // i long for the day when i never have to look at this fucking horseshit ever again
|
||||
public class ContainerPneumoStorageAccess extends Container implements ICustomPayloadReceiver {
|
||||
|
||||
/*
|
||||
* time wasted on this fucking class: a lot
|
||||
*
|
||||
* this approach was great right until it just stopped working.
|
||||
* a proper search requires the client to decide if the item matches
|
||||
* the criteria, and we have to process all items in the network, so
|
||||
* this entire approach of only sending 48 items at once to the client
|
||||
* just absolutely will not work.
|
||||
*
|
||||
* i may have to rewrite absolutely everything here now, but at least i
|
||||
* finally know what i am up against. didn't hear no bell.
|
||||
*/
|
||||
|
||||
protected TileEntityPneumoStorageAccess access;
|
||||
protected InventoryPneumoStorageAccess inventory;
|
||||
protected EntityPlayer player;
|
||||
protected String searchString = "";
|
||||
|
||||
public static boolean detailedSearch = false;
|
||||
|
||||
/** On the server, this is used to find changes in the system and then send them to the client. On the client, this is just to keep track of all items. */
|
||||
protected LinkedHashMap<Long, CacheSlotDummy> cachedEntries = new LinkedHashMap();
|
||||
/** Server to client queue, contains NBT tags that represents deltas yet to be sent to the client */
|
||||
public LinkedList<NBTTagCompound> s2cQueue = new LinkedList();
|
||||
|
||||
public void setSorter(Comparator<CacheSlotDummy> sorter) {
|
||||
this.listingStart = 0;
|
||||
this.sorter = sorter;
|
||||
this.rebuildClientIndex();
|
||||
}
|
||||
|
||||
public void setSearchString(String search) {
|
||||
this.listingStart = 0;
|
||||
this.searchString = search.toLowerCase(Locale.US);
|
||||
this.rebuildClientIndex();
|
||||
}
|
||||
|
||||
/** Used to temporarily store the previous CacheSlot contents to calculate deltas with (i.e. detect changes) */
|
||||
public static class CacheSlotDummy {
|
||||
|
||||
public final ItemStack displayStack;
|
||||
public long stacksize;
|
||||
public final int itemId;
|
||||
public final int meta;
|
||||
public final NBTTagCompound nbt;
|
||||
|
||||
public CacheSlotDummy(ItemStack displayStack, long stacksize) {
|
||||
this.displayStack = displayStack;
|
||||
this.stacksize = stacksize;
|
||||
this.itemId = Item.getIdFromItem(displayStack.getItem());
|
||||
this.meta = displayStack.getItemDamage();
|
||||
if(displayStack.hasTagCompound()) this.nbt = (NBTTagCompound) displayStack.stackTagCompound.copy();
|
||||
else this.nbt = null;
|
||||
}
|
||||
|
||||
public CacheSlotDummy(CacheSlot original) {
|
||||
this(original.displayStack.copy(), original.stacksize);
|
||||
}
|
||||
}
|
||||
|
||||
public static final int SLOT_CLICK_ID_REFRESH = -666;
|
||||
public static final int GRID_SIZE = 6 * 8;
|
||||
public static final String STACK_SIZE_KEY = "PNEUMO_STACK_SIZE";
|
||||
public static final int DELTAS_PER_MSG = 6 * 8;
|
||||
public static final int SLOT_CLICK_ID_REFRESH = -666;
|
||||
|
||||
public int itemCountForClient = 0;
|
||||
public int listingStart = 0;
|
||||
public int listingSize = 0;
|
||||
|
||||
public int getStackCount() {
|
||||
return listingSize;
|
||||
}
|
||||
|
||||
/** Serverside, creates a new delta for a new item stack */
|
||||
public void pushNewItem(ItemStack zeroStack, long amount) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setByte("type", (byte) DeltaType.NEW_TYPE.ordinal());
|
||||
zeroStack.writeToNBT(data);
|
||||
data.setLong("amount", amount);
|
||||
s2cQueue.add(data);
|
||||
}
|
||||
|
||||
/** Serverside, creates a new delta for an amount update */
|
||||
public void updateCount(long hash, long amount) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setByte("type", (byte) DeltaType.COUNT_CHANGE.ordinal());
|
||||
data.setLong("hash", hash);
|
||||
data.setLong("amount", amount);
|
||||
s2cQueue.add(data);
|
||||
}
|
||||
|
||||
/** Serverside, bunches up deltas into NBTTagLists and sends them, 48 (DELTAS_PER_MSG) at a time */
|
||||
public void processDeltasAndSync(EntityPlayerMP playerMP) {
|
||||
if(s2cQueue.isEmpty()) return;
|
||||
|
||||
NBTTagList list = null;
|
||||
|
||||
while(!s2cQueue.isEmpty()) {
|
||||
if(list == null) list = new NBTTagList();
|
||||
list.appendTag(s2cQueue.removeFirst());
|
||||
if(list.tagCount() >= DELTAS_PER_MSG) { bonVoyage(list, playerMP); list = null; }
|
||||
}
|
||||
|
||||
if(list != null) bonVoyage(list, playerMP);
|
||||
}
|
||||
|
||||
/** Wraps the NBTTagList into a master compound tag and sends it to the client */
|
||||
public void bonVoyage(NBTTagList list, EntityPlayerMP playerMP) {
|
||||
NBTTagCompound masterTag = new NBTTagCompound();
|
||||
masterTag.setTag("list", list);
|
||||
PacketDispatcher.wrapper.sendTo(new ContainerNBTCommsPacket(playerMP.currentWindowId, masterTag), playerMP);
|
||||
}
|
||||
|
||||
/** Compares the original access stack cache with the one we have buffered to detect changes and pushes them to the s2c sending queue */
|
||||
public void checkAndSyncCache() {
|
||||
if(this.access.cache == null || this.access.cache.hasExpired) return;
|
||||
|
||||
for(Entry<Long, CacheSlot> entry : this.access.cache.cacheSlots.entrySet()) {
|
||||
|
||||
Long hash = entry.getKey();
|
||||
if(hash == StackCache.getNullIdentity()) continue;
|
||||
|
||||
CacheSlotDummy existingCache = this.cachedEntries.get(hash);
|
||||
CacheSlot properCache = entry.getValue();
|
||||
|
||||
// if the previous entries already contain this type, check for amount change
|
||||
if(existingCache != null) {
|
||||
if(existingCache.stacksize != properCache.stacksize) {
|
||||
this.updateCount(hash, properCache.stacksize);
|
||||
existingCache.stacksize = properCache.stacksize;
|
||||
}
|
||||
// if not, add that type to our index
|
||||
} else {
|
||||
existingCache = new CacheSlotDummy(properCache);
|
||||
existingCache.stacksize = properCache.stacksize;
|
||||
this.cachedEntries.put(hash, existingCache);
|
||||
this.pushNewItem(existingCache.displayStack, existingCache.stacksize);
|
||||
}
|
||||
}
|
||||
|
||||
if(player instanceof EntityPlayerMP) processDeltasAndSync((EntityPlayerMP) this.player);
|
||||
}
|
||||
|
||||
public ContainerPneumoStorageAccess(InventoryPlayer invPlayer, TileEntityPneumoStorageAccess access) {
|
||||
this.access = access;
|
||||
this.inventory = new InventoryPneumoStorageAccess(access);
|
||||
this.player = invPlayer.player;
|
||||
|
||||
for(int i = 0; i < 6; i++) {
|
||||
for(int j = 0; j < 8; j++) {
|
||||
this.addSlotToContainer(new SlotPneumo(inventory, j + i * 8, 8 + j * 18, 17 + i * 18));
|
||||
}
|
||||
int hOffset = 34;
|
||||
|
||||
for(int i = 0; i < 6; i++) for(int j = 0; j < 8; j++) {
|
||||
this.addSlotToContainer(new SlotPneumo(inventory, j + i * 8, 8 + j * 18 + hOffset, 17 + i * 18));
|
||||
}
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
for(int j = 0; j < 9; j++) {
|
||||
this.addSlotToContainer(new SlotNonRetarded(invPlayer, j + i * 9 + 9, 8 + j * 18, 169 + i * 18));
|
||||
}
|
||||
for(int i = 0; i < 3; i++) for(int j = 0; j < 9; j++) {
|
||||
this.addSlotToContainer(new SlotNonRetarded(invPlayer, j + i * 9 + 9, 8 + j * 18 + hOffset, 169 + i * 18));
|
||||
}
|
||||
|
||||
for(int i = 0; i < 9; i++) {
|
||||
this.addSlotToContainer(new SlotNonRetarded(invPlayer, i, 8 + i * 18, 227));
|
||||
this.addSlotToContainer(new SlotNonRetarded(invPlayer, i, 8 + i * 18 + hOffset, 227));
|
||||
}
|
||||
|
||||
updateListing(0);
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
public int getStackCount() {
|
||||
return itemCountForClient;
|
||||
}
|
||||
|
||||
public void updateListing(int startingIndex) { // DEMO
|
||||
if(this.access.cache == null || this.access.cache.hasExpired) return;
|
||||
StackCache cache = this.access.cache;
|
||||
List<CacheSlot> cacheSlots = new ArrayList(cache.cacheSlots.size());
|
||||
cacheSlots.addAll(cache.cacheSlots.values());
|
||||
cacheSlots.removeIf(x -> { return x.stacksize <= 0; });
|
||||
Collections.sort(cacheSlots, SORT_BY_STACK_SIZE);
|
||||
int size = cacheSlots.size();
|
||||
|
||||
int offset = startingIndex * 8;
|
||||
|
||||
for(int i = 0; i < inventory.slots.length; i++) {
|
||||
int grabIndex = offset + i;
|
||||
if(grabIndex < size) {
|
||||
CacheSlot cacheSlot = cacheSlots.get(grabIndex);
|
||||
if(cacheSlot.displayStack != null) {
|
||||
inventory.slots[i] = cacheSlot.displayStack.copy();
|
||||
} else {
|
||||
inventory.slots[i] = null;
|
||||
}
|
||||
} else {
|
||||
inventory.slots[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final Comparator<CacheSlot> SORT_BY_STACK_SIZE = new Comparator<CacheSlot>() {
|
||||
@Override
|
||||
public int compare(CacheSlot o1, CacheSlot o2) {
|
||||
if(o1.stacksize > o2.stacksize) return -1; if(o1.stacksize < o2.stacksize) return 1;
|
||||
if(o1.itemId < o2.itemId) return -1; if(o1.itemId > o2.itemId) return 1;
|
||||
if(o1.meta < o2.meta) return -1; if(o1.meta > o2.meta) return 1;
|
||||
if(o1.nbt == null && o2.nbt != null) return -1; if(o1.nbt != null && o2.nbt == null) return 1;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return access.getDistanceFrom(player.posX, player.posY, player.posZ) <= 15 * 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -128,77 +187,50 @@ public class ContainerPneumoStorageAccess extends Container implements ICustomPa
|
||||
if(mode == 6) return null;
|
||||
|
||||
if(index == SLOT_CLICK_ID_REFRESH) {
|
||||
if(player.worldObj.isRemote) return null;
|
||||
this.listingStart = mode;
|
||||
this.detectAndSendChanges();
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean client = player.worldObj.isRemote;
|
||||
boolean leftClick = button == 0 && mode == 0;
|
||||
boolean rightClick = button == 1 && mode == 0;
|
||||
boolean shiftClick = button == 0 && mode == 1;
|
||||
|
||||
if(index >= 0 && index < GRID_SIZE) {
|
||||
boolean client = player.worldObj.isRemote;
|
||||
if(!client) return null;
|
||||
SlotPneumo slot = (SlotPneumo) this.getSlot(index);
|
||||
long hash = StackCache.getStackIdentity(slot.getStack());
|
||||
ItemStack held = player.inventory.getItemStack();
|
||||
|
||||
if(slot.getHasStack()) {
|
||||
|
||||
// left click, can't hold an item and provides a full stack to the held item
|
||||
if(leftClick || rightClick) {
|
||||
ItemStack stack = slot.getStack().copy();
|
||||
|
||||
int alreadyHeld = held == null ? 0 : held.stackSize;
|
||||
int capacity = stack.getMaxStackSize() - alreadyHeld;
|
||||
if(rightClick && capacity > 1) capacity = 1;
|
||||
int toGrab = (int) Math.min(capacity, slot.amount);
|
||||
|
||||
if(capacity > 0 && (held == null || StackCache.getStackIdentity(held) == StackCache.getStackIdentity(stack))) {
|
||||
if(client) {
|
||||
stack.stackSize = toGrab + alreadyHeld;
|
||||
player.inventory.setItemStack(stack);
|
||||
} else {
|
||||
if(this.access.cache == null || this.access.cache.hasExpired) return null;
|
||||
StackCache cache = this.access.cache;
|
||||
stack.stackSize = (int) cache.consumeItemsAndReturnQuantity(stack, toGrab) + alreadyHeld;
|
||||
player.inventory.setItemStack(stack);
|
||||
}
|
||||
|
||||
return null; // for some reason we gotta terminate here and not below
|
||||
}
|
||||
|
||||
// shift click, works even if there's a held stack, serverside only and the nwe just sync
|
||||
} else if(shiftClick && !client) {
|
||||
ItemStack stack = slot.getStack().copy();
|
||||
if(this.access.cache == null || this.access.cache.hasExpired) return null;
|
||||
StackCache cache = this.access.cache;
|
||||
int originalStacksize = (int) Math.min(stack.getMaxStackSize(), slot.amount);
|
||||
stack.stackSize = originalStacksize;
|
||||
ItemStack ret = InventoryUtil.tryAddItemToInventory(player.inventory.mainInventory, stack);
|
||||
int remainder = ret == null ? 0 : ret.stackSize;
|
||||
int itemsUsed = originalStacksize - remainder;
|
||||
cache.consumeItemsAndReturnQuantity(stack, itemsUsed);
|
||||
detectAndSendChanges();
|
||||
long heldHash = StackCache.getStackIdentity(held);
|
||||
if(leftClick) {
|
||||
if(held != null && hash != heldHash) held = null;
|
||||
else if(held != null && hash == heldHash) {
|
||||
held.stackSize += slot.amount;
|
||||
held.stackSize = Math.min(held.stackSize, held.getMaxStackSize());
|
||||
} else if(held == null && slot.getHasStack()) {
|
||||
held = slot.getStack().copy();
|
||||
held.stackSize = (int) Math.min(slot.amount, held.getMaxStackSize());
|
||||
}
|
||||
this.player.inventory.setItemStack(held);
|
||||
sendClickToServer(ClickType.LEFT_CLICK, hash);
|
||||
return null;
|
||||
}
|
||||
|
||||
if(held != null) {
|
||||
int toDeposit = rightClick ? 1 : held.stackSize;
|
||||
player.inventory.getItemStack().stackSize -= toDeposit;
|
||||
if(player.inventory.getItemStack().stackSize <= 0) player.inventory.setItemStack(null);
|
||||
if(this.access.cache == null || this.access.cache.hasExpired) return null;
|
||||
StackCache cache = this.access.cache;
|
||||
int remainder = (int) cache.addItemsAndReturnQuantity(held, toDeposit);
|
||||
if(remainder > 0) {
|
||||
ItemStack copy = held.copy();
|
||||
copy.stackSize = remainder;
|
||||
InventoryUtil.tryAddItemToInventory(player.inventory.mainInventory, copy);
|
||||
detectAndSendChanges();
|
||||
if(rightClick) {
|
||||
if(held != null && hash != heldHash) held.stackSize--;
|
||||
else if(held != null && hash == heldHash) {
|
||||
held.stackSize += 1;
|
||||
held.stackSize = Math.min(held.stackSize, held.getMaxStackSize());
|
||||
} else if(held == null && slot.getHasStack()) {
|
||||
held = slot.getStack().copy();
|
||||
held.stackSize = 1;
|
||||
}
|
||||
if(held.stackSize <= 0) held = null;
|
||||
this.player.inventory.setItemStack(held);
|
||||
sendClickToServer(ClickType.RIGHT_CLICK, hash);
|
||||
return null;
|
||||
}
|
||||
|
||||
return slot.getHasStack() ? slot.getStack().copy() : null;
|
||||
if(shiftClick) { sendClickToServer(ClickType.SHIFT_CLICK, hash); return null; }
|
||||
|
||||
// shift clicking an item from the player inv to the storage
|
||||
} else if(index >= GRID_SIZE && index < this.inventorySlots.size()) {
|
||||
@ -214,36 +246,25 @@ public class ContainerPneumoStorageAccess extends Container implements ICustomPa
|
||||
if(remainder <= 0) slot.putStack(null);
|
||||
slot.onSlotChanged();
|
||||
detectAndSendChanges();
|
||||
return null; // technically not needed but we don't have to run 500,000 lines of code that ends up doing nothing
|
||||
}
|
||||
}
|
||||
|
||||
return super.slotClick(index, button, mode, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters(ICrafting crafting) {
|
||||
super.addCraftingToCrafters(crafting);
|
||||
}
|
||||
public void sendClickToServer(ClickType type, long hash) {
|
||||
|
||||
/** Used only on the client side to set the contents of a slot after a sync */
|
||||
@Override
|
||||
public void putStackInSlot(int index, ItemStack slot) {
|
||||
this.getSlot(index).putStack(slot);
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setByte("type", (byte) type.ordinal());
|
||||
data.setLong("hash", hash);
|
||||
PacketDispatcher.wrapper.sendToServer(new ContainerNBTCommsPacket(this.windowId, data));
|
||||
}
|
||||
|
||||
public long[] previousStackSizes = new long[GRID_SIZE];
|
||||
|
||||
/**
|
||||
* All syncing is done using the ICrafting interface (which only EntityPlayerMP implements), each single slot change is one entire fucking
|
||||
* packet that is sent like a massive pile of pricks to each client. Who cares, right. Issue is, this interface only supports sending of
|
||||
* ItemStacks and integer values with integer keys for the progress bars. We need longs which are indexed, so at least an extra byte along
|
||||
* with that. After some fucking about I decided, well vanilla container code is complete fucking shit anyway, why bother with any of that?
|
||||
* Instead, we just skip all the syncing for that and use our custom crap packet. Depending on whether the stack, the count, or both has changed,
|
||||
* we send the requested data in a single packet.
|
||||
*/
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
this.updateListing(listingStart);
|
||||
|
||||
// skip the first 6*8 slots, i.e. all the ones visible in the access grid
|
||||
for(int i = GRID_SIZE; i < this.inventorySlots.size(); i++) {
|
||||
@ -260,92 +281,210 @@ public class ContainerPneumoStorageAccess extends Container implements ICustomPa
|
||||
}
|
||||
}
|
||||
|
||||
// custom horseshit scum fuck
|
||||
boolean isServer = !this.access.getWorldObj().isRemote;
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
if(this.access.cache != null && !this.access.cache.hasExpired) for(int i = 0; i < GRID_SIZE; i++) {
|
||||
PneumoMesageType msg = null;
|
||||
SlotPneumo slot = (SlotPneumo) this.inventorySlots.get(i);
|
||||
ItemStack actualStack = slot.getStack();
|
||||
long cachedSize = slot.amount;
|
||||
CacheSlot cacheSlot = actualStack != null ? this.access.cache.getSlotFromStack(actualStack) : null;
|
||||
long actualSize = cacheSlot != null ? cacheSlot.stacksize : 0;
|
||||
if(actualSize <= 0) actualStack = null;
|
||||
ItemStack cachedStack = (ItemStack) this.inventoryItemStacks.get(i);
|
||||
|
||||
if(!ItemStack.areItemStacksEqual(cachedStack, actualStack)) msg = PneumoMesageType.UPDATE_TYPE;
|
||||
|
||||
if(cachedSize != actualSize || actualSize > 0 /* HACK: solve this by moving the listing change to the container class and writing the correct amounts on init */) {
|
||||
if(msg == PneumoMesageType.UPDATE_TYPE) msg = PneumoMesageType.UPDATE_ALL;
|
||||
if(msg == null) msg = PneumoMesageType.UPDATE_COUNT;
|
||||
}
|
||||
|
||||
if(msg != null) {
|
||||
cachedStack = actualStack == null ? null : actualStack.copy();
|
||||
this.inventoryItemStacks.set(i, cachedStack);
|
||||
slot.amount = actualSize;
|
||||
|
||||
NBTTagCompound listEntry = new NBTTagCompound();
|
||||
listEntry.setByte(KEY_TYPE, (byte) msg.ordinal());
|
||||
listEntry.setByte(KEY_SLOT_INDEX, (byte) i);
|
||||
if(msg == PneumoMesageType.UPDATE_ALL || msg == PneumoMesageType.UPDATE_COUNT) {
|
||||
listEntry.setLong(KEY_LONG_COUNT, actualSize);
|
||||
}
|
||||
if(msg == PneumoMesageType.UPDATE_ALL || msg == PneumoMesageType.UPDATE_TYPE) if(actualStack != null) actualStack.writeToNBT(listEntry);
|
||||
|
||||
list.appendTag(listEntry);
|
||||
}
|
||||
}
|
||||
|
||||
if(list.tagCount() > 0) {
|
||||
NBTTagCompound masterTag = new NBTTagCompound();
|
||||
// if a null stack is indiced, skip
|
||||
boolean hasNullStack = this.access.cache.cacheSlots.containsKey(this.access.cache.getNullIdentity());
|
||||
masterTag.setInteger("itemCount", this.access.cache.cacheSlots.size() - (hasNullStack ? 1 : 0));
|
||||
masterTag.setInteger("listingStart", this.listingStart);
|
||||
masterTag.setTag("list", list);
|
||||
for(Object o : this.crafters) {
|
||||
if(o instanceof EntityPlayerMP) {
|
||||
EntityPlayerMP playerMP = (EntityPlayerMP) o;
|
||||
PacketDispatcher.wrapper.sendTo(new ContainerNBTCommsPacket(playerMP.currentWindowId, masterTag), playerMP);
|
||||
}
|
||||
}
|
||||
if(isServer) {
|
||||
checkAndSyncCache();
|
||||
} else {
|
||||
rebuildClientIndex();
|
||||
}
|
||||
}
|
||||
|
||||
public static final String KEY_TYPE = "t";
|
||||
public static final String KEY_SLOT_INDEX = "s";
|
||||
public static final String KEY_LONG_COUNT = "lc";
|
||||
public static enum PneumoMesageType {
|
||||
UPDATE_COUNT,
|
||||
UPDATE_TYPE,
|
||||
UPDATE_ALL;
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return access.getDistanceFrom(player.posX, player.posY, player.posZ) <= 15 * 15;
|
||||
}
|
||||
|
||||
/** For S2C to send deltas updating the available items */
|
||||
public static enum DeltaType {
|
||||
NEW_TYPE,
|
||||
COUNT_CHANGE;
|
||||
}
|
||||
|
||||
public static enum ClickType {
|
||||
LEFT_CLICK,
|
||||
RIGHT_CLICK,
|
||||
SHIFT_CLICK
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptData(Side side, int windowId, NBTTagCompound data) {
|
||||
if(windowId != this.windowId) return;
|
||||
|
||||
if(side.isClient()) {
|
||||
this.itemCountForClient = data.getInteger("itemCount");
|
||||
this.listingStart = data.getInteger("listingStart");
|
||||
|
||||
if(side == Side.CLIENT) {
|
||||
NBTTagList list = data.getTagList("list", 10);
|
||||
|
||||
for(int i = 0; i < list.tagCount(); i++) {
|
||||
NBTTagCompound listEntry = list.getCompoundTagAt(i);
|
||||
PneumoMesageType msg = EnumUtil.grabEnumSafely(PneumoMesageType.class, listEntry.getByte(KEY_TYPE));
|
||||
int slotIndex = listEntry.getByte(KEY_SLOT_INDEX);
|
||||
SlotPneumo slot = (SlotPneumo) this.inventorySlots.get(slotIndex);
|
||||
if(msg == PneumoMesageType.UPDATE_ALL || msg == PneumoMesageType.UPDATE_COUNT) slot.amount = listEntry.getLong(KEY_LONG_COUNT);
|
||||
if(msg == PneumoMesageType.UPDATE_ALL || msg == PneumoMesageType.UPDATE_TYPE) slot.putStack(ItemStack.loadItemStackFromNBT(listEntry));
|
||||
}
|
||||
} else {
|
||||
NBTTagCompound line = list.getCompoundTagAt(i);
|
||||
DeltaType type = EnumUtil.grabEnumSafely(DeltaType.class, line.getByte("type"));
|
||||
|
||||
if(type == DeltaType.NEW_TYPE) {
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(line);
|
||||
long amount = line.getLong("amount");
|
||||
long hash = StackCache.getStackIdentity(stack);
|
||||
CacheSlotDummy dummy = new CacheSlotDummy(stack, amount);
|
||||
this.cachedEntries.put(hash, dummy);
|
||||
|
||||
} else if(type == DeltaType.COUNT_CHANGE) {
|
||||
long hash = line.getLong("hash");
|
||||
CacheSlotDummy dummy = this.cachedEntries.get(hash);
|
||||
if(dummy != null) dummy.stacksize = line.getLong("amount");
|
||||
}
|
||||
}
|
||||
|
||||
rebuildClientIndex();
|
||||
|
||||
} else {
|
||||
if(this.access.cache == null || this.access.cache.hasExpired) return;
|
||||
ClickType type = EnumUtil.grabEnumSafely(ClickType.class, data.getByte("type"));
|
||||
long hash = data.getLong("hash");
|
||||
CacheSlotDummy cache = this.cachedEntries.get(hash);
|
||||
ItemStack held = this.player.inventory.getItemStack();
|
||||
long heldHash = StackCache.getStackIdentity(held);
|
||||
|
||||
// left click
|
||||
if(type == ClickType.LEFT_CLICK || type == ClickType.RIGHT_CLICK) {
|
||||
|
||||
// if we drop an item onto a different stack, or no stack at all, deposit
|
||||
if(hash != heldHash && held != null) {
|
||||
int toDeposit = type == ClickType.LEFT_CLICK ? held.stackSize : 1;
|
||||
held.stackSize -= toDeposit;
|
||||
int leftover = (int) this.access.cache.addItemsAndReturnQuantity(held, toDeposit);
|
||||
held.stackSize += leftover;
|
||||
this.player.inventory.setItemStack(null);
|
||||
if(held.stackSize > 0) InventoryUtil.tryAddItemToInventory(player.inventory.mainInventory, held);
|
||||
detectAndSendChanges();
|
||||
return;
|
||||
}
|
||||
|
||||
// if our hand is empty or we have the same type, withdraw
|
||||
if(cache != null && (held == null || hash == heldHash)) {
|
||||
ItemStack stack = cache.displayStack.copy();
|
||||
int alreadyHeld = held == null ? 0 : held.stackSize;
|
||||
int capacity = stack.getMaxStackSize() - alreadyHeld;
|
||||
if(type == ClickType.RIGHT_CLICK && capacity > 1) capacity = 1;
|
||||
int toGrab = (int) Math.min(capacity, cache.stacksize);
|
||||
int grabbed = (int) this.access.cache.consumeItemsAndReturnQuantity(stack, toGrab);
|
||||
stack.stackSize = alreadyHeld + grabbed;
|
||||
this.player.inventory.setItemStack(stack);
|
||||
detectAndSendChanges();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(type == ClickType.SHIFT_CLICK && cache != null) {
|
||||
ItemStack stack = cache.displayStack.copy();
|
||||
int originalStacksize = (int) Math.min(stack.getMaxStackSize(), cache.stacksize);
|
||||
stack.stackSize = originalStacksize;
|
||||
ItemStack ret = InventoryUtil.tryAddItemToInventory(player.inventory.mainInventory, stack);
|
||||
int remainder = ret == null ? 0 : ret.stackSize;
|
||||
int itemsUsed = originalStacksize - remainder;
|
||||
this.access.cache.consumeItemsAndReturnQuantity(stack, itemsUsed);
|
||||
detectAndSendChanges();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void rebuildClientIndex() {
|
||||
|
||||
List<CacheSlotDummy> cacheSlots = new ArrayList(this.cachedEntries.size());
|
||||
cacheSlots.addAll(this.cachedEntries.values());
|
||||
cacheSlots.removeIf(x -> { return x.stacksize <= 0; });
|
||||
|
||||
if(this.searchString != null && !this.searchString.isEmpty()) {
|
||||
if(!detailedSearch) {
|
||||
cacheSlots.removeIf(x -> {
|
||||
return !x.displayStack.getDisplayName().toLowerCase(Locale.US).contains(searchString);
|
||||
});
|
||||
} else {
|
||||
cacheSlots.removeIf(x -> {
|
||||
boolean contains = x.displayStack.getDisplayName().toLowerCase(Locale.US).contains(searchString);
|
||||
List<String> toolTip = new ArrayList();
|
||||
if(!contains) {
|
||||
x.displayStack.getItem().addInformation(x.displayStack, MainRegistry.proxy.me(), toolTip, MainRegistry.proxy.advancedTooltips());
|
||||
for(String string : toolTip) {
|
||||
if(string.toLowerCase(Locale.US).contains(searchString)) {
|
||||
contains = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return !contains;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
listingSize = cacheSlots.size();
|
||||
Collections.sort(cacheSlots, this.sorter);
|
||||
int size = cacheSlots.size();
|
||||
|
||||
int offset = listingStart * 8;
|
||||
|
||||
for(int i = 0; i < inventory.slots.length; i++) {
|
||||
int grabIndex = offset + i;
|
||||
if(grabIndex < size) {
|
||||
CacheSlotDummy cacheSlot = cacheSlots.get(grabIndex);
|
||||
SlotPneumo slot = (SlotPneumo) this.inventorySlots.get(i);
|
||||
if(cacheSlot.displayStack != null) {
|
||||
slot.putStack(cacheSlot.displayStack.copy());
|
||||
slot.amount = cacheSlot.stacksize;
|
||||
} else {
|
||||
slot.putStack(null);
|
||||
slot.amount = 0;
|
||||
}
|
||||
} else {
|
||||
inventory.slots[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final Comparator<CacheSlotDummy> SORT_BY_STACK_SIZE = new Comparator<CacheSlotDummy>() {
|
||||
@Override
|
||||
public int compare(CacheSlotDummy o1, CacheSlotDummy o2) {
|
||||
if(o1.stacksize > o2.stacksize) return -1; if(o1.stacksize < o2.stacksize) return 1;
|
||||
if(o1.itemId < o2.itemId) return -1; if(o1.itemId > o2.itemId) return 1;
|
||||
if(o1.meta < o2.meta) return -1; if(o1.meta > o2.meta) return 1;
|
||||
if(o1.nbt == null && o2.nbt != null) return -1; if(o1.nbt != null && o2.nbt == null) return 1;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
public static final Comparator<CacheSlotDummy> SORT_BY_ID = new Comparator<CacheSlotDummy>() {
|
||||
@Override
|
||||
public int compare(CacheSlotDummy o1, CacheSlotDummy o2) {
|
||||
if(o1.itemId < o2.itemId) return -1; if(o1.itemId > o2.itemId) return 1;
|
||||
if(o1.meta < o2.meta) return -1; if(o1.meta > o2.meta) return 1;
|
||||
if(o1.stacksize > o2.stacksize) return -1; if(o1.stacksize < o2.stacksize) return 1;
|
||||
if(o1.nbt == null && o2.nbt != null) return -1; if(o1.nbt != null && o2.nbt == null) return 1;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
public static final Comparator<CacheSlotDummy> SORT_BY_INTERNAL = new Comparator<CacheSlotDummy>() {
|
||||
@Override
|
||||
public int compare(CacheSlotDummy o1, CacheSlotDummy o2) {
|
||||
String name1 = o1.displayStack.getItem().getUnlocalizedName(o1.displayStack);
|
||||
String name2 = o2.displayStack.getItem().getUnlocalizedName(o2.displayStack);
|
||||
int compare = name1.compareToIgnoreCase(name2);
|
||||
if(compare != 0) return compare;
|
||||
return SORT_BY_ID.compare(o1, o2);
|
||||
}
|
||||
};
|
||||
|
||||
public static final Comparator<CacheSlotDummy> SORT_BY_LOCALIZED = new Comparator<CacheSlotDummy>() {
|
||||
@Override
|
||||
public int compare(CacheSlotDummy o1, CacheSlotDummy o2) {
|
||||
String name1 = o1.displayStack.getItem().getItemStackDisplayName(o1.displayStack);
|
||||
String name2 = o2.displayStack.getItem().getItemStackDisplayName(o2.displayStack);
|
||||
int compare = name1.compareToIgnoreCase(name2);
|
||||
if(compare != 0) return compare;
|
||||
return SORT_BY_ID.compare(o1, o2);
|
||||
}
|
||||
};
|
||||
|
||||
protected static Comparator<CacheSlotDummy> sorter = SORT_BY_STACK_SIZE;
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
|
||||
return null;
|
||||
@ -378,7 +517,7 @@ public class ContainerPneumoStorageAccess extends Container implements ICustomPa
|
||||
|
||||
@Override public int getSizeInventory() { return GRID_SIZE; }
|
||||
@Override public ItemStack getStackInSlot(int slot) { return slots[slot]; }
|
||||
@Override public int getInventoryStackLimit() { return 64; }
|
||||
@Override public int getInventoryStackLimit() { return 1; }
|
||||
@Override public ItemStack decrStackSize(int slot, int amount) { return null; }
|
||||
@Override public void setInventorySlotContents(int slot, ItemStack stack) { this.slots[slot] = stack; }
|
||||
|
||||
|
||||
@ -1,492 +0,0 @@
|
||||
package com.hbm.inventory.container;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.hbm.inventory.SlotNonRetarded;
|
||||
import com.hbm.inventory.container.ContainerPneumoStorageAccess.InventoryPneumoStorageAccess;
|
||||
import com.hbm.inventory.container.ContainerPneumoStorageAccess.SlotPneumo;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.packet.toclient.ContainerNBTCommsPacket;
|
||||
import com.hbm.tileentity.network.pneumatic.TileEntityPneumoStorageAccess;
|
||||
import com.hbm.util.EnumUtil;
|
||||
import com.hbm.util.InventoryUtil;
|
||||
|
||||
import api.hbm.ntl.StackCache;
|
||||
import api.hbm.ntl.StackCache.CacheSlot;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
public class ContainerPneumoStorageAccessMK2 extends Container implements ICustomPayloadReceiver {
|
||||
|
||||
protected TileEntityPneumoStorageAccess access;
|
||||
protected InventoryPneumoStorageAccess inventory;
|
||||
protected EntityPlayer player;
|
||||
protected String searchString = "";
|
||||
|
||||
public static boolean detailedSearch = false;
|
||||
|
||||
/** On the server, this is used to find changes in the system and then send them to the client. On the client, this is just to keep track of all items. */
|
||||
protected LinkedHashMap<Long, CacheSlotDummy> cachedEntries = new LinkedHashMap();
|
||||
/** Server to client queue, contains NBT tags that represents deltas yet to be sent to the client */
|
||||
public LinkedList<NBTTagCompound> s2cQueue = new LinkedList();
|
||||
|
||||
public void setSorter(Comparator<CacheSlotDummy> sorter) {
|
||||
this.listingStart = 0;
|
||||
this.sorter = sorter;
|
||||
this.rebuildClientIndex();
|
||||
}
|
||||
|
||||
public void setSearchString(String search) {
|
||||
this.listingStart = 0;
|
||||
this.searchString = search.toLowerCase(Locale.US);
|
||||
this.rebuildClientIndex();
|
||||
}
|
||||
|
||||
/** Used to temporarily store the previous CacheSlot contents to calculate deltas with (i.e. detect changes) */
|
||||
public static class CacheSlotDummy {
|
||||
|
||||
public final ItemStack displayStack;
|
||||
public long stacksize;
|
||||
public final int itemId;
|
||||
public final int meta;
|
||||
public final NBTTagCompound nbt;
|
||||
|
||||
public CacheSlotDummy(ItemStack displayStack, long stacksize) {
|
||||
this.displayStack = displayStack;
|
||||
this.stacksize = stacksize;
|
||||
this.itemId = Item.getIdFromItem(displayStack.getItem());
|
||||
this.meta = displayStack.getItemDamage();
|
||||
if(displayStack.hasTagCompound()) this.nbt = (NBTTagCompound) displayStack.stackTagCompound.copy();
|
||||
else this.nbt = null;
|
||||
}
|
||||
|
||||
public CacheSlotDummy(CacheSlot original) {
|
||||
this(original.displayStack.copy(), original.stacksize);
|
||||
}
|
||||
}
|
||||
|
||||
public static final int GRID_SIZE = 6 * 8;
|
||||
public static final int DELTAS_PER_MSG = 6 * 8;
|
||||
|
||||
public int listingStart = 0;
|
||||
public int listingSize = 0;
|
||||
|
||||
public int getStackCount() {
|
||||
return listingSize;
|
||||
}
|
||||
|
||||
/** Serverside, creates a new delta for a new item stack */
|
||||
public void pushNewItem(ItemStack zeroStack, long amount) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setByte("type", (byte) DeltaType.NEW_TYPE.ordinal());
|
||||
zeroStack.writeToNBT(data);
|
||||
data.setLong("amount", amount);
|
||||
s2cQueue.add(data);
|
||||
}
|
||||
|
||||
/** Serverside, creates a new delta for an amount update */
|
||||
public void updateCount(long hash, long amount) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setByte("type", (byte) DeltaType.COUNT_CHANGE.ordinal());
|
||||
data.setLong("hash", hash);
|
||||
data.setLong("amount", amount);
|
||||
s2cQueue.add(data);
|
||||
}
|
||||
|
||||
/** Serverside, bunches up deltas into NBTTagLists and sends them, 48 (DELTAS_PER_MSG) at a time */
|
||||
public void processDeltasAndSync(EntityPlayerMP playerMP) {
|
||||
if(s2cQueue.isEmpty()) return;
|
||||
|
||||
NBTTagList list = null;
|
||||
|
||||
while(!s2cQueue.isEmpty()) {
|
||||
if(list == null) list = new NBTTagList();
|
||||
list.appendTag(s2cQueue.removeFirst());
|
||||
if(list.tagCount() >= DELTAS_PER_MSG) { bonVoyage(list, playerMP); list = null; }
|
||||
}
|
||||
|
||||
if(list != null) bonVoyage(list, playerMP);
|
||||
}
|
||||
|
||||
/** Wraps the NBTTagList into a master compound tag and sends it to the client */
|
||||
public void bonVoyage(NBTTagList list, EntityPlayerMP playerMP) {
|
||||
NBTTagCompound masterTag = new NBTTagCompound();
|
||||
masterTag.setTag("list", list);
|
||||
PacketDispatcher.wrapper.sendTo(new ContainerNBTCommsPacket(playerMP.currentWindowId, masterTag), playerMP);
|
||||
}
|
||||
|
||||
/** Compares the original access stack cache with the one we have buffered to detect changes and pushes them to the s2c sending queue */
|
||||
public void checkAndSyncCache() {
|
||||
if(this.access.cache == null || this.access.cache.hasExpired) return;
|
||||
|
||||
for(Entry<Long, CacheSlot> entry : this.access.cache.cacheSlots.entrySet()) {
|
||||
|
||||
Long hash = entry.getKey();
|
||||
if(hash == StackCache.getNullIdentity()) continue;
|
||||
|
||||
CacheSlotDummy existingCache = this.cachedEntries.get(hash);
|
||||
CacheSlot properCache = entry.getValue();
|
||||
|
||||
// if the previous entries already contain this type, check for amount change
|
||||
if(existingCache != null) {
|
||||
if(existingCache.stacksize != properCache.stacksize) {
|
||||
this.updateCount(hash, properCache.stacksize);
|
||||
existingCache.stacksize = properCache.stacksize;
|
||||
}
|
||||
// if not, add that type to our index
|
||||
} else {
|
||||
existingCache = new CacheSlotDummy(properCache);
|
||||
existingCache.stacksize = properCache.stacksize;
|
||||
this.cachedEntries.put(hash, existingCache);
|
||||
this.pushNewItem(existingCache.displayStack, existingCache.stacksize);
|
||||
}
|
||||
}
|
||||
|
||||
if(player instanceof EntityPlayerMP) processDeltasAndSync((EntityPlayerMP) this.player);
|
||||
}
|
||||
|
||||
public ContainerPneumoStorageAccessMK2(InventoryPlayer invPlayer, TileEntityPneumoStorageAccess access) {
|
||||
this.access = access;
|
||||
this.inventory = new InventoryPneumoStorageAccess(access);
|
||||
this.player = invPlayer.player;
|
||||
|
||||
int hOffset = 34;
|
||||
|
||||
for(int i = 0; i < 6; i++) for(int j = 0; j < 8; j++) {
|
||||
this.addSlotToContainer(new SlotPneumo(inventory, j + i * 8, 8 + j * 18 + hOffset, 17 + i * 18));
|
||||
}
|
||||
|
||||
for(int i = 0; i < 3; i++) for(int j = 0; j < 9; j++) {
|
||||
this.addSlotToContainer(new SlotNonRetarded(invPlayer, j + i * 9 + 9, 8 + j * 18 + hOffset, 169 + i * 18));
|
||||
}
|
||||
|
||||
for(int i = 0; i < 9; i++) {
|
||||
this.addSlotToContainer(new SlotNonRetarded(invPlayer, i, 8 + i * 18 + hOffset, 227));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick(int index, int button, int mode, EntityPlayer player) {
|
||||
if(mode == 6) return null;
|
||||
|
||||
if(index == ContainerPneumoStorageAccess.SLOT_CLICK_ID_REFRESH) {
|
||||
this.listingStart = mode;
|
||||
this.detectAndSendChanges();
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean client = player.worldObj.isRemote;
|
||||
boolean leftClick = button == 0 && mode == 0;
|
||||
boolean rightClick = button == 1 && mode == 0;
|
||||
boolean shiftClick = button == 0 && mode == 1;
|
||||
|
||||
if(index >= 0 && index < GRID_SIZE) {
|
||||
if(!client) return null;
|
||||
SlotPneumo slot = (SlotPneumo) this.getSlot(index);
|
||||
long hash = StackCache.getStackIdentity(slot.getStack());
|
||||
ItemStack held = player.inventory.getItemStack();
|
||||
long heldHash = StackCache.getStackIdentity(held);
|
||||
if(leftClick) {
|
||||
if(held != null && hash != heldHash) held = null;
|
||||
else if(held != null && hash == heldHash) {
|
||||
held.stackSize += slot.amount;
|
||||
held.stackSize = Math.min(held.stackSize, held.getMaxStackSize());
|
||||
} else if(held == null && slot.getHasStack()) {
|
||||
held = slot.getStack().copy();
|
||||
held.stackSize = (int) Math.min(slot.amount, held.getMaxStackSize());
|
||||
}
|
||||
this.player.inventory.setItemStack(held);
|
||||
sendClickToServer(ClickType.LEFT_CLICK, hash);
|
||||
return null;
|
||||
}
|
||||
if(rightClick) {
|
||||
if(held != null && hash != heldHash) held.stackSize--;
|
||||
else if(held != null && hash == heldHash) {
|
||||
held.stackSize += 1;
|
||||
held.stackSize = Math.min(held.stackSize, held.getMaxStackSize());
|
||||
} else if(held == null && slot.getHasStack()) {
|
||||
held = slot.getStack().copy();
|
||||
held.stackSize = 1;
|
||||
}
|
||||
if(held.stackSize <= 0) held = null;
|
||||
this.player.inventory.setItemStack(held);
|
||||
sendClickToServer(ClickType.RIGHT_CLICK, hash);
|
||||
return null;
|
||||
}
|
||||
if(shiftClick) { sendClickToServer(ClickType.SHIFT_CLICK, hash); return null; }
|
||||
|
||||
// shift clicking an item from the player inv to the storage
|
||||
} else if(index >= GRID_SIZE && index < this.inventorySlots.size()) {
|
||||
|
||||
Slot slot = this.getSlot(index);
|
||||
|
||||
if(shiftClick && slot.getHasStack()) {
|
||||
ItemStack stack = slot.getStack().copy();
|
||||
if(this.access.cache == null || this.access.cache.hasExpired) return null;
|
||||
StackCache cache = this.access.cache;
|
||||
int remainder = (int) cache.addItemsAndReturnQuantity(stack, stack.stackSize);
|
||||
slot.decrStackSize(stack.stackSize - remainder);
|
||||
if(remainder <= 0) slot.putStack(null);
|
||||
slot.onSlotChanged();
|
||||
detectAndSendChanges();
|
||||
return null; // technically not needed but we don't have to run 500,000 lines of code that ends up doing nothing
|
||||
}
|
||||
}
|
||||
|
||||
return super.slotClick(index, button, mode, player);
|
||||
}
|
||||
|
||||
public void sendClickToServer(ClickType type, long hash) {
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setByte("type", (byte) type.ordinal());
|
||||
data.setLong("hash", hash);
|
||||
PacketDispatcher.wrapper.sendToServer(new ContainerNBTCommsPacket(this.windowId, data));
|
||||
}
|
||||
|
||||
public long[] previousStackSizes = new long[GRID_SIZE];
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
|
||||
// skip the first 6*8 slots, i.e. all the ones visible in the access grid
|
||||
for(int i = GRID_SIZE; i < this.inventorySlots.size(); i++) {
|
||||
ItemStack stack0 = ((Slot) this.inventorySlots.get(i)).getStack();
|
||||
ItemStack stack1 = (ItemStack) this.inventoryItemStacks.get(i);
|
||||
|
||||
if(!ItemStack.areItemStacksEqual(stack1, stack0)) {
|
||||
stack1 = stack0 == null ? null : stack0.copy();
|
||||
this.inventoryItemStacks.set(i, stack1);
|
||||
|
||||
for(int j = 0; j < this.crafters.size(); ++j) {
|
||||
((ICrafting) this.crafters.get(j)).sendSlotContents(this, i, stack1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean isServer = !this.access.getWorldObj().isRemote;
|
||||
|
||||
if(isServer) {
|
||||
checkAndSyncCache();
|
||||
} else {
|
||||
rebuildClientIndex();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return access.getDistanceFrom(player.posX, player.posY, player.posZ) <= 15 * 15;
|
||||
}
|
||||
|
||||
/** For S2C to send deltas updating the available items */
|
||||
public static enum DeltaType {
|
||||
NEW_TYPE,
|
||||
COUNT_CHANGE;
|
||||
}
|
||||
|
||||
public static enum ClickType {
|
||||
LEFT_CLICK,
|
||||
RIGHT_CLICK,
|
||||
SHIFT_CLICK
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptData(Side side, int windowId, NBTTagCompound data) {
|
||||
if(windowId != this.windowId) return;
|
||||
|
||||
if(side == Side.CLIENT) {
|
||||
NBTTagList list = data.getTagList("list", 10);
|
||||
|
||||
for(int i = 0; i < list.tagCount(); i++) {
|
||||
NBTTagCompound line = list.getCompoundTagAt(i);
|
||||
DeltaType type = EnumUtil.grabEnumSafely(DeltaType.class, line.getByte("type"));
|
||||
|
||||
if(type == DeltaType.NEW_TYPE) {
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(line);
|
||||
long amount = line.getLong("amount");
|
||||
long hash = StackCache.getStackIdentity(stack);
|
||||
CacheSlotDummy dummy = new CacheSlotDummy(stack, amount);
|
||||
this.cachedEntries.put(hash, dummy);
|
||||
|
||||
} else if(type == DeltaType.COUNT_CHANGE) {
|
||||
long hash = line.getLong("hash");
|
||||
CacheSlotDummy dummy = this.cachedEntries.get(hash);
|
||||
if(dummy != null) dummy.stacksize = line.getLong("amount");
|
||||
}
|
||||
}
|
||||
|
||||
rebuildClientIndex();
|
||||
|
||||
} else {
|
||||
if(this.access.cache == null || this.access.cache.hasExpired) return;
|
||||
ClickType type = EnumUtil.grabEnumSafely(ClickType.class, data.getByte("type"));
|
||||
long hash = data.getLong("hash");
|
||||
CacheSlotDummy cache = this.cachedEntries.get(hash);
|
||||
ItemStack held = this.player.inventory.getItemStack();
|
||||
long heldHash = StackCache.getStackIdentity(held);
|
||||
|
||||
// left click
|
||||
if(type == ClickType.LEFT_CLICK || type == ClickType.RIGHT_CLICK) {
|
||||
|
||||
// if we drop an item onto a different stack, or no stack at all, deposit
|
||||
if(hash != heldHash && held != null) {
|
||||
int toDeposit = type == ClickType.LEFT_CLICK ? held.stackSize : 1;
|
||||
held.stackSize -= toDeposit;
|
||||
int leftover = (int) this.access.cache.addItemsAndReturnQuantity(held, toDeposit);
|
||||
held.stackSize += leftover;
|
||||
this.player.inventory.setItemStack(null);
|
||||
if(held.stackSize > 0) InventoryUtil.tryAddItemToInventory(player.inventory.mainInventory, held);
|
||||
detectAndSendChanges();
|
||||
return;
|
||||
}
|
||||
|
||||
// if our hand is empty or we have the same type, withdraw
|
||||
if(cache != null && (held == null || hash == heldHash)) {
|
||||
ItemStack stack = cache.displayStack.copy();
|
||||
int alreadyHeld = held == null ? 0 : held.stackSize;
|
||||
int capacity = stack.getMaxStackSize() - alreadyHeld;
|
||||
if(type == ClickType.RIGHT_CLICK && capacity > 1) capacity = 1;
|
||||
int toGrab = (int) Math.min(capacity, cache.stacksize);
|
||||
int grabbed = (int) this.access.cache.consumeItemsAndReturnQuantity(stack, toGrab);
|
||||
stack.stackSize = alreadyHeld + grabbed;
|
||||
this.player.inventory.setItemStack(stack);
|
||||
detectAndSendChanges();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(type == ClickType.SHIFT_CLICK && cache != null) {
|
||||
ItemStack stack = cache.displayStack.copy();
|
||||
int originalStacksize = (int) Math.min(stack.getMaxStackSize(), cache.stacksize);
|
||||
stack.stackSize = originalStacksize;
|
||||
ItemStack ret = InventoryUtil.tryAddItemToInventory(player.inventory.mainInventory, stack);
|
||||
int remainder = ret == null ? 0 : ret.stackSize;
|
||||
int itemsUsed = originalStacksize - remainder;
|
||||
this.access.cache.consumeItemsAndReturnQuantity(stack, itemsUsed);
|
||||
detectAndSendChanges();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void rebuildClientIndex() {
|
||||
|
||||
List<CacheSlotDummy> cacheSlots = new ArrayList(this.cachedEntries.size());
|
||||
cacheSlots.addAll(this.cachedEntries.values());
|
||||
cacheSlots.removeIf(x -> { return x.stacksize <= 0; });
|
||||
|
||||
if(this.searchString != null && !this.searchString.isEmpty()) {
|
||||
if(!detailedSearch) {
|
||||
cacheSlots.removeIf(x -> {
|
||||
return !x.displayStack.getDisplayName().toLowerCase(Locale.US).contains(searchString);
|
||||
});
|
||||
} else {
|
||||
cacheSlots.removeIf(x -> {
|
||||
boolean contains = x.displayStack.getDisplayName().toLowerCase(Locale.US).contains(searchString);
|
||||
List<String> toolTip = new ArrayList();
|
||||
if(!contains) {
|
||||
x.displayStack.getItem().addInformation(x.displayStack, MainRegistry.proxy.me(), toolTip, MainRegistry.proxy.advancedTooltips());
|
||||
for(String string : toolTip) {
|
||||
if(string.toLowerCase(Locale.US).contains(searchString)) {
|
||||
contains = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return !contains;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
listingSize = cacheSlots.size();
|
||||
Collections.sort(cacheSlots, this.sorter);
|
||||
int size = cacheSlots.size();
|
||||
|
||||
int offset = listingStart * 8;
|
||||
|
||||
for(int i = 0; i < inventory.slots.length; i++) {
|
||||
int grabIndex = offset + i;
|
||||
if(grabIndex < size) {
|
||||
CacheSlotDummy cacheSlot = cacheSlots.get(grabIndex);
|
||||
SlotPneumo slot = (SlotPneumo) this.inventorySlots.get(i);
|
||||
if(cacheSlot.displayStack != null) {
|
||||
slot.putStack(cacheSlot.displayStack.copy());
|
||||
slot.amount = cacheSlot.stacksize;
|
||||
} else {
|
||||
slot.putStack(null);
|
||||
slot.amount = 0;
|
||||
}
|
||||
} else {
|
||||
inventory.slots[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final Comparator<CacheSlotDummy> SORT_BY_STACK_SIZE = new Comparator<CacheSlotDummy>() {
|
||||
@Override
|
||||
public int compare(CacheSlotDummy o1, CacheSlotDummy o2) {
|
||||
if(o1.stacksize > o2.stacksize) return -1; if(o1.stacksize < o2.stacksize) return 1;
|
||||
if(o1.itemId < o2.itemId) return -1; if(o1.itemId > o2.itemId) return 1;
|
||||
if(o1.meta < o2.meta) return -1; if(o1.meta > o2.meta) return 1;
|
||||
if(o1.nbt == null && o2.nbt != null) return -1; if(o1.nbt != null && o2.nbt == null) return 1;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
public static final Comparator<CacheSlotDummy> SORT_BY_ID = new Comparator<CacheSlotDummy>() {
|
||||
@Override
|
||||
public int compare(CacheSlotDummy o1, CacheSlotDummy o2) {
|
||||
if(o1.itemId < o2.itemId) return -1; if(o1.itemId > o2.itemId) return 1;
|
||||
if(o1.meta < o2.meta) return -1; if(o1.meta > o2.meta) return 1;
|
||||
if(o1.stacksize > o2.stacksize) return -1; if(o1.stacksize < o2.stacksize) return 1;
|
||||
if(o1.nbt == null && o2.nbt != null) return -1; if(o1.nbt != null && o2.nbt == null) return 1;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
public static final Comparator<CacheSlotDummy> SORT_BY_INTERNAL = new Comparator<CacheSlotDummy>() {
|
||||
@Override
|
||||
public int compare(CacheSlotDummy o1, CacheSlotDummy o2) {
|
||||
String name1 = o1.displayStack.getItem().getUnlocalizedName(o1.displayStack);
|
||||
String name2 = o2.displayStack.getItem().getUnlocalizedName(o2.displayStack);
|
||||
int compare = name1.compareToIgnoreCase(name2);
|
||||
if(compare != 0) return compare;
|
||||
return SORT_BY_ID.compare(o1, o2);
|
||||
}
|
||||
};
|
||||
|
||||
public static final Comparator<CacheSlotDummy> SORT_BY_LOCALIZED = new Comparator<CacheSlotDummy>() {
|
||||
@Override
|
||||
public int compare(CacheSlotDummy o1, CacheSlotDummy o2) {
|
||||
String name1 = o1.displayStack.getItem().getItemStackDisplayName(o1.displayStack);
|
||||
String name2 = o2.displayStack.getItem().getItemStackDisplayName(o2.displayStack);
|
||||
int compare = name1.compareToIgnoreCase(name2);
|
||||
if(compare != 0) return compare;
|
||||
return SORT_BY_ID.compare(o1, o2);
|
||||
}
|
||||
};
|
||||
|
||||
protected static Comparator<CacheSlotDummy> sorter = SORT_BY_STACK_SIZE;
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -7,7 +7,6 @@ import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import static com.hbm.inventory.gui.element.GUIElements.*;
|
||||
import com.hbm.inventory.container.ContainerPneumoStorageAccessMK2;
|
||||
import com.hbm.inventory.container.ContainerPneumoStorageAccess;
|
||||
import com.hbm.inventory.container.ContainerPneumoStorageAccess.SlotPneumo;
|
||||
import com.hbm.inventory.gui.element.GUIElements;
|
||||
@ -30,7 +29,7 @@ public class GUIPneumoStorageAccess extends GuiInfoContainer {
|
||||
|
||||
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/storage/gui_pneumatic_access.png");
|
||||
protected TileEntityPneumoStorageAccess access;
|
||||
protected ContainerPneumoStorageAccessMK2 container;
|
||||
protected ContainerPneumoStorageAccess container;
|
||||
protected GuiTextField search;
|
||||
|
||||
protected int scrollIndex = 0;
|
||||
@ -43,8 +42,8 @@ public class GUIPneumoStorageAccess extends GuiInfoContainer {
|
||||
protected static boolean startFocussed = false;
|
||||
|
||||
public GUIPneumoStorageAccess(InventoryPlayer invPlayer, TileEntityPneumoStorageAccess access) {
|
||||
super(new ContainerPneumoStorageAccessMK2(invPlayer, access));
|
||||
this.container = (ContainerPneumoStorageAccessMK2) this.inventorySlots;
|
||||
super(new ContainerPneumoStorageAccess(invPlayer, access));
|
||||
this.container = (ContainerPneumoStorageAccess) this.inventorySlots;
|
||||
this.access = access;
|
||||
|
||||
this.xSize = 176 + 34;
|
||||
|
||||
@ -264,7 +264,7 @@ public class AssemblyMachineRecipes extends GenericRecipes<GenericRecipe> {
|
||||
this.register(new GenericRecipe("ass.electrolyzer").setup(200, 100).outputItems(new ItemStack(ModBlocks.machine_electrolyser, 1))
|
||||
.inputItems(new OreDictStack(STEEL.plateCast(), 8), new OreDictStack(CU.plate(), 16), new OreDictStack(TI.shell(), 3), new OreDictStack(RUBBER.ingot(), 8), new ComparableStack(ModItems.ingot_firebrick, 16), new ComparableStack(ModItems.coil_copper, 16), new ComparableStack(ModItems.circuit, 8, EnumCircuitType.BASIC))
|
||||
.inputItemsEx(new ComparableStack(ModItems.item_expensive, 4, EnumExpensiveType.HEAVY_FRAME), new OreDictStack(TI.shell(), 3), new OreDictStack(RUBBER.ingot(), 8), new ComparableStack(ModItems.ingot_firebrick, 16), new ComparableStack(ModItems.coil_copper, 16), new ComparableStack(ModItems.item_expensive, 4, EnumExpensiveType.CIRCUIT)));
|
||||
this.register(new GenericRecipe("ass.rtg").setup(200, 100).outputItems(new ItemStack(ModBlocks.machine_rtg_grey, 1))
|
||||
this.register(new GenericRecipe("ass.rtg").setup(200, 100).outputItems(new ItemStack(ModBlocks.machine_rtg, 1))
|
||||
.inputItems(new ComparableStack(ModItems.rtg_unit, 3), new OreDictStack(STEEL.plate(), 4), new OreDictStack(MINGRADE.wireFine(), 16), new OreDictStack(ANY_PLASTIC.ingot(), 4)));
|
||||
this.register(new GenericRecipe("ass.derrick").setup(200, 100).outputItems(new ItemStack(ModBlocks.machine_well, 1))
|
||||
.inputItems(new OreDictStack(STEEL.plate(), 8), new OreDictStack(CU.plateCast(), 2), new OreDictStack(STEEL.pipe(), 4), new ComparableStack(ModItems.motor, 1), new ComparableStack(ModItems.drill_titanium, 1))
|
||||
|
||||
@ -6,6 +6,7 @@ import com.hbm.items.ItemEnumMulti;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.util.BobMathUtil;
|
||||
import com.hbm.util.EnumUtil;
|
||||
import com.hbm.util.i18n.I18nUtil;
|
||||
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@ -58,5 +59,9 @@ public class ItemBatterySC extends ItemEnumMulti implements IBatteryItem {
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) {
|
||||
EnumBatterySC pack = EnumUtil.grabEnumSafely(EnumBatterySC.class, stack.getItemDamage());
|
||||
if(pack.power > 0) list.add(EnumChatFormatting.YELLOW + "Discharge rate: " + BobMathUtil.getShortNumber(pack.power) + "HE/t");
|
||||
|
||||
for(String line : I18nUtil.resolveKeyArray(this.getUnlocalizedName() + ".desc")) {
|
||||
list.add(EnumChatFormatting.RED + line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ public class ItemStarterKit extends Item {
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModBlocks.reactor_research, 4));
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModBlocks.machine_turbine, 4));
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModBlocks.machine_radgen, 1));
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModBlocks.machine_rtg_grey, 1));
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModBlocks.machine_rtg, 1));
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModBlocks.machine_assembly_machine, 3));
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModBlocks.machine_chemical_plant, 2));
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModBlocks.machine_fluidtank, 1));
|
||||
|
||||
@ -307,7 +307,6 @@ public class ClientProxy extends ServerProxy {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineCrystallizer.class, new RenderCrystallizer());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMicrowave.class, new RenderMicrowave());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineRTG.class, new RenderRTG());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineMiniRTG.class, new RenderRTG());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFF.class, new RenderForceField());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityForceField.class, new RenderMachineForceField());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineFENSU.class, new RenderFENSU());
|
||||
|
||||
@ -1629,6 +1629,8 @@ public class MainRegistry {
|
||||
ignoreMappings.add("hbm:item.coil_advanced_alloy");
|
||||
ignoreMappings.add("hbm:item.coil_advanced_torus");
|
||||
ignoreMappings.add("hbm:item.blades_advanced_alloy");
|
||||
ignoreMappings.add("hbm:tile.machine_minirtg");
|
||||
ignoreMappings.add("hbm:tile.machine_powerrtg");
|
||||
|
||||
/// REMAP ///
|
||||
remapItems.put("hbm:item.gadget_explosive8", ModItems.early_explosive_lenses);
|
||||
|
||||
@ -672,8 +672,6 @@ public class ResourceManager {
|
||||
|
||||
//RTG
|
||||
public static final ResourceLocation rtg_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/rtg.png");
|
||||
public static final ResourceLocation rtg_cell_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/rtg_cell.png");
|
||||
public static final ResourceLocation rtg_polonium_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/rtg_polonium.png");
|
||||
|
||||
//Waste Drum
|
||||
public static final ResourceLocation waste_drum_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/drum_gray.png");
|
||||
|
||||
@ -2,7 +2,6 @@ package com.hbm.render.tileentity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.main.ResourceManager;
|
||||
|
||||
@ -14,47 +13,42 @@ public class RenderRTG extends TileEntitySpecialRenderer {
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float inter) {
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5D, y, z + 0.5D);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5D, y, z + 0.5D);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glRotatef(180, 0F, 1F, 0F);
|
||||
|
||||
if(te.getBlockType() == ModBlocks.machine_rtg_grey)
|
||||
bindTexture(ResourceManager.rtg_tex);
|
||||
else if(te.getBlockType() == ModBlocks.machine_powerrtg)
|
||||
bindTexture(ResourceManager.rtg_polonium_tex);
|
||||
else
|
||||
bindTexture(ResourceManager.rtg_cell_tex);
|
||||
bindTexture(ResourceManager.rtg_tex);
|
||||
|
||||
ResourceManager.rtg.renderPart("Gen");
|
||||
ResourceManager.rtg.renderPart("Gen");
|
||||
|
||||
int ix = te.xCoord;
|
||||
int iy = te.yCoord;
|
||||
int iz = te.zCoord;
|
||||
int ix = te.xCoord;
|
||||
int iy = te.yCoord;
|
||||
int iz = te.zCoord;
|
||||
|
||||
if(Library.canConnect(te.getWorldObj(), ix + 1, iy, iz, Library.POS_X))
|
||||
ResourceManager.rtg.renderPart("Connector");
|
||||
if(Library.canConnect(te.getWorldObj(), ix + 1, iy, iz, Library.POS_X))
|
||||
ResourceManager.rtg.renderPart("Connector");
|
||||
|
||||
if(Library.canConnect(te.getWorldObj(), ix - 1, iy, iz, Library.NEG_X)) {
|
||||
GL11.glRotatef(180, 0F, 1F, 0F);
|
||||
ResourceManager.rtg.renderPart("Connector");
|
||||
GL11.glRotatef(-180, 0F, 1F, 0F);
|
||||
}
|
||||
if(Library.canConnect(te.getWorldObj(), ix - 1, iy, iz, Library.NEG_X)) {
|
||||
GL11.glRotatef(180, 0F, 1F, 0F);
|
||||
ResourceManager.rtg.renderPart("Connector");
|
||||
GL11.glRotatef(-180, 0F, 1F, 0F);
|
||||
}
|
||||
|
||||
if(Library.canConnect(te.getWorldObj(), ix, iy, iz - 1, Library.NEG_Z)) {
|
||||
GL11.glRotatef(90, 0F, 1F, 0F);
|
||||
ResourceManager.rtg.renderPart("Connector");
|
||||
GL11.glRotatef(-90, 0F, 1F, 0F);
|
||||
}
|
||||
if(Library.canConnect(te.getWorldObj(), ix, iy, iz - 1, Library.NEG_Z)) {
|
||||
GL11.glRotatef(90, 0F, 1F, 0F);
|
||||
ResourceManager.rtg.renderPart("Connector");
|
||||
GL11.glRotatef(-90, 0F, 1F, 0F);
|
||||
}
|
||||
|
||||
if(Library.canConnect(te.getWorldObj(), ix, iy, iz + 1, Library.POS_Z)) {
|
||||
GL11.glRotatef(-90, 0F, 1F, 0F);
|
||||
ResourceManager.rtg.renderPart("Connector");
|
||||
GL11.glRotatef(90, 0F, 1F, 0F);
|
||||
}
|
||||
if(Library.canConnect(te.getWorldObj(), ix, iy, iz + 1, Library.POS_Z)) {
|
||||
GL11.glRotatef(-90, 0F, 1F, 0F);
|
||||
ResourceManager.rtg.renderPart("Connector");
|
||||
GL11.glRotatef(90, 0F, 1F, 0F);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -179,7 +179,6 @@ public class TileMappings {
|
||||
put(TileEntityMachineMiningLaser.class, "tileentity_mining_laser");
|
||||
put(TileEntityNukeBalefire.class, "tileentity_nuke_fstbmb");
|
||||
put(TileEntityMicrowave.class, "tileentity_microwave");
|
||||
put(TileEntityMachineMiniRTG.class, "tileentity_mini_rtg");
|
||||
put(TileEntityBlockICF.class, "tileentity_block_icf");
|
||||
put(TileEntityICFPress.class, "tileentity_icf_press");
|
||||
put(TileEntityICFController.class, "tileentity_icf_controller");
|
||||
|
||||
@ -1,60 +0,0 @@
|
||||
package com.hbm.tileentity.machine;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
import com.hbm.util.CompatEnergyControl;
|
||||
|
||||
import api.hbm.energymk2.IEnergyProviderMK2;
|
||||
import api.hbm.tile.IInfoProviderEC;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityMachineMiniRTG extends TileEntityLoadedBase implements IEnergyProviderMK2, IInfoProviderEC {
|
||||
|
||||
public long power;
|
||||
boolean tact = false;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
power += this.getOutput();
|
||||
|
||||
if(power > getMaxPower())
|
||||
power = getMaxPower();
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
this.tryProvide(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public long getOutput() {
|
||||
if(this.getBlockType() == ModBlocks.machine_powerrtg) return 2_500;
|
||||
return 700;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxPower() {
|
||||
if(this.getBlockType() == ModBlocks.machine_powerrtg) return 50_000;
|
||||
return 1_400;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPower() {
|
||||
return power;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPower(long i) {
|
||||
power = i;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void provideExtraInfo(NBTTagCompound data) {
|
||||
data.setBoolean(CompatEnergyControl.B_ACTIVE, true);
|
||||
data.setDouble(CompatEnergyControl.D_OUTPUT_HE, this.getOutput());
|
||||
}
|
||||
}
|
||||
@ -270,7 +270,8 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IC
|
||||
// function of SHS produced per tick
|
||||
// (heat - 10256)/100000 * steamFill (max efficiency at 14b) * 25 * 5 (should get rid of any rounding errors)
|
||||
if(this.heat > 10256) {
|
||||
int cycle = (int)((((float)heat - 10256F) / (float)maxHeat) * Math.min(((float)carbonDioxide.getFill() / 14000F), 1F) * 25F * 5F);
|
||||
float mult = 7.5F; // was 5 originally
|
||||
int cycle = (int)((((float)heat - 10256F) / (float)maxHeat) * Math.min(((float)carbonDioxide.getFill() / 14000F), 1F) * 25F * mult);
|
||||
this.output = cycle;
|
||||
|
||||
water.setFill(water.getFill() - cycle);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package com.hbm.tileentity.network.pneumatic;
|
||||
|
||||
import com.hbm.inventory.container.ContainerPneumoStorageAccessMK2;
|
||||
import com.hbm.inventory.container.ContainerPneumoStorageAccess;
|
||||
import com.hbm.inventory.gui.GUIPneumoStorageAccess;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
@ -75,6 +75,6 @@ public class TileEntityPneumoStorageAccess extends TileEntityLoadedBase implemen
|
||||
return dir == selfdir.getOpposite();
|
||||
}
|
||||
|
||||
@Override public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { return new ContainerPneumoStorageAccessMK2(player.inventory, this); }
|
||||
@Override public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { return new ContainerPneumoStorageAccess(player.inventory, this); }
|
||||
@Override public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { return new GUIPneumoStorageAccess(player.inventory, this); }
|
||||
}
|
||||
|
||||
@ -2016,13 +2016,7 @@ item.battery_sc.pu238.name=Plutonium-238 Self-Charging Battery
|
||||
item.battery_sc.ra226.name=Radium-226 Self-Charging Battery
|
||||
item.battery_sc.tc99.name=Technetium-99 Self-Charging Battery
|
||||
item.battery_sc.waste.name=Spent Fuel Self-Charging Battery
|
||||
item.battery_sc_americium.name=Self-Charging Americium-241 Battery (LEGACY)
|
||||
item.battery_sc_gold.name=Self-Charging Gold-198 Battery (LEGACY)
|
||||
item.battery_sc_lead.name=Self-Charging Lead-209 Battery (LEGACY)
|
||||
item.battery_sc_plutonium.name=Self-Charging Plutonium-238 Battery (LEGACY)
|
||||
item.battery_sc_polonium.name=Self-Charging Polonium-210 Battery (LEGACY)
|
||||
item.battery_sc_technetium.name=Self-Charging Technetium-99 Battery (LEGACY)
|
||||
item.battery_sc_uranium.name=Self-Charging Uranium-238 Battery (LEGACY)
|
||||
item.battery_sc.desc=Radiovoltaic devices are not suitable for$battery sockets! Power output may$be unreliable, and hazardous arcing$may occur!
|
||||
item.battery_schrabidium.name=Schrabidium Battery (LEGACY)
|
||||
item.battery_schrabidium_cell.name=Schrabidium Power Cell (LEGACY)
|
||||
item.battery_schrabidium_cell_2.name=Double Schrabidium Power Cell (LEGACY)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user