use of blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorTile in project ImmersiveEngineering by BluSunrize.
the class ConveyorSplit method onEntityCollision.
@Override
public void onEntityCollision(TileEntity tile, Entity entity, EnumFacing facing) {
if (!isActive(tile))
return;
EnumFacing redirect = null;
if (entity != null && !entity.isDead) {
String nbtKey = "immersiveengineering:conveyorDir" + Integer.toHexString(tile.getPos().hashCode());
if (entity.getEntityData().hasKey(nbtKey))
redirect = EnumFacing.values()[entity.getEntityData().getInteger(nbtKey)];
else {
redirect = this.outputFace;
entity.getEntityData().setInteger(nbtKey, redirect.ordinal());
BlockPos nextPos = tile.getPos().offset(this.outputFace.getOpposite());
if (tile.getWorld().isBlockLoaded(nextPos)) {
TileEntity nextTile = tile.getWorld().getTileEntity(nextPos);
if (!(nextTile instanceof IConveyorTile))
this.outputFace = outputFace.getOpposite();
else if (((IConveyorTile) nextTile).getFacing() != this.outputFace)
this.outputFace = outputFace.getOpposite();
}
}
}
super.onEntityCollision(tile, entity, facing);
if (redirect != null) {
String nbtKey = "immersiveengineering:conveyorDir" + Integer.toHexString(tile.getPos().hashCode());
BlockPos nextPos = tile.getPos().offset(redirect);
double distNext = Math.abs((redirect.getAxis() == Axis.Z ? nextPos.getZ() : nextPos.getX()) + .5 - (redirect.getAxis() == Axis.Z ? entity.posZ : entity.posX));
double treshold = .4;
boolean contact = distNext < treshold;
if (contact)
entity.getEntityData().removeTag(nbtKey);
}
}
use of blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorTile in project ImmersiveEngineering by BluSunrize.
the class ConveyorVertical method isInwardConveyor.
protected boolean isInwardConveyor(TileEntity tile, EnumFacing f) {
TileEntity te = tile.getWorld().getTileEntity(tile.getPos().offset(f));
if (te instanceof IConveyorTile) {
IConveyorBelt sub = ((IConveyorTile) te).getConveyorSubtype();
if (sub != null)
for (EnumFacing f2 : sub.sigTransportDirections(te, ((IConveyorTile) te).getFacing())) if (f2 == EnumFacing.UP)
break;
else if (f == f2.getOpposite())
return true;
}
te = tile.getWorld().getTileEntity(tile.getPos().add(0, -1, 0).offset(f));
if (te instanceof IConveyorTile) {
IConveyorBelt sub = ((IConveyorTile) te).getConveyorSubtype();
if (sub != null) {
int b = 0;
for (EnumFacing f2 : sub.sigTransportDirections(te, ((IConveyorTile) te).getFacing())) {
if (f == f2.getOpposite())
b++;
else if (EnumFacing.UP == f2)
b++;
if (b == 2)
return true;
}
}
}
return false;
}
use of blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorTile in project ImmersiveEngineering by BluSunrize.
the class ConveyorDrop method handleInsertion.
@Override
public void handleInsertion(TileEntity tile, EntityItem entity, EnumFacing facing, ConveyorDirection conDir, double distX, double distZ) {
BlockPos posDown = tile.getPos().down();
TileEntity inventoryTile = tile.getWorld().getTileEntity(posDown);
boolean contact = Math.abs(facing.getAxis() == Axis.Z ? (tile.getPos().getZ() + .5 - entity.posZ) : (tile.getPos().getX() + .5 - entity.posX)) < .2;
if (contact && inventoryTile != null && !(inventoryTile instanceof IConveyorTile)) {
if (!tile.getWorld().isRemote) {
ItemStack stack = entity.getItem();
if (!stack.isEmpty()) {
ItemStack ret = ApiUtils.insertStackIntoInventory(inventoryTile, stack, EnumFacing.UP);
if (ret.isEmpty())
entity.setDead();
else if (ret.getCount() < stack.getCount())
entity.setItem(ret);
}
}
} else if (contact && isEmptySpace(tile.getWorld(), posDown, inventoryTile)) {
entity.motionX = 0;
entity.motionZ = 0;
entity.setPosition(tile.getPos().getX() + .5, tile.getPos().getY() - .5, tile.getPos().getZ() + .5);
if (!(inventoryTile instanceof IConveyorTile))
ConveyorHandler.revertMagnetSupression(entity, (IConveyorTile) tile);
} else
super.handleInsertion(tile, entity, facing, conDir, distX, distZ);
}
use of blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorTile in project ImmersiveEngineering by BluSunrize.
the class EnderIOHelper method init.
@Override
public void init() {
ChemthrowerHandler.registerEffect("nutrient_distillation", new ChemthrowerEffect_Potion(null, 0, MobEffects.NAUSEA, 80, 1));
ChemthrowerHandler.registerEffect("liquid_sunshine", new ChemthrowerEffect_Potion(null, 0, new PotionEffect(MobEffects.GLOWING, 200, 0), new PotionEffect(MobEffects.LEVITATION, 40, 0)));
ChemthrowerHandler.registerEffect("cloud_seed_concentrated", new ChemthrowerEffect_Potion(null, 0, MobEffects.BLINDNESS, 40, 0));
ChemthrowerHandler.registerEffect("vapor_of_levity", new ChemthrowerEffect_Potion(null, 0, MobEffects.LEVITATION, 80, 2));
ConveyorHandler.registerMagnetSupression(new BiConsumer<Entity, IConveyorTile>() {
@Override
public void accept(Entity entity, IConveyorTile iConveyorTile) {
if (entity instanceof EntityItem) {
NBTTagCompound data = entity.getEntityData();
long pos = ((TileEntity) iConveyorTile).getPos().toLong();
if (!data.hasKey(EIO_MAGNET_NBT) || data.getLong(EIO_MAGNET_NBT) != pos)
data.setLong(EIO_MAGNET_NBT, pos);
}
}
}, new BiConsumer<Entity, IConveyorTile>() {
@Override
public void accept(Entity entity, IConveyorTile iConveyorTile) {
if (entity instanceof EntityItem)
entity.getEntityData().removeTag(EIO_MAGNET_NBT);
}
});
}
Aggregations