2
0
Fork 0

small framework for new kinds of arrows, and a test. Item has not been added.

Recipe for flatbread added
main
KeyLime17 6 months ago
parent a170a43026
commit e79d1bb319

@ -1,8 +1,10 @@
package com.zivilon.cinder_loe; package com.zivilon.cinder_loe;
import com.zivilon.cinder_loe.entity.corrupt.CorruptMan; import com.zivilon.cinder_loe.entity.corrupt.CorruptMan;
import com.zivilon.cinder_loe.entity.projectile.EntityElvenArrow;
import com.zivilon.cinder_loe.items.specials.BrokenHalo; import com.zivilon.cinder_loe.items.specials.BrokenHalo;
import com.zivilon.cinder_loe.network.PacketWarbandLocations; import com.zivilon.cinder_loe.network.PacketWarbandLocations;
import com.zivilon.cinder_loe.util.RangedDamageUtil;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.IFuelHandler; import cpw.mods.fml.common.IFuelHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@ -12,6 +14,7 @@ import lotr.common.LOTRMod;
import lotr.common.LOTRDimension; import lotr.common.LOTRDimension;
import lotr.common.enchant.LOTREnchantment; import lotr.common.enchant.LOTREnchantment;
import lotr.common.enchant.LOTREnchantmentHelper; import lotr.common.enchant.LOTREnchantmentHelper;
import lotr.common.entity.npc.LOTREntityOrc;
import lotr.common.item.*; import lotr.common.item.*;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
@ -109,6 +112,7 @@ public class CinderEventHandler implements IFuelHandler {
@SubscribeEvent @SubscribeEvent
public void onLivingHurt(LivingHurtEvent event) { public void onLivingHurt(LivingHurtEvent event) {
if (event.entityLiving == null || event.source.getEntity() == null) { if (event.entityLiving == null || event.source.getEntity() == null) {
return; return;
} }
@ -118,64 +122,11 @@ public class CinderEventHandler implements IFuelHandler {
World world = entity.worldObj; World world = entity.worldObj;
DamageSource source = event.source; DamageSource source = event.source;
/* Blocking event handler removed and replaced with one in DamageEvent class. Temporarily stored for backup reasons. //Elven Arrow, deals more damage to orc kind
// Utilizing the new Util, test if it works!
if (event.entity instanceof EntityPlayer && !source.isUnblockable()) { if (!world.isRemote && entity instanceof LOTREntityOrc && event.source.getSourceOfDamage() instanceof EntityElvenArrow) {
EntityPlayerMP player = (EntityPlayerMP) event.entity; RangedDamageUtil.applyExtraDamage(event, 0.2f); // increase damage by 20%
ItemStack sword = player.getHeldItem();
float playerYaw = player.getRotationYawHead();
float attackerYaw = attacker.getRotationYawHead();
// Normalize both angles to be within 0 - 360
playerYaw = (playerYaw + 360) % 360;
attackerYaw = (attackerYaw + 360) % 360;
// Calculate the angle difference
float angleDifference = Math.abs(playerYaw - attackerYaw);
if (angleDifference > 180) {
angleDifference = 360 - angleDifference;
} }
ItemStack weapon = attacker.getHeldItem();
if (weapon != null) {
if (player.isBlocking() && angleDifference >= 135 && angleDifference <=225) {
float additionalDamage = 0.0f;
if (weapon.getItem() instanceof ItemAxe || weapon.getItem() instanceof LOTRItemAxe || weapon.getItem() instanceof LOTRItemBattleaxe) {
sword.damageItem((int) (event.ammount *1.5), player); // Axes deal 150% the Durability damage
player.clearItemInUse();
world.playSoundAtEntity(player, "random.anvil_land", 1F, 2F);
additionalDamage = 0.75f; // Only 25% Passes through
} else if (weapon.getItem() instanceof LOTRItemHammer) {
sword.damageItem((int) event.ammount, player); // Hammers bypass the block better, but only deal 100% of the durability damage
player.clearItemInUse();
world.playSoundAtEntity(player, "random.anvil_land", 1F, 2F);
additionalDamage = 0.5f; // Only 50% Passes through
} else {
additionalDamage = 0.0f; // 0% Damage Passes through
sword.damageItem((int) (event.ammount/2), player); //Swords only deal 50% of durability damage
player.clearItemInUse();
world.playSoundAtEntity(player, "random.anvil_land", 1F, 2F);
}
float newDamage = event.ammount * (additionalDamage); // Calculate new damage
float newHealth = player.getHealth() - (newDamage - event.ammount); // Calculate health after applying extra damage
if (newHealth > 0) {
player.setHealth(newHealth);
event.setCanceled(true);
} else {
event.ammount = player.getHealth(); // Ensure player dies if health reaches 0 or below
}
}
}
}
*/
// Negative Arrow Protection Handler // Negative Arrow Protection Handler
if (!event.entityLiving.worldObj.isRemote && event.source.isProjectile() && event.entityLiving instanceof EntityPlayerMP player) { if (!event.entityLiving.worldObj.isRemote && event.source.isProjectile() && event.entityLiving instanceof EntityPlayerMP player) {

@ -176,6 +176,7 @@ public class CinderLoE {
public static Item pasta; public static Item pasta;
public static Item pretzel; public static Item pretzel;
public static Item halva; public static Item halva;
public static Item flatbread;
// public static Item honey; // public static Item honey;
public static Item doner_kebab; public static Item doner_kebab;
@ -589,6 +590,7 @@ public class CinderLoE {
pretzel = new LOTRItemFood(4,1.0f, false).setUnlocalizedName("lotr:pretzel").setTextureName("lotr:pretzel"); pretzel = new LOTRItemFood(4,1.0f, false).setUnlocalizedName("lotr:pretzel").setTextureName("lotr:pretzel");
halva = new LOTRItemFood (7, 4.0f, false).setUnlocalizedName("lotr:halva").setTextureName("lotr:halva"); halva = new LOTRItemFood (7, 4.0f, false).setUnlocalizedName("lotr:halva").setTextureName("lotr:halva");
doner_kebab = new LOTRItemFood (6, 6.0f, false).setUnlocalizedName("lotr:doner_kebab").setTextureName("lotr:doner_kebab"); doner_kebab = new LOTRItemFood (6, 6.0f, false).setUnlocalizedName("lotr:doner_kebab").setTextureName("lotr:doner_kebab");
flatbread = new LOTRItemFood (3, 8.0f, false).setUnlocalizedName("lotr:flatbread").setTextureName("lotr:flatbread");
// honey = new LOTRItemFood(3, 0.4f, false).setPotionEffect(Potion.regeneration.id, 5, 0, 100).setUnlocalizedName("lotr:honey").setTextureName("lotr:honey"); // honey = new LOTRItemFood(3, 0.4f, false).setPotionEffect(Potion.regeneration.id, 5, 0, 100).setUnlocalizedName("lotr:honey").setTextureName("lotr:honey");
spiceElven = new Item().setUnlocalizedName("lotr:spice_elven").setTextureName("lotr:spice_elven"); spiceElven = new Item().setUnlocalizedName("lotr:spice_elven").setTextureName("lotr:spice_elven");
spiceHuman = new Item().setUnlocalizedName("lotr:spice_human").setTextureName("lotr:spice_human"); spiceHuman = new Item().setUnlocalizedName("lotr:spice_human").setTextureName("lotr:spice_human");
@ -681,6 +683,7 @@ public class CinderLoE {
ItemRegistration.register(spiceOrcish, "spiceOrcish",6920); ItemRegistration.register(spiceOrcish, "spiceOrcish",6920);
ItemRegistration.register(spiceDwarven, "spiceDwarven",6921); ItemRegistration.register(spiceDwarven, "spiceDwarven",6921);
ItemRegistration.register(spiceIngredient, "spiceIngredient",6922); ItemRegistration.register(spiceIngredient, "spiceIngredient",6922);
ItemRegistration.register(flatbread, "flatbread",6923);
ItemRegistration.register(spawnEgg, "spawnEgg", 6003); ItemRegistration.register(spawnEgg, "spawnEgg", 6003);

@ -0,0 +1,13 @@
package com.zivilon.cinder_loe.client.render.projectile;
import net.minecraft.client.renderer.entity.RenderArrow;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
public class RenderElvenArrow extends RenderArrow {
private static final ResourceLocation arrowPoisonTexture = new ResourceLocation("lotr:item/arrowPoisoned.png");
protected ResourceLocation getEntityTexture(Entity entity) {
return arrowPoisonTexture;
}
}

@ -0,0 +1,67 @@
package com.zivilon.cinder_loe.entity.projectile;
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
public class EntityElvenArrow extends EntityArrow implements IEntityAdditionalSpawnData {
public EntityElvenArrow(World world) {
super(world);
}
public EntityElvenArrow(World world, double d, double d1, double d2) {
super(world, d, d1, d2);
}
public EntityElvenArrow(World world, EntityLivingBase shooter, EntityLivingBase target, float charge, float inaccuracy) {
super(world, shooter, target, charge, inaccuracy);
}
public EntityElvenArrow(World world, EntityLivingBase shooter, float charge) {
super(world, shooter, charge);
}
public void writeSpawnData(ByteBuf data) {
data.writeDouble(this.motionX);
data.writeDouble(this.motionY);
data.writeDouble(this.motionZ);
data.writeInt(this.shootingEntity == null ? -1 : this.shootingEntity.getEntityId());
}
public void readSpawnData(ByteBuf data) {
Entity entity;
this.motionX = data.readDouble();
this.motionY = data.readDouble();
this.motionZ = data.readDouble();
int id = data.readInt();
if (id >= 0 && (entity = this.worldObj.getEntityByID(id)) != null) {
this.shootingEntity = entity;
}
}
public void onCollideWithPlayer(EntityPlayer entityplayer) {
boolean isInGround;
NBTTagCompound nbt = new NBTTagCompound();
this.writeEntityToNBT(nbt);
boolean bl = isInGround = nbt.getByte("inGround") == 1;
if (!this.worldObj.isRemote && isInGround && this.arrowShake <= 0) {
boolean pickup;
boolean bl2 = pickup = this.canBePickedUp == 1 || this.canBePickedUp == 2 && entityplayer.capabilities.isCreativeMode;
//Need to add it as an item first
// if (this.canBePickedUp == 1 && !entityplayer.inventory.addItemStackToInventory(new ItemStack(LOTRMod.arrowPoisoned, 1))) {
// pickup = false;
// }
if (pickup) {
this.playSound("random.pop", 0.2f, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7f + 1.0f) * 2.0f);
entityplayer.onItemPickup((Entity)this, 1);
this.setDead();
}
}
}
}

@ -170,7 +170,7 @@ public class recipes {
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(CinderLoE.fruitsalad), Items.bowl, "fruit1", "fruit2", "fruit3")); GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(CinderLoE.fruitsalad), Items.bowl, "fruit1", "fruit2", "fruit3"));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(CinderLoE.pasta, 4), new ItemStack(LOTRMod.rollingPin, 1, OreDictionary.WILDCARD_VALUE), CinderLoE.dough, CinderLoE.dough)); GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(CinderLoE.pasta, 4), new ItemStack(LOTRMod.rollingPin, 1, OreDictionary.WILDCARD_VALUE), CinderLoE.dough, CinderLoE.dough));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(CinderLoE.halva), Items.sugar, CinderLoE.dough, CinderLoE.spice, LOTRMod.almond)); GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(CinderLoE.halva), Items.sugar, CinderLoE.dough, CinderLoE.spice, LOTRMod.almond));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(CinderLoE.doner_kebab), CinderLoE.dough, "vegetable2", CinderLoE.spice, LOTRMod.kebab)); GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(CinderLoE.doner_kebab), CinderLoE.flatbread, "vegetable2", CinderLoE.spice, LOTRMod.kebab));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(CinderLoE.chocolatebar, 2), LOTRMod.mugChocolate)); GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(CinderLoE.chocolatebar, 2), LOTRMod.mugChocolate));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(CinderLoE.pelmen), Items.wheat, "meat", LOTRMod.salt)); GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(CinderLoE.pelmen), Items.wheat, "meat", LOTRMod.salt));
GameRegistry.addRecipe(new LOTRRecipesPoisonDrinks()); GameRegistry.addRecipe(new LOTRRecipesPoisonDrinks());
@ -442,4 +442,10 @@ public class recipes {
LOTRMillstoneRecipes.addRecipe(LOTRMod.corn, new ItemStack(CinderLoE.flour)); LOTRMillstoneRecipes.addRecipe(LOTRMod.corn, new ItemStack(CinderLoE.flour));
} }
public static void registerSmeltingRecipes() {
System.out.println("[CinderLoE] Registering Smelting recipes...");
GameRegistry.addSmelting(new ItemStack(CinderLoE.flour), new ItemStack(CinderLoE.flatbread), 0f);
}
} }

@ -0,0 +1,21 @@
package com.zivilon.cinder_loe.util;
import net.minecraft.entity.EntityLivingBase;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
public class RangedDamageUtil {
public static void applyExtraDamage(LivingHurtEvent event, float multiplier) {
EntityLivingBase target = event.entityLiving;
float base = event.ammount;
float extra = base * multiplier;
float currentHealth = target.getHealth();
if (currentHealth > extra) {
target.setHealth(currentHealth - extra);
event.setCanceled(true);
} else {
event.ammount = currentHealth;
}
}
}
Loading…
Cancel
Save