use of net.minecraft.util.EnumFacing in project Bookshelf by Darkhax-Minecraft.
the class BlockBasicChest method getContainer.
@Override
public ILockableContainer getContainer(World world, BlockPos pos, boolean locked) {
final TileEntity tile = world.getTileEntity(pos);
if (!(tile instanceof TileEntityBasicChest)) {
return null;
} else {
ILockableContainer myChest = (TileEntityBasicChest) tile;
final IChestType myType = ((TileEntityBasicChest) tile).getType();
if (!locked && this.isBlocked(world, pos)) {
return null;
} else {
for (final EnumFacing facing : EnumFacing.Plane.HORIZONTAL) {
final BlockPos adjPos = pos.offset(facing);
final TileEntity adjTile = world.getTileEntity(adjPos);
if (world.getBlockState(adjPos).getBlock() == this && adjTile instanceof TileEntityBasicChest && ((TileEntityBasicChest) adjTile).getType() == myType) {
if (this.isBlocked(world, adjPos)) {
return null;
}
if (facing != EnumFacing.WEST && facing != EnumFacing.NORTH) {
myChest = new InventoryLargeChest("container.chestDouble", myChest, (TileEntityBasicChest) adjTile);
} else {
myChest = new InventoryLargeChest("container.chestDouble", (TileEntityBasicChest) adjTile, myChest);
}
}
}
return myChest;
}
}
}
use of net.minecraft.util.EnumFacing in project Bookshelf by Darkhax-Minecraft.
the class BlockBasicChest method onBlockPlacedBy.
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
final EnumFacing facing = EnumFacing.getHorizontal(MathHelper.floor(placer.rotationYaw * 4.0F / 360.0F + 0.5D) & 3).getOpposite();
state = state.withProperty(FACING, facing);
final BlockPos northPos = pos.north();
final BlockPos southPos = pos.south();
final BlockPos westPos = pos.west();
final BlockPos eastPos = pos.east();
final IChestType myType = this.getCustomType(stack);
final boolean northChest = myType == this.getCustomType(worldIn, northPos);
final boolean southChest = myType == this.getCustomType(worldIn, southPos);
final boolean westChest = myType == this.getCustomType(worldIn, westPos);
final boolean eastChest = myType == this.getCustomType(worldIn, eastPos);
if (!northChest && !southChest && !westChest && !eastChest) {
worldIn.setBlockState(pos, state, 3);
} else if (facing.getAxis() != EnumFacing.Axis.X || !northChest && !southChest) {
if (facing.getAxis() == EnumFacing.Axis.Z && (westChest || eastChest)) {
if (westChest) {
this.setState(worldIn, westPos, state, 3);
} else {
this.setState(worldIn, eastPos, state, 3);
}
worldIn.setBlockState(pos, state, 3);
} else {
final EnumFacing corrected = facing.rotateY();
this.setState(worldIn, pos, state.withProperty(FACING, corrected), 3);
if (northChest) {
this.setState(worldIn, northPos, state.withProperty(FACING, corrected), 3);
} else if (southChest) {
this.setState(worldIn, southPos, state.withProperty(FACING, corrected), 3);
} else if (westChest) {
this.setState(worldIn, westPos, state.withProperty(FACING, corrected), 3);
} else if (eastChest) {
this.setState(worldIn, eastPos, state.withProperty(FACING, corrected), 3);
}
}
} else {
if (northChest) {
this.setState(worldIn, northPos, state, 3);
} else {
this.setState(worldIn, southPos, state, 3);
}
worldIn.setBlockState(pos, state, 3);
}
final TileEntity te = worldIn.getTileEntity(pos);
if (te instanceof TileEntityBasicChest) {
final TileEntityBasicChest chest = (TileEntityBasicChest) te;
if (stack.hasDisplayName()) {
chest.setCustomName(stack.getDisplayName());
}
chest.setType(myType);
}
this.onBlockAdded(worldIn, pos, state);
}
use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class TileRenderBucketWheel method renderTileEntityAt.
@Override
public void renderTileEntityAt(TileEntityBucketWheel tile, double x, double y, double z, float f, int destroyStage) {
if (!tile.formed || !tile.getWorld().isBlockLoaded(tile.getPos(), false) || tile.isDummy())
return;
final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
IBlockState state = tile.getWorld().getBlockState(tile.getPos());
if (state.getBlock() != IEContent.blockMetalMultiblock)
return;
if (model == null) {
state = state.withProperty(IEProperties.DYNAMICRENDER, true);
model = blockRenderer.getModelForState(state);
}
OBJState objState = null;
HashMap<String, String> texMap = new HashMap<>();
if (state instanceof IExtendedBlockState) {
ArrayList<String> list = Lists.newArrayList("bucketWheel");
synchronized (tile.digStacks) {
for (int i = 0; i < tile.digStacks.length; i++) if (tile.digStacks[i] != null) {
list.add("dig" + i);
Block b = Block.getBlockFromItem(tile.digStacks[i].getItem());
IBlockState digState = b != null ? b.getStateFromMeta(tile.digStacks[i].getMetadata()) : Blocks.STONE.getDefaultState();
IBakedModel digModel = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(digState);
if (digModel != null && digModel.getParticleTexture() != null)
texMap.put("dig" + i, digModel.getParticleTexture().getIconName());
}
}
objState = new OBJState(list, true);
}
Tessellator tessellator = Tessellator.getInstance();
GlStateManager.pushMatrix();
GlStateManager.translate(x + .5, y + .5, z + .5);
GlStateManager.blendFunc(770, 771);
GlStateManager.enableBlend();
GlStateManager.disableCull();
EnumFacing facing = tile.facing;
if (tile.mirrored) {
GlStateManager.scale(facing.getAxis() == Axis.X ? -1 : 1, 1, facing.getAxis() == Axis.Z ? -1 : 1);
GlStateManager.disableCull();
}
float dir = tile.facing == EnumFacing.SOUTH ? 90 : tile.facing == EnumFacing.NORTH ? -90 : tile.facing == EnumFacing.EAST ? 180 : 0;
GlStateManager.rotate(dir, 0, 1, 0);
float rot = tile.rotation + (float) (tile.active ? IEConfig.Machines.excavator_speed * f : 0);
GlStateManager.rotate(rot, 1, 0, 0);
RenderHelper.disableStandardItemLighting();
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
VertexBuffer worldRenderer = tessellator.getBuffer();
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
worldRenderer.setTranslation(-.5, -.5, -.5);
List<BakedQuad> quads;
if (model instanceof IESmartObjModel)
quads = ((IESmartObjModel) model).getQuads(state, null, 0, objState, texMap, true);
else
quads = model.getQuads(state, null, 0);
ClientUtils.renderModelTESR(quads, worldRenderer, tile.getWorld().getCombinedLight(tile.getPos(), 0));
worldRenderer.setTranslation(0, 0, 0);
tessellator.draw();
GlStateManager.popMatrix();
RenderHelper.enableStandardItemLighting();
GlStateManager.disableBlend();
GlStateManager.enableCull();
if (tile.mirrored) {
GlStateManager.enableCull();
}
}
use of net.minecraft.util.EnumFacing in project AgriCraft by AgriCraft.
the class BlockWaterPad method getExtendedState.
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
AgriSideMetaMatrix connection = new AgriSideMetaMatrix();
for (EnumFacing facing : EnumFacing.HORIZONTALS) {
final IBlockState stateAt = world.getBlockState(pos.offset(facing));
final byte value = (byte) (stateAt.getBlock() == state.getBlock() ? 1 : 0);
connection.set(facing, value);
}
return connection.writeToBlockState(state);
}
use of net.minecraft.util.EnumFacing in project AgriCraft by AgriCraft.
the class DebugModeCheckSoil method debugActionBlockClicked.
@Override
public void debugActionBlockClicked(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
FuzzyStack soil = FuzzyStack.from(world.getBlockState(pos)).orElse(null);
String type = AgriApi.getSoilRegistry().all().stream().filter(s -> s.isVarient(soil)).map(s -> s.getName()).findFirst().orElse("Unknown Soil");
MessageUtil.messagePlayer(player, "{0} Soil Info:", FMLCommonHandler.instance().getSide());
MessageUtil.messagePlayer(player, " - Soil Type: \"{0}\"", type);
}
Aggregations