WIP Nex and durability recipes
@ -0,0 +1,107 @@
|
||||
package com.zivilon.cinder_loe;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
|
||||
public class ShapelessDurabilityRecipe implements IRecipe {
|
||||
private final ItemStack recipeOutput;
|
||||
private final List<ItemStack> recipeItems;
|
||||
private final Item toolItem;
|
||||
|
||||
public ShapelessDurabilityRecipe(ItemStack result, Item toolItem, ItemStack... ingredients) {
|
||||
this.recipeOutput = result;
|
||||
this.recipeItems = new ArrayList<>(ingredients.length);
|
||||
for (ItemStack ingredient : ingredients) {
|
||||
this.recipeItems.add(ingredient);
|
||||
}
|
||||
this.toolItem = toolItem;
|
||||
System.out.println("[CinderLoE] Created ShapelessDurabilityRecipe for: " + result.getUnlocalizedName());
|
||||
System.out.println("[CinderLoE] Ingredients: " + this.recipeItems);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(InventoryCrafting inv, World worldIn) {
|
||||
System.out.println("[CinderLoE] Checking matches for ShapelessDurabilityRecipe");
|
||||
|
||||
boolean hasTool = false;
|
||||
List<ItemStack> ingredientsCopy = new ArrayList<>(this.recipeItems);
|
||||
|
||||
for (int i = 0; i < inv.getSizeInventory(); ++i) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
if (stack != null) {
|
||||
if (stack.getItem() == toolItem) {
|
||||
hasTool = true;
|
||||
} else {
|
||||
boolean matched = false;
|
||||
for (ItemStack recipeStack : ingredientsCopy) {
|
||||
if (stack.getItem() == recipeStack.getItem() && (recipeStack.getItemDamage() == 32767 || stack.getItemDamage() == recipeStack.getItemDamage())) {
|
||||
matched = true;
|
||||
ingredientsCopy.remove(recipeStack);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!matched) {
|
||||
System.out.println("[CinderLoE] Ingredient did not match: " + stack);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean matches = hasTool && ingredientsCopy.isEmpty();
|
||||
System.out.println("[CinderLoE] ShapelessDurabilityRecipe match result: " + matches + ", has tool: " + hasTool);
|
||||
return matches;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting inv) {
|
||||
System.out.println("[CinderLoE] Getting crafting result for ShapelessDurabilityRecipe");
|
||||
return this.recipeOutput.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize() {
|
||||
return this.recipeItems.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return this.recipeOutput;
|
||||
}
|
||||
|
||||
public ItemStack[] getRemainingItems(InventoryCrafting inv) {
|
||||
System.out.println("[CinderLoE] Getting remaining items for ShapelessDurabilityRecipe");
|
||||
ItemStack[] remainingItems = new ItemStack[inv.getSizeInventory()];
|
||||
|
||||
for (int i = 0; i < remainingItems.length; ++i) {
|
||||
ItemStack itemstack = inv.getStackInSlot(i);
|
||||
|
||||
if (itemstack != null && itemstack.getItem() == toolItem) {
|
||||
ItemStack tool = itemstack.copy();
|
||||
tool.setItemDamage(tool.getItemDamage() + 1);
|
||||
System.out.println("[CinderLoE] Damaging tool: " + tool.getUnlocalizedName() + " | New Damage: " + tool.getItemDamage());
|
||||
|
||||
if (tool.getItemDamage() >= tool.getMaxDamage()) {
|
||||
System.out.println("[CinderLoE] Tool is out of durability, breaking: " + tool.getUnlocalizedName());
|
||||
tool = null;
|
||||
}
|
||||
|
||||
remainingItems[i] = tool;
|
||||
} else if (itemstack != null && itemstack.getItem().hasContainerItem(itemstack)) {
|
||||
System.out.println("[CinderLoE] Consuming non-tool item " + itemstack.getUnlocalizedName());
|
||||
remainingItems[i] = itemstack.getItem().getContainerItem(itemstack);
|
||||
} else {
|
||||
remainingItems[i] = itemstack;
|
||||
}
|
||||
}
|
||||
|
||||
return remainingItems;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
package com.zivilon.cinder_loe.blocks;
|
||||
|
||||
import com.zivilon.cinder_loe.util.Utilities;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
public class EntityBarrier extends Block {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon transparentIcon;
|
||||
|
||||
public EntityBarrier() {
|
||||
super(Material.rock);
|
||||
setHardness(Float.MAX_VALUE);
|
||||
setResistance(Float.MAX_VALUE);
|
||||
setBlockTextureName(Utilities.toSnakeCase("lotr:entityBarrier"));
|
||||
setBlockName(Utilities.toSnakeCase("lotr:entityBarrier"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
this.transparentIcon = iconRegister.registerIcon("lotr:invisible");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return this.transparentIcon;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private boolean isPlayerInSurvivalModeClientSide() {
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
return player != null && !player.capabilities.isCreativeMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT && isPlayerInSurvivalModeClientSide()) {
|
||||
this.setBlockBounds(0.5F, 1.0F, 0.5F, 0.5F, 0.0F, 0.5F); // Zero-sized bounding box for survival players
|
||||
} else {
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); // Full-sized bounding box for others
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity) {
|
||||
if (entity instanceof EntityPlayer) {
|
||||
return;
|
||||
}
|
||||
AxisAlignedBB boundingBox = AxisAlignedBB.getBoundingBox(x, y, z, x + 1.0F, y + 1.0F, z + 1.0F);
|
||||
if (boundingBox != null && aabb.intersectsWith(boundingBox)) {
|
||||
list.add(boundingBox);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,200 @@
|
||||
package com.zivilon.cinder_loe.blocks;
|
||||
|
||||
import com.zivilon.cinder_loe.util.Utilities;
|
||||
import com.zivilon.cinder_loe.client.render.block.RenderIceCage;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class IceCage extends Block {
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon blockIcon;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon emptyIcon;
|
||||
|
||||
public IceCage() {
|
||||
super(Material.ice);
|
||||
setHardness(2.0F);
|
||||
setResistance(1.0F);
|
||||
setStepSound(soundTypeGlass);
|
||||
setBlockTextureName(Utilities.toSnakeCase("lotr:iceCage"));
|
||||
setBlockName(Utilities.toSnakeCase("lotr:iceCage"));
|
||||
setLightOpacity(5); // Semi-transparent
|
||||
setCreativeTab(CreativeTabs.tabBlock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return RenderIceCage.RENDER_ID; // Use the custom render type
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderBlockPass() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
this.blockIcon = iconRegister.registerIcon("lotr:ice_cage");
|
||||
this.emptyIcon = iconRegister.registerIcon("lotr:invisible");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
if ((meta == 0 && side == 1) || (meta == 1 && side == 0)) {
|
||||
return this.emptyIcon;
|
||||
}
|
||||
return this.blockIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
|
||||
return AxisAlignedBB.getBoundingBox(x, y, z, x + 1.0F, y + 1.0F, z + 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 0) { // Lower part
|
||||
float thickness = 0.0625F; // 1/16th of a block thickness
|
||||
|
||||
AxisAlignedBB[] boundingBoxes = new AxisAlignedBB[]{
|
||||
AxisAlignedBB.getBoundingBox(x, y, z, x + thickness, y + 1.0F, z + 1.0F), // Left wall
|
||||
AxisAlignedBB.getBoundingBox(x + 1.0F - thickness, y, z, x + 1.0F, y + 1.0F, z + 1.0F), // Right wall
|
||||
AxisAlignedBB.getBoundingBox(x, y, z, x + 1.0F, y + 1.0F, z + thickness), // Front wall
|
||||
AxisAlignedBB.getBoundingBox(x, y, z + 1.0F - thickness, x + 1.0F, y + 1.0F, z + 1.0F) // Back wall
|
||||
};
|
||||
|
||||
for (AxisAlignedBB boundingBox : boundingBoxes) {
|
||||
if (boundingBox != null && aabb.intersectsWith(boundingBox)) {
|
||||
list.add(boundingBox);
|
||||
}
|
||||
}
|
||||
} else if (meta == 1) { // Upper partplayer.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 20, 2, true)); // Mining Fatigue III
|
||||
float thickness = 0.0625F; // 1/16th of a block thickness
|
||||
|
||||
AxisAlignedBB[] boundingBoxes = new AxisAlignedBB[]{
|
||||
AxisAlignedBB.getBoundingBox(x, y, z, x + thickness, y + 1.0F, z + 1.0F), // Left wall
|
||||
AxisAlignedBB.getBoundingBox(x + 1.0F - thickness, y, z, x + 1.0F, y + 1.0F, z + 1.0F), // Right wall
|
||||
AxisAlignedBB.getBoundingBox(x, y, z, x + 1.0F, y + 1.0F, z + thickness), // Front wall
|
||||
AxisAlignedBB.getBoundingBox(x, y, z + 1.0F - thickness, x + 1.0F, y + 1.0F, z + 1.0F), // Back wall
|
||||
AxisAlignedBB.getBoundingBox(x, y + 1.0F - thickness, z, x + 1.0F, y + 1.0F, z + 1.0F) // Ceiling
|
||||
};
|
||||
|
||||
for (AxisAlignedBB boundingBox : boundingBoxes) {
|
||||
if (boundingBox != null && aabb.intersectsWith(boundingBox)) {
|
||||
list.add(boundingBox);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
|
||||
if (entity instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
AxisAlignedBB blockBounds = AxisAlignedBB.getBoundingBox(x, y, z, x + 1.0F, y + 1.0F, z + 1.0F);
|
||||
if (blockBounds != null && blockBounds.intersectsWith(player.boundingBox)) {
|
||||
player.motionX = 0;
|
||||
player.motionY = 0;
|
||||
player.motionZ = 0;
|
||||
player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 20, 2, true)); // Mining Fatigue III
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, int x, int y, int z, Random random) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 0) { // Lower part
|
||||
List<EntityPlayer> players = world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1.0F, y + 2.0F, z + 1.0F));
|
||||
for (EntityPlayer player : players) {
|
||||
player.motionX = 0;
|
||||
player.motionY = 0;
|
||||
player.motionZ = 0;
|
||||
player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 20, 2, true)); // Mining Fatigue III
|
||||
}
|
||||
}
|
||||
world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int tickRate(World world) {
|
||||
return 1; // Adjust the tick rate as needed
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt(World world, int x, int y, int z) {
|
||||
return world.isAirBlock(x, y, z) && world.isAirBlock(x, y + 1, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase placer, ItemStack itemStack) {
|
||||
world.setBlockMetadataWithNotify(x, y, z, 0, 2); // Lower part
|
||||
world.setBlock(x, y + 1, z, this, 1, 2); // Upper part
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block neighbor) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 0) { // Lower part
|
||||
if (world.getBlock(x, y + 1, z) != this) {
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
} else if (meta == 1) { // Upper part
|
||||
if (world.getBlock(x, y - 1, z) != this) {
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
|
||||
if (meta == 0) { // Lower part
|
||||
if (world.getBlock(x, y + 1, z) == this) {
|
||||
world.setBlockToAir(x, y + 1, z);
|
||||
}
|
||||
} else if (meta == 1) { // Upper part
|
||||
if (world.getBlock(x, y - 1, z) == this) {
|
||||
world.setBlockToAir(x, y - 1, z);
|
||||
}
|
||||
}
|
||||
super.breakBlock(world, x, y, z, block, meta);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
package com.zivilon.cinder_loe.blocks;
|
||||
|
||||
import lotr.common.LOTRCreativeTabs;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.block.BlockPressurePlate;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class ShadowTile extends BlockPressurePlate {
|
||||
|
||||
public ShadowTile() {
|
||||
super("lotr:shadow_tile", Material.rock, BlockPressurePlate.Sensitivity.players);
|
||||
try {
|
||||
Field tabField = LOTRCreativeTabs.class.getDeclaredField("tabMisc"); // Stupid workaround because ForgeGradle tries to obfuscate field LOTRCreativeTabs.tabBlock when it's not supposed to
|
||||
LOTRCreativeTabs tab = (LOTRCreativeTabs)tabField.get(null);
|
||||
setCreativeTab((CreativeTabs)tab);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
setBlockTextureName("lotr:shadow_tile");
|
||||
setBlockName("lotr:shadowTile");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
|
||||
if (entity instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer)entity;
|
||||
player.attackEntityFrom(new DamageSource("shadow"), 10.0F);
|
||||
player.addPotionEffect(new PotionEffect(15, 6*20, 0, false));
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,200 @@
|
||||
package com.zivilon.cinder_loe.client.model;
|
||||
|
||||
import lotr.common.LOTRConfig;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
public class ModelNex extends ModelBase {
|
||||
public ModelRenderer body;
|
||||
|
||||
public ModelRenderer neck;
|
||||
|
||||
public ModelRenderer head;
|
||||
|
||||
public ModelRenderer rightArm;
|
||||
|
||||
public ModelRenderer leftArm;
|
||||
|
||||
public ModelRenderer rightLeg;
|
||||
|
||||
public ModelRenderer leftLeg;
|
||||
|
||||
public ModelRenderer tail;
|
||||
|
||||
public ModelRenderer rightWing;
|
||||
|
||||
public ModelRenderer leftWing;
|
||||
|
||||
private boolean isFireModel;
|
||||
|
||||
public int heldItemRight;
|
||||
|
||||
public ModelNex() {
|
||||
this(0.0F);
|
||||
}
|
||||
|
||||
public ModelNex(float f) {
|
||||
this.textureWidth = 128;
|
||||
this.textureHeight = 256;
|
||||
this.body = new ModelRenderer(this, 0, 38);
|
||||
this.body.setRotationPoint(0.0F, 7.0F, 3.0F);
|
||||
this.body.addBox(-8.0F, -15.0F, -6.0F, 16, 18, 12, f);
|
||||
this.body.setTextureOffset(0, 207);
|
||||
this.body.addBox(-9.0F, -6.5F, -7.0F, 7, 1, 14, f);
|
||||
this.body.addBox(-9.0F, -9.5F, -7.0F, 7, 1, 14, f);
|
||||
this.body.addBox(-9.0F, -12.5F, -7.0F, 7, 1, 14, f);
|
||||
this.body.mirror = true;
|
||||
this.body.addBox(2.0F, -6.5F, -7.0F, 7, 1, 14, f);
|
||||
this.body.addBox(2.0F, -9.5F, -7.0F, 7, 1, 14, f);
|
||||
this.body.addBox(2.0F, -12.5F, -7.0F, 7, 1, 14, f);
|
||||
this.body.mirror = false;
|
||||
this.body.setTextureOffset(0, 0).addBox(-9.0F, -29.0F, -7.0F, 18, 14, 15, f);
|
||||
this.body.setTextureOffset(81, 163).addBox(-2.0F, -21.0F, 5.5F, 4, 25, 2, f);
|
||||
this.neck = new ModelRenderer(this, 76, 0);
|
||||
this.neck.setRotationPoint(0.0F, -25.0F, -3.0F);
|
||||
this.neck.addBox(-6.0F, -5.0F, -10.0F, 12, 12, 14, f);
|
||||
this.body.addChild(this.neck);
|
||||
this.head = new ModelRenderer(this, 92, 48);
|
||||
this.head.setRotationPoint(0.0F, 0.0F, -10.0F);
|
||||
this.head.addBox(-4.0F, -6.0F, -6.0F, 8, 10, 7, f);
|
||||
this.head.setTextureOffset(57, 58).addBox(-6.0F, -7.0F, -4.0F, 12, 4, 4, f);
|
||||
this.head.rotateAngleX = (float)Math.toRadians(10.0D);
|
||||
this.neck.addChild(this.head);
|
||||
ModelRenderer rightHorn1 = new ModelRenderer(this, 57, 47);
|
||||
rightHorn1.setRotationPoint(-6.0F, -5.0F, -2.0F);
|
||||
rightHorn1.addBox(-7.0F, -1.5F, -1.5F, 8, 3, 3, f);
|
||||
rightHorn1.rotateAngleY = (float)Math.toRadians(-35.0D);
|
||||
this.head.addChild(rightHorn1);
|
||||
ModelRenderer rightHorn2 = new ModelRenderer(this, 57, 35);
|
||||
rightHorn2.setRotationPoint(-7.0F, 0.0F, 0.0F);
|
||||
rightHorn2.addBox(-1.0F, -1.0F, -6.0F, 2, 2, 6, f);
|
||||
rightHorn2.rotateAngleY = (float)Math.toRadians(45.0D);
|
||||
rightHorn1.addChild(rightHorn2);
|
||||
ModelRenderer leftHorn1 = new ModelRenderer(this, 57, 47);
|
||||
leftHorn1.setRotationPoint(6.0F, -5.0F, -2.0F);
|
||||
leftHorn1.mirror = true;
|
||||
leftHorn1.addBox(-1.0F, -1.5F, -1.5F, 8, 3, 3, f);
|
||||
leftHorn1.rotateAngleY = (float)Math.toRadians(35.0D);
|
||||
this.head.addChild(leftHorn1);
|
||||
ModelRenderer leftHorn2 = new ModelRenderer(this, 57, 35);
|
||||
leftHorn2.setRotationPoint(7.0F, 0.0F, 0.0F);
|
||||
leftHorn2.mirror = true;
|
||||
leftHorn2.addBox(-1.0F, -1.0F, -6.0F, 2, 2, 6, f);
|
||||
leftHorn2.rotateAngleY = (float)Math.toRadians(-45.0D);
|
||||
leftHorn1.addChild(leftHorn2);
|
||||
this.rightArm = new ModelRenderer(this, 59, 136);
|
||||
this.rightArm.setRotationPoint(-9.0F, -25.0F, 0.0F);
|
||||
this.rightArm.addBox(-7.0F, -2.0F, -4.0F, 7, 10, 8, f);
|
||||
this.rightArm.setTextureOffset(93, 136).addBox(-6.5F, 8.0F, -3.0F, 6, 16, 6, f);
|
||||
this.body.addChild(this.rightArm);
|
||||
this.leftArm = new ModelRenderer(this, 59, 136);
|
||||
this.leftArm.setRotationPoint(9.0F, -25.0F, 0.0F);
|
||||
this.leftArm.mirror = true;
|
||||
this.leftArm.addBox(0.0F, -2.0F, -4.0F, 7, 10, 8, f);
|
||||
this.leftArm.setTextureOffset(93, 136).addBox(0.5F, 8.0F, -3.0F, 6, 16, 6, f);
|
||||
this.body.addChild(this.leftArm);
|
||||
this.rightLeg = new ModelRenderer(this, 46, 230);
|
||||
this.rightLeg.setRotationPoint(-6.0F, 6.0F, 3.0F);
|
||||
this.rightLeg.addBox(-7.0F, -2.0F, -4.0F, 7, 9, 8, f);
|
||||
this.rightLeg.setTextureOffset(46, 208).addBox(-6.5F, 2.0F, 4.0F, 6, 13, 5, f);
|
||||
ModelRenderer rightFoot = new ModelRenderer(this, 0, 243);
|
||||
rightFoot.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
rightFoot.addBox(-7.0F, 15.0F, -6.0F, 7, 3, 9, f);
|
||||
rightFoot.rotateAngleX = (float)Math.toRadians(25.0D);
|
||||
this.rightLeg.addChild(rightFoot);
|
||||
this.leftLeg = new ModelRenderer(this, 46, 230);
|
||||
this.leftLeg.setRotationPoint(6.0F, 6.0F, 3.0F);
|
||||
this.leftLeg.mirror = true;
|
||||
this.leftLeg.addBox(0.0F, -2.0F, -4.0F, 7, 9, 8, f);
|
||||
this.leftLeg.setTextureOffset(46, 208).addBox(0.5F, 2.0F, 4.0F, 6, 13, 5, f);
|
||||
ModelRenderer leftFoot = new ModelRenderer(this, 0, 243);
|
||||
leftFoot.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
leftFoot.mirror = true;
|
||||
leftFoot.addBox(0.0F, 15.0F, -6.0F, 7, 3, 9, f);
|
||||
leftFoot.rotateAngleX = (float)Math.toRadians(25.0D);
|
||||
this.leftLeg.addChild(leftFoot);
|
||||
this.tail = new ModelRenderer(this, 79, 200);
|
||||
this.tail.setRotationPoint(0.0F, -3.0F, 3.0F);
|
||||
this.tail.addBox(-3.5F, -3.0F, 2.0F, 7, 7, 10, f);
|
||||
this.tail.setTextureOffset(80, 225).addBox(-2.5F, -2.5F, 11.0F, 5, 5, 14, f);
|
||||
this.tail.setTextureOffset(96, 175).addBox(-1.5F, -2.0F, 24.0F, 3, 3, 12, f);
|
||||
this.body.addChild(this.tail);
|
||||
this.rightWing = new ModelRenderer(this, 0, 137);
|
||||
this.rightWing.setRotationPoint(-6.0F, -27.0F, 4.0F);
|
||||
this.rightWing.addBox(-1.5F, -1.5F, 0.0F, 3, 3, 25, f);
|
||||
this.rightWing.setTextureOffset(0, 167).addBox(-1.0F, -2.0F, 25.0F, 2, 24, 2, f);
|
||||
this.rightWing.setTextureOffset(0, 30).addBox(-0.5F, -7.0F, 25.5F, 1, 5, 1, f);
|
||||
this.rightWing.setTextureOffset(0, 69).addBox(0.0F, 0.0F, 0.0F, 0, 35, 25, f);
|
||||
this.body.addChild(this.rightWing);
|
||||
this.leftWing = new ModelRenderer(this, 0, 137);
|
||||
this.leftWing.setRotationPoint(6.0F, -27.0F, 4.0F);
|
||||
this.leftWing.mirror = true;
|
||||
this.leftWing.addBox(-1.5F, -1.5F, 0.0F, 3, 3, 25, f);
|
||||
this.leftWing.setTextureOffset(0, 167).addBox(-1.0F, -2.0F, 25.0F, 2, 24, 2, f);
|
||||
this.leftWing.setTextureOffset(0, 30).addBox(-0.5F, -7.0F, 25.5F, 1, 5, 1, f);
|
||||
this.leftWing.setTextureOffset(0, 69).addBox(0.0F, 0.0F, 0.0F, 0, 35, 25, f);
|
||||
this.body.addChild(this.leftWing);
|
||||
}
|
||||
|
||||
public void setFireModel() {
|
||||
this.isFireModel = true;
|
||||
}
|
||||
|
||||
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
|
||||
this.rightWing.showModel = true;
|
||||
setRotationAngles(f, f1, f2, f3, f4, f5, entity);
|
||||
this.body.render(f5);
|
||||
this.rightLeg.render(f5);
|
||||
this.leftLeg.render(f5);
|
||||
}
|
||||
|
||||
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) {
|
||||
this.neck.rotateAngleX = (float)Math.toRadians(-10.0D);
|
||||
this.neck.rotateAngleY = 0.0F;
|
||||
this.neck.rotateAngleX += f4 / (float)Math.toDegrees(1.0D);
|
||||
this.neck.rotateAngleY += f3 / (float)Math.toDegrees(1.0D);
|
||||
this.body.rotateAngleX = (float)Math.toRadians(10.0D);
|
||||
this.body.rotateAngleX += MathHelper.cos(f2 * 0.03F) * 0.15F;
|
||||
this.rightArm.rotateAngleX = 0.0F;
|
||||
this.leftArm.rotateAngleX = 0.0F;
|
||||
this.rightArm.rotateAngleZ = 0.0F;
|
||||
this.leftArm.rotateAngleZ = 0.0F;
|
||||
this.rightArm.rotateAngleX += MathHelper.cos(f * 0.4F + 3.1415927F) * 0.8F * f1;
|
||||
this.leftArm.rotateAngleX += MathHelper.cos(f * 0.4F) * 0.8F * f1;
|
||||
this.rightArm.rotateAngleZ += MathHelper.cos(f2 * 0.09F) * 0.05F + 0.05F;
|
||||
this.leftArm.rotateAngleZ -= MathHelper.cos(f2 * 0.09F) * 0.05F + 0.05F;
|
||||
if (this.onGround > -9990.0F) {
|
||||
float f6 = this.onGround;
|
||||
this.rightArm.rotateAngleY += this.body.rotateAngleY;
|
||||
this.leftArm.rotateAngleY += this.body.rotateAngleY;
|
||||
this.leftArm.rotateAngleX += this.body.rotateAngleY;
|
||||
f6 = 1.0F - this.onGround;
|
||||
f6 *= f6;
|
||||
f6 *= f6;
|
||||
f6 = 1.0F - f6;
|
||||
float f7 = MathHelper.sin(f6 * 3.1415927F);
|
||||
float f8 = MathHelper.sin(this.onGround * 3.1415927F) * -(this.head.rotateAngleX - 0.7F) * 0.75F;
|
||||
this.rightArm.rotateAngleX = (float)(this.rightArm.rotateAngleX - f7 * 1.2D + f8);
|
||||
this.rightArm.rotateAngleY += this.body.rotateAngleY * 2.0F;
|
||||
this.rightArm.rotateAngleZ = MathHelper.sin(this.onGround * 3.1415927F) * -0.4F;
|
||||
}
|
||||
if (this.heldItemRight != 0)
|
||||
this.rightArm.rotateAngleX = this.rightArm.rotateAngleX * 0.5F - 0.31415927F * this.heldItemRight;
|
||||
this.rightLeg.rotateAngleX = (float)Math.toRadians(-25.0D);
|
||||
this.leftLeg.rotateAngleX = (float)Math.toRadians(-25.0D);
|
||||
this.rightLeg.rotateAngleX += MathHelper.sin(f * 0.4F) * 1.2F * f1;
|
||||
this.leftLeg.rotateAngleX += MathHelper.sin(f * 0.4F + 3.1415927F) * 1.2F * f1;
|
||||
this.rightWing.rotateAngleX = (float)Math.toRadians(40.0D);
|
||||
this.leftWing.rotateAngleX = (float)Math.toRadians(40.0D);
|
||||
this.rightWing.rotateAngleY = (float)Math.toRadians(-40.0D);
|
||||
this.leftWing.rotateAngleY = (float)Math.toRadians(40.0D);
|
||||
this.rightWing.rotateAngleY += MathHelper.cos(f2 * 0.04F) * 0.5F;
|
||||
this.leftWing.rotateAngleY -= MathHelper.cos(f2 * 0.04F) * 0.5F;
|
||||
this.tail.rotateAngleX = (float)Math.toRadians(-40.0D);
|
||||
this.tail.rotateAngleY = 0.0F;
|
||||
this.tail.rotateAngleY += MathHelper.cos(f2 * 0.05F) * 0.15F;
|
||||
this.tail.rotateAngleY += MathHelper.sin(f * 0.1F) * 0.6F * f1;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,134 @@
|
||||
package lotr.client.render.entity;
|
||||
|
||||
import com.zivilon.cinder_loe.client.model.ModelNex;
|
||||
import com.zivilon.cinder_loe.entity.Nex;
|
||||
import lotr.common.entity.LOTRRandomSkinEntity;
|
||||
import lotr.common.entity.npc.LOTREntityBalrog;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderLiving;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class RenderNex extends RenderLiving {
|
||||
private static LOTRRandomSkins balrogSkins;
|
||||
|
||||
private static LOTRRandomSkins balrogSkinsBright;
|
||||
|
||||
private static final ResourceLocation fireTexture = new ResourceLocation("lotr:mob/balrog/fire.png");
|
||||
|
||||
private ModelNex balrogModel;
|
||||
|
||||
private ModelNex balrogModelBright;
|
||||
|
||||
private ModelNex fireModel;
|
||||
|
||||
public RenderNex() {
|
||||
super((ModelBase)new ModelNex(), 0.5F);
|
||||
this.balrogModel = (ModelNex)this.mainModel;
|
||||
this.balrogModelBright = new ModelNex(0.05F);
|
||||
this.fireModel = new ModelNex(0.0F);
|
||||
this.fireModel.setFireModel();
|
||||
balrogSkins = LOTRRandomSkins.loadSkinsList("lotr:mob/balrog/balrog");
|
||||
balrogSkinsBright = LOTRRandomSkins.loadSkinsList("lotr:mob/balrog/balrog_bright");
|
||||
}
|
||||
|
||||
protected ResourceLocation getEntityTexture(Entity entity) {
|
||||
return balrogSkins.getRandomSkin((LOTRRandomSkinEntity)entity);
|
||||
}
|
||||
|
||||
public void doRender(Entity entity, double d, double d1, double d2, float f, float f1) {
|
||||
Nex balrog = (Nex)entity;
|
||||
ItemStack heldItem = balrog.getHeldItem();
|
||||
this.fireModel.heldItemRight = (heldItem == null) ? 0 : 2;
|
||||
doRender((EntityLiving)balrog, d, d1, d2, f, f1);
|
||||
}
|
||||
|
||||
protected void preRenderCallback(EntityLivingBase entity, float f) {
|
||||
Nex balrog = (Nex)entity;
|
||||
float scale = 2.0F;
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
}
|
||||
|
||||
private void setupFullBright() {
|
||||
int light = 15728880;
|
||||
int lx = light % 65536;
|
||||
int ly = light / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lx / 1.0F, ly / 1.0F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
protected int shouldRenderPass(EntityLivingBase entity, int pass, float f) {
|
||||
Nex balrog = (Nex)entity;
|
||||
if (pass == 1) {
|
||||
float alpha;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 240.0F);
|
||||
GL11.glMatrixMode(5890);
|
||||
GL11.glLoadIdentity();
|
||||
float f1 = balrog.ticksExisted + f;
|
||||
float f2 = f1 * 0.01F;
|
||||
float f3 = f1 * 0.01F;
|
||||
GL11.glTranslatef(f2, f3, 0.0F);
|
||||
GL11.glMatrixMode(5888);
|
||||
GL11.glAlphaFunc(516, 0.01F);
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(1, 1);
|
||||
alpha = 0.3F + MathHelper.sin(f1 * 0.05F) * 0.15F;
|
||||
GL11.glColor4f(alpha, alpha, alpha, 1.0F);
|
||||
GL11.glDisable(2896);
|
||||
GL11.glDepthMask(false);
|
||||
setRenderPassModel((ModelBase)this.fireModel);
|
||||
bindTexture(fireTexture);
|
||||
return 1;
|
||||
}
|
||||
if (pass == 2) {
|
||||
GL11.glMatrixMode(5890);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glMatrixMode(5888);
|
||||
GL11.glAlphaFunc(516, 0.1F);
|
||||
GL11.glDisable(3042);
|
||||
GL11.glEnable(2896);
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glDisable(2896);
|
||||
setupFullBright();
|
||||
setRenderPassModel((ModelBase)this.balrogModelBright);
|
||||
bindTexture(balrogSkinsBright.getRandomSkin((LOTRRandomSkinEntity)balrog));
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
if (pass == 3) {
|
||||
GL11.glEnable(2896);
|
||||
GL11.glDisable(3042);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected void renderEquippedItems(EntityLivingBase entity, float f) {
|
||||
GL11.glColor3f(1.0F, 1.0F, 1.0F);
|
||||
ItemStack heldItem = entity.getHeldItem();
|
||||
if (heldItem != null) {
|
||||
GL11.glPushMatrix();
|
||||
this.balrogModel.body.postRender(0.0625F);
|
||||
this.balrogModel.rightArm.postRender(0.0625F);
|
||||
GL11.glTranslatef(-0.25F, 1.5F, -0.125F);
|
||||
float scale = 1.25F;
|
||||
GL11.glScalef(scale, -scale, scale);
|
||||
GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
|
||||
this.renderManager.itemRenderer.renderItem(entity, heldItem, 0);
|
||||
if (heldItem.getItem().requiresMultipleRenderPasses())
|
||||
for (int x = 1; x < heldItem.getItem().getRenderPasses(heldItem.getItemDamage()); x++)
|
||||
this.renderManager.itemRenderer.renderItem(entity, heldItem, x);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
package com.zivilon.cinder_loe.client.render.block;
|
||||
|
||||
import com.zivilon.cinder_loe.blocks.IceCage;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class RenderIceCage implements ISimpleBlockRenderingHandler {
|
||||
|
||||
public static final int RENDER_ID = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
|
||||
if (modelID != RENDER_ID) return;
|
||||
|
||||
// Render inventory block as flat texture icon
|
||||
renderer.renderBlockAsItem(block, metadata, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
if (!(block instanceof IceCage) || modelId != RENDER_ID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
float thickness = 0.0625F; // 1/16th of a block thickness
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
// Render the bounding boxes as defined in the block class
|
||||
if (meta == 0) { // Lower part
|
||||
renderer.setRenderBounds(0, 0, 0, thickness, 1, 1); // Left wall
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(1 - thickness, 0, 0, 1, 1, 1); // Right wall
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0, 0, 0, 1, 1, thickness); // Front wall
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0, 0, 1 - thickness, 1, 1, 1); // Back wall
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0, 0, 0, 1, thickness, 1); // Floor
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
} else if (meta == 1) { // Upper part
|
||||
renderer.setRenderBounds(0, 0, 0, thickness, 1, 1); // Left wall
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(1 - thickness, 0, 0, 1, 1, 1); // Right wall
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0, 0, 0, 1, 1, thickness); // Front wall
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0, 0, 1 - thickness, 1, 1, 1); // Back wall
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0, 1, 0, 1, 1 + thickness, 1); // Ceiling
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return false; // Do not render as 3D in inventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return RENDER_ID;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
package com.zivilon.cinder_loe.client.render.projectile;
|
||||
|
||||
import com.zivilon.cinder_loe.entity.projectile.EntityWarDart;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
|
||||
public class RenderWarDart extends Render {
|
||||
|
||||
protected ResourceLocation getEntityTexture(Entity entity) {
|
||||
return TextureMap.locationItemsTexture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRender(Entity entity, double d, double d1, double d2, float f, float f1) {
|
||||
EntityWarDart dart = (EntityWarDart)entity;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float)d, (float)d1, (float)d2);
|
||||
GL11.glRotatef(dart.prevRotationYaw + (dart.rotationYaw - dart.prevRotationYaw) * f1 - 90.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(dart.prevRotationPitch + (dart.rotationPitch - dart.prevRotationPitch) * f1, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glEnable(32826);
|
||||
GL11.glRotatef(-135.0F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glTranslatef(0.0F, -1.0F, 0.0F);
|
||||
float scale = 0.6F;
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
GL11.glTranslatef(0.0F, 0.8F, 0.0F);
|
||||
|
||||
if (dart.item != null) {
|
||||
IIcon icon = dart.getDartIcon();
|
||||
if (icon != null) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
float minU = icon.getMinU();
|
||||
float maxU = icon.getMaxU();
|
||||
float minV = icon.getMinV();
|
||||
float maxV = icon.getMaxV();
|
||||
int width = icon.getIconWidth();
|
||||
int height = icon.getIconHeight();
|
||||
bindTexture(getEntityTexture((Entity)dart));
|
||||
ItemRenderer.renderItemIn2D(tessellator, maxU, minV, minU, maxV, width, height, 0.0625F);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glDisable(32826);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,117 @@
|
||||
package com.zivilon.cinder_loe.entity;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import lotr.common.entity.ai.LOTREntityAIAttackOnCollide;
|
||||
import lotr.common.entity.npc.LOTREntityNPC;
|
||||
import lotr.common.fac.LOTRFaction;
|
||||
|
||||
import net.minecraft.entity.EnumCreatureAttribute;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.entity.ai.EntityAILookIdle;
|
||||
import net.minecraft.entity.ai.EntityAIWander;
|
||||
import net.minecraft.entity.ai.EntityAIWatchClosest;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
|
||||
import com.zivilon.cinder_loe.CinderLoE;
|
||||
|
||||
public class Nex extends LOTREntityNPC {
|
||||
public AxisAlignedBB collisionBox;
|
||||
public AxisAlignedBB hitbox;
|
||||
public int phase = 1;
|
||||
public ChunkCoordinates currentFlightTarget;
|
||||
public EntityPlayer playerTarget;
|
||||
|
||||
public Nex(World world) {
|
||||
super(world);
|
||||
setSize(1.5F, 3.0F);
|
||||
((EntityLiving) this).tasks.addTask(2, (EntityAIBase) new LOTREntityAIAttackOnCollide(this, 1.3D, false));
|
||||
((EntityLiving) this).tasks.addTask(5, (EntityAIBase) new EntityAIWander(this, 1.0D));
|
||||
((EntityLiving) this).tasks.addTask(9, (EntityAIBase) new EntityAILookIdle((EntityLiving) this));
|
||||
addTargetTasks(true);
|
||||
}
|
||||
|
||||
protected void entityInit() {
|
||||
super.entityInit();
|
||||
this.dataWatcher.addObject(31, Integer.valueOf(0));
|
||||
}
|
||||
|
||||
protected void applyEntityAttributes() {
|
||||
super.applyEntityAttributes();
|
||||
getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(1000.0D);
|
||||
getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.2D);
|
||||
}
|
||||
|
||||
public int getPhase() {
|
||||
return this.dataWatcher.getWatchableObjectInt(31);
|
||||
}
|
||||
public void setPhase(int i) {
|
||||
this.dataWatcher.updateObject(31, Integer.valueOf(i));
|
||||
}
|
||||
|
||||
public LOTRFaction getFaction() {
|
||||
return LOTRFaction.UTUMNO;
|
||||
}
|
||||
|
||||
public void writeEntityToNBT(NBTTagCompound nbt) {
|
||||
super.writeEntityToNBT(nbt);
|
||||
nbt.setInteger("NexPhase", getPhase());
|
||||
}
|
||||
|
||||
public void readEntityFromNBT(NBTTagCompound nbt) {
|
||||
super.readEntityFromNBT(nbt);
|
||||
setPhase(nbt.getInteger("NexPhase"));
|
||||
}
|
||||
|
||||
public boolean canBePushed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void fall(float f) {}
|
||||
|
||||
protected void updateFallState(double d, boolean flag) {}
|
||||
|
||||
protected boolean canDespawn() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onLivingUpdate() {
|
||||
super.onLivingUpdate();
|
||||
if (rand.nextBoolean())
|
||||
((Entity)this).worldObj.spawnParticle("chill", ((Entity)this).posX + (rand.nextDouble() - 0.5D) * ((Entity)this).width, ((Entity)this).posY + rand.nextDouble() * ((Entity)this).height, ((Entity)this).posZ + (rand.nextDouble() - 0.5D) * ((Entity)this).width, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
|
||||
protected void dropFewItems(boolean flag, int i) {
|
||||
return;
|
||||
}
|
||||
|
||||
protected String getHurtSound() {
|
||||
return "lotr:wight.hurt";
|
||||
}
|
||||
|
||||
protected String getDeathSound() {
|
||||
return "lotr:wight.death";
|
||||
}
|
||||
|
||||
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickedResult(MovingObjectPosition target) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,159 @@
|
||||
package com.zivilon.cinder_loe.entity.projectile;
|
||||
|
||||
import com.zivilon.cinder_loe.CinderLoE;
|
||||
import com.zivilon.cinder_loe.items.WarDart;
|
||||
import lotr.common.entity.projectile.LOTREntityProjectileBase;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityWarDart extends LOTREntityProjectileBase {
|
||||
|
||||
public static int POSITION_WATCHER_ID = 20;
|
||||
public static int ITEMSTACK_WATCHER_ID = 18;
|
||||
|
||||
public int xTile = -1;
|
||||
public int yTile = -1;
|
||||
public int zTile = -1;
|
||||
public Block inTile;
|
||||
public int inData = 0;
|
||||
public boolean inGround = false;
|
||||
public int shake = 0;
|
||||
public Entity shootingEntity;
|
||||
public int ticksInGround;
|
||||
public int ticksInAir = 0;
|
||||
public int canBePickedUp = 0;
|
||||
public int knockbackStrength = 0;
|
||||
|
||||
public ItemStack item;
|
||||
public int damage;
|
||||
|
||||
public EntityWarDart(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
public EntityWarDart(World world, EntityLivingBase thrower, ItemStack item) {
|
||||
super(world, thrower, item, 3.0F);
|
||||
this.item = item.copy(); // Store a copy of the item stack
|
||||
this.item.stackSize = 1;
|
||||
this.damage = WarDart.getDamageFromMeta(item.getItemDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
this.dataWatcher.addObject(17, Byte.valueOf((byte)0));
|
||||
this.dataWatcher.addObjectByDataType(ITEMSTACK_WATCHER_ID, 5);
|
||||
this.dataWatcher.addObject(POSITION_WATCHER_ID, ""); // Test adding object with ID
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setThrowableHeading(double x, double y, double z, float velocity, float inaccuracy) {
|
||||
float f2 = MathHelper.sqrt_double(x * x + y * y + z * z);
|
||||
x /= f2;
|
||||
y /= f2;
|
||||
z /= f2;
|
||||
x += this.rand.nextGaussian() * 0.0075D * inaccuracy;
|
||||
y += this.rand.nextGaussian() * 0.0075D * inaccuracy;
|
||||
z += this.rand.nextGaussian() * 0.0075D * inaccuracy;
|
||||
x *= velocity;
|
||||
y *= velocity;
|
||||
z *= velocity;
|
||||
this.motionX = x;
|
||||
this.motionY = y;
|
||||
this.motionZ = z;
|
||||
float f3 = MathHelper.sqrt_double(x * x + z * z);
|
||||
this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(x, z) * 180.0D / Math.PI);
|
||||
this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(y, f3) * 180.0D / Math.PI);
|
||||
this.ticksInGround = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if (!this.worldObj.isRemote) {
|
||||
this.dataWatcher.updateObject(ITEMSTACK_WATCHER_ID, this.item);
|
||||
if (this.inGround) {
|
||||
String posString = this.xTile + "," + this.yTile + "," + this.zTile;
|
||||
this.dataWatcher.updateObject(POSITION_WATCHER_ID, posString);
|
||||
}
|
||||
} else {
|
||||
this.item = this.dataWatcher.getWatchableObjectItemStack(ITEMSTACK_WATCHER_ID);
|
||||
String posString = this.dataWatcher.getWatchableObjectString(POSITION_WATCHER_ID);
|
||||
if (!posString.equals("")) {
|
||||
String[] coords = posString.split(",");
|
||||
this.xTile = Integer.parseInt(coords[0]);
|
||||
this.yTile = Integer.parseInt(coords[1]);
|
||||
this.zTile = Integer.parseInt(coords[2]);
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure proper synchronization of position
|
||||
if (this.inGround) {
|
||||
this.motionX = this.motionY = this.motionZ = 0;
|
||||
this.posX = this.xTile + 0.5;
|
||||
this.posY = this.yTile + 0.5;
|
||||
this.posZ = this.zTile + 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBaseImpactDamage(Entity entity, ItemStack itemStack) {
|
||||
return this.damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound tagCompound) {
|
||||
// Do not call super.writeEntityToNBT to avoid recursion issues
|
||||
tagCompound.setInteger("xTile", this.xTile);
|
||||
tagCompound.setInteger("yTile", this.yTile);
|
||||
tagCompound.setInteger("zTile", this.zTile);
|
||||
tagCompound.setInteger("inTile", Block.getIdFromBlock(this.inTile));
|
||||
tagCompound.setByte("inData", (byte)this.inData);
|
||||
tagCompound.setByte("shake", (byte)this.shake);
|
||||
tagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0));
|
||||
tagCompound.setByte("pickup", (byte)this.canBePickedUp);
|
||||
tagCompound.setByte("Knockback", (byte)this.knockbackStrength);
|
||||
if (this.item != null) {
|
||||
NBTTagCompound itemTag = new NBTTagCompound();
|
||||
this.item.writeToNBT(itemTag);
|
||||
tagCompound.setTag("Item", itemTag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound tagCompound) {
|
||||
// Do not call super.readEntityFromNBT to avoid recursion issues
|
||||
this.xTile = tagCompound.getInteger("xTile");
|
||||
this.yTile = tagCompound.getInteger("yTile");
|
||||
this.zTile = tagCompound.getInteger("zTile");
|
||||
this.inTile = Block.getBlockById(tagCompound.getInteger("inTile"));
|
||||
this.inData = tagCompound.getByte("inData");
|
||||
this.shake = tagCompound.getByte("shake");
|
||||
this.inGround = tagCompound.getByte("inGround") == 1;
|
||||
this.canBePickedUp = tagCompound.getByte("pickup");
|
||||
this.knockbackStrength = tagCompound.getByte("Knockback");
|
||||
if (tagCompound.hasKey("Item")) {
|
||||
this.item = ItemStack.loadItemStackFromNBT(tagCompound.getCompoundTag("Item"));
|
||||
if (this.item != null) {
|
||||
this.damage = WarDart.getDamageFromMeta(this.item.getItemDamage());
|
||||
this.dataWatcher.updateObject(ITEMSTACK_WATCHER_ID, this.item); // Ensure DataWatcher is updated with the deserialized ItemStack
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public IIcon getDartIcon() {
|
||||
WarDart itemDart = (WarDart) CinderLoE.warDart;
|
||||
return itemDart.getIconFromDamage(this.item.getItemDamage());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package com.zivilon.cinder_loe.items;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class ToxicCore extends Item {
|
||||
|
||||
public ToxicCore() {
|
||||
this.setMaxDamage(100);
|
||||
this.setNoRepair();
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,150 @@
|
||||
package com.zivilon.cinder_loe.items;
|
||||
|
||||
import com.zivilon.cinder_loe.entity.projectile.EntityWarDart;
|
||||
|
||||
import lotr.common.LOTRCreativeTabs;
|
||||
import lotr.common.dispenser.LOTRDispenseThrowingAxe;
|
||||
import lotr.common.enchant.LOTREnchantment;
|
||||
import lotr.common.enchant.LOTREnchantmentHelper;
|
||||
import lotr.common.entity.projectile.LOTREntityThrowingAxe;
|
||||
import lotr.common.item.LOTRMaterial;
|
||||
import lotr.common.recipe.LOTRRecipes;
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.EnumCreatureAttribute;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class WarDart extends Item {
|
||||
public IIcon[] icons;
|
||||
|
||||
public WarDart() {
|
||||
this.setHasSubtypes(true);
|
||||
setMaxStackSize(4);
|
||||
this.setMaxDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
|
||||
if (itemStack.getItemDamage() > 0) {
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
--itemStack.stackSize;
|
||||
}
|
||||
|
||||
world.playSoundAtEntity(player, "lotr:item.dart", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F));
|
||||
|
||||
if (!world.isRemote) {
|
||||
world.spawnEntityInWorld(new EntityWarDart(world, player, itemStack));
|
||||
}
|
||||
}
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconFromDamage(int damage) {
|
||||
if (damage < 0 || damage >= icons.length) {
|
||||
damage = 0;
|
||||
}
|
||||
return this.icons[damage];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
this.icons = new IIcon[14];
|
||||
this.icons[0] = iconRegister.registerIcon("lotr:war_dart_headless");
|
||||
this.icons[1] = iconRegister.registerIcon("lotr:war_dart_copper");
|
||||
this.icons[2] = iconRegister.registerIcon("lotr:war_dart_bronze");
|
||||
this.icons[3] = iconRegister.registerIcon("lotr:war_dart_iron");
|
||||
this.icons[4] = iconRegister.registerIcon("lotr:war_dart_orc");
|
||||
this.icons[5] = iconRegister.registerIcon("lotr:war_dart_dwarven");
|
||||
this.icons[6] = iconRegister.registerIcon("lotr:war_dart_uruk");
|
||||
this.icons[7] = iconRegister.registerIcon("lotr:war_dart_blue_dwarven");
|
||||
this.icons[8] = iconRegister.registerIcon("lotr:war_dart_black_uruk");
|
||||
this.icons[9] = iconRegister.registerIcon("lotr:war_dart_elven");
|
||||
this.icons[10] = iconRegister.registerIcon("lotr:war_dart_gilded_iron");
|
||||
this.icons[11] = iconRegister.registerIcon("lotr:war_dart_red_dwarven");
|
||||
this.icons[12] = iconRegister.registerIcon("lotr:war_dart_mithril");
|
||||
this.icons[13] = iconRegister.registerIcon("lotr:war_dart_ancient");
|
||||
}
|
||||
|
||||
public static String getDartMaterial(ItemStack item) {
|
||||
switch(item.getItemDamage()) {
|
||||
case 1:
|
||||
return "copper";
|
||||
case 2:
|
||||
return "bronze";
|
||||
case 3:
|
||||
return "iron";
|
||||
case 4:
|
||||
return "orc";
|
||||
case 5:
|
||||
return "dwarven";
|
||||
case 6:
|
||||
return "uruk";
|
||||
case 7:
|
||||
return "blue_dwarven";
|
||||
case 8:
|
||||
return "black_uruk";
|
||||
case 9:
|
||||
return "elven";
|
||||
case 10:
|
||||
return "gilded_iron";
|
||||
case 11:
|
||||
return "red_dwarven";
|
||||
case 12:
|
||||
return "mithril";
|
||||
case 13:
|
||||
return "ancient";
|
||||
default:
|
||||
return "headless";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack item) {
|
||||
return "item.war_dart_" + getDartMaterial(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int damage) {
|
||||
return damage;
|
||||
}
|
||||
|
||||
public static int getDamageFromMeta(int meta) {
|
||||
switch(meta) {
|
||||
case 1: return 3; // Copper
|
||||
case 2: return 3; // Bronze
|
||||
case 3: return 4; // Iron
|
||||
case 4: return 5; // Orc
|
||||
case 5: return 6; // Dwarven
|
||||
case 6: return 6; // Uruk
|
||||
case 7: return 6; // Blue Dwarven
|
||||
case 8: return 6; // Black Uruk
|
||||
case 9: return 6; // Elven
|
||||
case 10: return 5; // Gilded Iron
|
||||
case 11: return 6; // Red Dwarven
|
||||
case 12: return 10; // Mithril
|
||||
case 13: return 12; // Ancient
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) {
|
||||
int damageMeta = stack.getItemDamage();
|
||||
double damagePercent = getDamageFromMeta(damageMeta) * (1.0 / 8) * 100.0;
|
||||
double roundedDamagePercent = 5 * Math.round(damagePercent / 5.0);
|
||||
list.add(EnumChatFormatting.DARK_GREEN + "Ranged damage: " + roundedDamagePercent + "%");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
package com.zivilon.cinder_loe.items;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class WarDartHeads extends Item {
|
||||
private IIcon[] icons;
|
||||
|
||||
public WarDartHeads() {
|
||||
super();
|
||||
setCreativeTab(CreativeTabs.tabMisc);
|
||||
setHasSubtypes(true); // Allows for different metadata values
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
icons = new IIcon[6]; // 6 icons for 0 to 5 count levels
|
||||
for (int i = 0; i < icons.length; i++) {
|
||||
icons[i] = iconRegister.registerIcon("lotr:war_dart_heads_" + i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack item) {
|
||||
return "item.war_dart_heads_" + WarDart.getDartMaterial(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorFromItemStack(ItemStack stack, int renderPass) {
|
||||
int damage = stack.getItemDamage();
|
||||
|
||||
switch (damage) {
|
||||
case 1: return 0xCA6C40; // Copper
|
||||
case 2: return 0xC28336; // Bronze
|
||||
case 3: return 0xD8D8D8; // Iron
|
||||
case 4: return 0x5D685A; // Orc
|
||||
case 5: return 0x6B787A; // Dwarven
|
||||
case 6: return 0x4C4D34; // Uruk
|
||||
case 7: return 0x577287; // Blue Dwarven
|
||||
case 8: return 0x444138; // Black Uruk
|
||||
case 9: return 0xD0C9AC; // Elven
|
||||
case 10: return 0xFFFFB0; // Gilded Iron
|
||||
case 11: return 0xFFC48B; // Red dwarven
|
||||
case 12: return 0xAFB3D3; // Mithril
|
||||
case 13: return 0x033346; // Ancient
|
||||
default: return 0xFFFFFF; // Blank
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconIndex(ItemStack item) {
|
||||
return getIcon(item, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int renderPass) {
|
||||
int count = stack.stackSize;
|
||||
if (count > 5 || count < 1) {
|
||||
return icons[0];
|
||||
} else {
|
||||
return icons[count];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,94 @@
|
||||
package com.zivilon.cinder_loe.mixins;
|
||||
|
||||
import com.zivilon.cinder_loe.util.DurableItemCrafter;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.SlotCrafting;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
|
||||
import org.spongepowered.asm.mixin.Dynamic;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
|
||||
import com.zivilon.cinder_loe.CinderLoE;
|
||||
|
||||
@Mixin(SlotCrafting.class)
|
||||
public abstract class MixinSlotCrafting {
|
||||
@Shadow
|
||||
private final IInventory craftMatrix;
|
||||
@Shadow
|
||||
private EntityPlayer thePlayer;
|
||||
@Shadow
|
||||
protected void onCrafting(ItemStack p_75210_1_) {}
|
||||
|
||||
public MixinSlotCrafting() {
|
||||
craftMatrix = null;
|
||||
}
|
||||
|
||||
@Overwrite
|
||||
public void onPickupFromSlot(EntityPlayer p_82870_1_, ItemStack p_82870_2_) {
|
||||
FMLCommonHandler.instance().firePlayerCraftingEvent(p_82870_1_, p_82870_2_, craftMatrix);
|
||||
onCrafting(p_82870_2_);
|
||||
boolean hasExceptionItem = false;
|
||||
int arrow_count = 0;
|
||||
|
||||
for (int i = 0; i < craftMatrix.getSizeInventory(); ++i) {
|
||||
ItemStack itemstack1 = craftMatrix.getStackInSlot(i);
|
||||
|
||||
if (itemstack1 != null && DurableItemCrafter.exceptionItems.contains(itemstack1.getItem())) {
|
||||
hasExceptionItem = true;
|
||||
}
|
||||
if (itemstack1 != null && itemstack1.getItem() == Items.arrow) {
|
||||
arrow_count++;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < craftMatrix.getSizeInventory(); ++i) {
|
||||
ItemStack itemstack1 = craftMatrix.getStackInSlot(i);
|
||||
|
||||
if (itemstack1 != null) {
|
||||
if (!hasExceptionItem && DurableItemCrafter.customItems.contains(itemstack1.getItem())) {
|
||||
if (itemstack1.getItem() == CinderLoE.toxicCore && arrow_count > 0) {
|
||||
damage_item(itemstack1, i, arrow_count, craftMatrix);
|
||||
} else {
|
||||
damage_item(itemstack1, i, 1, craftMatrix);
|
||||
}
|
||||
} else {
|
||||
craftMatrix.decrStackSize(i, 1);
|
||||
}
|
||||
|
||||
if (itemstack1 != null && itemstack1.getItem().hasContainerItem(itemstack1)) {
|
||||
ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1);
|
||||
|
||||
if (itemstack2 != null && itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage()) {
|
||||
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, itemstack2));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) || !thePlayer.inventory.addItemStackToInventory(itemstack2)) {
|
||||
if (craftMatrix.getStackInSlot(i) == null) {
|
||||
craftMatrix.setInventorySlotContents(i, itemstack2);
|
||||
} else {
|
||||
thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Dynamic
|
||||
public void damage_item(ItemStack item, int i, int damage, IInventory matrix) {
|
||||
item.setItemDamage(item.getItemDamage() + damage);
|
||||
if (item.getItemDamage() >= item.getMaxDamage()) {
|
||||
matrix.setInventorySlotContents(i, null); // Item breaks and is removed
|
||||
} else {
|
||||
matrix.setInventorySlotContents(i, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
package com.zivilon.cinder_loe.recipe;
|
||||
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.world.World;
|
||||
import com.zivilon.cinder_loe.CinderLoE;
|
||||
|
||||
public class ToxicCoreArrowsRecipe implements IRecipe {
|
||||
|
||||
private final ItemStack result;
|
||||
|
||||
public ToxicCoreArrowsRecipe(ItemStack result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(InventoryCrafting inv, World worldIn) {
|
||||
ItemStack toxicCore = null;
|
||||
int arrowCount = 0;
|
||||
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++) {
|
||||
ItemStack itemstack = inv.getStackInSlot(i);
|
||||
|
||||
if (itemstack != null) {
|
||||
if (itemstack.getItem() == CinderLoE.toxicCore) {
|
||||
if (toxicCore != null) {
|
||||
return false; // Only one toxic core allowed
|
||||
}
|
||||
toxicCore = itemstack;
|
||||
} else if (itemstack.getItem() == Items.arrow) {
|
||||
arrowCount++;
|
||||
} else {
|
||||
return false; // Invalid item in grid
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (toxicCore != null && arrowCount > 0) {
|
||||
return toxicCore.getItemDamage() + arrowCount <= toxicCore.getMaxDamage();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting inv) {
|
||||
ItemStack toxicCore = null;
|
||||
int arrowCount = 0;
|
||||
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++) {
|
||||
ItemStack itemstack = inv.getStackInSlot(i);
|
||||
|
||||
if (itemstack != null) {
|
||||
if (itemstack.getItem() == CinderLoE.toxicCore) {
|
||||
toxicCore = itemstack;
|
||||
} else if (itemstack.getItem() == Items.arrow) {
|
||||
arrowCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (toxicCore != null && arrowCount > 0) {
|
||||
ItemStack resultStack = new ItemStack(result.getItem(), arrowCount);
|
||||
return resultStack;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize() {
|
||||
return 9;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.zivilon.cinder_loe.util;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import lotr.common.LOTRMod;
|
||||
import com.zivilon.cinder_loe.CinderLoE;
|
||||
|
||||
public class DurableItemCrafter {
|
||||
public static final List<Item> customItems = new ArrayList<>();
|
||||
public static final List<Item> exceptionItems = new ArrayList<>();
|
||||
static {
|
||||
customItems.add(LOTRMod.chisel);
|
||||
customItems.add(CinderLoE.toxicCore);
|
||||
|
||||
exceptionItems.add(LOTRMod.ithildin);
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 5.4 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 5.6 KiB |
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 5.3 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 5.2 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 5.7 KiB |
|
After Width: | Height: | Size: 567 B |
|
After Width: | Height: | Size: 464 B |
|
After Width: | Height: | Size: 6.4 KiB |
|
After Width: | Height: | Size: 6.6 KiB |
|
After Width: | Height: | Size: 6.2 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.3 KiB |