mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
mass storage
This commit is contained in:
parent
c27d9e152e
commit
c616a64500
@ -587,6 +587,7 @@ public class ModBlocks {
|
||||
public static Block crate_desh;
|
||||
public static Block crate_tungsten;
|
||||
public static Block safe;
|
||||
public static Block mass_storage;
|
||||
|
||||
public static Block nuke_gadget;
|
||||
public static final int guiID_nuke_gadget = 3;
|
||||
@ -2107,8 +2108,9 @@ public class ModBlocks {
|
||||
crate_iron = new BlockStorageCrate(Material.iron).setBlockName("crate_iron").setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
|
||||
crate_steel = new BlockStorageCrate(Material.iron).setBlockName("crate_steel").setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
|
||||
crate_desh = new BlockStorageCrate(Material.iron).setBlockName("crate_desh").setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
|
||||
crate_tungsten = new BlockStorageCrate(Material.iron).setBlockName("crate_tungsten").setStepSound(Block.soundTypeMetal).setHardness(7.5F).setResistance(60.0F).setCreativeTab(MainRegistry.machineTab);
|
||||
crate_tungsten = new BlockStorageCrate(Material.iron).setBlockName("crate_tungsten").setStepSound(Block.soundTypeMetal).setHardness(7.5F).setResistance(300.0F).setCreativeTab(MainRegistry.machineTab);
|
||||
safe = new BlockStorageCrate(Material.iron).setBlockName("safe").setStepSound(Block.soundTypeMetal).setHardness(7.5F).setResistance(10000.0F).setCreativeTab(MainRegistry.machineTab);
|
||||
mass_storage = new BlockMassStorage().setBlockName("mass_storage").setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
|
||||
|
||||
boxcar = new DecoBlock(Material.iron).setBlockName("boxcar").setStepSound(Block.soundTypeMetal).setHardness(10.0F).setResistance(10.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":boxcar");
|
||||
boat = new DecoBlock(Material.iron).setBlockName("boat").setStepSound(Block.soundTypeMetal).setHardness(10.0F).setResistance(10.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":boat");
|
||||
@ -2904,6 +2906,7 @@ public class ModBlocks {
|
||||
GameRegistry.registerBlock(crate_desh, crate_desh.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(crate_tungsten, crate_tungsten.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(safe, safe.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(mass_storage, mass_storage.getUnlocalizedName());
|
||||
|
||||
//Junk
|
||||
GameRegistry.registerBlock(boxcar, boxcar.getUnlocalizedName());
|
||||
|
||||
@ -66,6 +66,10 @@ public class BlockStorageCrate extends BlockContainer {
|
||||
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":safe_front");
|
||||
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":safe_side");
|
||||
}
|
||||
if(this == ModBlocks.mass_storage) {
|
||||
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_top");
|
||||
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_side");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
69
src/main/java/com/hbm/blocks/machine/BlockMassStorage.java
Normal file
69
src/main/java/com/hbm/blocks/machine/BlockMassStorage.java
Normal file
@ -0,0 +1,69 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.tool.ItemLock;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityMassStorage;
|
||||
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockMassStorage extends BlockContainer {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconTop;
|
||||
|
||||
public BlockMassStorage() {
|
||||
super(Material.iron);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_top");
|
||||
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_side");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
|
||||
if(this == ModBlocks.safe)
|
||||
return metadata == 0 && side == 3 ? this.iconTop : (side == metadata ? this.iconTop : this.blockIcon);
|
||||
|
||||
return side == 1 ? this.iconTop : (side == 0 ? this.iconTop : this.blockIcon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityMassStorage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
if(world.isRemote) {
|
||||
return true;
|
||||
} else if(player.getHeldItem() != null && (player.getHeldItem().getItem() instanceof ItemLock || player.getHeldItem().getItem() == ModItems.key_kit)) {
|
||||
return false;
|
||||
|
||||
} else if(!player.isSneaking()) {
|
||||
TileEntity entity = world.getTileEntity(x, y, z);
|
||||
if(entity instanceof TileEntityMassStorage && ((TileEntityMassStorage) entity).canAccess(player)) {
|
||||
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -20,13 +20,12 @@ import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityMinecartDestroyer extends EntityMinecartContainerBase {
|
||||
|
||||
public EntityMinecartDestroyer(World p_i1712_1_) {
|
||||
super(p_i1712_1_);
|
||||
public EntityMinecartDestroyer(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
public EntityMinecartDestroyer(World world, double x, double y, double z, EnumCartBase type) {
|
||||
|
||||
@ -33,7 +33,7 @@ public class GUIHandler implements IGuiHandler {
|
||||
if(entity instanceof TileEntityCrateSteel) { return new ContainerCrateSteel(player.inventory, (TileEntityCrateSteel) entity); }
|
||||
if(entity instanceof TileEntityCrateDesh) { return new ContainerCrateDesh(player.inventory, (TileEntityCrateDesh) entity); }
|
||||
if(entity instanceof TileEntityCrateTungsten) { return new ContainerCrateTungsten(player.inventory, (TileEntityCrateTungsten) entity); }
|
||||
if(entity instanceof TileEntitySafe) { return new ContainerSafe(player.inventory, (TileEntitySafe) entity); }
|
||||
if(entity instanceof TileEntityMassStorage) { return new ContainerMassStorage(player.inventory, (TileEntityMassStorage) entity); }
|
||||
|
||||
if(entity instanceof TileEntityMachineLiquefactor) { return new ContainerLiquefactor(player.inventory, (TileEntityMachineLiquefactor) entity); }
|
||||
if(entity instanceof TileEntityMachineSolidifier) { return new ContainerSolidifier(player.inventory, (TileEntityMachineSolidifier) entity); }
|
||||
@ -857,6 +857,7 @@ public class GUIHandler implements IGuiHandler {
|
||||
if(entity instanceof TileEntityCrateDesh) { return new GUICrateDesh(player.inventory, (TileEntityCrateDesh) entity); }
|
||||
if(entity instanceof TileEntityCrateTungsten) { return new GUICrateTungsten(player.inventory, (TileEntityCrateTungsten) entity); }
|
||||
if(entity instanceof TileEntitySafe) { return new GUISafe(player.inventory, (TileEntitySafe) entity); }
|
||||
if(entity instanceof TileEntityMassStorage) { return new GUIMassStorage(player.inventory, (TileEntityMassStorage) entity); }
|
||||
|
||||
if(entity instanceof TileEntityMachineLiquefactor) { return new GUILiquefactor(player.inventory, (TileEntityMachineLiquefactor) entity); }
|
||||
if(entity instanceof TileEntityMachineSolidifier) { return new GUISolidifier(player.inventory, (TileEntityMachineSolidifier) entity); }
|
||||
|
||||
@ -0,0 +1,105 @@
|
||||
package com.hbm.inventory.container;
|
||||
|
||||
import com.hbm.inventory.SlotMachineOutput;
|
||||
import com.hbm.inventory.SlotPattern;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityMassStorage;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerMassStorage extends Container {
|
||||
|
||||
private TileEntityMassStorage storage;
|
||||
|
||||
public ContainerMassStorage(InventoryPlayer invPlayer, TileEntityMassStorage te) {
|
||||
this.storage = te;
|
||||
|
||||
this.addSlotToContainer(new Slot(storage, 0, 61, 17));
|
||||
this.addSlotToContainer(new SlotPattern(storage, 1, 61, 53));
|
||||
this.addSlotToContainer(new SlotMachineOutput(storage, 2, 61, 89));
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
for(int j = 0; j < 9; j++) {
|
||||
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 139 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < 9; i++) {
|
||||
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 197));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int par2) {
|
||||
ItemStack var3 = null;
|
||||
Slot var4 = (Slot) this.inventorySlots.get(par2);
|
||||
|
||||
if(var4 != null && var4.getHasStack()) {
|
||||
ItemStack var5 = var4.getStack();
|
||||
var3 = var5.copy();
|
||||
|
||||
if(par2 == 0 || par2 == 2) {
|
||||
if(!this.mergeItemStack(var5, storage.getSizeInventory(), this.inventorySlots.size(), true)) {
|
||||
return null;
|
||||
}
|
||||
} else if(!this.mergeItemStack(var5, 0, 1, false)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(var5.stackSize == 0) {
|
||||
var4.putStack((ItemStack) null);
|
||||
} else {
|
||||
var4.onSlotChanged();
|
||||
}
|
||||
|
||||
var4.onPickupFromSlot(player, var5);
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick(int index, int button, int mode, EntityPlayer player) {
|
||||
|
||||
//L/R: 0
|
||||
//M3: 3
|
||||
//SHIFT: 1
|
||||
//DRAG: 5
|
||||
//System.out.println("Mode " + mode);
|
||||
//System.out.println("Slot " + index);
|
||||
|
||||
if(index != 1) {
|
||||
return super.slotClick(index, button, mode, player);
|
||||
}
|
||||
|
||||
Slot slot = this.getSlot(index);
|
||||
|
||||
ItemStack ret = null;
|
||||
ItemStack held = player.inventory.getItemStack();
|
||||
|
||||
if(slot.getHasStack())
|
||||
ret = slot.getStack().copy();
|
||||
|
||||
//Don't allow for a type change when the thing isn't empty
|
||||
if(storage.getStockpile() > 0)
|
||||
return ret;
|
||||
|
||||
slot.putStack(held != null ? held.copy() : null);
|
||||
|
||||
if(slot.getHasStack()) {
|
||||
slot.getStack().stackSize = 1;
|
||||
}
|
||||
|
||||
slot.onSlotChanged();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return storage.isUseableByPlayer(player);
|
||||
}
|
||||
}
|
||||
@ -30,7 +30,7 @@ public class GUICrateDesh extends GuiContainer {
|
||||
String name = this.crate.hasCustomInventoryName() ? this.crate.getInventoryName() : I18n.format(this.crate.getInventoryName());
|
||||
|
||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory"), 40, this.ySize - 96 + 3, 4210752);
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory"), 44, this.ySize - 96 + 3, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
84
src/main/java/com/hbm/inventory/gui/GUIMassStorage.java
Normal file
84
src/main/java/com/hbm/inventory/gui/GUIMassStorage.java
Normal file
@ -0,0 +1,84 @@
|
||||
package com.hbm.inventory.gui;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.inventory.container.ContainerMassStorage;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.packet.NBTControlPacket;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityMassStorage;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GUIMassStorage extends GuiInfoContainer {
|
||||
|
||||
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/storage/gui_mass_storage.png");
|
||||
private TileEntityMassStorage storage;
|
||||
|
||||
public GUIMassStorage(InventoryPlayer invPlayer, TileEntityMassStorage tile) {
|
||||
super(new ContainerMassStorage(invPlayer, tile));
|
||||
storage = tile;
|
||||
|
||||
this.xSize = 176;
|
||||
this.ySize = 221;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float f) {
|
||||
super.drawScreen(mouseX, mouseY, f);
|
||||
|
||||
String percent = (((int) (storage.getStockpile() * 1000D / (double) storage.getCapacity())) / 10D) + "%";
|
||||
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 96, guiTop + 16, 18, 90, mouseX, mouseY, new String[] { storage.getStockpile() + " / " + storage.getCapacity(), percent });
|
||||
|
||||
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 62, guiTop + 72, 14, 14, mouseX, mouseY, new String[] { "Click: Provide one", "Shift-click: Provide stack" });
|
||||
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 80, guiTop + 72, 14, 14, mouseX, mouseY, new String[] { "Toggle output" });
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int x, int y, int i) {
|
||||
super.mouseClicked(x, y, i);
|
||||
|
||||
if(guiLeft + 62 <= x && guiLeft + 62 + 14 > x && guiTop + 72 < y && guiTop + 72 + 14 >= y) {
|
||||
|
||||
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setBoolean("provide", Keyboard.isKeyDown(Keyboard.KEY_LSHIFT));
|
||||
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, storage.xCoord, storage.yCoord, storage.zCoord));
|
||||
}
|
||||
|
||||
if(guiLeft + 80 <= x && guiLeft + 80 + 14 > x && guiTop + 72 < y && guiTop + 72 + 14 >= y) {
|
||||
|
||||
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setBoolean("toggle", false);
|
||||
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, storage.xCoord, storage.yCoord, storage.zCoord));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int i, int j) {
|
||||
String name = this.storage.hasCustomInventoryName() ? this.storage.getInventoryName() : I18n.format(this.storage.getInventoryName());
|
||||
|
||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
int gauge = storage.getStockpile() * 88 / storage.getCapacity();
|
||||
drawTexturedModalRect(guiLeft + 97, guiTop + 105 - gauge, 176, 88 - gauge, 16, gauge);
|
||||
|
||||
if(storage.output)
|
||||
drawTexturedModalRect(guiLeft + 80, guiTop + 72, 192, 0, 14, 14);
|
||||
}
|
||||
}
|
||||
@ -1631,16 +1631,19 @@ public class ClientProxy extends ServerProxy {
|
||||
int gW = (int)(width / 0.25F);
|
||||
int gH = (int)(height / 0.25F);
|
||||
|
||||
int count = (int) (gW * 1.5 * gH);
|
||||
|
||||
if(data.hasKey("cDiv"))
|
||||
count = (int) Math.ceil(count / (double)data.getInteger("cDiv"));
|
||||
|
||||
boolean blowMeIntoTheGodDamnStratosphere = rand.nextInt(15) == 0;
|
||||
double mult = 1D;
|
||||
|
||||
if(blowMeIntoTheGodDamnStratosphere)
|
||||
mult *= 10;
|
||||
|
||||
for(int i = -(gW / 2); i <= gW; i++) {
|
||||
for(int j = 0; j <= gH; j++) {
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect(new ParticleGiblet(man, world, x, y, z, rand.nextGaussian() * 0.25 * mult, rand.nextDouble() * mult, rand.nextGaussian() * 0.25 * mult));
|
||||
}
|
||||
for(int i = 0; i < count; i++) {
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect(new ParticleGiblet(man, world, x, y, z, rand.nextGaussian() * 0.25 * mult, rand.nextDouble() * mult, rand.nextGaussian() * 0.25 * mult));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -266,6 +266,7 @@ public class CraftingManager {
|
||||
addRecipeAuto(new ItemStack(ModBlocks.machine_converter_rf_he, 1), new Object[] { "SSS", "BRC", "SSS", 'S', BE.ingot(), 'C', ModItems.coil_copper, 'R', ModItems.coil_copper_torus, 'B', REDSTONE.block() });
|
||||
addRecipeAuto(new ItemStack(ModBlocks.crate_iron, 1), new Object[] { "PPP", "I I", "III", 'P', IRON.plate(), 'I', IRON.ingot() });
|
||||
addRecipeAuto(new ItemStack(ModBlocks.crate_steel, 1), new Object[] { "PPP", "I I", "III", 'P', STEEL.plate(), 'I', STEEL.ingot() });
|
||||
addRecipeAuto(new ItemStack(ModBlocks.crate_desh, 1), new Object[] { " D ", "DSD", " D ", 'D', ModItems.plate_desh, 'S', ModBlocks.crate_steel });
|
||||
addRecipeAuto(new ItemStack(ModBlocks.crate_tungsten, 1), new Object[] { "BPB", "PCP", "BPB", 'B', W.block(), 'P', ModItems.board_copper, 'C', ModBlocks.crate_steel });
|
||||
addRecipeAuto(new ItemStack(ModBlocks.safe, 1), new Object[] { "LAL", "ACA", "LAL", 'L', PB.plate(), 'A', ALLOY.plate(), 'C', ModBlocks.crate_steel });
|
||||
addRecipeAuto(new ItemStack(ModBlocks.machine_waste_drum, 1), new Object[] { "LRL", "BRB", "LRL", 'L', PB.ingot(), 'B', Blocks.iron_bars, 'R', ModItems.rod_quad_empty });
|
||||
|
||||
@ -8,9 +8,7 @@ import com.hbm.blocks.generic.BlockLoot.TileEntityLoot;
|
||||
import com.hbm.blocks.generic.BlockMotherOfAllOres.TileEntityRandomOre;
|
||||
import com.hbm.blocks.network.CableDiode.TileEntityDiode;
|
||||
import com.hbm.interfaces.IFluidAcceptor;
|
||||
import com.hbm.interfaces.IFluidContainer;
|
||||
import com.hbm.interfaces.IFluidSource;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.bomb.*;
|
||||
import com.hbm.tileentity.conductor.*;
|
||||
import com.hbm.tileentity.deco.*;
|
||||
@ -96,6 +94,8 @@ public class TileMappings {
|
||||
put(TileEntityMachineTurbofan.class, "tileentity_machine_turbofan");
|
||||
put(TileEntityCrateIron.class, "tileentity_crate_iron");
|
||||
put(TileEntityCrateSteel.class, "tileentity_crate_steel");
|
||||
put(TileEntityCrateDesh.class, "tileentity_crate_desh");
|
||||
put(TileEntityMassStorage.class, "tileentity_mass_storage");
|
||||
put(TileEntityMachinePress.class, "tileentity_press");
|
||||
put(TileEntityAMSBase.class, "tileentity_ams_base");
|
||||
put(TileEntityAMSEmitter.class, "tileentity_ams_emitter");
|
||||
|
||||
@ -6,6 +6,7 @@ import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.inventory.RecipesCommon.AStack;
|
||||
import com.hbm.inventory.RecipesCommon.ComparableStack;
|
||||
import com.hbm.inventory.recipes.AssemblerRecipes;
|
||||
import com.hbm.inventory.UpgradeManager;
|
||||
import com.hbm.items.ModItems;
|
||||
@ -208,12 +209,18 @@ public class TileEntityMachineAssembler extends TileEntityMachineBase implements
|
||||
break;
|
||||
}
|
||||
|
||||
int rec = -1;
|
||||
if(AssemblerRecipes.getOutputFromTempate(slots[4]) != null) {
|
||||
ComparableStack comp = ItemAssemblyTemplate.readType(slots[4]);
|
||||
rec = AssemblerRecipes.recipeList.indexOf(comp);
|
||||
}
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setLong("power", power);
|
||||
data.setInteger("progress", progress);
|
||||
data.setInteger("maxProgress", maxProgress);
|
||||
data.setBoolean("isProgressing", isProgressing);
|
||||
data.setInteger("recipe", slots[4] != null ? AssemblerRecipes.recipeList.indexOf(AssemblerRecipes.getOutputFromTempate(slots[4])) : -1);
|
||||
data.setInteger("recipe", rec);
|
||||
this.networkPack(data, 150);
|
||||
} else {
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.lib.ModDamageSource;
|
||||
import com.hbm.packet.AuxElectricityPacket;
|
||||
import com.hbm.packet.AuxParticlePacketNT;
|
||||
import com.hbm.packet.LoopedSoundPacket;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.packet.TETurbofanPacket;
|
||||
@ -24,6 +25,7 @@ import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@ -322,6 +324,16 @@ public class TileEntityMachineTurbofan extends TileEntityLoadedBase implements I
|
||||
|
||||
for(Entity e : list) {
|
||||
e.attackEntityFrom(ModDamageSource.turbofan, 1000);
|
||||
|
||||
if(!e.isEntityAlive() && e instanceof EntityLivingBase) {
|
||||
NBTTagCompound vdat = new NBTTagCompound();
|
||||
vdat.setString("type", "giblets");
|
||||
vdat.setInteger("ent", e.getEntityId());
|
||||
vdat.setInteger("cDiv", 5);
|
||||
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(vdat, e.posX, e.posY + e.height * 0.5, e.posZ), new TargetPoint(e.dimension, e.posX, e.posY + e.height * 0.5, e.posZ, 150));
|
||||
|
||||
worldObj.playSoundEffect(e.posX, e.posY, e.posZ, "mob.zombie.woodbreak", 2.0F, 0.95F + worldObj.rand.nextFloat() * 0.2F);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(meta == 3) {
|
||||
@ -374,6 +386,16 @@ public class TileEntityMachineTurbofan extends TileEntityLoadedBase implements I
|
||||
|
||||
for(Entity e : list) {
|
||||
e.attackEntityFrom(ModDamageSource.turbofan, 1000);
|
||||
|
||||
if(!e.isEntityAlive() && e instanceof EntityLivingBase) {
|
||||
NBTTagCompound vdat = new NBTTagCompound();
|
||||
vdat.setString("type", "giblets");
|
||||
vdat.setInteger("ent", e.getEntityId());
|
||||
vdat.setInteger("cDiv", 5);
|
||||
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(vdat, e.posX, e.posY + e.height * 0.5, e.posZ), new TargetPoint(e.dimension, e.posX, e.posY + e.height * 0.5, e.posZ, 150));
|
||||
|
||||
worldObj.playSoundEffect(e.posX, e.posY, e.posZ, "mob.zombie.woodbreak", 2.0F, 0.95F + worldObj.rand.nextFloat() * 0.2F);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(meta == 4) {
|
||||
@ -426,6 +448,16 @@ public class TileEntityMachineTurbofan extends TileEntityLoadedBase implements I
|
||||
|
||||
for(Entity e : list) {
|
||||
e.attackEntityFrom(ModDamageSource.turbofan, 1000);
|
||||
|
||||
if(!e.isEntityAlive() && e instanceof EntityLivingBase) {
|
||||
NBTTagCompound vdat = new NBTTagCompound();
|
||||
vdat.setString("type", "giblets");
|
||||
vdat.setInteger("ent", e.getEntityId());
|
||||
vdat.setInteger("cDiv", 5);
|
||||
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(vdat, e.posX, e.posY + e.height * 0.5, e.posZ), new TargetPoint(e.dimension, e.posX, e.posY + e.height * 0.5, e.posZ, 150));
|
||||
|
||||
worldObj.playSoundEffect(e.posX, e.posY, e.posZ, "mob.zombie.woodbreak", 2.0F, 0.95F + worldObj.rand.nextFloat() * 0.2F);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(meta == 5) {
|
||||
@ -478,6 +510,16 @@ public class TileEntityMachineTurbofan extends TileEntityLoadedBase implements I
|
||||
|
||||
for(Entity e : list) {
|
||||
e.attackEntityFrom(ModDamageSource.turbofan, 1000);
|
||||
|
||||
if(!e.isEntityAlive() && e instanceof EntityLivingBase) {
|
||||
NBTTagCompound vdat = new NBTTagCompound();
|
||||
vdat.setString("type", "giblets");
|
||||
vdat.setInteger("ent", e.getEntityId());
|
||||
vdat.setInteger("cDiv", 5);
|
||||
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(vdat, e.posX, e.posY + e.height * 0.5, e.posZ), new TargetPoint(e.dimension, e.posX, e.posY + e.height * 0.5, e.posZ, 150));
|
||||
|
||||
worldObj.playSoundEffect(e.posX, e.posY, e.posZ, "mob.zombie.woodbreak", 2.0F, 0.95F + worldObj.rand.nextFloat() * 0.2F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,10 +13,6 @@ public abstract class TileEntityCrateBase extends TileEntityLockableBase impleme
|
||||
protected ItemStack slots[];
|
||||
public String customName;
|
||||
|
||||
public TileEntityCrateBase() {
|
||||
slots = new ItemStack[0];
|
||||
}
|
||||
|
||||
public TileEntityCrateBase(int count) {
|
||||
slots = new ItemStack[count];
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@ package com.hbm.tileentity.machine.storage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.interfaces.IFluidAcceptor;
|
||||
import com.hbm.interfaces.IFluidContainer;
|
||||
import com.hbm.interfaces.IFluidSource;
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
package com.hbm.tileentity.machine.storage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.interfaces.IFluidContainer;
|
||||
import com.hbm.inventory.FluidTank;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
package com.hbm.tileentity.machine.storage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.interfaces.IFluidContainer;
|
||||
import com.hbm.inventory.FluidTank;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
|
||||
@ -0,0 +1,141 @@
|
||||
package com.hbm.tileentity.machine.storage;
|
||||
|
||||
import com.hbm.interfaces.IControlReceiver;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.tileentity.INBTPacketReceiver;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
public class TileEntityMassStorage extends TileEntityCrateBase implements INBTPacketReceiver, IControlReceiver {
|
||||
|
||||
private int stack = 0;
|
||||
public boolean output = false;
|
||||
|
||||
public TileEntityMassStorage() {
|
||||
super(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "container.massStorage";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
if(slots[0] != null && slots[0].getItem() == ModItems.fluid_barrel_infinite) {
|
||||
this.stack = this.getCapacity();
|
||||
}
|
||||
|
||||
if(this.getType() == null)
|
||||
this.stack = 0;
|
||||
|
||||
if(getType() != null && getStockpile() < getCapacity() && slots[0] != null && slots[0].isItemEqual(getType()) && ItemStack.areItemStackTagsEqual(slots[0], getType())) {
|
||||
|
||||
int remaining = getCapacity() - getStockpile();
|
||||
int toRemove = Math.min(remaining, slots[0].stackSize);
|
||||
this.decrStackSize(0, toRemove);
|
||||
this.stack += toRemove;
|
||||
this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this);
|
||||
}
|
||||
|
||||
if(output) {
|
||||
|
||||
if(slots[2] != null && !(slots[2].isItemEqual(getType()) && ItemStack.areItemStackTagsEqual(slots[2], getType()))) {
|
||||
return;
|
||||
}
|
||||
|
||||
int amount = Math.min(getStockpile(), getType().getMaxStackSize());
|
||||
|
||||
if(slots[2] == null) {
|
||||
slots[2] = slots[1].copy();
|
||||
slots[2].stackSize = amount;
|
||||
this.stack -= amount;
|
||||
} else {
|
||||
amount = Math.min(amount, slots[2].getMaxStackSize() - slots[2].stackSize);
|
||||
slots[2].stackSize += amount;
|
||||
this.stack -= amount;
|
||||
}
|
||||
}
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setInteger("stack", getStockpile());
|
||||
data.setBoolean("output", output);
|
||||
INBTPacketReceiver.networkPack(this, data, 15);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void networkUnpack(NBTTagCompound nbt) {
|
||||
this.stack = nbt.getInteger("stack");
|
||||
this.output = nbt.getBoolean("output");
|
||||
}
|
||||
|
||||
public int getCapacity() {
|
||||
return 10_000;
|
||||
}
|
||||
|
||||
public ItemStack getType() {
|
||||
return slots[1] == null ? null : slots[1].copy();
|
||||
}
|
||||
|
||||
public int getStockpile() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(EntityPlayer player) {
|
||||
return Vec3.createVectorHelper(xCoord - player.posX, yCoord - player.posY, zCoord - player.posZ).lengthVector() < 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
this.stack = nbt.getInteger("stack");
|
||||
this.output = nbt.getBoolean("output");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("stack", stack);
|
||||
nbt.setBoolean("output", output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveControl(NBTTagCompound data) {
|
||||
if(data.hasKey("provide") && slots[1] != null) {
|
||||
|
||||
if(this.getStockpile() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int amount = data.getBoolean("provide") ? slots[1].getMaxStackSize() : 1;
|
||||
amount = Math.min(amount, getStockpile());
|
||||
|
||||
if(slots[2] != null && !(slots[2].isItemEqual(getType()) && ItemStack.areItemStackTagsEqual(slots[2], getType()))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(slots[2] == null) {
|
||||
slots[2] = slots[1].copy();
|
||||
slots[2].stackSize = amount;
|
||||
this.stack -= amount;
|
||||
} else {
|
||||
amount = Math.min(amount, slots[2].getMaxStackSize() - slots[2].stackSize);
|
||||
slots[2].stackSize += amount;
|
||||
this.stack -= amount;
|
||||
}
|
||||
}
|
||||
|
||||
if(data.hasKey("toggle")) {
|
||||
this.output = !output;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 300 B |
Binary file not shown.
|
After Width: | Height: | Size: 302 B |
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
Loading…
x
Reference in New Issue
Block a user