mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
tooltips for persistent containers
This commit is contained in:
parent
42c154fa6e
commit
739ac79a6a
12
src/main/java/com/hbm/blocks/IPersistentInfoProvider.java
Normal file
12
src/main/java/com/hbm/blocks/IPersistentInfoProvider.java
Normal file
@ -0,0 +1,12 @@
|
||||
package com.hbm.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public interface IPersistentInfoProvider {
|
||||
|
||||
public void addInformation(ItemStack stack, NBTTagCompound persistentTag, EntityPlayer player, List list, boolean ext);
|
||||
}
|
||||
@ -1,12 +1,17 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.IPersistentInfoProvider;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.IPersistentNBT;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityBarrel;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
@ -22,10 +27,11 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockFluidBarrel extends BlockContainer {
|
||||
public class BlockFluidBarrel extends BlockContainer implements IPersistentInfoProvider {
|
||||
|
||||
int capacity;
|
||||
|
||||
@ -156,4 +162,11 @@ public class BlockFluidBarrel extends BlockContainer {
|
||||
player.addStat(StatList.mineBlockStatArray[getIdFromBlock(this)], 1);
|
||||
player.addExhaustion(0.025F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, NBTTagCompound persistentTag, EntityPlayer player, List list, boolean ext) {
|
||||
FluidTank tank = new FluidTank(Fluids.NONE, 0, 0);
|
||||
tank.readFromNBT(persistentTag, "tank");
|
||||
list.add(EnumChatFormatting.YELLOW + "" + tank.getFill() + "/" + tank.getMaxFill() + "mB " + I18nUtil.resolveKey(tank.getTankType().getUnlocalizedName()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,10 +5,11 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ILookOverlay;
|
||||
import com.hbm.blocks.IPersistentInfoProvider;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.machine.TileEntityDiFurnace;
|
||||
import com.hbm.tileentity.IPersistentNBT;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityMachineBattery;
|
||||
import com.hbm.util.BobMathUtil;
|
||||
import com.hbm.util.I18nUtil;
|
||||
@ -26,13 +27,15 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||
|
||||
public class MachineBattery extends BlockContainer implements ILookOverlay {
|
||||
public class MachineBattery extends BlockContainer implements ILookOverlay, IPersistentInfoProvider {
|
||||
|
||||
private final Random field_149933_a = new Random();
|
||||
private static boolean keepInventory;
|
||||
@ -143,8 +146,10 @@ public class MachineBattery extends BlockContainer implements ILookOverlay {
|
||||
}
|
||||
|
||||
if(itemStack.hasDisplayName()) {
|
||||
((TileEntityDiFurnace) world.getTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName());
|
||||
((TileEntityMachineBattery) world.getTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName());
|
||||
}
|
||||
|
||||
IPersistentNBT.restoreData(world, x, y, z, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -249,4 +254,30 @@ public class MachineBattery extends BlockContainer implements ILookOverlay {
|
||||
TileEntityMachineBattery battery = (TileEntityMachineBattery) te;
|
||||
return battery.getComparatorPower();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
return IPersistentNBT.getDrops(world, x, y, z, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player) {
|
||||
|
||||
if(!player.capabilities.isCreativeMode) {
|
||||
harvesters.set(player);
|
||||
this.dropBlockAsItem(world, x, y, z, meta, 0);
|
||||
harvesters.set(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) {
|
||||
player.addStat(StatList.mineBlockStatArray[getIdFromBlock(this)], 1);
|
||||
player.addExhaustion(0.025F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, NBTTagCompound persistentTag, EntityPlayer player, List list, boolean ext) {
|
||||
list.add(EnumChatFormatting.YELLOW + "" + BobMathUtil.getShortNumber(persistentTag.getLong("power")) + "/" + BobMathUtil.getShortNumber(this.maxPower) + "HE");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,24 +1,31 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.blocks.IPersistentInfoProvider;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.handler.MultiblockHandlerXR;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.IPersistentNBT;
|
||||
import com.hbm.tileentity.TileEntityProxyCombo;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityMachineBAT9000;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class MachineBigAssTank9000 extends BlockDummyable {
|
||||
public class MachineBigAssTank9000 extends BlockDummyable implements IPersistentInfoProvider {
|
||||
|
||||
public MachineBigAssTank9000(Material mat) {
|
||||
super(mat);
|
||||
@ -91,4 +98,11 @@ public class MachineBigAssTank9000 extends BlockDummyable {
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
return IPersistentNBT.getDrops(world, x, y, z, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, NBTTagCompound persistentTag, EntityPlayer player, List list, boolean ext) {
|
||||
FluidTank tank = new FluidTank(Fluids.NONE, 0, 0);
|
||||
tank.readFromNBT(persistentTag, "tank");
|
||||
list.add(EnumChatFormatting.YELLOW + "" + tank.getFill() + "/" + tank.getMaxFill() + "mB " + I18nUtil.resolveKey(tank.getTankType().getUnlocalizedName()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,9 +5,9 @@ import java.util.List;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.blocks.ILookOverlay;
|
||||
import com.hbm.blocks.IPersistentInfoProvider;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.IPersistentNBT;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityMachineBattery;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityMachineFENSU;
|
||||
import com.hbm.util.BobMathUtil;
|
||||
@ -17,11 +17,13 @@ import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||
|
||||
public class MachineFENSU extends BlockDummyable implements ILookOverlay {
|
||||
public class MachineFENSU extends BlockDummyable implements ILookOverlay, IPersistentInfoProvider {
|
||||
|
||||
public MachineFENSU(Material mat) {
|
||||
super(mat);
|
||||
@ -93,4 +95,9 @@ public class MachineFENSU extends BlockDummyable implements ILookOverlay {
|
||||
|
||||
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, NBTTagCompound persistentTag, EntityPlayer player, List list, boolean ext) {
|
||||
list.add(EnumChatFormatting.YELLOW + "" + BobMathUtil.getShortNumber(persistentTag.getLong("power")) + "/" + BobMathUtil.getShortNumber(Long.MAX_VALUE) + "HE");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,15 +1,20 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.IPersistentInfoProvider;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.handler.MultiblockHandler;
|
||||
import com.hbm.interfaces.IMultiblock;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.IPersistentNBT;
|
||||
import com.hbm.tileentity.machine.TileEntityDummy;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityMachineFluidTank;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import net.minecraft.block.Block;
|
||||
@ -24,10 +29,11 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class MachineFluidTank extends BlockContainer implements IMultiblock {
|
||||
public class MachineFluidTank extends BlockContainer implements IMultiblock, IPersistentInfoProvider {
|
||||
|
||||
public MachineFluidTank(Material p_i45386_1_) {
|
||||
super(p_i45386_1_);
|
||||
@ -342,4 +348,11 @@ public class MachineFluidTank extends BlockContainer implements IMultiblock {
|
||||
player.addStat(StatList.mineBlockStatArray[getIdFromBlock(this)], 1);
|
||||
player.addExhaustion(0.025F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, NBTTagCompound persistentTag, EntityPlayer player, List list, boolean ext) {
|
||||
FluidTank tank = new FluidTank(Fluids.NONE, 0, 0);
|
||||
tank.readFromNBT(persistentTag, "tank");
|
||||
list.add(EnumChatFormatting.YELLOW + "" + tank.getFill() + "/" + tank.getMaxFill() + "mB " + I18nUtil.resolveKey(tank.getTankType().getUnlocalizedName()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ import com.hbm.items.machine.ItemBattery;
|
||||
import com.hbm.items.tool.ItemModMinecart;
|
||||
import com.hbm.items.tool.ItemModMinecart.EnumCartBase;
|
||||
import com.hbm.items.tool.ItemModMinecart.EnumMinecart;
|
||||
import com.hbm.items.tool.ItemToolAbilityFueled;
|
||||
import com.hbm.main.CraftingManager;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
@ -78,7 +79,7 @@ public class ToolRecipes {
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.mese_pickaxe, 1), new Object[] { " SD", "APS", "FA ", 'S', ModItems.blades_desh, 'D', ModItems.powder_dineutronium, 'A', ModItems.plate_paa, 'P', ModItems.chlorophyte_pickaxe, 'F', ModItems.shimmer_handle });
|
||||
|
||||
//Chainsaws
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.chainsaw, 1), new Object[] { " H", "BBP", " C", 'H', ModItems.hull_small_steel, 'B', ModItems.blades_steel, 'P', ModItems.piston_selenium, 'C', ModItems.canister_empty });
|
||||
CraftingManager.addRecipeAuto(ItemToolAbilityFueled.getEmptyTool(ModItems.chainsaw), new Object[] { "CCH", "BBP", "CCE", 'H', ModItems.hull_small_steel, 'B', ModItems.blades_steel, 'P', ModItems.piston_selenium, 'C', ModBlocks.chain, 'E', ModItems.canister_empty });
|
||||
|
||||
//Misc
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.euphemium_stopper, 1), new Object[] { "I", "S", "S", 'I', EUPH.ingot(), 'S', KEY_STICK });
|
||||
|
||||
@ -4,7 +4,9 @@ import java.util.List;
|
||||
|
||||
import com.hbm.blocks.BlockEnumMulti;
|
||||
import com.hbm.blocks.IBlockMulti;
|
||||
import com.hbm.blocks.IPersistentInfoProvider;
|
||||
import com.hbm.blocks.ITooltipProvider;
|
||||
import com.hbm.tileentity.IPersistentNBT;
|
||||
import com.hbm.util.EnumUtil;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@ -14,6 +16,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class ItemBlockBase extends ItemBlock {
|
||||
@ -48,10 +51,15 @@ public class ItemBlockBase extends ItemBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool) {
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) {
|
||||
|
||||
if(field_150939_a instanceof ITooltipProvider) {
|
||||
((ITooltipProvider) field_150939_a).addInformation(itemstack, player, list, bool);
|
||||
((ITooltipProvider) field_150939_a).addInformation(stack, player, list, bool);
|
||||
}
|
||||
|
||||
if(field_150939_a instanceof IPersistentInfoProvider && stack.hasTagCompound() && stack.getTagCompound().hasKey(IPersistentNBT.NBT_PERSISTENT_KEY)) {
|
||||
NBTTagCompound data = stack.getTagCompound().getCompoundTag(IPersistentNBT.NBT_PERSISTENT_KEY);
|
||||
((IPersistentInfoProvider) field_150939_a).addInformation(stack, data, player, list, bool);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ import api.hbm.fluid.IFillableItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
@ -113,4 +114,11 @@ public class ItemToolAbilityFueled extends ItemToolAbility implements IFillableI
|
||||
public int tryEmpty(FluidType type, int amount, ItemStack stack) {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public static ItemStack getEmptyTool(Item item) {
|
||||
ItemToolAbilityFueled tool = (ItemToolAbilityFueled) item;
|
||||
ItemStack stack = new ItemStack(item);
|
||||
tool.setFill(stack, 0);
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,15 +5,19 @@ import org.lwjgl.opengl.GL11;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.inventory.fluid.trait.FT_Corrosive;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.ResourceManager;
|
||||
import com.hbm.render.item.ItemRenderBase;
|
||||
import com.hbm.render.util.DiamondPronter;
|
||||
import com.hbm.tileentity.IPersistentNBT;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityMachineFluidTank;
|
||||
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
@ -37,12 +41,9 @@ public class RenderFluidTank extends TileEntitySpecialRenderer implements IItemR
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
bindTexture(ResourceManager.tank_tex);
|
||||
ResourceManager.fluidtank.renderPart("Frame");
|
||||
|
||||
String s = "NONE";
|
||||
if(tileEntity instanceof TileEntityMachineFluidTank)
|
||||
s = ((TileEntityMachineFluidTank) tileEntity).tank.getTankType().getName();
|
||||
|
||||
bindTexture(new ResourceLocation(RefStrings.MODID, "textures/models/tank/tank_" + s + ".png"));
|
||||
|
||||
TileEntityMachineFluidTank tank = (TileEntityMachineFluidTank) tileEntity;
|
||||
bindTexture(new ResourceLocation(RefStrings.MODID, getTextureFromType(tank.tank.getTankType())));
|
||||
ResourceManager.fluidtank.renderPart("Tank");
|
||||
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
@ -70,6 +71,15 @@ public class RenderFluidTank extends TileEntitySpecialRenderer implements IItemR
|
||||
GL11.glPopMatrix();
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
}
|
||||
|
||||
public String getTextureFromType(FluidType type) {
|
||||
String s = type.getName();
|
||||
|
||||
if(type.isAntimatter() || (type.hasTrait(FT_Corrosive.class) && type.getTrait(FT_Corrosive.class).isHighlyCorrosive()))
|
||||
s = "DANGER";
|
||||
|
||||
return "textures/models/tank/tank_" + s + ".png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemForRenderer() {
|
||||
@ -85,12 +95,19 @@ public class RenderFluidTank extends TileEntitySpecialRenderer implements IItemR
|
||||
GL11.glTranslated(0, -2, 0);
|
||||
GL11.glScaled(3.5, 3.5, 3.5);
|
||||
}
|
||||
public void renderCommon() {
|
||||
public void renderCommonWithStack(ItemStack item) {
|
||||
GL11.glRotated(90, 0, 1, 0);
|
||||
GL11.glScaled(0.75, 0.75, 0.75);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
bindTexture(ResourceManager.tank_tex); ResourceManager.fluidtank.renderPart("Frame");
|
||||
bindTexture(ResourceManager.tank_label_tex); ResourceManager.fluidtank.renderPart("Tank");
|
||||
|
||||
FluidTank tank = new FluidTank(Fluids.NONE, 0, 0);
|
||||
if(item.hasTagCompound() && item.getTagCompound().hasKey(IPersistentNBT.NBT_PERSISTENT_KEY)) {
|
||||
tank.readFromNBT(item.getTagCompound().getCompoundTag(IPersistentNBT.NBT_PERSISTENT_KEY), "tank");
|
||||
}
|
||||
|
||||
bindTexture(new ResourceLocation(RefStrings.MODID, getTextureFromType(tank.getTankType())));
|
||||
ResourceManager.fluidtank.renderPart("Tank");
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
}};
|
||||
}
|
||||
|
||||
@ -9,6 +9,8 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IPersistentNBT {
|
||||
|
||||
public static final String NBT_PERSISTENT_KEY = "persistent";
|
||||
|
||||
public void writeNBT(NBTTagCompound nbt);
|
||||
public void readNBT(NBTTagCompound nbt);
|
||||
@ -33,8 +35,12 @@ public interface IPersistentNBT {
|
||||
}
|
||||
|
||||
public static void restoreData(World world, int x, int y, int z, ItemStack stack) {
|
||||
if(!stack.hasTagCompound()) return;
|
||||
IPersistentNBT tile = (IPersistentNBT) world.getTileEntity(x, y, z);
|
||||
tile.readNBT(stack.stackTagCompound);
|
||||
try {
|
||||
if(!stack.hasTagCompound()) return;
|
||||
IPersistentNBT tile = (IPersistentNBT) world.getTileEntity(x, y, z);
|
||||
tile.readNBT(stack.stackTagCompound);
|
||||
} catch(Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -402,11 +402,6 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
|
||||
for(int z = -range; z <= range; z++) {
|
||||
|
||||
if(worldObj.getBlock(x + xCoord, targetY, z + zCoord).getMaterial().isLiquid()) {
|
||||
/*targetX = x + xCoord;
|
||||
targetZ = z + zCoord;
|
||||
worldObj.func_147480_a(x + xCoord, targetY, z + zCoord, false);
|
||||
beam = true;*/
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@ -226,13 +226,13 @@ public class TileEntityBarrel extends TileEntityMachineBase implements IFluidAcc
|
||||
public void writeNBT(NBTTagCompound nbt) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
this.tank.writeToNBT(data, "tank");
|
||||
data.getShort("mode");
|
||||
nbt.setTag("persistent", data);
|
||||
data.setShort("mode", mode);
|
||||
nbt.setTag(NBT_PERSISTENT_KEY, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(NBTTagCompound nbt) {
|
||||
NBTTagCompound data = nbt.getCompoundTag("persistent");
|
||||
NBTTagCompound data = nbt.getCompoundTag(NBT_PERSISTENT_KEY);
|
||||
this.tank.readFromNBT(data, "tank");
|
||||
this.mode = data.getShort("nbt");
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package com.hbm.tileentity.machine.storage;
|
||||
|
||||
import com.hbm.blocks.machine.MachineBattery;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.tileentity.IPersistentNBT;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
@ -21,7 +22,7 @@ import li.cil.oc.api.machine.Context;
|
||||
import li.cil.oc.api.network.SimpleComponent;
|
||||
|
||||
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "opencomputers")})
|
||||
public class TileEntityMachineBattery extends TileEntityMachineBase implements IEnergyUser, SimpleComponent {
|
||||
public class TileEntityMachineBattery extends TileEntityMachineBase implements IEnergyUser, IPersistentNBT, SimpleComponent {
|
||||
|
||||
public long[] log = new long[20];
|
||||
public long power = 0;
|
||||
@ -326,4 +327,23 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I
|
||||
public Object[] getMaxEnergy(Context context, Arguments args) {
|
||||
return new Object[] {getMaxPower()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNBT(NBTTagCompound nbt) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setLong("power", power);
|
||||
data.setShort("redLow", redLow);
|
||||
data.setShort("redHigh", redHigh);
|
||||
data.setInteger("priority", this.priority.ordinal());
|
||||
nbt.setTag(NBT_PERSISTENT_KEY, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(NBTTagCompound nbt) {
|
||||
NBTTagCompound data = nbt.getCompoundTag(NBT_PERSISTENT_KEY);
|
||||
this.power = data.getLong("power");
|
||||
this.redLow = data.getShort("redLow");
|
||||
this.redHigh = data.getShort("redHigh");
|
||||
this.priority = ConnectionPriority.values()[data.getInteger("priority")];
|
||||
}
|
||||
}
|
||||
|
||||
@ -214,12 +214,12 @@ public class TileEntityMachineFluidTank extends TileEntityMachineBase implements
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
this.tank.writeToNBT(data, "tank");
|
||||
data.setShort("mode", mode);
|
||||
nbt.setTag("persistent", data);
|
||||
nbt.setTag(NBT_PERSISTENT_KEY, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(NBTTagCompound nbt) {
|
||||
NBTTagCompound data = nbt.getCompoundTag("persistent");
|
||||
NBTTagCompound data = nbt.getCompoundTag(NBT_PERSISTENT_KEY);
|
||||
this.tank.readFromNBT(data, "tank");
|
||||
this.mode = data.getShort("mode");
|
||||
}
|
||||
|
||||
@ -57,6 +57,7 @@ public class TileEntityTurretMaxwell extends TileEntityTurretBaseNT {
|
||||
ammoStacks.add(new ItemStack(ModItems.upgrade_overdrive_2));
|
||||
ammoStacks.add(new ItemStack(ModItems.upgrade_overdrive_3));
|
||||
ammoStacks.add(new ItemStack(ModItems.upgrade_5g));
|
||||
ammoStacks.add(new ItemStack(ModItems.upgrade_screm));
|
||||
|
||||
return ammoStacks;
|
||||
}
|
||||
@ -143,6 +144,7 @@ public class TileEntityTurretMaxwell extends TileEntityTurretBaseNT {
|
||||
this.blackLevel = 0;
|
||||
this.pinkLevel = 0;
|
||||
this._5g = false;
|
||||
this.screm = false;
|
||||
|
||||
for(int i = 1; i < 10; i++) {
|
||||
if(slots[i] != null) {
|
||||
@ -164,6 +166,7 @@ public class TileEntityTurretMaxwell extends TileEntityTurretBaseNT {
|
||||
if(item == ModItems.upgrade_overdrive_2) blackLevel += 2;
|
||||
if(item == ModItems.upgrade_overdrive_3) blackLevel += 3;
|
||||
if(item == ModItems.upgrade_5g) _5g = true;
|
||||
if(item == ModItems.upgrade_screm) screm = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -180,6 +183,7 @@ public class TileEntityTurretMaxwell extends TileEntityTurretBaseNT {
|
||||
int blackLevel;
|
||||
int pinkLevel;
|
||||
boolean _5g;
|
||||
boolean screm;
|
||||
|
||||
int checkDelay;
|
||||
|
||||
@ -206,7 +210,10 @@ public class TileEntityTurretMaxwell extends TileEntityTurretBaseNT {
|
||||
vdat.setInteger("ent", this.target.getEntityId());
|
||||
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(vdat, this.target.posX, this.target.posY + this.target.height * 0.5, this.target.posZ), new TargetPoint(this.target.dimension, this.target.posX, this.target.posY + this.target.height * 0.5, this.target.posZ, 150));
|
||||
|
||||
worldObj.playSoundEffect(this.target.posX, this.target.posY, this.target.posZ, "mob.zombie.woodbreak", 2.0F, 0.95F + worldObj.rand.nextFloat() * 0.2F);
|
||||
if(this.screm)
|
||||
worldObj.playSoundEffect(this.target.posX, this.target.posY, this.target.posZ, "hbm:block.screm", 20.0F, 1.0F);
|
||||
else
|
||||
worldObj.playSoundEffect(this.target.posX, this.target.posY, this.target.posZ, "mob.zombie.woodbreak", 2.0F, 0.95F + worldObj.rand.nextFloat() * 0.2F);
|
||||
}
|
||||
|
||||
this.power -= demand;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user