mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
battery fix, mass storage tiers
This commit is contained in:
parent
69cd33a3d2
commit
d011ada90d
@ -23,10 +23,6 @@ public abstract class BlockMulti extends BlockBase implements IBlockMulti {
|
||||
public int damageDropped(int meta) {
|
||||
return rectify(meta);
|
||||
}
|
||||
|
||||
protected int rectify(int meta) {
|
||||
return Math.abs(meta % getSubCount());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@ -3,4 +3,8 @@ package com.hbm.blocks;
|
||||
public interface IBlockMulti {
|
||||
|
||||
public int getSubCount();
|
||||
|
||||
public default int rectify(int meta) {
|
||||
return Math.abs(meta % getSubCount());
|
||||
}
|
||||
}
|
||||
|
||||
@ -2928,7 +2928,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());
|
||||
GameRegistry.registerBlock(mass_storage, ItemBlockBase.class, mass_storage.getUnlocalizedName());
|
||||
|
||||
//Junk
|
||||
GameRegistry.registerBlock(boxcar, boxcar.getUnlocalizedName());
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.blocks.IBlockMulti;
|
||||
import com.hbm.blocks.ILookOverlay;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.tool.ItemLock;
|
||||
import com.hbm.lib.RefStrings;
|
||||
@ -17,6 +20,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@ -27,11 +31,12 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||
|
||||
public class BlockMassStorage extends BlockContainer {
|
||||
public class BlockMassStorage extends BlockContainer implements IBlockMulti, ILookOverlay {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconTop;
|
||||
@SideOnly(Side.CLIENT) private IIcon[] iconTop;
|
||||
@SideOnly(Side.CLIENT) private IIcon[] iconSide;
|
||||
|
||||
public BlockMassStorage() {
|
||||
super(Material.iron);
|
||||
@ -40,23 +45,35 @@ public class BlockMassStorage extends BlockContainer {
|
||||
@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");
|
||||
this.iconTop = new IIcon[3];
|
||||
this.iconSide = new IIcon[3];
|
||||
|
||||
this.iconTop[0] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_top_iron");
|
||||
this.iconSide[0] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_side_iron");
|
||||
this.iconTop[1] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_top_desh");
|
||||
this.iconSide[1] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_side_desh");
|
||||
this.iconTop[2] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_top");
|
||||
this.iconSide[2] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_side");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
|
||||
for(int i = 0; i < getSubCount(); ++i) {
|
||||
list.add(new ItemStack(item, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
int meta = this.rectify(metadata);
|
||||
return side == 1 ? this.iconTop[meta] : (side == 0 ? this.iconTop[meta] : this.iconSide[meta]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityMassStorage();
|
||||
return new TileEntityMassStorage(meta == 0 ? 10_000 : meta == 1 ? 100_000 : 1_000_000);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -84,7 +101,7 @@ public class BlockMassStorage extends BlockContainer {
|
||||
|
||||
if(!player.capabilities.isCreativeMode && !world.isRemote && willHarvest) {
|
||||
|
||||
ItemStack drop = new ItemStack(this);
|
||||
ItemStack drop = new ItemStack(this, 1, world.getBlockMetadata(x, y, z));
|
||||
ISidedInventory inv = (ISidedInventory)world.getTileEntity(x, y, z);
|
||||
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
@ -211,4 +228,38 @@ public class BlockMassStorage extends BlockContainer {
|
||||
public Item getItemDropped(int i, Random rand, int j) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSubCount() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printHook(Pre event, World world, int x, int y, int z) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(!(te instanceof TileEntityMassStorage))
|
||||
return;
|
||||
|
||||
TileEntityMassStorage storage = (TileEntityMassStorage) te;
|
||||
|
||||
List<String> text = new ArrayList();
|
||||
String title = "Empty";
|
||||
boolean full = storage.type != null;
|
||||
|
||||
if(full) {
|
||||
|
||||
title = storage.type.getDisplayName();
|
||||
text.add(String.format("%,d", storage.getStockpile()) + " / " + String.format("%,d", storage.getCapacity()));
|
||||
|
||||
double percent = (double) storage.getStockpile() / (double) storage.getCapacity();
|
||||
int charge = (int) Math.floor(percent * 10_000D);
|
||||
int color = ((int) (0xFF - 0xFF * percent)) << 16 | ((int)(0xFF * percent) << 8);
|
||||
|
||||
text.add("&[" + color + "&]" + (charge / 100D) + "%");
|
||||
}
|
||||
|
||||
ILookOverlay.printGeneric(event, title, full ? 0xffff00 : 0x00ffff, full ? 0x404000 : 0x004040, text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,10 +57,6 @@ public class FluidDuctStandard extends FluidDuctBase implements IBlockMulti {
|
||||
public int damageDropped(int meta) {
|
||||
return rectify(meta);
|
||||
}
|
||||
|
||||
private int rectify(int meta) {
|
||||
return Math.abs(meta % 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
|
||||
@ -34,7 +34,8 @@ public class GUIMassStorage extends GuiInfoContainer {
|
||||
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 + 96, guiTop + 16, 18, 90, mouseX, mouseY, new String[]
|
||||
{ String.format("%,d", storage.getStockpile()) + " / " + String.format("%,d", 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" });
|
||||
|
||||
@ -276,7 +276,9 @@ public class CraftingManager {
|
||||
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.mass_storage, 1, 0), new Object[] { "ICI", "CLC", "ICI", 'I', TI.ingot(), 'C', ModBlocks.crate_steel, 'L', ModItems.circuit_red_copper });
|
||||
addRecipeAuto(new ItemStack(ModBlocks.mass_storage, 1, 0), new Object[] { "ICI", "CLC", "ICI", 'I', TI.ingot(), 'C', ModBlocks.crate_steel, 'L', ModItems.circuit_copper });
|
||||
addRecipeAuto(new ItemStack(ModBlocks.mass_storage, 1, 1), new Object[] { "PCP", "PMP", "PPP", 'P', DESH.ingot(), 'C', ModItems.circuit_red_copper, 'M', new ItemStack(ModBlocks.mass_storage, 1, 0) });
|
||||
addRecipeAuto(new ItemStack(ModBlocks.mass_storage, 1, 2), new Object[] { "PCP", "PMP", "PPP", 'P', TCALLOY.ingot(), 'C', ModItems.circuit_gold, 'M', new ItemStack(ModBlocks.mass_storage, 1, 1) });
|
||||
addRecipeAuto(new ItemStack(ModBlocks.machine_autocrafter, 1), new Object[] { "SCS", "MWM", "SCS", 'S', STEEL.plate(), 'C', ModItems.circuit_copper, 'M', ModItems.motor, 'W', Blocks.crafting_table });
|
||||
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 });
|
||||
addRecipeAuto(new ItemStack(ModBlocks.machine_press, 1), new Object[] { "IRI", "IPI", "IBI", 'I', IRON.ingot(), 'R', Blocks.furnace, 'B', IRON.block(), 'P', Blocks.piston });
|
||||
|
||||
@ -8,7 +8,6 @@ import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energy.IEnergyConductor;
|
||||
import api.hbm.energy.IEnergyConnector;
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
import api.hbm.energy.IEnergyConnector.ConnectionPriority;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@ -264,13 +263,14 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I
|
||||
@Override
|
||||
public long transferPower(long power) {
|
||||
|
||||
int mode =this.getRelevantMode();
|
||||
int mode = this.getRelevantMode();
|
||||
|
||||
if(mode == mode_output || mode == mode_none) {
|
||||
return power;
|
||||
}
|
||||
|
||||
this.power += power;
|
||||
this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this);
|
||||
|
||||
if(this.power > this.getMaxPower()) {
|
||||
|
||||
@ -285,7 +285,7 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I
|
||||
@Override
|
||||
public long getTransferWeight() {
|
||||
|
||||
int mode =this.getRelevantMode();
|
||||
int mode = this.getRelevantMode();
|
||||
|
||||
if(mode == mode_output || mode == mode_none) {
|
||||
return 0;
|
||||
|
||||
@ -4,6 +4,8 @@ import com.hbm.interfaces.IControlReceiver;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.tileentity.INBTPacketReceiver;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@ -13,10 +15,18 @@ public class TileEntityMassStorage extends TileEntityCrateBase implements INBTPa
|
||||
|
||||
private int stack = 0;
|
||||
public boolean output = false;
|
||||
private int capacity;
|
||||
|
||||
@SideOnly(Side.CLIENT) public ItemStack type;
|
||||
|
||||
public TileEntityMassStorage() {
|
||||
super(3);
|
||||
}
|
||||
|
||||
public TileEntityMassStorage(int capacity) {
|
||||
this();
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
@ -68,6 +78,7 @@ public class TileEntityMassStorage extends TileEntityCrateBase implements INBTPa
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setInteger("stack", getStockpile());
|
||||
data.setBoolean("output", output);
|
||||
if(slots[1] != null) slots[1].writeToNBT(data);
|
||||
INBTPacketReceiver.networkPack(this, data, 15);
|
||||
}
|
||||
}
|
||||
@ -76,10 +87,11 @@ public class TileEntityMassStorage extends TileEntityCrateBase implements INBTPa
|
||||
public void networkUnpack(NBTTagCompound nbt) {
|
||||
this.stack = nbt.getInteger("stack");
|
||||
this.output = nbt.getBoolean("output");
|
||||
this.type = ItemStack.loadItemStackFromNBT(nbt);
|
||||
}
|
||||
|
||||
public int getCapacity() {
|
||||
return 10_000;
|
||||
return capacity;
|
||||
}
|
||||
|
||||
public ItemStack getType() {
|
||||
@ -114,6 +126,11 @@ public class TileEntityMassStorage extends TileEntityCrateBase implements INBTPa
|
||||
super.readFromNBT(nbt);
|
||||
this.stack = nbt.getInteger("stack");
|
||||
this.output = nbt.getBoolean("output");
|
||||
this.capacity = nbt.getInteger("capacity");
|
||||
|
||||
if(this.capacity <= 0) {
|
||||
this.capacity = 10_000;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -121,6 +138,7 @@ public class TileEntityMassStorage extends TileEntityCrateBase implements INBTPa
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("stack", stack);
|
||||
nbt.setBoolean("output", output);
|
||||
nbt.setInteger("capacity", capacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user