use of lumien.randomthings.lib.EntityFilterItemStack in project Random-Things by lumien231.
the class TileEntityFilteredRedirectorPlate method onInventoryChanged.
@Override
public void onInventoryChanged(IInventory inventory) {
ItemStack f1 = inventory.getStackInSlot(0);
ItemStack f2 = inventory.getStackInSlot(1);
if (!f1.isEmpty() && f1.getItem() instanceof IEntityFilterItem) {
filter[0] = new EntityFilterItemStack(f1, (IEntityFilterItem) f1.getItem());
} else {
filter[0] = null;
}
if (!f2.isEmpty() && f2.getItem() instanceof IEntityFilterItem) {
filter[1] = new EntityFilterItemStack(f2, (IEntityFilterItem) f2.getItem());
} else {
filter[1] = null;
}
if (!reading) {
this.syncTE();
}
}
use of lumien.randomthings.lib.EntityFilterItemStack in project Random-Things by lumien231.
the class BlockFilteredRedirectorPlate method onEntityCollidedWithBlock.
@Override
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
super.onEntityCollidedWithBlock(worldIn, pos, state, entityIn);
Vec3d motionVec = new Vec3d(entityIn.motionX, entityIn.motionY, entityIn.motionZ);
EnumFacing roughMovingFacing = EnumFacing.getFacingFromVector((float) motionVec.x, (float) motionVec.y, (float) motionVec.z).getOpposite();
Vec3d center = new Vec3d(pos).addVector(0.5, 0, 0.5);
Vec3d difVec = center.subtract(entityIn.getPositionVector());
EnumFacing facing = EnumFacing.getFacingFromVector((float) difVec.x, (float) difVec.y, (float) difVec.z).getOpposite();
EnumFacing inputSide = state.getValue(INPUT_FACING);
if ((facing == inputSide || facing == inputSide.getOpposite()) && facing == roughMovingFacing) {
TileEntityFilteredRedirectorPlate te = (TileEntityFilteredRedirectorPlate) worldIn.getTileEntity(pos);
EntityFilterItemStack[] filter = te.getFilter();
EnumFacing output = facing.getOpposite();
if (filter[0] != null) {
if (filter[0].apply(entityIn)) {
output = inputSide.rotateY();
}
}
if (filter[1] != null) {
if (filter[1].apply(entityIn)) {
output = inputSide.rotateYCCW();
}
}
Vec3d facingVec = new Vec3d(output.getDirectionVec()).scale(0.4).add(center);
float dif = facing.getOpposite().getHorizontalAngle() - output.getHorizontalAngle();
Vec3d outputMotionVec = motionVec.rotateYaw((float) Math.toRadians(dif));
entityIn.setPosition(facingVec.x, facingVec.y, facingVec.z);
entityIn.motionX = outputMotionVec.x;
entityIn.motionY = outputMotionVec.y;
entityIn.motionZ = outputMotionVec.z;
}
}
Aggregations