mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
drone improvements part 1
fixed the dumb idiot logic that got it stuck all the time
This commit is contained in:
parent
bdbe821d9d
commit
543dd059af
@ -29,7 +29,7 @@ public abstract class EntityDroneBase extends Entity {
|
|||||||
|
|
||||||
public void setTarget(double x, double y, double z) {
|
public void setTarget(double x, double y, double z) {
|
||||||
this.targetX = x;
|
this.targetX = x;
|
||||||
this.targetY = y;
|
this.targetY = y + 1;
|
||||||
this.targetZ = z;
|
this.targetZ = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import net.minecraft.item.Item;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.Vec3;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
@ -61,78 +62,97 @@ public class EntityRequestDrone extends EntityDroneBase {
|
|||||||
} else if(next instanceof AStack && heldItem == null) {
|
} else if(next instanceof AStack && heldItem == null) {
|
||||||
|
|
||||||
AStack aStack = (AStack) next;
|
AStack aStack = (AStack) next;
|
||||||
TileEntity tile = worldObj.getTileEntity((int) Math.floor(posX), (int) Math.floor(posY - 1), (int) Math.floor(posZ));
|
//to make DAMN sure this fuckin idiot doesnt miss the dock
|
||||||
|
Vec3 pos = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
|
||||||
if(tile instanceof TileEntityDroneProvider) {
|
Vec3 nextPos = Vec3.createVectorHelper(this.posX, this.posY - 4, this.posZ);
|
||||||
TileEntityDroneProvider provider = (TileEntityDroneProvider) tile;
|
MovingObjectPosition mop = this.worldObj.rayTraceBlocks(pos, nextPos);
|
||||||
|
|
||||||
for(int i = 0; i < provider.slots.length; i++) {
|
if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||||
ItemStack stack = provider.slots[i];
|
|
||||||
|
TileEntity tile = worldObj.getTileEntity(mop.blockX, mop.blockY, mop.blockZ);
|
||||||
if(stack != null && aStack.matchesRecipe(stack, true)) {
|
if (tile instanceof TileEntityDroneProvider) {
|
||||||
this.heldItem = stack.copy();
|
TileEntityDroneProvider provider = (TileEntityDroneProvider) tile;
|
||||||
this.setAppearance(1);
|
|
||||||
worldObj.playSoundEffect(posX, posY, posZ, "hbm:item.unpack", 0.5F, 0.75F);
|
for (int i = 0; i < provider.slots.length; i++) {
|
||||||
provider.slots[i] = null;
|
ItemStack stack = provider.slots[i];
|
||||||
provider.markDirty();
|
|
||||||
break;
|
if (stack != null && aStack.matchesRecipe(stack, true)) {
|
||||||
|
this.heldItem = stack.copy();
|
||||||
|
this.setAppearance(1);
|
||||||
|
worldObj.playSoundEffect(posX, posY, posZ, "hbm:item.unpack", 0.5F, 0.75F);
|
||||||
|
provider.slots[i] = null;
|
||||||
|
provider.markDirty();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nextActionTimer = 5;
|
nextActionTimer = 5;
|
||||||
} else if(next == DroneProgram.UNLOAD && this.heldItem != null) {
|
} else if(next == DroneProgram.UNLOAD && this.heldItem != null) {
|
||||||
|
Vec3 pos = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
|
||||||
TileEntity tile = worldObj.getTileEntity((int) Math.floor(posX), (int) Math.floor(posY - 1), (int) Math.floor(posZ));
|
Vec3 nextPos = Vec3.createVectorHelper(this.posX, this.posY - 4, this.posZ);
|
||||||
if(tile instanceof TileEntityDroneRequester) {
|
MovingObjectPosition mop = this.worldObj.rayTraceBlocks(pos, nextPos);
|
||||||
TileEntityDroneRequester requester = (TileEntityDroneRequester) tile;
|
|
||||||
|
if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||||
for(int i = 9; i < 18; i++) {
|
|
||||||
ItemStack stack = requester.slots[i];
|
TileEntity tile = worldObj.getTileEntity(mop.blockX, mop.blockY, mop.blockZ);
|
||||||
if(stack != null && stack.getItem() == heldItem.getItem() && stack.getItemDamage() == heldItem.getItemDamage()) {
|
if (tile instanceof TileEntityDroneRequester) {
|
||||||
int toTransfer = Math.min(stack.getMaxStackSize() - stack.stackSize, heldItem.stackSize);
|
TileEntityDroneRequester requester = (TileEntityDroneRequester) tile;
|
||||||
requester.slots[i].stackSize += toTransfer;
|
|
||||||
this.heldItem.stackSize -= toTransfer;
|
for (int i = 9; i < 18; i++) {
|
||||||
|
ItemStack stack = requester.slots[i];
|
||||||
|
if (stack != null && stack.getItem() == heldItem.getItem() && stack.getItemDamage() == heldItem.getItemDamage()) {
|
||||||
|
int toTransfer = Math.min(stack.getMaxStackSize() - stack.stackSize, heldItem.stackSize);
|
||||||
|
requester.slots[i].stackSize += toTransfer;
|
||||||
|
this.heldItem.stackSize -= toTransfer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if (this.heldItem.stackSize <= 0) this.heldItem = null;
|
||||||
if(this.heldItem.stackSize <= 0) this.heldItem = null;
|
|
||||||
|
if (this.heldItem != null) for (int i = 9; i < 18; i++) {
|
||||||
if(this.heldItem != null) for(int i = 9; i < 18; i++) {
|
if (requester.slots[i] == null) {
|
||||||
if(requester.slots[i] == null) {
|
requester.slots[i] = this.heldItem.copy();
|
||||||
requester.slots[i] = this.heldItem.copy();
|
this.heldItem = null;
|
||||||
this.heldItem = null;
|
break;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.heldItem == null) {
|
||||||
|
this.setAppearance(0);
|
||||||
|
worldObj.playSoundEffect(posX, posY, posZ, "hbm:item.unpack", 0.5F, 0.75F);
|
||||||
|
}
|
||||||
|
|
||||||
|
requester.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.heldItem == null) {
|
|
||||||
this.setAppearance(0);
|
|
||||||
worldObj.playSoundEffect(posX, posY, posZ, "hbm:item.unpack", 0.5F, 0.75F);
|
|
||||||
}
|
|
||||||
|
|
||||||
requester.markDirty();
|
|
||||||
}
|
}
|
||||||
nextActionTimer = 5;
|
nextActionTimer = 5;
|
||||||
} else if(next == DroneProgram.DOCK) {
|
} else if(next == DroneProgram.DOCK) {
|
||||||
|
Vec3 pos = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
|
||||||
TileEntity tile = worldObj.getTileEntity((int) Math.floor(posX), (int) Math.floor(posY - 1), (int) Math.floor(posZ));
|
Vec3 nextPos = Vec3.createVectorHelper(this.posX, this.posY - 4, this.posZ);
|
||||||
if(tile instanceof TileEntityDroneDock) {
|
MovingObjectPosition mop = this.worldObj.rayTraceBlocks(pos, nextPos);
|
||||||
TileEntityDroneDock dock = (TileEntityDroneDock) tile;
|
|
||||||
|
if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||||
for(int i = 0; i < dock.slots.length; i++) {
|
|
||||||
if(dock.slots[i] == null) {
|
TileEntity tile = worldObj.getTileEntity(mop.blockX, mop.blockY, mop.blockZ);
|
||||||
this.setDead();
|
if (tile instanceof TileEntityDroneDock) {
|
||||||
dock.slots[i] = new ItemStack(ModItems.drone, 1, EnumDroneType.REQUEST.ordinal());
|
TileEntityDroneDock dock = (TileEntityDroneDock) tile;
|
||||||
this.worldObj.playSoundEffect(dock.xCoord + 0.5, dock.yCoord + 0.5, dock.zCoord + 0.5, "hbm:block.storageClose", 2.0F, 1.0F);
|
|
||||||
break;
|
for (int i = 0; i < dock.slots.length; i++) {
|
||||||
|
if (dock.slots[i] == null) {
|
||||||
|
this.setDead();
|
||||||
|
dock.slots[i] = new ItemStack(ModItems.drone, 1, EnumDroneType.REQUEST.ordinal());
|
||||||
|
this.worldObj.playSoundEffect(dock.xCoord + 0.5, dock.yCoord + 0.5, dock.zCoord + 0.5, "hbm:block.storageClose", 2.0F, 1.0F);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!this.isDead) {
|
||||||
if(!this.isDead) {
|
|
||||||
this.setDead();
|
this.setDead();
|
||||||
this.entityDropItem(new ItemStack(ModItems.drone, 1, EnumDroneType.REQUEST.ordinal()), 1F);
|
this.entityDropItem(new ItemStack(ModItems.drone, 1, EnumDroneType.REQUEST.ordinal()), 1F);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user