Search in sources :

Example 1 with IBoreHead

use of mods.railcraft.api.carts.bore.IBoreHead in project Railcraft by Railcraft.

the class EntityTunnelBore method canHeadHarvestBlock.

public static boolean canHeadHarvestBlock(@Nullable ItemStack head, IBlockState targetState) {
    if (InvTools.isEmpty(head))
        return false;
    if (head.getItem() instanceof IBoreHead) {
        IBoreHead boreHead = (IBoreHead) head.getItem();
        boolean mappingExists = false;
        int blockHarvestLevel = HarvestPlugin.getHarvestLevel(targetState, "pickaxe");
        if (blockHarvestLevel > -1) {
            if (boreHead.getHarvestLevel() >= blockHarvestLevel)
                return true;
            mappingExists = true;
        }
        blockHarvestLevel = HarvestPlugin.getHarvestLevel(targetState, "axe");
        if (blockHarvestLevel > -1) {
            if (boreHead.getHarvestLevel() >= blockHarvestLevel)
                return true;
            mappingExists = true;
        }
        blockHarvestLevel = HarvestPlugin.getHarvestLevel(targetState, "shovel");
        if (blockHarvestLevel > -1) {
            if (boreHead.getHarvestLevel() >= blockHarvestLevel)
                return true;
            mappingExists = true;
        }
        if (mappingExists)
            return false;
    }
    return true;
}
Also used : IBoreHead(mods.railcraft.api.carts.bore.IBoreHead)

Example 2 with IBoreHead

use of mods.railcraft.api.carts.bore.IBoreHead in project Railcraft by Railcraft.

the class EntityTunnelBore method getLayerHardness.

protected float getLayerHardness(BlockPos targetPos, BlockRailBase.EnumRailDirection dir) {
    float hardness = layerAction(targetPos, dir, 0F, this::getBlockHardness, (s, r) -> s + r);
    hardness *= HARDNESS_MULTIPLIER;
    ItemStack boreSlot = getStackInSlot(0);
    if (!InvTools.isEmpty(boreSlot) && boreSlot.getItem() instanceof IBoreHead) {
        IBoreHead head = (IBoreHead) boreSlot.getItem();
        float dig = 2f - head.getDigModifier();
        hardness *= dig;
        int e = EnchantmentHelper.getEnchantmentLevel(Enchantments.EFFICIENCY, boreSlot);
        hardness /= e * e * 0.2 + 1;
    }
    hardness /= RailcraftConfig.boreMiningSpeedMultiplier();
    return hardness;
}
Also used : IBoreHead(mods.railcraft.api.carts.bore.IBoreHead) ItemStack(net.minecraft.item.ItemStack)

Example 3 with IBoreHead

use of mods.railcraft.api.carts.bore.IBoreHead in project Railcraft by Railcraft.

the class RenderTunnelBore method doRender.

@Override
public void doRender(EntityTunnelBore bore, double x, double y, double z, float entityYaw, float partialTicks) {
    // System.out.println("Render Yaw = " + f);
    OpenGL.glPushMatrix();
    long var10 = (long) bore.getEntityId() * 493286711L;
    var10 = var10 * var10 * 4392167121L + var10 * 98761L;
    float tx = (((float) (var10 >> 16 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
    float ty = (((float) (var10 >> 20 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
    float tz = (((float) (var10 >> 24 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
    OpenGL.glTranslatef(tx, ty, tz);
    RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
    if (renderManager.isDebugBoundingBox()) {
        //            GlStateManager.depthMask(false);
        GlStateManager.disableTexture2D();
        GlStateManager.disableLighting();
        GlStateManager.disableCull();
        GlStateManager.disableBlend();
        for (Entity part : bore.getParts()) {
            OpenGL.glPushMatrix();
            double posX = part.lastTickPosX + (part.posX - part.lastTickPosX) * (double) partialTicks - TileEntityRendererDispatcher.staticPlayerX;
            double posY = part.lastTickPosY + (part.posY - part.lastTickPosY) * (double) partialTicks - TileEntityRendererDispatcher.staticPlayerY;
            double posZ = part.lastTickPosZ + (part.posZ - part.lastTickPosZ) * (double) partialTicks - TileEntityRendererDispatcher.staticPlayerZ;
            OpenGL.glTranslatef((float) posX, (float) posY, (float) posZ);
            float halfWidth = part.width / 2.0F;
            RenderGlobal.drawBoundingBox(-halfWidth, 0.0, -halfWidth, halfWidth, part.height, halfWidth, 1, 0, 0, 1);
            OpenGL.glPopMatrix();
        }
        GlStateManager.enableTexture2D();
        GlStateManager.enableLighting();
        GlStateManager.enableCull();
        GlStateManager.disableBlend();
    //            GlStateManager.depthMask(true);
    }
    OpenGL.glTranslatef(0F, 0.375F, 0F);
    OpenGL.glTranslatef((float) x, (float) y, (float) z);
    OpenGL.glRotatef(180F - entityYaw, 0.0F, 1.0F, 0.0F);
    OpenGL.glRotatef(90, 0.0F, 1.0F, 0.0F);
    float f3 = (float) bore.getRollingAmplitude() - partialTicks;
    float f4 = bore.getDamage() - partialTicks;
    if (f4 < 0.0F) {
        f4 = 0.0F;
    }
    if (f3 > 0.0F) {
        float angle = (MathHelper.sin(f3) * f3 * f4) / 10F;
        angle = Math.min(angle, 0.8f);
        angle = Math.copySign(angle, bore.getRollingDirection());
        OpenGL.glRotatef(angle, 1.0F, 0.0F, 0.0F);
    }
    float light = bore.getBrightness(partialTicks);
    light = light + ((1.0f - light) * 0.4f);
    //        boolean ghost = SeasonPlugin.isGhostTrain(bore);
    //        if (ghost)
    //            GlStateManager.enableBlend();
    int j = 0xffffff;
    float c1 = (float) (j >> 16 & 0xff) / 255F;
    float c2 = (float) (j >> 8 & 0xff) / 255F;
    float c3 = (float) (j & 0xff) / 255F;
    OpenGL.glColor4f(c1 * light, c2 * light, c3 * light, 1.0F);
    IBoreHead head = bore.getBoreHead();
    if (head != null) {
        bindTexture(head.getBoreTexture());
        modelTunnelBore.setRenderBoreHead(true);
    } else {
        bindTexture(TEXTURE);
        modelTunnelBore.setRenderBoreHead(false);
    }
    OpenGL.glScalef(-1F, -1F, 1.0F);
    modelTunnelBore.setBoreHeadRotation(bore.getBoreRotationAngle());
    modelTunnelBore.setBoreActive(bore.isMinecartPowered());
    modelTunnelBore.render(0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
    //        if (ghost)
    //            GlStateManager.disableBlend();
    OpenGL.glPopMatrix();
}
Also used : Entity(net.minecraft.entity.Entity) IBoreHead(mods.railcraft.api.carts.bore.IBoreHead) RenderManager(net.minecraft.client.renderer.entity.RenderManager)

Aggregations

IBoreHead (mods.railcraft.api.carts.bore.IBoreHead)3 RenderManager (net.minecraft.client.renderer.entity.RenderManager)1 Entity (net.minecraft.entity.Entity)1 ItemStack (net.minecraft.item.ItemStack)1