mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-20 20:22:36 +00:00
Fix JABBA-related issues with crafting station slots (#54)
* Fix shift-merging tools voiding items fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/11392> * Change 0-sized ItemStacks into null stacks in crafting station attached slots Fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/10425> * Update buildscript * spotlessApply
This commit is contained in:
1 parent
18bfeaff32
commit
39be06c23b
571 files changed
+25959
-28223
No files matched your search
@@ -1,19 +1,11 @@
|
||||
package tconstruct.library.tools;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.management.ItemInWorldManager;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public abstract class AOEHarvestTool extends HarvestTool {
|
||||
public int breakRadius;
|
||||
public int breakDepth;
|
||||
@@ -28,21 +20,19 @@ public abstract class AOEHarvestTool extends HarvestTool {
|
||||
@Override
|
||||
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
|
||||
// only effective materials matter. We don't want to aoe when beraking dirt with a hammer.
|
||||
Block block = player.worldObj.getBlock(x,y,z);
|
||||
int meta = player.worldObj.getBlockMetadata(x,y,z);
|
||||
if(block == null || !isEffective(block, meta) || !stack.hasTagCompound())
|
||||
return super.onBlockStartBreak(stack, x,y,z, player);
|
||||
Block block = player.worldObj.getBlock(x, y, z);
|
||||
int meta = player.worldObj.getBlockMetadata(x, y, z);
|
||||
if (block == null || !isEffective(block, meta) || !stack.hasTagCompound())
|
||||
return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
|
||||
// tool broken?
|
||||
NBTTagCompound toolTags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if(toolTags == null || toolTags.getBoolean("Broken"))
|
||||
return super.onBlockStartBreak(stack, x,y,z, player);
|
||||
if (toolTags == null || toolTags.getBoolean("Broken")) return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
|
||||
MovingObjectPosition mop = AbilityHelper.raytraceFromEntity(player.worldObj, player, false, 4.5d);
|
||||
if(mop == null)
|
||||
return super.onBlockStartBreak(stack, x,y,z, player);
|
||||
if (mop == null) return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
int sideHit = mop.sideHit;
|
||||
//int sideHit = Minecraft.getMinecraft().objectMouseOver.sideHit;
|
||||
// int sideHit = Minecraft.getMinecraft().objectMouseOver.sideHit;
|
||||
|
||||
// we successfully destroyed a block. time to do AOE!
|
||||
int xRange = breakRadius;
|
||||
@@ -70,15 +60,12 @@ public abstract class AOEHarvestTool extends HarvestTool {
|
||||
for (int yPos = y - yRange; yPos <= y + yRange; yPos++)
|
||||
for (int zPos = z - zRange; zPos <= z + zRange; zPos++) {
|
||||
// don't break the originally already broken block, duh
|
||||
if (xPos == x && yPos == y && zPos == z)
|
||||
continue;
|
||||
if (xPos == x && yPos == y && zPos == z) continue;
|
||||
|
||||
if(!super.onBlockStartBreak(stack, xPos, yPos, zPos, player))
|
||||
breakExtraBlock(player.worldObj, xPos, yPos, zPos, sideHit, player, x,y,z);
|
||||
if (!super.onBlockStartBreak(stack, xPos, yPos, zPos, player))
|
||||
breakExtraBlock(player.worldObj, xPos, yPos, zPos, sideHit, player, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
package tconstruct.library.tools;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -34,16 +33,14 @@ import tconstruct.library.ActiveToolMod;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.util.PiercingEntityDamage;
|
||||
|
||||
public class AbilityHelper
|
||||
{
|
||||
public class AbilityHelper {
|
||||
public static Random random = new Random();
|
||||
public static boolean necroticUHS;
|
||||
|
||||
/* Normal interactions */
|
||||
public static boolean onBlockChanged (ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase player, Random random)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
return false;
|
||||
public static boolean onBlockChanged(
|
||||
ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase player, Random random) {
|
||||
if (!stack.hasTagCompound()) return false;
|
||||
|
||||
int reinforced = 0;
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
@@ -51,23 +48,20 @@ public class AbilityHelper
|
||||
if (tags.getCompoundTag("InfiTool").hasKey("Unbreaking"))
|
||||
reinforced = tags.getCompoundTag("InfiTool").getInteger("Unbreaking");
|
||||
|
||||
if (random.nextInt(10) < 10 - reinforced)
|
||||
{
|
||||
if (random.nextInt(10) < 10 - reinforced) {
|
||||
damageTool(stack, 1, tags, player, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean onLeftClickEntity (ItemStack stack, EntityLivingBase player, Entity entity, ToolCore tool)
|
||||
{
|
||||
public static boolean onLeftClickEntity(ItemStack stack, EntityLivingBase player, Entity entity, ToolCore tool) {
|
||||
return onLeftClickEntity(stack, player, entity, tool, 0);
|
||||
}
|
||||
|
||||
public static boolean onLeftClickEntity (ItemStack stack, EntityLivingBase player, Entity entity, ToolCore tool, int baseDamage)
|
||||
{
|
||||
if (entity != null && player != null && entity.canAttackWithItem() && stack.hasTagCompound())
|
||||
{
|
||||
public static boolean onLeftClickEntity(
|
||||
ItemStack stack, EntityLivingBase player, Entity entity, ToolCore tool, int baseDamage) {
|
||||
if (entity != null && player != null && entity.canAttackWithItem() && stack.hasTagCompound()) {
|
||||
if (!entity.hitByEntity(player)) // can't attack this entity
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
@@ -85,152 +79,139 @@ public class AbilityHelper
|
||||
float enchantDamage = 0;
|
||||
|
||||
// magic extra damage
|
||||
if (entity instanceof EntityLivingBase)
|
||||
{
|
||||
if (entity instanceof EntityLivingBase) {
|
||||
enchantDamage = EnchantmentHelper.getEnchantmentModifierLiving(player, (EntityLivingBase) entity);
|
||||
}
|
||||
|
||||
if (damage > 0 || enchantDamage > 0)
|
||||
{
|
||||
boolean criticalHit = player.fallDistance > 0.0F && !player.onGround && !player.isOnLadder() && !player.isInWater() && !player.isPotionActive(Potion.blindness) && player.ridingEntity == null && entity instanceof EntityLivingBase;
|
||||
if (damage > 0 || enchantDamage > 0) {
|
||||
boolean criticalHit = player.fallDistance > 0.0F
|
||||
&& !player.onGround
|
||||
&& !player.isOnLadder()
|
||||
&& !player.isInWater()
|
||||
&& !player.isPotionActive(Potion.blindness)
|
||||
&& player.ridingEntity == null
|
||||
&& entity instanceof EntityLivingBase;
|
||||
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
if (mod.doesCriticalHit(tool, tags, toolTags, stack, player, entity))
|
||||
criticalHit = true;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers) {
|
||||
if (mod.doesCriticalHit(tool, tags, toolTags, stack, player, entity)) criticalHit = true;
|
||||
}
|
||||
|
||||
if (criticalHit)
|
||||
{
|
||||
if (criticalHit) {
|
||||
damage += random.nextInt(damage / 2 + 2);
|
||||
}
|
||||
|
||||
damage += enchantDamage;
|
||||
|
||||
if (tool.getDamageModifier() != 1f)
|
||||
{
|
||||
if (tool.getDamageModifier() != 1f) {
|
||||
damage *= tool.getDamageModifier();
|
||||
}
|
||||
|
||||
if (broken)
|
||||
{
|
||||
if (baseDamage > 0)
|
||||
damage = baseDamage;
|
||||
else
|
||||
damage = 1;
|
||||
if (broken) {
|
||||
if (baseDamage > 0) damage = baseDamage;
|
||||
else damage = 1;
|
||||
}
|
||||
boolean causedDamage = false;
|
||||
boolean isAlive = entity.isEntityAlive();
|
||||
if (tool.pierceArmor() && !broken)
|
||||
{
|
||||
if (tool.pierceArmor() && !broken) {
|
||||
if (player instanceof EntityPlayer)
|
||||
causedDamage = entity.attackEntityFrom(causePlayerPiercingDamage((EntityPlayer) player), damage);
|
||||
else
|
||||
causedDamage = entity.attackEntityFrom(causePiercingDamage(player), damage);
|
||||
}
|
||||
else
|
||||
{
|
||||
causedDamage =
|
||||
entity.attackEntityFrom(causePlayerPiercingDamage((EntityPlayer) player), damage);
|
||||
else causedDamage = entity.attackEntityFrom(causePiercingDamage(player), damage);
|
||||
} else {
|
||||
if (player instanceof EntityPlayer)
|
||||
causedDamage = entity.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) player), damage);
|
||||
else
|
||||
causedDamage = entity.attackEntityFrom(DamageSource.causeMobDamage(player), damage);
|
||||
causedDamage = entity.attackEntityFrom(
|
||||
DamageSource.causePlayerDamage((EntityPlayer) player), damage);
|
||||
else causedDamage = entity.attackEntityFrom(DamageSource.causeMobDamage(player), damage);
|
||||
}
|
||||
|
||||
if (causedDamage)
|
||||
{
|
||||
if (causedDamage) {
|
||||
damageTool(stack, 1, tags, player, false);
|
||||
|
||||
// damageTool(stack, 1, player, false);
|
||||
tool.onEntityDamaged(player.worldObj, player, entity);
|
||||
if (!necroticUHS || (entity instanceof IMob && entity instanceof EntityLivingBase && ((EntityLivingBase) entity).getHealth() <= 0))
|
||||
{
|
||||
if(isAlive) {
|
||||
if (!necroticUHS
|
||||
|| (entity instanceof IMob
|
||||
&& entity instanceof EntityLivingBase
|
||||
&& ((EntityLivingBase) entity).getHealth() <= 0)) {
|
||||
if (isAlive) {
|
||||
int drain = toolTags.getInteger("Necrotic") * 2;
|
||||
if (drain > 0)
|
||||
player.heal(random.nextInt(drain + 1));
|
||||
if (drain > 0) player.heal(random.nextInt(drain + 1));
|
||||
}
|
||||
}
|
||||
|
||||
if (knockback > 0)
|
||||
{
|
||||
entity.addVelocity((double) (-MathHelper.sin(player.rotationYaw * (float) Math.PI / 180.0F) * (float) knockback * 0.5F), 0.1D, (double) (MathHelper.cos(player.rotationYaw * (float) Math.PI / 180.0F) * (float) knockback * 0.5F));
|
||||
if (knockback > 0) {
|
||||
entity.addVelocity(
|
||||
(double) (-MathHelper.sin(player.rotationYaw * (float) Math.PI / 180.0F)
|
||||
* (float) knockback
|
||||
* 0.5F),
|
||||
0.1D,
|
||||
(double) (MathHelper.cos(player.rotationYaw * (float) Math.PI / 180.0F)
|
||||
* (float) knockback
|
||||
* 0.5F));
|
||||
player.motionX *= 0.6D;
|
||||
player.motionZ *= 0.6D;
|
||||
player.setSprinting(false);
|
||||
}
|
||||
|
||||
if (player instanceof EntityPlayer)
|
||||
{
|
||||
if (criticalHit)
|
||||
{
|
||||
if (player instanceof EntityPlayer) {
|
||||
if (criticalHit) {
|
||||
((EntityPlayer) player).onCriticalHit(entity);
|
||||
}
|
||||
|
||||
if (enchantDamage > 0)
|
||||
{
|
||||
if (enchantDamage > 0) {
|
||||
((EntityPlayer) player).onEnchantmentCritical(entity);
|
||||
}
|
||||
|
||||
if (damage >= 18)
|
||||
{
|
||||
if (damage >= 18) {
|
||||
((EntityPlayer) player).triggerAchievement(AchievementList.overkill);
|
||||
}
|
||||
}
|
||||
|
||||
player.setLastAttacker(entity);
|
||||
|
||||
if (entity instanceof EntityLivingBase)
|
||||
{
|
||||
DamageSource.causeThornsDamage(entity);// (((EntityLivingBase)player,
|
||||
// (EntityLivingBase)
|
||||
// entity);
|
||||
if (entity instanceof EntityLivingBase) {
|
||||
DamageSource.causeThornsDamage(entity); // (((EntityLivingBase)player,
|
||||
// (EntityLivingBase)
|
||||
// entity);
|
||||
}
|
||||
}
|
||||
|
||||
if (entity instanceof EntityLivingBase)
|
||||
{
|
||||
if (entity instanceof EntityPlayer)
|
||||
{
|
||||
if (entity instanceof EntityLivingBase) {
|
||||
if (entity instanceof EntityPlayer) {
|
||||
stack.hitEntity((EntityLivingBase) entity, (EntityPlayer) player);
|
||||
if (entity.isEntityAlive())
|
||||
{
|
||||
if (entity.isEntityAlive()) {
|
||||
alertPlayerWolves((EntityPlayer) player, (EntityLivingBase) entity, true);
|
||||
}
|
||||
|
||||
((EntityPlayer) player).addStat(StatList.damageDealtStat, damage);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
stack.getItem().hitEntity(stack, (EntityLivingBase) entity, player);
|
||||
}
|
||||
|
||||
if(causedDamage)
|
||||
processFiery(player, entity, toolTags);
|
||||
if (causedDamage) processFiery(player, entity, toolTags);
|
||||
}
|
||||
|
||||
if (entity instanceof EntityPlayer)
|
||||
((EntityPlayer) player).addExhaustion(0.3F);
|
||||
if (causedDamage)
|
||||
return true;
|
||||
if (entity instanceof EntityPlayer) ((EntityPlayer) player).addExhaustion(0.3F);
|
||||
if (causedDamage) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int calcDamage(Entity user, Entity entity, ItemStack stack, ToolCore tool, NBTTagCompound toolTags, int baseDamage)
|
||||
{
|
||||
EntityLivingBase living = user instanceof EntityLivingBase ? (EntityLivingBase)user : null;
|
||||
public static int calcDamage(
|
||||
Entity user, Entity entity, ItemStack stack, ToolCore tool, NBTTagCompound toolTags, int baseDamage) {
|
||||
EntityLivingBase living = user instanceof EntityLivingBase ? (EntityLivingBase) user : null;
|
||||
|
||||
int damage = toolTags.getInteger("Attack") + baseDamage;
|
||||
int earlyModDamage = 0;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
earlyModDamage = mod.baseAttackDamage(earlyModDamage, damage, tool, stack.getTagCompound(), toolTags, stack, living, entity);
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers) {
|
||||
earlyModDamage = mod.baseAttackDamage(
|
||||
earlyModDamage, damage, tool, stack.getTagCompound(), toolTags, stack, living, entity);
|
||||
}
|
||||
damage += earlyModDamage;
|
||||
|
||||
if(living != null) {
|
||||
if (living != null) {
|
||||
if (living.isPotionActive(Potion.damageBoost)) {
|
||||
damage += 3 << living.getActivePotionEffect(Potion.damageBoost).getAmplifier();
|
||||
}
|
||||
@@ -241,108 +222,109 @@ public class AbilityHelper
|
||||
}
|
||||
|
||||
damage -= calcStoneboundBonus(tool, toolTags);
|
||||
if (damage < 1)
|
||||
damage = 1;
|
||||
if (damage < 1) damage = 1;
|
||||
|
||||
if (living != null && living.isSprinting())
|
||||
{
|
||||
if (living != null && living.isSprinting()) {
|
||||
float lunge = tool.chargeAttack();
|
||||
if (lunge > 1f)
|
||||
{
|
||||
if (lunge > 1f) {
|
||||
damage *= lunge;
|
||||
}
|
||||
}
|
||||
|
||||
int modDamage = 0;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
modDamage = mod.attackDamage(modDamage, damage, tool, stack.getTagCompound(), toolTags, stack, living, entity);
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers) {
|
||||
modDamage =
|
||||
mod.attackDamage(modDamage, damage, tool, stack.getTagCompound(), toolTags, stack, living, entity);
|
||||
}
|
||||
damage += modDamage;
|
||||
|
||||
return damage;
|
||||
}
|
||||
|
||||
public static float calcKnockback(Entity user, Entity entity, ItemStack stack, ToolCore tool, NBTTagCompound toolTags, int baseDamage)
|
||||
{
|
||||
if(user == null) return 0;
|
||||
public static float calcKnockback(
|
||||
Entity user, Entity entity, ItemStack stack, ToolCore tool, NBTTagCompound toolTags, int baseDamage) {
|
||||
if (user == null) return 0;
|
||||
float knockback = 0;
|
||||
|
||||
if (entity instanceof EntityLivingBase && user instanceof EntityLivingBase)
|
||||
{
|
||||
knockback += EnchantmentHelper.getKnockbackModifier((EntityLivingBase)user, (EntityLivingBase) entity);
|
||||
if (entity instanceof EntityLivingBase && user instanceof EntityLivingBase) {
|
||||
knockback += EnchantmentHelper.getKnockbackModifier((EntityLivingBase) user, (EntityLivingBase) entity);
|
||||
}
|
||||
|
||||
if (user.isSprinting())
|
||||
{
|
||||
if (user.isSprinting()) {
|
||||
knockback++;
|
||||
float lunge = tool.chargeAttack();
|
||||
if (lunge > 1f)
|
||||
{
|
||||
if (lunge > 1f) {
|
||||
knockback += lunge - 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
float modKnockback = 0f;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
modKnockback = mod.knockback(modKnockback, knockback, tool, stack.getTagCompound(), toolTags, stack, user instanceof EntityLivingBase ? (EntityLivingBase)user : null, entity);
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers) {
|
||||
modKnockback = mod.knockback(
|
||||
modKnockback,
|
||||
knockback,
|
||||
tool,
|
||||
stack.getTagCompound(),
|
||||
toolTags,
|
||||
stack,
|
||||
user instanceof EntityLivingBase ? (EntityLivingBase) user : null,
|
||||
entity);
|
||||
}
|
||||
knockback += modKnockback;
|
||||
|
||||
return knockback;
|
||||
}
|
||||
|
||||
public static void processFiery(Entity player, Entity target, NBTTagCompound toolTags)
|
||||
{
|
||||
public static void processFiery(Entity player, Entity target, NBTTagCompound toolTags) {
|
||||
// only living things burnnnn
|
||||
if(!(target instanceof EntityLivingBase))
|
||||
return;
|
||||
if (!(target instanceof EntityLivingBase)) return;
|
||||
|
||||
int fireAspect = 0;
|
||||
if(player instanceof EntityLivingBase)
|
||||
fireAspect = EnchantmentHelper.getFireAspectModifier((EntityLivingBase)player);
|
||||
if (player instanceof EntityLivingBase)
|
||||
fireAspect = EnchantmentHelper.getFireAspectModifier((EntityLivingBase) player);
|
||||
|
||||
if ((fireAspect > 0 || toolTags.hasKey("Fiery") || toolTags.hasKey("Lava")))
|
||||
{
|
||||
if ((fireAspect > 0 || toolTags.hasKey("Fiery") || toolTags.hasKey("Lava"))) {
|
||||
fireAspect *= 4;
|
||||
if (toolTags.hasKey("Fiery"))
|
||||
{
|
||||
if (toolTags.hasKey("Fiery")) {
|
||||
fireAspect += toolTags.getInteger("Fiery") / 5 + 1;
|
||||
}
|
||||
if (toolTags.getBoolean("Lava"))
|
||||
{
|
||||
if (toolTags.getBoolean("Lava")) {
|
||||
fireAspect += 3;
|
||||
}
|
||||
target.setFire(fireAspect);
|
||||
}
|
||||
}
|
||||
|
||||
static void alertPlayerWolves (EntityPlayer player, EntityLivingBase living, boolean par2)
|
||||
{
|
||||
if (!(living instanceof EntityCreeper) && !(living instanceof EntityGhast))
|
||||
{
|
||||
if (living instanceof EntityWolf)
|
||||
{
|
||||
static void alertPlayerWolves(EntityPlayer player, EntityLivingBase living, boolean par2) {
|
||||
if (!(living instanceof EntityCreeper) && !(living instanceof EntityGhast)) {
|
||||
if (living instanceof EntityWolf) {
|
||||
EntityWolf var3 = (EntityWolf) living;
|
||||
|
||||
if (var3.isTamed() && player.getDisplayName().equals(var3.func_152113_b()))
|
||||
{
|
||||
if (var3.isTamed() && player.getDisplayName().equals(var3.func_152113_b())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(living instanceof EntityPlayer) || player.canAttackPlayer((EntityPlayer) living))
|
||||
{
|
||||
List var6 = player.worldObj.getEntitiesWithinAABB(EntityWolf.class, AxisAlignedBB.getBoundingBox(player.posX, player.posY, player.posZ, player.posX + 1.0D, player.posY + 1.0D, player.posZ + 1.0D).expand(16.0D, 4.0D, 16.0D));
|
||||
if (!(living instanceof EntityPlayer) || player.canAttackPlayer((EntityPlayer) living)) {
|
||||
List var6 = player.worldObj.getEntitiesWithinAABB(
|
||||
EntityWolf.class,
|
||||
AxisAlignedBB.getBoundingBox(
|
||||
player.posX,
|
||||
player.posY,
|
||||
player.posZ,
|
||||
player.posX + 1.0D,
|
||||
player.posY + 1.0D,
|
||||
player.posZ + 1.0D)
|
||||
.expand(16.0D, 4.0D, 16.0D));
|
||||
Iterator var4 = var6.iterator();
|
||||
|
||||
while (var4.hasNext())
|
||||
{
|
||||
while (var4.hasNext()) {
|
||||
EntityWolf var5 = (EntityWolf) var4.next();
|
||||
|
||||
if (var5.isTamed() && var5.getEntityToAttack() == null && player.getDisplayName().equals(var5.func_152113_b()) && (!par2 || !var5.isSitting()))
|
||||
{
|
||||
if (var5.isTamed()
|
||||
&& var5.getEntityToAttack() == null
|
||||
&& player.getDisplayName().equals(var5.func_152113_b())
|
||||
&& (!par2 || !var5.isSitting())) {
|
||||
var5.setSitting(false);
|
||||
var5.setTarget(living);
|
||||
}
|
||||
@@ -352,87 +334,67 @@ public class AbilityHelper
|
||||
}
|
||||
|
||||
/* Tool specific */
|
||||
public static void damageTool (ItemStack stack, int dam, EntityLivingBase entity, boolean ignoreCharge)
|
||||
{
|
||||
public static void damageTool(ItemStack stack, int dam, EntityLivingBase entity, boolean ignoreCharge) {
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
damageTool(stack, dam, tags, entity, ignoreCharge);
|
||||
}
|
||||
|
||||
public static void healTool (ItemStack stack, int dam, EntityLivingBase entity, boolean ignoreCharge)
|
||||
{
|
||||
public static void healTool(ItemStack stack, int dam, EntityLivingBase entity, boolean ignoreCharge) {
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
damageTool(stack, -dam, tags, entity, ignoreCharge);
|
||||
}
|
||||
|
||||
public static void damageTool (ItemStack stack, int dam, NBTTagCompound tags, EntityLivingBase entity, boolean ignoreCharge)
|
||||
{
|
||||
public static void damageTool(
|
||||
ItemStack stack, int dam, NBTTagCompound tags, EntityLivingBase entity, boolean ignoreCharge) {
|
||||
if (entity instanceof EntityPlayer && ((EntityPlayer) entity).capabilities.isCreativeMode || tags == null)
|
||||
return;
|
||||
|
||||
// calculate in reinforced/unbreaking
|
||||
int reinforced = 0;
|
||||
if(tags.hasKey("InfiTool") && dam > 0) // unbreaking only affects damage, not healing
|
||||
if (tags.hasKey("InfiTool") && dam > 0) // unbreaking only affects damage, not healing
|
||||
{
|
||||
NBTTagCompound toolTags = tags.getCompoundTag("InfiTool");
|
||||
if(toolTags.hasKey("Unbreaking"))
|
||||
{
|
||||
if (toolTags.hasKey("Unbreaking")) {
|
||||
reinforced = tags.getCompoundTag("InfiTool").getInteger("Unbreaking");
|
||||
// for each point of damage we deal, we separately decide if reinforced takes effect
|
||||
for(int i = dam; i > 0; i--)
|
||||
if(random.nextInt(10) < reinforced)
|
||||
dam--;
|
||||
for (int i = dam; i > 0; i--) if (random.nextInt(10) < reinforced) dam--;
|
||||
|
||||
// we prevented all damage with reinforced
|
||||
if(dam <= 0)
|
||||
return;
|
||||
if (dam <= 0) return;
|
||||
}
|
||||
}
|
||||
|
||||
if (ignoreCharge || !damageEnergyTool(stack, tags, entity))
|
||||
{
|
||||
if (ignoreCharge || !damageEnergyTool(stack, tags, entity)) {
|
||||
boolean damagedTool = false;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
if (mod.damageTool(stack, dam, entity))
|
||||
damagedTool = true;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers) {
|
||||
if (mod.damageTool(stack, dam, entity)) damagedTool = true;
|
||||
}
|
||||
|
||||
if (damagedTool)
|
||||
return;
|
||||
if (damagedTool) return;
|
||||
|
||||
int damage = tags.getCompoundTag("InfiTool").getInteger("Damage");
|
||||
int damageTrue = damage + dam;
|
||||
int maxDamage = tags.getCompoundTag("InfiTool").getInteger("TotalDurability");
|
||||
if (damageTrue <= 0)
|
||||
{
|
||||
if (damageTrue <= 0) {
|
||||
tags.getCompoundTag("InfiTool").setInteger("Damage", 0);
|
||||
//stack.setItemDamage(0);
|
||||
// stack.setItemDamage(0);
|
||||
tags.getCompoundTag("InfiTool").setBoolean("Broken", false);
|
||||
}
|
||||
|
||||
else if (damageTrue > maxDamage)
|
||||
{
|
||||
} else if (damageTrue > maxDamage) {
|
||||
breakTool(stack, tags, entity);
|
||||
//stack.setItemDamage(0);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// stack.setItemDamage(0);
|
||||
} else {
|
||||
tags.getCompoundTag("InfiTool").setInteger("Damage", damage + dam);
|
||||
int toolDamage = (damage * 100 / maxDamage) + 1;
|
||||
int stackDamage = stack.getItemDamage();
|
||||
if (toolDamage != stackDamage)
|
||||
{
|
||||
//stack.setItemDamage((damage * 100 / maxDamage) + 1);
|
||||
if (toolDamage != stackDamage) {
|
||||
// stack.setItemDamage((damage * 100 / maxDamage) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean damageEnergyTool (ItemStack stack, NBTTagCompound tags, Entity entity)
|
||||
{
|
||||
if (!tags.hasKey("Energy"))
|
||||
return false;
|
||||
public static boolean damageEnergyTool(ItemStack stack, NBTTagCompound tags, Entity entity) {
|
||||
if (!tags.hasKey("Energy")) return false;
|
||||
|
||||
NBTTagCompound toolTag = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
int energy = tags.getInteger("Energy");
|
||||
@@ -441,20 +403,17 @@ public class AbilityHelper
|
||||
|
||||
float mineSpeed = toolTag.getInteger("MiningSpeed");
|
||||
int heads = 1;
|
||||
if (toolTag.hasKey("MiningSpeed2"))
|
||||
{
|
||||
if (toolTag.hasKey("MiningSpeed2")) {
|
||||
mineSpeed += toolTag.getInteger("MiningSpeed2");
|
||||
heads++;
|
||||
}
|
||||
|
||||
if (toolTag.hasKey("MiningSpeedHandle"))
|
||||
{
|
||||
if (toolTag.hasKey("MiningSpeedHandle")) {
|
||||
mineSpeed += toolTag.getInteger("MiningSpeedHandle");
|
||||
heads++;
|
||||
}
|
||||
|
||||
if (toolTag.hasKey("MiningSpeedExtra"))
|
||||
{
|
||||
if (toolTag.hasKey("MiningSpeedExtra")) {
|
||||
mineSpeed += toolTag.getInteger("MiningSpeedExtra");
|
||||
heads++;
|
||||
}
|
||||
@@ -463,38 +422,33 @@ public class AbilityHelper
|
||||
float bonusLog = (float) Math.log(durability / 72f + 1) * 2 * stonebound;
|
||||
trueSpeed += bonusLog;
|
||||
trueSpeed *= 6;
|
||||
if (energy != -1)
|
||||
{
|
||||
int usage = (int)(trueSpeed * 2.8f);
|
||||
if (energy != -1) {
|
||||
int usage = (int) (trueSpeed * 2.8f);
|
||||
// first try charging from the hotbar if we don't have CoFHs override
|
||||
if (!equalityOverrideLoaded && entity instanceof EntityPlayer)
|
||||
{
|
||||
if (!equalityOverrideLoaded && entity instanceof EntityPlayer) {
|
||||
ToolCore tool = (ToolCore) stack.getItem();
|
||||
// workaround for charging flux-capacitors making tools unusable
|
||||
chargeEnergyFromHotbar(stack, (EntityPlayer) entity, tags);
|
||||
energy = tool.getEnergyStored(stack);
|
||||
}
|
||||
|
||||
if (energy < usage)
|
||||
{
|
||||
if (energy > 0)
|
||||
tags.setInteger("Energy", 0);
|
||||
if (energy < usage) {
|
||||
if (energy > 0) tags.setInteger("Energy", 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
energy -= usage;
|
||||
tags.setInteger("Energy", energy);
|
||||
|
||||
//stack.setItemDamage(1 + (tool.getMaxEnergyStored(stack) - energy) * (stack.getMaxDamage() - 1) / tool.getMaxEnergyStored(stack));
|
||||
// stack.setItemDamage(1 + (tool.getMaxEnergyStored(stack) - energy) * (stack.getMaxDamage() - 1) /
|
||||
// tool.getMaxEnergyStored(stack));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected static void chargeEnergyFromHotbar (ItemStack stack, EntityPlayer player, NBTTagCompound tags)
|
||||
{
|
||||
protected static void chargeEnergyFromHotbar(ItemStack stack, EntityPlayer player, NBTTagCompound tags) {
|
||||
// cool kids only
|
||||
if (!(stack.getItem() instanceof ToolCore))
|
||||
return;
|
||||
if (!(stack.getItem() instanceof ToolCore)) return;
|
||||
|
||||
ToolCore tool = (ToolCore) stack.getItem();
|
||||
|
||||
@@ -508,26 +462,21 @@ public class AbilityHelper
|
||||
int missing = max - buffer;
|
||||
|
||||
// you're full. xbox go home.
|
||||
if (missing <= 0)
|
||||
return;
|
||||
if (missing <= 0) return;
|
||||
|
||||
// iterate through hotbar
|
||||
for (int iter = 0; iter < 9; ++iter)
|
||||
{
|
||||
for (int iter = 0; iter < 9; ++iter) {
|
||||
ItemStack slot = player.inventory.mainInventory[iter];
|
||||
|
||||
// check if item is not another tool
|
||||
if (slot == null || slot.getItem() instanceof ToolCore)
|
||||
continue;
|
||||
if (slot == null || slot.getItem() instanceof ToolCore) continue;
|
||||
// check if item gives energy
|
||||
if (!(slot.getItem() instanceof IEnergyContainerItem))
|
||||
continue;
|
||||
if (!(slot.getItem() instanceof IEnergyContainerItem)) continue;
|
||||
|
||||
IEnergyContainerItem fluxItem = (IEnergyContainerItem) slot.getItem();
|
||||
|
||||
// mDiyo EATS your power
|
||||
while (fluxItem.extractEnergy(slot, missing, true) > 0)
|
||||
{
|
||||
while (fluxItem.extractEnergy(slot, missing, true) > 0) {
|
||||
missing -= fluxItem.extractEnergy(slot, missing, false);
|
||||
}
|
||||
}
|
||||
@@ -535,172 +484,158 @@ public class AbilityHelper
|
||||
tags.setInteger("Energy", max - missing);
|
||||
}
|
||||
|
||||
private static boolean equalityOverrideLoaded = Loader.isModLoaded("CoFHCore"); // Mods should be loaded far enough before this is ever initialized
|
||||
private static boolean equalityOverrideLoaded =
|
||||
Loader.isModLoaded("CoFHCore"); // Mods should be loaded far enough before this is ever initialized
|
||||
|
||||
public static void breakTool (ItemStack stack, NBTTagCompound tags, Entity entity)
|
||||
{
|
||||
public static void breakTool(ItemStack stack, NBTTagCompound tags, Entity entity) {
|
||||
tags.getCompoundTag("InfiTool").setBoolean("Broken", true);
|
||||
if (entity != null)
|
||||
entity.worldObj.playSound(entity.posX, entity.posY, entity.posZ, "random.break", 1f, 1f, true);
|
||||
}
|
||||
|
||||
public static void repairTool (ItemStack stack, NBTTagCompound tags)
|
||||
{
|
||||
public static void repairTool(ItemStack stack, NBTTagCompound tags) {
|
||||
tags.getCompoundTag("InfiTool").setBoolean("Broken", false);
|
||||
tags.getCompoundTag("InfiTool").setInteger("Damage", 0);
|
||||
}
|
||||
|
||||
public static DamageSource causePiercingDamage (EntityLivingBase mob)
|
||||
{
|
||||
public static DamageSource causePiercingDamage(EntityLivingBase mob) {
|
||||
return new PiercingEntityDamage("mob", mob);
|
||||
}
|
||||
|
||||
public static DamageSource causePlayerPiercingDamage (EntityPlayer player)
|
||||
{
|
||||
public static DamageSource causePlayerPiercingDamage(EntityPlayer player) {
|
||||
return new PiercingEntityDamage("player", player);
|
||||
}
|
||||
|
||||
public static void knockbackEntity (EntityLivingBase living, double boost)
|
||||
{
|
||||
public static void knockbackEntity(EntityLivingBase living, double boost) {
|
||||
living.motionX *= boost;
|
||||
// living.motionY *= boost/2;
|
||||
living.motionZ *= boost;
|
||||
}
|
||||
|
||||
public static boolean hoeGround (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, Random random)
|
||||
{
|
||||
if (!player.canPlayerEdit(x, y, z, side, stack))
|
||||
{
|
||||
public static boolean hoeGround(
|
||||
ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, Random random) {
|
||||
if (!player.canPlayerEdit(x, y, z, side, stack)) {
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z);
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
{
|
||||
if (MinecraftForge.EVENT_BUS.post(event)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (event.getResult() == Result.ALLOW)
|
||||
{
|
||||
if (event.getResult() == Result.ALLOW) {
|
||||
damageTool(stack, 1, player, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
if (side != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt))
|
||||
{
|
||||
if (side != 0
|
||||
&& world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z)
|
||||
&& (block == Blocks.grass || block == Blocks.dirt)) {
|
||||
Block block1 = Blocks.farmland;
|
||||
world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);
|
||||
world.playSoundEffect(
|
||||
(double) ((float) x + 0.5F),
|
||||
(double) ((float) y + 0.5F),
|
||||
(double) ((float) z + 0.5F),
|
||||
block1.stepSound.getStepResourcePath(),
|
||||
(block1.stepSound.getVolume() + 1.0F) / 2.0F,
|
||||
block1.stepSound.getPitch() * 0.8F);
|
||||
|
||||
if (world.isRemote)
|
||||
{
|
||||
if (world.isRemote) {
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
world.setBlock(x, y, z, block1);
|
||||
damageTool(stack, 1, player, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void spawnItemAtEntity (Entity entity, ItemStack stack, int delay)
|
||||
{
|
||||
if (!entity.worldObj.isRemote)
|
||||
{
|
||||
EntityItem entityitem = new EntityItem(entity.worldObj, entity.posX + 0.5D, entity.posY + 0.5D, entity.posZ + 0.5D, stack);
|
||||
public static void spawnItemAtEntity(Entity entity, ItemStack stack, int delay) {
|
||||
if (!entity.worldObj.isRemote) {
|
||||
EntityItem entityitem =
|
||||
new EntityItem(entity.worldObj, entity.posX + 0.5D, entity.posY + 0.5D, entity.posZ + 0.5D, stack);
|
||||
entityitem.delayBeforeCanPickup = delay;
|
||||
entity.worldObj.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
|
||||
public static void spawnItemAtPlayer (EntityPlayer player, ItemStack stack)
|
||||
{
|
||||
if (!player.worldObj.isRemote)
|
||||
{
|
||||
public static void spawnItemAtPlayer(EntityPlayer player, ItemStack stack) {
|
||||
if (!player.worldObj.isRemote) {
|
||||
// try to put it into the players inventory
|
||||
if(player instanceof FakePlayer || !player.inventory.addItemStackToInventory(stack)) // note that the addItemStackToInventory is not called for fake players
|
||||
if (player instanceof FakePlayer
|
||||
|| !player.inventory.addItemStackToInventory(
|
||||
stack)) // note that the addItemStackToInventory is not called for fake players
|
||||
{
|
||||
// drop the rest as an entity
|
||||
EntityItem entityitem = new EntityItem(player.worldObj, player.posX + 0.5D, player.posY + 0.5D, player.posZ + 0.5D, stack);
|
||||
EntityItem entityitem = new EntityItem(
|
||||
player.worldObj, player.posX + 0.5D, player.posY + 0.5D, player.posZ + 0.5D, stack);
|
||||
player.worldObj.spawnEntityInWorld(entityitem);
|
||||
if (!(player instanceof FakePlayer))
|
||||
entityitem.onCollideWithPlayer(player);
|
||||
if (!(player instanceof FakePlayer)) entityitem.onCollideWithPlayer(player);
|
||||
}
|
||||
// if it got picked up, we're playing the sound
|
||||
else {
|
||||
if(player instanceof EntityPlayerMP) {
|
||||
player.worldObj.playSoundAtEntity(player, "random.pop", 0.2F, ((TConstruct.random.nextFloat() - TConstruct.random.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
player.worldObj.playSoundAtEntity(
|
||||
player,
|
||||
"random.pop",
|
||||
0.2F,
|
||||
((TConstruct.random.nextFloat() - TConstruct.random.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
player.inventoryContainer.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Ranged weapons */
|
||||
|
||||
public static void forceAddToInv (EntityPlayer entityplayer, ItemStack itemstack, int i, boolean flag)
|
||||
{
|
||||
public static void forceAddToInv(EntityPlayer entityplayer, ItemStack itemstack, int i, boolean flag) {
|
||||
ItemStack itemstack1 = entityplayer.inventory.getStackInSlot(i);
|
||||
entityplayer.inventory.setInventorySlotContents(i, itemstack);
|
||||
if (itemstack1 != null)
|
||||
{
|
||||
if (itemstack1 != null) {
|
||||
addToInv(entityplayer, itemstack1, flag);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean addToInv (EntityPlayer entityplayer, ItemStack itemstack, boolean flag)
|
||||
{
|
||||
public static boolean addToInv(EntityPlayer entityplayer, ItemStack itemstack, boolean flag) {
|
||||
return addToInv(entityplayer, itemstack, entityplayer.inventory.currentItem, flag);
|
||||
}
|
||||
|
||||
public static boolean addToInv (EntityPlayer entityplayer, ItemStack itemstack, int i, boolean flag)
|
||||
{
|
||||
public static boolean addToInv(EntityPlayer entityplayer, ItemStack itemstack, int i, boolean flag) {
|
||||
ItemStack itemstack1 = entityplayer.inventory.getStackInSlot(i);
|
||||
boolean flag1;
|
||||
if (itemstack1 == null)
|
||||
{
|
||||
if (itemstack1 == null) {
|
||||
entityplayer.inventory.setInventorySlotContents(i, itemstack);
|
||||
flag1 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
flag1 = entityplayer.inventory.addItemStackToInventory(itemstack);
|
||||
}
|
||||
if (flag && !flag1)
|
||||
{
|
||||
addItemStackToWorld(entityplayer.worldObj, (float) Math.floor(entityplayer.posX), (float) Math.floor(entityplayer.posY), (float) Math.floor(entityplayer.posZ), itemstack);
|
||||
if (flag && !flag1) {
|
||||
addItemStackToWorld(
|
||||
entityplayer.worldObj,
|
||||
(float) Math.floor(entityplayer.posX),
|
||||
(float) Math.floor(entityplayer.posY),
|
||||
(float) Math.floor(entityplayer.posZ),
|
||||
itemstack);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return flag1;
|
||||
}
|
||||
}
|
||||
|
||||
public static EntityItem addItemStackToWorld (World world, float f, float f1, float f2, ItemStack itemstack)
|
||||
{
|
||||
public static EntityItem addItemStackToWorld(World world, float f, float f1, float f2, ItemStack itemstack) {
|
||||
return addItemStackToWorld(world, f, f1, f2, itemstack, false);
|
||||
}
|
||||
|
||||
public static EntityItem addItemStackToWorld (World world, float f, float f1, float f2, ItemStack itemstack, boolean flag)
|
||||
{
|
||||
public static EntityItem addItemStackToWorld(
|
||||
World world, float f, float f1, float f2, ItemStack itemstack, boolean flag) {
|
||||
EntityItem entityitem;
|
||||
if (flag)
|
||||
{
|
||||
if (flag) {
|
||||
entityitem = new EntityItem(world, f, f1, f2, itemstack);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
float f3 = 0.7F;
|
||||
float f4 = random.nextFloat() * f3 + (1.0F - f3) * 0.5F;
|
||||
float f5 = 1.2F;
|
||||
@@ -712,15 +647,13 @@ public class AbilityHelper
|
||||
return entityitem;
|
||||
}
|
||||
|
||||
public static MovingObjectPosition raytraceFromEntity (World world, Entity player, boolean par3, double range)
|
||||
{
|
||||
public static MovingObjectPosition raytraceFromEntity(World world, Entity player, boolean par3, double range) {
|
||||
float f = 1.0F;
|
||||
float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
|
||||
float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
|
||||
double d0 = player.prevPosX + (player.posX - player.prevPosX) * (double) f;
|
||||
double d1 = player.prevPosY + (player.posY - player.prevPosY) * (double) f;
|
||||
if (!world.isRemote && player instanceof EntityPlayer)
|
||||
d1 += 1.62D;
|
||||
if (!world.isRemote && player instanceof EntityPlayer) d1 += 1.62D;
|
||||
double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) f;
|
||||
Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2);
|
||||
float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI);
|
||||
@@ -730,38 +663,32 @@ public class AbilityHelper
|
||||
float f7 = f4 * f5;
|
||||
float f8 = f3 * f5;
|
||||
double d3 = range;
|
||||
if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance();
|
||||
}
|
||||
Vec3 vec31 = vec3.addVector((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
|
||||
return world.func_147447_a(vec3, vec31, par3, !par3, par3);
|
||||
}
|
||||
|
||||
public static float calcToolSpeed (ToolCore tool, NBTTagCompound tags)
|
||||
{
|
||||
public static float calcToolSpeed(ToolCore tool, NBTTagCompound tags) {
|
||||
float mineSpeed = tags.getInteger("MiningSpeed");
|
||||
int heads = 1;
|
||||
if (tags.hasKey("MiningSpeed2"))
|
||||
{
|
||||
if (tags.hasKey("MiningSpeed2")) {
|
||||
mineSpeed += tags.getInteger("MiningSpeed2");
|
||||
heads++;
|
||||
}
|
||||
|
||||
if (tags.hasKey("MiningSpeedHandle"))
|
||||
{
|
||||
if (tags.hasKey("MiningSpeedHandle")) {
|
||||
mineSpeed += tags.getInteger("MiningSpeedHandle");
|
||||
heads++;
|
||||
}
|
||||
|
||||
if (tags.hasKey("MiningSpeedExtra"))
|
||||
{
|
||||
if (tags.hasKey("MiningSpeedExtra")) {
|
||||
mineSpeed += tags.getInteger("MiningSpeedExtra");
|
||||
heads++;
|
||||
}
|
||||
float speedMod = 1f;
|
||||
if (tool instanceof HarvestTool)
|
||||
speedMod = ((HarvestTool) tool).breakSpeedModifier();
|
||||
if (tool instanceof HarvestTool) speedMod = ((HarvestTool) tool).breakSpeedModifier();
|
||||
|
||||
float trueSpeed = mineSpeed / (heads * 100f) * speedMod;
|
||||
trueSpeed += calcStoneboundBonus(tool, tags);
|
||||
@@ -769,15 +696,13 @@ public class AbilityHelper
|
||||
return trueSpeed;
|
||||
}
|
||||
|
||||
public static float calcDualToolSpeed (ToolCore tool, NBTTagCompound tags, boolean secondary)
|
||||
{
|
||||
public static float calcDualToolSpeed(ToolCore tool, NBTTagCompound tags, boolean secondary) {
|
||||
String tag = "MiningSpeed";
|
||||
if(secondary) tag += "2";
|
||||
if (secondary) tag += "2";
|
||||
|
||||
float mineSpeed = tags.getInteger(tag);
|
||||
float speedMod = 1f;
|
||||
if (tool instanceof HarvestTool)
|
||||
speedMod = ((HarvestTool) tool).breakSpeedModifier();
|
||||
if (tool instanceof HarvestTool) speedMod = ((HarvestTool) tool).breakSpeedModifier();
|
||||
|
||||
float trueSpeed = mineSpeed / 100f * speedMod;
|
||||
trueSpeed += calcStoneboundBonus(tool, tags);
|
||||
@@ -785,13 +710,11 @@ public class AbilityHelper
|
||||
return trueSpeed;
|
||||
}
|
||||
|
||||
public static float calcStoneboundBonus (ToolCore tool, NBTTagCompound tags)
|
||||
{
|
||||
public static float calcStoneboundBonus(ToolCore tool, NBTTagCompound tags) {
|
||||
int durability = tags.getInteger("Damage");
|
||||
float stonebound = tags.getFloat("Shoddy");
|
||||
float stoneboundMod = 72f;
|
||||
if (tool instanceof HarvestTool)
|
||||
stoneboundMod = ((HarvestTool) tool).stoneboundModifier();
|
||||
if (tool instanceof HarvestTool) stoneboundMod = ((HarvestTool) tool).stoneboundModifier();
|
||||
|
||||
return (float) Math.log(durability / stoneboundMod + 1) * 2 * stonebound;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
package tconstruct.library.tools;
|
||||
|
||||
public class ArrowMaterial
|
||||
{
|
||||
public class ArrowMaterial {
|
||||
public final float mass;
|
||||
public final float breakChance;
|
||||
|
||||
public ArrowMaterial(float weight, float breakChance)
|
||||
{
|
||||
public ArrowMaterial(float weight, float breakChance) {
|
||||
this.mass = weight;
|
||||
this.breakChance = breakChance;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ArrowMaterial(float weight, float breakChance, float accuraccy)
|
||||
{
|
||||
public ArrowMaterial(float weight, float breakChance, float accuraccy) {
|
||||
this(weight, breakChance);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
package tconstruct.library.tools;
|
||||
|
||||
public class BowMaterial
|
||||
{
|
||||
public class BowMaterial {
|
||||
public final int drawspeed;
|
||||
public final float flightSpeedMax;
|
||||
|
||||
public BowMaterial(int drawspeed, float attack)
|
||||
{
|
||||
public BowMaterial(int drawspeed, float attack) {
|
||||
this.drawspeed = drawspeed;
|
||||
this.flightSpeedMax = attack;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public BowMaterial(int durability, int drawspeed, float attack)
|
||||
{
|
||||
public BowMaterial(int durability, int drawspeed, float attack) {
|
||||
this(drawspeed, attack);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,20 @@ package tconstruct.library.tools;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class BowstringMaterial extends CustomMaterial
|
||||
{
|
||||
public class BowstringMaterial extends CustomMaterial {
|
||||
public final float durabilityModifier;
|
||||
public final float drawspeedModifier;
|
||||
public final float flightSpeedModifier;
|
||||
|
||||
public BowstringMaterial(int materialID, int value, ItemStack input, ItemStack craftingItem, float durability, float drawspeed, float flightspeed, int color)
|
||||
{
|
||||
public BowstringMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
ItemStack input,
|
||||
ItemStack craftingItem,
|
||||
float durability,
|
||||
float drawspeed,
|
||||
float flightspeed,
|
||||
int color) {
|
||||
super(materialID, value, input, craftingItem, color);
|
||||
this.durabilityModifier = durability;
|
||||
this.drawspeedModifier = drawspeed;
|
||||
@@ -17,8 +23,14 @@ public class BowstringMaterial extends CustomMaterial
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public BowstringMaterial(int materialID, int value, ItemStack input, ItemStack craftingItem, float durability, float drawspeed, float flightspeed)
|
||||
{
|
||||
public BowstringMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
ItemStack input,
|
||||
ItemStack craftingItem,
|
||||
float durability,
|
||||
float drawspeed,
|
||||
float flightspeed) {
|
||||
super(materialID, value, input, craftingItem);
|
||||
this.durabilityModifier = durability;
|
||||
this.drawspeedModifier = drawspeed;
|
||||
|
||||
@@ -4,8 +4,7 @@ import java.util.List;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public abstract class CustomMaterial
|
||||
{
|
||||
public abstract class CustomMaterial {
|
||||
public final int materialID;
|
||||
public final int value;
|
||||
public final ItemStack input;
|
||||
@@ -14,14 +13,11 @@ public abstract class CustomMaterial
|
||||
public final int color;
|
||||
|
||||
@Deprecated
|
||||
public CustomMaterial(int materialID, int value, ItemStack input, ItemStack craftingItem)
|
||||
{
|
||||
public CustomMaterial(int materialID, int value, ItemStack input, ItemStack craftingItem) {
|
||||
this(materialID, value, input, craftingItem, 0xffffffff);
|
||||
}
|
||||
|
||||
|
||||
public CustomMaterial(int materialID, int value, ItemStack input, ItemStack craftingItem, int color)
|
||||
{
|
||||
public CustomMaterial(int materialID, int value, ItemStack input, ItemStack craftingItem, int color) {
|
||||
this.materialID = materialID;
|
||||
this.value = value;
|
||||
this.input = input;
|
||||
@@ -31,13 +27,11 @@ public abstract class CustomMaterial
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public CustomMaterial(int materialID, int value, String oredict, ItemStack craftingItem)
|
||||
{
|
||||
public CustomMaterial(int materialID, int value, String oredict, ItemStack craftingItem) {
|
||||
this(materialID, value, oredict, craftingItem, 0xffffffff);
|
||||
}
|
||||
|
||||
public CustomMaterial(int materialID, int value, String oredict, ItemStack craftingItem, int color)
|
||||
{
|
||||
public CustomMaterial(int materialID, int value, String oredict, ItemStack craftingItem, int color) {
|
||||
this.materialID = materialID;
|
||||
this.value = value;
|
||||
this.input = null;
|
||||
@@ -49,17 +43,12 @@ public abstract class CustomMaterial
|
||||
/**
|
||||
* Wether an itemstack is a stack of this custom material or not.
|
||||
*/
|
||||
public boolean matches (ItemStack stack)
|
||||
{
|
||||
if (this.oredict != null)
|
||||
{
|
||||
public boolean matches(ItemStack stack) {
|
||||
if (this.oredict != null) {
|
||||
List<ItemStack> items = OreDictionary.getOres(oredict);
|
||||
for (ItemStack item : items)
|
||||
if (OreDictionary.itemMatches(item, stack, false))
|
||||
return true;
|
||||
for (ItemStack item : items) if (OreDictionary.itemMatches(item, stack, false)) return true;
|
||||
return false;
|
||||
}
|
||||
return stack.isItemEqual(input);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,71 +1,53 @@
|
||||
package tconstruct.library.tools;
|
||||
|
||||
import mantle.world.WorldHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.*;
|
||||
|
||||
/* Base class for harvest tools with each head having a different purpose */
|
||||
|
||||
public abstract class DualHarvestTool extends HarvestTool
|
||||
{
|
||||
public DualHarvestTool(int baseDamage)
|
||||
{
|
||||
public abstract class DualHarvestTool extends HarvestTool {
|
||||
public DualHarvestTool(int baseDamage) {
|
||||
super(baseDamage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel(ItemStack stack, String toolClass) {
|
||||
// well, we can only get the harvestlevel if we have an item to get it from!
|
||||
if(stack == null || !(stack.getItem() instanceof HarvestTool))
|
||||
return -1;
|
||||
if (stack == null || !(stack.getItem() instanceof HarvestTool)) return -1;
|
||||
// invalid query or wrong toolclass
|
||||
if(toolClass == null)
|
||||
return -1;
|
||||
if (toolClass == null) return -1;
|
||||
|
||||
if(!stack.hasTagCompound())
|
||||
return -1;
|
||||
if (!stack.hasTagCompound()) return -1;
|
||||
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
// broken tools suck.
|
||||
if (tags.getBoolean("Broken"))
|
||||
return -1;
|
||||
if (tags.getBoolean("Broken")) return -1;
|
||||
|
||||
if(this.getHarvestType().equals(toolClass))
|
||||
return tags.getInteger("HarvestLevel");
|
||||
else if(this.getSecondHarvestType().equals(toolClass))
|
||||
return tags.getInteger("HarvestLevel2");
|
||||
if (this.getHarvestType().equals(toolClass)) return tags.getInteger("HarvestLevel");
|
||||
else if (this.getSecondHarvestType().equals(toolClass)) return tags.getInteger("HarvestLevel2");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDigSpeed (ItemStack stack, Block block, int meta)
|
||||
{
|
||||
public float getDigSpeed(ItemStack stack, Block block, int meta) {
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.getBoolean("Broken"))
|
||||
return 0.1f;
|
||||
if (tags.getBoolean("Broken")) return 0.1f;
|
||||
|
||||
Material[] materials = getEffectiveMaterials();
|
||||
for (int i = 0; i < materials.length; i++)
|
||||
{
|
||||
if (materials[i] == block.getMaterial())
|
||||
{
|
||||
for (int i = 0; i < materials.length; i++) {
|
||||
if (materials[i] == block.getMaterial()) {
|
||||
if (block.getHarvestLevel(meta) <= tags.getInteger("HarvestLevel"))
|
||||
return AbilityHelper.calcDualToolSpeed(this, tags, false);
|
||||
return 0.1f;
|
||||
}
|
||||
}
|
||||
materials = getEffectiveSecondaryMaterials();
|
||||
for (int i = 0; i < materials.length; i++)
|
||||
{
|
||||
if (materials[i] == block.getMaterial())
|
||||
{
|
||||
for (int i = 0; i < materials.length; i++) {
|
||||
if (materials[i] == block.getMaterial()) {
|
||||
if (block.getHarvestLevel(meta) <= tags.getInteger("HarvestLevel2"))
|
||||
return AbilityHelper.calcDualToolSpeed(this, tags, true);
|
||||
return 0.1f;
|
||||
@@ -75,25 +57,20 @@ public abstract class DualHarvestTool extends HarvestTool
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEffective (Material material)
|
||||
{
|
||||
if (super.isEffective(material))
|
||||
return true;
|
||||
public boolean isEffective(Material material) {
|
||||
if (super.isEffective(material)) return true;
|
||||
|
||||
for (Material m : getEffectiveSecondaryMaterials())
|
||||
if (m == material)
|
||||
return true;
|
||||
for (Material m : getEffectiveSecondaryMaterials()) if (m == material) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTraits ()
|
||||
{
|
||||
return new String[] { "harvest", "dualharvest" };
|
||||
public String[] getTraits() {
|
||||
return new String[] {"harvest", "dualharvest"};
|
||||
}
|
||||
|
||||
protected abstract Material[] getEffectiveSecondaryMaterials ();
|
||||
protected abstract Material[] getEffectiveSecondaryMaterials();
|
||||
|
||||
protected abstract String getSecondHarvestType ();
|
||||
protected abstract String getSecondHarvestType();
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package tconstruct.library.tools;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -9,14 +11,10 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.DynamicToolPart;
|
||||
import tconstruct.library.util.TextureHelper;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DualMaterialToolPart extends DynamicToolPart {
|
||||
public IIcon defaultIcon2;
|
||||
public IIcon[] icons2;
|
||||
@@ -25,8 +23,7 @@ public class DualMaterialToolPart extends DynamicToolPart {
|
||||
super(textureType, name);
|
||||
}
|
||||
|
||||
public static ItemStack createDualMaterial(Item item, int mat1, int mat2)
|
||||
{
|
||||
public static ItemStack createDualMaterial(Item item, int mat1, int mat2) {
|
||||
ItemStack stack = new ItemStack(item, 1, mat1);
|
||||
NBTTagCompound tags = new NBTTagCompound();
|
||||
NBTTagCompound subtag = new NBTTagCompound();
|
||||
@@ -38,24 +35,20 @@ public class DualMaterialToolPart extends DynamicToolPart {
|
||||
return stack;
|
||||
}
|
||||
|
||||
public int getMaterialID2(ItemStack stack)
|
||||
{
|
||||
if(!stack.hasTagCompound())
|
||||
return -1;
|
||||
public int getMaterialID2(ItemStack stack) {
|
||||
if (!stack.hasTagCompound()) return -1;
|
||||
|
||||
int id = stack.getTagCompound().getCompoundTag("DualMat").getInteger("Material2");
|
||||
|
||||
if (TConstructRegistry.toolMaterials.keySet().contains(id))
|
||||
return id;
|
||||
if (TConstructRegistry.toolMaterials.keySet().contains(id)) return id;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems (Item item, CreativeTabs tab, List list)
|
||||
{
|
||||
public void getSubItems(Item item, CreativeTabs tab, List list) {
|
||||
// material id == metadata
|
||||
for(Integer matID : TConstructRegistry.toolMaterials.keySet())
|
||||
for (Integer matID : TConstructRegistry.toolMaterials.keySet())
|
||||
list.add(createDualMaterial(item, matID, TinkerTools.MaterialID.Iron));
|
||||
}
|
||||
|
||||
@@ -78,12 +71,12 @@ public class DualMaterialToolPart extends DynamicToolPart {
|
||||
this.icons2 = new IIcon[icons.length];
|
||||
|
||||
// register icon for each material that has one
|
||||
if(!PHConstruct.minimalTextures)
|
||||
for(Map.Entry<Integer, tconstruct.library.tools.ToolMaterial> entry : TConstructRegistry.toolMaterials.entrySet())
|
||||
{
|
||||
String tex = modTexPrefix + ":" + folder + entry.getValue().materialName.toLowerCase() + texture + "_2";
|
||||
if(TextureHelper.itemTextureExists(tex))
|
||||
this.icons2[entry.getKey()] = iconRegister.registerIcon(tex);
|
||||
if (!PHConstruct.minimalTextures)
|
||||
for (Map.Entry<Integer, tconstruct.library.tools.ToolMaterial> entry :
|
||||
TConstructRegistry.toolMaterials.entrySet()) {
|
||||
String tex = modTexPrefix + ":" + folder
|
||||
+ entry.getValue().materialName.toLowerCase() + texture + "_2";
|
||||
if (TextureHelper.itemTextureExists(tex)) this.icons2[entry.getKey()] = iconRegister.registerIcon(tex);
|
||||
}
|
||||
|
||||
this.defaultIcon2 = iconRegister.registerIcon(modTexPrefix + ":" + folder + texture + "_2");
|
||||
@@ -92,12 +85,10 @@ public class DualMaterialToolPart extends DynamicToolPart {
|
||||
@Override
|
||||
public IIcon getIconFromDamageForRenderPass(int meta, int pass) {
|
||||
// secondary item
|
||||
if(pass > 0) {
|
||||
if(meta > icons.length)
|
||||
return defaultIcon2;
|
||||
if (pass > 0) {
|
||||
if (meta > icons.length) return defaultIcon2;
|
||||
|
||||
if(icons2[meta] == null)
|
||||
return defaultIcon2;
|
||||
if (icons2[meta] == null) return defaultIcon2;
|
||||
|
||||
return icons2[meta];
|
||||
}
|
||||
@@ -106,13 +97,11 @@ public class DualMaterialToolPart extends DynamicToolPart {
|
||||
|
||||
@Override
|
||||
public int getColorFromItemStack(ItemStack stack, int renderpass) {
|
||||
if(renderpass > 0)
|
||||
{
|
||||
if (renderpass > 0) {
|
||||
int matId = getMaterialID2(stack);
|
||||
if(matId > icons2.length || matId < 0)
|
||||
return super.getColorFromItemStack(stack, renderpass);
|
||||
if (matId > icons2.length || matId < 0) return super.getColorFromItemStack(stack, renderpass);
|
||||
|
||||
if(icons[matId] == null)
|
||||
if (icons[matId] == null)
|
||||
return TConstructRegistry.getMaterial(matId).primaryColor();
|
||||
|
||||
return super.getColorFromItemStack(stack, renderpass);
|
||||
|
||||
@@ -2,28 +2,22 @@ package tconstruct.library.tools;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import mantle.items.abstracts.CraftingItem;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.util.IToolPart;
|
||||
import tconstruct.library.util.TextureHelper;
|
||||
import tconstruct.library.tools.CustomMaterial;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class DynamicToolPart extends CraftingItem implements IToolPart
|
||||
{
|
||||
public class DynamicToolPart extends CraftingItem implements IToolPart {
|
||||
public String partName;
|
||||
public String texture;
|
||||
public IIcon defaultIcon;
|
||||
@@ -31,23 +25,20 @@ public class DynamicToolPart extends CraftingItem implements IToolPart
|
||||
|
||||
private boolean hidden = false;
|
||||
|
||||
public DynamicToolPart(String texture, String name)
|
||||
{
|
||||
public DynamicToolPart(String texture, String name) {
|
||||
this(texture, name, (Class<? extends CustomMaterial>) null);
|
||||
}
|
||||
|
||||
public DynamicToolPart(String texture, String name, Class<? extends CustomMaterial> customMaterialClass)
|
||||
{
|
||||
public DynamicToolPart(String texture, String name, Class<? extends CustomMaterial> customMaterialClass) {
|
||||
this(texture, name, "tinker", customMaterialClass);
|
||||
}
|
||||
|
||||
public DynamicToolPart(String texture, String name, String domain)
|
||||
{
|
||||
public DynamicToolPart(String texture, String name, String domain) {
|
||||
this(texture, name, domain, (Class<? extends CustomMaterial>) null);
|
||||
}
|
||||
|
||||
public DynamicToolPart(String texture, String name, String domain, Class<? extends CustomMaterial> customMaterialClass)
|
||||
{
|
||||
public DynamicToolPart(
|
||||
String texture, String name, String domain, Class<? extends CustomMaterial> customMaterialClass) {
|
||||
super(null, null, "parts/", domain, TConstructRegistry.partTab);
|
||||
this.setUnlocalizedName("tconstruct." + name);
|
||||
this.partName = name;
|
||||
@@ -58,8 +49,7 @@ public class DynamicToolPart extends CraftingItem implements IToolPart
|
||||
/**
|
||||
* Doesn't add the item to creative tabs
|
||||
*/
|
||||
public DynamicToolPart hide()
|
||||
{
|
||||
public DynamicToolPart hide() {
|
||||
hidden = true;
|
||||
|
||||
return this;
|
||||
@@ -67,60 +57,49 @@ public class DynamicToolPart extends CraftingItem implements IToolPart
|
||||
|
||||
// item meta = material id
|
||||
@Override
|
||||
public int getMaterialID (ItemStack stack)
|
||||
{
|
||||
if (TConstructRegistry.toolMaterials.keySet().contains(stack.getItemDamage()))
|
||||
return stack.getItemDamage();
|
||||
public int getMaterialID(ItemStack stack) {
|
||||
if (TConstructRegistry.toolMaterials.keySet().contains(stack.getItemDamage())) return stack.getItemDamage();
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName (ItemStack stack)
|
||||
{
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
String material = "";
|
||||
String matName = "";
|
||||
if (customMaterialClass == null)
|
||||
{
|
||||
if (customMaterialClass == null) {
|
||||
tconstruct.library.tools.ToolMaterial toolmat = TConstructRegistry.getMaterial(getMaterialID(stack));
|
||||
if(toolmat == null)
|
||||
return super.getItemStackDisplayName(stack);
|
||||
if (toolmat == null) return super.getItemStackDisplayName(stack);
|
||||
|
||||
material = toolmat.localizationString.toLowerCase(Locale.ENGLISH).startsWith("material.") ? toolmat.localizationString.substring(9) : toolmat.localizationString; // :(
|
||||
material = toolmat.localizationString.toLowerCase(Locale.ENGLISH).startsWith("material.")
|
||||
? toolmat.localizationString.substring(9)
|
||||
: toolmat.localizationString; // :(
|
||||
matName = toolmat.prefixName();
|
||||
}
|
||||
else
|
||||
{
|
||||
CustomMaterial customMaterial = TConstructRegistry.getCustomMaterial(getMaterialID(stack), customMaterialClass);
|
||||
if (customMaterial == null)
|
||||
return super.getItemStackDisplayName(stack);
|
||||
} else {
|
||||
CustomMaterial customMaterial =
|
||||
TConstructRegistry.getCustomMaterial(getMaterialID(stack), customMaterialClass);
|
||||
if (customMaterial == null) return super.getItemStackDisplayName(stack);
|
||||
|
||||
material = "";
|
||||
if (customMaterial.input != null)
|
||||
{
|
||||
if (customMaterial.input != null) {
|
||||
material = customMaterial.input.getUnlocalizedName();
|
||||
int firstPeriodIndex = material.indexOf('.');
|
||||
if (firstPeriodIndex >= 0)
|
||||
material = material.substring(firstPeriodIndex+1);
|
||||
if (firstPeriodIndex >= 0) material = material.substring(firstPeriodIndex + 1);
|
||||
matName = customMaterial.input.getDisplayName();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
material = customMaterial.oredict;
|
||||
matName = customMaterial.oredict;
|
||||
}
|
||||
}
|
||||
|
||||
// custom name
|
||||
if (StatCollector.canTranslate("toolpart." + partName + "." + material))
|
||||
{
|
||||
if (StatCollector.canTranslate("toolpart." + partName + "." + material)) {
|
||||
return StatCollector.translateToLocal("toolpart." + partName + "." + material);
|
||||
}
|
||||
// general name
|
||||
else
|
||||
{
|
||||
else {
|
||||
// specific material name for materials?
|
||||
if(StatCollector.canTranslate("toolpart.material." + material))
|
||||
if (StatCollector.canTranslate("toolpart.material." + material))
|
||||
matName = StatCollector.translateToLocal("toolpart.material." + material);
|
||||
|
||||
return StatCollector.translateToLocal("toolpart." + partName).replaceAll("%%material", matName);
|
||||
@@ -130,57 +109,49 @@ public class DynamicToolPart extends CraftingItem implements IToolPart
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
int id = getMaterialID(stack);
|
||||
if(id == -1)
|
||||
return getUnlocalizedName();
|
||||
if (id == -1) return getUnlocalizedName();
|
||||
|
||||
String material = "unknown";
|
||||
if (customMaterialClass == null)
|
||||
{
|
||||
if (customMaterialClass == null) {
|
||||
tconstruct.library.tools.ToolMaterial toolmat = TConstructRegistry.getMaterial(getMaterialID(stack));
|
||||
material = toolmat.materialName;
|
||||
}
|
||||
else
|
||||
{
|
||||
CustomMaterial customMaterial = TConstructRegistry.getCustomMaterial(getMaterialID(stack), customMaterialClass);
|
||||
material = customMaterial.input != null ? customMaterial.input.getUnlocalizedName() : customMaterial.oredict;
|
||||
} else {
|
||||
CustomMaterial customMaterial =
|
||||
TConstructRegistry.getCustomMaterial(getMaterialID(stack), customMaterialClass);
|
||||
material =
|
||||
customMaterial.input != null ? customMaterial.input.getUnlocalizedName() : customMaterial.oredict;
|
||||
}
|
||||
|
||||
return "toolpart." + partName + "." + material;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems (Item item, CreativeTabs tab, List list)
|
||||
{
|
||||
if(hidden)
|
||||
return;
|
||||
public void getSubItems(Item item, CreativeTabs tab, List list) {
|
||||
if (hidden) return;
|
||||
|
||||
// material id == metadata
|
||||
for(Integer matID : TConstructRegistry.defaultToolPartMaterials) {
|
||||
for (Integer matID : TConstructRegistry.defaultToolPartMaterials) {
|
||||
ItemStack stack = new ItemStack(item, 1, matID);
|
||||
if (this.getMaterialID(stack) != -1)
|
||||
list.add(stack);
|
||||
if (this.getMaterialID(stack) != -1) list.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IIconRegister iconRegister)
|
||||
{
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
// get the biggest material index
|
||||
int max = -1;
|
||||
for(Integer id : TConstructRegistry.toolMaterials.keySet())
|
||||
if(id > max)
|
||||
max = id;
|
||||
for (Integer id : TConstructRegistry.toolMaterials.keySet()) if (id > max) max = id;
|
||||
|
||||
this.icons = new IIcon[max+1];
|
||||
this.icons = new IIcon[max + 1];
|
||||
|
||||
// register icon for each material that has one
|
||||
if(!PHConstruct.minimalTextures)
|
||||
for(Map.Entry<Integer, tconstruct.library.tools.ToolMaterial> entry : TConstructRegistry.toolMaterials.entrySet())
|
||||
{
|
||||
String tex = modTexPrefix + ":" + folder + entry.getValue().materialName.toLowerCase() + texture;
|
||||
if(TextureHelper.itemTextureExists(tex))
|
||||
this.icons[entry.getKey()] = iconRegister.registerIcon(tex);
|
||||
if (!PHConstruct.minimalTextures)
|
||||
for (Map.Entry<Integer, tconstruct.library.tools.ToolMaterial> entry :
|
||||
TConstructRegistry.toolMaterials.entrySet()) {
|
||||
String tex = modTexPrefix + ":" + folder
|
||||
+ entry.getValue().materialName.toLowerCase() + texture;
|
||||
if (TextureHelper.itemTextureExists(tex)) this.icons[entry.getKey()] = iconRegister.registerIcon(tex);
|
||||
}
|
||||
|
||||
// default texture
|
||||
@@ -188,13 +159,10 @@ public class DynamicToolPart extends CraftingItem implements IToolPart
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage (int meta)
|
||||
{
|
||||
if(meta > icons.length)
|
||||
return defaultIcon;
|
||||
public IIcon getIconFromDamage(int meta) {
|
||||
if (meta > icons.length) return defaultIcon;
|
||||
|
||||
if(icons[meta] == null)
|
||||
return defaultIcon;
|
||||
if (icons[meta] == null) return defaultIcon;
|
||||
|
||||
return icons[meta];
|
||||
}
|
||||
@@ -202,15 +170,12 @@ public class DynamicToolPart extends CraftingItem implements IToolPart
|
||||
@Override
|
||||
public int getColorFromItemStack(ItemStack stack, int renderpass) {
|
||||
int matId = getMaterialID(stack);
|
||||
if(matId > icons.length)
|
||||
return super.getColorFromItemStack(stack, renderpass);
|
||||
if (matId > icons.length) return super.getColorFromItemStack(stack, renderpass);
|
||||
|
||||
if(matId >= 0 && icons[matId] == null)
|
||||
{
|
||||
if (matId >= 0 && icons[matId] == null) {
|
||||
if (customMaterialClass == null)
|
||||
return TConstructRegistry.getMaterial(getMaterialID(stack)).primaryColor();
|
||||
else
|
||||
return TConstructRegistry.getCustomMaterial(getMaterialID(stack), customMaterialClass).color;
|
||||
else return TConstructRegistry.getCustomMaterial(getMaterialID(stack), customMaterialClass).color;
|
||||
}
|
||||
|
||||
return super.getColorFromItemStack(stack, renderpass);
|
||||
|
||||
@@ -2,14 +2,20 @@ package tconstruct.library.tools;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class FletchingMaterial extends CustomMaterial
|
||||
{
|
||||
public class FletchingMaterial extends CustomMaterial {
|
||||
public final float accuracy;
|
||||
public final float breakChance;
|
||||
public final float durabilityModifier;
|
||||
|
||||
public FletchingMaterial(int materialID, int value, ItemStack input, ItemStack craftingItem, float accuracy, float breakChance, float duribalityModifier, int color)
|
||||
{
|
||||
public FletchingMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
ItemStack input,
|
||||
ItemStack craftingItem,
|
||||
float accuracy,
|
||||
float breakChance,
|
||||
float duribalityModifier,
|
||||
int color) {
|
||||
super(materialID, value, input, craftingItem, color);
|
||||
this.accuracy = accuracy;
|
||||
this.breakChance = breakChance;
|
||||
@@ -17,13 +23,26 @@ public class FletchingMaterial extends CustomMaterial
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public FletchingMaterial(int materialID, int value, ItemStack input, ItemStack craftingItem, float accuracy, float breakChance, float mass)
|
||||
{
|
||||
public FletchingMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
ItemStack input,
|
||||
ItemStack craftingItem,
|
||||
float accuracy,
|
||||
float breakChance,
|
||||
float mass) {
|
||||
this(materialID, value, input, craftingItem, accuracy, 0.01f, 1f, 0xffffffff);
|
||||
}
|
||||
|
||||
public FletchingMaterial(int materialID, int value, String oredict, ItemStack craftingItem, float accuracy, float breakChance, float duribalityModifier, int color)
|
||||
{
|
||||
public FletchingMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
String oredict,
|
||||
ItemStack craftingItem,
|
||||
float accuracy,
|
||||
float breakChance,
|
||||
float duribalityModifier,
|
||||
int color) {
|
||||
super(materialID, value, oredict, craftingItem, color);
|
||||
this.accuracy = accuracy;
|
||||
this.breakChance = breakChance;
|
||||
@@ -31,8 +50,14 @@ public class FletchingMaterial extends CustomMaterial
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public FletchingMaterial(int materialID, int value, String oredict, ItemStack craftingItem, float accuracy, float breakChance, float mass)
|
||||
{
|
||||
public FletchingMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
String oredict,
|
||||
ItemStack craftingItem,
|
||||
float accuracy,
|
||||
float breakChance,
|
||||
float mass) {
|
||||
this(materialID, value, oredict, craftingItem, accuracy, 0.01f, 1f, 0xffffffff);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,31 +4,30 @@ import mantle.blocks.BlockUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class FletchlingLeafMaterial extends FletchingMaterial
|
||||
{
|
||||
public FletchlingLeafMaterial(int materialID, int value, String oredict, ItemStack craftingItem, float accuracy, float breakChance, float durabilityModifier)
|
||||
{
|
||||
public class FletchlingLeafMaterial extends FletchingMaterial {
|
||||
public FletchlingLeafMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
String oredict,
|
||||
ItemStack craftingItem,
|
||||
float accuracy,
|
||||
float breakChance,
|
||||
float durabilityModifier) {
|
||||
super(materialID, value, oredict, craftingItem, accuracy, breakChance, durabilityModifier, 0x5ece46);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches (ItemStack stack)
|
||||
{
|
||||
if (matchesLeaves(stack))
|
||||
return true;
|
||||
public boolean matches(ItemStack stack) {
|
||||
if (matchesLeaves(stack)) return true;
|
||||
|
||||
return super.matches(stack);
|
||||
}
|
||||
|
||||
public static boolean matchesLeaves (ItemStack stack)
|
||||
{
|
||||
if (stack != null)
|
||||
{
|
||||
public static boolean matchesLeaves(ItemStack stack) {
|
||||
if (stack != null) {
|
||||
Block block = BlockUtils.getBlockFromItemStack(stack);
|
||||
if (block != null)
|
||||
{
|
||||
if (block.isLeaves(null, 0, 0, 0))
|
||||
return true;
|
||||
if (block != null) {
|
||||
if (block.isLeaves(null, 0, 0, 0)) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -1,177 +1,150 @@
|
||||
package tconstruct.library.tools;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.material.MaterialLogic;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.client.C07PacketPlayerDigging;
|
||||
import net.minecraft.network.play.server.S23PacketBlockChange;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/* Base class for tools that should be harvesting blocks */
|
||||
|
||||
public abstract class HarvestTool extends ToolCore
|
||||
{
|
||||
public HarvestTool(int baseDamage)
|
||||
{
|
||||
public abstract class HarvestTool extends ToolCore {
|
||||
public HarvestTool(int baseDamage) {
|
||||
super(baseDamage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
|
||||
return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel(ItemStack stack, String toolClass) {
|
||||
// well, we can only get the harvestlevel if we have an item to get it from!
|
||||
if(stack == null || !(stack.getItem() instanceof HarvestTool))
|
||||
return -1;
|
||||
if (stack == null || !(stack.getItem() instanceof HarvestTool)) return -1;
|
||||
// invalid query or wrong toolclass
|
||||
if(toolClass == null || !this.getHarvestType().equals(toolClass))
|
||||
return -1;
|
||||
if (toolClass == null || !this.getHarvestType().equals(toolClass)) return -1;
|
||||
|
||||
if(!stack.hasTagCompound())
|
||||
return -1;
|
||||
if (!stack.hasTagCompound()) return -1;
|
||||
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
// broken tools suck.
|
||||
if (tags.getBoolean("Broken"))
|
||||
return 0;
|
||||
if (tags.getBoolean("Broken")) return 0;
|
||||
|
||||
// tadaaaa
|
||||
return tags.getInteger("HarvestLevel");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public float getDigSpeed (ItemStack stack, Block block, int meta)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
return 1.0f;
|
||||
public float getDigSpeed(ItemStack stack, Block block, int meta) {
|
||||
if (!stack.hasTagCompound()) return 1.0f;
|
||||
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.getBoolean("Broken"))
|
||||
return 0.1f;
|
||||
if (tags.getBoolean("Broken")) return 0.1f;
|
||||
|
||||
if(isEffective(block, meta))
|
||||
return calculateStrength(tags, block, meta);
|
||||
if (isEffective(block, meta)) return calculateStrength(tags, block, meta);
|
||||
|
||||
return super.getDigSpeed(stack, block, meta);
|
||||
}
|
||||
|
||||
public float calculateStrength (NBTTagCompound tags, Block block, int meta)
|
||||
{
|
||||
public float calculateStrength(NBTTagCompound tags, Block block, int meta) {
|
||||
|
||||
int hlvl = block.getHarvestLevel(meta);
|
||||
if (hlvl > tags.getInteger("HarvestLevel"))
|
||||
return 0.1f;
|
||||
if (hlvl > tags.getInteger("HarvestLevel")) return 0.1f;
|
||||
|
||||
return AbilityHelper.calcToolSpeed(this, tags);
|
||||
}
|
||||
|
||||
public float breakSpeedModifier ()
|
||||
{
|
||||
public float breakSpeedModifier() {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public float stoneboundModifier ()
|
||||
{
|
||||
public float stoneboundModifier() {
|
||||
return 72f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean func_150897_b (Block block)
|
||||
{
|
||||
public boolean func_150897_b(Block block) {
|
||||
return isEffective(block.getMaterial());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTraits ()
|
||||
{
|
||||
return new String[] { "harvest" };
|
||||
public String[] getTraits() {
|
||||
return new String[] {"harvest"};
|
||||
}
|
||||
|
||||
protected abstract Material[] getEffectiveMaterials ();
|
||||
protected abstract Material[] getEffectiveMaterials();
|
||||
|
||||
protected abstract String getHarvestType ();
|
||||
protected abstract String getHarvestType();
|
||||
|
||||
@Override
|
||||
public Set<String> getToolClasses(ItemStack stack) {
|
||||
Set<String> set = new HashSet<String>();
|
||||
|
||||
if(stack != null && stack.getItem() instanceof HarvestTool) {
|
||||
if (stack != null && stack.getItem() instanceof HarvestTool) {
|
||||
set.add(((HarvestTool) stack.getItem()).getHarvestType());
|
||||
}
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
public boolean isEffective (Block block, int meta)
|
||||
{
|
||||
if(this.getHarvestType().equals(block.getHarvestTool(meta)))
|
||||
return true;
|
||||
|
||||
public boolean isEffective(Block block, int meta) {
|
||||
if (this.getHarvestType().equals(block.getHarvestTool(meta))) return true;
|
||||
else return isEffective(block.getMaterial());
|
||||
}
|
||||
|
||||
public boolean isEffective (Material material)
|
||||
{
|
||||
for (Material m : getEffectiveMaterials())
|
||||
if (m == material)
|
||||
return true;
|
||||
public boolean isEffective(Material material) {
|
||||
for (Material m : getEffectiveMaterials()) if (m == material) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//Right-click
|
||||
// Right-click
|
||||
@Override
|
||||
public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ)
|
||||
{
|
||||
public boolean onItemUse(
|
||||
ItemStack stack,
|
||||
EntityPlayer player,
|
||||
World world,
|
||||
int x,
|
||||
int y,
|
||||
int z,
|
||||
int side,
|
||||
float clickX,
|
||||
float clickY,
|
||||
float clickZ) {
|
||||
/*if (world.isRemote)
|
||||
return true;*/
|
||||
return true;*/
|
||||
|
||||
boolean used = false;
|
||||
int hotbarSlot = player.inventory.currentItem;
|
||||
int itemSlot = hotbarSlot == 0 ? 8 : hotbarSlot + 1;
|
||||
ItemStack nearbyStack = null;
|
||||
|
||||
if (hotbarSlot < 8)
|
||||
{
|
||||
if (hotbarSlot < 8) {
|
||||
nearbyStack = player.inventory.getStackInSlot(itemSlot);
|
||||
if (nearbyStack != null)
|
||||
{
|
||||
if (nearbyStack != null) {
|
||||
Item item = nearbyStack.getItem();
|
||||
|
||||
if (item instanceof ItemBlock || (item != null && item == TinkerTools.openBlocksDevNull))
|
||||
{
|
||||
|
||||
if (item instanceof ItemBlock || (item != null && item == TinkerTools.openBlocksDevNull)) {
|
||||
int posX = x;
|
||||
int posY = y;
|
||||
int posZ = z;
|
||||
|
||||
switch (side)
|
||||
{
|
||||
switch (side) {
|
||||
case 0:
|
||||
--posY;
|
||||
break;
|
||||
@@ -192,40 +165,34 @@ public abstract class HarvestTool extends ToolCore
|
||||
break;
|
||||
}
|
||||
|
||||
AxisAlignedBB blockBounds = AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX + 1, posY + 1, posZ + 1);
|
||||
AxisAlignedBB blockBounds =
|
||||
AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX + 1, posY + 1, posZ + 1);
|
||||
AxisAlignedBB playerBounds = player.boundingBox;
|
||||
|
||||
if(item instanceof ItemBlock)
|
||||
{
|
||||
if (item instanceof ItemBlock) {
|
||||
Block blockToPlace = ((ItemBlock) item).field_150939_a;
|
||||
if(blockToPlace.getMaterial().blocksMovement())
|
||||
{
|
||||
if (playerBounds.intersectsWith(blockBounds))
|
||||
return false;
|
||||
if (blockToPlace.getMaterial().blocksMovement()) {
|
||||
if (playerBounds.intersectsWith(blockBounds)) return false;
|
||||
}
|
||||
}
|
||||
|
||||
int dmg = nearbyStack.getItemDamage();
|
||||
int count = nearbyStack.stackSize;
|
||||
if (item == TinkerTools.openBlocksDevNull)
|
||||
{
|
||||
//Openblocks uses current inventory slot, so we have to do this...
|
||||
player.inventory.currentItem=itemSlot;
|
||||
item.onItemUse(nearbyStack, player, world, x, y, z, side, clickX, clickY, clickZ);
|
||||
player.inventory.currentItem=hotbarSlot;
|
||||
player.swingItem();
|
||||
}
|
||||
else
|
||||
used = item.onItemUse(nearbyStack, player, world, x, y, z, side, clickX, clickY, clickZ);
|
||||
if (item == TinkerTools.openBlocksDevNull) {
|
||||
// Openblocks uses current inventory slot, so we have to do this...
|
||||
player.inventory.currentItem = itemSlot;
|
||||
item.onItemUse(nearbyStack, player, world, x, y, z, side, clickX, clickY, clickZ);
|
||||
player.inventory.currentItem = hotbarSlot;
|
||||
player.swingItem();
|
||||
} else used = item.onItemUse(nearbyStack, player, world, x, y, z, side, clickX, clickY, clickZ);
|
||||
|
||||
// handle creative mode
|
||||
if(player.capabilities.isCreativeMode) {
|
||||
if (player.capabilities.isCreativeMode) {
|
||||
// fun fact: vanilla minecraft does it exactly the same way
|
||||
nearbyStack.setItemDamage(dmg);
|
||||
nearbyStack.stackSize = count;
|
||||
}
|
||||
if (nearbyStack.stackSize < 1)
|
||||
{
|
||||
if (nearbyStack.stackSize < 1) {
|
||||
nearbyStack = null;
|
||||
player.inventory.setInventorySlotContents(itemSlot, null);
|
||||
}
|
||||
@@ -234,24 +201,23 @@ public abstract class HarvestTool extends ToolCore
|
||||
}
|
||||
|
||||
/*
|
||||
if (used) //Update client
|
||||
{
|
||||
Packet103SetSlot packet = new Packet103SetSlot(player.openContainer.windowId, itemSlot, nearbyStack);
|
||||
((EntityPlayerMP)player).playerNetServerHandler.sendPacketToPlayer(packet);
|
||||
}
|
||||
*/
|
||||
if (used) //Update client
|
||||
{
|
||||
Packet103SetSlot packet = new Packet103SetSlot(player.openContainer.windowId, itemSlot, nearbyStack);
|
||||
((EntityPlayerMP)player).playerNetServerHandler.sendPacketToPlayer(packet);
|
||||
}
|
||||
*/
|
||||
|
||||
return used;
|
||||
}
|
||||
|
||||
public void breakExtraBlock(World world, int x, int y, int z, int sidehit, EntityPlayer playerEntity, int refX, int refY, int refZ) {
|
||||
public void breakExtraBlock(
|
||||
World world, int x, int y, int z, int sidehit, EntityPlayer playerEntity, int refX, int refY, int refZ) {
|
||||
// prevent calling that stuff for air blocks, could lead to unexpected behaviour since it fires events
|
||||
if (world.isAirBlock(x, y, z))
|
||||
return;
|
||||
if (world.isAirBlock(x, y, z)) return;
|
||||
|
||||
// what?
|
||||
if(!(playerEntity instanceof EntityPlayerMP))
|
||||
return;
|
||||
if (!(playerEntity instanceof EntityPlayerMP)) return;
|
||||
EntityPlayerMP player = (EntityPlayerMP) playerEntity;
|
||||
|
||||
// check if the block can be broken, since extra block breaks shouldn't instantly break stuff like obsidian
|
||||
@@ -260,21 +226,19 @@ public abstract class HarvestTool extends ToolCore
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
// only effective materials
|
||||
if (!isEffective(block, meta))
|
||||
return;
|
||||
if (!isEffective(block, meta)) return;
|
||||
|
||||
Block refBlock = world.getBlock(refX, refY, refZ);
|
||||
float refStrength = ForgeHooks.blockStrength(refBlock, player, world, refX, refY, refZ);
|
||||
float strength = ForgeHooks.blockStrength(block, player, world, x,y,z);
|
||||
float strength = ForgeHooks.blockStrength(block, player, world, x, y, z);
|
||||
|
||||
// only harvestable blocks that aren't impossibly slow to harvest
|
||||
if (!ForgeHooks.canHarvestBlock(block, player, meta) || refStrength/strength > 10f)
|
||||
return;
|
||||
if (!ForgeHooks.canHarvestBlock(block, player, meta) || refStrength / strength > 10f) return;
|
||||
|
||||
// send the blockbreak event
|
||||
BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(world, player.theItemInWorldManager.getGameType(), player, x,y,z);
|
||||
if(event.isCanceled())
|
||||
return;
|
||||
BlockEvent.BreakEvent event =
|
||||
ForgeHooks.onBlockBreakEvent(world, player.theItemInWorldManager.getGameType(), player, x, y, z);
|
||||
if (event.isCanceled()) return;
|
||||
|
||||
if (player.capabilities.isCreativeMode) {
|
||||
block.onBlockHarvested(world, x, y, z, meta, player);
|
||||
@@ -290,7 +254,7 @@ public abstract class HarvestTool extends ToolCore
|
||||
|
||||
// callback to the tool the player uses. Called on both sides. This damages the tool n stuff.
|
||||
ItemStack currentItem = player.getCurrentEquippedItem();
|
||||
if(currentItem != null) {
|
||||
if (currentItem != null) {
|
||||
currentItem.func_150999_a(world, block, x, y, z, player);
|
||||
}
|
||||
|
||||
@@ -299,13 +263,14 @@ public abstract class HarvestTool extends ToolCore
|
||||
// serverside we reproduce ItemInWorldManager.tryHarvestBlock
|
||||
|
||||
// ItemInWorldManager.removeBlock
|
||||
block.onBlockHarvested(world, x,y,z, meta, player);
|
||||
block.onBlockHarvested(world, x, y, z, meta, player);
|
||||
|
||||
if(block.removedByPlayer(world, player, x,y,z, true)) // boolean is if block can be harvested, checked above
|
||||
if (block.removedByPlayer(
|
||||
world, player, x, y, z, true)) // boolean is if block can be harvested, checked above
|
||||
{
|
||||
block.onBlockDestroyedByPlayer( world, x,y,z, meta);
|
||||
block.harvestBlock(world, player, x,y,z, meta);
|
||||
block.dropXpOnBlockBreak(world, x,y,z, event.getExpToDrop());
|
||||
block.onBlockDestroyedByPlayer(world, x, y, z, meta);
|
||||
block.harvestBlock(world, player, x, y, z, meta);
|
||||
block.dropXpOnBlockBreak(world, x, y, z, event.getExpToDrop());
|
||||
}
|
||||
|
||||
// always send block update to client
|
||||
@@ -313,31 +278,33 @@ public abstract class HarvestTool extends ToolCore
|
||||
}
|
||||
// client sided handling
|
||||
else {
|
||||
//PlayerControllerMP pcmp = Minecraft.getMinecraft().playerController;
|
||||
// clientside we do a "this clock has been clicked on long enough to be broken" call. This should not send any new packets
|
||||
// the code above, executed on the server, sends a block-updates that give us the correct state of the block we destroy.
|
||||
// PlayerControllerMP pcmp = Minecraft.getMinecraft().playerController;
|
||||
// clientside we do a "this clock has been clicked on long enough to be broken" call. This should not send
|
||||
// any new packets
|
||||
// the code above, executed on the server, sends a block-updates that give us the correct state of the block
|
||||
// we destroy.
|
||||
|
||||
// following code can be found in PlayerControllerMP.onPlayerDestroyBlock
|
||||
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
|
||||
if(block.removedByPlayer(world, player, x,y,z, true))
|
||||
{
|
||||
block.onBlockDestroyedByPlayer(world, x,y,z, meta);
|
||||
if (block.removedByPlayer(world, player, x, y, z, true)) {
|
||||
block.onBlockDestroyedByPlayer(world, x, y, z, meta);
|
||||
}
|
||||
// callback to the tool
|
||||
ItemStack itemstack = player.getCurrentEquippedItem();
|
||||
if (itemstack != null)
|
||||
{
|
||||
if (itemstack != null) {
|
||||
itemstack.func_150999_a(world, block, x, y, z, player);
|
||||
|
||||
if (itemstack.stackSize == 0)
|
||||
{
|
||||
if (itemstack.stackSize == 0) {
|
||||
player.destroyCurrentEquippedItem();
|
||||
}
|
||||
}
|
||||
|
||||
// send an update to the server, so we get an update back
|
||||
if(PHConstruct.extraBlockUpdates)
|
||||
Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C07PacketPlayerDigging(2, x,y,z, Minecraft.getMinecraft().objectMouseOver.sideHit));
|
||||
if (PHConstruct.extraBlockUpdates)
|
||||
Minecraft.getMinecraft()
|
||||
.getNetHandler()
|
||||
.addToSendQueue(new C07PacketPlayerDigging(
|
||||
2, x, y, z, Minecraft.getMinecraft().objectMouseOver.sideHit));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -5,8 +5,7 @@ import net.minecraft.util.StatCollector;
|
||||
/*
|
||||
* Dynamic substitute for an enum. It carries a lot of information
|
||||
*/
|
||||
public class ToolMaterial
|
||||
{
|
||||
public class ToolMaterial {
|
||||
public final String materialName;
|
||||
public final int harvestLevel;
|
||||
public final int durability;
|
||||
@@ -22,34 +21,92 @@ public class ToolMaterial
|
||||
|
||||
@Deprecated
|
||||
public String displayName;
|
||||
|
||||
@Deprecated
|
||||
public String ability;
|
||||
|
||||
@Deprecated
|
||||
public ToolMaterial(String name, String displayName, int level, int durability, int speed, int damage, float handle, int reinforced, float stonebound, String style, String ability)
|
||||
{
|
||||
public ToolMaterial(
|
||||
String name,
|
||||
String displayName,
|
||||
int level,
|
||||
int durability,
|
||||
int speed,
|
||||
int damage,
|
||||
float handle,
|
||||
int reinforced,
|
||||
float stonebound,
|
||||
String style,
|
||||
String ability) {
|
||||
this(name, level, durability, speed, damage, handle, reinforced, stonebound, style, 0xFFFFFF);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ToolMaterial(String name, int level, int durability, int speed, int damage, float handle, int reinforced, float stonebound, String style, String ability)
|
||||
{
|
||||
public ToolMaterial(
|
||||
String name,
|
||||
int level,
|
||||
int durability,
|
||||
int speed,
|
||||
int damage,
|
||||
float handle,
|
||||
int reinforced,
|
||||
float stonebound,
|
||||
String style,
|
||||
String ability) {
|
||||
this(name, level, durability, speed, damage, handle, reinforced, stonebound, style, 0xFFFFFF);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ToolMaterial(String name, int level, int durability, int speed, int damage, float handle, int reinforced, float stonebound, String style)
|
||||
{
|
||||
public ToolMaterial(
|
||||
String name,
|
||||
int level,
|
||||
int durability,
|
||||
int speed,
|
||||
int damage,
|
||||
float handle,
|
||||
int reinforced,
|
||||
float stonebound,
|
||||
String style) {
|
||||
this(name, level, durability, speed, damage, handle, reinforced, stonebound, style, 0xFFFFFF);
|
||||
}
|
||||
|
||||
public ToolMaterial(String name, int level, int durability, int speed, int damage, float handle, int reinforced, float stonebound, String style, int primaryColor)
|
||||
{
|
||||
this(name, "material." + name.toLowerCase().replaceAll(" ", ""), level, durability, speed, damage, handle, reinforced, stonebound, style, primaryColor);
|
||||
public ToolMaterial(
|
||||
String name,
|
||||
int level,
|
||||
int durability,
|
||||
int speed,
|
||||
int damage,
|
||||
float handle,
|
||||
int reinforced,
|
||||
float stonebound,
|
||||
String style,
|
||||
int primaryColor) {
|
||||
this(
|
||||
name,
|
||||
"material." + name.toLowerCase().replaceAll(" ", ""),
|
||||
level,
|
||||
durability,
|
||||
speed,
|
||||
damage,
|
||||
handle,
|
||||
reinforced,
|
||||
stonebound,
|
||||
style,
|
||||
primaryColor);
|
||||
}
|
||||
|
||||
public ToolMaterial(String name, String localizationString, int level, int durability, int speed, int damage, float handle, int reinforced, float stonebound, String style, int primaryColor)
|
||||
{
|
||||
public ToolMaterial(
|
||||
String name,
|
||||
String localizationString,
|
||||
int level,
|
||||
int durability,
|
||||
int speed,
|
||||
int damage,
|
||||
float handle,
|
||||
int reinforced,
|
||||
float stonebound,
|
||||
String style,
|
||||
int primaryColor) {
|
||||
this.materialName = name;
|
||||
this.harvestLevel = level;
|
||||
this.durability = durability;
|
||||
@@ -67,66 +124,54 @@ public class ToolMaterial
|
||||
this.ability = ability();
|
||||
}
|
||||
|
||||
public String name ()
|
||||
{
|
||||
public String name() {
|
||||
return materialName;
|
||||
}
|
||||
|
||||
public String localizedName ()
|
||||
{
|
||||
public String localizedName() {
|
||||
return StatCollector.translateToLocal(localizationString);
|
||||
}
|
||||
|
||||
public String prefixName ()
|
||||
{
|
||||
public String prefixName() {
|
||||
// check if there's a special name, otherwise use the regular one
|
||||
if (StatCollector.canTranslate(String.format("%s.display", localizationString)))
|
||||
return StatCollector.translateToLocal(String.format("%s.display", localizationString));
|
||||
return localizedName();
|
||||
}
|
||||
|
||||
public int durability ()
|
||||
{
|
||||
public int durability() {
|
||||
return this.durability;
|
||||
}
|
||||
|
||||
public int toolSpeed ()
|
||||
{
|
||||
public int toolSpeed() {
|
||||
return this.miningspeed;
|
||||
}
|
||||
|
||||
public int attack ()
|
||||
{
|
||||
public int attack() {
|
||||
return this.attack;
|
||||
}
|
||||
|
||||
public int harvestLevel ()
|
||||
{
|
||||
public int harvestLevel() {
|
||||
return this.harvestLevel;
|
||||
}
|
||||
|
||||
public float handleDurability ()
|
||||
{
|
||||
public float handleDurability() {
|
||||
return this.handleModifier;
|
||||
}
|
||||
|
||||
public int reinforced ()
|
||||
{
|
||||
public int reinforced() {
|
||||
return this.reinforced;
|
||||
}
|
||||
|
||||
public float shoddy ()
|
||||
{
|
||||
public float shoddy() {
|
||||
return this.stonebound;
|
||||
}
|
||||
|
||||
public String style ()
|
||||
{
|
||||
public String style() {
|
||||
return this.tipStyle;
|
||||
}
|
||||
|
||||
public int primaryColor ()
|
||||
{
|
||||
public int primaryColor() {
|
||||
return this.primaryColor;
|
||||
}
|
||||
|
||||
@@ -134,8 +179,7 @@ public class ToolMaterial
|
||||
* Returns the ability of the tool to display.
|
||||
* ONLY USE THIS FOR DISPLAY PURPOSES. It is not data you can rely on. Use the material-ids for that.
|
||||
*/
|
||||
public String ability ()
|
||||
{
|
||||
public String ability() {
|
||||
if (StatCollector.canTranslate(String.format("%s.ability", localizationString)))
|
||||
return StatCollector.translateToLocal(String.format("%s.ability", localizationString));
|
||||
return "";
|
||||
|
||||
@@ -19,37 +19,29 @@ import tconstruct.tools.TinkerTools;
|
||||
@Optional.Interface(modid = "ZeldaItemAPI", iface = "zeldaswordskills.api.item.ISword"),
|
||||
@Optional.Interface(modid = "DynamicSkillsAPI", iface = "dynamicswordskills.api.ISword")
|
||||
})
|
||||
public abstract class Weapon extends ToolCore implements IBattlegearWeapon, zeldaswordskills.api.item.ISword, dynamicswordskills.api.ISword
|
||||
{
|
||||
public abstract class Weapon extends ToolCore
|
||||
implements IBattlegearWeapon, zeldaswordskills.api.item.ISword, dynamicswordskills.api.ISword {
|
||||
|
||||
public Weapon(int baseDamage)
|
||||
{
|
||||
public Weapon(int baseDamage) {
|
||||
super(baseDamage);
|
||||
}
|
||||
|
||||
protected float baseSpeed ()
|
||||
{
|
||||
protected float baseSpeed() {
|
||||
return 1.5f;
|
||||
}
|
||||
|
||||
protected float effectiveSpeed ()
|
||||
{
|
||||
protected float effectiveSpeed() {
|
||||
return 15f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDigSpeed (ItemStack stack, Block block, int meta)
|
||||
{
|
||||
if(!stack.hasTagCompound())
|
||||
return 0f;
|
||||
|
||||
if (stack.getTagCompound().getCompoundTag("InfiTool").getBoolean("Broken"))
|
||||
return 0.1f;
|
||||
public float getDigSpeed(ItemStack stack, Block block, int meta) {
|
||||
if (!stack.hasTagCompound()) return 0f;
|
||||
|
||||
for (int i = 0; i < web.length; i++)
|
||||
{
|
||||
if (web[i] == block.getMaterial())
|
||||
{
|
||||
if (stack.getTagCompound().getCompoundTag("InfiTool").getBoolean("Broken")) return 0.1f;
|
||||
|
||||
for (int i = 0; i < web.length; i++) {
|
||||
if (web[i] == block.getMaterial()) {
|
||||
return effectiveSpeed();
|
||||
}
|
||||
}
|
||||
@@ -61,8 +53,7 @@ public abstract class Weapon extends ToolCore implements IBattlegearWeapon, zeld
|
||||
* is being used
|
||||
*/
|
||||
@Override
|
||||
public EnumAction getItemUseAction (ItemStack par1ItemStack)
|
||||
{
|
||||
public EnumAction getItemUseAction(ItemStack par1ItemStack) {
|
||||
return EnumAction.block;
|
||||
}
|
||||
|
||||
@@ -70,8 +61,7 @@ public abstract class Weapon extends ToolCore implements IBattlegearWeapon, zeld
|
||||
* How long it takes to use or consume an item
|
||||
*/
|
||||
@Override
|
||||
public int getMaxItemUseDuration (ItemStack par1ItemStack)
|
||||
{
|
||||
public int getMaxItemUseDuration(ItemStack par1ItemStack) {
|
||||
return 72000;
|
||||
}
|
||||
|
||||
@@ -80,15 +70,23 @@ public abstract class Weapon extends ToolCore implements IBattlegearWeapon, zeld
|
||||
* pressed. Args: itemStack, world, entityPlayer
|
||||
*/
|
||||
@Override
|
||||
public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ)
|
||||
{
|
||||
public boolean onItemUse(
|
||||
ItemStack stack,
|
||||
EntityPlayer player,
|
||||
World world,
|
||||
int x,
|
||||
int y,
|
||||
int z,
|
||||
int side,
|
||||
float clickX,
|
||||
float clickY,
|
||||
float clickZ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -96,32 +94,25 @@ public abstract class Weapon extends ToolCore implements IBattlegearWeapon, zeld
|
||||
* Returns if the item (tool) can harvest results from the block type.
|
||||
*/
|
||||
@Override
|
||||
public boolean canHarvestBlock (Block block, ItemStack is)
|
||||
{
|
||||
for (int i = 0; i < web.length; i++)
|
||||
{
|
||||
if (block.getMaterial() == web[i])
|
||||
return true;
|
||||
public boolean canHarvestBlock(Block block, ItemStack is) {
|
||||
for (int i = 0; i < web.length; i++) {
|
||||
if (block.getMaterial() == web[i]) return true;
|
||||
}
|
||||
return super.canHarvestBlock(block, is);
|
||||
}
|
||||
|
||||
protected Material[] getEffectiveMaterials ()
|
||||
{
|
||||
protected Material[] getEffectiveMaterials() {
|
||||
return web;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5)
|
||||
{
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) {
|
||||
super.onUpdate(stack, world, entity, par4, par5);
|
||||
if (entity instanceof EntityPlayerSP)
|
||||
{
|
||||
if (entity instanceof EntityPlayerSP) {
|
||||
EntityPlayerSP player = (EntityPlayerSP) entity;
|
||||
ItemStack usingItem = player.getItemInUse();
|
||||
if (usingItem != null && usingItem.getItem() == this)
|
||||
{
|
||||
if (usingItem != null && usingItem.getItem() == this) {
|
||||
player.movementInput.moveForward *= 2.5F;
|
||||
player.movementInput.moveStrafe *= 2.5F;
|
||||
}
|
||||
@@ -129,21 +120,18 @@ public abstract class Weapon extends ToolCore implements IBattlegearWeapon, zeld
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTraits ()
|
||||
{
|
||||
return new String[] { "weapon", "melee" };
|
||||
public String[] getTraits() {
|
||||
return new String[] {"weapon", "melee"};
|
||||
}
|
||||
|
||||
public static Material[] web = new Material[] { Material.web, Material.cloth, Material.coral, Material.cake };
|
||||
public static Material[] web = new Material[] {Material.web, Material.cloth, Material.coral, Material.cake};
|
||||
public static Material[] none = new Material[0];
|
||||
|
||||
|
||||
/*---- Battlegear Support START ----*/
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean sheatheOnBack(ItemStack item)
|
||||
{
|
||||
public boolean sheatheOnBack(ItemStack item) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -155,7 +143,8 @@ public abstract class Weapon extends ToolCore implements IBattlegearWeapon, zeld
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean offhandAttackEntity(PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
|
||||
public boolean offhandAttackEntity(
|
||||
PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -180,10 +169,11 @@ public abstract class Weapon extends ToolCore implements IBattlegearWeapon, zeld
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean allowOffhand(ItemStack mainhand, ItemStack offhand) {
|
||||
if(offhand == null)
|
||||
return true;
|
||||
if (offhand == null) return true;
|
||||
|
||||
return (mainhand != null && mainhand.getItem() != TinkerTools.cleaver && mainhand.getItem() != TinkerTools.battleaxe)
|
||||
return (mainhand != null
|
||||
&& mainhand.getItem() != TinkerTools.cleaver
|
||||
&& mainhand.getItem() != TinkerTools.battleaxe)
|
||||
&& (offhand.getItem() != TinkerTools.cleaver && offhand.getItem() != TinkerTools.battleaxe);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user