use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class TileEntityRazorWire method outputEnergy.
@Override
public int outputEnergy(int amount, boolean simulate, int energyType) {
if (amount > 0) {
if (!simulate) {
int maxReach = amount / 8;
int widthP = 0;
boolean connectP = true;
int widthN = 0;
boolean connectN = true;
EnumFacing dir = facing.rotateY();
if (dir.getAxisDirection() == AxisDirection.NEGATIVE)
dir = dir.getOpposite();
for (int i = 1; i <= maxReach; i++) {
BlockPos posP = getPos().offset(dir, i);
if (connectP && worldObj.isBlockLoaded(posP) && worldObj.getTileEntity(posP) instanceof TileEntityRazorWire)
widthP++;
else
connectP = false;
BlockPos posN = getPos().offset(dir, -i);
if (connectN && worldObj.isBlockLoaded(posN) && worldObj.getTileEntity(posN) instanceof TileEntityRazorWire)
widthN++;
else
connectN = false;
}
AxisAlignedBB aabb = new AxisAlignedBB(getPos().add(facing.getAxis() == Axis.Z ? -widthN : 0, 0, facing.getAxis() == Axis.X ? -widthN : 0), getPos().add(facing.getAxis() == Axis.Z ? 1 + widthP : 1, 1, facing.getAxis() == Axis.X ? 1 + widthP : 1));
List<EntityLivingBase> entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, aabb);
for (EntityLivingBase ent : entities) ent.attackEntityFrom(IEDamageSources.razorShock, 2);
}
return 64;
}
return 0;
}
use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class TileEntityRazorWire method renderWall.
private boolean renderWall(boolean left) {
EnumFacing dir = left ? facing.rotateY() : facing.rotateYCCW();
BlockPos neighbourPos = getPos().offset(dir, -1);
if (!worldObj.isBlockLoaded(neighbourPos))
return true;
if (worldObj.getTileEntity(neighbourPos) instanceof TileEntityRazorWire)
return false;
IBlockState neighbour = worldObj.getBlockState(neighbourPos);
return !neighbour.isSideSolid(worldObj, neighbourPos, dir);
}
use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class TileEntityRefinery method getAdvancedSelectionBounds.
@Override
public List<AxisAlignedBB> getAdvancedSelectionBounds() {
EnumFacing fl = facing;
EnumFacing fw = facing.rotateY();
if (mirrored)
fw = fw.getOpposite();
if (pos == 0 || pos == 4 || pos == 10 || pos == 14) {
List<AxisAlignedBB> list = Lists.newArrayList(new AxisAlignedBB(0, 0, 0, 1, .5f, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
if (pos >= 10)
fl = fl.getOpposite();
if (pos % 10 == 0)
fw = fw.getOpposite();
float minX = fl == EnumFacing.WEST ? 0 : fl == EnumFacing.EAST ? .75f : fw == EnumFacing.WEST ? .5f : .25f;
float maxX = fl == EnumFacing.EAST ? 1 : fl == EnumFacing.WEST ? .25f : fw == EnumFacing.EAST ? .5f : .75f;
float minZ = fl == EnumFacing.NORTH ? 0 : fl == EnumFacing.SOUTH ? .75f : fw == EnumFacing.NORTH ? .5f : .25f;
float maxZ = fl == EnumFacing.SOUTH ? 1 : fl == EnumFacing.NORTH ? .25f : fw == EnumFacing.SOUTH ? .5f : .75f;
list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1.375f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
if (pos == 4) {
minX = fl == EnumFacing.WEST ? .625f : fl == EnumFacing.EAST ? .125f : .125f;
maxX = fl == EnumFacing.EAST ? .375f : fl == EnumFacing.WEST ? .875f : .25f;
minZ = fl == EnumFacing.NORTH ? .625f : fl == EnumFacing.SOUTH ? .125f : .125f;
maxZ = fl == EnumFacing.SOUTH ? .375f : fl == EnumFacing.NORTH ? .875f : .25f;
list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
minX = fl == EnumFacing.WEST ? .625f : fl == EnumFacing.EAST ? .125f : .75f;
maxX = fl == EnumFacing.EAST ? .375f : fl == EnumFacing.WEST ? .875f : .875f;
minZ = fl == EnumFacing.NORTH ? .625f : fl == EnumFacing.SOUTH ? .125f : .75f;
maxZ = fl == EnumFacing.SOUTH ? .375f : fl == EnumFacing.NORTH ? .875f : .875f;
list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
}
return list;
}
if (pos == 1 || pos == 3 || pos == 11 || pos == 13) {
List<AxisAlignedBB> list = Lists.newArrayList(new AxisAlignedBB(0, 0, 0, 1, .0f, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
if (pos >= 10)
fl = fl.getOpposite();
if (pos % 10 == 1)
fw = fw.getOpposite();
float minX = fl == EnumFacing.WEST ? 0 : fl == EnumFacing.EAST ? .75f : fw == EnumFacing.WEST ? .75f : 0;
float maxX = fl == EnumFacing.EAST ? 1 : fl == EnumFacing.WEST ? .25f : fw == EnumFacing.EAST ? .25f : 1;
float minZ = fl == EnumFacing.NORTH ? 0 : fl == EnumFacing.SOUTH ? .75f : fw == EnumFacing.NORTH ? .75f : 0;
float maxZ = fl == EnumFacing.SOUTH ? 1 : fl == EnumFacing.NORTH ? .25f : fw == EnumFacing.SOUTH ? .25f : 1;
list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1.375f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
return list;
}
if ((pos == 20 || pos == 24 || pos == 25 || pos == 29) || (pos == 35 || pos == 39 || pos == 40 || pos == 44)) {
List<AxisAlignedBB> list = Lists.newArrayList();
if (pos % 5 == 4)
fw = fw.getOpposite();
float minX = fl == EnumFacing.WEST ? -.25f : fl == EnumFacing.EAST ? -.25f : fw == EnumFacing.WEST ? -1f : .5f;
float maxX = fl == EnumFacing.EAST ? 1.25f : fl == EnumFacing.WEST ? 1.25f : fw == EnumFacing.EAST ? 2 : .5f;
float minZ = fl == EnumFacing.NORTH ? -.25f : fl == EnumFacing.SOUTH ? -.25f : fw == EnumFacing.NORTH ? -1f : .5f;
float maxZ = fl == EnumFacing.SOUTH ? 1.25f : fl == EnumFacing.NORTH ? 1.25f : fw == EnumFacing.SOUTH ? 2 : .5f;
float minY = pos < 35 ? .5f : -.5f;
float maxY = pos < 35 ? 2f : 1f;
if (pos % 15 >= 10) {
minX += fl == EnumFacing.WEST ? 1 : fl == EnumFacing.EAST ? -1 : 0;
maxX += fl == EnumFacing.WEST ? 1 : fl == EnumFacing.EAST ? -1 : 0;
minZ += fl == EnumFacing.NORTH ? 1 : fl == EnumFacing.SOUTH ? -1 : 0;
maxZ += fl == EnumFacing.NORTH ? 1 : fl == EnumFacing.SOUTH ? -1 : 0;
}
list.add(new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
return list;
}
if ((pos == 21 || pos == 23 || pos == 26 || pos == 28) || (pos == 36 || pos == 38 || pos == 41 || pos == 43)) {
List<AxisAlignedBB> list = Lists.newArrayList();
if (pos % 5 == 3)
fw = fw.getOpposite();
float minX = fl == EnumFacing.WEST ? -.25f : fl == EnumFacing.EAST ? -.25f : fw == EnumFacing.WEST ? 0f : -.5f;
float maxX = fl == EnumFacing.EAST ? 1.25f : fl == EnumFacing.WEST ? 1.25f : fw == EnumFacing.EAST ? 1f : 1.5f;
float minZ = fl == EnumFacing.NORTH ? -.25f : fl == EnumFacing.SOUTH ? -.25f : fw == EnumFacing.NORTH ? 0 : -.5f;
float maxZ = fl == EnumFacing.SOUTH ? 1.25f : fl == EnumFacing.NORTH ? 1.25f : fw == EnumFacing.SOUTH ? 1f : 1.5f;
float minY = pos < 35 ? .5f : -.5f;
float maxY = pos < 35 ? 2f : 1f;
if (pos % 15 >= 10) {
minX += fl == EnumFacing.WEST ? 1 : fl == EnumFacing.EAST ? -1 : 0;
maxX += fl == EnumFacing.WEST ? 1 : fl == EnumFacing.EAST ? -1 : 0;
minZ += fl == EnumFacing.NORTH ? 1 : fl == EnumFacing.SOUTH ? -1 : 0;
maxZ += fl == EnumFacing.NORTH ? 1 : fl == EnumFacing.SOUTH ? -1 : 0;
}
list.add(new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
return list;
}
return null;
}
use of net.minecraft.util.EnumFacing in project NetherEx by LogicTechCorp.
the class BlockEnokiMushroomCap method canSurvive.
public boolean canSurvive(World world, BlockPos pos) {
IBlockState stateUp = world.getBlockState(pos.up());
Block blockUp = stateUp.getBlock();
if (blockUp != NetherExBlocks.PLANT_MUSHROOM_ENOKI_STEM && stateUp != NetherExBlocks.BLOCK_NETHERRACK.getDefaultState().withProperty(BlockNetherrack.TYPE, BlockNetherrack.EnumType.LIVELY)) {
if (stateUp.getMaterial() == Material.AIR) {
int i = 0;
for (EnumFacing facing : EnumFacing.Plane.HORIZONTAL) {
IBlockState stateSide = world.getBlockState(pos.offset(facing));
Block blockSide = stateSide.getBlock();
if (blockSide == NetherExBlocks.PLANT_MUSHROOM_ENOKI_STEM) {
i++;
} else if (stateSide.getMaterial() != Material.AIR) {
return false;
}
}
return i == 1;
} else {
return false;
}
} else {
return true;
}
}
use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class CapabilityShader method register.
public static void register() {
CapabilityManager.INSTANCE.register(ShaderWrapper.class, new Capability.IStorage<ShaderWrapper>() {
@Override
public NBTBase writeNBT(Capability<ShaderWrapper> capability, ShaderWrapper instance, EnumFacing side) {
NBTTagCompound nbt = new NBTTagCompound();
ItemStack shader = instance.getShaderItem();
if (shader != null)
shader.writeToNBT(nbt);
else
nbt.setString("IE:NoShader", "");
nbt.setString("IE:ShaderType", instance.getShaderType());
return nbt;
}
@Override
public void readNBT(Capability<ShaderWrapper> capability, ShaderWrapper instance, EnumFacing side, NBTBase nbt) {
NBTTagCompound tags = (NBTTagCompound) nbt;
instance.setShaderType(tags.getString("IE:ShaderType"));
if (!tags.hasKey("IE:NoShader"))
instance.setShaderItem(ItemStack.loadItemStackFromNBT(tags));
}
}, new Callable<ShaderWrapper>() {
@Override
public ShaderWrapper call() throws Exception {
return new ShaderWrapper_Direct("");
}
});
}
Aggregations