mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
amazon warehouse employee machine
This commit is contained in:
parent
9ae1801e76
commit
521b040f63
@ -1,6 +1,9 @@
|
||||
package api.hbm.ntl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@ -27,11 +30,30 @@ public class StorageManifest {
|
||||
meta.metaNBT.put(stack.getItemDamage(), nbt);
|
||||
}
|
||||
|
||||
long amount = nbt.nbtAmount.containsKey(stack.stackTagCompound) ? nbt.nbtAmount.get(stack.stackTagCompound) : 0;
|
||||
NBTTagCompound compound = stack.hasTagCompound() ? (NBTTagCompound) stack.stackTagCompound.copy() : null;
|
||||
long amount = nbt.nbtAmount.containsKey(compound) ? nbt.nbtAmount.get(compound) : 0;
|
||||
|
||||
amount += stack.stackSize;
|
||||
|
||||
nbt.nbtAmount.put(stack.stackTagCompound, amount);
|
||||
nbt.nbtAmount.put(compound, amount);
|
||||
}
|
||||
|
||||
public List<StorageStack> getStacks() {
|
||||
List<StorageStack> stacks = new ArrayList();
|
||||
|
||||
for(Entry<Integer, MetaNode> itemNode : itemMeta.entrySet()) {
|
||||
for(Entry<Integer, NBTNode> metaNode : itemNode.getValue().metaNBT.entrySet()) {
|
||||
for(Entry<NBTTagCompound, Long> nbtNode : metaNode.getValue().nbtAmount.entrySet()) {
|
||||
|
||||
ItemStack itemStack = new ItemStack(Item.getItemById(itemNode.getKey()), 1, metaNode.getKey());
|
||||
itemStack.stackTagCompound = nbtNode.getKey();
|
||||
StorageStack stack = new StorageStack(itemStack, nbtNode.getValue());
|
||||
stacks.add(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return stacks;
|
||||
}
|
||||
|
||||
public class MetaNode {
|
||||
|
||||
@ -10,6 +10,8 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
@ -59,7 +61,14 @@ public class CraneBoxer extends BlockCraneBase implements IEnterableBlock {
|
||||
|
||||
@Override
|
||||
public void onItemEnter(World world, int x, int y, int z, ForgeDirection dir, IConveyorItem entity) {
|
||||
TileEntityCraneBoxer boxer = (TileEntityCraneBoxer) world.getTileEntity(x, y, z);
|
||||
|
||||
ItemStack remainder = CraneInserter.addToInventory(boxer, boxer.getAccessibleSlotsFromSide(dir.ordinal()), entity.getItemStack(), dir.ordinal());
|
||||
|
||||
if(remainder != null && remainder.stackSize > 0) {
|
||||
EntityItem drop = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, remainder.copy());
|
||||
world.spawnEntityInWorld(drop);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -10,6 +10,8 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
@ -61,11 +63,20 @@ public class CraneUnboxer extends BlockCraneBase implements IEnterableBlock {
|
||||
|
||||
@Override
|
||||
public boolean canPackageEnter(World world, int x, int y, int z, ForgeDirection dir, IConveyorPackage entity) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPackageEnter(World world, int x, int y, int z, ForgeDirection dir, IConveyorPackage entity) {
|
||||
TileEntityCraneUnboxer unboxer = (TileEntityCraneUnboxer) world.getTileEntity(x, y, z);
|
||||
|
||||
for(ItemStack stack : entity.getItemStacks()) {
|
||||
ItemStack remainder = CraneInserter.addToInventory(unboxer, unboxer.getAccessibleSlotsFromSide(dir.ordinal()), stack, dir.ordinal());
|
||||
|
||||
if(remainder != null && remainder.stackSize > 0) {
|
||||
EntityItem drop = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, remainder.copy());
|
||||
world.spawnEntityInWorld(drop);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,6 +171,7 @@ public class EntityMappings {
|
||||
addEntity(EntitySoyuz.class, "entity_soyuz", 1000);
|
||||
addEntity(EntitySoyuzCapsule.class, "entity_soyuz_capsule", 1000);
|
||||
addEntity(EntityMovingItem.class, "entity_c_item", 1000);
|
||||
addEntity(EntityMovingPackage.class, "entity_c_package", 1000);
|
||||
addEntity(EntityCloudTom.class, "entity_moonstone_blast", 1000);
|
||||
addEntity(EntityBeamVortex.class, "entity_vortex_beam", 1000);
|
||||
addEntity(EntityFireworks.class, "entity_firework_ball", 1000);
|
||||
|
||||
@ -0,0 +1,164 @@
|
||||
package com.hbm.entity.item;
|
||||
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
|
||||
import api.hbm.conveyor.IConveyorBelt;
|
||||
import api.hbm.conveyor.IEnterableBlock;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public abstract class EntityMovingConveyorObject extends Entity {
|
||||
|
||||
protected int turnProgress;
|
||||
protected double syncPosX;
|
||||
protected double syncPosY;
|
||||
protected double syncPosZ;
|
||||
@SideOnly(Side.CLIENT) protected double velocityX;
|
||||
@SideOnly(Side.CLIENT) protected double velocityY;
|
||||
@SideOnly(Side.CLIENT) protected double velocityZ;
|
||||
|
||||
public EntityMovingConveyorObject(World world) {
|
||||
super(world);
|
||||
this.noClip = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeCollidedWith() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAttackWithItem() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitByEntity(Entity attacker) {
|
||||
|
||||
if(attacker instanceof EntityPlayer) {
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canTriggerWalking() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
|
||||
if(worldObj.isRemote) {
|
||||
if(this.turnProgress > 0) {
|
||||
double interpX = this.posX + (this.syncPosX - this.posX) / (double) this.turnProgress;
|
||||
double interpY = this.posY + (this.syncPosY - this.posY) / (double) this.turnProgress;
|
||||
double interpZ = this.posZ + (this.syncPosZ - this.posZ) / (double) this.turnProgress;
|
||||
--this.turnProgress;
|
||||
this.setPosition(interpX, interpY, interpZ);
|
||||
} else {
|
||||
this.setPosition(this.posX, this.posY, this.posZ);
|
||||
}
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
int blockX = (int) Math.floor(posX);
|
||||
int blockY = (int) Math.floor(posY);
|
||||
int blockZ = (int) Math.floor(posZ);
|
||||
|
||||
Block b = worldObj.getBlock(blockX, blockY, blockZ);
|
||||
|
||||
if(!(b instanceof IConveyorBelt)) {
|
||||
|
||||
if(onLeaveConveyor()) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
||||
Vec3 target = ((IConveyorBelt) b).getTravelLocation(worldObj, blockX, blockY, blockZ, Vec3.createVectorHelper(posX, posY, posZ), getMoveSpeed());
|
||||
this.motionX = target.xCoord - posX;
|
||||
this.motionY = target.yCoord - posY;
|
||||
this.motionZ = target.zCoord - posZ;
|
||||
}
|
||||
|
||||
BlockPos lastPos = new BlockPos(posX, posY, posZ);
|
||||
this.moveEntity(motionX, motionY, motionZ);
|
||||
BlockPos newPos = new BlockPos(posX, posY, posZ);
|
||||
|
||||
if(!lastPos.equals(newPos)) {
|
||||
|
||||
Block newBlock = worldObj.getBlock(newPos.getX(), newPos.getY(), newPos.getZ());
|
||||
|
||||
if(newBlock instanceof IEnterableBlock) {
|
||||
|
||||
ForgeDirection dir = ForgeDirection.UNKNOWN;
|
||||
|
||||
if(lastPos.getX() > newPos.getX() && lastPos.getY() == newPos.getY() && lastPos.getZ() == newPos.getZ()) dir = Library.POS_X;
|
||||
else if(lastPos.getX() < newPos.getX() && lastPos.getY() == newPos.getY() && lastPos.getZ() == newPos.getZ()) dir = Library.NEG_X;
|
||||
else if(lastPos.getX() == newPos.getX() && lastPos.getY() > newPos.getY() && lastPos.getZ() == newPos.getZ()) dir = Library.POS_Y;
|
||||
else if(lastPos.getX() == newPos.getX() && lastPos.getY() < newPos.getY() && lastPos.getZ() == newPos.getZ()) dir = Library.NEG_Y;
|
||||
else if(lastPos.getX() == newPos.getX() && lastPos.getY() == newPos.getY() && lastPos.getZ() > newPos.getZ()) dir = Library.POS_Z;
|
||||
else if(lastPos.getX() == newPos.getX() && lastPos.getY() == newPos.getY() && lastPos.getZ() < newPos.getZ()) dir = Library.NEG_Z;
|
||||
|
||||
IEnterableBlock enterable = (IEnterableBlock) newBlock;
|
||||
enterBlock(enterable, newPos, dir);
|
||||
|
||||
} else {
|
||||
|
||||
if(!newBlock.getMaterial().isSolid()) {
|
||||
|
||||
newBlock = worldObj.getBlock(newPos.getX(), newPos.getY() - 1, newPos.getZ());
|
||||
|
||||
if(newBlock instanceof IEnterableBlock) {
|
||||
|
||||
IEnterableBlock enterable = (IEnterableBlock) newBlock;
|
||||
enterBlockFalling(enterable, newPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void enterBlock(IEnterableBlock enterable, BlockPos pos, ForgeDirection dir);
|
||||
|
||||
public void enterBlockFalling(IEnterableBlock enterable, BlockPos pos) {
|
||||
this.enterBlock(enterable, pos.add(0, -1, 0), ForgeDirection.UP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the update loop should end
|
||||
*/
|
||||
public abstract boolean onLeaveConveyor();
|
||||
|
||||
public double getMoveSpeed() {
|
||||
return 0.0625D;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void setVelocity(double motionX, double motionY, double motionZ) {
|
||||
this.velocityX = this.motionX = motionX;
|
||||
this.velocityY = this.motionY = motionY;
|
||||
this.velocityZ = this.motionZ = motionZ;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void setPositionAndRotation2(double x, double y, double z, float yaw, float pitch, int theNumberThree) {
|
||||
this.syncPosX = x;
|
||||
this.syncPosY = y;
|
||||
this.syncPosZ = z;
|
||||
this.turnProgress = theNumberThree + 2; //use 4-ply for extra smoothness
|
||||
this.motionX = this.velocityX;
|
||||
this.motionY = this.velocityY;
|
||||
this.motionZ = this.velocityZ;
|
||||
}
|
||||
}
|
||||
@ -1,42 +1,23 @@
|
||||
package com.hbm.entity.item;
|
||||
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
|
||||
import api.hbm.conveyor.IConveyorBelt;
|
||||
import api.hbm.conveyor.IConveyorItem;
|
||||
import api.hbm.conveyor.IEnterableBlock;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class EntityMovingItem extends Entity implements IConveyorItem {
|
||||
|
||||
private int turnProgress;
|
||||
private double syncPosX;
|
||||
private double syncPosY;
|
||||
private double syncPosZ;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private double velocityX;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private double velocityY;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private double velocityZ;
|
||||
public class EntityMovingItem extends EntityMovingConveyorObject implements IConveyorItem {
|
||||
|
||||
public EntityMovingItem(World p_i1582_1_) {
|
||||
super(p_i1582_1_);
|
||||
this.setSize(0.375F, 0.375F);
|
||||
this.noClip = true;
|
||||
}
|
||||
|
||||
public void setItemStack(ItemStack stack) {
|
||||
@ -44,16 +25,13 @@ public class EntityMovingItem extends Entity implements IConveyorItem {
|
||||
this.getDataWatcher().setObjectWatched(10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
|
||||
ItemStack stack = this.getDataWatcher().getWatchableObjectItemStack(10);
|
||||
return stack == null ? new ItemStack(Blocks.stone) : stack;
|
||||
}
|
||||
|
||||
public boolean canBeCollidedWith() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean interactFirst(EntityPlayer player) {
|
||||
|
||||
if(!worldObj.isRemote && player.inventory.addItemStackToInventory(this.getItemStack().copy())) {
|
||||
@ -63,6 +41,7 @@ public class EntityMovingItem extends Entity implements IConveyorItem {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
@ -72,156 +51,6 @@ public class EntityMovingItem extends Entity implements IConveyorItem {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canAttackWithItem() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hitByEntity(Entity attacker) {
|
||||
|
||||
if(attacker instanceof EntityPlayer) {
|
||||
}
|
||||
|
||||
this.setDead();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean canTriggerWalking() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private int schedule = 0;
|
||||
|
||||
public void onUpdate() {
|
||||
|
||||
if(worldObj.isRemote) {
|
||||
if(this.turnProgress > 0) {
|
||||
double interpX = this.posX + (this.syncPosX - this.posX) / (double) this.turnProgress;
|
||||
double interpY = this.posY + (this.syncPosY - this.posY) / (double) this.turnProgress;
|
||||
double interpZ = this.posZ + (this.syncPosZ - this.posZ) / (double) this.turnProgress;
|
||||
--this.turnProgress;
|
||||
this.setPosition(interpX, interpY, interpZ);
|
||||
} else {
|
||||
this.setPosition(this.posX, this.posY, this.posZ);
|
||||
}
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
int blockX = (int) Math.floor(posX);
|
||||
int blockY = (int) Math.floor(posY);
|
||||
int blockZ = (int) Math.floor(posZ);
|
||||
|
||||
Block b = worldObj.getBlock(blockX, blockY, blockZ);
|
||||
|
||||
if(!(b instanceof IConveyorBelt)) {
|
||||
this.setDead();
|
||||
EntityItem item = new EntityItem(worldObj, posX + motionX * 2, posY + motionY * 2, posZ + motionZ * 2, this.getItemStack());
|
||||
item.motionX = this.motionX * 2;
|
||||
item.motionY = 0.1;
|
||||
item.motionZ = this.motionZ * 2;
|
||||
item.velocityChanged = true;
|
||||
worldObj.spawnEntityInWorld(item);
|
||||
return;
|
||||
} else {
|
||||
|
||||
Vec3 target = ((IConveyorBelt) b).getTravelLocation(worldObj, blockX, blockY, blockZ, Vec3.createVectorHelper(posX, posY, posZ), 0.0625);
|
||||
//this.worldObj.spawnParticle("reddust", target.xCoord, target.yCoord, target.zCoord, 0, 0, 0);
|
||||
this.motionX = target.xCoord - posX;
|
||||
this.motionY = target.yCoord - posY;
|
||||
this.motionZ = target.zCoord - posZ;
|
||||
}
|
||||
|
||||
/*if(worldObj.getBlock((int) Math.floor(posX), (int) Math.floor(posY), (int) Math.floor(posZ)) == ModBlocks.conveyor) {
|
||||
|
||||
if(schedule <= 0) {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(worldObj.getBlockMetadata((int) Math.floor(posX), (int) Math.floor(posY), (int) Math.floor(posZ)));
|
||||
|
||||
if(worldObj.getBlock((int) Math.floor(posX), (int) Math.floor(posY) + 1, (int) Math.floor(posZ)) == ModBlocks.conveyor && motionY >= 0) {
|
||||
dir = ForgeDirection.DOWN;
|
||||
}
|
||||
|
||||
if(worldObj.getBlock((int) Math.floor(posX), (int) Math.floor(posY) - 1, (int) Math.floor(posZ)) == ModBlocks.conveyor && motionY <= 0) {
|
||||
dir = ForgeDirection.UP;
|
||||
}
|
||||
|
||||
double speed = 0.0625;
|
||||
|
||||
schedule = (int) (1 / speed);
|
||||
motionX = -speed * dir.offsetX;
|
||||
motionY = -speed * dir.offsetY;
|
||||
motionZ = -speed * dir.offsetZ;
|
||||
|
||||
this.velocityChanged = true;
|
||||
}
|
||||
|
||||
schedule--;
|
||||
}*/
|
||||
|
||||
BlockPos lastPos = new BlockPos(posX, posY, posZ);
|
||||
this.moveEntity(motionX, motionY, motionZ);
|
||||
BlockPos newPos = new BlockPos(posX, posY, posZ);
|
||||
|
||||
if(!lastPos.equals(newPos)) {
|
||||
|
||||
Block newBlock = worldObj.getBlock(newPos.getX(), newPos.getY(), newPos.getZ());
|
||||
|
||||
if(newBlock instanceof IEnterableBlock) {
|
||||
|
||||
ForgeDirection dir = ForgeDirection.UNKNOWN;
|
||||
|
||||
if(lastPos.getX() > newPos.getX() && lastPos.getY() == newPos.getY() && lastPos.getZ() == newPos.getZ()) dir = Library.POS_X;
|
||||
else if(lastPos.getX() < newPos.getX() && lastPos.getY() == newPos.getY() && lastPos.getZ() == newPos.getZ()) dir = Library.NEG_X;
|
||||
else if(lastPos.getX() == newPos.getX() && lastPos.getY() > newPos.getY() && lastPos.getZ() == newPos.getZ()) dir = Library.POS_Y;
|
||||
else if(lastPos.getX() == newPos.getX() && lastPos.getY() < newPos.getY() && lastPos.getZ() == newPos.getZ()) dir = Library.NEG_Y;
|
||||
else if(lastPos.getX() == newPos.getX() && lastPos.getY() == newPos.getY() && lastPos.getZ() > newPos.getZ()) dir = Library.POS_Z;
|
||||
else if(lastPos.getX() == newPos.getX() && lastPos.getY() == newPos.getY() && lastPos.getZ() < newPos.getZ()) dir = Library.NEG_Z;
|
||||
|
||||
IEnterableBlock enterable = (IEnterableBlock) newBlock;
|
||||
|
||||
if(enterable.canItemEnter(worldObj, newPos.getX(), newPos.getY(), newPos.getZ(), dir, this)) {
|
||||
|
||||
enterable.onItemEnter(worldObj, newPos.getX(), newPos.getY(), newPos.getZ(), dir, this);
|
||||
this.setDead();
|
||||
}
|
||||
} else {
|
||||
|
||||
if(!newBlock.getMaterial().isSolid()) {
|
||||
|
||||
newBlock = worldObj.getBlock(newPos.getX(), newPos.getY() - 1, newPos.getZ());
|
||||
|
||||
if(newBlock instanceof IEnterableBlock) {
|
||||
|
||||
IEnterableBlock enterable = (IEnterableBlock) newBlock;
|
||||
if(enterable.canItemEnter(worldObj, newPos.getX(), newPos.getY() - 1, newPos.getZ(), ForgeDirection.UP, this)) {
|
||||
enterable.onItemEnter(worldObj, newPos.getX(), newPos.getY() - 1, newPos.getZ(), ForgeDirection.UP, this);
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void setVelocity(double p_70016_1_, double p_70016_3_, double p_70016_5_) {
|
||||
this.velocityX = this.motionX = p_70016_1_;
|
||||
this.velocityY = this.motionY = p_70016_3_;
|
||||
this.velocityZ = this.motionZ = p_70016_5_;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void setPositionAndRotation2(double x, double y, double z, float yaw, float pitch, int theNumberThree) {
|
||||
this.syncPosX = x;
|
||||
this.syncPosY = y;
|
||||
this.syncPosZ = z;
|
||||
this.turnProgress = theNumberThree + 2; //use 4-ply for extra smoothness
|
||||
this.motionX = this.velocityX;
|
||||
this.motionY = this.velocityY;
|
||||
this.motionZ = this.velocityZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
this.getDataWatcher().addObjectByDataType(10, 5);
|
||||
@ -235,8 +64,6 @@ public class EntityMovingItem extends Entity implements IConveyorItem {
|
||||
|
||||
ItemStack stack = getDataWatcher().getWatchableObjectItemStack(10);
|
||||
|
||||
schedule = nbt.getInteger("schedule");
|
||||
|
||||
if(stack == null || stack.stackSize <= 0)
|
||||
this.setDead();
|
||||
}
|
||||
@ -246,7 +73,28 @@ public class EntityMovingItem extends Entity implements IConveyorItem {
|
||||
|
||||
if(this.getItemStack() != null)
|
||||
nbt.setTag("Item", this.getItemStack().writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
nbt.setInteger("schedule", schedule);
|
||||
@Override
|
||||
public void enterBlock(IEnterableBlock enterable, BlockPos pos, ForgeDirection dir) {
|
||||
|
||||
if(enterable.canItemEnter(worldObj, pos.getX(), pos.getY(), pos.getZ(), dir, this)) {
|
||||
enterable.onItemEnter(worldObj, pos.getX(), pos.getY(), pos.getZ(), dir, this);
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLeaveConveyor() {
|
||||
|
||||
this.setDead();
|
||||
EntityItem item = new EntityItem(worldObj, posX + motionX * 2, posY + motionY * 2, posZ + motionZ * 2, this.getItemStack());
|
||||
item.motionX = this.motionX * 2;
|
||||
item.motionY = 0.1;
|
||||
item.motionZ = this.motionZ * 2;
|
||||
item.velocityChanged = true;
|
||||
worldObj.spawnEntityInWorld(item);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
93
src/main/java/com/hbm/entity/item/EntityMovingPackage.java
Normal file
93
src/main/java/com/hbm/entity/item/EntityMovingPackage.java
Normal file
@ -0,0 +1,93 @@
|
||||
package com.hbm.entity.item;
|
||||
|
||||
import com.hbm.util.ItemStackUtil;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
|
||||
import api.hbm.conveyor.IConveyorPackage;
|
||||
import api.hbm.conveyor.IEnterableBlock;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class EntityMovingPackage extends EntityMovingConveyorObject implements IConveyorPackage {
|
||||
|
||||
protected ItemStack[] contents = new ItemStack[0];
|
||||
|
||||
public EntityMovingPackage(World world) {
|
||||
super(world);
|
||||
this.setSize(0.5F, 0.5F);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit() { }
|
||||
|
||||
public void setItemStacks(ItemStack[] stacks) {
|
||||
this.contents = ItemStackUtil.carefulCopyArray(stacks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacks() {
|
||||
return contents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterBlock(IEnterableBlock enterable, BlockPos pos, ForgeDirection dir) {
|
||||
|
||||
if(enterable.canPackageEnter(worldObj, pos.getX(), pos.getY(), pos.getZ(), dir, this)) {
|
||||
enterable.onPackageEnter(worldObj, pos.getX(), pos.getY(), pos.getZ(), dir, this);
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLeaveConveyor() {
|
||||
|
||||
this.setDead();
|
||||
|
||||
for(ItemStack stack : contents) {
|
||||
EntityItem item = new EntityItem(worldObj, posX + motionX * 2, posY + motionY * 2, posZ + motionZ * 2, stack);
|
||||
item.motionX = this.motionX * 2;
|
||||
item.motionY = 0.1;
|
||||
item.motionZ = this.motionZ * 2;
|
||||
item.velocityChanged = true;
|
||||
worldObj.spawnEntityInWorld(item);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(NBTTagCompound nbt) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
|
||||
for(int i = 0; i < this.contents.length; ++i) {
|
||||
if(this.contents[i] != null) {
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
nbttagcompound1.setByte("slot", (byte) i);
|
||||
this.contents[i].writeToNBT(nbttagcompound1);
|
||||
nbttaglist.appendTag(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
|
||||
nbt.setTag("contents", nbttaglist);
|
||||
nbt.setInteger("count", this.contents.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound nbt) {
|
||||
this.contents = new ItemStack[nbt.getInteger("count")];
|
||||
NBTTagList nbttaglist = nbt.getTagList("contents", 10);
|
||||
|
||||
for(int i = 0; i < nbttaglist.tagCount(); ++i) {
|
||||
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
|
||||
int j = nbttagcompound1.getByte("slot") & 255;
|
||||
|
||||
if(j >= 0 && j < this.contents.length) {
|
||||
this.contents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -657,6 +657,7 @@ public class ClientProxy extends ServerProxy {
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityMagnusCartus.class, new RenderMagnusCartus());
|
||||
//items
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityMovingItem.class, new RenderMovingItem());
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityMovingPackage.class, new RenderMovingPackage());
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityTNTPrimedBase.class, new RenderTNTPrimedBase());
|
||||
//mobs
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityNuclearCreeper.class, new RenderNuclearCreeper());
|
||||
|
||||
@ -49,5 +49,4 @@ public class RenderMovingItem extends Render {
|
||||
protected ResourceLocation getEntityTexture(Entity p_110775_1_) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
package com.hbm.render.entity.item;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class RenderMovingPackage extends Render {
|
||||
|
||||
private ItemStack dummy;
|
||||
|
||||
@Override
|
||||
public void doRender(Entity entity, double x, double y, double z, float f1, float f2) {
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x, y, z);
|
||||
|
||||
Random rand = new Random(entity.getEntityId());
|
||||
GL11.glTranslated(0, rand.nextDouble() * 0.0625, 0);
|
||||
|
||||
if(this.dummy == null) {
|
||||
this.dummy = new ItemStack(ModBlocks.crate);
|
||||
}
|
||||
|
||||
EntityItem dummy = new EntityItem(entity.worldObj, 0, 0, 0, this.dummy);
|
||||
dummy.hoverStart = 0.0F;
|
||||
|
||||
RenderItem.renderInFrame = true;
|
||||
double scale = 8D / 6D;
|
||||
GL11.glScaled(scale, scale, scale);
|
||||
RenderManager.instance.renderEntityWithPosYaw(dummy, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
|
||||
RenderItem.renderInFrame = false;
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(Entity p_110775_1_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -1,18 +1,33 @@
|
||||
package com.hbm.tileentity.network;
|
||||
|
||||
import com.hbm.entity.item.EntityMovingItem;
|
||||
import com.hbm.entity.item.EntityMovingPackage;
|
||||
import com.hbm.inventory.container.ContainerCraneBoxer;
|
||||
import com.hbm.inventory.gui.GUICraneBoxer;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
|
||||
import api.hbm.conveyor.IConveyorBelt;
|
||||
import api.hbm.ntl.StorageManifest;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
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.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityCraneBoxer extends TileEntityMachineBase implements IGUIProvider {
|
||||
|
||||
public byte mode = 0;
|
||||
public static final byte MODE_4 = 0;
|
||||
public static final byte MODE_8 = 1;
|
||||
public static final byte MODE_16 = 2;
|
||||
public static final byte MODE_REDSTONE = 3;
|
||||
|
||||
|
||||
public TileEntityCraneBoxer() {
|
||||
super(7 * 3);
|
||||
@ -26,6 +41,72 @@ public class TileEntityCraneBoxer extends TileEntityMachineBase implements IGUIP
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote && mode != MODE_REDSTONE && worldObj.getTotalWorldTime() % 20 == 0) {
|
||||
int pack = 1;
|
||||
|
||||
switch(mode) {
|
||||
case MODE_4: pack = 4; break;
|
||||
case MODE_8: pack = 8; break;
|
||||
case MODE_16: pack = 16; break;
|
||||
}
|
||||
|
||||
int fullStacks = 0;
|
||||
|
||||
// NO!
|
||||
/*StorageManifest manifest = new StorageManifest(); //i wrote some of this for a feature that i scrapped so why not make proper use of it?
|
||||
|
||||
for(int i = 0; i < slots.length; i++) {
|
||||
if(slots[i] != null) {
|
||||
manifest.writeStack(slots[i]);
|
||||
}
|
||||
}*/
|
||||
|
||||
for(int i = 0; i < slots.length; i++) {
|
||||
|
||||
if(slots[i] != null && slots[i].stackSize == slots[i].getMaxStackSize()) {
|
||||
fullStacks++;
|
||||
}
|
||||
}
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata());
|
||||
Block b = worldObj.getBlock(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
|
||||
IConveyorBelt belt = null;
|
||||
|
||||
if(b instanceof IConveyorBelt) {
|
||||
belt = (IConveyorBelt) b;
|
||||
}
|
||||
|
||||
if(belt != null && fullStacks >= pack) {
|
||||
|
||||
ItemStack[] box = new ItemStack[pack];
|
||||
|
||||
for(int i = 0; i < slots.length && pack > 0; i++) {
|
||||
|
||||
if(slots[i] != null && slots[i].stackSize == slots[i].getMaxStackSize()) {
|
||||
pack--;
|
||||
box[pack] = slots[i].copy();
|
||||
slots[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
EntityMovingPackage moving = new EntityMovingPackage(worldObj);
|
||||
Vec3 pos = Vec3.createVectorHelper(xCoord + 0.5 + dir.offsetX * 0.55, yCoord + 0.5 + dir.offsetY * 0.55, zCoord + 0.5 + dir.offsetZ * 0.55);
|
||||
Vec3 snap = belt.getClosestSnappingPosition(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, pos);
|
||||
moving.setPosition(snap.xCoord, snap.yCoord, snap.zCoord);
|
||||
moving.setItemStacks(box);
|
||||
worldObj.spawnEntityInWorld(moving);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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, 18, 19, 20 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemStack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,7 +1,32 @@
|
||||
package com.hbm.tileentity.network;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
|
||||
public class TileEntityCraneUnboxer extends TileEntity {
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class TileEntityCraneUnboxer extends TileEntityMachineBase {
|
||||
|
||||
public TileEntityCraneUnboxer() {
|
||||
super(7 * 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "container.craneUnboxer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
}
|
||||
|
||||
@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, 18, 19, 20 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemStack) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,8 @@
|
||||
package com.hbm.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.inventory.RecipesCommon.ComparableStack;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
@ -26,6 +26,10 @@ public class BlockPos {
|
||||
this((int)MathHelper.floor_double(x), (int)MathHelper.floor_double(y), (int)MathHelper.floor_double(z));
|
||||
}
|
||||
|
||||
public BlockPos add(int x, int y, int z) {
|
||||
return x == 0 && y == 0 && z == 0 ? this : new BlockPos(this.getX() + x, this.getY() + y, this.getZ() + z);
|
||||
}
|
||||
|
||||
public BlockPos add(double x, double y, double z) {
|
||||
return x == 0.0D && y == 0.0D && z == 0.0D ? this : new BlockPos((double) this.getX() + x, (double) this.getY() + y, (double) this.getZ() + z);
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
Loading…
x
Reference in New Issue
Block a user