use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class ConveyorSplit method handleInsertion.
@Override
public void handleInsertion(TileEntity tile, EntityItem entity, EnumFacing facing, ConveyorDirection conDir, double distX, double distZ) {
String nbtKey = "immersiveengineering:conveyorDir" + Integer.toHexString(tile.getPos().hashCode());
if (entity.getEntityData().hasKey(nbtKey)) {
EnumFacing redirect = EnumFacing.values()[entity.getEntityData().getInteger(nbtKey)];
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));
if (distNext < .7)
super.handleInsertion(tile, entity, redirect, conDir, distX, distZ);
}
}
use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class MultiblockBlastFurnace method createStructure.
@Override
public boolean createStructure(World world, BlockPos pos, EnumFacing side, EntityPlayer player) {
EnumFacing f = EnumFacing.fromAngle(player.rotationYaw);
pos = pos.offset(f);
for (int h = -1; h <= 1; h++) for (int xx = -1; xx <= 1; xx++) for (int zz = -1; zz <= 1; zz++) {
if (!Utils.isBlockAt(world, pos.add(xx, h, zz), IEContent.blockStoneDecoration, BlockTypes_StoneDecoration.BLASTBRICK.getMeta()))
return false;
}
for (int h = -1; h <= 1; h++) for (int l = -1; l <= 1; l++) for (int w = -1; w <= 1; w++) {
int xx = f == EnumFacing.EAST ? l : f == EnumFacing.WEST ? -l : f == EnumFacing.NORTH ? -w : w;
int zz = f == EnumFacing.NORTH ? l : f == EnumFacing.SOUTH ? -l : f == EnumFacing.EAST ? w : -w;
BlockPos pos2 = pos.add(xx, h, zz);
world.setBlockState(pos2, IEContent.blockStoneDevice.getStateFromMeta(1));
TileEntity curr = world.getTileEntity(pos2);
if (curr instanceof TileEntityBlastFurnace) {
TileEntityBlastFurnace currBlast = (TileEntityBlastFurnace) curr;
currBlast.offset = new int[] { xx, h, zz };
currBlast.pos = (h + 1) * 9 + (l + 1) * 3 + (w + 1);
currBlast.facing = f.getOpposite();
currBlast.formed = true;
currBlast.markDirty();
world.addBlockEvent(pos2, IEContent.blockStoneDevice, 255, 0);
}
}
player.addStat(IEAchievements.blastfurnace);
return true;
}
use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class MultiblockCokeOven method createStructure.
@Override
public boolean createStructure(World world, BlockPos pos, EnumFacing side, EntityPlayer player) {
EnumFacing f = EnumFacing.fromAngle(player.rotationYaw);
pos = pos.offset(f);
for (int h = -1; h <= 1; h++) for (int xx = -1; xx <= 1; xx++) for (int zz = -1; zz <= 1; zz++) {
if (!Utils.isBlockAt(world, pos.add(xx, h, zz), IEContent.blockStoneDecoration, BlockTypes_StoneDecoration.COKEBRICK.getMeta()))
return false;
}
for (int h = -1; h <= 1; h++) for (int l = -1; l <= 1; l++) for (int w = -1; w <= 1; w++) {
int xx = f == EnumFacing.EAST ? l : f == EnumFacing.WEST ? -l : f == EnumFacing.NORTH ? -w : w;
int zz = f == EnumFacing.NORTH ? l : f == EnumFacing.SOUTH ? -l : f == EnumFacing.EAST ? w : -w;
world.setBlockState(pos.add(xx, h, zz), IEContent.blockStoneDevice.getStateFromMeta(0));
BlockPos pos2 = pos.add(xx, h, zz);
TileEntity curr = world.getTileEntity(pos2);
if (curr instanceof TileEntityCokeOven) {
TileEntityCokeOven currBlast = (TileEntityCokeOven) curr;
currBlast.offset = new int[] { xx, h, zz };
currBlast.pos = (h + 1) * 9 + (l + 1) * 3 + (w + 1);
currBlast.facing = f.getOpposite();
currBlast.formed = true;
currBlast.markDirty();
world.addBlockEvent(pos2, IEContent.blockStoneDevice, 255, 0);
}
}
return true;
}
use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class MultiblockSheetmetalTank method createStructure.
@Override
public boolean createStructure(World world, BlockPos pos, EnumFacing side, EntityPlayer player) {
EnumFacing f = EnumFacing.fromAngle(player.rotationYaw);
pos = pos.offset(f);
if (!(Utils.isOreBlockAt(world, pos.offset(f, -1).offset(f.rotateY()), "fenceTreatedWood") && Utils.isOreBlockAt(world, pos.offset(f, -1).offset(f.rotateYCCW()), "fenceTreatedWood")))
for (int i = 0; i < 4; i++) if (Utils.isOreBlockAt(world, pos.add(0, -i, 0).offset(f, -1).offset(f.rotateY()), "fenceTreatedWood") && Utils.isOreBlockAt(world, pos.add(0, -i, 0).offset(f, -1).offset(f.rotateYCCW()), "fenceTreatedWood")) {
pos = pos.add(0, -i, 0);
break;
}
for (int h = 0; h <= 4; h++) for (int xx = -1; xx <= 1; xx++) for (int zz = -1; zz <= 1; zz++) if (h == 0) {
if (Math.abs(xx) == 1 && Math.abs(zz) == 1) {
if (!Utils.isOreBlockAt(world, pos.add(xx, h, zz), "fenceTreatedWood"))
return false;
} else if (xx == 0 && zz == 0)
if (!Utils.isOreBlockAt(world, pos.add(xx, h, zz), "blockSheetmetalIron"))
return false;
} else {
if (h < 4 && xx == 0 && zz == 0) {
if (!world.isAirBlock(pos.add(xx, h, zz)))
return false;
} else if (!Utils.isOreBlockAt(world, pos.add(xx, h, zz), "blockSheetmetalIron"))
return false;
}
for (int h = 0; h <= 4; h++) for (int l = -1; l <= 1; l++) for (int w = -1; w <= 1; w++) {
if (h == 0 && !((l == 0 && w == 0) || (Math.abs(l) == 1 && Math.abs(w) == 1)))
continue;
if (h > 0 && h < 4 && l == 0 && w == 0)
continue;
int xx = f == EnumFacing.EAST ? l : f == EnumFacing.WEST ? -l : f == EnumFacing.NORTH ? -w : w;
int zz = f == EnumFacing.NORTH ? l : f == EnumFacing.SOUTH ? -l : f == EnumFacing.EAST ? w : -w;
world.setBlockState(pos.add(xx, h, zz), IEContent.blockMetalMultiblock.getStateFromMeta(BlockTypes_MetalMultiblock.TANK.getMeta()));
BlockPos pos2 = pos.add(xx, h, zz);
TileEntity curr = world.getTileEntity(pos2);
if (curr instanceof TileEntitySheetmetalTank) {
TileEntitySheetmetalTank currTank = (TileEntitySheetmetalTank) curr;
currTank.offset = new int[] { xx, h, zz };
currTank.pos = h * 9 + (l + 1) * 3 + (w + 1);
currTank.facing = f.getOpposite();
currTank.formed = true;
currTank.offset = new int[] { xx, h, zz };
currTank.markDirty();
world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0);
}
}
return true;
}
use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class MultiblockSilo method createStructure.
@Override
public boolean createStructure(World world, BlockPos pos, EnumFacing side, EntityPlayer player) {
EnumFacing f = EnumFacing.fromAngle(player.rotationYaw);
pos = pos.offset(f);
if (!(Utils.isOreBlockAt(world, pos.offset(f, -1).offset(f.rotateY()), "fenceTreatedWood") && Utils.isOreBlockAt(world, pos.offset(f, -1).offset(f.rotateYCCW()), "fenceTreatedWood")))
for (int i = 0; i < 6; i++) if (Utils.isOreBlockAt(world, pos.add(0, -i, 0).offset(f, -1).offset(f.rotateY()), "fenceTreatedWood") && Utils.isOreBlockAt(world, pos.add(0, -i, 0).offset(f, -1).offset(f.rotateYCCW()), "fenceTreatedWood")) {
pos = pos.add(0, -i, 0);
break;
}
for (int h = 0; h <= 6; h++) for (int xx = -1; xx <= 1; xx++) for (int zz = -1; zz <= 1; zz++) if (h == 0) {
if (Math.abs(xx) == 1 && Math.abs(zz) == 1) {
if (!Utils.isOreBlockAt(world, pos.add(xx, h, zz), "fenceTreatedWood"))
return false;
} else if (xx == 0 && zz == 0)
if (!Utils.isOreBlockAt(world, pos.add(xx, h, zz), "blockSheetmetalIron"))
return false;
} else {
if (h < 6 && xx == 0 && zz == 0) {
if (!world.isAirBlock(pos.add(xx, h, zz)))
return false;
} else if (!Utils.isOreBlockAt(world, pos.add(xx, h, zz), "blockSheetmetalIron"))
return false;
}
for (int h = 0; h <= 6; h++) for (int l = -1; l <= 1; l++) for (int w = -1; w <= 1; w++) {
if (h == 0 && !((l == 0 && w == 0) || (Math.abs(l) == 1 && Math.abs(w) == 1)))
continue;
if (h > 0 && h < 6 && l == 0 && w == 0)
continue;
int xx = f == EnumFacing.EAST ? l : f == EnumFacing.WEST ? -l : f == EnumFacing.NORTH ? -w : w;
int zz = f == EnumFacing.NORTH ? l : f == EnumFacing.SOUTH ? -l : f == EnumFacing.EAST ? w : -w;
world.setBlockState(pos.add(xx, h, zz), IEContent.blockMetalMultiblock.getStateFromMeta(BlockTypes_MetalMultiblock.SILO.getMeta()));
BlockPos pos2 = pos.add(xx, h, zz);
TileEntity curr = world.getTileEntity(pos2);
if (curr instanceof TileEntitySilo) {
TileEntitySilo currTank = (TileEntitySilo) curr;
currTank.offset = new int[] { xx, h, zz };
currTank.pos = h * 9 + (l + 1) * 3 + (w + 1);
currTank.facing = f.getOpposite();
currTank.formed = true;
currTank.offset = new int[] { xx, h, zz };
currTank.markDirty();
world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0);
}
}
player.addStat(IEAchievements.mbSilo);
return true;
}
Aggregations