mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
load of crap that doesn't work
This commit is contained in:
parent
55b4fec00b
commit
39aa0de008
@ -1,11 +1,15 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.handler.MultiblockHandlerXR;
|
||||
import com.hbm.tileentity.TileEntityProxyCombo;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineAnnihilator;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class MachineAnnihilator extends BlockDummyable {
|
||||
|
||||
@ -16,16 +20,36 @@ public class MachineAnnihilator extends BlockDummyable {
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
if(meta >= 12) return new TileEntityMachineAnnihilator();
|
||||
if(meta >= 6) return new TileEntityProxyCombo().inventory().fluid();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
return standardOpenBehavior(world, x, y, z, player, side);
|
||||
}
|
||||
|
||||
@Override public int[] getDimensions() { return new int[] {2, 0, 4, 4, 1, 1}; }
|
||||
@Override public int getOffset() { return 4; }
|
||||
|
||||
@Override
|
||||
public int[] getDimensions() {
|
||||
return new int[] {0, 0, 0, 0, 0, 0};
|
||||
protected boolean checkRequirement(World world, int x, int y, int z, ForgeDirection dir, int o) {
|
||||
return super.checkRequirement(world, x, y, z, dir, o) &&
|
||||
MultiblockHandlerXR.checkSpace(world, x + dir.offsetX * (o - 3), y, z + dir.offsetZ * (o - 3), new int[] {8, -2, 1, 1, 1, 1}, x, y, z, dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOffset() {
|
||||
return 0;
|
||||
public void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) {
|
||||
super.fillSpace(world, x, y, z, dir, o);
|
||||
MultiblockHandlerXR.fillSpace(world, x + dir.offsetX * (o - 3), y, z + dir.offsetZ * (o - 3), new int[] {8, -2, 1, 1, 1, 1}, this, dir);
|
||||
|
||||
x += dir.offsetX * o;
|
||||
z += dir.offsetZ * o;
|
||||
|
||||
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
||||
|
||||
this.makeExtra(world, x + dir.offsetX * 3 + rot.offsetX, y, z + dir.offsetZ * 3 + rot.offsetZ);
|
||||
this.makeExtra(world, x + dir.offsetX * 3 - rot.offsetX, y, z + dir.offsetZ * 3 - rot.offsetZ);
|
||||
this.makeExtra(world, x + dir.offsetX * 4, y, z + dir.offsetZ * 4);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,63 @@
|
||||
package com.hbm.inventory.container;
|
||||
|
||||
import com.hbm.inventory.SlotCraftingOutput;
|
||||
import com.hbm.inventory.SlotNonRetarded;
|
||||
import com.hbm.items.machine.IItemFluidIdentifier;
|
||||
import com.hbm.util.InventoryUtil;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerMachineAnnihilator extends ContainerBase {
|
||||
|
||||
public ContainerMachineAnnihilator(InventoryPlayer invPlayer, IInventory annihilator) {
|
||||
super(invPlayer, annihilator);
|
||||
|
||||
// Input
|
||||
this.addSlotToContainer(new SlotNonRetarded(annihilator, 0, 17, 45));
|
||||
// Fluid ID
|
||||
this.addSlotToContainer(new SlotNonRetarded(annihilator, 1, 35, 45));
|
||||
// Output
|
||||
this.addOutputSlots(invPlayer.player, annihilator, 2, 80, 36, 2, 3);
|
||||
|
||||
this.playerInv(invPlayer, 8, 126);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
|
||||
ItemStack slotOriginal = null;
|
||||
Slot slot = (Slot) this.inventorySlots.get(index);
|
||||
|
||||
if(slot != null && slot.getHasStack()) {
|
||||
ItemStack slotStack = slot.getStack();
|
||||
slotOriginal = slotStack.copy();
|
||||
|
||||
if(index <= tile.getSizeInventory() - 1) {
|
||||
SlotCraftingOutput.checkAchievements(player, slotStack);
|
||||
if(!this.mergeItemStack(slotStack, tile.getSizeInventory(), this.inventorySlots.size(), true)) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
|
||||
if(slotOriginal.getItem() instanceof IItemFluidIdentifier) {
|
||||
if(!this.mergeItemStack(slotStack, 0, 1, false)) return null;
|
||||
} else {
|
||||
if(!InventoryUtil.mergeItemStack(this.inventorySlots, slotStack, 1, 2, false)) return null;
|
||||
}
|
||||
}
|
||||
|
||||
if(slotStack.stackSize == 0) {
|
||||
slot.putStack(null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
slot.onPickupFromSlot(player, slotStack);
|
||||
}
|
||||
|
||||
return slotOriginal;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package com.hbm.inventory.gui;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.inventory.container.ContainerMachineAnnihilator;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineAnnihilator;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GUIMachineAnnihilator extends GuiInfoContainer {
|
||||
|
||||
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/processing/gui_annihilator.png");
|
||||
private TileEntityMachineAnnihilator assembler;
|
||||
|
||||
public GUIMachineAnnihilator(InventoryPlayer invPlayer, TileEntityMachineAnnihilator tedf) {
|
||||
super(new ContainerMachineAnnihilator(invPlayer, tedf));
|
||||
assembler = tedf;
|
||||
|
||||
this.xSize = 176;
|
||||
this.ySize = 208;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int i, int j) {
|
||||
String name = this.assembler.hasCustomInventoryName() ? this.assembler.getInventoryName() : I18n.format(this.assembler.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 interp, int x, int y) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
}
|
||||
}
|
||||
@ -265,6 +265,7 @@ public class ClientProxy extends ServerProxy {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityChimneyBrick.class, new RenderChimneyBrick());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityChimneyIndustrial.class, new RenderChimneyIndustrial());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineMiningLaser.class, new RenderLaserMiner());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineAnnihilator.class, new RenderAnnihilator());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineAssembler.class, new RenderAssembler());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineAssemblyMachine.class, new RenderAssemblyMachine());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineAssemfac.class, new RenderAssemfac());
|
||||
|
||||
@ -134,6 +134,9 @@ public class ResourceManager {
|
||||
public static final IModelCustom epress_head = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/epress_head.obj"));
|
||||
public static final IModelCustom conveyor_press = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/machines/conveyor_press.obj"));
|
||||
public static final IModelCustom ammo_press = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/machines/ammo_press.obj")).asVBO();
|
||||
|
||||
//Annihilator
|
||||
public static final IModelCustom annihilator = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/machines/annihilator.obj")).asVBO();
|
||||
|
||||
//Assembler
|
||||
public static final IModelCustom assembler_body = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/assembler_new_body.obj"));
|
||||
@ -576,6 +579,10 @@ public class ResourceManager {
|
||||
public static final ResourceLocation conveyor_press_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/conveyor_press.png");
|
||||
public static final ResourceLocation conveyor_press_belt_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/conveyor_press_belt.png");
|
||||
public static final ResourceLocation ammo_press_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/ammo_press.png");
|
||||
|
||||
//Annihilator
|
||||
public static final ResourceLocation annihilator_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/annihilator.png");
|
||||
public static final ResourceLocation annihilator_belt_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/annihilator_belt.png");
|
||||
|
||||
//Assembler
|
||||
public static final ResourceLocation assembler_body_tex = new ResourceLocation(RefStrings.MODID, "textures/models/assembler_base_new.png");
|
||||
|
||||
@ -0,0 +1,79 @@
|
||||
package com.hbm.render.tileentity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.main.ResourceManager;
|
||||
import com.hbm.render.item.ItemRenderBase;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
public class RenderAnnihilator extends TileEntitySpecialRenderer implements IItemRendererProvider {
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float interp) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y, z + 0.5);
|
||||
GL11.glRotated(90, 0, 1, 0);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
|
||||
switch(tileEntity.getBlockMetadata() - BlockDummyable.offset) {
|
||||
case 2: GL11.glRotatef(0, 0F, 1F, 0F); break;
|
||||
case 4: GL11.glRotatef(90, 0F, 1F, 0F); break;
|
||||
case 3: GL11.glRotatef(180, 0F, 1F, 0F); break;
|
||||
case 5: GL11.glRotatef(270, 0F, 1F, 0F); break;
|
||||
}
|
||||
|
||||
bindTexture(ResourceManager.annihilator_tex);
|
||||
ResourceManager.annihilator.renderPart("Annihilator");
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(0, 1.75, 0);
|
||||
GL11.glRotated(System.currentTimeMillis() * 0.15 % 360, 0, 0, -1);
|
||||
GL11.glTranslated(0, -1.75, 0);
|
||||
ResourceManager.annihilator.renderPart("Roller");
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glMatrixMode(GL11.GL_TEXTURE);
|
||||
GL11.glLoadIdentity();
|
||||
bindTexture(ResourceManager.annihilator_belt_tex);
|
||||
GL11.glTranslated(-System.currentTimeMillis() / 3000D % 1D, 0, 0);
|
||||
ResourceManager.annihilator.renderPart("Belt");
|
||||
GL11.glMatrixMode(GL11.GL_TEXTURE);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemForRenderer() {
|
||||
return Item.getItemFromBlock(ModBlocks.machine_annihilator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemRenderer getRenderer() {
|
||||
|
||||
return new ItemRenderBase() {
|
||||
|
||||
public void renderInventory() {
|
||||
GL11.glTranslated(0, -3, 0);
|
||||
GL11.glScaled(2.75, 2.75, 2.75);
|
||||
}
|
||||
public void renderCommonWithStack(ItemStack item) {
|
||||
GL11.glScaled(0.5, 0.5, 0.5);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
bindTexture(ResourceManager.annihilator_tex);
|
||||
ResourceManager.annihilator.renderPart("Annihilator");
|
||||
ResourceManager.annihilator.renderPart("Roller");
|
||||
bindTexture(ResourceManager.annihilator_belt_tex);
|
||||
ResourceManager.annihilator.renderPart("Belt");
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
}};
|
||||
}
|
||||
}
|
||||
@ -6,20 +6,20 @@ import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.util.ItemStackUtil;
|
||||
import com.hbm.interfaces.NotableComments;
|
||||
import com.hbm.inventory.RecipesCommon.ComparableStack;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagByte;
|
||||
import net.minecraft.nbt.NBTTagByteArray;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagShort;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldSavedData;
|
||||
|
||||
@NotableComments
|
||||
public class AnnihilatorSavedData extends WorldSavedData {
|
||||
|
||||
public static final String KEY = "annihilator";
|
||||
@ -35,29 +35,61 @@ public class AnnihilatorSavedData extends WorldSavedData {
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
NBTTagList pools = nbt.getTagList("pools", 10);
|
||||
|
||||
//NBTTagList list = nbt.getTagList(p_150295_1_, p_150295_2_)
|
||||
for(int i = 0; i < pools.tagCount(); i++) {
|
||||
NBTTagCompound poolCompound = pools.getCompoundTagAt(i);
|
||||
|
||||
String poolName = poolCompound.getString("poolname");
|
||||
AnnihilatorPool pool = new AnnihilatorPool();
|
||||
pool.deserialize(poolCompound.getTagList("pool", 7));
|
||||
|
||||
this.pools.put(poolName, pool);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* woah nelly!
|
||||
*
|
||||
* ROOT NBT
|
||||
* \
|
||||
* POOLS LIST(COMPOUND) - all pools
|
||||
* \
|
||||
* POOL COMPOUND - pool + name association
|
||||
* \
|
||||
* POOLNAME STRING
|
||||
* POOL LIST(LIST) - all item entries in a pool
|
||||
* \
|
||||
* PER-ITEM LIST(BYTEARRAY) - all data associated with one item
|
||||
* \
|
||||
* KEY ID
|
||||
* KEY BYTES
|
||||
* POOL SIZE BYTES
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
for(Entry<String, AnnihilatorPool> entry : pools.entrySet()) {
|
||||
list.appendTag(new NBTTagString(entry.getKey()));
|
||||
NBTTagList pools = new NBTTagList();
|
||||
|
||||
for(Entry<String, AnnihilatorPool> entry : this.pools.entrySet()) {
|
||||
NBTTagCompound pool = new NBTTagCompound();
|
||||
NBTTagList poolList = new NBTTagList();
|
||||
|
||||
entry.getValue().serialize(poolList);
|
||||
list.appendTag(poolList);
|
||||
pool.setString("poolname", entry.getKey());
|
||||
pool.setTag("pool", poolList);
|
||||
pools.appendTag(pool);
|
||||
}
|
||||
|
||||
nbt.setTag("list", list);
|
||||
nbt.setTag("pools", pools);
|
||||
}
|
||||
|
||||
public static AnnihilatorSavedData getData(World worldObj) {
|
||||
AnnihilatorSavedData data = (AnnihilatorSavedData) worldObj.perWorldStorage.loadData(AnnihilatorSavedData.class, KEY);
|
||||
if(data == null) {
|
||||
data = new AnnihilatorSavedData();
|
||||
worldObj.perWorldStorage.setData(KEY, data);
|
||||
worldObj.perWorldStorage.setData(KEY, new AnnihilatorSavedData());
|
||||
data = (AnnihilatorSavedData) worldObj.perWorldStorage.loadData(AnnihilatorSavedData.class, KEY);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
@ -86,7 +118,7 @@ public class AnnihilatorSavedData extends WorldSavedData {
|
||||
poolInstance.increment(new ComparableStack(stack).makeSingular(), stack.stackSize);
|
||||
|
||||
List<String> oreDict = ItemStackUtil.getOreDictNames(stack);
|
||||
for(String name : oreDict) poolInstance.increment(name, stack.stackSize);
|
||||
for(String name : oreDict) if(name != null && !name.isEmpty()) poolInstance.increment(name, stack.stackSize); // because some assholes pollute the ore dict with crap values
|
||||
|
||||
// originally a lookup for fluid containers was considered, but no one would use the annihilator like that, and it adds unnecessary overhead
|
||||
|
||||
@ -112,7 +144,7 @@ public class AnnihilatorSavedData extends WorldSavedData {
|
||||
if(counter == null) {
|
||||
counter = BigInteger.valueOf(amount);
|
||||
} else {
|
||||
counter.add(BigInteger.valueOf(amount));
|
||||
counter = counter.add(BigInteger.valueOf(amount));
|
||||
}
|
||||
items.put(type, counter);
|
||||
}
|
||||
@ -126,40 +158,87 @@ public class AnnihilatorSavedData extends WorldSavedData {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* this absolutely will not work because it was written under the assumption that NBTTagList can support arbitrary NBTTagBase
|
||||
* even though an NBTTagList can only hold tags of a single type. this fucking sucks and implementing it better would have
|
||||
* been easy, but we work with what we are given.
|
||||
*
|
||||
* alternative: keep the lists, but change all types to NBTTagByteArray since we can effectively reduce all other data
|
||||
* types down into byte arrays anyway. if we can avoid NBTTagCompounds, we will. so much named tag crap we don't need just
|
||||
* bloats the file size.
|
||||
*/
|
||||
public void deserialize(NBTTagList nbt) {
|
||||
try {
|
||||
for(int i = 0; i < nbt.tagCount(); i++) {
|
||||
NBTTagList list = (NBTTagList) nbt.tagList.get(i);
|
||||
Object key = deserializeKey(list);
|
||||
NBTTagByteArray ntba = (NBTTagByteArray) list.tagList.get(list.tagList.size() - 1);
|
||||
if(key != null) this.items.put(key, new BigInteger(ntba.func_150292_c()));
|
||||
}
|
||||
} catch(Throwable ex) { } // because world data can be dented to all fucking hell and back
|
||||
}
|
||||
|
||||
/** So we want to avoid NBTTagCompounds because the keys are basically useless here and Strings are heavy as shit.
|
||||
* So what do? Shrimple, we use NBTTagLists. However, Mojang never expected lists to use different types, even though
|
||||
* implementing a list like that would be really easy, so we just break down absolutely all information we have into
|
||||
* byte arrays because the NBTTagList can handle those. God I hate this. */
|
||||
public void serializeKey(NBTTagList list, Object key) {
|
||||
if(key instanceof Item) { // 0
|
||||
Item item = (Item) key;
|
||||
list.appendTag(new NBTTagByte((byte) 0));
|
||||
list.appendTag(new NBTTagString(Item.itemRegistry.getNameForObject(item)));
|
||||
list.appendTag(new NBTTagByteArray(new byte[] {0}));
|
||||
list.appendTag(new NBTTagByteArray(Item.itemRegistry.getNameForObject(item).getBytes()));
|
||||
}
|
||||
|
||||
if(key instanceof ComparableStack) { // 1
|
||||
ComparableStack item = (ComparableStack) key;
|
||||
list.appendTag(new NBTTagByte((byte) 1));
|
||||
list.appendTag(new NBTTagString(Item.itemRegistry.getNameForObject(item.item)));
|
||||
list.appendTag(new NBTTagShort((short) item.meta));
|
||||
list.appendTag(new NBTTagByteArray(new byte[] {1}));
|
||||
list.appendTag(new NBTTagByteArray(Item.itemRegistry.getNameForObject(item.item).getBytes()));
|
||||
short meta = (short) item.meta;
|
||||
list.appendTag(new NBTTagByteArray(new byte[] {
|
||||
(byte) ((meta & 0xFF00) << 8),
|
||||
(byte) (meta & 0x00FF)
|
||||
})); // HSB and LSB may not be split "fairly" due to sign bit, but we do not care, we just want to store bits
|
||||
}
|
||||
|
||||
if(key instanceof FluidType) { // 2
|
||||
FluidType item = (FluidType) key;
|
||||
list.appendTag(new NBTTagByte((byte) 2));
|
||||
list.appendTag(new NBTTagString(item.getUnlocalizedName()));
|
||||
list.appendTag(new NBTTagByteArray(new byte[] {2}));
|
||||
list.appendTag(new NBTTagByteArray(item.getUnlocalizedName().getBytes()));
|
||||
}
|
||||
|
||||
if(key instanceof String) { // 3
|
||||
String item = (String) key;
|
||||
list.appendTag(new NBTTagByte((byte)3));
|
||||
list.appendTag(new NBTTagString(item));
|
||||
list.appendTag(new NBTTagByteArray(new byte[] {3}));
|
||||
list.appendTag(new NBTTagByteArray(item.getBytes()));
|
||||
}
|
||||
}
|
||||
|
||||
public Object deserializeKey(NBTTagList list) {
|
||||
try {
|
||||
int size = list.tagCount();
|
||||
if(size <= 0) return null;
|
||||
byte key = ((NBTTagByteArray) list.tagList.get(0)).func_150292_c()[0]; // i am pissing myself from all these assumptions
|
||||
|
||||
if(key == 0) { // item
|
||||
byte[] bytes = ((NBTTagByteArray) list.tagList.get(1)).func_150292_c();
|
||||
Item item = (Item) Item.itemRegistry.getObject(new String(bytes)); // not specifying a charset is probably dangerous for multiple
|
||||
// reasons but given that i don't really think the charset should change serverside, i *think* this should work
|
||||
return item;
|
||||
}
|
||||
if(key == 1) { // comparablestack
|
||||
byte[] itembytes = ((NBTTagByteArray) list.tagList.get(1)).func_150292_c();
|
||||
byte[] metabytes = ((NBTTagByteArray) list.tagList.get(2)).func_150292_c();
|
||||
Item item = (Item) Item.itemRegistry.getObject(new String(itembytes));
|
||||
//short hsb = (short) (((short) metabytes[0]) << 8);
|
||||
//short lsb = (short) metabytes[1];
|
||||
short meta = (short) ((metabytes[0] << 8) | (metabytes[1] & 0xFF));
|
||||
return new ComparableStack(item, 1, meta);
|
||||
}
|
||||
if(key == 2) { // fluidtype
|
||||
byte[] bytes = ((NBTTagByteArray) list.tagList.get(1)).func_150292_c();
|
||||
FluidType type = Fluids.fromName(new String(bytes));
|
||||
return type;
|
||||
}
|
||||
if(key == 3) {
|
||||
byte[] bytes = ((NBTTagByteArray) list.tagList.get(1)).func_150292_c();
|
||||
String type = new String(bytes);
|
||||
return type;
|
||||
}
|
||||
// i feel filthy
|
||||
|
||||
} catch(Throwable ex) { }
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,34 @@
|
||||
package com.hbm.tileentity.machine;
|
||||
|
||||
import com.hbm.inventory.container.ContainerMachineAnnihilator;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.inventory.gui.GUIMachineAnnihilator;
|
||||
import com.hbm.items.machine.IItemFluidIdentifier;
|
||||
import com.hbm.saveddata.AnnihilatorSavedData;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
|
||||
public class TileEntityMachineAnnihilator extends TileEntityMachineBase {
|
||||
import api.hbm.fluidmk2.IFluidStandardReceiverMK2;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileEntityMachineAnnihilator extends TileEntityMachineBase implements IFluidStandardReceiverMK2, IGUIProvider {
|
||||
|
||||
public String pool = "Recycling";
|
||||
public int timer;
|
||||
|
||||
public FluidTank tank;
|
||||
|
||||
public TileEntityMachineAnnihilator() {
|
||||
super(8);
|
||||
super(11);
|
||||
|
||||
this.tank = new FluidTank(Fluids.NONE, 256_000);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -16,6 +39,55 @@ public class TileEntityMachineAnnihilator extends TileEntityMachineBase {
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
this.tank.setType(1, slots);
|
||||
|
||||
if(this.pool != null && !this.pool.isEmpty()) {
|
||||
|
||||
if(slots[0] != null) {
|
||||
AnnihilatorSavedData.getData(worldObj).pushToPool(pool, slots[0]);
|
||||
this.slots[0] = null;
|
||||
this.markChanged();
|
||||
}
|
||||
if(tank.getFill() > 0) {
|
||||
AnnihilatorSavedData.getData(worldObj).pushToPool(pool, tank.getTankType(), tank.getFill());
|
||||
tank.setFill(0);
|
||||
this.markChanged();
|
||||
}
|
||||
}
|
||||
|
||||
this.networkPackNT(25);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack) {
|
||||
if(slot == 0) return true; // trash
|
||||
if(slot == 1 && stack.getItem() instanceof IItemFluidIdentifier) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return new int[] {0};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
this.pool = nbt.getString("pool");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setString("pool", pool);
|
||||
}
|
||||
|
||||
@Override public FluidTank[] getAllTanks() { return new FluidTank[] {tank}; }
|
||||
@Override public FluidTank[] getReceivingTanks() { return new FluidTank[] {tank}; }
|
||||
|
||||
@Override public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { return new ContainerMachineAnnihilator(player.inventory, this); }
|
||||
@Override @SideOnly(Side.CLIENT) public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { return new GUIMachineAnnihilator(player.inventory, this); }
|
||||
}
|
||||
|
||||
1457
src/main/resources/assets/hbm/models/machines/annihilator.obj
Normal file
1457
src/main/resources/assets/hbm/models/machines/annihilator.obj
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 251 B |
Loading…
x
Reference in New Issue
Block a user