Search in sources :

Example 1 with TileEntityPressureChamberValve

use of me.desht.pneumaticcraft.common.tileentity.TileEntityPressureChamberValve in project pnc-repressurized by TeamPneumatic.

the class BlockPressureChamberWall method updateState.

public IBlockState updateState(IBlockState state, IBlockAccess world, BlockPos pos) {
    state = super.getExtendedState(state, world, pos);
    TileEntityPressureChamberWall wall = (TileEntityPressureChamberWall) world.getTileEntity(pos);
    EnumWallState wallState;
    if (wall != null) {
        TileEntityPressureChamberValve core = wall.getCore();
        if (core != null) {
            int x = pos.getX();
            int y = pos.getY();
            int z = pos.getZ();
            boolean xMin = x == core.multiBlockX;
            boolean yMin = y == core.multiBlockY;
            boolean zMin = z == core.multiBlockZ;
            boolean xMax = x == core.multiBlockX + core.multiBlockSize - 1;
            boolean yMax = y == core.multiBlockY + core.multiBlockSize - 1;
            boolean zMax = z == core.multiBlockZ + core.multiBlockSize - 1;
            // Corners
            if (xMin && yMin && zMin || xMax && yMax && zMax) {
                wallState = EnumWallState.XMIN_YMIN_ZMIN;
            } else if (xMin && yMin && zMax || xMax && yMax && zMin) {
                wallState = EnumWallState.XMIN_YMIN_ZMAX;
            } else if (xMin && yMax && zMax || xMax && yMin && zMin) {
                wallState = EnumWallState.XMIN_YMAX_ZMAX;
            } else if (xMin && yMax && zMin || xMax && yMin && zMax) {
                wallState = EnumWallState.XMIN_YMAX_ZMIN;
            } else // Edges
            if (yMin && xMin || yMax && xMax || yMin && xMax || yMax && xMin) {
                wallState = EnumWallState.XEDGE;
            } else if (yMin && zMin || yMax && zMax || yMin && zMax || yMax && zMin) {
                wallState = EnumWallState.ZEDGE;
            } else if (!yMin && !yMax) {
                if (xMin && zMin || xMax && zMax || xMin && zMax || xMax && zMin) {
                    wallState = EnumWallState.YEDGE;
                } else {
                    wallState = EnumWallState.CENTER;
                }
            } else {
                wallState = EnumWallState.CENTER;
            }
        } else {
            wallState = EnumWallState.NONE;
        }
    } else {
        wallState = EnumWallState.NONE;
    }
    state = state.withProperty(WALL_STATE, wallState);
    return state;
}
Also used : TileEntityPressureChamberValve(me.desht.pneumaticcraft.common.tileentity.TileEntityPressureChamberValve) TileEntityPressureChamberWall(me.desht.pneumaticcraft.common.tileentity.TileEntityPressureChamberWall)

Example 2 with TileEntityPressureChamberValve

use of me.desht.pneumaticcraft.common.tileentity.TileEntityPressureChamberValve in project pnc-repressurized by TeamPneumatic.

the class RenderPressureChamber method render.

@Override
public void render(TileEntityPressureChamberValve te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    List<ItemStack> stacks = new ItemStackHandlerIterable(te.getStacksInChamber()).stream().filter(stack -> !stack.isEmpty()).collect(Collectors.toList());
    if (!stacks.isEmpty()) {
        x += te.multiBlockX - te.getPos().getX() + te.multiBlockSize / 2D;
        // Set to '+ 1' for normal y value.
        y += te.multiBlockY - te.getPos().getY() + 1.1;
        z += te.multiBlockZ - te.getPos().getZ() + te.multiBlockSize / 2D;
        GlStateManager.pushMatrix();
        GlStateManager.translate(x, y, z);
        RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
        boolean fancySetting = renderManager.options.fancyGraphics;
        renderManager.options.fancyGraphics = true;
        // render single item centered (looks best), multiple items arranged in a circle
        // around the centre of the chamber, radius dependent on chamber size
        float circleRadius = stacks.size() == 1 ? 0 : 0.33f * (te.multiBlockSize - 2);
        float degreesPerStack = 360f / stacks.size();
        // some gentle rotation and bobbing looks good here
        double ticks = ClientTickHandler.TICKS + partialTicks;
        float yBob = MathHelper.sin(((float) ticks / 10) % 360) * 0.01f;
        float yRot = (float) (ticks / 2) % 360;
        for (int i = 0; i < stacks.size(); i++) {
            GlStateManager.pushMatrix();
            GlStateManager.rotate(i * degreesPerStack, 0, 1, 0);
            GlStateManager.translate(circleRadius, yBob, 0);
            GlStateManager.rotate(yRot, 0, 1, 0);
            Minecraft.getMinecraft().getRenderItem().renderItem(stacks.get(i), ItemCameraTransforms.TransformType.GROUND);
            GlStateManager.popMatrix();
        }
        renderManager.options.fancyGraphics = fancySetting;
        GlStateManager.popMatrix();
    }
}
Also used : ClientTickHandler(me.desht.pneumaticcraft.client.ClientTickHandler) RenderManager(net.minecraft.client.renderer.entity.RenderManager) ItemStack(net.minecraft.item.ItemStack) TileEntityPressureChamberValve(me.desht.pneumaticcraft.common.tileentity.TileEntityPressureChamberValve) List(java.util.List) ItemStackHandlerIterable(me.desht.pneumaticcraft.common.util.ItemStackHandlerIterable) Minecraft(net.minecraft.client.Minecraft) MathHelper(net.minecraft.util.math.MathHelper) GlStateManager(net.minecraft.client.renderer.GlStateManager) TileEntitySpecialRenderer(net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer) ItemCameraTransforms(net.minecraft.client.renderer.block.model.ItemCameraTransforms) Collectors(java.util.stream.Collectors) ItemStackHandlerIterable(me.desht.pneumaticcraft.common.util.ItemStackHandlerIterable) ItemStack(net.minecraft.item.ItemStack) RenderManager(net.minecraft.client.renderer.entity.RenderManager)

Aggregations

TileEntityPressureChamberValve (me.desht.pneumaticcraft.common.tileentity.TileEntityPressureChamberValve)2 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 ClientTickHandler (me.desht.pneumaticcraft.client.ClientTickHandler)1 TileEntityPressureChamberWall (me.desht.pneumaticcraft.common.tileentity.TileEntityPressureChamberWall)1 ItemStackHandlerIterable (me.desht.pneumaticcraft.common.util.ItemStackHandlerIterable)1 Minecraft (net.minecraft.client.Minecraft)1 GlStateManager (net.minecraft.client.renderer.GlStateManager)1 ItemCameraTransforms (net.minecraft.client.renderer.block.model.ItemCameraTransforms)1 RenderManager (net.minecraft.client.renderer.entity.RenderManager)1 TileEntitySpecialRenderer (net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer)1 ItemStack (net.minecraft.item.ItemStack)1 MathHelper (net.minecraft.util.math.MathHelper)1