Java Code Examples for net.minecraft.util.MathHelper#floor_float()

The following examples show how to use net.minecraft.util.MathHelper#floor_float() . 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: ServerEventHandler.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@SubscribeEvent
public void entityHurtEvent(LivingHurtEvent event) {
	if (!EtFuturum.enableDmgIndicator)
		return;
	int amount = MathHelper.floor_float(Math.min(event.entityLiving.getHealth(), event.ammount) / 2F);
	if (amount <= 0)
		return;

	// If the attacker is a player spawn the hearts aligned and facing it
	if (event.source instanceof EntityDamageSource) {
		EntityDamageSource src = (EntityDamageSource) event.source;
		Entity attacker = src.getSourceOfDamage();
		if (attacker instanceof EntityPlayer && !(attacker instanceof FakePlayer)) {
			EntityPlayer player = (EntityPlayer) attacker;
			Vec3 look = player.getLookVec();
			look.rotateAroundY((float) Math.PI / 2);
			for (int i = 0; i < amount; i++) {
				double x = event.entityLiving.posX - amount * 0.35 * look.xCoord / 2 + i * 0.35 * look.xCoord;
				double y = event.entityLiving.posY + 1.5 + event.entityLiving.worldObj.rand.nextGaussian() * 0.05;
				double z = event.entityLiving.posZ - amount * 0.35 * look.zCoord / 2 + i * 0.35 * look.zCoord;
				EtFuturum.networkWrapper.sendToAllAround(new BlackHeartParticlesMessage(x, y, z), new TargetPoint(player.worldObj.provider.dimensionId, x, y, z, 64));
			}
		}
	}
}
 
Example 2
Source File: MoCTools.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
public boolean isInsideOfMaterial(Material material, Entity entity)
{
    double d = entity.posY + (double) entity.getEyeHeight();
    int i = MathHelper.floor_double(entity.posX);
    int j = MathHelper.floor_float(MathHelper.floor_double(d));
    int k = MathHelper.floor_double(entity.posZ);
    int l = entity.worldObj.getBlockId(i, j, k);
    if (l != 0 && Block.blocksList[l].blockMaterial == material)
    {
        float f = BlockFluid.getFluidHeightPercent(entity.worldObj.getBlockMetadata(i, j, k)) - 0.1111111F;
        float f1 = (float) (j + 1) - f;
        return d < (double) f1;
    }
    else
    {
        return false;
    }
}
 
Example 3
Source File: HyperiumGuiNewChat.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void setChatLine(IChatComponent chatComponent, int chatLineId, int updateCounter, boolean displayOnly, int scrollPos,
                        boolean isScrolled, List<ChatLine> chatLineList, List<ChatLine> chatLines, Minecraft mc) {
    if (chatLineId != 0) {
        parent.deleteChatLine(chatLineId);
    }

    int i = MathHelper.floor_float((float) parent.getChatWidth() / parent.getChatScale());
    List<IChatComponent> list = GuiUtilRenderComponents.splitText(chatComponent, i, mc.fontRendererObj, false, false);
    boolean flag = parent.getChatOpen();

    list.forEach(ichatcomponent -> {
        if (flag && scrollPos > 0) {
            ((IMixinGuiNewChat) parent).setIsScrolled(isScrolled);
            parent.scroll(1);
        }

        chatLineList.add(0, new ChatLine(updateCounter, ichatcomponent, chatLineId));
    });

    while (chatLineList.size() > 500) {
        chatLineList.remove(chatLineList.size() - 1);
    }

    if (!displayOnly) {
        chatLines.add(0, new ChatLine(updateCounter, chatComponent, chatLineId));

        while (chatLines.size() > 500) {
            chatLines.remove(chatLines.size() - 1);
        }
    }
}
 
Example 4
Source File: Particle.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
public Particle(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, int damage) {
    super(par1World, par2, par4, par6, par8, par10, par12);
    this.Damage = damage;
    this.setSize(0.2f, 0.2f);
    this.yOffset = this.height * 1.1f;
    this.setPosition(par2, par4, par6);
    this.motionX = par8;
    this.motionY = par10;
    this.motionZ = par12;
    float var15 = MathHelper.sqrt_double((this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ));
    this.motionX = this.motionX / var15 * 0.12;
    this.motionY = this.motionY / var15 * 0.12;
    this.motionZ = this.motionZ / var15 * 0.12;
    this.particleTextureJitterX = 1.5f;
    this.particleTextureJitterY = 1.5f;
    this.particleGravity = 0.8f;
    this.particleScale = 3f;
    this.particleMaxAge = 12;
    this.particleAge = 0;
    if (this.Damage < 0) {
        this.heal = true;
        this.Damage = Math.abs(this.Damage);
    }
    try {
        int baseColor = this.heal ? 65280 : 16755200;
        this.red = (baseColor >> 16 & 255) / 255.0f;
        this.green = (baseColor >> 8 & 255) / 255.0f;
        this.blue = (baseColor & 255) / 255.0f;
        this.alpha = 0.9947f;
        this.ul = (this.Damage - MathHelper.floor_float(this.Damage / 16.0f) * 16.0f) % 16.0f / 16.0f;
        this.ur = this.ul + 0.0624375f;
        this.vl = MathHelper.floor_float(this.Damage / 16.0f) * 16.0f / 16.0f / 16.0f;
        this.vr = this.vl + 0.0624375f;
    } catch (Throwable ex) {
        // empty catch block
    }
}
 
Example 5
Source File: Entity.java    From TickDynamic with MIT License 5 votes vote down vote up
/**
 * Checks if the current block the entity is within of the specified material type
 */
public boolean isInsideOfMaterial(Material p_70055_1_)
{
    double d0 = this.posY + (double)this.getEyeHeight();
    int i = MathHelper.floor_double(this.posX);
    int j = MathHelper.floor_float((float)MathHelper.floor_double(d0));
    int k = MathHelper.floor_double(this.posZ);
    Block block = this.worldObj.getBlock(i, j, k);

    if (block.getMaterial() == p_70055_1_)
    {
        double filled = 1.0f; //If it's not a liquid assume it's a solid block
        if (block instanceof IFluidBlock)
        {
            filled = ((IFluidBlock)block).getFilledPercentage(worldObj, i, j, k);
        }

        if (filled < 0)
        {
            filled *= -1;
            //filled -= 0.11111111F; //Why this is needed.. not sure...
            return d0 > (double)(j + (1 - filled));
        }
        else
        {
            return d0 < (double)(j + filled);
        }
    }
    else
    {
        return false;
    }
}
 
Example 6
Source File: PathFinderDrone.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Internal implementation of creating a path from an entity to a point
 */
private PathEntity createEntityPathTo(Entity par1Entity, double par2, double par4, double par6, float par8){
    path.clearPath();
    pointMap.clearMap();
    boolean flag = isPathingInWater;
    int i = MathHelper.floor_double(par1Entity.boundingBox.minY + 0.5D);

    if(canEntityDrown && par1Entity.isInWater()) {
        i = (int)par1Entity.boundingBox.minY;

        for(Block j = worldMap.getBlock(MathHelper.floor_double(par1Entity.posX), i, MathHelper.floor_double(par1Entity.posZ)); j == Blocks.water || j == Blocks.flowing_water; j = worldMap.getBlock(MathHelper.floor_double(par1Entity.posX), i, MathHelper.floor_double(par1Entity.posZ))) {
            ++i;
        }

        flag = isPathingInWater;
        isPathingInWater = false;
    } else {
        i = MathHelper.floor_double(par1Entity.boundingBox.minY + 0.5D);
    }

    PathPoint pathpoint = openPoint(MathHelper.floor_double(par1Entity.boundingBox.minX), i, MathHelper.floor_double(par1Entity.boundingBox.minZ));
    PathPoint pathpoint1 = openPoint(MathHelper.floor_double(par2 - par1Entity.width / 2.0F), MathHelper.floor_double(par4), MathHelper.floor_double(par6 - par1Entity.width / 2.0F));
    PathPoint pathpoint2 = new PathPoint(MathHelper.floor_float(par1Entity.width + 1.0F), MathHelper.floor_float(par1Entity.height + 1.0F), MathHelper.floor_float(par1Entity.width + 1.0F));
    PathEntity pathentity = addToPath(par1Entity, pathpoint, pathpoint1, pathpoint2, par8);
    isPathingInWater = flag;
    return pathentity;
}
 
Example 7
Source File: MixinGuiNewChat.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
@Inject(method = "getChatComponent", at = @At("HEAD"), cancellable = true)
private void getChatComponent(int p_getChatComponent_1_, int p_getChatComponent_2_, final CallbackInfoReturnable<IChatComponent> callbackInfo) {
    final HUD hud = (HUD) LiquidBounce.moduleManager.getModule(HUD.class);

    if(hud.getState() && hud.fontChatValue.get()) {
        if(!this.getChatOpen()) {
            callbackInfo.setReturnValue(null);
        }else{
            ScaledResolution lvt_3_1_ = new ScaledResolution(this.mc);
            int lvt_4_1_ = lvt_3_1_.getScaleFactor();
            float lvt_5_1_ = this.getChatScale();
            int lvt_6_1_ = p_getChatComponent_1_ / lvt_4_1_ - 3;
            int lvt_7_1_ = p_getChatComponent_2_ / lvt_4_1_ - 27;
            lvt_6_1_ = MathHelper.floor_float((float) lvt_6_1_ / lvt_5_1_);
            lvt_7_1_ = MathHelper.floor_float((float) lvt_7_1_ / lvt_5_1_);
            if(lvt_6_1_ >= 0 && lvt_7_1_ >= 0) {
                int lvt_8_1_ = Math.min(this.getLineCount(), this.drawnChatLines.size());
                if(lvt_6_1_ <= MathHelper.floor_float((float) this.getChatWidth() / this.getChatScale()) && lvt_7_1_ < Fonts.font40.FONT_HEIGHT * lvt_8_1_ + lvt_8_1_) {
                    int lvt_9_1_ = lvt_7_1_ / Fonts.font40.FONT_HEIGHT + this.scrollPos;
                    if(lvt_9_1_ >= 0 && lvt_9_1_ < this.drawnChatLines.size()) {
                        ChatLine lvt_10_1_ = (ChatLine) this.drawnChatLines.get(lvt_9_1_);
                        int lvt_11_1_ = 0;
                        Iterator lvt_12_1_ = lvt_10_1_.getChatComponent().iterator();

                        while(lvt_12_1_.hasNext()) {
                            IChatComponent lvt_13_1_ = (IChatComponent) lvt_12_1_.next();
                            if(lvt_13_1_ instanceof ChatComponentText) {
                                lvt_11_1_ += Fonts.font40.getStringWidth(GuiUtilRenderComponents.func_178909_a(((ChatComponentText) lvt_13_1_).getChatComponentText_TextValue(), false));
                                if(lvt_11_1_ > lvt_6_1_) {
                                    callbackInfo.setReturnValue(lvt_13_1_);
                                    return;
                                }
                            }
                        }
                    }

                    callbackInfo.setReturnValue(null);
                }else{
                    callbackInfo.setReturnValue(null);
                }
            }else{
                callbackInfo.setReturnValue(null);
            }
        }
    }
}
 
Example 8
Source File: MixinGuiNewChat.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
@Inject(method = "getChatComponent", at = @At("HEAD"), cancellable = true)
private void getChatComponent(int p_getChatComponent_1_, int p_getChatComponent_2_, final CallbackInfoReturnable<IChatComponent> callbackInfo) {
    final HUD hud = (HUD) LiquidBounce.moduleManager.getModule(HUD.class);

    if(hud.getState() && hud.fontChatValue.get()) {
        if(!this.getChatOpen()) {
            callbackInfo.setReturnValue(null);
        }else{
            ScaledResolution lvt_3_1_ = new ScaledResolution(this.mc);
            int lvt_4_1_ = lvt_3_1_.getScaleFactor();
            float lvt_5_1_ = this.getChatScale();
            int lvt_6_1_ = p_getChatComponent_1_ / lvt_4_1_ - 3;
            int lvt_7_1_ = p_getChatComponent_2_ / lvt_4_1_ - 27;
            lvt_6_1_ = MathHelper.floor_float((float) lvt_6_1_ / lvt_5_1_);
            lvt_7_1_ = MathHelper.floor_float((float) lvt_7_1_ / lvt_5_1_);
            if(lvt_6_1_ >= 0 && lvt_7_1_ >= 0) {
                int lvt_8_1_ = Math.min(this.getLineCount(), this.drawnChatLines.size());
                if(lvt_6_1_ <= MathHelper.floor_float((float) this.getChatWidth() / this.getChatScale()) && lvt_7_1_ < Fonts.font40.FONT_HEIGHT * lvt_8_1_ + lvt_8_1_) {
                    int lvt_9_1_ = lvt_7_1_ / Fonts.font40.FONT_HEIGHT + this.scrollPos;
                    if(lvt_9_1_ >= 0 && lvt_9_1_ < this.drawnChatLines.size()) {
                        ChatLine lvt_10_1_ = (ChatLine) this.drawnChatLines.get(lvt_9_1_);
                        int lvt_11_1_ = 0;
                        Iterator lvt_12_1_ = lvt_10_1_.getChatComponent().iterator();

                        while(lvt_12_1_.hasNext()) {
                            IChatComponent lvt_13_1_ = (IChatComponent) lvt_12_1_.next();
                            if(lvt_13_1_ instanceof ChatComponentText) {
                                lvt_11_1_ += Fonts.font40.getStringWidth(GuiUtilRenderComponents.func_178909_a(((ChatComponentText) lvt_13_1_).getChatComponentText_TextValue(), false));
                                if(lvt_11_1_ > lvt_6_1_) {
                                    callbackInfo.setReturnValue(lvt_13_1_);
                                    return;
                                }
                            }
                        }
                    }

                    callbackInfo.setReturnValue(null);
                }else{
                    callbackInfo.setReturnValue(null);
                }
            }else{
                callbackInfo.setReturnValue(null);
            }
        }
    }
}
 
Example 9
Source File: ConsoleGui.java    From ehacks-pro with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public IChatComponent getChatComponent(int mouseX, int mouseY) {
    if (!this.getChatOpen()) {
        return null;
    } else {
        ScaledResolution scaledresolution = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight);
        int k = scaledresolution.getScaleFactor();
        float f = this.getChatScale();
        int l = mouseX / k - 3;
        int i1 = mouseY / k - 27;
        l = MathHelper.floor_float(l / f);
        i1 = MathHelper.floor_float(i1 / f);

        if (l >= 0 && i1 >= 0) {
            int j1 = Math.min(this.getLineCount(), this.drawnChatLines.size());

            if (l <= MathHelper.floor_float(this.getChatWidth() / this.getChatScale()) && i1 < this.mc.fontRenderer.FONT_HEIGHT * j1 + j1) {
                int k1 = i1 / this.mc.fontRenderer.FONT_HEIGHT + this.scrollPos;

                if (k1 >= 0 && k1 < this.drawnChatLines.size()) {
                    ChatLine chatline = this.drawnChatLines.get(k1);
                    int l1 = 0;

                    for (Object iChatComponent : chatline.func_151461_a()) {
                        if (iChatComponent instanceof ChatComponentText) {
                            l1 += this.mc.fontRenderer.getStringWidth(this.func_146235_b(((ChatComponentText) iChatComponent).getChatComponentText_TextValue()));

                            if (l1 > l) {
                                return (IChatComponent) iChatComponent;
                            }
                        }
                    }
                }

                return null;
            } else {
                return null;
            }
        } else {
            return null;
        }
    }
}
 
Example 10
Source File: ConsoleGui.java    From ehacks-pro with GNU General Public License v3.0 4 votes vote down vote up
public static int calculateChatboxWidth(float p_146233_0_) {
    short short1 = 320;
    byte b0 = 40;
    return MathHelper.floor_float(p_146233_0_ * (short1 - b0) + b0);
}
 
Example 11
Source File: ConsoleGui.java    From ehacks-pro with GNU General Public License v3.0 4 votes vote down vote up
public static int calculateChatboxHeight(float p_146243_0_) {
    short short1 = 180;
    byte b0 = 20;
    return MathHelper.floor_float(p_146243_0_ * (short1 - b0) + b0);
}
 
Example 12
Source File: TileEntityNewBeaconRenderer.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTickTime) {
	TileEntityNewBeacon beacon = (TileEntityNewBeacon) tile;

	float f1 = beacon.func_146002_i();
	OpenGLHelper.alphaFunc(GL11.GL_GREATER, 0.1F);

	if (f1 > 0.0F) {
		Tessellator tessellator = Tessellator.instance;
		List<BeamSegment> list = beacon.getSegments();
		int j = 0;

		for (int i = 0; i < list.size(); i++) {
			BeamSegment beamsegment = list.get(i);
			int l = j + beamsegment.func_177264_c();
			bindTexture(BEAM_TEXTURE);
			GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F);
			GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F);
			OpenGLHelper.disableLighting();
			OpenGLHelper.disableCull();
			OpenGLHelper.disableBlend();
			OpenGLHelper.depthMask(true);
			OpenGlHelper.glBlendFunc(770, 1, 1, 0);
			float f2 = tile.getWorldObj().getTotalWorldTime() + partialTickTime;
			float f3 = -f2 * 0.2F - MathHelper.floor_float(-f2 * 0.1F);
			double d3 = f2 * 0.025D * -1.5D;
			tessellator.startDrawingQuads();
			double d4 = 0.2D;
			double d5 = 0.5D + Math.cos(d3 + 2.356194490192345D) * d4;
			double d6 = 0.5D + Math.sin(d3 + 2.356194490192345D) * d4;
			double d7 = 0.5D + Math.cos(d3 + Math.PI / 4D) * d4;
			double d8 = 0.5D + Math.sin(d3 + Math.PI / 4D) * d4;
			double d9 = 0.5D + Math.cos(d3 + 3.9269908169872414D) * d4;
			double d10 = 0.5D + Math.sin(d3 + 3.9269908169872414D) * d4;
			double d11 = 0.5D + Math.cos(d3 + 5.497787143782138D) * d4;
			double d12 = 0.5D + Math.sin(d3 + 5.497787143782138D) * d4;
			double d13 = 0.0D;
			double d14 = 1.0D;
			double d15 = -1.0F + f3;
			double d16 = beamsegment.func_177264_c() * f1 * (0.5D / d4) + d15;
			tessellator.setColorRGBA_F(beamsegment.func_177263_b()[0], beamsegment.func_177263_b()[1], beamsegment.func_177263_b()[2], 0.125F);
			tessellator.addVertexWithUV(x + d5, y + l, z + d6, d14, d16);
			tessellator.addVertexWithUV(x + d5, y + j, z + d6, d14, d15);
			tessellator.addVertexWithUV(x + d7, y + j, z + d8, d13, d15);
			tessellator.addVertexWithUV(x + d7, y + l, z + d8, d13, d16);
			tessellator.addVertexWithUV(x + d11, y + l, z + d12, d14, d16);
			tessellator.addVertexWithUV(x + d11, y + j, z + d12, d14, d15);
			tessellator.addVertexWithUV(x + d9, y + j, z + d10, d13, d15);
			tessellator.addVertexWithUV(x + d9, y + l, z + d10, d13, d16);
			tessellator.addVertexWithUV(x + d7, y + l, z + d8, d14, d16);
			tessellator.addVertexWithUV(x + d7, y + j, z + d8, d14, d15);
			tessellator.addVertexWithUV(x + d11, y + j, z + d12, d13, d15);
			tessellator.addVertexWithUV(x + d11, y + l, z + d12, d13, d16);
			tessellator.addVertexWithUV(x + d9, y + l, z + d10, d14, d16);
			tessellator.addVertexWithUV(x + d9, y + j, z + d10, d14, d15);
			tessellator.addVertexWithUV(x + d5, y + j, z + d6, d13, d15);
			tessellator.addVertexWithUV(x + d5, y + l, z + d6, d13, d16);
			tessellator.draw();
			OpenGLHelper.enableBlend();
			OpenGlHelper.glBlendFunc(770, 771, 1, 0);
			OpenGLHelper.depthMask(false);
			tessellator.startDrawingQuads();
			tessellator.setColorRGBA_F(beamsegment.func_177263_b()[0], beamsegment.func_177263_b()[1], beamsegment.func_177263_b()[2], 0.125F);
			d3 = 0.2D;
			d4 = 0.2D;
			d5 = 0.8D;
			d6 = 0.2D;
			d7 = 0.2D;
			d8 = 0.8D;
			d9 = 0.8D;
			d10 = 0.8D;
			d11 = 0.0D;
			d12 = 1.0D;
			d13 = -1.0F + f3;
			d14 = beamsegment.func_177264_c() * f1 + d13;
			tessellator.addVertexWithUV(x + d3, y + l, z + d4, d12, d14);
			tessellator.addVertexWithUV(x + d3, y + j, z + d4, d12, d13);
			tessellator.addVertexWithUV(x + d5, y + j, z + d6, d11, d13);
			tessellator.addVertexWithUV(x + d5, y + l, z + d6, d11, d14);
			tessellator.addVertexWithUV(x + d9, y + l, z + d10, d12, d14);
			tessellator.addVertexWithUV(x + d9, y + j, z + d10, d12, d13);
			tessellator.addVertexWithUV(x + d7, y + j, z + d8, d11, d13);
			tessellator.addVertexWithUV(x + d7, y + l, z + d8, d11, d14);
			tessellator.addVertexWithUV(x + d5, y + l, z + d6, d12, d14);
			tessellator.addVertexWithUV(x + d5, y + j, z + d6, d12, d13);
			tessellator.addVertexWithUV(x + d9, y + j, z + d10, d11, d13);
			tessellator.addVertexWithUV(x + d9, y + l, z + d10, d11, d14);
			tessellator.addVertexWithUV(x + d7, y + l, z + d8, d12, d14);
			tessellator.addVertexWithUV(x + d7, y + j, z + d8, d12, d13);
			tessellator.addVertexWithUV(x + d3, y + j, z + d4, d11, d13);
			tessellator.addVertexWithUV(x + d3, y + l, z + d4, d11, d14);
			tessellator.draw();
			OpenGLHelper.enableLighting();
			OpenGLHelper.enableTexture2D();
			OpenGLHelper.depthMask(true);
			j = l;
		}
	}
}
 
Example 13
Source File: ItemArmourStand.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
	if (side == 0)
		return false;
	else {
		if (side == 1)
			y++;
		if (side == 2)
			z--;
		if (side == 3)
			z++;
		if (side == 4)
			x--;
		if (side == 5)
			x++;

		if (!player.canPlayerEdit(x, y, z, side, stack))
			return false;
		else {
			boolean flag1 = !world.isAirBlock(x, y, z) && !world.getBlock(x, y, z).isReplaceable(world, x, y, z);
			flag1 |= !world.isAirBlock(x, y + 1, z) && !world.getBlock(x, y + 1, z).isReplaceable(world, x, y + 1, z);

			if (flag1)
				return false;
			else {
				double d0 = x;
				double d1 = y;
				double d2 = z;
				List<Entity> list = world.getEntitiesWithinAABBExcludingEntity(null, AxisAlignedBB.getBoundingBox(d0, d1, d2, d0 + 1.0D, d1 + 2.0D, d2 + 1.0D));

				if (list.size() > 0)
					return false;
				else {
					if (!world.isRemote) {
						world.setBlockToAir(x, y, z);
						world.setBlockToAir(x, y + 1, z);
						EntityArmourStand stand = new EntityArmourStand(world, d0 + 0.5D, d1, d2 + 0.5D);
						float f3 = MathHelper.floor_float((MathHelper.wrapAngleTo180_float(player.rotationYaw - 180.0F) + 22.5F) / 45.0F) * 45.0F;
						stand.setLocationAndAngles(d0 + 0.5D, d1, d2 + 0.5D, f3, 0.0F);
						applyRandomRotations(stand, world.rand);
						NBTTagCompound nbt = stack.getTagCompound();

						if (nbt != null && nbt.hasKey("EntityTag", 10)) {
							NBTTagCompound nbt1 = new NBTTagCompound();
							stand.writeToNBTOptional(nbt1);
							merge(nbt1, nbt.getCompoundTag("EntityTag"));
							stand.readFromNBT(nbt1);
						}

						world.spawnEntityInWorld(stand);
					}

					stack.stackSize--;
					return true;
				}
			}
		}
	}
}
 
Example 14
Source File: RenderCarvableBeacon.java    From Chisel-2 with GNU General Public License v2.0 4 votes vote down vote up
public void renderTileEntityAt(TileEntityCarvableBeacon beacon, double x, double y, double z, float partialTicks) {
    float f1 = beacon.func_146002_i();
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
    if(f1 > 0.1F){
        Color color = new Color(ItemDye.field_150922_c[beacon.getWorldObj().getBlockMetadata(beacon.xCoord, beacon.yCoord, beacon.zCoord)]);
        Tessellator tessellator = Tessellator.instance;
        this.bindTexture(texture);
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F);
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glDepthMask(true);
        OpenGlHelper.glBlendFunc(770, 1, 1, 0);
        float f2 = (float) beacon.getWorldObj().getTotalWorldTime() + partialTicks;
        float f3 = -f2 * 0.2F - (float) MathHelper.floor_float(-f2 * 0.1F);
        byte b0 = 1;
        double d3 = (double) f2 * 0.025D * (1.0D - (double) (b0 & 1) * 2.5D);
        tessellator.startDrawingQuads();
        tessellator.setColorRGBA(color.getRed(), color.getGreen(), color.getBlue(), 32);
        double d5 = (double) b0 * 0.2D;
        double d7 = 0.5D + Math.cos(d3 + 2.356194490192345D) * d5;
        double d9 = 0.5D + Math.sin(d3 + 2.356194490192345D) * d5;
        double d11 = 0.5D + Math.cos(d3 + (Math.PI / 4D)) * d5;
        double d13 = 0.5D + Math.sin(d3 + (Math.PI / 4D)) * d5;
        double d15 = 0.5D + Math.cos(d3 + 3.9269908169872414D) * d5;
        double d17 = 0.5D + Math.sin(d3 + 3.9269908169872414D) * d5;
        double d19 = 0.5D + Math.cos(d3 + 5.497787143782138D) * d5;
        double d21 = 0.5D + Math.sin(d3 + 5.497787143782138D) * d5;
        double d23 = (double) (256.0F * f1);
        double d25 = 0.0D;
        double d27 = 1.0D;
        double d28 = (double) (-1.0F + f3);
        double d29 = (double) (256.0F * f1) * (0.5D / d5) + d28;
        tessellator.addVertexWithUV(x + d7, y + d23, z + d9, d27, d29);
        tessellator.addVertexWithUV(x + d7, y, z + d9, d27, d28);
        tessellator.addVertexWithUV(x + d11, y, z + d13, d25, d28);
        tessellator.addVertexWithUV(x + d11, y + d23, z + d13, d25, d29);
        tessellator.addVertexWithUV(x + d19, y + d23, z + d21, d27, d29);
        tessellator.addVertexWithUV(x + d19, y, z + d21, d27, d28);
        tessellator.addVertexWithUV(x + d15, y, z + d17, d25, d28);
        tessellator.addVertexWithUV(x + d15, y + d23, z + d17, d25, d29);
        tessellator.addVertexWithUV(x + d11, y + d23, z + d13, d27, d29);
        tessellator.addVertexWithUV(x + d11, y, z + d13, d27, d28);
        tessellator.addVertexWithUV(x + d19, y, z + d21, d25, d28);
        tessellator.addVertexWithUV(x + d19, y + d23, z + d21, d25, d29);
        tessellator.addVertexWithUV(x + d15, y + d23, z + d17, d27, d29);
        tessellator.addVertexWithUV(x + d15, y, z + d17, d27, d28);
        tessellator.addVertexWithUV(x + d7, y, z + d9, d25, d28);
        tessellator.addVertexWithUV(x + d7, y + d23, z + d9, d25, d29);
        tessellator.draw();
        GL11.glEnable(GL11.GL_BLEND);
        OpenGlHelper.glBlendFunc(770, 771, 1, 0);
        GL11.glDepthMask(false);
        tessellator.startDrawingQuads();
        tessellator.setColorRGBA(color.getRed(), color.getGreen(), color.getBlue(), 32);
        double d30 = 0.2D;
        double d4 = 0.2D;
        double d6 = 0.8D;
        double d8 = 0.2D;
        double d10 = 0.2D;
        double d12 = 0.8D;
        double d14 = 0.8D;
        double d16 = 0.8D;
        double d18 = (double) (256.0F * f1);
        double d20 = 0.0D;
        double d22 = 1.0D;
        double d24 = (double) (-1.0F + f3);
        double d26 = (double) (256.0F * f1) + d24;
        tessellator.addVertexWithUV(x + d30, y + d18, z + d4, d22, d26);
        tessellator.addVertexWithUV(x + d30, y, z + d4, d22, d24);
        tessellator.addVertexWithUV(x + d6, y, z + d8, d20, d24);
        tessellator.addVertexWithUV(x + d6, y + d18, z + d8, d20, d26);
        tessellator.addVertexWithUV(x + d14, y + d18, z + d16, d22, d26);
        tessellator.addVertexWithUV(x + d14, y, z + d16, d22, d24);
        tessellator.addVertexWithUV(x + d10, y, z + d12, d20, d24);
        tessellator.addVertexWithUV(x + d10, y + d18, z + d12, d20, d26);
        tessellator.addVertexWithUV(x + d6, y + d18, z + d8, d22, d26);
        tessellator.addVertexWithUV(x + d6, y, z + d8, d22, d24);
        tessellator.addVertexWithUV(x + d14, y, z + d16, d20, d24);
        tessellator.addVertexWithUV(x + d14, y + d18, z + d16, d20, d26);
        tessellator.addVertexWithUV(x + d10, y + d18, z + d12, d22, d26);
        tessellator.addVertexWithUV(x + d10, y, z + d12, d22, d24);
        tessellator.addVertexWithUV(x + d30, y, z + d4, d20, d24);
        tessellator.addVertexWithUV(x + d30, y + d18, z + d4, d20, d26);
        tessellator.draw();
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glDepthMask(true);
    }
}