use of net.minecraft.util.EnumFacing in project MorePlanets by SteveKunG.
the class BlockCheeseSporeChest method getLockableContainer.
@Override
public ILockableContainer getLockableContainer(World world, BlockPos pos) {
TileEntity tileentity = world.getTileEntity(pos);
if (!(tileentity instanceof TileEntityCheeseSporeChest)) {
return null;
} else {
Object object = tileentity;
if (this.isBlocked(world, pos)) {
return null;
} else {
Iterator iterator = EnumFacing.Plane.HORIZONTAL.iterator();
while (iterator.hasNext()) {
EnumFacing enumfacing = (EnumFacing) iterator.next();
BlockPos blockpos1 = pos.offset(enumfacing);
Block block = world.getBlockState(blockpos1).getBlock();
if (block == this) {
if (this.isBlocked(world, blockpos1)) {
return null;
}
TileEntity tileentity1 = world.getTileEntity(blockpos1);
if (tileentity1 instanceof TileEntityCheeseSporeChest) {
if (enumfacing != EnumFacing.WEST && enumfacing != EnumFacing.NORTH) {
object = new InventoryLargeChest(GCCoreUtil.translate("container.chestDouble"), (ILockableContainer) object, (TileEntityCheeseSporeChest) tileentity1);
} else {
object = new InventoryLargeChest(GCCoreUtil.translate("container.chestDouble"), (TileEntityCheeseSporeChest) tileentity1, (ILockableContainer) object);
}
}
}
}
return (ILockableContainer) object;
}
}
}
use of net.minecraft.util.EnumFacing in project MorePlanets by SteveKunG.
the class WorldGenSpaceDungeons method generate.
@Override
public boolean generate(World world, Random rand, BlockPos pos) {
int i = rand.nextInt(2) + 2;
int j = -i - 1;
int k = i + 1;
int l = rand.nextInt(2) + 2;
int i1 = -l - 1;
int j1 = l + 1;
int k1 = 0;
int l1;
int i2;
int j2;
BlockPos blockpos1;
for (l1 = j; l1 <= k; ++l1) {
for (i2 = -1; i2 <= 4; ++i2) {
for (j2 = i1; j2 <= j1; ++j2) {
blockpos1 = pos.add(l1, i2, j2);
Material material = world.getBlockState(blockpos1).getMaterial();
boolean flag3 = material.isSolid();
if (i2 == -1 && !flag3) {
return false;
}
if (i2 == 4 && !flag3) {
return false;
}
if ((l1 == j || l1 == k || j2 == i1 || j2 == j1) && i2 == 0 && world.isAirBlock(blockpos1) && world.isAirBlock(blockpos1.up())) {
++k1;
}
}
}
}
if (k1 >= 1 && k1 <= 5) {
for (l1 = j; l1 <= k; ++l1) {
for (i2 = 3; i2 >= -1; --i2) {
for (j2 = i1; j2 <= j1; ++j2) {
blockpos1 = pos.add(l1, i2, j2);
if (l1 != j && i2 != -1 && j2 != i1 && l1 != k && i2 != 4 && j2 != j1) {
if (world.getBlockState(blockpos1).getBlock() != this.chest) {
world.setBlockToAir(blockpos1);
}
} else if (blockpos1.getY() >= 0 && !world.getBlockState(blockpos1.down()).getMaterial().isSolid()) {
world.setBlockToAir(blockpos1);
} else if (world.getBlockState(blockpos1).getMaterial().isSolid() && world.getBlockState(blockpos1).getBlock() != this.chest) {
if (i2 == -1 && rand.nextInt(4) != 0) {
world.setBlockState(blockpos1, this.moss.getStateFromMeta(this.mossMeta), 2);
} else {
world.setBlockState(blockpos1, this.cobblestone.getStateFromMeta(this.cobbleMeta), 2);
}
}
}
}
}
l1 = 0;
while (l1 < 2) {
i2 = 0;
while (true) {
if (i2 < 3) {
label100: {
j2 = pos.getX() + rand.nextInt(i * 2 + 1) - i;
int l2 = pos.getY();
int i3 = pos.getZ() + rand.nextInt(l * 2 + 1) - l;
BlockPos blockpos2 = new BlockPos(j2, l2, i3);
if (world.isAirBlock(blockpos2)) {
int k2 = 0;
Iterator iterator = EnumFacing.Plane.HORIZONTAL.iterator();
while (iterator.hasNext()) {
EnumFacing enumfacing = (EnumFacing) iterator.next();
if (world.getBlockState(blockpos2.offset(enumfacing)).getMaterial().isSolid()) {
++k2;
}
}
if (k2 == 1) {
world.setBlockState(blockpos2, ((BlockAncientChestMP) this.chest).correctFacing(world, blockpos2, this.chest.getDefaultState()), 2);
TileEntity tileentity1 = world.getTileEntity(blockpos2);
if (tileentity1 instanceof TileEntityAncientChestMP) {
((TileEntityAncientChestMP) tileentity1).setLootTable(MPLootTables.COMMON_SPACE_DUNGEON, rand.nextLong());
}
break label100;
}
}
++i2;
continue;
}
}
++l1;
break;
}
}
world.setBlockState(pos, Blocks.MOB_SPAWNER.getDefaultState(), 2);
TileEntity tileentity = world.getTileEntity(pos);
if (tileentity instanceof TileEntityMobSpawner) {
((TileEntityMobSpawner) tileentity).getSpawnerBaseLogic().setEntityId(this.pickMobSpawner(rand));
} else {
MPLog.error("Failed to fetch mob spawner entity at x:{} y:{} z:{}", pos.getX(), pos.getY(), pos.getZ());
}
MPLog.debug("Generate {} spawner at: x:{} y:{} z:{}", ((TileEntityMobSpawner) tileentity).getSpawnerBaseLogic().getEntityId().toString(), pos.getX(), pos.getY(), pos.getZ());
return true;
} else {
return false;
}
}
use of net.minecraft.util.EnumFacing in project MorePlanets by SteveKunG.
the class ItemDoorMP method onItemUse.
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack itemStack = player.getHeldItem(hand);
if (facing != EnumFacing.UP) {
return EnumActionResult.FAIL;
} else {
IBlockState iblockstate = world.getBlockState(pos);
Block block = iblockstate.getBlock();
if (!block.isReplaceable(world, pos)) {
pos = pos.offset(facing);
}
if (player.canPlayerEdit(pos, facing, itemStack) && this.door.canPlaceBlockAt(world, pos)) {
EnumFacing enumfacing = EnumFacing.fromAngle(player.rotationYaw);
int i = enumfacing.getFrontOffsetX();
int j = enumfacing.getFrontOffsetZ();
boolean flag = i < 0 && hitZ < 0.5F || i > 0 && hitZ > 0.5F || j < 0 && hitX > 0.5F || j > 0 && hitX < 0.5F;
ItemDoor.placeDoor(world, pos, enumfacing, this.door, flag);
SoundType soundtype = world.getBlockState(pos).getBlock().getSoundType(world.getBlockState(pos), world, pos, player);
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
itemStack.shrink(1);
return EnumActionResult.SUCCESS;
} else {
return EnumActionResult.FAIL;
}
}
}
use of net.minecraft.util.EnumFacing in project MorePlanets by SteveKunG.
the class DoubleAncientChestItemHandlerMP method get.
public static DoubleAncientChestItemHandlerMP get(TileEntityAncientChestMP chest) {
World world = chest.getWorld();
BlockPos pos = chest.getPos();
if (world == null || pos == null || !world.isBlockLoaded(pos)) {
return null;
}
Block blockType = chest.getBlockType();
EnumFacing[] horizontals = EnumFacing.HORIZONTALS;
for (int i = horizontals.length - 1; i >= 0; i--) {
EnumFacing enumfacing = horizontals[i];
BlockPos blockpos = pos.offset(enumfacing);
Block block = world.getBlockState(blockpos).getBlock();
if (block == blockType) {
TileEntity otherTE = world.getTileEntity(blockpos);
if (otherTE instanceof TileEntityAncientChestMP) {
TileEntityAncientChestMP otherChest = (TileEntityAncientChestMP) otherTE;
return new DoubleAncientChestItemHandlerMP(chest, otherChest, enumfacing != net.minecraft.util.EnumFacing.WEST && enumfacing != net.minecraft.util.EnumFacing.NORTH);
}
}
}
return NO_ADJACENT_CHESTS_INSTANCE;
}
use of net.minecraft.util.EnumFacing in project SpongeCommon by SpongePowered.
the class PoweredPropertyStore method getFor.
@Override
public Optional<PoweredProperty> getFor(Location<World> location, Direction direction) {
final net.minecraft.world.World world = (net.minecraft.world.World) location.getExtent();
final EnumFacing facing = toEnumFacing(direction);
final boolean powered = world.getStrongPower(VecHelper.toBlockPos(location).offset(facing), facing) > 0;
return Optional.of(powered ? TRUE : FALSE);
}
Aggregations