-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
823 additions
and
129 deletions.
There are no files selected for viewing
113 changes: 113 additions & 0 deletions
113
src/main/java/mod/emt/harkenscythe/blocks/HSBloodAltar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package mod.emt.harkenscythe.blocks; | ||
|
||
import mod.emt.harkenscythe.init.HSAltarRecipes; | ||
import mod.emt.harkenscythe.init.HSItems; | ||
import mod.emt.harkenscythe.init.HSSoundEvents; | ||
import mod.emt.harkenscythe.tileentities.HSTileEntityBloodAltar; | ||
import net.minecraft.block.BlockEnchantmentTable; | ||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.entity.item.EntityItem; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.init.SoundEvents; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.util.EnumFacing; | ||
import net.minecraft.util.EnumHand; | ||
import net.minecraft.util.EnumParticleTypes; | ||
import net.minecraft.util.SoundCategory; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
|
||
public class HSBloodAltar extends BlockEnchantmentTable | ||
{ | ||
public HSBloodAltar() | ||
{ | ||
super(); | ||
} | ||
|
||
@Override | ||
public boolean hasTileEntity(IBlockState state) | ||
{ | ||
return true; | ||
} | ||
|
||
@Override | ||
public void breakBlock(World world, BlockPos pos, IBlockState state) | ||
{ | ||
TileEntity te = world.getTileEntity(pos); | ||
if (te instanceof HSTileEntityBloodAltar) | ||
{ | ||
HSTileEntityBloodAltar altar = (HSTileEntityBloodAltar) te; | ||
altar.dropItem(); | ||
} | ||
super.breakBlock(world, pos, state); | ||
} | ||
|
||
@Override | ||
public TileEntity createNewTileEntity(World worldIn, int meta) | ||
{ | ||
return new HSTileEntityBloodAltar(); | ||
} | ||
|
||
@Override | ||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) | ||
{ | ||
TileEntity te = world.getTileEntity(pos); | ||
if (te instanceof HSTileEntityBloodAltar) | ||
{ | ||
HSTileEntityBloodAltar altar = (HSTileEntityBloodAltar) te; | ||
ItemStack heldItem = player.getHeldItem(hand); | ||
|
||
if (heldItem.getItem() == HSItems.harken_athame) | ||
{ | ||
if (altar.isValidRecipe()) | ||
{ | ||
Item item = altar.getItemStack().getItem(); | ||
int requiredBloods = HSAltarRecipes.getRequiredBlood(altar.getItemStack().getItem()); | ||
altar.decreaseCrucibleLevel(requiredBloods / 10); | ||
altar.getItemStack().shrink(1); | ||
if (!player.world.isRemote) player.world.spawnEntity(new EntityItem(player.world, altar.getPos().getX() + 0.5D, altar.getPos().getY() + 1.5D, altar.getPos().getZ() + 0.5D, new ItemStack(HSAltarRecipes.getOutputBlood(item)))); | ||
player.world.playSound(altar.getPos().getX(), altar.getPos().getY(), altar.getPos().getZ(), HSSoundEvents.BLOCK_BLOOD_ALTAR_ENCHANT, SoundCategory.BLOCKS, 0.8F, 1.5F / (altar.getWorld().rand.nextFloat() * 0.4F + 1.2F), false); | ||
player.world.playSound(altar.getPos().getX(), altar.getPos().getY(), altar.getPos().getZ(), SoundEvents.ENTITY_ENDEREYE_DEATH, SoundCategory.BLOCKS, 1.0F, 1.5F / (altar.getWorld().rand.nextFloat() * 0.4F + 1.2F), false); | ||
for (int i = 0; i < requiredBloods; i++) | ||
{ | ||
player.world.spawnParticle(EnumParticleTypes.SPELL_WITCH, altar.getPos().getX() + 0.5D, altar.getPos().getY() + 2.0D, altar.getPos().getZ() + 0.5D, 0.0D, 0.0D, 0.0D); | ||
} | ||
altar.updateBloodCount(); | ||
altar.updateRecipe(); | ||
return true; | ||
} | ||
} | ||
else if (!heldItem.isEmpty()) | ||
{ | ||
ItemStack altarItem = altar.getItemStack(); | ||
if (altarItem.isEmpty()) | ||
{ | ||
altar.setItemStack(heldItem.splitStack(1)); | ||
player.world.playSound(altar.getPos().getX(), altar.getPos().getY(), altar.getPos().getZ(), SoundEvents.BLOCK_END_PORTAL_FRAME_FILL, SoundCategory.BLOCKS, 1.0F, 1.5F / (altar.getWorld().rand.nextFloat() * 0.4F + 1.2F), false); | ||
return true; | ||
} | ||
else if (altarItem.getMaxStackSize() > altarItem.getCount() && ItemStack.areItemsEqual(altarItem, heldItem) && ItemStack.areItemStackTagsEqual(altarItem, heldItem)) | ||
{ | ||
heldItem.shrink(1); | ||
player.world.playSound(altar.getPos().getX(), altar.getPos().getY(), altar.getPos().getZ(), SoundEvents.BLOCK_END_PORTAL_FRAME_FILL, SoundCategory.BLOCKS, 1.0F, 1.5F / (altar.getWorld().rand.nextFloat() * 0.4F + 1.2F), false); | ||
altarItem.grow(1); | ||
return true; | ||
} | ||
} | ||
else | ||
{ | ||
ItemStack itemStack = altar.getItemStack(); | ||
if (!itemStack.isEmpty()) | ||
{ | ||
player.addItemStackToInventory(itemStack); | ||
player.world.playSound(altar.getPos().getX(), altar.getPos().getY(), altar.getPos().getZ(), SoundEvents.ENTITY_ENDEREYE_DEATH, SoundCategory.BLOCKS, 1.0F, 1.5F / (altar.getWorld().rand.nextFloat() * 0.4F + 1.2F), false); | ||
altar.setItemStack(ItemStack.EMPTY); | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 changes: 137 additions & 0 deletions
137
src/main/java/mod/emt/harkenscythe/client/renderers/RenderHSBloodAltar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
package mod.emt.harkenscythe.client.renderers; | ||
|
||
import mod.emt.harkenscythe.HarkenScythe; | ||
import mod.emt.harkenscythe.tileentities.HSTileEntityBloodAltar; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.model.ModelBook; | ||
import net.minecraft.client.renderer.GlStateManager; | ||
import net.minecraft.client.renderer.RenderHelper; | ||
import net.minecraft.client.renderer.RenderItem; | ||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms; | ||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.ResourceLocation; | ||
import net.minecraft.util.math.MathHelper; | ||
import net.minecraft.world.World; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
|
||
@SideOnly(Side.CLIENT) | ||
public class RenderHSBloodAltar extends TileEntitySpecialRenderer<HSTileEntityBloodAltar> | ||
{ | ||
private static final ResourceLocation TEXTURE_BOOK = new ResourceLocation(HarkenScythe.MOD_ID, "textures/entities/blood_altar_book.png"); | ||
private final ModelBook modelBook = new ModelBook(); | ||
|
||
@Override | ||
public void render(HSTileEntityBloodAltar te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) | ||
{ | ||
GlStateManager.pushMatrix(); | ||
RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); | ||
World world = te.getWorld(); | ||
//noinspection ConstantConditions | ||
if (world == null) return; | ||
|
||
GlStateManager.pushAttrib(); | ||
GlStateManager.disableLighting(); | ||
GlStateManager.translate(x, y, z); | ||
|
||
GlStateManager.pushMatrix(); | ||
float timeD = (float) (360.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL); | ||
GlStateManager.translate(0.20, 0.25, 0.25); | ||
RenderHelper.enableStandardItemLighting(); | ||
GlStateManager.pushAttrib(); | ||
|
||
ItemStack stack = te.getItemStack(); | ||
if (!stack.isEmpty()) | ||
{ | ||
GlStateManager.pushMatrix(); | ||
GlStateManager.translate(0.25, 1.75, 0.25); | ||
GlStateManager.rotate(timeD, 0, 1, 0); | ||
renderItem.renderItem(stack, ItemCameraTransforms.TransformType.FIXED); | ||
GlStateManager.popMatrix(); | ||
} | ||
|
||
RenderHelper.disableStandardItemLighting(); | ||
GlStateManager.popAttrib(); | ||
GlStateManager.popMatrix(); | ||
|
||
GlStateManager.popAttrib(); | ||
GlStateManager.popMatrix(); | ||
|
||
GlStateManager.pushMatrix(); | ||
GlStateManager.translate((float) x + 0.5F, (float) y + 0.75F, (float) z + 0.5F); | ||
float f = (float) te.tickCount + partialTicks; | ||
GlStateManager.translate(0.0F, 0.1F + MathHelper.sin(f * 0.1F) * 0.01F, 0.0F); | ||
float f1; | ||
|
||
for (f1 = te.bookRotation - te.bookRotationPrev; f1 >= (float) Math.PI; f1 -= ((float) Math.PI * 2F)) {} | ||
|
||
while (f1 < -(float) Math.PI) | ||
{ | ||
f1 += ((float) Math.PI * 2F); | ||
} | ||
|
||
float f2 = te.bookRotationPrev + f1 * partialTicks; | ||
GlStateManager.rotate(-f2 * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F); | ||
GlStateManager.rotate(80.0F, 0.0F, 0.0F, 1.0F); | ||
this.bindTexture(TEXTURE_BOOK); | ||
float f3 = te.pageFlipPrev + (te.pageFlip - te.pageFlipPrev) * partialTicks + 0.25F; | ||
float f4 = te.pageFlipPrev + (te.pageFlip - te.pageFlipPrev) * partialTicks + 0.75F; | ||
f3 = (f3 - (float) MathHelper.fastFloor(f3)) * 1.6F - 0.3F; | ||
f4 = (f4 - (float) MathHelper.fastFloor(f4)) * 1.6F - 0.3F; | ||
|
||
if (f3 < 0.0F) | ||
{ | ||
f3 = 0.0F; | ||
} | ||
|
||
if (f4 < 0.0F) | ||
{ | ||
f4 = 0.0F; | ||
} | ||
|
||
if (f3 > 1.0F) | ||
{ | ||
f3 = 1.0F; | ||
} | ||
|
||
if (f4 > 1.0F) | ||
{ | ||
f4 = 1.0F; | ||
} | ||
|
||
float f5 = te.bookSpreadPrev + (te.bookSpread - te.bookSpreadPrev) * partialTicks; | ||
GlStateManager.enableCull(); | ||
this.modelBook.render(null, f, f3, f4, f5, 0.0F, 0.0625F); | ||
GlStateManager.popMatrix(); | ||
|
||
if (!stack.isEmpty()) | ||
{ | ||
int textColor = te.isValidRecipe() ? 0x00FF00 : 0xFFFFFF; | ||
|
||
// Display blood count | ||
String bloodText = "Blood: " + te.getBloodCount(); | ||
GlStateManager.pushMatrix(); | ||
GlStateManager.translate(x + 0.5, y + 1.5, z + 0.5); | ||
GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0, 1, 0); | ||
GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1, 0, 0); | ||
GlStateManager.scale(-0.025f, -0.025f, 0.025f); | ||
GlStateManager.disableLighting(); | ||
Minecraft.getMinecraft().fontRenderer.drawString(bloodText, -Minecraft.getMinecraft().fontRenderer.getStringWidth(bloodText) / 2, 0, textColor); | ||
GlStateManager.enableLighting(); | ||
GlStateManager.popMatrix(); | ||
|
||
// Display input stack count | ||
String stackText = String.valueOf(stack.getCount()); | ||
GlStateManager.pushMatrix(); | ||
GlStateManager.translate(x + 0.5, y + 2.7, z + 0.5); | ||
GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0, 1, 0); | ||
GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1, 0, 0); | ||
GlStateManager.scale(-0.025f, -0.025f, 0.025f); | ||
GlStateManager.disableLighting(); | ||
Minecraft.getMinecraft().fontRenderer.drawString(stackText, -Minecraft.getMinecraft().fontRenderer.getStringWidth(stackText) / 2, 0, textColor); | ||
GlStateManager.enableLighting(); | ||
GlStateManager.popMatrix(); | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/main/java/mod/emt/harkenscythe/client/renderers/RenderHSEntityBlood.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package mod.emt.harkenscythe.client.renderers; | ||
|
||
import mod.emt.harkenscythe.HarkenScythe; | ||
import mod.emt.harkenscythe.client.models.ModelHSEntityEssence; | ||
import mod.emt.harkenscythe.entities.HSEntityBlood; | ||
import net.minecraft.client.model.ModelBase; | ||
import net.minecraft.client.renderer.GlStateManager; | ||
import net.minecraft.client.renderer.entity.Render; | ||
import net.minecraft.client.renderer.entity.RenderManager; | ||
import net.minecraft.util.ResourceLocation; | ||
import net.minecraft.util.math.MathHelper; | ||
import net.minecraftforge.fml.client.registry.IRenderFactory; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
|
||
@SideOnly(Side.CLIENT) | ||
public class RenderHSEntityBlood extends Render<HSEntityBlood> | ||
{ | ||
private static final ResourceLocation BLOOD_TEXTURES = new ResourceLocation(HarkenScythe.MOD_ID, "textures/entities/blood_common.png"); | ||
private final ModelBase modelEssence = new ModelHSEntityEssence(); | ||
|
||
public RenderHSEntityBlood(RenderManager renderManagerIn) | ||
{ | ||
super(renderManagerIn); | ||
this.shadowSize = 0.0F; | ||
} | ||
|
||
@Override | ||
public void doRender(HSEntityBlood entity, double x, double y, double z, float entityYaw, float partialTicks) | ||
{ | ||
float f = (float) entity.getInnerRotation() + partialTicks; | ||
GlStateManager.pushMatrix(); | ||
GlStateManager.translate((float) x, (float) y, (float) z); | ||
this.bindTexture(BLOOD_TEXTURES); | ||
float f1 = MathHelper.sin(f * 0.2F) / 2.0F + 0.5F; | ||
f1 = f1 * f1 + f1; | ||
this.modelEssence.render(entity, 0.0F, f * 3.0F, f1 * 0.2F, 0.0F, 0.0F, 0.0625F); | ||
GlStateManager.popMatrix(); | ||
super.doRender(entity, x, y, z, entityYaw, partialTicks); | ||
} | ||
|
||
@Override | ||
protected ResourceLocation getEntityTexture(HSEntityBlood entity) | ||
{ | ||
return BLOOD_TEXTURES; | ||
} | ||
|
||
public static class Factory implements IRenderFactory<HSEntityBlood> | ||
{ | ||
@Override | ||
public Render<? super HSEntityBlood> createRenderFor(RenderManager manager) | ||
{ | ||
return new RenderHSEntityBlood(manager); | ||
} | ||
} | ||
} |
Oops, something went wrong.