use of com.axanthic.loi.blocks.BlockGrinder in project Lands-of-Icaria by Axanthic-Game-Studios.
the class TileEntityGrinder method update.
/**
* Like the old updateEntity(), except more generic.
*/
public void update() {
boolean flag = this.isGrinding();
boolean flag1 = false;
if (!this.world.isRemote) {
ItemStack itemstack = this.inventoryItems.get(1);
if (this.isBurning() || !itemstack.isEmpty() && !((ItemStack) this.inventoryItems.get(0)).isEmpty()) {
if (!this.isBurning() && this.canGrind()) {
this.burnTime = GrinderFuel.getItemBurnTime(itemstack);
this.currentItemBurnTime = this.burnTime;
if (this.isBurning()) {
flag1 = true;
if (!itemstack.isEmpty()) {
Item item = itemstack.getItem();
itemstack.shrink(1);
if (itemstack.isEmpty()) {
ItemStack item1 = item.getContainerItem(itemstack);
this.inventoryItems.set(1, item1);
}
}
}
}
if (this.isBurning() && this.canGrind()) {
++this.cookTime;
--this.burnTime;
if (this.cookTime == this.totalCookTime) {
this.cookTime = 0;
this.totalCookTime = this.getCookTime(this.inventoryItems.get(0));
this.grindItem();
flag1 = true;
}
} else {
this.cookTime = 0;
}
} else if (!this.isBurning() && this.cookTime > 0) {
this.cookTime = MathHelper.clamp(this.cookTime - 2, 0, this.totalCookTime);
}
if (flag != this.isGrinding()) {
flag1 = true;
((BlockGrinder) this.world.getBlockState(this.pos).getBlock()).setState(this.world.getBlockState(this.pos).withProperty(BlockGrinder.BURNING, this.canGrind()), this.world, pos);
}
} else {
if (this.isGrinding()) {
if (this.lastSound > 285) {
this.world.playSound((double) pos.getX() + 0.5D, (double) pos.getY(), (double) pos.getZ() + 0.5D, IcariaSounds.GRIND, SoundCategory.BLOCKS, 0.7F, 1.0F, false);
this.lastSound = 0;
} else
this.lastSound++;
} else
this.lastSound++;
}
if (flag1) {
this.markDirty();
}
if (this.isGrinding()) {
double d0 = (double) pos.getX() + 8.0D / 16.0D;
double d1 = (double) pos.getY() + 8.0D / 16.0D;
double d2 = (double) pos.getZ() + 8.0D / 16.0D;
ItemStack stack = this.getStackInSlot(0);
if (!stack.isEmpty()) {
if (this.world instanceof WorldServer)
((WorldServer) this.world).spawnParticle(EnumParticleTypes.ITEM_CRACK, d0, d1 + 7.0D / 16.0D, d2, 0.0D, 0.3D, 0.0D, Item.getIdFromItem(stack.getItem()), stack.getMetadata());
else
this.world.spawnParticle(EnumParticleTypes.ITEM_CRACK, d0, d1 + 7.0D / 16.0D, d2, 0.0D, 0.3D, 0.0D, Item.getIdFromItem(stack.getItem()), stack.getMetadata());
}
}
}
use of com.axanthic.loi.blocks.BlockGrinder in project Lands-of-Icaria by Axanthic-Game-Studios.
the class LOIItemStackRenderer method renderByItem.
public void renderByItem(ItemStack stack, float partialTicks) {
Item item = stack.getItem();
if (item instanceof ItemBlockMobHead) {
if (TileEntitySpecialRendererMobHead.instance != null) {
GlStateManager.pushMatrix();
GlStateManager.disableCull();
TileEntitySpecialRendererMobHead.instance.renderSkull(0.0F, 0.1F, 0.0F, EnumFacing.DOWN, 0.0F, ((BlockMobHead) ((ItemBlock) item).getBlock()).name, -1, 1.6F);
GlStateManager.enableCull();
GlStateManager.popMatrix();
}
}
if (item instanceof ItemSaltedFood) {
GlStateManager.pushMatrix();
GlStateManager.translate(0.5F, 0.5F, 0.5F);
if (stack.hasTagCompound()) {
ItemStack foodStack = ItemSaltedFood.getContainedItem(stack.getTagCompound());
if (!foodStack.isEmpty())
Minecraft.getMinecraft().getRenderItem().renderItem(foodStack, ItemCameraTransforms.TransformType.NONE);
}
Minecraft.getMinecraft().getRenderItem().renderItem(saltOverlay, ItemCameraTransforms.TransformType.NONE);
GlStateManager.popMatrix();
}
if (item instanceof ItemBlock && ((ItemBlock) item).getBlock() instanceof BlockGrinder) {
if (TileEntitySpecialRendererGrinder.instance != null) {
GlStateManager.pushMatrix();
GlStateManager.disableCull();
TileEntitySpecialRendererGrinder.instance.renderInventory();
GlStateManager.enableCull();
GlStateManager.popMatrix();
}
}
if (item instanceof ItemScroll) {
ItemScroll scroll = ((ItemScroll) item);
if (!Minecraft.getMinecraft().player.isInvisible()) {
EnumHand rightHand = EnumHand.MAIN_HAND;
EnumHand leftHand = EnumHand.OFF_HAND;
if (Minecraft.getMinecraft().player.getPrimaryHand() == EnumHandSide.LEFT) {
rightHand = EnumHand.OFF_HAND;
leftHand = EnumHand.MAIN_HAND;
}
// render player arms
if (BakedModelScroll.transform == TransformType.FIRST_PERSON_RIGHT_HAND) {
GlStateManager.translate(((float) Minecraft.getMinecraft().displayWidth) / ((float) Minecraft.getMinecraft().displayHeight) * 0.5F, 0.9F, 0.4F);
GlStateManager.disableCull();
GlStateManager.pushMatrix();
GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
if (Minecraft.getMinecraft().player.getHeldItem(leftHand).isEmpty() && rightHand != EnumHand.OFF_HAND)
renderArm(EnumHandSide.LEFT);
GlStateManager.translate(0.0F, 0.3F, -0.7F);
GlStateManager.rotate(-60.0F, 1.0F, 0.0F, 0.0F);
renderArm(EnumHandSide.RIGHT);
GlStateManager.popMatrix();
GlStateManager.enableCull();
}
if (BakedModelScroll.transform == TransformType.FIRST_PERSON_LEFT_HAND) {
GlStateManager.translate(((float) Minecraft.getMinecraft().displayWidth) / ((float) Minecraft.getMinecraft().displayHeight) * -0.5F + 1.68F, 0.9F, 0.4F);
GlStateManager.disableCull();
GlStateManager.pushMatrix();
GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.translate(-0.1F, 0.03F, -0.7F);
if (Minecraft.getMinecraft().player.getHeldItem(rightHand).isEmpty() && leftHand != EnumHand.OFF_HAND)
renderArm(EnumHandSide.RIGHT);
GlStateManager.translate(0.1F, 0.27F, 0.7F);
GlStateManager.rotate(60.0F, 1.0F, 0.0F, 0.0F);
renderArm(EnumHandSide.LEFT);
GlStateManager.popMatrix();
GlStateManager.enableCull();
}
}
// render scroll background
GlStateManager.scale(0.76F, 0.76F, 0.76F);
GlStateManager.disableLighting();
Minecraft.getMinecraft().getTextureManager().bindTexture(RES_SCROLL_BACKGROUND);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
GlStateManager.translate(-1.0F, -0.6F, -0.2F);
GlStateManager.scale(0.0078125F, 0.0078125F, 0.0078125F);
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
bufferbuilder.pos(0.0D, 0.0D, 0.0D).tex(0.0D, 1.0D).endVertex();
bufferbuilder.pos(142.0D, 0.0D, 0.0D).tex(1.0D, 1.0D).endVertex();
bufferbuilder.pos(142.0D, 142.0D, 0.0D).tex(1.0D, 0.0D).endVertex();
bufferbuilder.pos(0.0D, 142.0D, 0.0D).tex(0.0D, 0.0D).endVertex();
tessellator.draw();
GlStateManager.translate(71.0F, 44.5F, 0.01F);
// render scroll title
GlStateManager.pushMatrix();
GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
String title = I18n.translateToLocal("spell." + scroll.getName() + ".name");
fontRenderer.drawString(title, -fontRenderer.getStringWidth(title) / 2, -60, 0x82735A);
GlStateManager.popMatrix();
GlStateManager.scale(25.0F, 25.0F, 0.001F);
// render ingredients
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
GlStateManager.pushMatrix();
GlStateManager.scale(0.6F, 0.6F, 1.0F);
GlStateManager.translate(0.55F - scroll.getRecipe().order.size() * 0.55F, 2.5F, 0.0F);
for (int i = 0; i < scroll.getRecipe().order.size(); ++i) {
Minecraft.getMinecraft().getRenderItem().renderItem(scroll.getRecipe().getInputs().get(scroll.getRecipe().order.get(i)).getMatchingStacks()[0], ItemCameraTransforms.TransformType.GUI);
GlStateManager.translate(1.1F, 0.0F, 0.0F);
}
GlStateManager.popMatrix();
// render result
Minecraft.getMinecraft().getRenderItem().renderItem(scroll.getRecipe().recipeOutput, ItemCameraTransforms.TransformType.GUI);
GlStateManager.enableLighting();
}
}
Aggregations