Search in sources :

Example 1 with AbstractMachineEntity

use of crazypants.enderio.base.machine.base.te.AbstractMachineEntity in project EnderIO by SleepyTrousers.

the class MachineRenderMapper method mapOverlayLayer.

@Override
@SideOnly(Side.CLIENT)
public EnumMap<EnumFacing, EnumIOMode> mapOverlayLayer(@Nonnull IBlockStateWrapper state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, boolean isPainted) {
    TileEntity tileEntity = state.getTileEntity();
    Block block = state.getBlock();
    if ((tileEntity instanceof AbstractMachineEntity) && (block instanceof AbstractMachineBlock)) {
        if (isPainted) {
            return renderPaintIO((AbstractMachineEntity) tileEntity, (AbstractMachineBlock<?>) block);
        } else {
            return renderIO((AbstractMachineEntity) tileEntity, (AbstractMachineBlock<?>) block);
        }
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AbstractMachineEntity(crazypants.enderio.base.machine.base.te.AbstractMachineEntity) AbstractMachineBlock(crazypants.enderio.base.machine.base.block.AbstractMachineBlock) AbstractMachineBlock(crazypants.enderio.base.machine.base.block.AbstractMachineBlock) Block(net.minecraft.block.Block) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with AbstractMachineEntity

use of crazypants.enderio.base.machine.base.te.AbstractMachineEntity in project EnderIO by SleepyTrousers.

the class BlockCombustionGenerator method randomDisplayTick.

@Override
public void randomDisplayTick(@Nonnull IBlockState bs, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Random rand) {
    // If active, randomly throw some smoke around
    if (isActive(world, pos)) {
        TileEntity te = world.getTileEntity(pos);
        EnumFacing facing = EnumFacing.SOUTH;
        if (te instanceof AbstractMachineEntity) {
            AbstractMachineEntity me = (AbstractMachineEntity) te;
            facing = me.facing;
        }
        for (int j = 0; j < (isEnhanced ? 3 : 1); j++) {
            boolean toTop = rand.nextBoolean();
            // top:front<->back or side:bottom<->top
            float offsetA = rand.nextFloat();
            // right<->left
            float offsetB = .5f + rand.nextFloat() * .2f - rand.nextFloat() * .2f;
            float startX = pos.getX(), startY = pos.getY(), startZ = pos.getZ();
            if (toTop) {
                startY += 0.95f;
                switch(facing) {
                    case NORTH:
                    case SOUTH:
                        startX += offsetB;
                        startZ += offsetA;
                        break;
                    case EAST:
                    case WEST:
                    default:
                        startX += offsetA;
                        startZ += offsetB;
                        break;
                }
            } else {
                boolean swap = rand.nextBoolean();
                startY += offsetA;
                switch(facing) {
                    case NORTH:
                    case SOUTH:
                        startX += offsetB;
                        startZ += swap ? 0.05f : 0.95f;
                        break;
                    case EAST:
                    case WEST:
                    default:
                        startX += swap ? 0.05f : 0.95f;
                        startZ += offsetB;
                        break;
                }
            }
            for (int i = 0; i < (isEnhanced ? 5 : 2); i++) {
                ParticleManager er = Minecraft.getMinecraft().effectRenderer;
                Particle fx = er.spawnEffectParticle(EnumParticleTypes.SMOKE_NORMAL.getParticleID(), startX, startY, startZ, 0.0D, 0.0D, 0.0D);
                if (fx != null && rand.nextFloat() > .75f) {
                    fx.setRBGColorF(1 - (rand.nextFloat() * 0.2f), 1 - (rand.nextFloat() * 0.1f), 1 - (rand.nextFloat() * 0.2f));
                }
                startX += rand.nextFloat() * .1f - rand.nextFloat() * .1f;
                startY += rand.nextFloat() * .1f - rand.nextFloat() * .1f;
                startZ += rand.nextFloat() * .1f - rand.nextFloat() * .1f;
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Particle(net.minecraft.client.particle.Particle) AbstractMachineEntity(crazypants.enderio.base.machine.base.te.AbstractMachineEntity) EnumFacing(net.minecraft.util.EnumFacing) ParticleManager(net.minecraft.client.particle.ParticleManager)

Example 3 with AbstractMachineEntity

use of crazypants.enderio.base.machine.base.te.AbstractMachineEntity in project EnderIO by SleepyTrousers.

the class ObeliskRenderMapper method mapBlockRender.

@Override
@SideOnly(Side.CLIENT)
public List<IBlockState> mapBlockRender(@Nonnull IBlockStateWrapper state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, BlockRenderLayer blockLayer, @Nonnull QuadCollector quadCollector) {
    TileEntity tileEntity = getTileEntity(state, pos);
    boolean isActive = tileEntity instanceof AbstractMachineEntity ? ((AbstractMachineEntity) tileEntity).isActive() : true;
    quadCollector.addQuads(null, BlockRenderLayer.CUTOUT, ObeliskBakery.bake(isActive ? ObeliskRenderManager.INSTANCE.getActiveTextures() : ObeliskRenderManager.INSTANCE.getTextures()));
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AbstractMachineEntity(crazypants.enderio.base.machine.base.te.AbstractMachineEntity) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with AbstractMachineEntity

use of crazypants.enderio.base.machine.base.te.AbstractMachineEntity in project EnderIO by SleepyTrousers.

the class KillerJoeRenderMapper method renderHead.

private List<BakedQuad> renderHead(@Nullable IBlockStateWrapper state) {
    EnumFacing facing = EnumFacing.NORTH;
    if (state != null) {
        TileEntity tileEntity = state.getTileEntity();
        if (tileEntity instanceof AbstractMachineEntity) {
            facing = ((AbstractMachineEntity) tileEntity).getFacing();
            if (facing.getAxis() == EnumFacing.Axis.X) {
                facing = facing.getOpposite();
            }
        }
    }
    VertexRotationFacing rot = new VertexRotationFacing(EnumFacing.NORTH);
    rot.setCenter(CENTER);
    rot.setRotation(facing);
    BoundingBox bb = new BoundingBox(4 * px, 4 * px, 4 * px, 12 * px, 12 * px, 12 * px);
    VertexTransform sca = new VertexScale(.9, .9, .9, CENTER);
    VertexTransform rotx = new VertexRotation(0.03054326, new Vector3d(1, 0, 0), CENTER);
    VertexTransform roty = new VertexRotation(0.17453290, new Vector3d(0, 1, 0), CENTER);
    VertexTransform rotz = new VertexRotation(0.23928460, new Vector3d(0, 0, 1), CENTER);
    VertexTransform mov = new VertexTranslation(0.25 * px, -1 * px, 0);
    TextureAtlasSprite tex1 = head1.get(TextureAtlasSprite.class);
    TextureAtlasSprite tex2 = head2.get(TextureAtlasSprite.class);
    HalfBakedList buffer = new HalfBakedList();
    buffer.add(bb, EnumFacing.NORTH, 0f, .5f, 0f, .5f, tex1, null);
    buffer.add(bb, EnumFacing.EAST, .5f, 1f, 0f, .5f, tex1, null);
    buffer.add(bb, EnumFacing.SOUTH, 0f, .5f, .5f, 1f, tex1, null);
    buffer.add(bb, EnumFacing.WEST, .5f, 1f, .5f, 1f, tex1, null);
    buffer.add(bb, EnumFacing.UP, 0f, .5f, 0f, .5f, tex2, null);
    buffer.add(bb, EnumFacing.DOWN, .5f, 1f, 0f, .5f, tex2, null);
    List<BakedQuad> quads = new ArrayList<BakedQuad>();
    buffer.bake(quads, sca, rotx, roty, rotz, mov, rot);
    for (double angle : ROTS) {
        buffer = new HalfBakedList();
        BoundingBox bb1 = new BoundingBox(4.5 * px, 10.5 * px, 3 * px, 5.5 * px, 11.5 * px, 4 * px);
        BoundingBox bb2 = new BoundingBox(7.5 * px, 9.5 * px, 3 * px, 8.5 * px, 10.5 * px, 4 * px);
        BoundingBox bb3 = new BoundingBox(10.5 * px, 10.5 * px, 3 * px, 11.5 * px, 11.5 * px, 4 * px);
        for (EnumFacing face : EnumFacing.values()) {
            buffer.add(bb1, face, (face.ordinal() + 1) * px, (face.ordinal() + 2) * px, 9 * px, 10 * px, tex2, null);
            buffer.add(bb2, face, (face.ordinal() + 1) * px, (face.ordinal() + 2) * px, 10 * px, 11 * px, tex2, null);
            buffer.add(bb3, face, (face.ordinal() + 1) * px, (face.ordinal() + 2) * px, 11 * px, 12 * px, tex2, null);
        }
        VertexTransform rota = new VertexRotation(angle, new Vector3d(0, 1, 0), CENTER);
        buffer.bake(quads, sca, rota, rotx, roty, rotz, mov, rot);
    }
    return quads;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EnumFacing(net.minecraft.util.EnumFacing) ArrayList(java.util.ArrayList) VertexScale(com.enderio.core.client.render.VertexScale) VertexTransform(com.enderio.core.api.client.render.VertexTransform) HalfBakedList(crazypants.enderio.base.render.util.HalfBakedQuad.HalfBakedList) TileEntity(net.minecraft.tileentity.TileEntity) VertexTranslation(com.enderio.core.client.render.VertexTranslation) VertexRotationFacing(com.enderio.core.client.render.VertexRotationFacing) VertexRotation(com.enderio.core.client.render.VertexRotation) AbstractMachineEntity(crazypants.enderio.base.machine.base.te.AbstractMachineEntity) Vector3d(com.enderio.core.common.vecmath.Vector3d) BoundingBox(com.enderio.core.client.render.BoundingBox)

Example 5 with AbstractMachineEntity

use of crazypants.enderio.base.machine.base.te.AbstractMachineEntity in project EnderIO by SleepyTrousers.

the class MachineRenderMapper method mapBlockRender.

@Override
@SideOnly(Side.CLIENT)
public List<IBlockState> mapBlockRender(@Nonnull IBlockStateWrapper state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, BlockRenderLayer blockLayer, @Nonnull QuadCollector quadCollector) {
    TileEntity tileEntity = getTileEntity(state, pos);
    Block block = state.getBlock();
    if ((tileEntity instanceof AbstractMachineEntity) && (block instanceof AbstractMachineBlock)) {
        return render(state.getState(), world, pos, blockLayer, (AbstractMachineEntity) tileEntity, (AbstractMachineBlock<?>) block);
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AbstractMachineEntity(crazypants.enderio.base.machine.base.te.AbstractMachineEntity) AbstractMachineBlock(crazypants.enderio.base.machine.base.block.AbstractMachineBlock) AbstractMachineBlock(crazypants.enderio.base.machine.base.block.AbstractMachineBlock) Block(net.minecraft.block.Block) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

AbstractMachineEntity (crazypants.enderio.base.machine.base.te.AbstractMachineEntity)5 TileEntity (net.minecraft.tileentity.TileEntity)5 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 AbstractMachineBlock (crazypants.enderio.base.machine.base.block.AbstractMachineBlock)2 Block (net.minecraft.block.Block)2 EnumFacing (net.minecraft.util.EnumFacing)2 VertexTransform (com.enderio.core.api.client.render.VertexTransform)1 BoundingBox (com.enderio.core.client.render.BoundingBox)1 VertexRotation (com.enderio.core.client.render.VertexRotation)1 VertexRotationFacing (com.enderio.core.client.render.VertexRotationFacing)1 VertexScale (com.enderio.core.client.render.VertexScale)1 VertexTranslation (com.enderio.core.client.render.VertexTranslation)1 Vector3d (com.enderio.core.common.vecmath.Vector3d)1 HalfBakedList (crazypants.enderio.base.render.util.HalfBakedQuad.HalfBakedList)1 ArrayList (java.util.ArrayList)1 Particle (net.minecraft.client.particle.Particle)1 ParticleManager (net.minecraft.client.particle.ParticleManager)1 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1