mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-24 22:14:31 +00:00
Fix some bugs,and add diyos BattleSigns
This commit is contained in:
1 parent
1124d54a7b
commit
42a5af5566
27 files changed
+500
-92
No files matched your search
@@ -23,17 +23,23 @@ import net.minecraft.entity.monster.IMob;
|
||||
import net.minecraft.entity.passive.EntityChicken;
|
||||
import net.minecraft.entity.passive.EntityCow;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemFood;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EntityDamageSourceIndirect;
|
||||
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.GameRules;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
@@ -162,6 +168,13 @@ public class TEventHandler
|
||||
event.overrideResult(arrow);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.tool == TRepo.battlesign)
|
||||
{
|
||||
int modifiers = toolTag.getInteger("Modifiers");
|
||||
modifiers += 1;
|
||||
toolTag.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean allowCrafting (int head, int handle, int accessory)
|
||||
@@ -240,14 +253,95 @@ public class TEventHandler
|
||||
@SubscribeEvent
|
||||
public void onHurt (LivingHurtEvent event)
|
||||
{
|
||||
if (event.entityLiving instanceof EntityPlayer)
|
||||
EntityLivingBase reciever = event.entityLiving;
|
||||
if (reciever instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
// Cutlass
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if (stack != null && stack.getItem() == TRepo.cutlass && player.isUsingItem())
|
||||
if (stack != null && player.isUsingItem())
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 3 * 20, 1));
|
||||
Item item = stack.getItem();
|
||||
if (item == TRepo.cutlass)
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 3 * 20, 1));
|
||||
}
|
||||
else if (item == TRepo.battlesign)
|
||||
{
|
||||
event.ammount *= 1.5; //Puts battlesign blocking at 3/4 instead of 1/2
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (reciever instanceof EntityCreeper)
|
||||
{
|
||||
Entity attacker = event.source.getEntity();
|
||||
if (attacker instanceof EntityLivingBase)
|
||||
{
|
||||
Entity target = ((EntityCreeper) reciever).getAttackTarget();
|
||||
if (target != null)
|
||||
{
|
||||
float d1 = reciever.getDistanceToEntity(((EntityCreeper) reciever).getAttackTarget());
|
||||
float d2 = reciever.getDistanceToEntity(attacker);
|
||||
if (d2 < d1)
|
||||
{
|
||||
((EntityCreeper) event.entityLiving).setAttackTarget((EntityLivingBase) event.source.getEntity());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onAttack (LivingAttackEvent event)
|
||||
{
|
||||
//System.out.println("Damage: "+event.ammount);
|
||||
if (event.entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
//Cutlass
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if (stack != null && stack.getItem() == TRepo.battlesign && player.isUsingItem())
|
||||
{
|
||||
DamageSource source = event.source;
|
||||
if (!source.isUnblockable() && !source.isMagicDamage() && !source.isExplosion())
|
||||
{
|
||||
if (source instanceof EntityDamageSourceIndirect)
|
||||
{
|
||||
if (random.nextInt(3) == 0)
|
||||
{
|
||||
Entity attacker = source.getEntity();
|
||||
Entity projectile = ((EntityDamageSourceIndirect) source).getSourceOfDamage();
|
||||
projectile.motionX *= -1;
|
||||
projectile.motionZ *= -1;
|
||||
projectile.setDead();
|
||||
event.setCanceled(true);
|
||||
|
||||
if (projectile.getClass() == EntityArrow.class && !player.worldObj.isRemote)
|
||||
{
|
||||
EntityArrow reflection = null;
|
||||
if (attacker instanceof EntityLivingBase)
|
||||
reflection = new EntityArrow(player.worldObj, (EntityLivingBase) attacker, 0);
|
||||
else
|
||||
reflection = new EntityArrow(player.worldObj, player, 0);
|
||||
|
||||
Vec3 look = player.getLookVec();
|
||||
reflection.posX = projectile.posX;
|
||||
reflection.posY = projectile.posY;
|
||||
reflection.posZ = projectile.posZ;
|
||||
reflection.motionX = (projectile.motionX + (look.xCoord * 8)) / 6;
|
||||
reflection.motionY = (projectile.motionY + (look.yCoord * 8)) / 6;
|
||||
reflection.motionZ = (projectile.motionZ + (look.zCoord * 8)) / 6;
|
||||
reflection.damage = ((EntityArrow) projectile).damage;
|
||||
player.worldObj.spawnEntityInWorld(reflection);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Entity attacker = source.getEntity();
|
||||
attacker.attackEntityFrom(DamageSource.causeThornsDamage(player), event.ammount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ public class PHConstruct
|
||||
vanillaMetalBlocks = config.get("Difficulty Changes", "Craft vanilla metal blocks", true).getBoolean(true);
|
||||
lavaFortuneInteraction = config.get("Difficulty Changes", "Enable Auto-Smelt and Fortune interaction", true).getBoolean(true);
|
||||
removeVanillaToolRecipes = config.get("Difficulty Changes", "Remove Vanilla Tool Recipes", false).getBoolean(false);
|
||||
labotimizeVanillaTools = config.get("Difficulty Changes", "Remove Vanilla Tool Effectiveness", false).getBoolean(false);
|
||||
stencilTableCrafting = config.get("Difficulty Changes", "Craft Stencil Tables", true).getBoolean(true);
|
||||
miningLevelIncrease = config.get("Difficulty Changes", "Modifiers increase Mining Level", true).getBoolean(true);
|
||||
denyMattock = config.get("Difficulty Changes", "Deny creation of non-metal mattocks", false).getBoolean(false);
|
||||
@@ -273,6 +274,7 @@ public class PHConstruct
|
||||
public static boolean craftMetalTools;
|
||||
public static boolean vanillaMetalBlocks;
|
||||
public static boolean removeVanillaToolRecipes;
|
||||
public static boolean labotimizeVanillaTools;
|
||||
public static boolean stencilTableCrafting;
|
||||
public static boolean miningLevelIncrease;
|
||||
public static boolean denyMattock;
|
||||
|
||||
@@ -18,6 +18,7 @@ import net.minecraftforge.event.entity.EntityEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
@@ -70,6 +71,8 @@ public class TPlayerHandler
|
||||
|
||||
stats.level = entityplayer.experienceLevel;
|
||||
stats.hunger = entityplayer.getFoodStats().getFoodLevel();
|
||||
|
||||
//stats.battlesignBonus = tags.getCompoundTag("TConstruct").getBoolean("battlesignBonus");
|
||||
|
||||
// gamerule naturalRegeneration false
|
||||
if (!PHConstruct.enableHealthRegen)
|
||||
@@ -77,6 +80,7 @@ public class TPlayerHandler
|
||||
if (!stats.beginnerManual)
|
||||
{
|
||||
stats.beginnerManual = true;
|
||||
stats.battlesignBonus = true;
|
||||
if (PHConstruct.beginnerBook)
|
||||
{
|
||||
ItemStack diary = new ItemStack(TRepo.manualBook);
|
||||
@@ -116,6 +120,34 @@ public class TPlayerHandler
|
||||
|
||||
AbilityHelper.spawnItemAtPlayer(entityplayer, pattern);
|
||||
}
|
||||
if (entityplayer.getDisplayName().toLowerCase().equals("zisteau"))
|
||||
{
|
||||
spawnPigmanModifier(entityplayer);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!stats.battlesignBonus)
|
||||
{
|
||||
stats.battlesignBonus = true;
|
||||
ItemStack modifier = new ItemStack(TRepo.creativeModifier);
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("display", new NBTTagCompound());
|
||||
NBTTagList list = new NBTTagList();
|
||||
list.appendTag(new NBTTagString("Battlesigns were buffed recently."));
|
||||
list.appendTag(new NBTTagString("This might make up for it."));
|
||||
compound.getCompoundTag("display").setTag("Lore", list);
|
||||
compound.setString("TargetLock", TRepo.battlesign.getToolName());
|
||||
modifier.setTagCompound(compound);
|
||||
|
||||
AbilityHelper.spawnItemAtPlayer(entityplayer, modifier);
|
||||
|
||||
if (entityplayer.getDisplayName().toLowerCase().equals("zisteau"))
|
||||
{
|
||||
spawnPigmanModifier(entityplayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (PHConstruct.gregtech && Loader.isModLoaded("GregTech-Addon"))
|
||||
@@ -129,6 +161,23 @@ public class TPlayerHandler
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void spawnPigmanModifier(EntityPlayer entityplayer)
|
||||
{
|
||||
ItemStack modifier = new ItemStack(TRepo.creativeModifier);
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("display", new NBTTagCompound());
|
||||
compound.getCompoundTag("display").setString("Name", "Zistonian Bonus Modifier");
|
||||
NBTTagList list = new NBTTagList();
|
||||
list.appendTag(new NBTTagString("Zombie Pigmen seem to have a natural affinty"));
|
||||
list.appendTag(new NBTTagString("for these types of weapons."));
|
||||
compound.getCompoundTag("display").setTag("Lore", list);
|
||||
compound.setString("TargetLock", TRepo.battlesign.getToolName());
|
||||
modifier.setTagCompound(compound);
|
||||
|
||||
AbilityHelper.spawnItemAtPlayer(entityplayer, modifier);
|
||||
}
|
||||
|
||||
public void onPlayerRespawn (EntityPlayer entityplayer)
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@ public class TPlayerStats implements IExtendedEntityProperties
|
||||
public boolean beginnerManual;
|
||||
public boolean materialManual;
|
||||
public boolean smelteryManual;
|
||||
public boolean battlesignBonus;
|
||||
public ArmorExtended armor;
|
||||
public KnapsackInventory knapsack;
|
||||
|
||||
@@ -47,6 +48,7 @@ public class TPlayerStats implements IExtendedEntityProperties
|
||||
tTag.setBoolean("beginnerManual", this.beginnerManual);
|
||||
tTag.setBoolean("materialManual", this.materialManual);
|
||||
tTag.setBoolean("smelteryManual", this.smelteryManual);
|
||||
tTag.setBoolean("battlesignBonus", this.battlesignBonus);
|
||||
compound.setTag(PROP_NAME, tTag);
|
||||
}
|
||||
|
||||
@@ -60,6 +62,7 @@ public class TPlayerStats implements IExtendedEntityProperties
|
||||
this.beginnerManual = properties.getBoolean("beginnerManual");
|
||||
this.materialManual = properties.getBoolean("materialManual");
|
||||
this.smelteryManual = properties.getBoolean("smelteryManual");
|
||||
this.battlesignBonus = properties.getBoolean("battlesignBonus");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user