Java Code Examples for net.minecraft.util.EnumFacing#HORIZONTALS

The following examples show how to use net.minecraft.util.EnumFacing#HORIZONTALS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HarvesterTileEntity.java    From EmergingTechnology with MIT License 6 votes vote down vote up
public void doEnergyTransferProcess() {
    int transferEnergy = EmergingTechnologyConfig.HYDROPONICS_MODULE.HARVESTER.harvesterEnergyTransferRate;

    for (EnumFacing facing : EnumFacing.HORIZONTALS) {

        if (this.getEnergy() < transferEnergy) {
            break;
        }

        TileEntity neighbour = this.world.getTileEntity(this.pos.offset(facing));

        if (neighbour instanceof HarvesterTileEntity) {
            HarvesterTileEntity targetTileEntity = (HarvesterTileEntity) neighbour;

            int accepted = targetTileEntity.energyHandler.receiveEnergy(transferEnergy, false);

            if (accepted > 0) {
                this.energyHandler.extractEnergy(accepted, true);
                this.setEnergy(this.energyHandler.getEnergyStored());
            }
        }

    }
}
 
Example 2
Source File: MetaTileEntityPump.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) {
    super.renderMetaTileEntity(renderState, translation, pipeline);
    ColourMultiplier multiplier = new ColourMultiplier(GTUtility.convertRGBtoOpaqueRGBA_CL(getPaintingColorForRendering()));
    IVertexOperation[] coloredPipeline = ArrayUtils.add(pipeline, multiplier);
    for (EnumFacing renderSide : EnumFacing.HORIZONTALS) {
        if (renderSide == getFrontFacing()) {
            Textures.PIPE_OUT_OVERLAY.renderSided(renderSide, renderState, translation, pipeline);
        } else {
            Textures.ADV_PUMP_OVERLAY.renderSided(renderSide, renderState, translation, coloredPipeline);
        }
    }
    Textures.SCREEN.renderSided(EnumFacing.UP, renderState, translation, pipeline);
    Textures.PIPE_IN_OVERLAY.renderSided(EnumFacing.DOWN, renderState, translation, pipeline);
}
 
Example 3
Source File: BlockSignalBase.java    From Signals with GNU General Public License v3.0 6 votes vote down vote up
@Override
public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer){
    List<EnumFacing> railFacings = new ArrayList<>(4);
    for(EnumFacing horFacing : EnumFacing.HORIZONTALS) {
        BlockPos railPos = pos.offset(horFacing);
        if(RailManager.getInstance().getRail(worldIn, railPos, worldIn.getBlockState(railPos)) != null) {
            railFacings.add(horFacing);
        }
    }

    EnumFacing orientation;
    if(railFacings.size() == 1) { //When exactly one rail is connecting, connect the signal to the rail
        orientation = railFacings.get(0).rotateY();
    } else { //Else, fall back onto player orientation.
        orientation = placer.getHorizontalFacing();
    }
    return getDefaultState().withProperty(FACING, orientation);
}
 
Example 4
Source File: RenderWaterPad.java    From AgriCraft with MIT License 6 votes vote down vote up
@Override
public void renderWorldBlockStatic(ITessellator tessellator, IBlockState state, BlockWaterPad block, EnumFacing side) {
    // Icon
    final TextureAtlasSprite matIcon = BaseIcons.DIRT.getIcon();
    final TextureAtlasSprite waterIcon = BaseIcons.WATER_STILL.getIcon();

    // Draw Base
    renderBase(tessellator, matIcon);
    
    // Get Connections.
    final AgriSideMetaMatrix connections = new AgriSideMetaMatrix();
    connections.readFromBlockState(state);

    // Render Sides
    for (EnumFacing dir : EnumFacing.HORIZONTALS) {
        if (connections.get(dir) < 1) {
            renderSide(tessellator, dir, matIcon);
        }
    }

    // Render Water
    if (AgriProperties.POWERED.getValue(state)) {
        renderWater(tessellator, waterIcon);
    }
}
 
Example 5
Source File: MapGenSpaceStation.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
public static void generateStation(World world, int blockX, int blockY, int blockZ) {

		BlockPos pos = new BlockPos(blockX, blockY, blockZ); 

		//Center
		world.setBlockState(pos, AdvancedRocketryBlocks.blockConcrete.getDefaultState(), 6);
		world.setBlockState(pos.add(1,0,1), AdvancedRocketryBlocks.blockConcrete.getDefaultState(), 6);
		world.setBlockState(pos.add(-1,0,-1), AdvancedRocketryBlocks.blockConcrete.getDefaultState(), 6);
		world.setBlockState(pos.add(1,0,-1), AdvancedRocketryBlocks.blockConcrete.getDefaultState(), 6);
		world.setBlockState(pos.add(-1,0,1), AdvancedRocketryBlocks.blockConcrete.getDefaultState(), 6);


		for(EnumFacing dir : EnumFacing.HORIZONTALS) {
			world.setBlockState(pos.offset(dir), Blocks.PISTON.getDefaultState().withProperty(BlockPistonBase.FACING, dir), 6);
			generateArm(world, pos, dir);
		}

	}
 
Example 6
Source File: CocoaHandler.java    From BetterChests with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean canHandleHarvest(IBlockState state, World world, BlockPos pos) {
	if (!isJungleTree(state)) {
		return false;
	}

	for (EnumFacing side : EnumFacing.HORIZONTALS) {
		BlockPos toCheck = pos.offset(side);
		if (world.getBlockState(toCheck).getBlock() == Blocks.COCOA) {
			return true;
		}
	}
	return false;

}
 
Example 7
Source File: CocoaHandler.java    From BetterChests with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean handlePlant(IBetterChest chest, Collection<ItemStack> items, World world, BlockPos pos) {

	EnumFacing jungleBlock = EnumFacing.UP;
	for (EnumFacing side : EnumFacing.HORIZONTALS) {
		if (isJungleTree(world.getBlockState(pos.offset(side)))) {
			jungleBlock = side;
			break;
		}
	}
	world.setBlockState(pos, Blocks.COCOA.getDefaultState().withProperty(BlockCocoa.FACING, jungleBlock));
	ItemStack stack = items.stream().filter(this::canPlantStack).findFirst().get();
	stack.setCount(stack.getCount() - 1);
	return true;
}
 
Example 8
Source File: RenderPeripheral.java    From AgriCraft with MIT License 5 votes vote down vote up
private void renderChasis(ITessellator tessellator) {
    // Fetch Icons
    final TextureAtlasSprite iconTop = getIcon(TEXTURE_TOP);
    final TextureAtlasSprite iconSide = getIcon(TEXTURE_SIDE);
    final TextureAtlasSprite iconBottom = getIcon(TEXTURE_BOTTOM);
    final TextureAtlasSprite iconInside = getIcon(TEXTURE_INNER);

    // Render Top
    tessellator.drawScaledFace(0, 0, 16, 16, EnumFacing.UP, iconTop, 16);
    tessellator.drawScaledFace(0, 0, 16, 16, EnumFacing.DOWN, iconTop, 14);

    // Render Bottom
    tessellator.drawScaledFace(0, 0, 16, 16, EnumFacing.UP, iconInside, 2);
    tessellator.drawScaledFace(0, 0, 16, 16, EnumFacing.DOWN, iconBottom, 0);

    // Render Sides - Don't Ask Why This Works...
    for (EnumFacing side : EnumFacing.HORIZONTALS) {
        // Push Matrix
        tessellator.pushMatrix();
        // Rotate The Block
        rotateBlock(tessellator, side);
        // Render Outer Face
        tessellator.drawScaledFace(0, 0, 16, 16, EnumFacing.NORTH, iconSide, 0);
        // Render Inner Face
        tessellator.drawScaledFaceDouble(0, 0, 16, 16, EnumFacing.NORTH, iconInside, 4);
        // Pop Matrix
        tessellator.popMatrix();
    }
}
 
Example 9
Source File: RenderChannel.java    From AgriCraft with MIT License 5 votes vote down vote up
protected void renderWoodChannel(ITessellator tessellator, IBlockState state, TextureAtlasSprite icon) {
    final AgriSideMetaMatrix connections = new AgriSideMetaMatrix();
    connections.readFromBlockState(state);
    this.renderBottom(tessellator, icon);
    for (EnumFacing side : EnumFacing.HORIZONTALS) {
        this.renderSide(tessellator, state, side, connections.get(side), icon);
    }
}
 
Example 10
Source File: BlockRotationModeTest.java    From OpenModsLib with MIT License 5 votes vote down vote up
@Test
public void toolRotationOnHorizontalChangesFrontToOpposite() {
	for (EnumFacing front : EnumFacing.HORIZONTALS) {
		Orientation orientation = MODE.getOrientationFacing(front);
		final Orientation rotatedOrientation = MODE.calculateToolRotation(orientation, front);
		EnumFacing rotatedFront = MODE.getFront(rotatedOrientation);
		Assert.assertEquals(front.getOpposite(), rotatedFront);
	}
}
 
Example 11
Source File: BlockRotationModeTest.java    From OpenModsLib with MIT License 5 votes vote down vote up
@Test
public void toolRotationOnHorizontalChangesFrontAxisToClickedSide() {
	for (Orientation orientation : MODE.getValidDirections()) {
		for (EnumFacing rotatedSide : EnumFacing.HORIZONTALS) {
			final Orientation rotatedOrientation = MODE.calculateToolRotation(orientation, rotatedSide);
			final EnumFacing rotatedFront = MODE.getFront(rotatedOrientation);
			Assert.assertEquals(rotatedSide.getAxis(), rotatedFront.getAxis());
		}
	}
}
 
Example 12
Source File: BlockWaterPad.java    From AgriCraft with MIT License 5 votes vote down vote up
@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);
}
 
Example 13
Source File: TileEntityCartHopper.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings({"rawtypes", "unchecked"})
private boolean tryTransfer(boolean extract){
    boolean active = false, empty = false, full = false;
    List<Pair<TileEntity, EnumFacing>> filters = Lists.newArrayList();
    for(EnumFacing dir : EnumFacing.HORIZONTALS) {
        TileEntity filter = getWorld().getTileEntity(getPos().offset(dir));
        if(filter != null) filters.add(new ImmutablePair<>(filter, dir));
    }

    for(ICartHopperBehaviour hopperBehaviour : getApplicableHopperBehaviours(managingCart)) {
        Capability<?> cap = hopperBehaviour.getCapability();
        Object cart = null;
        if(interactEngine && hopperBehaviour instanceof CartHopperBehaviourItems) {
            if(managingCart.hasCapability(CapabilityMinecartDestination.INSTANCE, null)) {
                cart = managingCart.getCapability(CapabilityMinecartDestination.INSTANCE, null).getEngineItemHandler();
            } else {
                continue;
            }
        } else {
            cart = managingCart.getCapability(cap, null);
        }
        Object te = getCapabilityAt(cap, extract ? EnumFacing.DOWN : EnumFacing.UP);
        if(te != null && hopperBehaviour.tryTransfer(extract ? cart : te, extract ? te : cart, filters)) active = true;
        if(hopperMode == HopperMode.CART_EMPTY && hopperBehaviour.isCartEmpty(cart, filters)) empty = true;
        if(hopperMode == HopperMode.CART_FULL && hopperBehaviour.isCartFull(cart)) full = true;
    }
    return hopperMode == HopperMode.NO_ACTIVITY ? !active : empty || full;
}
 
Example 14
Source File: BlockRotationModeTest.java    From OpenModsLib with MIT License 5 votes vote down vote up
@Test
public void testHorizontals() {
	for (EnumFacing facing : EnumFacing.HORIZONTALS) {
		Orientation orientation = mode.getOrientationFacing(facing);
		Assert.assertNotNull(facing.toString(), orientation);
	}
}
 
Example 15
Source File: PumpkinBlockHandler.java    From BetterChests with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean canHandlePlant(Collection<ItemStack> items, World world, BlockPos pos, IBlockState state) {
	if (!WorldUtil.isBlockAir(world, pos)) {
		return false;
	}
	MutableBlockPos mut = new MutableBlockPos();
	for (EnumFacing facing : EnumFacing.HORIZONTALS) {
		mut.setPos(pos).move(facing);
		IBlockState other = world.getBlockState(mut);
		if (other.getBlock() == Blocks.MELON_STEM || other.getBlock() == Blocks.PUMPKIN_STEM) {
			return  true;
		}
	}
	return false;
}
 
Example 16
Source File: GTTileMagicEnergyAbsorber.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public void randomTickDisplay(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
	if (this.isActive && this.portalMode
			&& worldIn.getBlockState(this.pos.offset(EnumFacing.DOWN)).getBlock() == Blocks.END_PORTAL) {
		for (EnumFacing facing : EnumFacing.HORIZONTALS) {
			BlockPos sidePos = pos.offset(facing);
			if (world.getBlockState(sidePos).isFullBlock()) {
				continue;
			}
			for (int k = 3; k > 0; --k) {
				ParticleManager er = Minecraft.getMinecraft().effectRenderer;
				float multPos = (float) (.1 * 2) + 0.9F;
				double x = (double) ((float) sidePos.getX() + 0.05F + rand.nextFloat() * multPos);
				double y = (double) ((float) sidePos.getY() + 0.0F + rand.nextFloat() * 0.5F);
				double z = (double) ((float) sidePos.getZ() + 0.05F + rand.nextFloat() * multPos);
				double[] velocity = new double[] { 0.0D, 7.6D, 0.0D };
				if (k < 4) {
					velocity[2] *= 0.55D;
				}
				float foo = rand.nextFloat() * .25F;
				float[] colour = new float[] { 0.0F, foo, foo };
				er.addEffect(new EntityChargePadAuraFX(this.world, x, y, z, 8, velocity, colour, false));
			}
		}
	}
}
 
Example 17
Source File: BlockRotationModeTest.java    From OpenModsLib with MIT License 5 votes vote down vote up
@Test
public void testTopEqualsUpForAllHorizontals() {
	for (EnumFacing facing : EnumFacing.HORIZONTALS) {
		final Orientation orientation = mode.getOrientationFacing(facing);
		Assert.assertNotNull(facing.toString(), orientation);
		Assert.assertEquals(facing.toString(), EnumFacing.UP, mode.getTop(orientation));
	}
}
 
Example 18
Source File: DiffuserHelper.java    From EmergingTechnology with MIT License 5 votes vote down vote up
private static int doBoost(World world, BlockPos pos, FluidTank gasHandler, int probability, int range) {
    int plantsBoosted = 0;

    for (EnumFacing facing : EnumFacing.HORIZONTALS) {
        for (int i = 1; i < range + 1; i++) {

            // Not enough gas
            if (gasHandler
                    .getFluidAmount() < EmergingTechnologyConfig.HYDROPONICS_MODULE.DIFFUSER.diffuserGasBaseUsage) {
                break;
            }

            BlockPos position = pos.offset(facing, i);
            IBlockState blockState = world.getBlockState(position);
            Block block = blockState.getBlock();

            if (PlantHelper.isPlantBlock(blockState.getBlock())) {

                boolean success = growBlock(world, blockState, block, position, gasHandler, probability);

                if (success)
                    plantsBoosted += 1;

            } else if (!blockState.getBlock().isFullBlock(blockState)) {
                continue;
            } else {
                break;
            }
        }
    }

    return plantsBoosted;
}
 
Example 19
Source File: TileEntityCartHopper.java    From Signals with GNU General Public License v3.0 4 votes vote down vote up
private boolean isDisabled(){
    for(EnumFacing facing : EnumFacing.HORIZONTALS) {
        if(getWorld().getRedstonePower(pos.offset(facing), facing) > 0) return true;
    }
    return false;
}
 
Example 20
Source File: TESRBBarrel.java    From BetterChests with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void render(TileEntityBBarrel te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {

	if (te.getChestPart().isItemSet()) {
		GlStateManager.pushMatrix();
		GlStateManager.translate((float) x, (float) y, (float) z);
		GlStateManager.translate(0.5F, 0.5F, 0.5F);

		ItemStack stack = te.getChestPart().getDummy();

		EnumFacing side = EnumFacing.HORIZONTALS[te.getBlockMetadata()];

		float angle = side.getHorizontalAngle();
		switch (side) {
		case SOUTH:
			//south
			angle = 180;
			break;
		case WEST:
			//west
			angle = 90;
			break;
		case NORTH:
			//north
			angle = 0;
			break;
		case EAST:
			//east
			angle = -90;
			break;
		}
		GlStateManager.rotate(angle, 0, 1, 0);

		{
			GlStateManager.pushMatrix();

			GlStateManager.translate(0, 0.1, -0.5);
			GlStateManager.scale(0.8, 0.8, 0.8);

			int skyBrightness = te.getWorld().getCombinedLight(te.getPosition().offset(side), 0);
			int skyBrightness1 = skyBrightness % 65536;
			int skyBrightness2 = skyBrightness / 65536;
			OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, skyBrightness1,
					skyBrightness2);

			Minecraft.getMinecraft().getRenderItem().renderItem(stack, TransformType.FIXED);

			GlStateManager.popMatrix();
		}

		{
			GlStateManager.pushMatrix();

			GlStateManager.translate(0, -0.25, -0.51);
			GlStateManager.scale(0.015, 0.015, 0.015);
			GlStateManager.rotate(180, 0, 0, 1);

			String text = te.getChestPart().getAmountDescr();
			int textlen = Minecraft.getMinecraft().fontRenderer.getStringWidth(text);
			Minecraft.getMinecraft().fontRenderer.drawString(text, -textlen / 2, 0, 0xFFFFFFFF);

			GlStateManager.popMatrix();
		}

		GlStateManager.popMatrix();
	}

}