diff --git a/src/main/java/com/hbm/blocks/network/DroneCrate.java b/src/main/java/com/hbm/blocks/network/DroneCrate.java index 02180bfbd..bd82c8d20 100644 --- a/src/main/java/com/hbm/blocks/network/DroneCrate.java +++ b/src/main/java/com/hbm/blocks/network/DroneCrate.java @@ -7,9 +7,11 @@ import java.util.Random; import com.hbm.blocks.ILookOverlay; import com.hbm.blocks.ITooltipProvider; import com.hbm.lib.RefStrings; +import com.hbm.main.MainRegistry; import com.hbm.tileentity.network.TileEntityDroneCrate; import com.hbm.util.I18nUtil; +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; @@ -54,6 +56,18 @@ public class DroneCrate extends BlockContainer implements ILookOverlay, ITooltip public IIcon getIcon(int side, int metadata) { return side == 1 ? this.iconTop : (side == 0 ? this.iconBottom : this.blockIcon); } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + if(world.isRemote) { + return true; + } else if(!player.isSneaking()) { + FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z); + return true; + } else { + return false; + } + } @Override public void breakBlock(World world, int x, int y, int z, Block block, int meta) { diff --git a/src/main/java/com/hbm/entity/item/EntityDeliveryDrone.java b/src/main/java/com/hbm/entity/item/EntityDeliveryDrone.java index f8b50012d..d63dd43d3 100644 --- a/src/main/java/com/hbm/entity/item/EntityDeliveryDrone.java +++ b/src/main/java/com/hbm/entity/item/EntityDeliveryDrone.java @@ -1,14 +1,20 @@ package com.hbm.entity.item; +import com.hbm.inventory.FluidStack; +import com.hbm.inventory.fluid.Fluids; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.util.Vec3; import net.minecraft.world.World; -public class EntityDeliveryDrone extends Entity { +public class EntityDeliveryDrone extends Entity implements IInventory { protected int turnProgress; protected double syncPosX; @@ -17,6 +23,9 @@ public class EntityDeliveryDrone extends Entity { @SideOnly(Side.CLIENT) protected double velocityX; @SideOnly(Side.CLIENT) protected double velocityY; @SideOnly(Side.CLIENT) protected double velocityZ; + + protected ItemStack[] slots = new ItemStack[this.getSizeInventory()]; + public FluidStack fluid; public double targetX = -1; public double targetY = -1; @@ -60,7 +69,20 @@ public class EntityDeliveryDrone extends Entity { @Override protected void entityInit() { - this.dataWatcher.addObject(10, new Integer(0)); + this.dataWatcher.addObject(10, new Byte((byte) 0)); + } + + /** + * 0: Empty
+ * 1: Crate
+ * 2: Barrel
+ */ + public void setAppearance(int style) { + this.dataWatcher.updateObject(10, (byte) style); + } + + public int getAppearance() { + return this.dataWatcher.getWatchableObjectByte(10); } @Override @@ -107,15 +129,57 @@ public class EntityDeliveryDrone extends Entity { public double getSpeed() { return 0.125D; } - + @Override - protected void readEntityFromNBT(NBTTagCompound p_70037_1_) { + protected void writeEntityToNBT(NBTTagCompound nbt) { + + nbt.setDouble("tX", targetX); + nbt.setDouble("tY", targetY); + nbt.setDouble("tZ", targetZ); + NBTTagList nbttaglist = new NBTTagList(); + + for(int i = 0; i < this.slots.length; ++i) { + if(this.slots[i] != null) { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setByte("Slot", (byte) i); + this.slots[i].writeToNBT(nbttagcompound1); + nbttaglist.appendTag(nbttagcompound1); + } + } + + nbt.setTag("Items", nbttaglist); + + if(fluid != null) { + nbt.setString("fluidType", fluid.type.getUnlocalizedName()); + nbt.setInteger("fluidAmount", fluid.fill); + } } @Override - protected void writeEntityToNBT(NBTTagCompound p_70014_1_) { + protected void readEntityFromNBT(NBTTagCompound nbt) { + + if(nbt.hasKey("tY")) { + this.targetX = nbt.getDouble("tX"); + this.targetY = nbt.getDouble("tY"); + this.targetZ = nbt.getDouble("tZ"); + } + NBTTagList nbttaglist = nbt.getTagList("Items", 10); + this.slots = new ItemStack[this.getSizeInventory()]; + + for(int i = 0; i < nbttaglist.tagCount(); ++i) { + NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); + int j = nbttagcompound1.getByte("Slot") & 255; + + if(j >= 0 && j < this.slots.length) { + this.slots[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); + } + } + + if(nbt.hasKey("fluidType")) { + this.fluid = new FluidStack(Fluids.fromName(nbt.getString("fluidType")), nbt.getInteger("fluidAmount")); + } } @SideOnly(Side.CLIENT) @@ -135,4 +199,63 @@ public class EntityDeliveryDrone extends Entity { this.motionY = this.velocityY; this.motionZ = this.velocityZ; } + + @Override + public ItemStack getStackInSlot(int slot) { + return slots[slot]; + } + + @Override + public ItemStack decrStackSize(int slot, int amount) { + if(this.slots[slot] != null) { + ItemStack itemstack; + + if(this.slots[slot].stackSize <= amount) { + itemstack = this.slots[slot]; + this.slots[slot] = null; + return itemstack; + } else { + itemstack = this.slots[slot].splitStack(amount); + + if(this.slots[slot].stackSize == 0) { + this.slots[slot] = null; + } + + return itemstack; + } + } else { + return null; + } + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + if(this.slots[slot] != null) { + ItemStack itemstack = this.slots[slot]; + this.slots[slot] = null; + return itemstack; + } else { + return null; + } + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) { + this.slots[slot] = stack; + + if(stack != null && stack.stackSize > this.getInventoryStackLimit()) { + stack.stackSize = this.getInventoryStackLimit(); + } + } + + @Override public int getSizeInventory() { return 18; } + @Override public String getInventoryName() { return "container.drone"; } + @Override public int getInventoryStackLimit() { return 64; } + @Override public boolean hasCustomInventoryName() { return false; } + @Override public boolean isUseableByPlayer(EntityPlayer player) { return false; } + @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { return false; } + + @Override public void markDirty() { } + @Override public void openInventory() { } + @Override public void closeInventory() { } } diff --git a/src/main/java/com/hbm/inventory/container/ContainerDroneCrate.java b/src/main/java/com/hbm/inventory/container/ContainerDroneCrate.java new file mode 100644 index 000000000..cf9338763 --- /dev/null +++ b/src/main/java/com/hbm/inventory/container/ContainerDroneCrate.java @@ -0,0 +1,79 @@ +package com.hbm.inventory.container; + +import com.hbm.items.machine.IItemFluidIdentifier; +import com.hbm.tileentity.network.TileEntityDroneCrate; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class ContainerDroneCrate extends Container { + + protected TileEntityDroneCrate crate; + + public ContainerDroneCrate(InventoryPlayer invPlayer, TileEntityDroneCrate inserter) { + this.crate = inserter; + + for(int i = 0; i < 3; i++) { + for(int j = 0; j < 6; j++) { + this.addSlotToContainer(new Slot(inserter, j + i * 6, 8 + j * 18, 17 + i * 18)); + } + } + + this.addSlotToContainer(new Slot(inserter, 18, 125, 53)); + + for(int i = 0; i < 3; i++) { + for(int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 103 + i * 18)); + } + } + + for(int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 161)); + } + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { + ItemStack var3 = null; + Slot var4 = (Slot) this.inventorySlots.get(slot); + + if(var4 != null && var4.getHasStack()) { + ItemStack var5 = var4.getStack(); + var3 = var5.copy(); + + if(slot <= crate.getSizeInventory() - 1) { + if(!this.mergeItemStack(var5, crate.getSizeInventory(), this.inventorySlots.size(), true)) { + return null; + } + } else { + + if(var3.getItem() instanceof IItemFluidIdentifier) { + if(!this.mergeItemStack(var5, 18, 19, false)) + return null; + } else if(!this.mergeItemStack(var5, 0, 18, false)) { + return null; + } + + return null; + } + + if(var5.stackSize == 0) { + var4.putStack((ItemStack) null); + } else { + var4.onSlotChanged(); + } + + var4.onPickupFromSlot(player, var5); + } + + return var3; + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + return crate.isUseableByPlayer(player); + } +} diff --git a/src/main/java/com/hbm/inventory/gui/GUIDroneCrate.java b/src/main/java/com/hbm/inventory/gui/GUIDroneCrate.java new file mode 100644 index 000000000..cd99405b4 --- /dev/null +++ b/src/main/java/com/hbm/inventory/gui/GUIDroneCrate.java @@ -0,0 +1,75 @@ +package com.hbm.inventory.gui; + +import org.lwjgl.opengl.GL11; + +import com.hbm.inventory.container.ContainerDroneCrate; +import com.hbm.lib.RefStrings; +import com.hbm.packet.NBTControlPacket; +import com.hbm.packet.PacketDispatcher; +import com.hbm.tileentity.network.TileEntityDroneCrate; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; + +public class GUIDroneCrate extends GuiInfoContainer { + + private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/storage/gui_crate_drone.png"); + private TileEntityDroneCrate crate; + + public GUIDroneCrate(InventoryPlayer invPlayer, TileEntityDroneCrate crate) { + super(new ContainerDroneCrate(invPlayer, crate)); + this.crate = crate; + + this.xSize = 176; + this.ySize = 185; + } + + @Override + public void drawScreen(int x, int y, float interp) { + super.drawScreen(x, y, interp); + + crate.tank.renderTankInfo(this, x, y, guiLeft + 125, guiTop + 17, 16, 34); + } + + @Override + protected void mouseClicked(int x, int y, int i) { + super.mouseClicked(x, y, i); + + String op = null; + + // Toggle type + if(guiLeft + 151 <= x && guiLeft + 151 + 18 > x && guiTop + 16 < y && guiTop + 16 + 18 >= y) op = "type"; + // Toggle mode + if(guiLeft + 151 <= x && guiLeft + 151 + 18 > x && guiTop + 52 < y && guiTop + 52 + 18 >= y) op = "mode"; + + if(op != null) { + mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); + NBTTagCompound data = new NBTTagCompound(); + data.setBoolean(op, true); + PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, crate.xCoord, crate.yCoord, crate.zCoord)); + } + } + + @Override + protected void drawGuiContainerForegroundLayer(int i, int j) { + String name = this.crate.hasCustomInventoryName() ? this.crate.getInventoryName() : I18n.format(this.crate.getInventoryName()); + this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752); + this.fontRendererObj.drawString(I18n.format("container.inventory"), 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); + + drawTexturedModalRect(guiLeft + 151, guiTop + 16, 194, crate.itemType ? 0 : 18, 18, 18); + drawTexturedModalRect(guiLeft + 151, guiTop + 52, 176, crate.sendingMode ? 18 : 0, 18, 18); + + crate.tank.renderTank(guiLeft + 125, guiTop + 51, this.zLevel, 16, 34); + } +} diff --git a/src/main/java/com/hbm/render/item/RenderDeliveryDrone.java b/src/main/java/com/hbm/render/entity/item/RenderDeliveryDrone.java similarity index 55% rename from src/main/java/com/hbm/render/item/RenderDeliveryDrone.java rename to src/main/java/com/hbm/render/entity/item/RenderDeliveryDrone.java index d84b1de01..0c7434688 100644 --- a/src/main/java/com/hbm/render/item/RenderDeliveryDrone.java +++ b/src/main/java/com/hbm/render/entity/item/RenderDeliveryDrone.java @@ -1,7 +1,8 @@ -package com.hbm.render.item; +package com.hbm.render.entity.item; import org.lwjgl.opengl.GL11; +import com.hbm.entity.item.EntityDeliveryDrone; import com.hbm.main.ResourceManager; import net.minecraft.client.renderer.entity.Render; @@ -16,17 +17,25 @@ public class RenderDeliveryDrone extends Render { GL11.glPushMatrix(); GL11.glTranslated(x, y, z); + GL11.glDisable(GL11.GL_CULL_FACE); GL11.glShadeModel(GL11.GL_SMOOTH); bindTexture(ResourceManager.delivery_drone_tex); ResourceManager.delivery_drone.renderPart("Drone"); - ResourceManager.delivery_drone.renderPart("Barrel"); + + EntityDeliveryDrone drone = (EntityDeliveryDrone) entity; + int style = drone.getAppearance(); + + if(style == 1) ResourceManager.delivery_drone.renderPart("Crate"); + if(style == 2) ResourceManager.delivery_drone.renderPart("Barrel"); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glEnable(GL11.GL_CULL_FACE); GL11.glPopMatrix(); } @Override - protected ResourceLocation getEntityTexture(Entity p_110775_1_) { - return null; + protected ResourceLocation getEntityTexture(Entity drone) { + return ResourceManager.delivery_drone_tex; } } diff --git a/src/main/java/com/hbm/tileentity/network/TileEntityDroneCrate.java b/src/main/java/com/hbm/tileentity/network/TileEntityDroneCrate.java index 1fbad4f7d..5512fe3ab 100644 --- a/src/main/java/com/hbm/tileentity/network/TileEntityDroneCrate.java +++ b/src/main/java/com/hbm/tileentity/network/TileEntityDroneCrate.java @@ -3,29 +3,44 @@ package com.hbm.tileentity.network; import java.util.List; import com.hbm.entity.item.EntityDeliveryDrone; +import com.hbm.interfaces.IControlReceiver; +import com.hbm.inventory.FluidStack; +import com.hbm.inventory.container.ContainerDroneCrate; +import com.hbm.inventory.fluid.Fluids; +import com.hbm.inventory.fluid.tank.FluidTank; +import com.hbm.inventory.gui.GUIDroneCrate; import com.hbm.tileentity.IGUIProvider; import com.hbm.tileentity.INBTPacketReceiver; import com.hbm.tileentity.TileEntityMachineBase; import com.hbm.util.fauxpointtwelve.BlockPos; +import api.hbm.fluid.IFluidStandardTransceiver; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.Vec3; import net.minecraft.world.World; -public class TileEntityDroneCrate extends TileEntityMachineBase implements IGUIProvider, INBTPacketReceiver, IDroneLinkable { +public class TileEntityDroneCrate extends TileEntityMachineBase implements IGUIProvider, INBTPacketReceiver, IControlReceiver, IDroneLinkable, IFluidStandardTransceiver { + + public FluidTank tank; public int nextX = -1; public int nextY = -1; public int nextZ = -1; + + public boolean sendingMode = false; + public boolean itemType = true; public TileEntityDroneCrate() { super(19); + this.tank = new FluidTank(Fluids.NONE, 64_000); } @Override @@ -38,22 +53,141 @@ public class TileEntityDroneCrate extends TileEntityMachineBase implements IGUIP if(!worldObj.isRemote) { + this.tank.setType(18, slots); + + if(sendingMode && !itemType && worldObj.getTotalWorldTime() % 20 == 0) { + this.subscribeToAllAround(tank.getTankType(), this); + } + + if(!sendingMode && !itemType && worldObj.getTotalWorldTime() % 20 == 0) { + this.sendFluidToAll(tank, this); + } + if(nextY != -1) { List drones = worldObj.getEntitiesWithinAABB(EntityDeliveryDrone.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1)); for(EntityDeliveryDrone drone : drones) { if(Vec3.createVectorHelper(drone.motionX, drone.motionY, drone.motionZ).lengthVector() < 0.05) { drone.setTarget(nextX + 0.5, nextY, nextZ + 0.5); + + if(sendingMode && itemType) loadItems(drone); + if(!sendingMode && itemType) unloadItems(drone); + if(sendingMode && !itemType) loadFluid(drone); + if(!sendingMode && !itemType) unloadFluid(drone); } } } NBTTagCompound data = new NBTTagCompound(); data.setIntArray("pos", new int[] {nextX, nextY, nextZ}); + data.setBoolean("mode", sendingMode); + data.setBoolean("type", itemType); + tank.writeToNBT(data, "t"); INBTPacketReceiver.networkPack(this, data, 25); } } + @Override + public void networkUnpack(NBTTagCompound nbt) { + int[] pos = nbt.getIntArray("pos"); + this.nextX = pos[0]; + this.nextY = pos[1]; + this.nextZ = pos[2]; + this.sendingMode = nbt.getBoolean("mode"); + this.itemType = nbt.getBoolean("type"); + tank.readFromNBT(nbt, "t"); + } + + protected void loadItems(EntityDeliveryDrone drone) { + + if(drone.getAppearance() != 0) return; + + boolean loaded = false; + + for(int i = 0; i < 18; i++) { + if(this.slots[i] != null) { + loaded = true; + drone.setInventorySlotContents(i, this.slots[i].copy()); + this.slots[i] = null; + } + } + + if(loaded) { + this.markDirty(); + drone.setAppearance(1); + } + } + + protected void unloadItems(EntityDeliveryDrone drone) { + + if(drone.getAppearance() != 1) return; + + boolean emptied = true; + + for(int i = 0; i < 18; i++) { + ItemStack droneSlot = drone.getStackInSlot(i); + + if(this.slots[i] == null && droneSlot != null) { + this.slots[i] = droneSlot.copy(); + drone.setInventorySlotContents(i, null); + } else if(this.slots[i] != null && droneSlot != null) { + emptied = false; + } + } + + this.markDirty(); + + if(emptied) drone.setAppearance(0); + } + + protected void loadFluid(EntityDeliveryDrone drone) { + + if(drone.getAppearance() != 0) return; + + if(this.tank.getFill() > 0) { + drone.fluid = new FluidStack(tank.getTankType(), tank.getFill()); + this.tank.setFill(0); + drone.setAppearance(2); + + this.markDirty(); + } + } + + protected void unloadFluid(EntityDeliveryDrone drone) { + + if(drone.getAppearance() != 2) return; + + if(drone.fluid != null && drone.fluid.type == tank.getTankType()) { + + if(drone.fluid.fill + tank.getFill() <= tank.getMaxFill()) { + tank.setFill(tank.getFill() + drone.fluid.fill); + drone.fluid = null; + drone.setAppearance(0); + } else { + int overshoot = drone.fluid.fill + tank.getFill() - tank.getMaxFill(); + tank.setFill(tank.getMaxFill()); + drone.fluid.fill = overshoot; + } + + this.markDirty(); + } + } + + @Override + public int[] getAccessibleSlotsFromSide(int p_94128_1_) { + return new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }; + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemStack) { + return true; + } + + @Override + public boolean canExtractItem(int i, ItemStack itemStack, int j) { + return true; + } + @Override public BlockPos getPoint() { return new BlockPos(xCoord, yCoord + 1, zCoord); @@ -66,23 +200,72 @@ public class TileEntityDroneCrate extends TileEntityMachineBase implements IGUIP this.nextZ = z; this.markDirty(); } - + @Override - public void networkUnpack(NBTTagCompound nbt) { + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + int[] pos = nbt.getIntArray("pos"); this.nextX = pos[0]; this.nextY = pos[1]; this.nextZ = pos[2]; + this.sendingMode = nbt.getBoolean("mode"); + this.itemType = nbt.getBoolean("type"); + tank.readFromNBT(nbt, "t"); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + + nbt.setIntArray("pos", new int[] {nextX, nextY, nextZ}); + nbt.setBoolean("mode", sendingMode); + nbt.setBoolean("type", itemType); + tank.writeToNBT(nbt, "t"); } @Override public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { - return null; + return new ContainerDroneCrate(player.inventory, this); } @Override @SideOnly(Side.CLIENT) public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { - return null; + return new GUIDroneCrate(player.inventory, this); + } + + @Override + public boolean hasPermission(EntityPlayer player) { + return this.isUseableByPlayer(player); + } + + @Override + public void receiveControl(NBTTagCompound data) { + + if(data.hasKey("mode")) { + this.sendingMode = !this.sendingMode; + this.markChanged(); + } + + if(data.hasKey("type")) { + this.itemType = !this.itemType; + this.markChanged(); + } + } + + @Override + public FluidTank[] getAllTanks() { + return new FluidTank[] { tank }; + } + + @Override + public FluidTank[] getSendingTanks() { + return !sendingMode && !itemType ? new FluidTank[] { tank } : new FluidTank[0]; + } + + @Override + public FluidTank[] getReceivingTanks() { + return sendingMode && !itemType ? new FluidTank[] { tank } : new FluidTank[0]; } } diff --git a/src/main/java/com/hbm/tileentity/network/TileEntityDroneWaypoint.java b/src/main/java/com/hbm/tileentity/network/TileEntityDroneWaypoint.java index 8476fef96..99cddf18f 100644 --- a/src/main/java/com/hbm/tileentity/network/TileEntityDroneWaypoint.java +++ b/src/main/java/com/hbm/tileentity/network/TileEntityDroneWaypoint.java @@ -47,15 +47,6 @@ public class TileEntityDroneWaypoint extends TileEntity implements INBTPacketRec double z = zCoord + height * dir.offsetZ + 0.5; worldObj.spawnParticle("reddust", x, y, z, 0, 0, 0); - - /*Vec3 vec = Vec3.createVectorHelper(nextX + 0.5 - x, nextY + 0.5 - y, nextZ + 0.5 - z); - double speed = Math.min(vec.lengthVector(), 0.5); - double mX = vec.xCoord * speed; - double mY = vec.yCoord * speed; - double mZ = vec.zCoord * speed; - vec = vec.normalize(); - - worldObj.spawnParticle("crit", x, y, z, mX, mY, mZ);*/ } } } @@ -87,4 +78,21 @@ public class TileEntityDroneWaypoint extends TileEntity implements INBTPacketRec height += h; height = MathHelper.clamp_int(height, 1, 15); } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + + int[] pos = nbt.getIntArray("pos"); + this.nextX = pos[0]; + this.nextY = pos[1]; + this.nextZ = pos[2]; + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + + nbt.setIntArray("pos", new int[] {nextX, nextY, nextZ}); + } } diff --git a/src/main/resources/assets/hbm/textures/items/delivery_drone.png b/src/main/resources/assets/hbm/textures/items/delivery_drone.png new file mode 100644 index 000000000..a1bd3424a Binary files /dev/null and b/src/main/resources/assets/hbm/textures/items/delivery_drone.png differ