From c6a9f233499f8d0eba9c7cfab0e604ba60314343 Mon Sep 17 00:00:00 2001 From: Robert S Date: Wed, 6 Aug 2014 12:50:58 -0400 Subject: [PATCH] More error corrections and scala conversions --- .../resonantinduction/archaic/Archaic.scala | 5 +- .../imprint => blocks}/ItemImprint.java | 20 +- .../imprint => blocks}/TileFilterable.java | 2 +- .../archaic/blocks/TileImprinter.java | 474 ++++++++++++++++++ .../engineering/TileEngineeringTable.java | 130 ++--- .../archaic/filter/BlockImprinter.java | 202 -------- .../archaic/filter/RenderImprinter.java | 26 - .../archaic/filter/TileFilter.java | 185 ------- .../archaic/filter/TileImprinter.java | 302 ----------- .../filter/imprint/BlockImprintable.java | 81 --- .../archaic/fluid/grate/TileGrate.scala | 6 +- .../archaic/fluid/tank/ItemBlockTank.java | 13 +- .../archaic/fluid/tank/TileTank.java | 36 +- .../core/render/RenderImprintable.java | 4 +- .../logistic/belt/TileDetector.java | 2 +- .../logistic/belt/TileRejector.java | 2 +- 16 files changed, 582 insertions(+), 908 deletions(-) rename src/main/scala/resonantinduction/archaic/{filter/imprint => blocks}/ItemImprint.java (86%) rename src/main/scala/resonantinduction/archaic/{filter/imprint => blocks}/TileFilterable.java (98%) create mode 100644 src/main/scala/resonantinduction/archaic/blocks/TileImprinter.java delete mode 100644 src/main/scala/resonantinduction/archaic/filter/BlockImprinter.java delete mode 100644 src/main/scala/resonantinduction/archaic/filter/RenderImprinter.java delete mode 100644 src/main/scala/resonantinduction/archaic/filter/TileFilter.java delete mode 100644 src/main/scala/resonantinduction/archaic/filter/TileImprinter.java delete mode 100644 src/main/scala/resonantinduction/archaic/filter/imprint/BlockImprintable.java diff --git a/src/main/scala/resonantinduction/archaic/Archaic.scala b/src/main/scala/resonantinduction/archaic/Archaic.scala index 8234fb2fb..e614ea340 100644 --- a/src/main/scala/resonantinduction/archaic/Archaic.scala +++ b/src/main/scala/resonantinduction/archaic/Archaic.scala @@ -9,7 +9,7 @@ import net.minecraftforge.oredict.OreDictionary import net.minecraftforge.oredict.ShapedOreRecipe import resonant.content.loader.ModManager import resonant.lib.recipe.UniversalRecipe -import resonantinduction.archaic.blocks.TileTurntable +import resonantinduction.archaic.blocks.{ItemImprint, TileImprinter, TileTurntable} import resonantinduction.archaic.crate.BlockCrate import resonantinduction.archaic.crate.CrateRecipe import resonantinduction.archaic.crate.ItemBlockCrate @@ -17,8 +17,6 @@ import resonantinduction.archaic.crate.TileCrate import resonantinduction.archaic.engineering.ItemHammer import resonantinduction.archaic.engineering.TileEngineeringTable import resonantinduction.archaic.filter.BlockImprinter -import resonantinduction.archaic.filter.TileFilter -import resonantinduction.archaic.filter.TileImprinter import resonantinduction.archaic.firebox.BlockHotPlate import resonantinduction.archaic.firebox.TileFirebox import resonantinduction.archaic.firebox.TileHotPlate @@ -32,7 +30,6 @@ import resonantinduction.core.Reference import resonantinduction.core.ResonantInduction import resonantinduction.core.ResonantTab import resonantinduction.core.Settings -import resonantinduction.archaic.filter.imprint.ItemImprint import resonantinduction.mechanical.gear.ItemHandCrank import cpw.mods.fml.common.Mod import cpw.mods.fml.common.Mod.EventHandler diff --git a/src/main/scala/resonantinduction/archaic/filter/imprint/ItemImprint.java b/src/main/scala/resonantinduction/archaic/blocks/ItemImprint.java similarity index 86% rename from src/main/scala/resonantinduction/archaic/filter/imprint/ItemImprint.java rename to src/main/scala/resonantinduction/archaic/blocks/ItemImprint.java index b78fb137a..9c224ecfa 100644 --- a/src/main/scala/resonantinduction/archaic/filter/imprint/ItemImprint.java +++ b/src/main/scala/resonantinduction/archaic/blocks/ItemImprint.java @@ -1,4 +1,4 @@ -package resonantinduction.archaic.filter.imprint; +package resonantinduction.archaic.blocks; import java.util.ArrayList; import java.util.HashSet; @@ -22,12 +22,12 @@ import resonantinduction.core.Settings; public class ItemImprint extends Item { - public ItemImprint(int id) + public ItemImprint() { - super(Settings.config.getItem("imprint", id).getInt()); - this.setUnlocalizedName(Reference.PREFIX + "imprint"); - this.setTextureName(Reference.PREFIX + "imprint"); - this.setCreativeTab(ResonantTab.DEFAULT); + super(); + this.setUnlocalizedName(Reference.prefix() + "imprint"); + this.setTextureName(Reference.prefix() + "imprint"); + this.setCreativeTab(ResonantTab.tab()); this.setHasSubtypes(true); this.setMaxStackSize(1); } @@ -114,11 +114,11 @@ public class ItemImprint extends Item HashSet filterStacks = new HashSet(); NBTTagCompound nbt = NBTUtility.getNBTTagCompound(itemStack); - NBTTagList tagList = nbt.getTagList("Items"); + NBTTagList tagList = nbt.getTagList("Items", 0); for (int i = 0; i < tagList.tagCount(); ++i) { - NBTTagCompound var4 = (NBTTagCompound) tagList.tagAt(i); + NBTTagCompound var4 = (NBTTagCompound) tagList.getCompoundTagAt(i); filterStacks.add(ItemStack.loadItemStackFromNBT(var4)); } @@ -130,11 +130,11 @@ public class ItemImprint extends Item List filterStacks = new ArrayList(); NBTTagCompound nbt = NBTUtility.getNBTTagCompound(itemStack); - NBTTagList tagList = nbt.getTagList("Items"); + NBTTagList tagList = nbt.getTagList("Items", 0); for (int i = 0; i < tagList.tagCount(); ++i) { - NBTTagCompound var4 = (NBTTagCompound) tagList.tagAt(i); + NBTTagCompound var4 = (NBTTagCompound) tagList.getCompoundTagAt(i); filterStacks.add(ItemStack.loadItemStackFromNBT(var4)); } diff --git a/src/main/scala/resonantinduction/archaic/filter/imprint/TileFilterable.java b/src/main/scala/resonantinduction/archaic/blocks/TileFilterable.java similarity index 98% rename from src/main/scala/resonantinduction/archaic/filter/imprint/TileFilterable.java rename to src/main/scala/resonantinduction/archaic/blocks/TileFilterable.java index 7f0a9ec29..9dc07617c 100644 --- a/src/main/scala/resonantinduction/archaic/filter/imprint/TileFilterable.java +++ b/src/main/scala/resonantinduction/archaic/blocks/TileFilterable.java @@ -1,4 +1,4 @@ -package resonantinduction.archaic.filter.imprint; +package resonantinduction.archaic.blocks; import java.util.Set; diff --git a/src/main/scala/resonantinduction/archaic/blocks/TileImprinter.java b/src/main/scala/resonantinduction/archaic/blocks/TileImprinter.java new file mode 100644 index 000000000..e44341c02 --- /dev/null +++ b/src/main/scala/resonantinduction/archaic/blocks/TileImprinter.java @@ -0,0 +1,474 @@ +package resonantinduction.archaic.blocks; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +import codechicken.multipart.ControlKeyModifer; +import cpw.mods.fml.common.network.ByteBufUtils; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.network.Packet; +import net.minecraft.util.IIcon; +import net.minecraftforge.common.util.ForgeDirection; +import org.lwjgl.opengl.GL11; +import resonant.content.prefab.java.TileAdvanced; +import resonant.content.spatial.block.SpatialBlock; +import resonant.engine.ResonantEngine; +import resonant.lib.network.discriminator.PacketTile; +import resonant.lib.network.discriminator.PacketType; +import resonant.lib.network.handle.IPacketReceiver; +import resonant.lib.render.RenderItemOverlayUtility; +import resonant.lib.utility.inventory.InventoryUtility; + +import resonantinduction.core.Reference; +import universalelectricity.core.transform.vector.Vector2; +import universalelectricity.core.transform.vector.Vector3; +import universalelectricity.core.transform.vector.VectorWorld; + +public class TileImprinter extends TileAdvanced implements ISidedInventory, IPacketReceiver +{ + public ItemStack[] inventory = new ItemStack[10]; + + public TileImprinter() + { + super(Material.circuits); + } + + @Override + public Packet getDescriptionPacket() + { + NBTTagCompound nbt = new NBTTagCompound(); + this.writeToNBT(nbt); + return ResonantEngine.instance.packetHandler.toMCPacket(new PacketTile(this, nbt)); + } + + @Override + public void read(ByteBuf data, EntityPlayer player, PacketType type) + { + try + { + this.readFromNBT(ByteBufUtils.readTag(data)); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + /** + * Inventory methods. + */ + @Override + public boolean canUpdate() + { + return false; + } + + @Override + public int getSizeInventory() + { + return this.inventory.length; + } + + /** + * Sets the given item stack to the specified slot in the inventory (can be crafting or armor + * sections). + */ + @Override + public void setInventorySlotContents(int slot, ItemStack itemStack) + { + if (slot < this.getSizeInventory()) + { + inventory[slot] = itemStack; + } + } + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public ItemStack decrStackSize(int i, int amount) + { + if (this.getStackInSlot(i) != null) + { + ItemStack stack; + + if (this.getStackInSlot(i).stackSize <= amount) + { + stack = this.getStackInSlot(i); + this.setInventorySlotContents(i, null); + return stack; + } + else + { + stack = this.getStackInSlot(i).splitStack(amount); + + if (this.getStackInSlot(i).stackSize == 0) + { + this.setInventorySlotContents(i, null); + } + + return stack; + } + } + else + { + return null; + } + } + + @Override + public ItemStack getStackInSlot(int slot) + { + return this.inventory[slot]; + } + + /** + * When some containers are closed they call this on each slot, then drop whatever it returns as + * an EntityItem - like when you close a workbench GUI. + */ + @Override + public ItemStack getStackInSlotOnClosing(int slot) + { + if (this.getStackInSlot(slot) != null) + { + ItemStack var2 = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return var2; + } + else + { + return null; + } + } + + @Override + public void openInventory() + { + this.onInventoryChanged(); + } + + @Override + public void closeInventory() + { + this.onInventoryChanged(); + } + + /** Updates all the output slots. Call this to update the Imprinter. */ + public void onInventoryChanged() + { + if (!this.worldObj.isRemote) + { + /** Makes the stamping recipe for filters */ + ItemStack fitlerStack = this.inventory[9]; + + if (fitlerStack != null && fitlerStack.getItem() instanceof ItemImprint) + { + ItemStack outputStack = fitlerStack.copy(); + Set filters = ItemImprint.getFilters(outputStack); + Set toAdd = new HashSet(); + + /** A hashset of to be imprinted items containing NO repeats. */ + Set toBeImprinted = new HashSet(); + + check: + for (int i = 0; i < 9; i++) + { + ItemStack stackInInventory = inventory[i]; + + if (stackInInventory != null) + { + for (ItemStack check : toBeImprinted) + { + if (check.isItemEqual(stackInInventory)) + continue check; + } + + toBeImprinted.add(stackInInventory); + } + } + + for (ItemStack stackInInventory : toBeImprinted) + { + Iterator it = filters.iterator(); + + boolean removed = false; + + while (it.hasNext()) + { + ItemStack filteredStack = it.next(); + + if (filteredStack.isItemEqual(stackInInventory)) + { + it.remove(); + removed = true; + } + } + + if (!removed) + toAdd.add(stackInInventory); + } + + filters.addAll(toAdd); + + ItemImprint.setFilters(outputStack, filters); + this.inventory[9] = outputStack; + } + } + } + + // /////////////////////////////////////// + // // Save And Data processing ////// + // /////////////////////////////////////// + /** NBT Data */ + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + + NBTTagList var2 = nbt.getTagList("Items", 0); + this.inventory = new ItemStack[10]; + + for (int i = 0; i < var2.tagCount(); ++i) + { + NBTTagCompound var4 = (NBTTagCompound) var2.getCompoundTagAt(i); + byte var5 = var4.getByte("Slot"); + + if (var5 >= 0 && var5 < this.getSizeInventory()) + { + this.setInventorySlotContents(var5, ItemStack.loadItemStackFromNBT(var4)); + } + } + } + + /** Writes a tile entity to NBT. */ + @Override + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + + NBTTagList var2 = new NBTTagList(); + + for (int i = 0; i < this.getSizeInventory(); ++i) + { + if (this.getStackInSlot(i) != null) + { + NBTTagCompound var4 = new NBTTagCompound(); + var4.setByte("Slot", (byte) i); + this.getStackInSlot(i).writeToNBT(var4); + var2.appendTag(var4); + } + } + + nbt.setTag("Items", var2); + } + + // /////////////////////////////////////// + // // Inventory Access side Methods ////// + // /////////////////////////////////////// + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) + { + return true; + } + + @Override + public int getInventoryStackLimit() + { + return 64; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) + { + return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : entityplayer.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) + { + return side == 1 ? new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 } : new int[10]; + } + + @Override + public boolean canInsertItem(int slot, ItemStack itemstack, int side) + { + return this.isItemValidForSlot(slot, itemstack); + } + + @Override + public boolean canExtractItem(int slot, ItemStack itemstack, int side) + { + return this.isItemValidForSlot(slot, itemstack); + } + + @Override + public void renderDynamic(Vector3 position, float frame, int pass) + { + GL11.glPushMatrix(); + RenderItemOverlayUtility.renderTopOverlay(this, inventory, ForgeDirection.EAST, x(), y(), z()); + RenderItemOverlayUtility.renderItemOnSides(this, getStackInSlot(9), x(), y(), z()); + GL11.glPopMatrix(); + } + + @SideOnly(Side.CLIENT) + @Override + public void registerIcons(IIconRegister iconReg) + { + super.registerIcons(iconReg); + SpatialBlock.icon().put("imprinter_side", iconReg.registerIcon(Reference.prefix() + "imprinter_side")); + SpatialBlock.icon().put("imprinter_top", iconReg.registerIcon(Reference.prefix() + "imprinter_top")); + SpatialBlock.icon().put("imprinter_bottom", iconReg.registerIcon(Reference.prefix() + "imprinter_bottom")); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) + { + if (side == 1) + { + return SpatialBlock.icon().get("imprinter_top"); + + } + else if (side == 0) + { + return SpatialBlock.icon().get("imprinter_bottom"); + + } + + return SpatialBlock.icon().get("imprinter_side"); + } + + public boolean use(EntityPlayer player, int hitSide, Vector3 hit) + { + ItemStack current = player.inventory.getCurrentItem(); + + if (hitSide == 1) + { + if (!world().isRemote) + { + Vector2 hitVector = new Vector2(hit.x(), hit.z()); + double regionLength = 1d / 3d; + + /** + * Crafting Matrix + */ + matrix: + for (int j = 0; j < 3; j++) + { + for (int k = 0; k < 3; k++) + { + Vector2 check = new Vector2(j, k).multiply(regionLength); + + if (check.distance(hitVector) < regionLength) + { + int slotID = j * 3 + k; + boolean didInsert = false; + ItemStack checkStack = inventory[slotID]; + + if (current != null) + { + if (checkStack == null || checkStack.isItemEqual(current)) + { + if (ControlKeyModifer.isControlDown(player)) + { + if (checkStack == null) + { + inventory[slotID] = current; + } + else + { + inventory[slotID].stackSize += current.stackSize; + current.stackSize = 0; + } + + current = null; + } + else + { + if (checkStack == null) + { + inventory[slotID] = current.splitStack(1); + } + else + { + inventory[slotID].stackSize++; + current.stackSize--; + } + } + + if (current == null || current.stackSize <= 0) + { + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + } + + didInsert = true; + } + } + + if (!didInsert && checkStack != null) + { + InventoryUtility.dropItemStack(world(), new Vector3(player), checkStack, 0); + inventory[slotID] = null; + } + + break matrix; + } + } + } + + world().markBlockForUpdate(x(), y(), z()); + } + + return true; + } + else if (hitSide != 0) + { + + ItemStack output = getStackInSlot(9); + + if (output != null) + { + InventoryUtility.dropItemStack(world(), new Vector3(player), output, 0); + setInventorySlotContents(9, null); + } + else if (current != null && current.getItem() instanceof ItemImprint) + { + setInventorySlotContents(9, current); + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + } + } + return false; + } + + @Override + public void onNeighborChanged(Block block) + { + VectorWorld vec = new VectorWorld(this); + Block b = vec.add(ForgeDirection.getOrientation(1)).getBlock(); + + if (Blocks.piston_head == b) + { + onInventoryChanged(); + } + } +} diff --git a/src/main/scala/resonantinduction/archaic/engineering/TileEngineeringTable.java b/src/main/scala/resonantinduction/archaic/engineering/TileEngineeringTable.java index 6ce1e2122..697febcb8 100644 --- a/src/main/scala/resonantinduction/archaic/engineering/TileEngineeringTable.java +++ b/src/main/scala/resonantinduction/archaic/engineering/TileEngineeringTable.java @@ -3,6 +3,9 @@ package resonantinduction.archaic.engineering; import java.util.ArrayList; import java.util.Set; +import cpw.mods.fml.common.network.ByteBufUtils; +import io.netty.buffer.ByteBuf; +import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -11,12 +14,14 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import net.minecraft.network.packet.Packet; +import net.minecraft.network.Packet; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentText; import net.minecraft.util.IIcon; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.oredict.OreDictionary; @@ -28,13 +33,12 @@ import resonant.api.IRotatable; import resonant.api.ISlotPickResult; import resonant.api.recipe.MachineRecipes; import resonant.api.recipe.RecipeResource; -import resonant.lib.content.module.TileRender; -import resonant.lib.content.module.prefab.TileInventory; +import resonant.content.prefab.itemblock.ItemBlockSaved; +import resonant.engine.ResonantEngine; import resonant.lib.gui.ContainerDummy; -import resonant.lib.network.IPacketReceiver; -import resonant.lib.network.PacketHandler; -import resonant.lib.prefab.item.ItemBlockSaved; -import resonant.lib.prefab.vector.Cuboid; +import resonant.lib.network.discriminator.PacketTile; +import resonant.lib.network.discriminator.PacketType; +import resonant.lib.network.handle.IPacketReceiver; import resonant.lib.render.RenderItemOverlayUtility; import resonant.lib.type.Pair; import resonant.lib.utility.LanguageUtility; @@ -45,15 +49,16 @@ import resonant.lib.utility.inventory.InventoryUtility; import resonantinduction.core.Reference; import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInduction.RecipeType; -import resonantinduction.archaic.filter.imprint.ItemImprint; -import universalelectricity.api.vector.Vector2; +import resonantinduction.archaic.blocks.ItemImprint; +import universalelectricity.core.transform.region.Cuboid; +import universalelectricity.core.transform.rotation.Quaternion; +import universalelectricity.core.transform.vector.Vector2; import universalelectricity.core.transform.vector.Vector3; import codechicken.multipart.ControlKeyModifer; -import com.google.common.io.ByteArrayDataInput; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import resonant.lib.content.prefab.java.TileInventory; /** Advanced crafting table that stores its crafting grid, can craft out of the player's inv, and be * configed to auto craft. @@ -92,10 +97,10 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv public TileEngineeringTable() { super(Material.wood); - bounds = new Cuboid(0, 0, 0, 1, 0.9f, 1); - isOpaqueCube = false; - normalRender = false; - itemBlock = ItemBlockSaved.class; + bounds(new Cuboid(0, 0, 0, 1, 0.9f, 1)); + isOpaqueCube(false); + normalRender(false); + itemBlock(ItemBlockSaved.class); } @Override @@ -132,7 +137,7 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv } @Override - protected boolean use(EntityPlayer player, int hitSide, Vector3 hit) + public boolean use(EntityPlayer player, int hitSide, Vector3 hit) { if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemHammer) { @@ -146,7 +151,7 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv if (oreName != null && !oreName.equals("Unknown")) { - RecipeResource[] outputs = MachineRecipes.INSTANCE.getOutput(RecipeType.CRUSHER.name(), oreName); + RecipeResource[] outputs = MachineRecipes.INSTANCE.getOutput(RecipeType.CRUSHER().toString(), oreName); if (outputs != null && outputs.length > 0) { @@ -164,8 +169,8 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv } } - ResonantInduction.proxy.renderBlockParticle(world(), new Vector3(x() + 0.5, y() + 0.5, z() + 0.5), new Vector3((Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 3), inputStack.itemID, 1); - world().playSoundEffect(x() + 0.5, y() + 0.5, z() + 0.5, Reference.PREFIX + "hammer", 0.5f, 0.8f + (0.2f * world().rand.nextFloat())); + ResonantInduction.proxy().renderBlockParticle(world(), new Vector3(x() + 0.5, y() + 0.5, z() + 0.5), new Vector3((Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 3), Item.getIdFromItem(inputStack.getItem()), 1); + world().playSoundEffect(x() + 0.5, y() + 0.5, z() + 0.5, Reference.prefix() + "hammer", 0.5f, 0.8f + (0.2f * world().rand.nextFloat())); player.addExhaustion(0.1f); player.getCurrentEquippedItem().damageItem(1, player); return true; @@ -180,12 +185,12 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv { if (!world().isRemote) { - Vector3 hitVector = new Vector3(hit.x, 0, hit.z); + Vector3 hitVector = new Vector3(hit.x(), 0, hit.z()); final double regionLength = 1d / 3d; // Rotate the hit vector based on direction of the tile. hitVector.add(new Vector3(-0.5, 0, -0.5)); - hitVector.rotate(WorldUtility.getAngleFromForgeDirection(getDirection()), Vector3.UP()); + hitVector.transform(new Quaternion(WorldUtility.getAngleFromForgeDirection(getDirection()), Vector3.up())); hitVector.add(new Vector3(0.5, 0, 0.5)); /** Crafting Matrix */ @@ -194,7 +199,7 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv { for (int k = 0; k < 3; k++) { - Vector2 check = new Vector2(j, k).scale(regionLength); + Vector2 check = new Vector2(j, k).multiply(regionLength); if (check.distance(hitVector.toVector2()) < regionLength) { @@ -246,7 +251,7 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv } @Override - protected boolean configure(EntityPlayer player, int side, Vector3 hit) + public boolean configure(EntityPlayer player, int side, Vector3 hit) { if (player.isSneaking()) { @@ -254,9 +259,9 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv if (!world().isRemote) { if (searchInventories) - player.addChatMessage(LanguageUtility.getLocal("engineerTable.config.inventory.true")); + player.addChatMessage(new ChatComponentText(LanguageUtility.getLocal("engineerTable.config.inventory.true"))); else - player.addChatMessage(LanguageUtility.getLocal("engineerTable.config.inventory.false")); + player.addChatMessage(new ChatComponentText(LanguageUtility.getLocal("engineerTable.config.inventory.false"))); } markUpdate(); @@ -273,9 +278,9 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv } @Override - public void onRemove(int par5, int par6) + public void onRemove(Block block, int par6) { - ItemStack stack = ItemBlockSaved.getItemStackWithNBT(this.getBlockType(), world(), x(), y(), z()); + ItemStack stack = ItemBlockSaved.getItemStackWithNBT(block, world(), x(), y(), z()); InventoryUtility.dropItemStack(world(), center(), stack); } @@ -320,15 +325,15 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv { NBTTagCompound nbt = new NBTTagCompound(); this.writeToNBT(nbt); - return ResonantInduction.PACKET_TILE.getPacket(this, nbt); + return ResonantEngine.instance.packetHandler.toMCPacket(new PacketTile(this, nbt)); } @Override - public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra) + public void read(ByteBuf data, EntityPlayer player, PacketType type) { try { - readFromNBT(PacketHandler.readNBTTagCompound(data)); + readFromNBT(ByteBufUtils.readTag(data)); } catch (Exception e) { @@ -475,24 +480,6 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv } } - @Override - public String getInvName() - { - return this.getBlockType().getLocalizedName(); - } - - @Override - public void openChest() - { - this.onInventoryChanged(); - } - - @Override - public void closeChest() - { - this.onInventoryChanged(); - } - /** Construct an InventoryCrafting Matrix on the fly. * * @return */ @@ -509,7 +496,6 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv } /** Updates all the output slots. Call this to update the Engineering Table. */ - @Override public void onInventoryChanged() { if (worldObj != null) @@ -597,13 +583,13 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv { super.readFromNBT(nbt); - NBTTagList nbtList = nbt.getTagList("Items"); + NBTTagList nbtList = nbt.getTagList("Items", 0); this.craftingMatrix = new ItemStack[9]; this.outputInventory = new ItemStack[1]; for (int i = 0; i < nbtList.tagCount(); ++i) { - NBTTagCompound stackTag = (NBTTagCompound) nbtList.tagAt(i); + NBTTagCompound stackTag = nbtList.getCompoundTagAt(i); byte id = stackTag.getByte("Slot"); if (id >= 0 && id < this.getSizeInventory()) @@ -642,12 +628,6 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv // // Inventory Access side Methods ////// // /////////////////////////////////////// - @Override - public boolean isInvNameLocalized() - { - return false; - } - @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { @@ -756,25 +736,23 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv return slots; } - @Override - @SideOnly(Side.CLIENT) - protected TileRender newRenderer() - { - return new TileRender() - { - @Override - public boolean renderDynamic(Vector3 position, boolean isItem, float frame) - { - if (!isItem) - { - GL11.glPushMatrix(); - RenderItemOverlayUtility.renderItemOnSides(TileEngineeringTable.this, getStackInSlot(9), position.x, position.y, position.z); - RenderItemOverlayUtility.renderTopOverlay(TileEngineeringTable.this, craftingMatrix, getDirection(), position.x, position.y - 0.1, position.z); - GL11.glPopMatrix(); - } - return false; - } - }; + @Override + public void renderDynamic(Vector3 position, float frame, int pass) + { + GL11.glPushMatrix(); + RenderItemOverlayUtility.renderItemOnSides(TileEngineeringTable.this, getStackInSlot(9), position.x(), position.y(), position.z()); + RenderItemOverlayUtility.renderTopOverlay(TileEngineeringTable.this, craftingMatrix, getDirection(), position.x(), position.y() - 0.1, position.z()); + GL11.glPopMatrix(); + } + + @Override + public ForgeDirection getDirection() { + return null; + } + + @Override + public void setDirection(ForgeDirection direction) { + } } diff --git a/src/main/scala/resonantinduction/archaic/filter/BlockImprinter.java b/src/main/scala/resonantinduction/archaic/filter/BlockImprinter.java deleted file mode 100644 index e3832336f..000000000 --- a/src/main/scala/resonantinduction/archaic/filter/BlockImprinter.java +++ /dev/null @@ -1,202 +0,0 @@ -package resonantinduction.archaic.filter; - -import net.minecraft.block.Block; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import resonant.lib.prefab.block.BlockTile; -import resonant.lib.utility.inventory.InventoryUtility; -import resonantinduction.core.Reference; -import resonantinduction.archaic.filter.imprint.ItemImprint; -import universalelectricity.api.UniversalElectricity; -import universalelectricity.api.vector.Vector2; -import universalelectricity.core.transform.vector.Vector3; -import universalelectricity.api.vector.VectorWorld; -import codechicken.multipart.ControlKeyModifer; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class BlockImprinter extends BlockTile -{ - IIcon imprinter_side; - IIcon imprinter_top; - IIcon imprinter_bottom; - - public BlockImprinter(int id) - { - super(id, UniversalElectricity.machine); - } - - @SideOnly(Side.CLIENT) - @Override - public void registerIcons(IIconRegister iconReg) - { - this.imprinter_side = iconReg.registerIcon(Reference.PREFIX + "imprinter_side"); - this.imprinter_top = iconReg.registerIcon(Reference.PREFIX + "imprinter_top"); - this.imprinter_bottom = iconReg.registerIcon(Reference.PREFIX + "imprinter_bottom"); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getBlockTexture(IBlockAccess world, int x, int y, int z, int side) - { - return getIcon(side, 0); - } - - /** Returns the block texture based on the side being looked at. Args: side */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) - { - if (side == 1) - { - return this.imprinter_top; - - } - else if (side == 0) - { - return this.imprinter_bottom; - - } - - return this.imprinter_side; - } - - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, int blockID) - { - TileEntity te = world.getTileEntity(x, y, z); - - if (te instanceof TileImprinter) - { - TileImprinter tile = (TileImprinter) te; - int idOnTop = ((VectorWorld) new VectorWorld(world, x, y, z).add(ForgeDirection.getOrientation(1))).getBlock(); - - if (Block.pistonMoving.blockID == blockID) - { - tile.onInventoryChanged(); - } - } - } - - @Override - public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer player, int hitSide, float hitX, float hitY, float hitZ) - { - TileEntity te = world.getTileEntity(x, y, z); - - if (te instanceof TileImprinter) - { - TileImprinter tile = (TileImprinter) te; - ItemStack current = player.inventory.getCurrentItem(); - - if (hitSide == 1) - { - if (!world.isRemote) - { - Vector2 hitVector = new Vector2(hitX, hitZ); - double regionLength = 1d / 3d; - - /** - * Crafting Matrix - */ - matrix: - for (int j = 0; j < 3; j++) - { - for (int k = 0; k < 3; k++) - { - Vector2 check = new Vector2(j, k).scale(regionLength); - - if (check.distance(hitVector) < regionLength) - { - int slotID = j * 3 + k; - boolean didInsert = false; - ItemStack checkStack = tile.inventory[slotID]; - - if (current != null) - { - if (checkStack == null || checkStack.isItemEqual(current)) - { - if (ControlKeyModifer.isControlDown(player)) - { - if (checkStack == null) - { - tile.inventory[slotID] = current; - } - else - { - tile.inventory[slotID].stackSize += current.stackSize; - current.stackSize = 0; - } - - current = null; - } - else - { - if (checkStack == null) - { - tile.inventory[slotID] = current.splitStack(1); - } - else - { - tile.inventory[slotID].stackSize++; - current.stackSize--; - } - } - - if (current == null || current.stackSize <= 0) - { - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - } - - didInsert = true; - } - } - - if (!didInsert && checkStack != null) - { - InventoryUtility.dropItemStack(world, new Vector3(player), checkStack, 0); - tile.inventory[slotID] = null; - } - - break matrix; - } - } - } - - world.markBlockForUpdate(x, y, z); - } - - return true; - } - else if (hitSide != 0) - { - - ItemStack output = tile.getStackInSlot(9); - - if (output != null) - { - InventoryUtility.dropItemStack(world, new Vector3(player), output, 0); - tile.setInventorySlotContents(9, null); - } - else if (current != null && current.getItem() instanceof ItemImprint) - { - tile.setInventorySlotContents(9, current); - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - } - } - } - - return false; - } - - @Override - public TileEntity createNewTileEntity(World var1) - { - return new TileImprinter(); - } -} diff --git a/src/main/scala/resonantinduction/archaic/filter/RenderImprinter.java b/src/main/scala/resonantinduction/archaic/filter/RenderImprinter.java deleted file mode 100644 index 9723d963e..000000000 --- a/src/main/scala/resonantinduction/archaic/filter/RenderImprinter.java +++ /dev/null @@ -1,26 +0,0 @@ -package resonantinduction.archaic.filter; - -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; -import resonant.lib.render.RenderItemOverlayUtility; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class RenderImprinter extends TileEntitySpecialRenderer -{ - private final RenderBlocks renderBlocks = new RenderBlocks(); - - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8) - { - if (tileEntity instanceof TileImprinter) - { - TileImprinter tile = (TileImprinter) tileEntity; - RenderItemOverlayUtility.renderTopOverlay(tileEntity, tile.inventory, ForgeDirection.EAST, x, y, z); - RenderItemOverlayUtility.renderItemOnSides(tileEntity, tile.getStackInSlot(9), x, y, z); - } - } -} diff --git a/src/main/scala/resonantinduction/archaic/filter/TileFilter.java b/src/main/scala/resonantinduction/archaic/filter/TileFilter.java deleted file mode 100644 index d3f93800e..000000000 --- a/src/main/scala/resonantinduction/archaic/filter/TileFilter.java +++ /dev/null @@ -1,185 +0,0 @@ -package resonantinduction.archaic.filter; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.packet.Packet; -import net.minecraft.world.IBlockAccess; -import net.minecraftforge.common.util.ForgeDirection; -import resonant.api.IFilterable; -import resonant.api.recipe.MachineRecipes; -import resonant.api.recipe.RecipeResource; -import resonant.lib.content.module.TileRender; -import resonant.lib.network.Synced.SyncedInput; -import resonant.lib.network.Synced.SyncedOutput; -import resonant.lib.prefab.vector.Cuboid; -import resonant.lib.render.RenderItemOverlayUtility; -import resonant.lib.utility.LanguageUtility; -import resonant.lib.utility.inventory.InventoryUtility; -import resonantinduction.core.ResonantInduction; -import resonantinduction.core.ResonantInduction.RecipeType; -import resonantinduction.archaic.filter.imprint.ItemImprint; -import resonantinduction.archaic.filter.imprint.TileFilterable; -import resonantinduction.core.resource.ResourceGenerator; -import resonantinduction.core.resource.fluid.BlockFluidMixture; -import universalelectricity.core.transform.vector.Vector3; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class TileFilter extends TileFilterable implements IFilterable -{ - public TileFilter() - { - super(Material.iron); - maxSlots = 1; - isOpaqueCube = false; - normalRender = false; - } - - public Iterable getCollisionBoxes(Cuboid intersect, Entity entity) - { - if (entity == null) - return null; - - if (entity instanceof EntityItem) - { - if (isFiltering(((EntityItem) entity).getEntityItem())) - { - return null; - } - } - - return super.getCollisionBoxes(intersect, entity); - } - - @Override - public void updateEntity() - { - super.updateEntity(); - - if (ticks % 60 == 0) - { - /** Toggle item filter render */ - if (getFilter() != null) - { - List filteredStacks = ItemImprint.getFilterList(getFilter()); - - if (filteredStacks.size() > 0) - { - renderIndex = (renderIndex + 1) % filteredStacks.size(); - } - } - - /** Fluid filters */ - Vector3 position = new Vector3(this); - Vector3 checkAbove = position.clone().add(ForgeDirection.UP); - Vector3 checkBelow = position.clone().add(ForgeDirection.DOWN); - - Block bAbove = Block.blocksList[checkAbove.getBlock(worldObj)]; - - if (bAbove instanceof BlockFluidMixture && worldObj.isAirBlock(checkBelow.xi(), checkBelow.yi(), checkBelow.zi())) - { - worldObj.spawnParticle("dripWater", xCoord + 0.5, yCoord, zCoord + 0.5, 0, 0, 0); - - /** Leak the fluid down. */ - BlockFluidMixture fluidBlock = (BlockFluidMixture) bAbove; - int amount = fluidBlock.getQuantaValue(worldObj, checkAbove.xi(), checkAbove.yi(), checkAbove.zi()); - int leakAmount = 2; - - /** Drop item from fluid. */ - for (RecipeResource resoure : MachineRecipes.INSTANCE.getOutput(RecipeType.MIXER.name(), "dirtyDust" + LanguageUtility.capitalizeFirst(ResourceGenerator.mixtureToMaterial(fluidBlock.getFluid().getName())))) - { - InventoryUtility.dropItemStack(worldObj, checkAbove.clone().add(0.5), resoure.getItemStack().copy(), 0, 0); - } - - // TODO: Check if this is correct? - int remaining = amount - leakAmount; - - /** Remove liquid from top. */ - fluidBlock.setQuanta(worldObj, checkAbove.xi(), checkAbove.yi(), checkAbove.zi(), remaining); - - // Since there is air below us we will spawn water. - checkBelow.setBlock(worldObj, Block.waterMoving.blockID); - } - } - } - - @SyncedOutput - @Override - public void writeToNBT(NBTTagCompound nbt) - { - super.writeToNBT(nbt); - } - - @SyncedInput - @Override - public void readFromNBT(NBTTagCompound nbt) - { - super.readFromNBT(nbt); - } - - private int renderIndex = 0; - - @SideOnly(Side.CLIENT) - protected TileRender newRenderer() - { - return new TileRender() - { - @Override - public boolean renderDynamic(Vector3 position, boolean isItem, float frame) - { - if (isItem) - return false; - - if (getFilter() != null) - { - List filteredStacks = ItemImprint.getFilterList(getFilter()); - - if (filteredStacks.size() > 0) - { - ItemStack renderStack = filteredStacks.get(renderIndex); - RenderItemOverlayUtility.renderItemOnSides(TileFilter.this, renderStack, position.x, position.y, position.z); - } - } - - return false; - } - }; - } - - @Override - public boolean shouldSideBeRendered(IBlockAccess access, int x, int y, int z, int side) - { - return access.getBlockId(x, y, z) == block.blockID ? false : super.shouldSideBeRendered(access, x, y, z, side); - } - - @Override - public Packet getDescriptionPacket() - { - return ResonantInduction.PACKET_ANNOTATION.getPacket(this); - } - - @Override - public boolean canStore(ItemStack stack, int slot, ForgeDirection side) - { - return slot == 0 && stack.getItem() instanceof ItemImprint; - } - - @Override - public void setFilter(ItemStack filter) - { - setInventorySlotContents(0, filter); - markUpdate(); - } - - @Override - public ItemStack getFilter() - { - return getStackInSlot(0); - } -} diff --git a/src/main/scala/resonantinduction/archaic/filter/TileImprinter.java b/src/main/scala/resonantinduction/archaic/filter/TileImprinter.java deleted file mode 100644 index 9bbbf0493..000000000 --- a/src/main/scala/resonantinduction/archaic/filter/TileImprinter.java +++ /dev/null @@ -1,302 +0,0 @@ -package resonantinduction.archaic.filter; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.network.packet.Packet; -import resonant.lib.network.IPacketReceiver; -import resonant.lib.network.PacketHandler; -import resonant.lib.prefab.tile.TileAdvanced; -import resonantinduction.core.ResonantInduction; -import resonantinduction.archaic.filter.imprint.ItemImprint; - -import com.google.common.io.ByteArrayDataInput; - -public class TileImprinter extends TileAdvanced implements ISidedInventory, IPacketReceiver -{ - public ItemStack[] inventory = new ItemStack[10]; - - @Override - public Packet getDescriptionPacket() - { - NBTTagCompound nbt = new NBTTagCompound(); - this.writeToNBT(nbt); - return new PacketTile(this, nbt); - } - - @Override - public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra) - { - try - { - this.readFromNBT(PacketHandler.readNBTTagCompound(data)); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - /** - * Inventory methods. - */ - @Override - public boolean canUpdate() - { - return false; - } - - @Override - public int getSizeInventory() - { - return this.inventory.length; - } - - /** - * Sets the given item stack to the specified slot in the inventory (can be crafting or armor - * sections). - */ - @Override - public void setInventorySlotContents(int slot, ItemStack itemStack) - { - if (slot < this.getSizeInventory()) - { - inventory[slot] = itemStack; - } - } - - @Override - public ItemStack decrStackSize(int i, int amount) - { - if (this.getStackInSlot(i) != null) - { - ItemStack stack; - - if (this.getStackInSlot(i).stackSize <= amount) - { - stack = this.getStackInSlot(i); - this.setInventorySlotContents(i, null); - return stack; - } - else - { - stack = this.getStackInSlot(i).splitStack(amount); - - if (this.getStackInSlot(i).stackSize == 0) - { - this.setInventorySlotContents(i, null); - } - - return stack; - } - } - else - { - return null; - } - } - - @Override - public ItemStack getStackInSlot(int slot) - { - return this.inventory[slot]; - } - - /** - * When some containers are closed they call this on each slot, then drop whatever it returns as - * an EntityItem - like when you close a workbench GUI. - */ - @Override - public ItemStack getStackInSlotOnClosing(int slot) - { - if (this.getStackInSlot(slot) != null) - { - ItemStack var2 = this.getStackInSlot(slot); - this.setInventorySlotContents(slot, null); - return var2; - } - else - { - return null; - } - } - - @Override - public void openChest() - { - this.onInventoryChanged(); - } - - @Override - public void closeChest() - { - this.onInventoryChanged(); - } - - /** Updates all the output slots. Call this to update the Imprinter. */ - @Override - public void onInventoryChanged() - { - if (!this.worldObj.isRemote) - { - /** Makes the stamping recipe for filters */ - ItemStack fitlerStack = this.inventory[9]; - - if (fitlerStack != null && fitlerStack.getItem() instanceof ItemImprint) - { - ItemStack outputStack = fitlerStack.copy(); - Set filters = ItemImprint.getFilters(outputStack); - Set toAdd = new HashSet(); - - /** A hashset of to be imprinted items containing NO repeats. */ - Set toBeImprinted = new HashSet(); - - check: - for (int i = 0; i < 9; i++) - { - ItemStack stackInInventory = inventory[i]; - - if (stackInInventory != null) - { - for (ItemStack check : toBeImprinted) - { - if (check.isItemEqual(stackInInventory)) - continue check; - } - - toBeImprinted.add(stackInInventory); - } - } - - for (ItemStack stackInInventory : toBeImprinted) - { - Iterator it = filters.iterator(); - - boolean removed = false; - - while (it.hasNext()) - { - ItemStack filteredStack = it.next(); - - if (filteredStack.isItemEqual(stackInInventory)) - { - it.remove(); - removed = true; - } - } - - if (!removed) - toAdd.add(stackInInventory); - } - - filters.addAll(toAdd); - - ItemImprint.setFilters(outputStack, filters); - this.inventory[9] = outputStack; - } - } - } - - // /////////////////////////////////////// - // // Save And Data processing ////// - // /////////////////////////////////////// - /** NBT Data */ - @Override - public void readFromNBT(NBTTagCompound nbt) - { - super.readFromNBT(nbt); - - NBTTagList var2 = nbt.getTagList("Items"); - this.inventory = new ItemStack[10]; - - for (int i = 0; i < var2.tagCount(); ++i) - { - NBTTagCompound var4 = (NBTTagCompound) var2.tagAt(i); - byte var5 = var4.getByte("Slot"); - - if (var5 >= 0 && var5 < this.getSizeInventory()) - { - this.setInventorySlotContents(var5, ItemStack.loadItemStackFromNBT(var4)); - } - } - } - - /** Writes a tile entity to NBT. */ - @Override - public void writeToNBT(NBTTagCompound nbt) - { - super.writeToNBT(nbt); - - NBTTagList var2 = new NBTTagList(); - - for (int i = 0; i < this.getSizeInventory(); ++i) - { - if (this.getStackInSlot(i) != null) - { - NBTTagCompound var4 = new NBTTagCompound(); - var4.setByte("Slot", (byte) i); - this.getStackInSlot(i).writeToNBT(var4); - var2.appendTag(var4); - } - } - - nbt.setTag("Items", var2); - } - - // /////////////////////////////////////// - // // Inventory Access side Methods ////// - // /////////////////////////////////////// - @Override - public boolean isInvNameLocalized() - { - return false; - } - - @Override - public String getInvName() - { - return getBlockType().getLocalizedName(); - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) - { - return true; - } - - @Override - public int getInventoryStackLimit() - { - return 64; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) - { - return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : entityplayer.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - return side == 1 ? new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 } : new int[10]; - } - - @Override - public boolean canInsertItem(int slot, ItemStack itemstack, int side) - { - return this.isItemValidForSlot(slot, itemstack); - } - - @Override - public boolean canExtractItem(int slot, ItemStack itemstack, int side) - { - return this.isItemValidForSlot(slot, itemstack); - } -} diff --git a/src/main/scala/resonantinduction/archaic/filter/imprint/BlockImprintable.java b/src/main/scala/resonantinduction/archaic/filter/imprint/BlockImprintable.java deleted file mode 100644 index a40173b9b..000000000 --- a/src/main/scala/resonantinduction/archaic/filter/imprint/BlockImprintable.java +++ /dev/null @@ -1,81 +0,0 @@ -package resonantinduction.archaic.filter.imprint; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import resonant.api.IFilterable; - -/** - * Extend this block class if a filter is allowed to be placed inside of this block. - * - * @author Calclavia - */ -public abstract class BlockImprintable extends Block -{ - public BlockImprintable(Material material) - { - super(material); - } - - /** Allows filters to be placed inside of this block. */ - @Override - public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); - - if (tileEntity instanceof IFilterable) - { - ItemStack containingStack = ((IFilterable) tileEntity).getFilter(); - - if (containingStack != null) - { - if (!world.isRemote) - { - EntityItem dropStack = new EntityItem(world, player.posX, player.posY, player.posZ, containingStack); - dropStack.delayBeforeCanPickup = 0; - world.spawnEntityInWorld(dropStack); - } - - ((IFilterable) tileEntity).setFilter(null); - return true; - } - else - { - if (player.getCurrentEquippedItem() != null) - { - if (player.getCurrentEquippedItem().getItem() instanceof ItemImprint) - { - ((IFilterable) tileEntity).setFilter(player.getCurrentEquippedItem()); - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - return true; - } - } - } - - } - - return false; - } - - @Override - public boolean onSneakUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); - - if (tileEntity != null) - { - if (tileEntity instanceof TileFilterable) - { - ((TileFilterable) tileEntity).toggleInversion(); - world.markBlockForRenderUpdate(x, y, z); - world.markBlockForUpdate(x, y, z); - } - } - - return true; - } -} diff --git a/src/main/scala/resonantinduction/archaic/fluid/grate/TileGrate.scala b/src/main/scala/resonantinduction/archaic/fluid/grate/TileGrate.scala index f831e76d3..031c29a65 100644 --- a/src/main/scala/resonantinduction/archaic/fluid/grate/TileGrate.scala +++ b/src/main/scala/resonantinduction/archaic/fluid/grate/TileGrate.scala @@ -43,14 +43,14 @@ object TileGrate { @SideOnly( Side.CLIENT ) private var iconSide : IIcon = _ - class ComparableVector( var position : Vector3, var iterations : Int ) extends Comparable[ _ ] { + class ComparableVector( var position : Vector3, var iterations : Int ) extends Comparable[Vector3] { - override def compareTo( obj : AnyRef ) : Int = { + override def compareTo( obj : Vector3 ) : Int = { val wr = obj.asInstanceOf[ ComparableVector ] if ( this.position.y == wr.position.y ) { return this.iterations - wr.iterations } - this.position.yi() - wr.position.yi() + this.position.yi - wr.position.yi } } } diff --git a/src/main/scala/resonantinduction/archaic/fluid/tank/ItemBlockTank.java b/src/main/scala/resonantinduction/archaic/fluid/tank/ItemBlockTank.java index f75a0f841..9e0579336 100644 --- a/src/main/scala/resonantinduction/archaic/fluid/tank/ItemBlockTank.java +++ b/src/main/scala/resonantinduction/archaic/fluid/tank/ItemBlockTank.java @@ -9,6 +9,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; import resonant.lib.utility.LanguageUtility; @@ -46,7 +47,7 @@ public class ItemBlockTank extends ItemBlock implements IFluidContainerItem if (fluid != null) { list.add("Fluid: " + fluid.getFluid().getLocalizedName()); - list.add("Volume: " + UnitDisplay.getDisplay(fluid.amount, Unit.LITER, UnitPrefix.MILLI)); + list.add("Volume: " + new UnitDisplay(Unit.LITER, fluid.amount)); } } } @@ -64,14 +65,14 @@ public class ItemBlockTank extends ItemBlock implements IFluidContainerItem @Override public String getUnlocalizedName(ItemStack itemStack) { - String translation = LanguageUtility.getLocal(Block.blocksList[this.getBlock()].getUnlocalizedName() + "." + itemStack.getItemDamage()); + String translation = LanguageUtility.getLocal(getUnlocalizedName() + "." + itemStack.getItemDamage()); if (translation == null || translation.isEmpty()) { - return Block.blocksList[this.getBlock()].getUnlocalizedName(); + return getUnlocalizedName(); } - return Block.blocksList[this.getBlock()].getUnlocalizedName() + "." + itemStack.getItemDamage(); + return getUnlocalizedName() + "." + itemStack.getItemDamage(); } @Override @@ -82,9 +83,7 @@ public class ItemBlockTank extends ItemBlock implements IFluidContainerItem TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof TileFluidDistribution) { - ((TileFluidDistribution) tile).setSubID(stack.getItemDamage()); - ((TileFluidDistribution) tile).getForwardTank().fill(getFluid(stack), true); - + ((TileFluidDistribution) tile).getForwardTank().fill(ForgeDirection.UNKNOWN, getFluid(stack), true); } return true; } diff --git a/src/main/scala/resonantinduction/archaic/fluid/tank/TileTank.java b/src/main/scala/resonantinduction/archaic/fluid/tank/TileTank.java index 63135fa86..4b3b01e09 100644 --- a/src/main/scala/resonantinduction/archaic/fluid/tank/TileTank.java +++ b/src/main/scala/resonantinduction/archaic/fluid/tank/TileTank.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.List; import archaic.Archaic; +import net.minecraft.block.material.Material; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -34,6 +35,7 @@ import resonantinduction.core.grid.fluid.distribution.TFluidDistributor; import resonantinduction.core.grid.fluid.distribution.TankGrid; import resonantinduction.core.grid.fluid.distribution.TileFluidDistribution; import universalelectricity.api.UniversalElectricity; +import universalelectricity.api.core.grid.INode; import universalelectricity.core.transform.vector.Vector3; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -49,20 +51,20 @@ public class TileTank extends TileFluidDistribution implements IComparatorInputO public TileTank() { - super(UniversalElectricity.machine, VOLUME * FluidContainerRegistry.BUCKET_VOLUME); - isOpaqueCube = false; - normalRender = false; - itemBlock = ItemBlockTank.class; + super(Material.iron, VOLUME * FluidContainerRegistry.BUCKET_VOLUME); + isOpaqueCube(false); + normalRender(false); + itemBlock(ItemBlockTank.class); } @Override public boolean shouldSideBeRendered(IBlockAccess access, int x, int y, int z, int side) { - return access != null && block != null && access.getBlockId(x, y, z) != block.blockID; + return access.getBlock(x, y, z) != getBlockType(); } @Override - protected boolean use(EntityPlayer player, int side, Vector3 vector3) + public boolean use(EntityPlayer player, int side, Vector3 vector3) { if (!world().isRemote) { @@ -204,7 +206,27 @@ public class TileTank extends TileFluidDistribution implements IComparatorInputO }; } - public static class ItemRenderer implements ISimpleItemRenderer + @Override + public FluidTank getTank() { + return null; + } + + @Override + public FluidTank tank() { + return null; + } + + @Override + public void tank_$eq(FluidTank tank) { + + } + + @Override + public INode getNode(Class nodeType, ForgeDirection from) { + return null; + } + + public static class ItemRenderer implements ISimpleItemRenderer { public static ItemRenderer instance = new ItemRenderer(); diff --git a/src/main/scala/resonantinduction/core/render/RenderImprintable.java b/src/main/scala/resonantinduction/core/render/RenderImprintable.java index ba64af14c..bf541f268 100644 --- a/src/main/scala/resonantinduction/core/render/RenderImprintable.java +++ b/src/main/scala/resonantinduction/core/render/RenderImprintable.java @@ -9,8 +9,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; import resonant.lib.render.RenderUtility; -import resonantinduction.archaic.filter.imprint.ItemImprint; -import resonantinduction.archaic.filter.imprint.TileFilterable; +import resonantinduction.archaic.blocks.ItemImprint; +import resonantinduction.archaic.blocks.TileFilterable; import universalelectricity.core.transform.vector.Vector3; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; diff --git a/src/main/scala/resonantinduction/mechanical/logistic/belt/TileDetector.java b/src/main/scala/resonantinduction/mechanical/logistic/belt/TileDetector.java index 38214a07b..0ec01b7ba 100644 --- a/src/main/scala/resonantinduction/mechanical/logistic/belt/TileDetector.java +++ b/src/main/scala/resonantinduction/mechanical/logistic/belt/TileDetector.java @@ -22,7 +22,7 @@ import resonant.engine.ResonantEngine; import resonant.lib.network.discriminator.PacketTile; import resonant.lib.network.discriminator.PacketType; import resonant.lib.network.handle.IPacketIDReceiver; -import resonantinduction.archaic.filter.imprint.TileFilterable; +import resonantinduction.archaic.blocks.TileFilterable; import resonantinduction.core.Reference; import resonantinduction.mechanical.Mechanical; diff --git a/src/main/scala/resonantinduction/mechanical/logistic/belt/TileRejector.java b/src/main/scala/resonantinduction/mechanical/logistic/belt/TileRejector.java index 69cba69f4..79dfeb989 100644 --- a/src/main/scala/resonantinduction/mechanical/logistic/belt/TileRejector.java +++ b/src/main/scala/resonantinduction/mechanical/logistic/belt/TileRejector.java @@ -17,7 +17,7 @@ import resonant.engine.ResonantEngine; import resonant.lib.network.discriminator.PacketTile; import resonant.lib.network.discriminator.PacketType; import resonant.lib.network.handle.IPacketIDReceiver; -import resonantinduction.archaic.filter.imprint.TileFilterable; +import resonantinduction.archaic.blocks.TileFilterable; import universalelectricity.core.transform.vector.Vector3; /** @author Darkguardsman */