mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 19:59:55 +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
@@ -7,62 +7,78 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public class ActiveToolMod
|
||||
{
|
||||
public class ActiveToolMod {
|
||||
/* Updating */
|
||||
public void updateTool (ToolCore tool, ItemStack stack, World world, Entity entity)
|
||||
{
|
||||
|
||||
}
|
||||
public void updateTool(ToolCore tool, ItemStack stack, World world, Entity entity) {}
|
||||
|
||||
/* Harvesting */
|
||||
public boolean beforeBlockBreak (ToolCore tool, ItemStack stack, int x, int y, int z, EntityLivingBase entity)
|
||||
{
|
||||
public boolean beforeBlockBreak(ToolCore tool, ItemStack stack, int x, int y, int z, EntityLivingBase entity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean afterBlockBreak () // Unfinished, not called
|
||||
{
|
||||
public boolean afterBlockBreak() // Unfinished, not called
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void afterBlockBreak(ToolCore tool, ItemStack stack, Block block, int x, int y, int z, EntityLivingBase entity)
|
||||
{
|
||||
|
||||
}
|
||||
public void afterBlockBreak(
|
||||
ToolCore tool, ItemStack stack, Block block, int x, int y, int z, EntityLivingBase entity) {}
|
||||
|
||||
/* Attacking */
|
||||
|
||||
public int baseAttackDamage (int earlyModDamage, int damage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity)
|
||||
{
|
||||
public int baseAttackDamage(
|
||||
int earlyModDamage,
|
||||
int damage,
|
||||
ToolCore tool,
|
||||
NBTTagCompound tags,
|
||||
NBTTagCompound toolTags,
|
||||
ItemStack stack,
|
||||
EntityLivingBase player,
|
||||
Entity entity) {
|
||||
return earlyModDamage;
|
||||
}
|
||||
|
||||
// Calculated after sprinting and enchant bonuses
|
||||
public float knockback (float modKnockback, float currentKnockback, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity)
|
||||
{
|
||||
public float knockback(
|
||||
float modKnockback,
|
||||
float currentKnockback,
|
||||
ToolCore tool,
|
||||
NBTTagCompound tags,
|
||||
NBTTagCompound toolTags,
|
||||
ItemStack stack,
|
||||
EntityLivingBase player,
|
||||
Entity entity) {
|
||||
return modKnockback;
|
||||
}
|
||||
|
||||
public int attackDamage (int modDamage, int currentDamage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity)
|
||||
{
|
||||
public int attackDamage(
|
||||
int modDamage,
|
||||
int currentDamage,
|
||||
ToolCore tool,
|
||||
NBTTagCompound tags,
|
||||
NBTTagCompound toolTags,
|
||||
ItemStack stack,
|
||||
EntityLivingBase player,
|
||||
Entity entity) {
|
||||
return modDamage;
|
||||
}
|
||||
|
||||
public void lateAttackEntity () // Unfinished, not called
|
||||
{
|
||||
|
||||
}
|
||||
public void lateAttackEntity() // Unfinished, not called
|
||||
{}
|
||||
|
||||
/* Damage tool */
|
||||
public boolean damageTool (ItemStack stack, int damage, EntityLivingBase entity)
|
||||
{
|
||||
public boolean damageTool(ItemStack stack, int damage, EntityLivingBase entity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean doesCriticalHit (ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity)
|
||||
{
|
||||
public boolean doesCriticalHit(
|
||||
ToolCore tool,
|
||||
NBTTagCompound tags,
|
||||
NBTTagCompound toolTags,
|
||||
ItemStack stack,
|
||||
EntityLivingBase player,
|
||||
Entity entity) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
package tconstruct.library;
|
||||
|
||||
public interface ItemBlocklike
|
||||
{
|
||||
}
|
||||
public interface ItemBlocklike {}
|
||||
@@ -1,11 +1,9 @@
|
||||
package tconstruct.library;
|
||||
|
||||
import java.util.IdentityHashMap;
|
||||
|
||||
import javax.vecmath.Vector3d;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import java.util.IdentityHashMap;
|
||||
import javax.vecmath.Vector3d;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
@@ -17,272 +15,272 @@ import tconstruct.gadgets.item.ItemSlimeBoots;
|
||||
/** Logic for entities bouncing */
|
||||
public class SlimeBounceHandler {
|
||||
|
||||
public static final float SQRT_2 = sqrt(2.0F);
|
||||
private static final float[] SIN_TABLE = new float[65536];
|
||||
private static final double FRAC_BIAS;
|
||||
private static final double[] ASINE_TAB;
|
||||
private static final double[] COS_TAB;
|
||||
public static final IdentityHashMap<EntityLivingBase, BounceInfo> BOUNCING_ENTITIES = new IdentityHashMap<EntityLivingBase, BounceInfo>();
|
||||
public static final float SQRT_2 = sqrt(2.0F);
|
||||
private static final float[] SIN_TABLE = new float[65536];
|
||||
private static final double FRAC_BIAS;
|
||||
private static final double[] ASINE_TAB;
|
||||
private static final double[] COS_TAB;
|
||||
public static final IdentityHashMap<EntityLivingBase, BounceInfo> BOUNCING_ENTITIES =
|
||||
new IdentityHashMap<EntityLivingBase, BounceInfo>();
|
||||
|
||||
static {
|
||||
for (int i = 0; i < 65536; ++i) {
|
||||
SIN_TABLE[i] = (float) Math.sin(i * Math.PI * 2.0D / 65536.0D);
|
||||
}
|
||||
FRAC_BIAS = Double.longBitsToDouble(4805340802404319232L);
|
||||
ASINE_TAB = new double[257];
|
||||
COS_TAB = new double[257];
|
||||
static {
|
||||
for (int i = 0; i < 65536; ++i) {
|
||||
SIN_TABLE[i] = (float) Math.sin(i * Math.PI * 2.0D / 65536.0D);
|
||||
}
|
||||
FRAC_BIAS = Double.longBitsToDouble(4805340802404319232L);
|
||||
ASINE_TAB = new double[257];
|
||||
COS_TAB = new double[257];
|
||||
|
||||
for (int j = 0; j < 257; ++j) {
|
||||
double d0 = j / 256.0D;
|
||||
double d1 = Math.asin(d0);
|
||||
COS_TAB[j] = Math.cos(d1);
|
||||
ASINE_TAB[j] = d1;
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < 257; ++j) {
|
||||
double d0 = j / 256.0D;
|
||||
double d1 = Math.asin(d0);
|
||||
COS_TAB[j] = Math.cos(d1);
|
||||
ASINE_TAB[j] = d1;
|
||||
}
|
||||
}
|
||||
|
||||
private SlimeBounceHandler() {
|
||||
TinkerGadgets.log.info("Created instance of Bounce Handler.");
|
||||
}
|
||||
private SlimeBounceHandler() {
|
||||
TinkerGadgets.log.info("Created instance of Bounce Handler.");
|
||||
}
|
||||
|
||||
/** Registers event handlers */
|
||||
public static void init() {
|
||||
TinkerGadgets.log.info("Registering Bounce Handler.");
|
||||
registerEvent(new SlimeBounceHandler());
|
||||
}
|
||||
/** Registers event handlers */
|
||||
public static void init() {
|
||||
TinkerGadgets.log.info("Registering Bounce Handler.");
|
||||
registerEvent(new SlimeBounceHandler());
|
||||
}
|
||||
|
||||
/**
|
||||
* Preserves entity air momentum
|
||||
*
|
||||
* @param entity Entity to bounce
|
||||
*/
|
||||
public static void addBounceHandler(EntityLivingBase entity) {
|
||||
addBounceHandler(entity, 0d);
|
||||
}
|
||||
/**
|
||||
* Preserves entity air momentum
|
||||
*
|
||||
* @param entity Entity to bounce
|
||||
*/
|
||||
public static void addBounceHandler(EntityLivingBase entity) {
|
||||
addBounceHandler(entity, 0d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Causes the entity to bounce, needed because the fall event will reset motion
|
||||
* afterwards
|
||||
*
|
||||
* @param entity Entity to bounce
|
||||
* @param bounce Bounce amount
|
||||
*/
|
||||
public static void addBounceHandler(EntityLivingBase entity, double bounce) {
|
||||
// no fake players PlayerTick event
|
||||
if (entity instanceof FakePlayer) {
|
||||
return;
|
||||
}
|
||||
// update bounce info
|
||||
BounceInfo info = BOUNCING_ENTITIES.get(entity);
|
||||
if (hasSlimeBoots(entity)) {
|
||||
if (info == null) {
|
||||
BOUNCING_ENTITIES.put(entity, new BounceInfo(entity, bounce));
|
||||
TinkerGadgets.log.info("Created new BounceInfo for "+entity.getCommandSenderName());
|
||||
} else if (bounce != 0) {
|
||||
TinkerGadgets.log.info("Updating Bounce data?");
|
||||
// updated bounce if needed
|
||||
info.bounce = bounce;
|
||||
// add one to the tick as there is a 1 tick delay between falling and ticking
|
||||
// for many entities
|
||||
info.bounceTick = entity.ticksExisted + 1;
|
||||
/**
|
||||
* Causes the entity to bounce, needed because the fall event will reset motion
|
||||
* afterwards
|
||||
*
|
||||
* @param entity Entity to bounce
|
||||
* @param bounce Bounce amount
|
||||
*/
|
||||
public static void addBounceHandler(EntityLivingBase entity, double bounce) {
|
||||
// no fake players PlayerTick event
|
||||
if (entity instanceof FakePlayer) {
|
||||
return;
|
||||
}
|
||||
// update bounce info
|
||||
BounceInfo info = BOUNCING_ENTITIES.get(entity);
|
||||
if (hasSlimeBoots(entity)) {
|
||||
if (info == null) {
|
||||
BOUNCING_ENTITIES.put(entity, new BounceInfo(entity, bounce));
|
||||
TinkerGadgets.log.info("Created new BounceInfo for " + entity.getCommandSenderName());
|
||||
} else if (bounce != 0) {
|
||||
TinkerGadgets.log.info("Updating Bounce data?");
|
||||
// updated bounce if needed
|
||||
info.bounce = bounce;
|
||||
// add one to the tick as there is a 1 tick delay between falling and ticking
|
||||
// for many entities
|
||||
info.bounceTick = entity.ticksExisted + 1;
|
||||
|
||||
info.lastMagSq = entity.motionX * entity.motionX + entity.motionZ * entity.motionZ;
|
||||
info.lastAngle = atan2(entity.motionZ, entity.motionX);
|
||||
}
|
||||
}
|
||||
}
|
||||
info.lastMagSq = entity.motionX * entity.motionX + entity.motionZ * entity.motionZ;
|
||||
info.lastAngle = atan2(entity.motionZ, entity.motionX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerEvent(Object o){
|
||||
MinecraftForge.EVENT_BUS.register(o);
|
||||
FMLCommonHandler.instance().bus().register(o);
|
||||
}
|
||||
public static void registerEvent(Object o) {
|
||||
MinecraftForge.EVENT_BUS.register(o);
|
||||
FMLCommonHandler.instance().bus().register(o);
|
||||
}
|
||||
|
||||
/** Called on living tick to preserve momentum and bounce */
|
||||
@SubscribeEvent
|
||||
public void onLivingTick(LivingUpdateEvent event) {
|
||||
EntityLivingBase entity = event.entityLiving;
|
||||
if (entity != null) {
|
||||
BounceInfo info = BOUNCING_ENTITIES.get(entity);
|
||||
/** Called on living tick to preserve momentum and bounce */
|
||||
@SubscribeEvent
|
||||
public void onLivingTick(LivingUpdateEvent event) {
|
||||
EntityLivingBase entity = event.entityLiving;
|
||||
if (entity != null) {
|
||||
BounceInfo info = BOUNCING_ENTITIES.get(entity);
|
||||
|
||||
//TinkerGadgets.log.info("Bounce Data valid? "+(info != null));
|
||||
// if we have info for this entity, time to work
|
||||
if (info != null) {
|
||||
//TinkerGadgets.log.info("Found Bounce Data in tick handler.");
|
||||
// if flying, nothing to do
|
||||
if (entity.isDead || entity.noClip) {
|
||||
//TinkerGadgets.log.info("Removing Bounce Data.");
|
||||
BOUNCING_ENTITIES.remove(entity);
|
||||
return;
|
||||
}
|
||||
if (!hasSlimeBoots(entity)) {
|
||||
//TinkerGadgets.log.info("Removing Bounce Data. No Boots.");
|
||||
BOUNCING_ENTITIES.remove(entity);
|
||||
return;
|
||||
}
|
||||
// TinkerGadgets.log.info("Bounce Data valid? "+(info != null));
|
||||
// if we have info for this entity, time to work
|
||||
if (info != null) {
|
||||
// TinkerGadgets.log.info("Found Bounce Data in tick handler.");
|
||||
// if flying, nothing to do
|
||||
if (entity.isDead || entity.noClip) {
|
||||
// TinkerGadgets.log.info("Removing Bounce Data.");
|
||||
BOUNCING_ENTITIES.remove(entity);
|
||||
return;
|
||||
}
|
||||
if (!hasSlimeBoots(entity)) {
|
||||
// TinkerGadgets.log.info("Removing Bounce Data. No Boots.");
|
||||
BOUNCING_ENTITIES.remove(entity);
|
||||
return;
|
||||
}
|
||||
|
||||
// if its the bounce tick, time to bounce. This is to circumvent the logic that
|
||||
// resets y motion after landing
|
||||
if (entity.ticksExisted == info.bounceTick) {
|
||||
TinkerGadgets.log.info("Bounce Tick?");
|
||||
entity.setVelocity(entity.motionX, info.bounce, entity.motionZ);
|
||||
info.bounceTick = 0;
|
||||
}
|
||||
// if its the bounce tick, time to bounce. This is to circumvent the logic that
|
||||
// resets y motion after landing
|
||||
if (entity.ticksExisted == info.bounceTick) {
|
||||
TinkerGadgets.log.info("Bounce Tick?");
|
||||
entity.setVelocity(entity.motionX, info.bounce, entity.motionZ);
|
||||
info.bounceTick = 0;
|
||||
}
|
||||
|
||||
boolean isInAir = !entity.onGround && !entity.isInWater() && !entity.isOnLadder();
|
||||
boolean isInAir = !entity.onGround && !entity.isInWater() && !entity.isOnLadder();
|
||||
|
||||
//TinkerGadgets.log.info("In Air? "+isInAir);
|
||||
// preserve motion
|
||||
if (isInAir && info.lastMagSq > 0) {
|
||||
// figure out how much motion has reduced
|
||||
double motionSq = entity.motionX * entity.motionX + entity.motionZ * entity.motionZ;
|
||||
// if not moving, cancel velocity preserving in 5 ticks
|
||||
if (motionSq == 0) {
|
||||
if (info.stopMagTick == 0) {
|
||||
info.stopMagTick = entity.ticksExisted + 5;
|
||||
} else if (entity.ticksExisted > info.stopMagTick) {
|
||||
info.lastMagSq = 0;
|
||||
}
|
||||
} else if (motionSq < info.lastMagSq) {
|
||||
info.stopMagTick = 0;
|
||||
// preserve 95% of former speed
|
||||
double boost = Math.sqrt(info.lastMagSq / motionSq) * 0.95f;
|
||||
if (boost > 1) {
|
||||
entity.setVelocity(entity.motionX * boost, entity.motionY, entity.motionZ * boost);
|
||||
entity.isAirBorne = true;
|
||||
info.lastMagSq = info.lastMagSq * 0.95f * 0.95f;
|
||||
// play sound if we had a big angle change
|
||||
double newAngle = atan2(entity.motionZ, entity.motionX);
|
||||
if (Math.abs(newAngle - info.lastAngle) > 1) {
|
||||
entity.playSound("mob.slime.small", 1.0f, 1.0f);
|
||||
}
|
||||
info.lastAngle = newAngle;
|
||||
} else {
|
||||
info.lastMagSq = motionSq;
|
||||
info.lastAngle = atan2(entity.motionZ, entity.motionX);
|
||||
}
|
||||
}
|
||||
}
|
||||
//TinkerGadgets.log.info("Did things? 1");
|
||||
// TinkerGadgets.log.info("In Air? "+isInAir);
|
||||
// preserve motion
|
||||
if (isInAir && info.lastMagSq > 0) {
|
||||
// figure out how much motion has reduced
|
||||
double motionSq = entity.motionX * entity.motionX + entity.motionZ * entity.motionZ;
|
||||
// if not moving, cancel velocity preserving in 5 ticks
|
||||
if (motionSq == 0) {
|
||||
if (info.stopMagTick == 0) {
|
||||
info.stopMagTick = entity.ticksExisted + 5;
|
||||
} else if (entity.ticksExisted > info.stopMagTick) {
|
||||
info.lastMagSq = 0;
|
||||
}
|
||||
} else if (motionSq < info.lastMagSq) {
|
||||
info.stopMagTick = 0;
|
||||
// preserve 95% of former speed
|
||||
double boost = Math.sqrt(info.lastMagSq / motionSq) * 0.95f;
|
||||
if (boost > 1) {
|
||||
entity.setVelocity(entity.motionX * boost, entity.motionY, entity.motionZ * boost);
|
||||
entity.isAirBorne = true;
|
||||
info.lastMagSq = info.lastMagSq * 0.95f * 0.95f;
|
||||
// play sound if we had a big angle change
|
||||
double newAngle = atan2(entity.motionZ, entity.motionX);
|
||||
if (Math.abs(newAngle - info.lastAngle) > 1) {
|
||||
entity.playSound("mob.slime.small", 1.0f, 1.0f);
|
||||
}
|
||||
info.lastAngle = newAngle;
|
||||
} else {
|
||||
info.lastMagSq = motionSq;
|
||||
info.lastAngle = atan2(entity.motionZ, entity.motionX);
|
||||
}
|
||||
}
|
||||
}
|
||||
// TinkerGadgets.log.info("Did things? 1");
|
||||
|
||||
// timing the effect out
|
||||
if (info.wasInAir && !isInAir) {
|
||||
if (info.endHandler == 0) {
|
||||
info.endHandler = entity.ticksExisted + 5;
|
||||
} else if (entity.ticksExisted > info.endHandler) {
|
||||
//TinkerGadgets.log.info("Removing Bounce Data for "+entity.getCommandSenderName());
|
||||
BOUNCING_ENTITIES.remove(entity);
|
||||
}
|
||||
} else {
|
||||
info.endHandler = 0;
|
||||
info.wasInAir = true;
|
||||
}
|
||||
//TinkerGadgets.log.info("Did things? 2");
|
||||
}
|
||||
else {
|
||||
//TinkerGadgets.log.info("Bad Bounce Data.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector3d getMotion(EntityLivingBase aEntity) {
|
||||
return new Vector3d(aEntity.motionX, aEntity.motionY, aEntity.motionZ);
|
||||
}
|
||||
|
||||
public static boolean hasSlimeBoots(EntityLivingBase entity) {
|
||||
if (entity != null) {
|
||||
for (int i = 1; i < 5; i++) {
|
||||
ItemStack aBoots = entity.getEquipmentInSlot(i);
|
||||
if (aBoots != null && aBoots.getItem() instanceof ItemSlimeBoots) {
|
||||
//TinkerGadgets.log.info("Found boots in slot "+i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// timing the effect out
|
||||
if (info.wasInAir && !isInAir) {
|
||||
if (info.endHandler == 0) {
|
||||
info.endHandler = entity.ticksExisted + 5;
|
||||
} else if (entity.ticksExisted > info.endHandler) {
|
||||
// TinkerGadgets.log.info("Removing Bounce Data for "+entity.getCommandSenderName());
|
||||
BOUNCING_ENTITIES.remove(entity);
|
||||
}
|
||||
} else {
|
||||
info.endHandler = 0;
|
||||
info.wasInAir = true;
|
||||
}
|
||||
// TinkerGadgets.log.info("Did things? 2");
|
||||
} else {
|
||||
// TinkerGadgets.log.info("Bad Bounce Data.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static float sqrt(float value) {
|
||||
return (float) Math.sqrt(value);
|
||||
}
|
||||
public static Vector3d getMotion(EntityLivingBase aEntity) {
|
||||
return new Vector3d(aEntity.motionX, aEntity.motionY, aEntity.motionZ);
|
||||
}
|
||||
|
||||
public static double atan2(double aArg1, double aArg2) {
|
||||
double d0 = aArg2 * aArg2 + aArg1 * aArg1;
|
||||
if (Double.isNaN(d0)) {
|
||||
return Double.NaN;
|
||||
} else {
|
||||
boolean flag = aArg1 < 0.0D;
|
||||
if (flag) {
|
||||
aArg1 = -aArg1;
|
||||
}
|
||||
boolean flag1 = aArg2 < 0.0D;
|
||||
if (flag1) {
|
||||
aArg2 = -aArg2;
|
||||
}
|
||||
boolean flag2 = aArg1 > aArg2;
|
||||
if (flag2) {
|
||||
double d1 = aArg2;
|
||||
aArg2 = aArg1;
|
||||
aArg1 = d1;
|
||||
}
|
||||
double d9 = fastInvSqrt(d0);
|
||||
aArg2 = aArg2 * d9;
|
||||
aArg1 = aArg1 * d9;
|
||||
double d2 = FRAC_BIAS + aArg1;
|
||||
int i = (int) Double.doubleToRawLongBits(d2);
|
||||
double d3 = ASINE_TAB[i];
|
||||
double d4 = COS_TAB[i];
|
||||
double d5 = d2 - FRAC_BIAS;
|
||||
double d6 = aArg1 * d4 - aArg2 * d5;
|
||||
double d7 = (6.0D + d6 * d6) * d6 * 0.16666666666666666D;
|
||||
double d8 = d3 + d7;
|
||||
if (flag2) {
|
||||
d8 = (Math.PI / 2D) - d8;
|
||||
}
|
||||
if (flag1) {
|
||||
d8 = Math.PI - d8;
|
||||
}
|
||||
if (flag) {
|
||||
d8 = -d8;
|
||||
}
|
||||
return d8;
|
||||
}
|
||||
}
|
||||
public static boolean hasSlimeBoots(EntityLivingBase entity) {
|
||||
if (entity != null) {
|
||||
for (int i = 1; i < 5; i++) {
|
||||
ItemStack aBoots = entity.getEquipmentInSlot(i);
|
||||
if (aBoots != null && aBoots.getItem() instanceof ItemSlimeBoots) {
|
||||
// TinkerGadgets.log.info("Found boots in slot "+i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static double fastInvSqrt(double aArg) {
|
||||
double d0 = 0.5D * aArg;
|
||||
long i = Double.doubleToRawLongBits(aArg);
|
||||
i = 6910469410427058090L - (i >> 1);
|
||||
aArg = Double.longBitsToDouble(i);
|
||||
aArg = aArg * (1.5D - d0 * aArg * aArg);
|
||||
return aArg;
|
||||
}
|
||||
public static float sqrt(float value) {
|
||||
return (float) Math.sqrt(value);
|
||||
}
|
||||
|
||||
/** Data class to keep track of bouncing info for an entity */
|
||||
private static class BounceInfo {
|
||||
/** Velocity the entity should have, unused if 0 */
|
||||
private double bounce;
|
||||
/** Time to update the entities velocity */
|
||||
private int bounceTick;
|
||||
/** Tick to stop entity magnitude changes */
|
||||
private int stopMagTick;
|
||||
/** Magnitude of the X/Z motion last tick */
|
||||
private double lastMagSq;
|
||||
/** If true, the entity was in air last tick */
|
||||
private boolean wasInAir = false;
|
||||
/** Time when motion should stop */
|
||||
private int endHandler = 0;
|
||||
/** Last angle of motion, used for sound effects */
|
||||
private double lastAngle;
|
||||
public static double atan2(double aArg1, double aArg2) {
|
||||
double d0 = aArg2 * aArg2 + aArg1 * aArg1;
|
||||
if (Double.isNaN(d0)) {
|
||||
return Double.NaN;
|
||||
} else {
|
||||
boolean flag = aArg1 < 0.0D;
|
||||
if (flag) {
|
||||
aArg1 = -aArg1;
|
||||
}
|
||||
boolean flag1 = aArg2 < 0.0D;
|
||||
if (flag1) {
|
||||
aArg2 = -aArg2;
|
||||
}
|
||||
boolean flag2 = aArg1 > aArg2;
|
||||
if (flag2) {
|
||||
double d1 = aArg2;
|
||||
aArg2 = aArg1;
|
||||
aArg1 = d1;
|
||||
}
|
||||
double d9 = fastInvSqrt(d0);
|
||||
aArg2 = aArg2 * d9;
|
||||
aArg1 = aArg1 * d9;
|
||||
double d2 = FRAC_BIAS + aArg1;
|
||||
int i = (int) Double.doubleToRawLongBits(d2);
|
||||
double d3 = ASINE_TAB[i];
|
||||
double d4 = COS_TAB[i];
|
||||
double d5 = d2 - FRAC_BIAS;
|
||||
double d6 = aArg1 * d4 - aArg2 * d5;
|
||||
double d7 = (6.0D + d6 * d6) * d6 * 0.16666666666666666D;
|
||||
double d8 = d3 + d7;
|
||||
if (flag2) {
|
||||
d8 = (Math.PI / 2D) - d8;
|
||||
}
|
||||
if (flag1) {
|
||||
d8 = Math.PI - d8;
|
||||
}
|
||||
if (flag) {
|
||||
d8 = -d8;
|
||||
}
|
||||
return d8;
|
||||
}
|
||||
}
|
||||
|
||||
public BounceInfo(EntityLivingBase entity, double bounce) {
|
||||
this.bounce = bounce;
|
||||
if (bounce != 0) {
|
||||
// add one to the tick as there is a 1 tick delay between falling and ticking
|
||||
// for many entities
|
||||
this.bounceTick = entity.ticksExisted + 1;
|
||||
} else {
|
||||
this.bounceTick = 0;
|
||||
}
|
||||
this.lastMagSq = entity.motionX * entity.motionX + entity.motionZ * entity.motionZ;
|
||||
}
|
||||
}
|
||||
public static double fastInvSqrt(double aArg) {
|
||||
double d0 = 0.5D * aArg;
|
||||
long i = Double.doubleToRawLongBits(aArg);
|
||||
i = 6910469410427058090L - (i >> 1);
|
||||
aArg = Double.longBitsToDouble(i);
|
||||
aArg = aArg * (1.5D - d0 * aArg * aArg);
|
||||
return aArg;
|
||||
}
|
||||
|
||||
/** Data class to keep track of bouncing info for an entity */
|
||||
private static class BounceInfo {
|
||||
/** Velocity the entity should have, unused if 0 */
|
||||
private double bounce;
|
||||
/** Time to update the entities velocity */
|
||||
private int bounceTick;
|
||||
/** Tick to stop entity magnitude changes */
|
||||
private int stopMagTick;
|
||||
/** Magnitude of the X/Z motion last tick */
|
||||
private double lastMagSq;
|
||||
/** If true, the entity was in air last tick */
|
||||
private boolean wasInAir = false;
|
||||
/** Time when motion should stop */
|
||||
private int endHandler = 0;
|
||||
/** Last angle of motion, used for sound effects */
|
||||
private double lastAngle;
|
||||
|
||||
public BounceInfo(EntityLivingBase entity, double bounce) {
|
||||
this.bounce = bounce;
|
||||
if (bounce != 0) {
|
||||
// add one to the tick as there is a 1 tick delay between falling and ticking
|
||||
// for many entities
|
||||
this.bounceTick = entity.ticksExisted + 1;
|
||||
} else {
|
||||
this.bounceTick = 0;
|
||||
}
|
||||
this.lastMagSq = entity.motionX * entity.motionX + entity.motionZ * entity.motionZ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,27 +3,22 @@ package tconstruct.library;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.*;
|
||||
|
||||
public class TConstructCreativeTab extends CreativeTabs
|
||||
{
|
||||
public class TConstructCreativeTab extends CreativeTabs {
|
||||
ItemStack display;
|
||||
|
||||
public TConstructCreativeTab(String label)
|
||||
{
|
||||
public TConstructCreativeTab(String label) {
|
||||
super(label);
|
||||
}
|
||||
|
||||
public void init (ItemStack stack)
|
||||
{
|
||||
public void init(ItemStack stack) {
|
||||
display = stack;
|
||||
}
|
||||
|
||||
public ItemStack getIconItemStack ()
|
||||
{
|
||||
public ItemStack getIconItemStack() {
|
||||
return display;
|
||||
}
|
||||
|
||||
public Item getTabIconItem ()
|
||||
{
|
||||
public Item getTabIconItem() {
|
||||
return display.getItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,12 +11,10 @@ import tconstruct.tools.TinkerTools;
|
||||
|
||||
/**
|
||||
* A registry to store any relevant API work
|
||||
*
|
||||
*
|
||||
* @author mDiyo
|
||||
*/
|
||||
|
||||
public class TConstructRegistry
|
||||
{
|
||||
public class TConstructRegistry {
|
||||
public static TConstructRegistry instance = new TConstructRegistry();
|
||||
|
||||
public static Logger logger = LogManager.getLogger("TCon-API");
|
||||
@@ -34,13 +32,13 @@ public class TConstructRegistry
|
||||
|
||||
/**
|
||||
* A directory of crafting items and tools used by the mod.
|
||||
*
|
||||
*
|
||||
* Tools: pickaxe, shovel, hatchet, broadsword, longsword, rapier, dagger,
|
||||
* cutlass frypan, battlesign, mattock, chisel lumberaxe, cleaver, scythe,
|
||||
* excavator, hammer, battleaxe
|
||||
*
|
||||
*
|
||||
* Patterns: blankPattern, woodPattern, metalPattern, clayPattern
|
||||
*
|
||||
*
|
||||
* Tool crafting parts: toolRod, toolShard, binding, toughBinding, toughRod,
|
||||
* heavyPlate pickaxeHead, shovelhead, hatchetHead, swordBlade, wideguard,
|
||||
* handGuard, crossbar, knifeBlade, fullGuard, frypanHead, signHead,
|
||||
@@ -51,42 +49,36 @@ public class TConstructRegistry
|
||||
|
||||
/**
|
||||
* Adds an item to the directory
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
* Associates the name with the stack
|
||||
* @param itemstack
|
||||
* The stack to add to the directory
|
||||
*/
|
||||
|
||||
public static void addItemToDirectory (String name, Item itemstack)
|
||||
{
|
||||
public static void addItemToDirectory(String name, Item itemstack) {
|
||||
Item add = itemDirectory.get(name);
|
||||
if (add != null)
|
||||
logger.warn(name + " is already present in the Item directory");
|
||||
if (add != null) logger.warn(name + " is already present in the Item directory");
|
||||
|
||||
itemDirectory.put(name, itemstack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves an itemstack from the directory
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
* The name of the item to get
|
||||
* @return Item associated with the name, or null if not present.
|
||||
*/
|
||||
|
||||
public static Item getItem (String name)
|
||||
{
|
||||
public static Item getItem(String name) {
|
||||
Item ret = itemDirectory.get(name);
|
||||
if (ret == null)
|
||||
logger.warn("Could not find " + name + " in the Item directory");
|
||||
if (ret == null) logger.warn("Could not find " + name + " in the Item directory");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* A directory of ItemStacks. Contains mostly crafting items
|
||||
*
|
||||
*
|
||||
* Materials: paperStack, greenSlimeCrystal, blueSlimeCrystal, searedBrick,
|
||||
* mossBall, lavaCrystal, necroticBone, silkyCloth, silkyJewel ingotCobalt,
|
||||
* ingotArdite, ingotManyullyn, ingotCopper, ingotTin, ingotAluminum,
|
||||
@@ -95,7 +87,7 @@ public class TConstructRegistry
|
||||
* nuggetSilver, nuggetAluminumBrass oreberryIron, oreberryGold,
|
||||
* oreberryCopper, oreberryTin, oreberryTin, oreberrySilver, diamondApple,
|
||||
* blueSlimeFood, canisterEmpty, miniRedHeart, canisterRedHeart
|
||||
*
|
||||
*
|
||||
* Patterns - These have a suffix of Pattern or Cast. ex: hatchetHeadPattern
|
||||
* ingot, toolRod, pickaxeHead, shovelHead, hatchetHead, swordBlade,
|
||||
* wideGuard, handGuard, crossbar, binding, frypanHead, signHead,
|
||||
@@ -107,35 +99,29 @@ public class TConstructRegistry
|
||||
|
||||
/**
|
||||
* Adds an itemstack to the directory
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
* Associates the name with the stack
|
||||
* @param itemstack
|
||||
* The stack to add to the directory
|
||||
*/
|
||||
|
||||
public static void addItemStackToDirectory (String name, ItemStack itemstack)
|
||||
{
|
||||
public static void addItemStackToDirectory(String name, ItemStack itemstack) {
|
||||
ItemStack add = itemstackDirectory.get(name);
|
||||
if (add != null)
|
||||
logger.warn(name + " is already present in the ItemStack directory");
|
||||
if (add != null) logger.warn(name + " is already present in the ItemStack directory");
|
||||
|
||||
itemstackDirectory.put(name, itemstack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves an itemstack from the directory
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
* The name of the item to get
|
||||
* @return Item associated with the name, or null if not present.
|
||||
*/
|
||||
|
||||
public static ItemStack getItemStack (String name)
|
||||
{
|
||||
public static ItemStack getItemStack(String name) {
|
||||
ItemStack ret = itemstackDirectory.get(name);
|
||||
if (ret == null)
|
||||
logger.warn("Could not find " + name + " in the ItemStack directory");
|
||||
if (ret == null) logger.warn("Could not find " + name + " in the ItemStack directory");
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -152,7 +138,7 @@ public class TConstructRegistry
|
||||
|
||||
/**
|
||||
* Maps an item and a material ID to an output part
|
||||
*
|
||||
*
|
||||
* @param woodPattern
|
||||
* ID to check against
|
||||
* @param patternMeta
|
||||
@@ -162,16 +148,13 @@ public class TConstructRegistry
|
||||
* @param output
|
||||
* The resulting part
|
||||
*/
|
||||
public static void addPartMapping (Item woodPattern, int patternMeta, int materialID, ItemStack output)
|
||||
{
|
||||
public static void addPartMapping(Item woodPattern, int patternMeta, int materialID, ItemStack output) {
|
||||
patternPartMapping.put(Arrays.asList(woodPattern, patternMeta, materialID), output);
|
||||
}
|
||||
|
||||
public static ItemStack getPartMapping (Item item, int metadata, int materialID)
|
||||
{
|
||||
public static ItemStack getPartMapping(Item item, int metadata, int materialID) {
|
||||
ItemStack stack = patternPartMapping.get(Arrays.asList(item, metadata, materialID));
|
||||
if (stack != null)
|
||||
return stack.copy();
|
||||
if (stack != null) return stack.copy();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -179,23 +162,19 @@ public class TConstructRegistry
|
||||
|
||||
/**
|
||||
* Internal tool mapping, used for adding textures
|
||||
*
|
||||
*
|
||||
* @param tool
|
||||
*/
|
||||
|
||||
public static void addToolMapping (ToolCore tool)
|
||||
{
|
||||
public static void addToolMapping(ToolCore tool) {
|
||||
tools.add(tool);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal tool mapping, used for adding textures
|
||||
*
|
||||
*
|
||||
* @return List of tools
|
||||
*/
|
||||
|
||||
public static ArrayList<ToolCore> getToolMapping ()
|
||||
{
|
||||
public static ArrayList<ToolCore> getToolMapping() {
|
||||
return tools;
|
||||
}
|
||||
|
||||
@@ -203,18 +182,16 @@ public class TConstructRegistry
|
||||
* Registers a tool to its crafting parts. If an output is registered
|
||||
* multiple times the parts are added to the recipe's input list Valid part
|
||||
* amounts are 2, 3, and 4.
|
||||
*
|
||||
*
|
||||
* @see ToolBuilder
|
||||
* @param output
|
||||
* The ToolCore to craft
|
||||
* @param parts
|
||||
* Pieces to make the tool with
|
||||
*/
|
||||
public static void addToolRecipe (ToolCore output, Item... parts)
|
||||
{
|
||||
public static void addToolRecipe(ToolCore output, Item... parts) {
|
||||
ToolBuilder tb = ToolBuilder.instance;
|
||||
if (parts.length < 2 || parts.length > 4)
|
||||
logger.warn("Wrong amount of items to craft into a tool");
|
||||
if (parts.length < 2 || parts.length > 4) logger.warn("Wrong amount of items to craft into a tool");
|
||||
|
||||
tb.addToolRecipe(output, parts);
|
||||
}
|
||||
@@ -225,25 +202,21 @@ public class TConstructRegistry
|
||||
public static List<Integer> defaultToolPartMaterials = new LinkedList<Integer>();
|
||||
public static List<Integer> defaultShardMaterials = new LinkedList<Integer>();
|
||||
|
||||
public static void addDefaultToolPartMaterial(int materialID)
|
||||
{
|
||||
if(!toolMaterials.containsKey(materialID))
|
||||
public static void addDefaultToolPartMaterial(int materialID) {
|
||||
if (!toolMaterials.containsKey(materialID))
|
||||
logger.error("[TCon API] Can't add default toolpart: Material ID " + materialID + " is unknown.");
|
||||
else
|
||||
defaultToolPartMaterials.add(materialID);
|
||||
else defaultToolPartMaterials.add(materialID);
|
||||
}
|
||||
|
||||
public static void addDefaultShardMaterial(int materialID)
|
||||
{
|
||||
if(!toolMaterials.containsKey(materialID))
|
||||
public static void addDefaultShardMaterial(int materialID) {
|
||||
if (!toolMaterials.containsKey(materialID))
|
||||
logger.error("[TCon API] Can't add default shard: Material ID " + materialID + " is unknown.");
|
||||
else
|
||||
defaultShardMaterials.add(materialID);
|
||||
else defaultShardMaterials.add(materialID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a tool material to the registry
|
||||
*
|
||||
*
|
||||
* @param materialID
|
||||
* Unique ID, stored for each part
|
||||
* @param materialName
|
||||
@@ -266,18 +239,36 @@ public class TConstructRegistry
|
||||
* Amount of Stonebound to put on the tool. Negative numbers are
|
||||
* Spiny.
|
||||
*/
|
||||
|
||||
public static void addToolMaterial (int materialID, String materialName, int harvestLevel, int durability, int miningspeed, int attack, float handleModifier, int reinforced, float stonebound, String style, int primaryColor)
|
||||
{
|
||||
public static void addToolMaterial(
|
||||
int materialID,
|
||||
String materialName,
|
||||
int harvestLevel,
|
||||
int durability,
|
||||
int miningspeed,
|
||||
int attack,
|
||||
float handleModifier,
|
||||
int reinforced,
|
||||
float stonebound,
|
||||
String style,
|
||||
int primaryColor) {
|
||||
ToolMaterial mat = toolMaterials.get(materialID);
|
||||
if (mat == null)
|
||||
{
|
||||
mat = new ToolMaterial(materialName, harvestLevel, durability, miningspeed, attack, handleModifier, reinforced, stonebound, style, primaryColor);
|
||||
if (mat == null) {
|
||||
mat = new ToolMaterial(
|
||||
materialName,
|
||||
harvestLevel,
|
||||
durability,
|
||||
miningspeed,
|
||||
attack,
|
||||
handleModifier,
|
||||
reinforced,
|
||||
stonebound,
|
||||
style,
|
||||
primaryColor);
|
||||
toolMaterials.put(materialID, mat);
|
||||
toolMaterialStrings.put(materialName, mat);
|
||||
}
|
||||
else
|
||||
throw new IllegalArgumentException("[TCon API] Material ID " + materialID + " is already occupied by " + mat.materialName);
|
||||
} else
|
||||
throw new IllegalArgumentException(
|
||||
"[TCon API] Material ID " + materialID + " is already occupied by " + mat.materialName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -307,74 +298,153 @@ public class TConstructRegistry
|
||||
* Amount of Stonebound to put on the tool. Negative numbers are
|
||||
* Spiny.
|
||||
*/
|
||||
public static void addToolMaterial (int materialID, String materialName, String localizationName, int harvestLevel, int durability, int miningspeed, int attack, float handleModifier, int reinforced, float stonebound, String style, int primaryColor)
|
||||
{
|
||||
public static void addToolMaterial(
|
||||
int materialID,
|
||||
String materialName,
|
||||
String localizationName,
|
||||
int harvestLevel,
|
||||
int durability,
|
||||
int miningspeed,
|
||||
int attack,
|
||||
float handleModifier,
|
||||
int reinforced,
|
||||
float stonebound,
|
||||
String style,
|
||||
int primaryColor) {
|
||||
ToolMaterial mat = toolMaterials.get(materialID);
|
||||
if (mat == null)
|
||||
{
|
||||
mat = new ToolMaterial(materialName, localizationName, harvestLevel, durability, miningspeed, attack, handleModifier, reinforced, stonebound, style, primaryColor);
|
||||
if (mat == null) {
|
||||
mat = new ToolMaterial(
|
||||
materialName,
|
||||
localizationName,
|
||||
harvestLevel,
|
||||
durability,
|
||||
miningspeed,
|
||||
attack,
|
||||
handleModifier,
|
||||
reinforced,
|
||||
stonebound,
|
||||
style,
|
||||
primaryColor);
|
||||
toolMaterials.put(materialID, mat);
|
||||
toolMaterialStrings.put(materialName, mat);
|
||||
}
|
||||
else
|
||||
throw new IllegalArgumentException("[TCon API] Material ID " + materialID + " is already occupied by " + mat.materialName);
|
||||
} else
|
||||
throw new IllegalArgumentException(
|
||||
"[TCon API] Material ID " + materialID + " is already occupied by " + mat.materialName);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addToolMaterial (int materialID, String materialName, int harvestLevel, int durability, int miningspeed, int attack, float handleModifier, int reinforced, float stonebound, String style)
|
||||
{
|
||||
logger.warn("[TCon API] Using deprecated addToolMaterial with no primary color. A fallback of white will be used.");
|
||||
addToolMaterial(materialID, materialName, harvestLevel, durability, miningspeed, attack, handleModifier, reinforced, stonebound, style, 0xFFFFFF);
|
||||
public static void addToolMaterial(
|
||||
int materialID,
|
||||
String materialName,
|
||||
int harvestLevel,
|
||||
int durability,
|
||||
int miningspeed,
|
||||
int attack,
|
||||
float handleModifier,
|
||||
int reinforced,
|
||||
float stonebound,
|
||||
String style) {
|
||||
logger.warn(
|
||||
"[TCon API] Using deprecated addToolMaterial with no primary color. A fallback of white will be used.");
|
||||
addToolMaterial(
|
||||
materialID,
|
||||
materialName,
|
||||
harvestLevel,
|
||||
durability,
|
||||
miningspeed,
|
||||
attack,
|
||||
handleModifier,
|
||||
reinforced,
|
||||
stonebound,
|
||||
style,
|
||||
0xFFFFFF);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addToolMaterial (int materialID, String materialName, int harvestLevel, int durability, int miningspeed, int attack, float handleModifier, int reinforced, float stonebound, String style, String ability)
|
||||
{
|
||||
logger.warn("[TCon API] Using deprecated addToolMaterial with ability name. ability will be ignored, use languages files for that.");
|
||||
addToolMaterial(materialID, materialName, harvestLevel, durability, miningspeed, attack, handleModifier, reinforced, stonebound, style);
|
||||
public static void addToolMaterial(
|
||||
int materialID,
|
||||
String materialName,
|
||||
int harvestLevel,
|
||||
int durability,
|
||||
int miningspeed,
|
||||
int attack,
|
||||
float handleModifier,
|
||||
int reinforced,
|
||||
float stonebound,
|
||||
String style,
|
||||
String ability) {
|
||||
logger.warn(
|
||||
"[TCon API] Using deprecated addToolMaterial with ability name. ability will be ignored, use languages files for that.");
|
||||
addToolMaterial(
|
||||
materialID,
|
||||
materialName,
|
||||
harvestLevel,
|
||||
durability,
|
||||
miningspeed,
|
||||
attack,
|
||||
handleModifier,
|
||||
reinforced,
|
||||
stonebound,
|
||||
style);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addToolMaterial (int materialID, String materialName, String displayName, int harvestLevel, int durability, int miningspeed, int attack, float handleModifier, int reinforced, float stonebound, String style, String ability)
|
||||
{
|
||||
logger.warn("[TCon API] Using deprecated addToolMaterial with display and ability name. displayName and ability will be ignored, use languages files for that.");
|
||||
addToolMaterial(materialID, materialName, harvestLevel, durability, miningspeed, attack, handleModifier, reinforced, stonebound, style);
|
||||
public static void addToolMaterial(
|
||||
int materialID,
|
||||
String materialName,
|
||||
String displayName,
|
||||
int harvestLevel,
|
||||
int durability,
|
||||
int miningspeed,
|
||||
int attack,
|
||||
float handleModifier,
|
||||
int reinforced,
|
||||
float stonebound,
|
||||
String style,
|
||||
String ability) {
|
||||
logger.warn(
|
||||
"[TCon API] Using deprecated addToolMaterial with display and ability name. displayName and ability will be ignored, use languages files for that.");
|
||||
addToolMaterial(
|
||||
materialID,
|
||||
materialName,
|
||||
harvestLevel,
|
||||
durability,
|
||||
miningspeed,
|
||||
attack,
|
||||
handleModifier,
|
||||
reinforced,
|
||||
stonebound,
|
||||
style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a tool material to the registry
|
||||
*
|
||||
*
|
||||
* @param materialID
|
||||
* Unique ID, stored for each part
|
||||
* @param material
|
||||
* Complete tool material to add. Uses the name in the material
|
||||
* for lookup purposes.
|
||||
*/
|
||||
|
||||
public static void addtoolMaterial (int materialID, ToolMaterial material)
|
||||
{
|
||||
public static void addtoolMaterial(int materialID, ToolMaterial material) {
|
||||
ToolMaterial mat = toolMaterials.get(materialID);
|
||||
if (mat == null)
|
||||
{
|
||||
if (mat == null) {
|
||||
toolMaterials.put(materialID, material);
|
||||
toolMaterialStrings.put(material.name(), material);
|
||||
}
|
||||
else
|
||||
throw new IllegalArgumentException("[TCon API] Material ID " + materialID + " is already occupied by " + mat.materialName);
|
||||
} else
|
||||
throw new IllegalArgumentException(
|
||||
"[TCon API] Material ID " + materialID + " is already occupied by " + mat.materialName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks up a tool material by ID
|
||||
*
|
||||
*
|
||||
* @param key
|
||||
* The ID to look up
|
||||
* @return Tool Material
|
||||
*/
|
||||
|
||||
public static ToolMaterial getMaterial (int key)
|
||||
{
|
||||
if (toolMaterials.containsKey(key))
|
||||
{
|
||||
public static ToolMaterial getMaterial(int key) {
|
||||
if (toolMaterials.containsKey(key)) {
|
||||
return (toolMaterials.get(key));
|
||||
}
|
||||
|
||||
@@ -385,14 +455,12 @@ public class TConstructRegistry
|
||||
|
||||
/**
|
||||
* Looks up a tool material by name
|
||||
*
|
||||
*
|
||||
* @param key
|
||||
* the name to look up
|
||||
* @return Tool Material
|
||||
*/
|
||||
|
||||
public static ToolMaterial getMaterial (String key)
|
||||
{
|
||||
public static ToolMaterial getMaterial(String key) {
|
||||
return (toolMaterialStrings.get(key));
|
||||
}
|
||||
|
||||
@@ -400,115 +468,123 @@ public class TConstructRegistry
|
||||
public static HashMap<Integer, BowMaterial> bowMaterials = new HashMap<Integer, BowMaterial>(40);
|
||||
|
||||
@Deprecated
|
||||
public static void addBowMaterial (int materialID, int durability, int drawSpeed, float speedMax)
|
||||
{
|
||||
public static void addBowMaterial(int materialID, int durability, int drawSpeed, float speedMax) {
|
||||
addBowMaterial(materialID, drawSpeed, speedMax);
|
||||
}
|
||||
|
||||
public static void addBowMaterial (int materialID, int drawSpeed, float speedMax)
|
||||
{
|
||||
public static void addBowMaterial(int materialID, int drawSpeed, float speedMax) {
|
||||
BowMaterial mat = bowMaterials.get(materialID);
|
||||
if (mat == null)
|
||||
{
|
||||
if (mat == null) {
|
||||
mat = new BowMaterial(drawSpeed, speedMax);
|
||||
bowMaterials.put(materialID, mat);
|
||||
}
|
||||
else
|
||||
throw new IllegalArgumentException("[TCon API] Bow Material ID " + materialID + " is already occupied");
|
||||
} else throw new IllegalArgumentException("[TCon API] Bow Material ID " + materialID + " is already occupied");
|
||||
}
|
||||
|
||||
public static boolean validBowMaterial (int materialID)
|
||||
{
|
||||
public static boolean validBowMaterial(int materialID) {
|
||||
return bowMaterials.containsKey(materialID);
|
||||
}
|
||||
|
||||
public static BowMaterial getBowMaterial (int materialID)
|
||||
{
|
||||
public static BowMaterial getBowMaterial(int materialID) {
|
||||
return bowMaterials.get(materialID);
|
||||
}
|
||||
|
||||
public static HashMap<Integer, ArrowMaterial> arrowMaterials = new HashMap<Integer, ArrowMaterial>(40);
|
||||
|
||||
@Deprecated
|
||||
public static void addArrowMaterial (int materialID, float mass, float breakChance, float accuracy)
|
||||
{
|
||||
public static void addArrowMaterial(int materialID, float mass, float breakChance, float accuracy) {
|
||||
addArrowMaterial(materialID, mass, breakChance);
|
||||
}
|
||||
|
||||
public static void addArrowMaterial (int materialID, float mass, float breakChance)
|
||||
{
|
||||
public static void addArrowMaterial(int materialID, float mass, float breakChance) {
|
||||
ArrowMaterial mat = arrowMaterials.get(materialID);
|
||||
if (mat == null)
|
||||
{
|
||||
if (mat == null) {
|
||||
mat = new ArrowMaterial(mass, breakChance);
|
||||
arrowMaterials.put(materialID, mat);
|
||||
}
|
||||
else
|
||||
} else
|
||||
throw new IllegalArgumentException("[TCon API] Arrow Material ID " + materialID + " is already occupied");
|
||||
}
|
||||
|
||||
public static boolean validArrowMaterial (int materialID)
|
||||
{
|
||||
public static boolean validArrowMaterial(int materialID) {
|
||||
return arrowMaterials.containsKey(materialID);
|
||||
}
|
||||
|
||||
public static ArrowMaterial getArrowMaterial (int materialID)
|
||||
{
|
||||
public static ArrowMaterial getArrowMaterial(int materialID) {
|
||||
return arrowMaterials.get(materialID);
|
||||
}
|
||||
|
||||
// Custom materials - bowstrings, fletching, etc
|
||||
public static ArrayList<CustomMaterial> customMaterials = new ArrayList<CustomMaterial>();
|
||||
|
||||
public static void addCustomMaterial (CustomMaterial mat)
|
||||
{
|
||||
if (mat != null)
|
||||
customMaterials.add(mat);
|
||||
public static void addCustomMaterial(CustomMaterial mat) {
|
||||
if (mat != null) customMaterials.add(mat);
|
||||
}
|
||||
|
||||
|
||||
public static void addBowstringMaterial (int materialID, int value, ItemStack input, ItemStack craftingMaterial, float durability, float drawSpeed, float flightSpeed, int color)
|
||||
{
|
||||
BowstringMaterial mat = new BowstringMaterial(materialID, value, input, craftingMaterial, durability, drawSpeed, flightSpeed, color);
|
||||
public static void addBowstringMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
ItemStack input,
|
||||
ItemStack craftingMaterial,
|
||||
float durability,
|
||||
float drawSpeed,
|
||||
float flightSpeed,
|
||||
int color) {
|
||||
BowstringMaterial mat = new BowstringMaterial(
|
||||
materialID, value, input, craftingMaterial, durability, drawSpeed, flightSpeed, color);
|
||||
customMaterials.add(mat);
|
||||
}
|
||||
|
||||
public static void addFletchingMaterial (int materialID, int value, ItemStack input, ItemStack craftingMaterial, float accuracy, float breakChance, float durabilityModifier, int color)
|
||||
{
|
||||
FletchingMaterial mat = new FletchingMaterial(materialID, value, input, craftingMaterial, accuracy, breakChance, durabilityModifier, color);
|
||||
public static void addFletchingMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
ItemStack input,
|
||||
ItemStack craftingMaterial,
|
||||
float accuracy,
|
||||
float breakChance,
|
||||
float durabilityModifier,
|
||||
int color) {
|
||||
FletchingMaterial mat = new FletchingMaterial(
|
||||
materialID, value, input, craftingMaterial, accuracy, breakChance, durabilityModifier, color);
|
||||
customMaterials.add(mat);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addBowstringMaterial (int materialID, int value, ItemStack input, ItemStack craftingMaterial, float durability, float drawSpeed, float flightSpeed)
|
||||
{
|
||||
BowstringMaterial mat = new BowstringMaterial(materialID, value, input, craftingMaterial, durability, drawSpeed, flightSpeed);
|
||||
public static void addBowstringMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
ItemStack input,
|
||||
ItemStack craftingMaterial,
|
||||
float durability,
|
||||
float drawSpeed,
|
||||
float flightSpeed) {
|
||||
BowstringMaterial mat =
|
||||
new BowstringMaterial(materialID, value, input, craftingMaterial, durability, drawSpeed, flightSpeed);
|
||||
customMaterials.add(mat);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addFletchingMaterial (int materialID, int value, ItemStack input, ItemStack craftingMaterial, float accuracy, float breakChance, float mass)
|
||||
{
|
||||
FletchingMaterial mat = new FletchingMaterial(materialID, value, input, craftingMaterial, accuracy, breakChance, mass);
|
||||
public static void addFletchingMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
ItemStack input,
|
||||
ItemStack craftingMaterial,
|
||||
float accuracy,
|
||||
float breakChance,
|
||||
float mass) {
|
||||
FletchingMaterial mat =
|
||||
new FletchingMaterial(materialID, value, input, craftingMaterial, accuracy, breakChance, mass);
|
||||
customMaterials.add(mat);
|
||||
}
|
||||
|
||||
public static CustomMaterial getCustomMaterial (int materialID, Class<? extends CustomMaterial> clazz)
|
||||
{
|
||||
for (CustomMaterial mat : customMaterials)
|
||||
{
|
||||
if (mat.getClass().equals(clazz) && mat.materialID == materialID)
|
||||
return mat;
|
||||
public static CustomMaterial getCustomMaterial(int materialID, Class<? extends CustomMaterial> clazz) {
|
||||
for (CustomMaterial mat : customMaterials) {
|
||||
if (mat.getClass().equals(clazz) && mat.materialID == materialID) return mat;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static CustomMaterial getCustomMaterial (ItemStack input, Class<? extends CustomMaterial> clazz)
|
||||
{
|
||||
for (CustomMaterial mat : customMaterials)
|
||||
{
|
||||
if (mat.getClass().equals(clazz) && mat.matches(input))
|
||||
return mat;
|
||||
public static CustomMaterial getCustomMaterial(ItemStack input, Class<? extends CustomMaterial> clazz) {
|
||||
for (CustomMaterial mat : customMaterials) {
|
||||
if (mat.getClass().equals(clazz) && mat.matches(input)) return mat;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -522,76 +598,61 @@ public class TConstructRegistry
|
||||
/*
|
||||
* public static ItemStack craftBowString(ItemStack stack) { if
|
||||
* (stack.stackSize < 3) return null;
|
||||
*
|
||||
*
|
||||
* for (BowstringMaterial mat : bowstringMaterials) { if
|
||||
* (stack.isItemEqual(mat.input)) return mat.craftingItem.copy(); } return
|
||||
* null; }
|
||||
*
|
||||
*
|
||||
* public static BowstringMaterial getBowstringMaterial(ItemStack stack) {
|
||||
* if (stack.stackSize < 3) return null;
|
||||
*
|
||||
*
|
||||
* for (BowstringMaterial mat : bowstringMaterials) { if
|
||||
* (stack.isItemEqual(mat.input)) return mat; } return null; }
|
||||
*/
|
||||
|
||||
public static LiquidCasting getTableCasting ()
|
||||
{
|
||||
public static LiquidCasting getTableCasting() {
|
||||
return instance.tableCasting();
|
||||
}
|
||||
|
||||
LiquidCasting tableCasting ()
|
||||
{
|
||||
try
|
||||
{
|
||||
LiquidCasting tableCasting() {
|
||||
try {
|
||||
Class clazz = Class.forName("tconstruct.TConstruct");
|
||||
Method method = clazz.getMethod("getTableCasting");
|
||||
LiquidCasting lc = (LiquidCasting) method.invoke(this);
|
||||
return lc;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
logger.warn("Could not find casting table recipes.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static LiquidCasting getBasinCasting ()
|
||||
{
|
||||
public static LiquidCasting getBasinCasting() {
|
||||
return instance.basinCasting();
|
||||
}
|
||||
|
||||
LiquidCasting basinCasting ()
|
||||
{
|
||||
try
|
||||
{
|
||||
LiquidCasting basinCasting() {
|
||||
try {
|
||||
Class clazz = Class.forName("tconstruct.TConstruct");
|
||||
Method method = clazz.getMethod("getBasinCasting");
|
||||
LiquidCasting lc = (LiquidCasting) method.invoke(this);
|
||||
return lc;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
logger.warn("Could not find casting basin recipes.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Detailing getChiselDetailing ()
|
||||
{
|
||||
public static Detailing getChiselDetailing() {
|
||||
return instance.chiselDetailing();
|
||||
}
|
||||
|
||||
Detailing chiselDetailing ()
|
||||
{
|
||||
try
|
||||
{
|
||||
Detailing chiselDetailing() {
|
||||
try {
|
||||
Class clazz = Class.forName("tconstruct.TConstruct");
|
||||
Method method = clazz.getMethod("getChiselDetailing");
|
||||
Detailing lc = (Detailing) method.invoke(this);
|
||||
return lc;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
logger.warn("Could not find chisel detailing recipes.");
|
||||
return null;
|
||||
}
|
||||
@@ -600,13 +661,11 @@ public class TConstructRegistry
|
||||
public static ArrayList<ActiveToolMod> activeModifiers = new ArrayList<ActiveToolMod>();
|
||||
public static LinkedList<ActiveArmorMod> activeArmorModifiers = new LinkedList<ActiveArmorMod>();
|
||||
|
||||
public static void registerActiveToolMod (ActiveToolMod mod)
|
||||
{
|
||||
public static void registerActiveToolMod(ActiveToolMod mod) {
|
||||
activeModifiers.add(mod);
|
||||
}
|
||||
|
||||
public static void registerActiveArmorMod (ActiveArmorMod mod)
|
||||
{
|
||||
public static void registerActiveArmorMod(ActiveArmorMod mod) {
|
||||
activeArmorModifiers.add(mod);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,15 +12,13 @@ import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.modifier.IModifyable;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public abstract class AccessoryCore extends Item implements IAccessory, IModifyable
|
||||
{
|
||||
public abstract class AccessoryCore extends Item implements IAccessory, IModifyable {
|
||||
/**
|
||||
* Override getArmorModel() to have render on the player.
|
||||
*/
|
||||
protected String texture;
|
||||
|
||||
public AccessoryCore(String texture)
|
||||
{
|
||||
public AccessoryCore(String texture) {
|
||||
super();
|
||||
this.setCreativeTab(TConstructRegistry.equipableTab);
|
||||
this.setMaxStackSize(1);
|
||||
@@ -28,22 +26,19 @@ public abstract class AccessoryCore extends Item implements IAccessory, IModifya
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseTagName ()
|
||||
{
|
||||
public String getBaseTagName() {
|
||||
return "TinkerAccessory";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModifyType ()
|
||||
{
|
||||
public String getModifyType() {
|
||||
return "Accessory";
|
||||
}
|
||||
|
||||
final static String[] traits = new String[] { "accessory" };
|
||||
static final String[] traits = new String[] {"accessory"};
|
||||
|
||||
@Override
|
||||
public String[] getTraits ()
|
||||
{
|
||||
public String[] getTraits() {
|
||||
return traits;
|
||||
}
|
||||
|
||||
@@ -61,23 +56,21 @@ public abstract class AccessoryCore extends Item implements IAccessory, IModifya
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems (Item par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
par3List.add(getDefaultItem());
|
||||
}
|
||||
|
||||
public ItemStack getDefaultItem ()
|
||||
{
|
||||
public ItemStack getDefaultItem() {
|
||||
ItemStack gear = new ItemStack(this, 1, 0);
|
||||
NBTTagCompound itemTag = new NBTTagCompound();
|
||||
|
||||
int baseDurability = 500;
|
||||
|
||||
itemTag.setInteger("Damage", 0); //Damage is damage to the tool
|
||||
itemTag.setInteger("Damage", 0); // Damage is damage to the tool
|
||||
itemTag.setInteger("TotalDurability", baseDurability);
|
||||
itemTag.setInteger("BaseDurability", baseDurability);
|
||||
itemTag.setInteger("BonusDurability", 0); //Modifier
|
||||
itemTag.setFloat("ModDurability", 0f); //Modifier
|
||||
itemTag.setInteger("BonusDurability", 0); // Modifier
|
||||
itemTag.setFloat("ModDurability", 0f); // Modifier
|
||||
itemTag.setInteger("Modifiers", 5);
|
||||
itemTag.setBoolean("Broken", false);
|
||||
itemTag.setBoolean("Built", true);
|
||||
@@ -95,56 +88,44 @@ public abstract class AccessoryCore extends Item implements IAccessory, IModifya
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IIconRegister iconRegister)
|
||||
{
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
itemIcon = iconRegister.registerIcon("tinker:" + texture);
|
||||
registerModifiers(iconRegister);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected void registerModifiers (IIconRegister iconRegister)
|
||||
{
|
||||
}
|
||||
protected void registerModifiers(IIconRegister iconRegister) {}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean requiresMultipleRenderPasses ()
|
||||
{
|
||||
public boolean requiresMultipleRenderPasses() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getRenderPasses (int metadata)
|
||||
{
|
||||
public int getRenderPasses(int metadata) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean hasEffect (ItemStack par1ItemStack)
|
||||
{
|
||||
public boolean hasEffect(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (ItemStack stack, int renderPass)
|
||||
{
|
||||
if (renderPass > 0)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
public IIcon getIcon(ItemStack stack, int renderPass) {
|
||||
if (renderPass > 0) {
|
||||
if (stack.hasTagCompound()) {
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("TinkerAccessory");
|
||||
if (renderPass == 1 && tags.hasKey("Effect1"))
|
||||
{
|
||||
if (renderPass == 1 && tags.hasKey("Effect1")) {
|
||||
return modifiers[tags.getInteger("Effect1")];
|
||||
}
|
||||
if (renderPass == 2 && tags.hasKey("Effect2"))
|
||||
{
|
||||
if (renderPass == 2 && tags.hasKey("Effect2")) {
|
||||
return modifiers[tags.getInteger("Effect2")];
|
||||
}
|
||||
if (renderPass == 3 && tags.hasKey("Effect3"))
|
||||
{
|
||||
if (renderPass == 3 && tags.hasKey("Effect3")) {
|
||||
return modifiers[tags.getInteger("Effect3")];
|
||||
}
|
||||
}
|
||||
@@ -158,34 +139,24 @@ public abstract class AccessoryCore extends Item implements IAccessory, IModifya
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
|
||||
if (!stack.hasTagCompound()) return;
|
||||
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
if (tags.hasKey(getBaseTagName()))
|
||||
{
|
||||
if (tags.hasKey(getBaseTagName())) {
|
||||
tags = stack.getTagCompound().getCompoundTag(getBaseTagName());
|
||||
boolean broken = tags.getBoolean("Broken");
|
||||
if (broken)
|
||||
list.add("\u00A7oBroken");
|
||||
else
|
||||
{
|
||||
if (broken) list.add("\u00A7oBroken");
|
||||
else {
|
||||
boolean displayToolTips = true;
|
||||
int tipNum = 0;
|
||||
while (displayToolTips)
|
||||
{
|
||||
while (displayToolTips) {
|
||||
tipNum++;
|
||||
String tooltip = "Tooltip" + tipNum;
|
||||
if (tags.hasKey(tooltip))
|
||||
{
|
||||
if (tags.hasKey(tooltip)) {
|
||||
String tipName = tags.getString(tooltip);
|
||||
if (!tipName.equals(""))
|
||||
list.add(tipName);
|
||||
}
|
||||
else
|
||||
displayToolTips = false;
|
||||
if (!tipName.equals("")) list.add(tipName);
|
||||
} else displayToolTips = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,12 @@ package tconstruct.library.accessory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IAccessory
|
||||
{
|
||||
public interface IAccessory {
|
||||
/** Accessory slots are not the same as armor slots!
|
||||
*
|
||||
*
|
||||
* @param item Instance of the item
|
||||
* @param slot Accessory slot
|
||||
* @return Whether the accessory can be inserted into the slot
|
||||
*/
|
||||
public boolean canEquipAccessory (ItemStack item, int slot);
|
||||
public boolean canEquipAccessory(ItemStack item, int slot);
|
||||
}
|
||||
@@ -5,16 +5,14 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public interface IAccessoryModel
|
||||
{
|
||||
public interface IAccessoryModel {
|
||||
/** Similar to how armor is rendered.
|
||||
*
|
||||
*
|
||||
* @param stack
|
||||
* @param entity
|
||||
* @param slot
|
||||
* @return Resource location of the texture. Return null for none
|
||||
*/
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ResourceLocation getWearbleTexture (Entity entity, ItemStack stack, int slot);
|
||||
public ResourceLocation getWearbleTexture(Entity entity, ItemStack stack, int slot);
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package tconstruct.library.accessory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IHealthAccessory extends IAccessory
|
||||
{
|
||||
public int getHealthBoost (ItemStack item);
|
||||
public interface IHealthAccessory extends IAccessory {
|
||||
public int getHealthBoost(ItemStack item);
|
||||
}
|
||||
@@ -20,8 +20,7 @@ import tconstruct.library.modifier.*;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.tools.entity.FancyEntityItem;
|
||||
|
||||
public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IModifyable
|
||||
{
|
||||
public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IModifyable {
|
||||
public final ArmorPart armorPart;
|
||||
private static final IBehaviorDispenseItem dispenserBehavior = new BehaviorDispenseArmorCopy();
|
||||
public final int baseProtection;
|
||||
@@ -29,8 +28,7 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
protected final String textureFolder;
|
||||
protected final String textureName;
|
||||
|
||||
public ArmorCore(int baseProtection, ArmorPart part, String type, String textureFolder, String textureName)
|
||||
{
|
||||
public ArmorCore(int baseProtection, ArmorPart part, String type, String textureFolder, String textureName) {
|
||||
super(ArmorMaterial.CHAIN, 0, part.getPartId());
|
||||
this.maxStackSize = 1;
|
||||
this.setMaxDamage(100);
|
||||
@@ -43,46 +41,42 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
this.setCreativeTab(TConstructRegistry.equipableTab);
|
||||
}
|
||||
|
||||
public ArmorCore(int baseProtection, ArmorPart part, String type, String textureName)
|
||||
{
|
||||
public ArmorCore(int baseProtection, ArmorPart part, String type, String textureName) {
|
||||
this(baseProtection, part, type, "armor", textureName);
|
||||
}
|
||||
|
||||
//Temporary?
|
||||
public abstract ItemStack getRepairMaterial (ItemStack input);
|
||||
// Temporary?
|
||||
public abstract ItemStack getRepairMaterial(ItemStack input);
|
||||
|
||||
public String getArmorName ()
|
||||
{
|
||||
public String getArmorName() {
|
||||
return this.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseTagName ()
|
||||
{
|
||||
public String getBaseTagName() {
|
||||
return "TinkerArmor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModifyType ()
|
||||
{
|
||||
public String getModifyType() {
|
||||
return modifyType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTraits ()
|
||||
{
|
||||
return new String[] { "armor" };
|
||||
public String[] getTraits() {
|
||||
return new String[] {"armor"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
int i = EntityLiving.getArmorPosition(stack) - 1;
|
||||
ItemStack itemstack1 = player.getCurrentArmor(i);
|
||||
|
||||
if (itemstack1 == null)
|
||||
{
|
||||
player.setCurrentItemOrArmor(i + 1, stack.copy()); //Forge: Vanilla bug fix associated with fixed setCurrentItemOrArmor indexs for players.
|
||||
if (itemstack1 == null) {
|
||||
player.setCurrentItemOrArmor(
|
||||
i + 1,
|
||||
stack.copy()); // Forge: Vanilla bug fix associated with fixed setCurrentItemOrArmor indexs for
|
||||
// players.
|
||||
stack.stackSize = 0;
|
||||
}
|
||||
|
||||
@@ -90,20 +84,16 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmorTick (World world, EntityPlayer player, ItemStack itemStack)
|
||||
{
|
||||
for (ActiveArmorMod mod : TConstructRegistry.activeArmorModifiers)
|
||||
{
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
|
||||
for (ActiveArmorMod mod : TConstructRegistry.activeArmorModifiers) {
|
||||
mod.onArmorTick(world, player, itemStack, this, this.armorPart);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getArmorTexture (ItemStack stack, Entity entity, int slot, String type)
|
||||
{
|
||||
if (slot == 2)
|
||||
return "tinker:textures/armor/" + textureName + "_" + 2 + ".png";
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
|
||||
if (slot == 2) return "tinker:textures/armor/" + textureName + "_" + 2 + ".png";
|
||||
return "tinker:textures/armor/" + textureName + "_" + 1 + ".png";
|
||||
}
|
||||
|
||||
@@ -112,31 +102,29 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("tinker:" + textureFolder + "/" + textureName + (this.armorType == 0 ? "helmet" : this.armorType == 1 ? "chestplate" : this.armorType == 2 ? "pants" : this.armorType == 3 ? "boots" : "helmet"));
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
this.itemIcon = iconRegister.registerIcon("tinker:" + textureFolder + "/" + textureName
|
||||
+ (this.armorType == 0
|
||||
? "helmet"
|
||||
: this.armorType == 1
|
||||
? "chestplate"
|
||||
: this.armorType == 2 ? "pants" : this.armorType == 3 ? "boots" : "helmet"));
|
||||
registerModifiers(iconRegister);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (ItemStack stack, int renderPass)
|
||||
{
|
||||
if (renderPass > 0)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
public IIcon getIcon(ItemStack stack, int renderPass) {
|
||||
if (renderPass > 0) {
|
||||
if (stack.hasTagCompound()) {
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag(getBaseTagName());
|
||||
if (renderPass == 1 && tags.hasKey("Effect1"))
|
||||
{
|
||||
if (renderPass == 1 && tags.hasKey("Effect1")) {
|
||||
return modifiers[tags.getInteger("Effect1")];
|
||||
}
|
||||
if (renderPass == 2 && tags.hasKey("Effect2"))
|
||||
{
|
||||
if (renderPass == 2 && tags.hasKey("Effect2")) {
|
||||
return modifiers[tags.getInteger("Effect2")];
|
||||
}
|
||||
if (renderPass == 3 && tags.hasKey("Effect3"))
|
||||
{
|
||||
if (renderPass == 3 && tags.hasKey("Effect3")) {
|
||||
return modifiers[tags.getInteger("Effect3")];
|
||||
}
|
||||
}
|
||||
@@ -147,55 +135,46 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected void registerModifiers (IIconRegister iconRegister)
|
||||
{
|
||||
}
|
||||
protected void registerModifiers(IIconRegister iconRegister) {}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean requiresMultipleRenderPasses ()
|
||||
{
|
||||
public boolean requiresMultipleRenderPasses() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderPasses (int metadata)
|
||||
{
|
||||
public int getRenderPasses(int metadata) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean hasEffect (ItemStack par1ItemStack)
|
||||
{
|
||||
public boolean hasEffect(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//ISpecialArmor overrides
|
||||
// ISpecialArmor overrides
|
||||
@Override
|
||||
public ArmorProperties getProperties (EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot)
|
||||
{
|
||||
//Priority, absorbRatio, max
|
||||
if (!armor.hasTagCompound() || source.isUnblockable())
|
||||
return new ArmorProperties(0, 0, 0);
|
||||
public ArmorProperties getProperties(
|
||||
EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) {
|
||||
// Priority, absorbRatio, max
|
||||
if (!armor.hasTagCompound() || source.isUnblockable()) return new ArmorProperties(0, 0, 0);
|
||||
|
||||
NBTTagCompound tags = armor.getTagCompound().getCompoundTag(getBaseTagName());
|
||||
if (tags.getBoolean("Broken"))
|
||||
return new ArmorProperties(0, 0, 0);
|
||||
if (tags.getBoolean("Broken")) return new ArmorProperties(0, 0, 0);
|
||||
|
||||
double current = getProtection(tags);
|
||||
|
||||
return new ArmorProperties(0, current / 100, 100);
|
||||
}
|
||||
|
||||
public double getProtection(ItemStack stack)
|
||||
{
|
||||
public double getProtection(ItemStack stack) {
|
||||
return getProtection(stack.getTagCompound().getCompoundTag(getBaseTagName()));
|
||||
}
|
||||
|
||||
public double getProtection(NBTTagCompound tags)
|
||||
{
|
||||
public double getProtection(NBTTagCompound tags) {
|
||||
float maxDurability = tags.getInteger("TotalDurability");
|
||||
float currentDurability = maxDurability - tags.getInteger("Damage");
|
||||
float ratio = currentDurability / maxDurability;
|
||||
@@ -207,59 +186,46 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getArmorDisplay (EntityPlayer player, ItemStack armor, int slot)
|
||||
{
|
||||
if (slot != 1)
|
||||
{
|
||||
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
|
||||
if (slot != 1) {
|
||||
ItemStack stack = player.getCurrentArmor(1);
|
||||
if (stack != null && stack.getItem() instanceof ArmorCore)
|
||||
return 0;
|
||||
if (stack != null && stack.getItem() instanceof ArmorCore) return 0;
|
||||
return disconnectedArmorDisplay(player, armor, slot);
|
||||
}
|
||||
|
||||
return combinedArmorDisplay(player, armor);
|
||||
}
|
||||
|
||||
protected int disconnectedArmorDisplay (EntityPlayer player, ItemStack armor, int slot)
|
||||
{
|
||||
if (!armor.hasTagCompound())
|
||||
return 0;
|
||||
protected int disconnectedArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
|
||||
if (!armor.hasTagCompound()) return 0;
|
||||
|
||||
NBTTagCompound armorTag = armor.getTagCompound().getCompoundTag(getBaseTagName());
|
||||
if (armorTag.getBoolean("Broken"))
|
||||
return 0;
|
||||
if (armorTag.getBoolean("Broken")) return 0;
|
||||
|
||||
float max = armorTag.getInteger("TotalDurability");
|
||||
float current = max - armorTag.getInteger("Damage");
|
||||
float amount = current / max * 5 + 0.09F;
|
||||
if (slot == 2 && amount < 1)
|
||||
amount = 1;
|
||||
if (slot == 2 && amount < 1) amount = 1;
|
||||
return (int) amount;
|
||||
}
|
||||
|
||||
protected int combinedArmorDisplay (EntityPlayer player, ItemStack legs)
|
||||
{
|
||||
ItemStack[] armors = new ItemStack[] { player.getCurrentArmor(3), player.getCurrentArmor(2), legs, player.getCurrentArmor(0) };
|
||||
protected int combinedArmorDisplay(EntityPlayer player, ItemStack legs) {
|
||||
ItemStack[] armors =
|
||||
new ItemStack[] {player.getCurrentArmor(3), player.getCurrentArmor(2), legs, player.getCurrentArmor(0)};
|
||||
int types = 0;
|
||||
int max = 0;
|
||||
int damage = 0;
|
||||
boolean anyAlive = false;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
for (int i = 0; i < 4; i++) {
|
||||
ItemStack stack = armors[i];
|
||||
if (stack != null && stack.hasTagCompound())
|
||||
{
|
||||
if (stack != null && stack.hasTagCompound()) {
|
||||
NBTTagCompound armorTag = stack.getTagCompound().getCompoundTag(getBaseTagName());
|
||||
if (stack.getItem() instanceof ArmorCore)
|
||||
{
|
||||
if (stack.getItem() instanceof ArmorCore) {
|
||||
types++;
|
||||
max += armorTag.getInteger("TotalDurability");
|
||||
if (armorTag.getBoolean("Broken"))
|
||||
{
|
||||
if (armorTag.getBoolean("Broken")) {
|
||||
damage += armorTag.getInteger("TotalDurability");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
damage += armorTag.getInteger("Damage");
|
||||
anyAlive = true;
|
||||
}
|
||||
@@ -268,30 +234,23 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
}
|
||||
float ratio = ((float) max - (float) damage) / (float) max * (types * 5) + 0.1f;
|
||||
int minimum = anyAlive ? 1 : 0;
|
||||
if (ratio < minimum)
|
||||
ratio = minimum;
|
||||
if (ratio < minimum) ratio = minimum;
|
||||
return (int) ratio;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void damageArmor (EntityLivingBase entity, ItemStack armor, DamageSource source, int damage, int slot)
|
||||
{
|
||||
if (armor.hasTagCompound())
|
||||
{
|
||||
public void damageArmor(EntityLivingBase entity, ItemStack armor, DamageSource source, int damage, int slot) {
|
||||
if (armor.hasTagCompound()) {
|
||||
NBTTagCompound tags = armor.getTagCompound().getCompoundTag(getBaseTagName());
|
||||
if (!tags.getBoolean("Broken"))
|
||||
{
|
||||
if (!tags.getBoolean("Broken")) {
|
||||
int maxDurability = tags.getInteger("TotalDurability");
|
||||
int currentDurability = tags.getInteger("Damage");
|
||||
if (currentDurability + damage > maxDurability)
|
||||
{
|
||||
if (currentDurability + damage > maxDurability) {
|
||||
tags.setInteger("Damage", 0);
|
||||
tags.setBoolean("Broken", true);
|
||||
armor.setItemDamage(0);
|
||||
entity.worldObj.playSound(entity.posX, entity.posY, entity.posZ, "random.break", 1f, 1f, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
tags.setInteger("Damage", currentDurability + damage);
|
||||
armor.setItemDamage(currentDurability + damage);
|
||||
}
|
||||
@@ -301,13 +260,11 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems (Item par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
par3List.add(getDefaultItem());
|
||||
}
|
||||
|
||||
public ItemStack getDefaultItem ()
|
||||
{
|
||||
public ItemStack getDefaultItem() {
|
||||
ItemStack gear = new ItemStack(this, 1, 0);
|
||||
NBTTagCompound baseTag = new NBTTagCompound();
|
||||
|
||||
@@ -322,11 +279,11 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
|
||||
int baseDurability = getDurability();
|
||||
|
||||
tag.setInteger("Damage", 0); //Damage is damage to the armor
|
||||
tag.setInteger("Damage", 0); // Damage is damage to the armor
|
||||
tag.setInteger("TotalDurability", baseDurability);
|
||||
tag.setInteger("BaseDurability", baseDurability);
|
||||
tag.setInteger("BonusDurability", 0); //Modifier
|
||||
tag.setFloat("ModDurability", 0f); //Modifier
|
||||
tag.setInteger("BonusDurability", 0); // Modifier
|
||||
tag.setFloat("ModDurability", 0f); // Modifier
|
||||
tag.setBoolean("Broken", false);
|
||||
tag.setBoolean("Built", true);
|
||||
|
||||
@@ -335,66 +292,55 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
return gear;
|
||||
}
|
||||
|
||||
protected double getFlatDefense ()
|
||||
{
|
||||
protected double getFlatDefense() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected abstract double getBaseDefense ();
|
||||
protected abstract double getBaseDefense();
|
||||
|
||||
protected abstract double getMaxDefense ();
|
||||
protected abstract double getMaxDefense();
|
||||
|
||||
protected abstract int getDurability ();
|
||||
protected abstract int getDurability();
|
||||
|
||||
// Vanilla overrides
|
||||
public boolean isItemTool (ItemStack par1ItemStack)
|
||||
{
|
||||
public boolean isItemTool(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable (ItemStack par1ItemStack, ItemStack par2ItemStack)
|
||||
{
|
||||
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isRepairable ()
|
||||
{
|
||||
public boolean isRepairable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getItemEnchantability ()
|
||||
{
|
||||
public int getItemEnchantability() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean isFull3D ()
|
||||
{
|
||||
public boolean isFull3D() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isValidArmor (ItemStack stack, int armorType, Entity entity)
|
||||
{
|
||||
public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) {
|
||||
return this.armorPart.getPartId() == armorType;
|
||||
}
|
||||
|
||||
/* Proper stack damage */
|
||||
public int getItemMaxDamageFromStack (ItemStack stack)
|
||||
{
|
||||
public int getItemMaxDamageFromStack(ItemStack stack) {
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
if (tags == null)
|
||||
{
|
||||
if (tags == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return tags.getCompoundTag(getBaseTagName()).getInteger("TotalDurability");
|
||||
}
|
||||
|
||||
public int getItemMaxDamageFromStackForDisplay (ItemStack stack)
|
||||
{
|
||||
public int getItemMaxDamageFromStackForDisplay(ItemStack stack) {
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
if (tags == null)
|
||||
{
|
||||
if (tags == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -405,52 +351,43 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
|
||||
if (!stack.hasTagCompound()) return;
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag(getBaseTagName());
|
||||
double protection = 0;
|
||||
if (!tags.getBoolean("Broken"))
|
||||
{
|
||||
if (!tags.getBoolean("Broken")) {
|
||||
protection = getProtection(tags);
|
||||
}
|
||||
if (protection > 0)
|
||||
list.add("\u00a77" + StatCollector.translateToLocal("armor.core.protection") + df.format(protection) + "%");
|
||||
else
|
||||
list.add("\u00A7o" + StatCollector.translateToLocal("armor.core.broken"));
|
||||
else list.add("\u00A7o" + StatCollector.translateToLocal("armor.core.broken"));
|
||||
|
||||
boolean displayToolTips = true;
|
||||
int tipNum = 0;
|
||||
while (displayToolTips)
|
||||
{
|
||||
while (displayToolTips) {
|
||||
tipNum++;
|
||||
String tooltip = "Tooltip" + tipNum;
|
||||
if (tags.hasKey(tooltip))
|
||||
{
|
||||
if (tags.hasKey(tooltip)) {
|
||||
String tipName = tags.getString(tooltip);
|
||||
// let's see if we can translate it somehow
|
||||
// strip color information
|
||||
String locString = "modifier.tooltip." + EnumChatFormatting.getTextWithoutFormattingCodes(tipName);
|
||||
locString = locString.replace(" ", "");
|
||||
if(StatCollector.canTranslate(locString))
|
||||
tipName = tipName.replace(EnumChatFormatting.getTextWithoutFormattingCodes(tipName), StatCollector.translateToLocal(locString));
|
||||
if (!tipName.equals(""))
|
||||
list.add(tipName);
|
||||
}
|
||||
else
|
||||
displayToolTips = false;
|
||||
if (StatCollector.canTranslate(locString))
|
||||
tipName = tipName.replace(
|
||||
EnumChatFormatting.getTextWithoutFormattingCodes(tipName),
|
||||
StatCollector.translateToLocal(locString));
|
||||
if (!tipName.equals("")) list.add(tipName);
|
||||
} else displayToolTips = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Prevent armor from dying */
|
||||
public boolean hasCustomEntity (ItemStack stack)
|
||||
{
|
||||
public boolean hasCustomEntity(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Entity createEntity (World world, Entity location, ItemStack itemstack)
|
||||
{
|
||||
public Entity createEntity(World world, Entity location, ItemStack itemstack) {
|
||||
return new FancyEntityItem(world, location, itemstack);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,25 +5,20 @@ import net.minecraft.item.*;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.modifier.*;
|
||||
|
||||
public abstract class ArmorMod extends ItemModifier
|
||||
{
|
||||
public abstract class ArmorMod extends ItemModifier {
|
||||
protected final EnumSet<ArmorPart> armorTypes;
|
||||
|
||||
public ArmorMod(int effect, String dataKey, EnumSet<ArmorPart> armorTypes, ItemStack[] items)
|
||||
{
|
||||
public ArmorMod(int effect, String dataKey, EnumSet<ArmorPart> armorTypes, ItemStack[] items) {
|
||||
super(items, effect, dataKey);
|
||||
this.armorTypes = armorTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack armor, ItemStack[] input)
|
||||
{
|
||||
protected boolean canModify(ItemStack armor, ItemStack[] input) {
|
||||
Item i = armor.getItem();
|
||||
if (!(i instanceof ArmorCore))
|
||||
return false;
|
||||
if (!(i instanceof ArmorCore)) return false;
|
||||
ArmorCore item = (ArmorCore) armor.getItem();
|
||||
if (armorTypes.contains(item.armorPart))
|
||||
{
|
||||
if (armorTypes.contains(item.armorPart)) {
|
||||
NBTTagCompound tags = getModifierTag(armor);
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
}
|
||||
@@ -31,8 +26,7 @@ public abstract class ArmorMod extends ItemModifier
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validType (IModifyable type)
|
||||
{
|
||||
public boolean validType(IModifyable type) {
|
||||
return type.getModifyType().equals("Armor") || type.getModifyType().equals("Clothing");
|
||||
}
|
||||
}
|
||||
@@ -3,17 +3,16 @@ package tconstruct.library.armor;
|
||||
import java.util.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class ArmorModTypeFilter extends ArmorMod
|
||||
{
|
||||
public abstract class ArmorModTypeFilter extends ArmorMod {
|
||||
public final List<Integer> increase;
|
||||
|
||||
public ArmorModTypeFilter(int effect, String dataKey, EnumSet<ArmorPart> armorTypes, ItemStack[] items, int[] values)
|
||||
{
|
||||
public ArmorModTypeFilter(
|
||||
int effect, String dataKey, EnumSet<ArmorPart> armorTypes, ItemStack[] items, int[] values) {
|
||||
super(effect, dataKey, armorTypes, items);
|
||||
assert items.length == values.length : "Itemstacks and their values for armor modifiers must be the same length";
|
||||
assert items.length == values.length
|
||||
: "Itemstacks and their values for armor modifiers must be the same length";
|
||||
this.increase = new ArrayList<Integer>();
|
||||
for (int i = 0; i < values.length; i++)
|
||||
{
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
increase.add(values[i]);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +20,7 @@ public abstract class ArmorModTypeFilter extends ArmorMod
|
||||
/**
|
||||
* Checks to see if the inputs match the stored items Note: Filters types,
|
||||
* doesn't care about amount
|
||||
*
|
||||
*
|
||||
* @param input
|
||||
* The ItemStacks to compare against
|
||||
* @param tool
|
||||
@@ -29,61 +28,40 @@ public abstract class ArmorModTypeFilter extends ArmorMod
|
||||
* @return Whether the recipe matches the input
|
||||
*/
|
||||
@Override
|
||||
public boolean matches (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
if (!canModify(tool, input))
|
||||
return false;
|
||||
public boolean matches(ItemStack[] input, ItemStack tool) {
|
||||
if (!canModify(tool, input)) return false;
|
||||
|
||||
boolean minimumMatch = false;
|
||||
for (ItemStack inputStack : input)
|
||||
{
|
||||
if (inputStack == null)
|
||||
continue;
|
||||
for (ItemStack inputStack : input) {
|
||||
if (inputStack == null) continue;
|
||||
|
||||
boolean match = false;
|
||||
for (Object check : stacks)
|
||||
{
|
||||
for (Object check : stacks) {
|
||||
ItemStack stack = (ItemStack) check;
|
||||
if (stack.getItemDamage() == Short.MAX_VALUE)
|
||||
{
|
||||
if (this.areItemsEquivalent(inputStack, stack))
|
||||
match = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.areItemStacksEquivalent(inputStack, stack))
|
||||
match = true;
|
||||
if (stack.getItemDamage() == Short.MAX_VALUE) {
|
||||
if (this.areItemsEquivalent(inputStack, stack)) match = true;
|
||||
} else {
|
||||
if (this.areItemStacksEquivalent(inputStack, stack)) match = true;
|
||||
}
|
||||
}
|
||||
if (!match)
|
||||
return false;
|
||||
if (!match) return false;
|
||||
|
||||
minimumMatch = true;
|
||||
}
|
||||
return minimumMatch;
|
||||
}
|
||||
|
||||
public int matchingAmount (ItemStack[] input)
|
||||
{
|
||||
public int matchingAmount(ItemStack[] input) {
|
||||
int amount = 0;
|
||||
for (ItemStack inputStack : input)
|
||||
{
|
||||
if (inputStack == null)
|
||||
continue;
|
||||
else
|
||||
{
|
||||
for (int iter = 0; iter < stacks.size(); iter++)
|
||||
{
|
||||
for (ItemStack inputStack : input) {
|
||||
if (inputStack == null) continue;
|
||||
else {
|
||||
for (int iter = 0; iter < stacks.size(); iter++) {
|
||||
ItemStack stack = (ItemStack) stacks.get(iter);
|
||||
if (stack.getItemDamage() == Short.MAX_VALUE)
|
||||
{
|
||||
if (this.areItemsEquivalent(inputStack, stack))
|
||||
amount += increase.get(iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.areItemStacksEquivalent(inputStack, stack))
|
||||
amount += increase.get(iter);
|
||||
if (stack.getItemDamage() == Short.MAX_VALUE) {
|
||||
if (this.areItemsEquivalent(inputStack, stack)) amount += increase.get(iter);
|
||||
} else {
|
||||
if (this.areItemStacksEquivalent(inputStack, stack)) amount += increase.get(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,29 +69,26 @@ public abstract class ArmorModTypeFilter extends ArmorMod
|
||||
return amount;
|
||||
}
|
||||
|
||||
public int matchingItems (ItemStack[] input)
|
||||
{
|
||||
public int matchingItems(ItemStack[] input) {
|
||||
int amount = 0;
|
||||
for (ItemStack inputStack : input)
|
||||
{
|
||||
if (inputStack != null)
|
||||
amount++;
|
||||
for (ItemStack inputStack : input) {
|
||||
if (inputStack != null) amount++;
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new itemstack to the list for increases
|
||||
*
|
||||
*
|
||||
* @param stack
|
||||
* ItemStack to compare against
|
||||
* @param amount
|
||||
* Amount to increase
|
||||
*/
|
||||
public void addStackToMatchList (ItemStack stack, int amount)
|
||||
{
|
||||
public void addStackToMatchList(ItemStack stack, int amount) {
|
||||
if (stack == null)
|
||||
throw new NullPointerException("ItemStack added to " + this.getClass().getSimpleName() + " cannot be null.");
|
||||
throw new NullPointerException(
|
||||
"ItemStack added to " + this.getClass().getSimpleName() + " cannot be null.");
|
||||
stacks.add(stack);
|
||||
increase.add(amount);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
package tconstruct.library.armor;
|
||||
|
||||
public enum ArmorPart
|
||||
{
|
||||
|
||||
Head(0), Chest(1), Legs(2), Feet(3);
|
||||
public enum ArmorPart {
|
||||
Head(0),
|
||||
Chest(1),
|
||||
Legs(2),
|
||||
Feet(3);
|
||||
|
||||
private final int partID;
|
||||
|
||||
private ArmorPart(int partID)
|
||||
{
|
||||
private ArmorPart(int partID) {
|
||||
this.partID = partID;
|
||||
}
|
||||
|
||||
public int getPartId ()
|
||||
{
|
||||
public int getPartId() {
|
||||
return this.partID;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,52 +9,50 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.*;
|
||||
|
||||
final class BehaviorDispenseArmorCopy extends BehaviorDefaultDispenseItem
|
||||
{
|
||||
final class BehaviorDispenseArmorCopy extends BehaviorDefaultDispenseItem {
|
||||
/**
|
||||
* Dispense the specified stack, play the dispense sound and spawn
|
||||
* particles.
|
||||
*/
|
||||
@Override
|
||||
protected ItemStack dispenseStack (IBlockSource par1IBlockSource, ItemStack par2ItemStack)
|
||||
{
|
||||
protected ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) {
|
||||
EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata());
|
||||
int i = par1IBlockSource.getXInt() + enumfacing.getFrontOffsetX();
|
||||
int j = par1IBlockSource.getYInt() + enumfacing.getFrontOffsetY();
|
||||
int k = par1IBlockSource.getZInt() + enumfacing.getFrontOffsetZ();
|
||||
AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox((double) i, (double) j, (double) k, (double) (i + 1), (double) (j + 1), (double) (k + 1));
|
||||
List list = par1IBlockSource.getWorld().selectEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb, new IEntitySelector.ArmoredMob(par2ItemStack));
|
||||
AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(
|
||||
(double) i, (double) j, (double) k, (double) (i + 1), (double) (j + 1), (double) (k + 1));
|
||||
List list = par1IBlockSource
|
||||
.getWorld()
|
||||
.selectEntitiesWithinAABB(
|
||||
EntityLivingBase.class, axisalignedbb, new IEntitySelector.ArmoredMob(par2ItemStack));
|
||||
|
||||
if (list.size() > 0)
|
||||
{
|
||||
if (list.size() > 0) {
|
||||
EntityLivingBase entitylivingbase = (EntityLivingBase) list.get(0);
|
||||
int l = entitylivingbase instanceof EntityPlayer ? 1 : 0;
|
||||
int i1 = EntityLiving.getArmorPosition(par2ItemStack);
|
||||
ItemStack itemstack1 = par2ItemStack.copy();
|
||||
itemstack1.stackSize = 1;
|
||||
entitylivingbase.setCurrentItemOrArmor(i1, itemstack1); // BUGFIX
|
||||
// Forge:
|
||||
// Vanilla
|
||||
// bug fix
|
||||
// associated
|
||||
// with
|
||||
// fixed
|
||||
// setCurrentItemOrArmor
|
||||
// indexs
|
||||
// for
|
||||
// players.
|
||||
// Forge:
|
||||
// Vanilla
|
||||
// bug fix
|
||||
// associated
|
||||
// with
|
||||
// fixed
|
||||
// setCurrentItemOrArmor
|
||||
// indexs
|
||||
// for
|
||||
// players.
|
||||
|
||||
if (entitylivingbase instanceof EntityLiving)
|
||||
{
|
||||
if (entitylivingbase instanceof EntityLiving) {
|
||||
((EntityLiving) entitylivingbase).setEquipmentDropChance(i1, 2.0F);
|
||||
}
|
||||
|
||||
--par2ItemStack.stackSize;
|
||||
return par2ItemStack;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return super.dispenseStack(par1IBlockSource, par2ItemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,14 @@
|
||||
package tconstruct.library.client;
|
||||
|
||||
public class FluidRenderProperties
|
||||
{
|
||||
public class FluidRenderProperties {
|
||||
|
||||
//Constant defaults
|
||||
// Constant defaults
|
||||
public static final FluidRenderProperties DEFAULT_TABLE = new FluidRenderProperties(Applications.TABLE);
|
||||
public static final FluidRenderProperties DEFAULT_BASIN = new FluidRenderProperties(Applications.BASIN);
|
||||
|
||||
public float minHeight, maxHeight, minX, maxX, minZ, maxZ;
|
||||
|
||||
public FluidRenderProperties(float minHeight, float maxHeight, float minX, float maxX, float minZ, float maxZ)
|
||||
{
|
||||
public FluidRenderProperties(float minHeight, float maxHeight, float minX, float maxX, float minZ, float maxZ) {
|
||||
this.minHeight = minHeight;
|
||||
this.maxHeight = maxHeight;
|
||||
this.minX = minX;
|
||||
@@ -19,39 +17,32 @@ public class FluidRenderProperties
|
||||
this.maxZ = maxZ;
|
||||
}
|
||||
|
||||
public FluidRenderProperties(float minHeight, float maxHeight, Applications defaults)
|
||||
{
|
||||
public FluidRenderProperties(float minHeight, float maxHeight, Applications defaults) {
|
||||
this(minHeight, maxHeight, defaults.minX, defaults.maxX, defaults.minZ, defaults.maxZ);
|
||||
}
|
||||
|
||||
public FluidRenderProperties(float minHeight, float maxHeight, float minX, float maxX, Applications defaults)
|
||||
{
|
||||
public FluidRenderProperties(float minHeight, float maxHeight, float minX, float maxX, Applications defaults) {
|
||||
this(minHeight, maxHeight, minX, maxX, defaults.minZ, defaults.maxZ);
|
||||
}
|
||||
|
||||
public FluidRenderProperties(Applications defaults, float minX, float maxX)
|
||||
{
|
||||
public FluidRenderProperties(Applications defaults, float minX, float maxX) {
|
||||
this(defaults.minHeight, defaults.maxHeight, minX, maxX, defaults.minZ, defaults.maxZ);
|
||||
}
|
||||
|
||||
public FluidRenderProperties(Applications defaults, float minX, float maxX, float minZ, float maxZ)
|
||||
{
|
||||
public FluidRenderProperties(Applications defaults, float minX, float maxX, float minZ, float maxZ) {
|
||||
this(defaults.minHeight, defaults.maxHeight, minX, maxX, minZ, maxZ);
|
||||
}
|
||||
|
||||
public FluidRenderProperties(Applications defaults)
|
||||
{
|
||||
public FluidRenderProperties(Applications defaults) {
|
||||
this(defaults.minHeight, defaults.maxHeight, defaults.minX, defaults.maxX, defaults.minZ, defaults.maxZ);
|
||||
}
|
||||
|
||||
public static enum Applications
|
||||
{
|
||||
TABLE(0.9375F, 1F, 0.0625F, 0.9375F, 0.062F, 0.9375F), BASIN(0.25F, 0.95F, 0.0625F, 0.9375F, 0.0625F, 0.9375F);
|
||||
|
||||
public static enum Applications {
|
||||
TABLE(0.9375F, 1F, 0.0625F, 0.9375F, 0.062F, 0.9375F),
|
||||
BASIN(0.25F, 0.95F, 0.0625F, 0.9375F, 0.0625F, 0.9375F);
|
||||
public float minHeight, maxHeight, minX, maxX, minZ, maxZ;
|
||||
|
||||
Applications(float minHeight, float maxHeight, float minX, float maxX, float minZ, float maxZ)
|
||||
{
|
||||
Applications(float minHeight, float maxHeight, float minX, float maxX, float minZ, float maxZ) {
|
||||
this.minHeight = minHeight;
|
||||
this.maxHeight = maxHeight;
|
||||
this.minX = minX;
|
||||
@@ -60,4 +51,4 @@ public class FluidRenderProperties
|
||||
this.maxZ = maxZ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,12 @@
|
||||
package tconstruct.library.client;
|
||||
|
||||
public class GuiElement
|
||||
{
|
||||
public class GuiElement {
|
||||
public final int buttonIconX;
|
||||
public final int buttonIconY;
|
||||
public final String domain;
|
||||
public final String texture;
|
||||
|
||||
public GuiElement(int buttonIconX, int buttonIconY, String domain, String texture)
|
||||
{
|
||||
public GuiElement(int buttonIconX, int buttonIconY, String domain, String texture) {
|
||||
this.buttonIconX = buttonIconX;
|
||||
this.buttonIconY = buttonIconY;
|
||||
this.domain = domain;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package tconstruct.library.client;
|
||||
|
||||
public class StencilGuiElement extends GuiElement
|
||||
{
|
||||
public class StencilGuiElement extends GuiElement {
|
||||
public final int stencilIndex;
|
||||
|
||||
public StencilGuiElement(int buttonIconX, int buttonIconY, int stencilIndex, String domain, String texture)
|
||||
{
|
||||
public StencilGuiElement(int buttonIconX, int buttonIconY, int stencilIndex, String domain, String texture) {
|
||||
super(buttonIconX, buttonIconY, domain, texture);
|
||||
|
||||
this.stencilIndex = stencilIndex;
|
||||
|
||||
@@ -8,8 +8,7 @@ import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.crafting.ModifyBuilder;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public class TConstructClientRegistry
|
||||
{
|
||||
public class TConstructClientRegistry {
|
||||
public static ArrayList<StencilGuiElement> stencilButtons = new ArrayList<StencilGuiElement>();
|
||||
public static ArrayList<StencilGuiElement> stencilButtons2 = new ArrayList<StencilGuiElement>();
|
||||
public static ArrayList<ToolGuiElement> toolButtons = new ArrayList<ToolGuiElement>(20);
|
||||
@@ -17,16 +16,13 @@ public class TConstructClientRegistry
|
||||
public static Map<String, ItemStack> manualIcons = new HashMap<String, ItemStack>();
|
||||
public static ItemStack defaultStack = new ItemStack(Items.iron_ingot);
|
||||
|
||||
public static void addMaterialRenderMapping (int materialID, String domain, String renderName, boolean useDefaultFolder)
|
||||
{
|
||||
for (ToolCore tool : TConstructRegistry.getToolMapping())
|
||||
{
|
||||
public static void addMaterialRenderMapping(
|
||||
int materialID, String domain, String renderName, boolean useDefaultFolder) {
|
||||
for (ToolCore tool : TConstructRegistry.getToolMapping()) {
|
||||
String[] toolIcons = new String[tool.getPartAmount() + 1];
|
||||
for (int i = 0; i < tool.getPartAmount() + 1; i++)
|
||||
{
|
||||
for (int i = 0; i < tool.getPartAmount() + 1; i++) {
|
||||
String icon = domain + ":";
|
||||
if (useDefaultFolder)
|
||||
icon += tool.getDefaultFolder() + "/";
|
||||
if (useDefaultFolder) icon += tool.getDefaultFolder() + "/";
|
||||
icon += renderName + tool.getIconSuffix(i);
|
||||
toolIcons[i] = icon;
|
||||
}
|
||||
@@ -34,73 +30,67 @@ public class TConstructClientRegistry
|
||||
}
|
||||
}
|
||||
|
||||
public static void addAlternateMaterialRenderMapping (ToolCore tool, int materialID, String domain, String renderName, boolean useDefaultFolder)
|
||||
{
|
||||
public static void addAlternateMaterialRenderMapping(
|
||||
ToolCore tool, int materialID, String domain, String renderName, boolean useDefaultFolder) {
|
||||
String[] toolIcons = new String[tool.getPartAmount() + 1];
|
||||
for (int i = 0; i < tool.getPartAmount() + 1; i++)
|
||||
{
|
||||
for (int i = 0; i < tool.getPartAmount() + 1; i++) {
|
||||
String icon = domain + ":";
|
||||
if (useDefaultFolder)
|
||||
icon += tool.getDefaultFolder() + "/";
|
||||
if (useDefaultFolder) icon += tool.getDefaultFolder() + "/";
|
||||
icon += renderName + tool.getIconSuffix(i);
|
||||
toolIcons[i] = icon;
|
||||
}
|
||||
tool.registerAlternatePartPaths(materialID, toolIcons);
|
||||
}
|
||||
|
||||
public static void addEffectRenderMapping (ToolCore tool, int materialID, String domain, String renderName, boolean useDefaultFolder)
|
||||
{
|
||||
public static void addEffectRenderMapping(
|
||||
ToolCore tool, int materialID, String domain, String renderName, boolean useDefaultFolder) {
|
||||
String icon = domain + ":";
|
||||
if (useDefaultFolder)
|
||||
icon += tool.getDefaultFolder() + "/";
|
||||
if (useDefaultFolder) icon += tool.getDefaultFolder() + "/";
|
||||
icon += renderName + tool.getEffectSuffix();
|
||||
tool.registerEffectPath(materialID, icon);
|
||||
}
|
||||
|
||||
public static void addEffectRenderMapping (int materialID, String domain, String renderName, boolean useDefaultFolder)
|
||||
{
|
||||
for (ToolCore tool : TConstructRegistry.getToolMapping())
|
||||
{
|
||||
public static void addEffectRenderMapping(
|
||||
int materialID, String domain, String renderName, boolean useDefaultFolder) {
|
||||
for (ToolCore tool : TConstructRegistry.getToolMapping()) {
|
||||
String icon = domain + ":";
|
||||
if (useDefaultFolder)
|
||||
icon += tool.getDefaultFolder() + "/";
|
||||
if (useDefaultFolder) icon += tool.getDefaultFolder() + "/";
|
||||
icon += renderName + tool.getEffectSuffix();
|
||||
tool.registerEffectPath(materialID, icon);
|
||||
}
|
||||
}
|
||||
|
||||
public static void addSingleEffectRenderMapping (ToolCore tool, int materialID, String domain, String renderName, boolean useDefaultFolder)
|
||||
{
|
||||
public static void addSingleEffectRenderMapping(
|
||||
ToolCore tool, int materialID, String domain, String renderName, boolean useDefaultFolder) {
|
||||
String icon = domain + ":";
|
||||
if (useDefaultFolder)
|
||||
icon += tool.getDefaultFolder() + "/";
|
||||
if (useDefaultFolder) icon += tool.getDefaultFolder() + "/";
|
||||
icon += renderName + tool.getEffectSuffix();
|
||||
tool.registerEffectPath(materialID, icon);
|
||||
}
|
||||
|
||||
public static void registerManualModifier (String name, ItemStack output, ItemStack topinput)
|
||||
{
|
||||
public static void registerManualModifier(String name, ItemStack output, ItemStack topinput) {
|
||||
registerManualModifier(name, output, topinput, null);
|
||||
}
|
||||
|
||||
public static void registerManualModifier (String name, ItemStack output, ItemStack topinput, ItemStack bottominput)
|
||||
{
|
||||
public static void registerManualModifier(
|
||||
String name, ItemStack output, ItemStack topinput, ItemStack bottominput) {
|
||||
ItemStack[] recipe = new ItemStack[3];
|
||||
recipe[0] = ModifyBuilder.instance.modifyItem(output, new ItemStack[] { topinput, bottominput });//ToolBuilder.instance.buildTool(output, topinput, bottominput, "");
|
||||
recipe[0] = ModifyBuilder.instance.modifyItem(output, new ItemStack[] {topinput, bottominput
|
||||
}); // ToolBuilder.instance.buildTool(output, topinput, bottominput, "");
|
||||
recipe[1] = topinput;
|
||||
recipe[2] = bottominput;
|
||||
MantleClientRegistry.recipeIcons.put(name, recipe);
|
||||
}
|
||||
|
||||
public static void registerManualModifier (String name, ItemStack output, ItemStack input1, ItemStack input2, ItemStack input3)
|
||||
{
|
||||
public static void registerManualModifier(
|
||||
String name, ItemStack output, ItemStack input1, ItemStack input2, ItemStack input3) {
|
||||
registerManualModifier(name, output, input1, input2, input3, null);
|
||||
}
|
||||
|
||||
public static void registerManualModifier (String name, ItemStack output, ItemStack input1, ItemStack input2, ItemStack input3, ItemStack input4)
|
||||
{
|
||||
public static void registerManualModifier(
|
||||
String name, ItemStack output, ItemStack input1, ItemStack input2, ItemStack input3, ItemStack input4) {
|
||||
ItemStack[] recipe = new ItemStack[5];
|
||||
recipe[0] = ModifyBuilder.instance.modifyItem(output, new ItemStack[] { input1, input2, input3, input4 });
|
||||
recipe[0] = ModifyBuilder.instance.modifyItem(output, new ItemStack[] {input1, input2, input3, input4});
|
||||
recipe[1] = input1;
|
||||
recipe[2] = input2;
|
||||
recipe[3] = input3;
|
||||
@@ -108,8 +98,7 @@ public class TConstructClientRegistry
|
||||
MantleClientRegistry.recipeIcons.put(name, recipe);
|
||||
}
|
||||
|
||||
public static void registerManualSmeltery (String name, ItemStack output, ItemStack liquid, ItemStack cast)
|
||||
{
|
||||
public static void registerManualSmeltery(String name, ItemStack output, ItemStack liquid, ItemStack cast) {
|
||||
ItemStack[] recipe = new ItemStack[3];
|
||||
recipe[0] = output;
|
||||
recipe[1] = liquid;
|
||||
@@ -117,50 +106,60 @@ public class TConstructClientRegistry
|
||||
MantleClientRegistry.recipeIcons.put(name, recipe);
|
||||
}
|
||||
|
||||
//Gui
|
||||
public static void addStencilButton (StencilGuiElement element)
|
||||
{
|
||||
// Gui
|
||||
public static void addStencilButton(StencilGuiElement element) {
|
||||
stencilButtons.add(element);
|
||||
}
|
||||
|
||||
public static void addStencilButton (int xButton, int yButton, int index, String domain, String texture)
|
||||
{
|
||||
public static void addStencilButton(int xButton, int yButton, int index, String domain, String texture) {
|
||||
stencilButtons.add(new StencilGuiElement(xButton, yButton, index, domain, texture));
|
||||
}
|
||||
|
||||
public static void addStencilButton2 (StencilGuiElement element)
|
||||
{
|
||||
public static void addStencilButton2(StencilGuiElement element) {
|
||||
stencilButtons.add(element);
|
||||
}
|
||||
|
||||
// adds a button to the right side of the stencil table
|
||||
public static void addStencilButton2 (int xButton, int yButton, int index, String domain, String texture)
|
||||
{
|
||||
public static void addStencilButton2(int xButton, int yButton, int index, String domain, String texture) {
|
||||
stencilButtons2.add(new StencilGuiElement(xButton, yButton, index, domain, texture));
|
||||
}
|
||||
|
||||
public static void addToolButton (ToolGuiElement element)
|
||||
{
|
||||
public static void addToolButton(ToolGuiElement element) {
|
||||
toolButtons.add(element);
|
||||
}
|
||||
|
||||
public static void addToolButton (int slotType, int xButton, int yButton, int[] xIcons, int[] yIcons, String title, String body, String domain, String texture)
|
||||
{
|
||||
public static void addToolButton(
|
||||
int slotType,
|
||||
int xButton,
|
||||
int yButton,
|
||||
int[] xIcons,
|
||||
int[] yIcons,
|
||||
String title,
|
||||
String body,
|
||||
String domain,
|
||||
String texture) {
|
||||
toolButtons.add(new ToolGuiElement(slotType, xButton, yButton, xIcons, yIcons, title, body, domain, texture));
|
||||
}
|
||||
|
||||
public static void addTierTwoButton (ToolGuiElement element)
|
||||
{
|
||||
public static void addTierTwoButton(ToolGuiElement element) {
|
||||
tierTwoButtons.add(element);
|
||||
}
|
||||
|
||||
public static void addTierTwoButton (int slotType, int xButton, int yButton, int[] xIcons, int[] yIcons, String title, String body, String domain, String texture)
|
||||
{
|
||||
tierTwoButtons.add(new ToolGuiElement(slotType, xButton, yButton, xIcons, yIcons, title, body, domain, texture));
|
||||
public static void addTierTwoButton(
|
||||
int slotType,
|
||||
int xButton,
|
||||
int yButton,
|
||||
int[] xIcons,
|
||||
int[] yIcons,
|
||||
String title,
|
||||
String body,
|
||||
String domain,
|
||||
String texture) {
|
||||
tierTwoButtons.add(
|
||||
new ToolGuiElement(slotType, xButton, yButton, xIcons, yIcons, title, body, domain, texture));
|
||||
}
|
||||
|
||||
public static ArrayList<ToolGuiElement> getToolButtons ()
|
||||
{
|
||||
public static ArrayList<ToolGuiElement> getToolButtons() {
|
||||
return toolButtons;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,13 @@
|
||||
package tconstruct.library.client;
|
||||
|
||||
public class ToolGuiElement extends GuiElement
|
||||
{
|
||||
public class ToolGuiElement extends GuiElement {
|
||||
public final int slotType;
|
||||
public final int[] iconsX;
|
||||
public final int[] iconsY;
|
||||
public final String title;
|
||||
public final String body;
|
||||
|
||||
public ToolGuiElement(int st, int bx, int by, int[] xi, int[] yi, String t, String b, String d, String tex)
|
||||
{
|
||||
public ToolGuiElement(int st, int bx, int by, int[] xi, int[] yi, String t, String b, String d, String tex) {
|
||||
super(bx, by, d, tex);
|
||||
slotType = st;
|
||||
iconsX = xi;
|
||||
|
||||
@@ -2,7 +2,6 @@ package tconstruct.library.component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IComponentHolder
|
||||
{
|
||||
public List<LogicComponent> getComponents ();
|
||||
public interface IComponentHolder {
|
||||
public List<LogicComponent> getComponents();
|
||||
}
|
||||
@@ -3,32 +3,22 @@ package tconstruct.library.component;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class LogicComponent
|
||||
{
|
||||
public class LogicComponent {
|
||||
protected World world;
|
||||
|
||||
public void setWorld (World world)
|
||||
{
|
||||
public void setWorld(World world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tags) {
|
||||
readNetworkNBT(tags);
|
||||
}
|
||||
|
||||
public void readNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
public void readNetworkNBT(NBTTagCompound tags) {}
|
||||
|
||||
}
|
||||
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
public void writeToNBT(NBTTagCompound tags) {
|
||||
writeNetworkNBT(tags);
|
||||
}
|
||||
|
||||
public void writeNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
public void writeNetworkNBT(NBTTagCompound tags) {}
|
||||
}
|
||||
@@ -5,164 +5,122 @@ import net.minecraft.nbt.*;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import tconstruct.library.crafting.Smeltery;
|
||||
|
||||
public class MultiFluidTank extends LogicComponent implements IFluidTank
|
||||
{
|
||||
public class MultiFluidTank extends LogicComponent implements IFluidTank {
|
||||
public ArrayList<FluidStack> fluidlist = new ArrayList<FluidStack>();
|
||||
protected int maxLiquid;
|
||||
protected int currentLiquid;
|
||||
|
||||
public MultiFluidTank()
|
||||
{
|
||||
}
|
||||
public MultiFluidTank() {}
|
||||
|
||||
public MultiFluidTank(int max)
|
||||
{
|
||||
public MultiFluidTank(int max) {
|
||||
maxLiquid = max;
|
||||
}
|
||||
|
||||
public void setCapacity (int i)
|
||||
{
|
||||
public void setCapacity(int i) {
|
||||
maxLiquid = i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity ()
|
||||
{
|
||||
public int getCapacity() {
|
||||
return maxLiquid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFluidAmount ()
|
||||
{
|
||||
public int getFluidAmount() {
|
||||
return currentLiquid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (int maxDrain, boolean doDrain)
|
||||
{
|
||||
if (fluidlist.size() == 0)
|
||||
return null;
|
||||
public FluidStack drain(int maxDrain, boolean doDrain) {
|
||||
if (fluidlist.size() == 0) return null;
|
||||
|
||||
FluidStack liquid = fluidlist.get(0);
|
||||
if (liquid != null)
|
||||
{
|
||||
if (liquid.amount - maxDrain <= 0)
|
||||
{
|
||||
if (liquid != null) {
|
||||
if (liquid.amount - maxDrain <= 0) {
|
||||
FluidStack liq = liquid.copy();
|
||||
if (doDrain)
|
||||
{
|
||||
if (doDrain) {
|
||||
fluidlist.remove(liquid);
|
||||
currentLiquid = 0;
|
||||
}
|
||||
return liq;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (doDrain)
|
||||
{
|
||||
} else {
|
||||
if (doDrain) {
|
||||
liquid.amount -= maxDrain;
|
||||
currentLiquid -= maxDrain;
|
||||
}
|
||||
return new FluidStack(liquid.getFluid(), maxDrain, liquid.tag);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return new FluidStack(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill (FluidStack resource, boolean doFill)
|
||||
{
|
||||
if (resource != null && currentLiquid < maxLiquid)
|
||||
{
|
||||
if (resource.amount + currentLiquid > maxLiquid)
|
||||
resource.amount = maxLiquid - currentLiquid;
|
||||
public int fill(FluidStack resource, boolean doFill) {
|
||||
if (resource != null && currentLiquid < maxLiquid) {
|
||||
if (resource.amount + currentLiquid > maxLiquid) resource.amount = maxLiquid - currentLiquid;
|
||||
int amount = resource.amount;
|
||||
|
||||
if (doFill)
|
||||
{
|
||||
if (addFluidToTank(resource, false))
|
||||
{
|
||||
if (doFill) {
|
||||
if (addFluidToTank(resource, false)) {
|
||||
ArrayList alloys = Smeltery.mixMetals(fluidlist);
|
||||
for (int al = 0; al < alloys.size(); al++)
|
||||
{
|
||||
for (int al = 0; al < alloys.size(); al++) {
|
||||
FluidStack liquid = (FluidStack) alloys.get(al);
|
||||
addFluidToTank(liquid, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
} else return 0;
|
||||
}
|
||||
|
||||
public boolean addFluidToTank (FluidStack liquid, boolean first)
|
||||
{
|
||||
if (fluidlist.size() == 0)
|
||||
{
|
||||
public boolean addFluidToTank(FluidStack liquid, boolean first) {
|
||||
if (fluidlist.size() == 0) {
|
||||
fluidlist.add(liquid.copy());
|
||||
currentLiquid += liquid.amount;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (liquid.amount + currentLiquid > maxLiquid)
|
||||
return false;
|
||||
} else {
|
||||
if (liquid.amount + currentLiquid > maxLiquid) return false;
|
||||
|
||||
currentLiquid += liquid.amount;
|
||||
boolean added = false;
|
||||
for (int i = 0; i < fluidlist.size(); i++)
|
||||
{
|
||||
for (int i = 0; i < fluidlist.size(); i++) {
|
||||
FluidStack l = fluidlist.get(i);
|
||||
if (l.isFluidEqual(liquid))
|
||||
{
|
||||
if (l.isFluidEqual(liquid)) {
|
||||
l.amount += liquid.amount;
|
||||
added = true;
|
||||
}
|
||||
if (l.amount <= 0)
|
||||
{
|
||||
if (l.amount <= 0) {
|
||||
fluidlist.remove(l);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
if (!added)
|
||||
{
|
||||
if (first)
|
||||
fluidlist.add(0, liquid.copy());
|
||||
else
|
||||
fluidlist.add(liquid.copy());
|
||||
if (!added) {
|
||||
if (first) fluidlist.add(0, liquid.copy());
|
||||
else fluidlist.add(liquid.copy());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getFluid ()
|
||||
{
|
||||
if (fluidlist.size() == 0)
|
||||
return null;
|
||||
public FluidStack getFluid() {
|
||||
if (fluidlist.size() == 0) return null;
|
||||
return fluidlist.get(0);
|
||||
}
|
||||
|
||||
public List<FluidStack> getAllFluids ()
|
||||
{
|
||||
public List<FluidStack> getAllFluids() {
|
||||
return fluidlist;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo getInfo ()
|
||||
{
|
||||
public FluidTankInfo getInfo() {
|
||||
return new FluidTankInfo(this);
|
||||
}
|
||||
|
||||
public FluidTankInfo[] getMultiTankInfo ()
|
||||
{
|
||||
public FluidTankInfo[] getMultiTankInfo() {
|
||||
FluidTankInfo[] info = new FluidTankInfo[fluidlist.size() + 1];
|
||||
for (int i = 0; i < fluidlist.size(); i++)
|
||||
{
|
||||
for (int i = 0; i < fluidlist.size(); i++) {
|
||||
FluidStack fluid = fluidlist.get(i);
|
||||
info[i] = new FluidTankInfo(fluid.copy(), fluid.amount);
|
||||
}
|
||||
@@ -173,26 +131,21 @@ public class MultiFluidTank extends LogicComponent implements IFluidTank
|
||||
/* Sync liquids */
|
||||
|
||||
@Override
|
||||
public void readNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
public void readNetworkNBT(NBTTagCompound tags) {
|
||||
NBTTagList liquidTag = tags.getTagList("Liquids", 10);
|
||||
fluidlist.clear();
|
||||
|
||||
for (int iter = 0; iter < liquidTag.tagCount(); iter++)
|
||||
{
|
||||
for (int iter = 0; iter < liquidTag.tagCount(); iter++) {
|
||||
NBTTagCompound nbt = (NBTTagCompound) liquidTag.getCompoundTagAt(iter);
|
||||
FluidStack fluid = FluidStack.loadFluidStackFromNBT(nbt);
|
||||
if (fluid != null)
|
||||
fluidlist.add(fluid);
|
||||
if (fluid != null) fluidlist.add(fluid);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
public void writeNetworkNBT(NBTTagCompound tags) {
|
||||
NBTTagList taglist = new NBTTagList();
|
||||
for (FluidStack liquid : fluidlist)
|
||||
{
|
||||
for (FluidStack liquid : fluidlist) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
liquid.writeToNBT(nbt);
|
||||
taglist.appendTag(nbt);
|
||||
@@ -200,4 +153,4 @@ public class MultiFluidTank extends LogicComponent implements IFluidTank
|
||||
|
||||
tags.setTag("Liquids", taglist);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,7 @@ import net.minecraft.nbt.*;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import tconstruct.TConstruct;
|
||||
|
||||
public class TankLayerScan extends LogicComponent
|
||||
{
|
||||
public class TankLayerScan extends LogicComponent {
|
||||
protected TileEntity master;
|
||||
protected IMasterLogic imaster;
|
||||
protected Block[] scanBlocks;
|
||||
@@ -29,110 +28,98 @@ public class TankLayerScan extends LogicComponent
|
||||
protected CoordTuple returnStone;
|
||||
|
||||
private static boolean debug = System.getenv("DBG_MANTLE_TankLayerScan") != null;
|
||||
private static int MAX_LAYER_RECURSION_DEPTH = System.getProperty("os.arch").equals("amd64") ? 4000 : 2000; // Recursion causes overflows on 32-bit, so reduce if not 64-bit
|
||||
private static int MAX_LAYER_RECURSION_DEPTH = System.getProperty("os.arch").equals("amd64")
|
||||
? 4000
|
||||
: 2000; // Recursion causes overflows on 32-bit, so reduce if not 64-bit
|
||||
|
||||
public TankLayerScan(TileEntity te, Block... ids)
|
||||
{
|
||||
public TankLayerScan(TileEntity te, Block... ids) {
|
||||
assert te instanceof IMasterLogic : "TileEntity must be an instance of IMasterLogic";
|
||||
master = te;
|
||||
imaster = (IMasterLogic) te;
|
||||
scanBlocks = ids;
|
||||
masterCoord = new CoordTuple(te.xCoord, te.yCoord, te.zCoord);
|
||||
validAirCoords.add(new int[] { 1, 0 });
|
||||
validAirCoords.add(new int[] { -1, 0 });
|
||||
validAirCoords.add(new int[] { 0, 1 });
|
||||
validAirCoords.add(new int[] { 0, -1 });
|
||||
if (debug)
|
||||
{
|
||||
validAirCoords.add(new int[] {1, 0});
|
||||
validAirCoords.add(new int[] {-1, 0});
|
||||
validAirCoords.add(new int[] {0, 1});
|
||||
validAirCoords.add(new int[] {0, -1});
|
||||
if (debug) {
|
||||
TConstruct.logger.info("In debug mode: " + this);
|
||||
TConstruct.logger.info("Using recursion size " + MAX_LAYER_RECURSION_DEPTH + " on JVM arch " + System.getProperty("os.arch"));
|
||||
TConstruct.logger.info("Using recursion size " + MAX_LAYER_RECURSION_DEPTH + " on JVM arch "
|
||||
+ System.getProperty("os.arch"));
|
||||
}
|
||||
}
|
||||
|
||||
public void checkValidStructure ()
|
||||
{
|
||||
public void checkValidStructure() {
|
||||
bricks = 0;
|
||||
airBlocks = 0;
|
||||
blockCoords.clear();
|
||||
airCoords.clear();
|
||||
boolean validAir = false;
|
||||
//Check for air space in front of and behind the structure
|
||||
// Check for air space in front of and behind the structure
|
||||
byte dir = getDirection();
|
||||
switch (getDirection())
|
||||
{
|
||||
case 2: // +z
|
||||
case 3: // -z
|
||||
if (checkAir(master.xCoord, master.yCoord, master.zCoord - 1) && checkAir(master.xCoord, master.yCoord, master.zCoord + 1))
|
||||
validAir = true;
|
||||
break;
|
||||
case 4: // +x
|
||||
case 5: // -x
|
||||
if (checkAir(master.xCoord - 1, master.yCoord, master.zCoord) && checkAir(master.xCoord + 1, master.yCoord, master.zCoord))
|
||||
validAir = true;
|
||||
break;
|
||||
switch (getDirection()) {
|
||||
case 2: // +z
|
||||
case 3: // -z
|
||||
if (checkAir(master.xCoord, master.yCoord, master.zCoord - 1)
|
||||
&& checkAir(master.xCoord, master.yCoord, master.zCoord + 1)) validAir = true;
|
||||
break;
|
||||
case 4: // +x
|
||||
case 5: // -x
|
||||
if (checkAir(master.xCoord - 1, master.yCoord, master.zCoord)
|
||||
&& checkAir(master.xCoord + 1, master.yCoord, master.zCoord)) validAir = true;
|
||||
break;
|
||||
}
|
||||
|
||||
//Recurse the structure
|
||||
// Recurse the structure
|
||||
boolean validBlocks = false;
|
||||
|
||||
int xPos = 0, zPos = 0;
|
||||
if (dir == 2)
|
||||
xPos = 1;
|
||||
if (dir == 3)
|
||||
xPos = -1;
|
||||
if (dir == 4)
|
||||
zPos = -1;
|
||||
if (dir == 5)
|
||||
zPos = 1;
|
||||
if (dir == 2) xPos = 1;
|
||||
if (dir == 3) xPos = -1;
|
||||
if (dir == 4) zPos = -1;
|
||||
if (dir == 5) zPos = 1;
|
||||
|
||||
returnStone = new CoordTuple(master.xCoord - xPos, master.yCoord, master.zCoord - zPos);
|
||||
if (initialRecurseLayer(master.xCoord + xPos, master.yCoord, master.zCoord + zPos))
|
||||
{
|
||||
if (initialRecurseLayer(master.xCoord + xPos, master.yCoord, master.zCoord + zPos)) {
|
||||
xPos = 0;
|
||||
zPos = 0;
|
||||
switch (dir)
|
||||
{
|
||||
case 2: // +z
|
||||
zPos = 1;
|
||||
break;
|
||||
case 3: // -z
|
||||
zPos = -1;
|
||||
break;
|
||||
case 4: // +x
|
||||
xPos = 1;
|
||||
break;
|
||||
case 5: // -x
|
||||
xPos = -1;
|
||||
break;
|
||||
switch (dir) {
|
||||
case 2: // +z
|
||||
zPos = 1;
|
||||
break;
|
||||
case 3: // -z
|
||||
zPos = -1;
|
||||
break;
|
||||
case 4: // +x
|
||||
xPos = 1;
|
||||
break;
|
||||
case 5: // -x
|
||||
xPos = -1;
|
||||
break;
|
||||
}
|
||||
if (!world.isRemote && debug)
|
||||
TConstruct.logger.info("Bricks in recursion: " + blockCoords.size());
|
||||
if (!world.isRemote && debug) TConstruct.logger.info("Bricks in recursion: " + blockCoords.size());
|
||||
blockCoords.clear();
|
||||
bricks = 0;
|
||||
|
||||
//Does the actual adding of blocks in the ring
|
||||
// Does the actual adding of blocks in the ring
|
||||
boolean sealed = floodTest(master.xCoord + xPos, master.yCoord, master.zCoord + zPos);
|
||||
if (!world.isRemote && debug)
|
||||
{
|
||||
if (!world.isRemote && debug) {
|
||||
TConstruct.logger.info("Air in ring: " + airBlocks);
|
||||
TConstruct.logger.info("Bricks in ring: " + bricks);
|
||||
}
|
||||
|
||||
if (sealed)
|
||||
{
|
||||
blockCoords.add(new CoordTuple(master.xCoord, master.yCoord, master.zCoord)); //Don't forget me!
|
||||
if (sealed) {
|
||||
blockCoords.add(new CoordTuple(master.xCoord, master.yCoord, master.zCoord)); // Don't forget me!
|
||||
layerAirCoords = new HashSet<CoordTuple>(airCoords);
|
||||
layerBlockCoords = new HashSet<CoordTuple>(blockCoords);
|
||||
|
||||
int lowY = recurseStructureDown(master.yCoord - 1);
|
||||
if (lowY != -1)
|
||||
{
|
||||
if (lowY != -1) {
|
||||
completeStructure = true;
|
||||
structureTop = recurseStructureUp(master.yCoord + 1);
|
||||
finalizeStructure();
|
||||
|
||||
if (!world.isRemote && debug)
|
||||
{
|
||||
if (!world.isRemote && debug) {
|
||||
TConstruct.logger.info("Air in structure: " + airCoords.size());
|
||||
TConstruct.logger.info("Bricks in structure: " + blockCoords.size());
|
||||
}
|
||||
@@ -141,67 +128,54 @@ public class TankLayerScan extends LogicComponent
|
||||
}
|
||||
}
|
||||
|
||||
//@SuppressWarnings({ "unchecked" })
|
||||
protected void finalizeStructure ()
|
||||
{
|
||||
// @SuppressWarnings({ "unchecked" })
|
||||
protected void finalizeStructure() {
|
||||
Collections.sort(blockCoords, new CoordTupleSort());
|
||||
Collections.sort(airCoords, new CoordTupleSort());
|
||||
|
||||
for (CoordTuple coord : blockCoords)
|
||||
{
|
||||
for (CoordTuple coord : blockCoords) {
|
||||
TileEntity servant = world.getTileEntity(coord.x, coord.y, coord.z);
|
||||
if (servant instanceof IServantLogic)
|
||||
((IServantLogic) servant).verifyMaster(imaster, world, master.xCoord, master.yCoord, master.zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isComplete ()
|
||||
{
|
||||
public boolean isComplete() {
|
||||
return completeStructure;
|
||||
}
|
||||
|
||||
public int getAirLayerSize ()
|
||||
{
|
||||
public int getAirLayerSize() {
|
||||
return layerAirCoords.size();
|
||||
}
|
||||
|
||||
public int getAirSize ()
|
||||
{
|
||||
public int getAirSize() {
|
||||
return airBlocks;
|
||||
}
|
||||
|
||||
public CoordTuple getAirByIndex (int index)
|
||||
{
|
||||
if (index >= airCoords.size() || index < 0)
|
||||
return null;
|
||||
public CoordTuple getAirByIndex(int index) {
|
||||
if (index >= airCoords.size() || index < 0) return null;
|
||||
|
||||
return airCoords.get(index);
|
||||
}
|
||||
|
||||
private byte getDirection ()
|
||||
{
|
||||
if (master instanceof IFacingLogic)
|
||||
return ((IFacingLogic) master).getRenderDirection();
|
||||
private byte getDirection() {
|
||||
if (master instanceof IFacingLogic) return ((IFacingLogic) master).getRenderDirection();
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected boolean checkAir (int x, int y, int z)
|
||||
{
|
||||
protected boolean checkAir(int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (block == null || world.isAirBlock(x, y, z))// || block == TContent.tankAir)
|
||||
return true;
|
||||
if (block == null || world.isAirBlock(x, y, z)) // || block == TContent.tankAir)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean checkServant (int x, int y, int z)
|
||||
{
|
||||
protected boolean checkServant(int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (block == null || world.isAirBlock(x, y, z) || !isValidBlock(x, y, z))
|
||||
return false;
|
||||
if (block == null || world.isAirBlock(x, y, z) || !isValidBlock(x, y, z)) return false;
|
||||
|
||||
if (!block.hasTileEntity(world.getBlockMetadata(x, y, z)))
|
||||
return false;
|
||||
if (!block.hasTileEntity(world.getBlockMetadata(x, y, z))) return false;
|
||||
|
||||
TileEntity be = world.getTileEntity(x, y, z);
|
||||
if (be instanceof IServantLogic)
|
||||
@@ -210,24 +184,17 @@ public class TankLayerScan extends LogicComponent
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean initialRecurseLayer (int x, int y, int z)
|
||||
{
|
||||
if (bricks > MAX_LAYER_RECURSION_DEPTH)
|
||||
return false;
|
||||
protected boolean initialRecurseLayer(int x, int y, int z) {
|
||||
if (bricks > MAX_LAYER_RECURSION_DEPTH) return false;
|
||||
|
||||
CoordTuple keystone = new CoordTuple(x, y, z);
|
||||
if (keystone.equals(returnStone))
|
||||
return true;
|
||||
if (keystone.equals(returnStone)) return true;
|
||||
|
||||
for (int xPos = -1; xPos <= 1; xPos++)
|
||||
{
|
||||
for (int zPos = -1; zPos <= 1; zPos++)
|
||||
{
|
||||
for (int xPos = -1; xPos <= 1; xPos++) {
|
||||
for (int zPos = -1; zPos <= 1; zPos++) {
|
||||
CoordTuple coord = new CoordTuple(x + xPos, y, z + zPos);
|
||||
if (!blockCoords.contains(coord))
|
||||
{
|
||||
if (isValidBlock(x + xPos, y, z + zPos))
|
||||
{
|
||||
if (!blockCoords.contains(coord)) {
|
||||
if (isValidBlock(x + xPos, y, z + zPos)) {
|
||||
bricks++;
|
||||
blockCoords.add(coord);
|
||||
return initialRecurseLayer(x + xPos, y, z + zPos);
|
||||
@@ -239,37 +206,26 @@ public class TankLayerScan extends LogicComponent
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean isValidBlock (int x, int y, int z)
|
||||
{
|
||||
protected boolean isValidBlock(int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (block != null)
|
||||
{
|
||||
for (int i = 0; i < scanBlocks.length; i++)
|
||||
{
|
||||
if (block == scanBlocks[i])
|
||||
return true;
|
||||
if (block != null) {
|
||||
for (int i = 0; i < scanBlocks.length; i++) {
|
||||
if (block == scanBlocks[i]) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean floodTest (int x, int y, int z)
|
||||
{
|
||||
if (airBlocks > MAX_LAYER_RECURSION_DEPTH)
|
||||
return false;
|
||||
protected boolean floodTest(int x, int y, int z) {
|
||||
if (airBlocks > MAX_LAYER_RECURSION_DEPTH) return false;
|
||||
|
||||
for (int[] offset : validAirCoords)
|
||||
{
|
||||
for (int[] offset : validAirCoords) {
|
||||
CoordTuple coord = new CoordTuple(x + offset[0], y, z + offset[1]);
|
||||
if (!airCoords.contains(coord))
|
||||
{
|
||||
if (checkAir(x + offset[0], y, z + offset[1]))
|
||||
{
|
||||
if (!airCoords.contains(coord)) {
|
||||
if (checkAir(x + offset[0], y, z + offset[1])) {
|
||||
addAirBlock(coord.x, y, coord.z);
|
||||
floodTest(x + offset[0], y, z + offset[1]);
|
||||
}
|
||||
else if (!blockCoords.contains(coord) && checkServant(x + offset[0], y, z + offset[1]))
|
||||
{
|
||||
} else if (!blockCoords.contains(coord) && checkServant(x + offset[0], y, z + offset[1])) {
|
||||
bricks++;
|
||||
blockCoords.add(coord);
|
||||
}
|
||||
@@ -278,179 +234,134 @@ public class TankLayerScan extends LogicComponent
|
||||
return true;
|
||||
}
|
||||
|
||||
public int recurseStructureDown (int y)
|
||||
{
|
||||
public int recurseStructureDown(int y) {
|
||||
Iterator i = layerAirCoords.iterator();
|
||||
if (i.hasNext())
|
||||
{
|
||||
if (i.hasNext()) {
|
||||
CoordTuple coord = (CoordTuple) i.next();
|
||||
if (checkAir(coord.x, y, coord.z))
|
||||
{
|
||||
if (checkAir(coord.x, y, coord.z)) {
|
||||
boolean valid = true;
|
||||
addAirBlock(coord.x, y, coord.z); //Don't skip first one
|
||||
addAirBlock(coord.x, y, coord.z); // Don't skip first one
|
||||
|
||||
//Air blocks
|
||||
while (i.hasNext())
|
||||
{
|
||||
// Air blocks
|
||||
while (i.hasNext()) {
|
||||
coord = (CoordTuple) i.next();
|
||||
if (checkAir(coord.x, y, coord.z))
|
||||
{
|
||||
if (checkAir(coord.x, y, coord.z)) {
|
||||
addAirBlock(coord.x, y, coord.z);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Bricks
|
||||
// Bricks
|
||||
i = layerBlockCoords.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
while (i.hasNext()) {
|
||||
coord = (CoordTuple) i.next();
|
||||
if (checkServant(coord.x, y, coord.z))
|
||||
blockCoords.add(new CoordTuple(coord.x, y, coord.z));
|
||||
|
||||
else
|
||||
{
|
||||
if (checkServant(coord.x, y, coord.z)) blockCoords.add(new CoordTuple(coord.x, y, coord.z));
|
||||
else {
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (valid)
|
||||
return recurseStructureDown(y - 1);
|
||||
}
|
||||
else if (checkServant(coord.x, y, coord.z))
|
||||
{
|
||||
//Bottom floor. All blocks, please vacate the elevator
|
||||
if (valid) return recurseStructureDown(y - 1);
|
||||
} else if (checkServant(coord.x, y, coord.z)) {
|
||||
// Bottom floor. All blocks, please vacate the elevator
|
||||
boolean valid = true;
|
||||
while (i.hasNext())
|
||||
{
|
||||
while (i.hasNext()) {
|
||||
coord = (CoordTuple) i.next();
|
||||
|
||||
if (checkServant(coord.x, y, coord.z))
|
||||
blockCoords.add(new CoordTuple(coord.x, y, coord.z));
|
||||
|
||||
else
|
||||
{
|
||||
if (checkServant(coord.x, y, coord.z)) blockCoords.add(new CoordTuple(coord.x, y, coord.z));
|
||||
else {
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (valid)
|
||||
return y + 1;
|
||||
if (valid) return y + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int recurseStructureUp (int y)
|
||||
{
|
||||
public int recurseStructureUp(int y) {
|
||||
Iterator i = layerBlockCoords.iterator();
|
||||
if (i.hasNext())
|
||||
{
|
||||
if (i.hasNext()) {
|
||||
CoordTuple coord = (CoordTuple) i.next();
|
||||
if (checkServant(coord.x, y, coord.z))
|
||||
{
|
||||
if (checkServant(coord.x, y, coord.z)) {
|
||||
boolean valid = true;
|
||||
|
||||
//Bricks
|
||||
while (i.hasNext())
|
||||
{
|
||||
// Bricks
|
||||
while (i.hasNext()) {
|
||||
coord = (CoordTuple) i.next();
|
||||
if (checkServant(coord.x, y, coord.z))
|
||||
blockCoords.add(new CoordTuple(coord.x, y, coord.z));
|
||||
|
||||
else
|
||||
{
|
||||
if (checkServant(coord.x, y, coord.z)) blockCoords.add(new CoordTuple(coord.x, y, coord.z));
|
||||
else {
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Air blocks
|
||||
if (valid)
|
||||
{
|
||||
// Air blocks
|
||||
if (valid) {
|
||||
i = layerAirCoords.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
while (i.hasNext()) {
|
||||
coord = (CoordTuple) i.next();
|
||||
if (checkAir(coord.x, y, coord.z))
|
||||
{
|
||||
if (checkAir(coord.x, y, coord.z)) {
|
||||
addAirBlock(coord.x, y, coord.z);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (valid)
|
||||
recurseStructureUp(y + 1);
|
||||
if (valid) recurseStructureUp(y + 1);
|
||||
}
|
||||
}
|
||||
return y - 1;
|
||||
}
|
||||
|
||||
protected void addAirBlock (int x, int y, int z)
|
||||
{
|
||||
protected void addAirBlock(int x, int y, int z) {
|
||||
airBlocks++;
|
||||
airCoords.add(new CoordTuple(x, y, z));
|
||||
}
|
||||
|
||||
/* Checking for valid structures */
|
||||
|
||||
public void recheckStructure ()
|
||||
{
|
||||
public void recheckStructure() {
|
||||
System.out.println("Rechecking structure");
|
||||
int height = -1;
|
||||
for (CoordTuple coord : blockCoords)
|
||||
{
|
||||
for (CoordTuple coord : blockCoords) {
|
||||
TileEntity servant = world.getTileEntity(coord.x, coord.y, coord.z);
|
||||
boolean canPass = false;
|
||||
if (servant instanceof IServantLogic)
|
||||
{
|
||||
canPass = ((IServantLogic) servant).verifyMaster(imaster, world, master.xCoord, master.yCoord, master.zCoord);
|
||||
if (canPass)
|
||||
continue;
|
||||
if (servant instanceof IServantLogic) {
|
||||
canPass = ((IServantLogic) servant)
|
||||
.verifyMaster(imaster, world, master.xCoord, master.yCoord, master.zCoord);
|
||||
if (canPass) continue;
|
||||
}
|
||||
if (!canPass)
|
||||
{
|
||||
if (!canPass) {
|
||||
System.out.println("Coord: " + coord);
|
||||
height = coord.y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (height != -1)
|
||||
{
|
||||
if (height <= master.yCoord)
|
||||
invalidateStructure();
|
||||
else
|
||||
invalidateBlocksAbove(height);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (structureTop == 0) //Workaround for missing data
|
||||
if (height != -1) {
|
||||
if (height <= master.yCoord) invalidateStructure();
|
||||
else invalidateBlocksAbove(height);
|
||||
} else {
|
||||
if (structureTop == 0) // Workaround for missing data
|
||||
{
|
||||
for (CoordTuple coord : blockCoords)
|
||||
structureTop = coord.y;
|
||||
for (CoordTuple coord : blockCoords) structureTop = coord.y;
|
||||
}
|
||||
structureTop = recurseStructureUp(structureTop + 1);
|
||||
finalizeStructure();
|
||||
}
|
||||
}
|
||||
|
||||
protected void invalidateStructure ()
|
||||
{
|
||||
protected void invalidateStructure() {
|
||||
completeStructure = false;
|
||||
for (CoordTuple coord : blockCoords)
|
||||
{
|
||||
for (CoordTuple coord : blockCoords) {
|
||||
TileEntity servant = world.getTileEntity(coord.x, coord.y, coord.z);
|
||||
if (servant instanceof IServantLogic)
|
||||
((IServantLogic) servant).invalidateMaster(imaster, world, master.xCoord, master.yCoord, master.zCoord);
|
||||
@@ -458,12 +369,9 @@ public class TankLayerScan extends LogicComponent
|
||||
master.getWorldObj().markBlockForUpdate(master.xCoord, master.yCoord, master.zCoord);
|
||||
}
|
||||
|
||||
protected void invalidateBlocksAbove (int height)
|
||||
{
|
||||
for (CoordTuple coord : blockCoords)
|
||||
{
|
||||
if (coord.y < height)
|
||||
continue;
|
||||
protected void invalidateBlocksAbove(int height) {
|
||||
for (CoordTuple coord : blockCoords) {
|
||||
if (coord.y < height) continue;
|
||||
|
||||
TileEntity servant = world.getTileEntity(coord.x, coord.y, coord.z);
|
||||
if (servant instanceof IServantLogic)
|
||||
@@ -472,15 +380,12 @@ public class TankLayerScan extends LogicComponent
|
||||
}
|
||||
|
||||
/** Do any necessary cleanup here. Remove air blocks, invalidate servants, etc */
|
||||
public void cleanup ()
|
||||
{
|
||||
public void cleanup() {
|
||||
Iterator i = blockCoords.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
while (i.hasNext()) {
|
||||
CoordTuple coord = (CoordTuple) i.next();
|
||||
TileEntity te = world.getTileEntity(coord.x, coord.y, coord.z);
|
||||
if (te != null && te instanceof IServantLogic)
|
||||
{
|
||||
if (te != null && te instanceof IServantLogic) {
|
||||
((IServantLogic) te).invalidateMaster(imaster, world, master.xCoord, master.yCoord, master.zCoord);
|
||||
}
|
||||
}
|
||||
@@ -488,40 +393,33 @@ public class TankLayerScan extends LogicComponent
|
||||
|
||||
/* NBT */
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tags) {
|
||||
super.readFromNBT(tags);
|
||||
NBTTagList layerAir = tags.getTagList("AirLayer", 10);
|
||||
if (layerAir != null)
|
||||
{
|
||||
if (layerAir != null) {
|
||||
layerAirCoords.clear();
|
||||
|
||||
for (int i = 0; i < layerAir.tagCount(); ++i)
|
||||
{
|
||||
for (int i = 0; i < layerAir.tagCount(); ++i) {
|
||||
int[] coord = layerAir.func_150306_c(i);
|
||||
layerAirCoords.add(new CoordTuple(coord[0], coord[1], coord[2]));
|
||||
}
|
||||
}
|
||||
|
||||
NBTTagList blocks = tags.getTagList("Blocks", 10);
|
||||
if (blocks != null)
|
||||
{
|
||||
if (blocks != null) {
|
||||
blockCoords.clear();
|
||||
|
||||
for (int i = 0; i < blocks.tagCount(); ++i)
|
||||
{
|
||||
for (int i = 0; i < blocks.tagCount(); ++i) {
|
||||
int[] coord = blocks.func_150306_c(i);
|
||||
blockCoords.add(new CoordTuple(coord[0], coord[1], coord[2]));
|
||||
}
|
||||
}
|
||||
|
||||
NBTTagList air = tags.getTagList("Air", 10);
|
||||
if (air != null)
|
||||
{
|
||||
if (air != null) {
|
||||
airCoords.clear();
|
||||
|
||||
for (int i = 0; i < air.tagCount(); ++i)
|
||||
{
|
||||
for (int i = 0; i < air.tagCount(); ++i) {
|
||||
int[] coord = air.func_150306_c(i);
|
||||
airCoords.add(new CoordTuple(coord[0], coord[1], coord[2]));
|
||||
}
|
||||
@@ -530,41 +428,35 @@ public class TankLayerScan extends LogicComponent
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
public void readNetworkNBT(NBTTagCompound tags) {
|
||||
completeStructure = tags.getBoolean("Complete");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
public void writeToNBT(NBTTagCompound tags) {
|
||||
super.writeToNBT(tags);
|
||||
NBTTagList layerAir = new NBTTagList();
|
||||
for (CoordTuple coord : layerAirCoords)
|
||||
{
|
||||
layerAir.appendTag(new NBTTagIntArray(new int[] { coord.x, coord.y, coord.z }));
|
||||
for (CoordTuple coord : layerAirCoords) {
|
||||
layerAir.appendTag(new NBTTagIntArray(new int[] {coord.x, coord.y, coord.z}));
|
||||
}
|
||||
tags.setTag("AirLayer", layerAir);
|
||||
|
||||
NBTTagList blocks = new NBTTagList();
|
||||
for (CoordTuple coord : blockCoords)
|
||||
{
|
||||
blocks.appendTag(new NBTTagIntArray(new int[] { coord.x, coord.y, coord.z }));
|
||||
for (CoordTuple coord : blockCoords) {
|
||||
blocks.appendTag(new NBTTagIntArray(new int[] {coord.x, coord.y, coord.z}));
|
||||
}
|
||||
tags.setTag("Blocks", blocks);
|
||||
|
||||
NBTTagList air = new NBTTagList();
|
||||
for (CoordTuple coord : airCoords)
|
||||
{
|
||||
air.appendTag(new NBTTagIntArray(new int[] { coord.x, coord.y, coord.z }));
|
||||
for (CoordTuple coord : airCoords) {
|
||||
air.appendTag(new NBTTagIntArray(new int[] {coord.x, coord.y, coord.z}));
|
||||
}
|
||||
tags.setTag("Air", air);
|
||||
tags.setInteger("structureTop", structureTop);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
public void writeNetworkNBT(NBTTagCompound tags) {
|
||||
tags.setBoolean("Complete", completeStructure);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,11 @@ package tconstruct.library.crafting;
|
||||
import java.util.*;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class AlloyMix
|
||||
{
|
||||
public class AlloyMix {
|
||||
public final FluidStack result;
|
||||
public final List<FluidStack> mixers;
|
||||
|
||||
public AlloyMix(FluidStack output, List<FluidStack> inputs)
|
||||
{
|
||||
public AlloyMix(FluidStack output, List<FluidStack> inputs) {
|
||||
result = output;
|
||||
mixers = inputs;
|
||||
}
|
||||
@@ -19,23 +17,18 @@ public class AlloyMix
|
||||
* ArrayList(mixers); return false; }
|
||||
*/
|
||||
|
||||
public FluidStack mix (ArrayList<FluidStack> liquids)
|
||||
{
|
||||
public FluidStack mix(ArrayList<FluidStack> liquids) {
|
||||
ArrayList<FluidStack> copyMix = new ArrayList(mixers);
|
||||
ArrayList effectiveAmount = new ArrayList();
|
||||
|
||||
for (int i = 0; i < liquids.size(); i++)
|
||||
{
|
||||
for (int i = 0; i < liquids.size(); i++) {
|
||||
FluidStack liquid = liquids.get(i);
|
||||
Iterator iter = copyMix.iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
while (iter.hasNext()) {
|
||||
FluidStack mixer = (FluidStack) iter.next();
|
||||
if (mixer.isFluidEqual(liquid))
|
||||
{
|
||||
if (mixer.isFluidEqual(liquid)) {
|
||||
// do we actually have enough of that liquid?
|
||||
if(liquid.amount < mixer.amount)
|
||||
break;
|
||||
if (liquid.amount < mixer.amount) break;
|
||||
|
||||
int eAmt = liquid.amount / mixer.amount;
|
||||
effectiveAmount.add(eAmt);
|
||||
@@ -45,28 +38,23 @@ public class AlloyMix
|
||||
}
|
||||
}
|
||||
|
||||
if (copyMix.size() > 0)
|
||||
return null;
|
||||
if (copyMix.size() > 0) return null;
|
||||
|
||||
// Remove old liquids
|
||||
int low = getLowestAmount(effectiveAmount);
|
||||
ArrayList<FluidStack> copyMix2 = new ArrayList(mixers);
|
||||
|
||||
for (int i = 0; i < liquids.size(); i++)
|
||||
{
|
||||
for (int i = 0; i < liquids.size(); i++) {
|
||||
FluidStack liquid = liquids.get(i);
|
||||
Iterator iter = copyMix2.iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
while (iter.hasNext()) {
|
||||
FluidStack mixer = (FluidStack) iter.next();
|
||||
// if (mixer.itemID == liquid.itemID && mixer.itemMeta ==
|
||||
// liquid.itemMeta)
|
||||
if (mixer.isFluidEqual(liquid))
|
||||
{
|
||||
if (mixer.isFluidEqual(liquid)) {
|
||||
int eAmt = low * mixer.amount;
|
||||
liquid.amount -= eAmt;
|
||||
if (liquid.amount <= 0)
|
||||
{
|
||||
if (liquid.amount <= 0) {
|
||||
liquids.remove(liquid);
|
||||
i--;
|
||||
}
|
||||
@@ -81,14 +69,11 @@ public class AlloyMix
|
||||
return ret;
|
||||
}
|
||||
|
||||
int getLowestAmount (ArrayList list)
|
||||
{
|
||||
int getLowestAmount(ArrayList list) {
|
||||
int frist = (Integer) list.get(0); // FRIST!!!
|
||||
for (int i = 1; i < list.size(); i++)
|
||||
{
|
||||
for (int i = 1; i < list.size(); i++) {
|
||||
int compare = (Integer) list.get(i);
|
||||
if (frist > compare)
|
||||
frist = compare;
|
||||
if (frist > compare) frist = compare;
|
||||
}
|
||||
return frist;
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import tconstruct.library.client.FluidRenderProperties;
|
||||
|
||||
public class CastingRecipe
|
||||
{
|
||||
public class CastingRecipe {
|
||||
public ItemStack output;
|
||||
public FluidStack castingMetal;
|
||||
public ItemStack cast;
|
||||
@@ -15,8 +14,14 @@ public class CastingRecipe
|
||||
public FluidRenderProperties fluidRenderProperties;
|
||||
public boolean ignoreNBT;
|
||||
|
||||
public CastingRecipe(ItemStack replacement, FluidStack metal, ItemStack cast, boolean consume, int delay, FluidRenderProperties props, boolean ignoreNBT)
|
||||
{
|
||||
public CastingRecipe(
|
||||
ItemStack replacement,
|
||||
FluidStack metal,
|
||||
ItemStack cast,
|
||||
boolean consume,
|
||||
int delay,
|
||||
FluidRenderProperties props,
|
||||
boolean ignoreNBT) {
|
||||
castingMetal = metal;
|
||||
this.cast = cast;
|
||||
output = replacement;
|
||||
@@ -26,15 +31,21 @@ public class CastingRecipe
|
||||
this.ignoreNBT = ignoreNBT;
|
||||
}
|
||||
|
||||
public CastingRecipe(ItemStack replacement, FluidStack metal, ItemStack cast, boolean consume, int delay, FluidRenderProperties props)
|
||||
{
|
||||
public CastingRecipe(
|
||||
ItemStack replacement,
|
||||
FluidStack metal,
|
||||
ItemStack cast,
|
||||
boolean consume,
|
||||
int delay,
|
||||
FluidRenderProperties props) {
|
||||
this(replacement, metal, cast, consume, delay, props, false);
|
||||
}
|
||||
|
||||
public boolean matches (FluidStack metal, ItemStack inputCast)
|
||||
{
|
||||
public boolean matches(FluidStack metal, ItemStack inputCast) {
|
||||
if (castingMetal.isFluidEqual(metal)) {
|
||||
if (cast != null && cast.getItemDamage() == OreDictionary.WILDCARD_VALUE && inputCast.getItem() == cast.getItem()) {
|
||||
if (cast != null
|
||||
&& cast.getItemDamage() == OreDictionary.WILDCARD_VALUE
|
||||
&& inputCast.getItem() == cast.getItem()) {
|
||||
return true;
|
||||
} else if (!ignoreNBT && ItemStack.areItemStacksEqual(cast, inputCast)) {
|
||||
return true;
|
||||
@@ -45,8 +56,7 @@ public class CastingRecipe
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemStack getResult ()
|
||||
{
|
||||
public ItemStack getResult() {
|
||||
return output.copy();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,43 +7,27 @@ import net.minecraft.item.*;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public class Detailing
|
||||
{
|
||||
public class Detailing {
|
||||
public List<DetailInput> detailing = new ArrayList<DetailInput>();
|
||||
|
||||
public void addDetailing (Object input, int inputMeta, Object output, int outputMeta, ToolCore tool)
|
||||
{
|
||||
public void addDetailing(Object input, int inputMeta, Object output, int outputMeta, ToolCore tool) {
|
||||
ItemStack iID, oID;
|
||||
int iMeta = inputMeta, oMeta = outputMeta;
|
||||
|
||||
if (input instanceof Block)
|
||||
iID = new ItemStack(((Block) input));
|
||||
if (input instanceof Block) iID = new ItemStack(((Block) input));
|
||||
else if (input instanceof Item) iID = new ItemStack(((Item) input));
|
||||
else if (input instanceof ItemStack) iID = ((ItemStack) input);
|
||||
else throw new RuntimeException("Invalid detail input!");
|
||||
|
||||
else if (input instanceof Item)
|
||||
iID = new ItemStack(((Item) input));
|
||||
else if (input instanceof ItemStack)
|
||||
iID = ((ItemStack) input);
|
||||
|
||||
else
|
||||
throw new RuntimeException("Invalid detail input!");
|
||||
|
||||
if (output instanceof Block)
|
||||
oID = new ItemStack((Block) output);
|
||||
|
||||
else if (output instanceof Item)
|
||||
oID = new ItemStack((Item) output);
|
||||
|
||||
else if (output instanceof ItemStack)
|
||||
oID = (ItemStack) output;
|
||||
|
||||
else
|
||||
throw new RuntimeException("Invalid detail output!");
|
||||
if (output instanceof Block) oID = new ItemStack((Block) output);
|
||||
else if (output instanceof Item) oID = new ItemStack((Item) output);
|
||||
else if (output instanceof ItemStack) oID = (ItemStack) output;
|
||||
else throw new RuntimeException("Invalid detail output!");
|
||||
|
||||
this.addDetailing(new DetailInput(iID, iMeta, oID, oMeta), tool);
|
||||
}
|
||||
|
||||
public void addDetailing (DetailInput details, ToolCore tool)
|
||||
{
|
||||
public void addDetailing(DetailInput details, ToolCore tool) {
|
||||
detailing.add(details);
|
||||
ItemStack toolstack = new ItemStack(tool, 1, Short.MAX_VALUE);
|
||||
|
||||
@@ -56,31 +40,26 @@ public class Detailing
|
||||
toolTag.setInteger("TotalDurability", 100);
|
||||
compound.setTag("InfiTool", toolTag);
|
||||
toolstack.setTagCompound(compound);
|
||||
addShapelessToolRecipe(new ItemStack(details.output.getItem(), 1, details.outputMeta), toolstack, new ItemStack(details.input.getItem(), 1, details.inputMeta));
|
||||
addShapelessToolRecipe(
|
||||
new ItemStack(details.output.getItem(), 1, details.outputMeta),
|
||||
toolstack,
|
||||
new ItemStack(details.input.getItem(), 1, details.inputMeta));
|
||||
}
|
||||
|
||||
public void addShapelessToolRecipe (ItemStack par1ItemStack, Object... par2ArrayOfObj)
|
||||
{
|
||||
public void addShapelessToolRecipe(ItemStack par1ItemStack, Object... par2ArrayOfObj) {
|
||||
ArrayList arraylist = new ArrayList();
|
||||
Object[] aobject = par2ArrayOfObj;
|
||||
int i = par2ArrayOfObj.length;
|
||||
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
for (int j = 0; j < i; ++j) {
|
||||
Object object1 = aobject[j];
|
||||
|
||||
if (object1 instanceof ItemStack)
|
||||
{
|
||||
if (object1 instanceof ItemStack) {
|
||||
arraylist.add(((ItemStack) object1).copy());
|
||||
}
|
||||
else if (object1 instanceof Item)
|
||||
{
|
||||
} else if (object1 instanceof Item) {
|
||||
arraylist.add(new ItemStack((Item) object1));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(object1 instanceof Block))
|
||||
{
|
||||
} else {
|
||||
if (!(object1 instanceof Block)) {
|
||||
throw new RuntimeException("Invalid shapeless tool recipe!");
|
||||
}
|
||||
|
||||
@@ -91,28 +70,23 @@ public class Detailing
|
||||
GameRegistry.addRecipe(new ShapelessToolRecipe(par1ItemStack, arraylist));
|
||||
}
|
||||
|
||||
public DetailInput getDetailing (Block block, int inputMeta)
|
||||
{
|
||||
for (int i = 0; i < detailing.size(); i++)
|
||||
{
|
||||
public DetailInput getDetailing(Block block, int inputMeta) {
|
||||
for (int i = 0; i < detailing.size(); i++) {
|
||||
DetailInput detail = (DetailInput) detailing.get(i);
|
||||
if (Item.getItemFromBlock(block) == detail.input.getItem() && inputMeta == detail.inputMeta)
|
||||
{
|
||||
if (Item.getItemFromBlock(block) == detail.input.getItem() && inputMeta == detail.inputMeta) {
|
||||
return detail;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public class DetailInput
|
||||
{
|
||||
public class DetailInput {
|
||||
public ItemStack input;
|
||||
public int inputMeta;
|
||||
public ItemStack output;
|
||||
public int outputMeta;
|
||||
|
||||
public DetailInput(ItemStack input, int inputMeta, ItemStack output, int outputMeta)
|
||||
{
|
||||
public DetailInput(ItemStack input, int inputMeta, ItemStack output, int outputMeta) {
|
||||
this.input = input;
|
||||
this.inputMeta = inputMeta;
|
||||
this.output = output;
|
||||
|
||||
@@ -4,85 +4,64 @@ import java.util.ArrayList;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.*;
|
||||
|
||||
public class DryingRackRecipes
|
||||
{
|
||||
public class DryingRackRecipes {
|
||||
public static ArrayList<DryingRecipe> recipes = new ArrayList<DryingRecipe>();
|
||||
|
||||
public static void addDryingRecipe (Object input, int time, Object output)
|
||||
{
|
||||
public static void addDryingRecipe(Object input, int time, Object output) {
|
||||
ItemStack inputItem = null;
|
||||
ItemStack outputItem = null;
|
||||
|
||||
if (input instanceof ItemStack)
|
||||
inputItem = (ItemStack) input;
|
||||
else if (input instanceof Item)
|
||||
inputItem = new ItemStack((Item) input, 1, 0);
|
||||
else if (input instanceof Block)
|
||||
inputItem = new ItemStack((Block) input, 1, 0);
|
||||
else
|
||||
throw new RuntimeException("Drying recipe input is invalid!");
|
||||
if (input instanceof ItemStack) inputItem = (ItemStack) input;
|
||||
else if (input instanceof Item) inputItem = new ItemStack((Item) input, 1, 0);
|
||||
else if (input instanceof Block) inputItem = new ItemStack((Block) input, 1, 0);
|
||||
else throw new RuntimeException("Drying recipe input is invalid!");
|
||||
|
||||
if (output instanceof ItemStack)
|
||||
outputItem = (ItemStack) output;
|
||||
else if (output instanceof Item)
|
||||
outputItem = new ItemStack((Item) output, 1, 0);
|
||||
else if (output instanceof Block)
|
||||
outputItem = new ItemStack((Block) output, 1, 0);
|
||||
else
|
||||
throw new RuntimeException("Drying recipe output is invalid!");
|
||||
if (output instanceof ItemStack) outputItem = (ItemStack) output;
|
||||
else if (output instanceof Item) outputItem = new ItemStack((Item) output, 1, 0);
|
||||
else if (output instanceof Block) outputItem = new ItemStack((Block) output, 1, 0);
|
||||
else throw new RuntimeException("Drying recipe output is invalid!");
|
||||
|
||||
recipes.add(new DryingRecipe(inputItem, time, outputItem));
|
||||
}
|
||||
|
||||
public static int getDryingTime (ItemStack input)
|
||||
{
|
||||
for (DryingRecipe r : recipes)
|
||||
{
|
||||
if (r.matches(input))
|
||||
return r.time;
|
||||
public static int getDryingTime(ItemStack input) {
|
||||
for (DryingRecipe r : recipes) {
|
||||
if (r.matches(input)) return r.time;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static ItemStack getDryingResult (ItemStack input)
|
||||
{
|
||||
for (DryingRecipe r : recipes)
|
||||
{
|
||||
if (r.matches(input))
|
||||
return r.getResult();
|
||||
public static ItemStack getDryingResult(ItemStack input) {
|
||||
for (DryingRecipe r : recipes) {
|
||||
if (r.matches(input)) return r.getResult();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class DryingRecipe
|
||||
{
|
||||
public static class DryingRecipe {
|
||||
public final int time;
|
||||
public final ItemStack input;
|
||||
public final ItemStack result;
|
||||
|
||||
DryingRecipe(ItemStack input, int time, ItemStack result)
|
||||
{
|
||||
DryingRecipe(ItemStack input, int time, ItemStack result) {
|
||||
this.time = time;
|
||||
this.input = input;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public boolean matches (ItemStack input)
|
||||
{
|
||||
public boolean matches(ItemStack input) {
|
||||
// makes all drying rack recipies compatible with stuff killed by a frying pan
|
||||
if(input.hasTagCompound()) {
|
||||
if (input.hasTagCompound()) {
|
||||
input = input.copy();
|
||||
input.getTagCompound().removeTag("frypanKill");
|
||||
if(input.getTagCompound().hasNoTags())
|
||||
input.setTagCompound(null);
|
||||
if (input.getTagCompound().hasNoTags()) input.setTagCompound(null);
|
||||
}
|
||||
return ItemStack.areItemStacksEqual(this.input, input);
|
||||
}
|
||||
|
||||
public ItemStack getResult ()
|
||||
{
|
||||
public ItemStack getResult() {
|
||||
return result.copy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,7 @@ import java.util.*;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
public class FluidType
|
||||
{
|
||||
public class FluidType {
|
||||
public final Block renderBlock;
|
||||
public final int renderMeta;
|
||||
public final int baseTemperature;
|
||||
@@ -14,8 +13,7 @@ public class FluidType
|
||||
|
||||
public static HashMap<String, FluidType> fluidTypes = new HashMap<String, FluidType>();
|
||||
|
||||
public FluidType(Block block, int meta, int baseTemperature, Fluid fluid, boolean isToolpart)
|
||||
{
|
||||
public FluidType(Block block, int meta, int baseTemperature, Fluid fluid, boolean isToolpart) {
|
||||
this.renderBlock = block;
|
||||
this.renderMeta = meta;
|
||||
this.baseTemperature = baseTemperature;
|
||||
@@ -23,43 +21,36 @@ public class FluidType
|
||||
this.isToolpart = isToolpart;
|
||||
}
|
||||
|
||||
public static void registerFluidType (String name, FluidType type)
|
||||
{
|
||||
public static void registerFluidType(String name, FluidType type) {
|
||||
fluidTypes.put(name, type);
|
||||
}
|
||||
|
||||
public static void registerFluidType (String name, Block block, int meta, int baseTemperature, Fluid fluid, boolean isToolpart)
|
||||
{
|
||||
public static void registerFluidType(
|
||||
String name, Block block, int meta, int baseTemperature, Fluid fluid, boolean isToolpart) {
|
||||
FluidType type = new FluidType(block, meta, baseTemperature, fluid, isToolpart);
|
||||
registerFluidType(name, type);
|
||||
}
|
||||
|
||||
public static FluidType getFluidType (String typeName)
|
||||
{
|
||||
public static FluidType getFluidType(String typeName) {
|
||||
return fluidTypes.get(typeName);
|
||||
}
|
||||
|
||||
public static FluidType getFluidType (Fluid searchedFluid)
|
||||
{
|
||||
public static FluidType getFluidType(Fluid searchedFluid) {
|
||||
Iterator iter = fluidTypes.entrySet().iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry pairs = (Map.Entry) iter.next();
|
||||
if (((FluidType) pairs.getValue()).fluid.equals(searchedFluid))
|
||||
return (FluidType) pairs.getValue();
|
||||
if (((FluidType) pairs.getValue()).fluid.equals(searchedFluid)) return (FluidType) pairs.getValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getTemperatureByFluid (Fluid searchedFluid)
|
||||
{
|
||||
public static int getTemperatureByFluid(Fluid searchedFluid) {
|
||||
Iterator iter = fluidTypes.entrySet().iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry pairs = (Map.Entry) iter.next();
|
||||
if (((FluidType) pairs.getValue()).fluid.equals(searchedFluid))
|
||||
return ((FluidType) pairs.getValue()).baseTemperature;
|
||||
}
|
||||
return 800;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,24 +6,20 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import tconstruct.library.client.FluidRenderProperties;
|
||||
|
||||
/* Melting becomes hardened */
|
||||
public class LiquidCasting
|
||||
{
|
||||
public class LiquidCasting {
|
||||
// public static LiquidCasting instance = new LiquidCasting();
|
||||
private final ArrayList<CastingRecipe> casts = new ArrayList<CastingRecipe>();
|
||||
|
||||
private boolean contains (CastingRecipe recipe)
|
||||
{
|
||||
for (CastingRecipe c : casts)
|
||||
{
|
||||
if (c.matches(recipe.castingMetal, recipe.cast))
|
||||
return true;
|
||||
private boolean contains(CastingRecipe recipe) {
|
||||
for (CastingRecipe c : casts) {
|
||||
if (c.matches(recipe.castingMetal, recipe.cast)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a casting recipe
|
||||
*
|
||||
*
|
||||
* @param output
|
||||
* Result of the cast
|
||||
* @param metal
|
||||
@@ -38,16 +34,20 @@ public class LiquidCasting
|
||||
* @param props
|
||||
* The rendering properties for the casting fluid (may be null)
|
||||
*/
|
||||
public void addCastingRecipe (ItemStack output, FluidStack metal, ItemStack cast, boolean consume, int delay, FluidRenderProperties props)
|
||||
{
|
||||
public void addCastingRecipe(
|
||||
ItemStack output,
|
||||
FluidStack metal,
|
||||
ItemStack cast,
|
||||
boolean consume,
|
||||
int delay,
|
||||
FluidRenderProperties props) {
|
||||
CastingRecipe cr = new CastingRecipe(output, metal, cast, consume, delay, props);
|
||||
if (!contains(cr))
|
||||
casts.add(cr);
|
||||
if (!contains(cr)) casts.add(cr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a casting recipe
|
||||
*
|
||||
*
|
||||
* @param output
|
||||
* Result of the cast
|
||||
* @param metal
|
||||
@@ -60,14 +60,13 @@ public class LiquidCasting
|
||||
* @param delay
|
||||
* Time to cast in ticks
|
||||
*/
|
||||
public void addCastingRecipe (ItemStack output, FluidStack metal, ItemStack cast, boolean consume, int delay)
|
||||
{
|
||||
public void addCastingRecipe(ItemStack output, FluidStack metal, ItemStack cast, boolean consume, int delay) {
|
||||
addCastingRecipe(output, metal, cast, consume, delay, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a casting recipe. Does not consume the cast
|
||||
*
|
||||
*
|
||||
* @param output
|
||||
* Result of the cast
|
||||
* @param metal
|
||||
@@ -80,14 +79,14 @@ public class LiquidCasting
|
||||
* @param props
|
||||
* The rendering properties for the casting fluid (may be null)
|
||||
*/
|
||||
public void addCastingRecipe (ItemStack output, FluidStack metal, ItemStack cast, int delay, FluidRenderProperties props)
|
||||
{
|
||||
public void addCastingRecipe(
|
||||
ItemStack output, FluidStack metal, ItemStack cast, int delay, FluidRenderProperties props) {
|
||||
addCastingRecipe(output, metal, cast, false, delay, props);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a casting recipe. Does not consume the cast
|
||||
*
|
||||
*
|
||||
* @param output
|
||||
* Result of the cast
|
||||
* @param metal
|
||||
@@ -98,15 +97,14 @@ public class LiquidCasting
|
||||
* @param delay
|
||||
* Time to cast in ticks
|
||||
*/
|
||||
public void addCastingRecipe (ItemStack output, FluidStack metal, ItemStack cast, int delay)
|
||||
{
|
||||
public void addCastingRecipe(ItemStack output, FluidStack metal, ItemStack cast, int delay) {
|
||||
addCastingRecipe(output, metal, cast, false, delay, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a casting recipe. Does not consume the cast or have an item to cast
|
||||
* against
|
||||
*
|
||||
*
|
||||
* @param output
|
||||
* Result of the cast
|
||||
* @param metal
|
||||
@@ -117,15 +115,14 @@ public class LiquidCasting
|
||||
* @param props
|
||||
* The rendering properties for the casting fluid (may be null)
|
||||
*/
|
||||
public void addCastingRecipe (ItemStack output, FluidStack metal, int delay, FluidRenderProperties props)
|
||||
{
|
||||
public void addCastingRecipe(ItemStack output, FluidStack metal, int delay, FluidRenderProperties props) {
|
||||
addCastingRecipe(output, metal, null, false, delay, props);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a casting recipe. Does not consume the cast or have an item to cast
|
||||
* against
|
||||
*
|
||||
*
|
||||
* @param output
|
||||
* Result of the cast
|
||||
* @param metal
|
||||
@@ -134,45 +131,35 @@ public class LiquidCasting
|
||||
* @param delay
|
||||
* Time to cast in ticks
|
||||
*/
|
||||
public void addCastingRecipe (ItemStack output, FluidStack metal, int delay)
|
||||
{
|
||||
public void addCastingRecipe(ItemStack output, FluidStack metal, int delay) {
|
||||
addCastingRecipe(output, metal, null, false, delay, null);
|
||||
}
|
||||
|
||||
public void addCustomCastingRecipe (CastingRecipe recipe)
|
||||
{
|
||||
public void addCustomCastingRecipe(CastingRecipe recipe) {
|
||||
casts.add(recipe);
|
||||
}
|
||||
|
||||
public int getCastingDelay (FluidStack metal, ItemStack cast)
|
||||
{
|
||||
public int getCastingDelay(FluidStack metal, ItemStack cast) {
|
||||
CastingRecipe recipe = getCastingRecipe(metal, cast);
|
||||
if (recipe != null)
|
||||
return recipe.coolTime;
|
||||
if (recipe != null) return recipe.coolTime;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int getCastingAmount (FluidStack metal, ItemStack cast)
|
||||
{
|
||||
public int getCastingAmount(FluidStack metal, ItemStack cast) {
|
||||
CastingRecipe recipe = getCastingRecipe(metal, cast);
|
||||
if (recipe != null)
|
||||
return recipe.castingMetal.amount;
|
||||
if (recipe != null) return recipe.castingMetal.amount;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public CastingRecipe getCastingRecipe (FluidStack metal, ItemStack cast)
|
||||
{
|
||||
for (CastingRecipe recipe : casts)
|
||||
{
|
||||
if (recipe.matches(metal, cast))
|
||||
return recipe;
|
||||
public CastingRecipe getCastingRecipe(FluidStack metal, ItemStack cast) {
|
||||
for (CastingRecipe recipe : casts) {
|
||||
if (recipe.matches(metal, cast)) return recipe;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Getter for public viewing
|
||||
public ArrayList<CastingRecipe> getCastingRecipes ()
|
||||
{
|
||||
public ArrayList<CastingRecipe> getCastingRecipes() {
|
||||
return casts;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,52 +2,44 @@ package tconstruct.library.crafting;
|
||||
|
||||
import java.util.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import tconstruct.library.event.ModifyEvent;
|
||||
import tconstruct.library.modifier.*;
|
||||
|
||||
public class ModifyBuilder
|
||||
{
|
||||
public class ModifyBuilder {
|
||||
public static ModifyBuilder instance = new ModifyBuilder();
|
||||
public List<ItemModifier> itemModifiers = new ArrayList<ItemModifier>();
|
||||
|
||||
public ItemStack modifyItem (ItemStack input, ItemStack[] modifiers)
|
||||
{
|
||||
ItemStack copy = input.copy(); //Prevent modifying the original
|
||||
if (copy.getItem() instanceof IModifyable)
|
||||
{
|
||||
public ItemStack modifyItem(ItemStack input, ItemStack[] modifiers) {
|
||||
ItemStack copy = input.copy(); // Prevent modifying the original
|
||||
if (copy.getItem() instanceof IModifyable) {
|
||||
IModifyable item = (IModifyable) copy.getItem();
|
||||
|
||||
boolean built = false;
|
||||
for (ItemModifier mod : itemModifiers)
|
||||
{
|
||||
if (mod.matches(modifiers, copy) && mod.validType(item))
|
||||
{
|
||||
for (ItemModifier mod : itemModifiers) {
|
||||
if (mod.matches(modifiers, copy) && mod.validType(item)) {
|
||||
ModifyEvent event = new ModifyEvent(mod, item, copy);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
if(event.isCanceled())
|
||||
continue;
|
||||
if (event.isCanceled()) continue;
|
||||
|
||||
built = true;
|
||||
mod.addMatchingEffect(copy); //Order matters here
|
||||
mod.addMatchingEffect(copy); // Order matters here
|
||||
mod.modify(modifiers, copy);
|
||||
|
||||
// we do not allow negative modifiers >:(
|
||||
if(copy.getTagCompound().getCompoundTag(item.getBaseTagName()).getInteger("Modifiers") < 0)
|
||||
return null;
|
||||
if (copy.getTagCompound()
|
||||
.getCompoundTag(item.getBaseTagName())
|
||||
.getInteger("Modifiers")
|
||||
< 0) return null;
|
||||
}
|
||||
}
|
||||
if (built)
|
||||
return copy;
|
||||
if (built) return copy;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void registerModifier (ItemModifier mod)
|
||||
{
|
||||
if (mod == null)
|
||||
throw new NullPointerException("Modifier cannot be null.");
|
||||
public static void registerModifier(ItemModifier mod) {
|
||||
if (mod == null) throw new NullPointerException("Modifier cannot be null.");
|
||||
instance.itemModifiers.add(mod);
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,7 @@ import tconstruct.library.event.PartBuilderEvent;
|
||||
import tconstruct.library.tools.CustomMaterial;
|
||||
import tconstruct.library.util.IPattern;
|
||||
|
||||
public class PatternBuilder
|
||||
{
|
||||
public class PatternBuilder {
|
||||
public static PatternBuilder instance = new PatternBuilder();
|
||||
// Map items to their parts with a hashmap
|
||||
public List<ItemKey> materials = new ArrayList<ItemKey>();
|
||||
@@ -22,73 +21,57 @@ public class PatternBuilder
|
||||
public List<IPattern> toolPatterns = new ArrayList<IPattern>();
|
||||
|
||||
/* Register methods */
|
||||
public void registerMaterial (ItemStack material, int value, String key)
|
||||
{
|
||||
public void registerMaterial(ItemStack material, int value, String key) {
|
||||
materials.add(new ItemKey(material.getItem(), material.getItemDamage(), value, key));
|
||||
}
|
||||
|
||||
public void registerMaterialSet (String key, ItemStack shard, ItemStack rod, int materialID)
|
||||
{
|
||||
public void registerMaterialSet(String key, ItemStack shard, ItemStack rod, int materialID) {
|
||||
materialSets.put(key, new MaterialSet(shard, rod, materialID));
|
||||
materials.add(new ItemKey(shard.getItem(), shard.getItemDamage(), 1, key));
|
||||
}
|
||||
|
||||
public void registerFullMaterial (ItemStack material, int value, String key, ItemStack shard, ItemStack rod, int materialID)
|
||||
{
|
||||
public void registerFullMaterial(
|
||||
ItemStack material, int value, String key, ItemStack shard, ItemStack rod, int materialID) {
|
||||
materials.add(new ItemKey(material.getItem(), material.getItemDamage(), value, key));
|
||||
materials.add(new ItemKey(shard.getItem(), shard.getItemDamage(), 1, key));
|
||||
materialSets.put(key, new MaterialSet(shard, rod, materialID));
|
||||
}
|
||||
|
||||
public void addToolPattern (IPattern item)
|
||||
{
|
||||
public void addToolPattern(IPattern item) {
|
||||
toolPatterns.add(item);
|
||||
}
|
||||
|
||||
/* Build tool parts from patterns */
|
||||
public ItemStack[] getToolPart (ItemStack material, ItemStack pattern, ItemStack otherPattern)
|
||||
{
|
||||
if (material != null && pattern != null)
|
||||
{
|
||||
public ItemStack[] getToolPart(ItemStack material, ItemStack pattern, ItemStack otherPattern) {
|
||||
if (material != null && pattern != null) {
|
||||
PartBuilderEvent.NormalPart event = new PartBuilderEvent.NormalPart(material, pattern, otherPattern);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
if (event.getResult() == Result.ALLOW)
|
||||
{
|
||||
if (event.getResult() == Result.ALLOW) {
|
||||
return event.getResultStacks();
|
||||
}
|
||||
else if (event.getResult() == Result.DENY)
|
||||
{
|
||||
} else if (event.getResult() == Result.DENY) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemKey key = getItemKey(material);
|
||||
if (key != null)
|
||||
{
|
||||
if (key != null) {
|
||||
MaterialSet mat = (MaterialSet) materialSets.get(key.key);
|
||||
ItemStack toolPart = getMatchingPattern(pattern, material, mat);
|
||||
|
||||
if (toolPart != null)
|
||||
{
|
||||
if (toolPart != null) {
|
||||
int patternValue = ((IPattern) pattern.getItem()).getPatternCost(pattern);
|
||||
int totalMaterial = key.value * material.stackSize;
|
||||
|
||||
if (totalMaterial < patternValue) // Not enough material
|
||||
return null;
|
||||
|
||||
return null;
|
||||
else if (patternValue == key.value) // Material only
|
||||
return new ItemStack[] { toolPart, null };
|
||||
|
||||
else
|
||||
{
|
||||
if (patternValue % 2 == 1 && mat.shard != null)
|
||||
{
|
||||
return new ItemStack[] { toolPart, mat.shard.copy() }; // Material
|
||||
// +
|
||||
// shard
|
||||
}
|
||||
else
|
||||
return new ItemStack[] { toolPart, null };
|
||||
return new ItemStack[] {toolPart, null};
|
||||
else {
|
||||
if (patternValue % 2 == 1 && mat.shard != null) {
|
||||
return new ItemStack[] {toolPart, mat.shard.copy()}; // Material
|
||||
// +
|
||||
// shard
|
||||
} else return new ItemStack[] {toolPart, null};
|
||||
}
|
||||
/*
|
||||
* if ( patternValue < totalMaterial ) { if (otherPattern !=
|
||||
@@ -99,11 +82,11 @@ public class PatternBuilder
|
||||
* otherPart = getMatchingPattern(otherPattern, mat); return
|
||||
* new ItemStack[] { toolPart, otherPart }; //Material +
|
||||
* Material } } }
|
||||
*
|
||||
*
|
||||
* else if ( patternValue == key.value ) return new
|
||||
* ItemStack[] { new ItemStack(toolPart, 1, mat.materialID),
|
||||
* null }; //Material only
|
||||
*
|
||||
*
|
||||
* else return null; //Not a valid match
|
||||
*/
|
||||
}
|
||||
@@ -112,13 +95,10 @@ public class PatternBuilder
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getPartID (ItemStack material)
|
||||
{
|
||||
if (material != null)
|
||||
{
|
||||
public int getPartID(ItemStack material) {
|
||||
if (material != null) {
|
||||
ItemKey key = getItemKey(material);
|
||||
if (key != null)
|
||||
{
|
||||
if (key != null) {
|
||||
MaterialSet set = (MaterialSet) materialSets.get(key.key);
|
||||
return set.materialID;
|
||||
}
|
||||
@@ -126,73 +106,56 @@ public class PatternBuilder
|
||||
return Short.MAX_VALUE;
|
||||
}
|
||||
|
||||
public int getPartValue (ItemStack material)
|
||||
{
|
||||
if (material != null)
|
||||
{
|
||||
public int getPartValue(ItemStack material) {
|
||||
if (material != null) {
|
||||
ItemKey key = getItemKey(material);
|
||||
if (key != null)
|
||||
return key.value;
|
||||
if (key != null) return key.value;
|
||||
|
||||
for (CustomMaterial mat : TConstructRegistry.customMaterials)
|
||||
{
|
||||
if (mat.matches(material))
|
||||
return mat.value;
|
||||
for (CustomMaterial mat : TConstructRegistry.customMaterials) {
|
||||
if (mat.matches(material)) return mat.value;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ItemKey getItemKey (ItemStack material)
|
||||
{
|
||||
public ItemKey getItemKey(ItemStack material) {
|
||||
Item mat = material.getItem();
|
||||
int damage = material.getItemDamage();
|
||||
for (ItemKey ik : materials)
|
||||
{
|
||||
if (mat == ik.item && (ik.damage == Short.MAX_VALUE || damage == ik.damage))
|
||||
return ik;
|
||||
for (ItemKey ik : materials) {
|
||||
if (mat == ik.item && (ik.damage == Short.MAX_VALUE || damage == ik.damage)) return ik;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getMatchingPattern (ItemStack stack, ItemStack input, MaterialSet set)
|
||||
{
|
||||
public ItemStack getMatchingPattern(ItemStack stack, ItemStack input, MaterialSet set) {
|
||||
Item item = stack.getItem();
|
||||
for (IPattern pattern : toolPatterns)
|
||||
{
|
||||
if (pattern == item)
|
||||
return pattern.getPatternOutput(stack, input, set);
|
||||
for (IPattern pattern : toolPatterns) {
|
||||
if (pattern == item) return pattern.getPatternOutput(stack, input, set);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getShardFromSet (String materialset)
|
||||
{
|
||||
public ItemStack getShardFromSet(String materialset) {
|
||||
MaterialSet set = (MaterialSet) materialSets.get(materialset);
|
||||
if (set != null && set.shard != null)
|
||||
return set.shard.copy();
|
||||
if (set != null && set.shard != null) return set.shard.copy();
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getRodFromSet (String materialset)
|
||||
{
|
||||
public ItemStack getRodFromSet(String materialset) {
|
||||
MaterialSet set = (MaterialSet) materialSets.get(materialset);
|
||||
if (set != null)
|
||||
return set.rod.copy();
|
||||
if (set != null) return set.rod.copy();
|
||||
return null;
|
||||
}
|
||||
|
||||
// Small data classes. I would prefer the struct from C#, but we do what we
|
||||
// can.
|
||||
public class ItemKey
|
||||
{
|
||||
public class ItemKey {
|
||||
public final Item item;
|
||||
public final int damage;
|
||||
public final int value;
|
||||
public final String key;
|
||||
|
||||
public ItemKey(Item i, int d, int v, String s)
|
||||
{
|
||||
public ItemKey(Item i, int d, int v, String s) {
|
||||
item = i;
|
||||
damage = d;
|
||||
value = v;
|
||||
@@ -200,14 +163,12 @@ public class PatternBuilder
|
||||
}
|
||||
}
|
||||
|
||||
public class MaterialSet
|
||||
{
|
||||
public class MaterialSet {
|
||||
public final ItemStack shard;
|
||||
public final ItemStack rod;
|
||||
public final int materialID;
|
||||
|
||||
public MaterialSet(ItemStack s, ItemStack r, int id)
|
||||
{
|
||||
public MaterialSet(ItemStack s, ItemStack r, int id) {
|
||||
shard = s;
|
||||
rod = r;
|
||||
materialID = id;
|
||||
@@ -215,23 +176,21 @@ public class PatternBuilder
|
||||
}
|
||||
|
||||
// Helper Methods
|
||||
public void registerMaterial (Block material, int value, String key)
|
||||
{
|
||||
public void registerMaterial(Block material, int value, String key) {
|
||||
registerMaterial(new ItemStack(material, 1, Short.MAX_VALUE), value, key);
|
||||
}
|
||||
|
||||
public void registerMaterial (Item material, int value, String key)
|
||||
{
|
||||
public void registerMaterial(Item material, int value, String key) {
|
||||
registerMaterial(new ItemStack(material, 1, Short.MAX_VALUE), value, key);
|
||||
}
|
||||
|
||||
public void registerFullMaterial (Block material, int value, String key, ItemStack shard, ItemStack rod, int materialID)
|
||||
{
|
||||
public void registerFullMaterial(
|
||||
Block material, int value, String key, ItemStack shard, ItemStack rod, int materialID) {
|
||||
registerFullMaterial(new ItemStack(material, 1, Short.MAX_VALUE), value, key, shard, rod, materialID);
|
||||
}
|
||||
|
||||
public void registerFullMaterial (Item material, int value, String key, ItemStack shard, ItemStack rod, int materialID)
|
||||
{
|
||||
public void registerFullMaterial(
|
||||
Item material, int value, String key, ItemStack shard, ItemStack rod, int materialID) {
|
||||
registerFullMaterial(new ItemStack(material, 1, Short.MAX_VALUE), value, key, shard, rod, materialID);
|
||||
}
|
||||
|
||||
@@ -241,11 +200,11 @@ public class PatternBuilder
|
||||
* Short.MAX_VALUE), value, key, new ItemStack(TContent.toolShard, 1,
|
||||
* materialID), new ItemStack(TContent.toolRod, 1, materialID), materialID);
|
||||
* }
|
||||
*
|
||||
*
|
||||
* public void registerFullMaterial (Item material, int value, String key,
|
||||
* int materialID) { registerFullMaterial(new ItemStack(material, 1,
|
||||
* Short.MAX_VALUE), value, key, new ItemStack(TContent.toolShard, 1,
|
||||
* materialID), new ItemStack(TContent.toolRod, 1, materialID), materialID);
|
||||
* }
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -10,58 +10,47 @@ import net.minecraftforge.oredict.RecipeSorter;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public class ShapelessToolRecipe extends ShapelessRecipes
|
||||
{
|
||||
public class ShapelessToolRecipe extends ShapelessRecipes {
|
||||
static {
|
||||
RecipeSorter.register(TConstruct.modID + ":" + "toolrecipe", ShapelessToolRecipe.class, RecipeSorter.Category.SHAPELESS, "");
|
||||
RecipeSorter.register(
|
||||
TConstruct.modID + ":" + "toolrecipe", ShapelessToolRecipe.class, RecipeSorter.Category.SHAPELESS, "");
|
||||
}
|
||||
|
||||
public ShapelessToolRecipe(ItemStack par1ItemStack, List par2List)
|
||||
{
|
||||
public ShapelessToolRecipe(ItemStack par1ItemStack, List par2List) {
|
||||
super(par1ItemStack, par2List);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches (InventoryCrafting par1InventoryCrafting, World par2World)
|
||||
{
|
||||
public boolean matches(InventoryCrafting par1InventoryCrafting, World par2World) {
|
||||
ArrayList arraylist = new ArrayList(this.recipeItems);
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 3; ++j)
|
||||
{
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 3; ++j) {
|
||||
ItemStack itemstack = par1InventoryCrafting.getStackInRowAndColumn(j, i);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
if (itemstack != null) {
|
||||
boolean flag = false;
|
||||
Iterator iterator = arraylist.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
while (iterator.hasNext()) {
|
||||
ItemStack itemstack1 = (ItemStack) iterator.next();
|
||||
|
||||
// TConstruct.logger.info("Rawr! "+itemstack1.getItemDamage());
|
||||
if (itemstack.getItem() == itemstack1.getItem())
|
||||
{
|
||||
if (itemstack.getItem() instanceof ToolCore)
|
||||
{
|
||||
if (itemstack.getItem() == itemstack1.getItem()) {
|
||||
if (itemstack.getItem() instanceof ToolCore) {
|
||||
NBTTagCompound tags = itemstack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.getBoolean("Broken"))
|
||||
return false;
|
||||
if (tags.getBoolean("Broken")) return false;
|
||||
|
||||
flag = true;
|
||||
}
|
||||
else if((itemstack1.getItemDamage() == Short.MAX_VALUE || itemstack.getItemDamage() == itemstack1.getItemDamage()))
|
||||
flag = true;
|
||||
} else if ((itemstack1.getItemDamage() == Short.MAX_VALUE
|
||||
|| itemstack.getItemDamage() == itemstack1.getItemDamage())) flag = true;
|
||||
|
||||
arraylist.remove(itemstack1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
if (!flag) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -70,5 +59,4 @@ public class ShapelessToolRecipe extends ShapelessRecipes
|
||||
|
||||
return arraylist.isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,8 +8,7 @@ import net.minecraftforge.fluids.*;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
/** Melting and hacking, churn and burn */
|
||||
public class Smeltery
|
||||
{
|
||||
public class Smeltery {
|
||||
public static Smeltery instance = new Smeltery();
|
||||
|
||||
private final Map<ItemMetaWrapper, FluidStack> smeltingList = new HashMap<ItemMetaWrapper, FluidStack>();
|
||||
@@ -24,24 +23,21 @@ public class Smeltery
|
||||
* @param power The temperature of the fluid. This also influences the melting speed. Lava is 1000.
|
||||
* @param duration How long one "portion" of liquid fuels the smeltery. Lava is 10.
|
||||
*/
|
||||
public static void addSmelteryFuel (Fluid fluid, int power, int duration)
|
||||
{
|
||||
instance.smelteryFuels.put(fluid, new Integer[] { power, duration });
|
||||
public static void addSmelteryFuel(Fluid fluid, int power, int duration) {
|
||||
instance.smelteryFuels.put(fluid, new Integer[] {power, duration});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the liquid is a valid smeltery fuel.
|
||||
*/
|
||||
public static boolean isSmelteryFuel (Fluid fluid)
|
||||
{
|
||||
public static boolean isSmelteryFuel(Fluid fluid) {
|
||||
return instance.smelteryFuels.containsKey(fluid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the power of a smeltery fuel or 0 if it's not a fuel.
|
||||
*/
|
||||
public static int getFuelPower (Fluid fluid)
|
||||
{
|
||||
public static int getFuelPower(Fluid fluid) {
|
||||
Integer[] power = instance.smelteryFuels.get(fluid);
|
||||
return power == null ? 0 : power[0];
|
||||
}
|
||||
@@ -49,8 +45,7 @@ public class Smeltery
|
||||
/**
|
||||
* Returns the duration of a smeltery fuel or 0 if it's not a fuel.
|
||||
*/
|
||||
public static int getFuelDuration (Fluid fluid)
|
||||
{
|
||||
public static int getFuelDuration(Fluid fluid) {
|
||||
Integer[] power = instance.smelteryFuels.get(fluid);
|
||||
return power == null ? 0 : power[1];
|
||||
}
|
||||
@@ -59,31 +54,28 @@ public class Smeltery
|
||||
* Adds mappings between an itemstack and an output liquid Example:
|
||||
* Smeltery.addMelting(Block.oreIron, 0, 600, new
|
||||
* FluidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue * 2, 0));
|
||||
*
|
||||
*
|
||||
* @param stack The itemstack to liquify. Must hold a block.
|
||||
* @param temperature How hot the block should be before liquifying. Max temp in the Smeltery is 800, other structures may vary
|
||||
* @param output The result of the process in liquid form
|
||||
*/
|
||||
public static void addMelting (ItemStack stack, int temperature, FluidStack output)
|
||||
{
|
||||
public static void addMelting(ItemStack stack, int temperature, FluidStack output) {
|
||||
if (stack.getItem() instanceof ItemBlock)
|
||||
addMelting(stack, ((ItemBlock) stack.getItem()).field_150939_a, stack.getItemDamage(), temperature, output);
|
||||
else
|
||||
throw new IllegalArgumentException("ItemStack must house a block.");
|
||||
else throw new IllegalArgumentException("ItemStack must house a block.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds mappings between a block and its liquid Example:
|
||||
* Smeltery.addMelting(Block.oreIron, 0, 600, new
|
||||
* FluidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue * 2, 0));
|
||||
*
|
||||
*
|
||||
* @param block The block to liquify and render
|
||||
* @param metadata The metadata of the block to liquify and render
|
||||
* @param temperature How hot the block should be before liquifying. Max temp in the Smeltery is 800, other structures may vary
|
||||
* @param output The result of the process in liquid form
|
||||
*/
|
||||
public static void addMelting (Block block, int metadata, int temperature, FluidStack output)
|
||||
{
|
||||
public static void addMelting(Block block, int metadata, int temperature, FluidStack output) {
|
||||
addMelting(new ItemStack(block, 1, metadata), block, metadata, temperature, output);
|
||||
}
|
||||
|
||||
@@ -92,15 +84,14 @@ public class Smeltery
|
||||
* input's block ID and metadata Example: Smeltery.addMelting(Block.oreIron,
|
||||
* 0, 600, new FluidStack(liquidMetalStill.blockID,
|
||||
* TConstruct.ingotLiquidValue * 2, 0));
|
||||
*
|
||||
*
|
||||
* @param input The item to liquify
|
||||
* @param block The block to render
|
||||
* @param metadata The metadata of the block to render
|
||||
* @param temperature How hot the block should be before liquifying
|
||||
* @param liquid The result of the process
|
||||
*/
|
||||
public static void addMelting (ItemStack input, Block block, int metadata, int temperature, FluidStack liquid)
|
||||
{
|
||||
public static void addMelting(ItemStack input, Block block, int metadata, int temperature, FluidStack liquid) {
|
||||
ItemMetaWrapper in = new ItemMetaWrapper(input);
|
||||
instance.smeltingList.put(in, liquid);
|
||||
instance.temperatureList.put(in, temperature);
|
||||
@@ -112,148 +103,136 @@ public class Smeltery
|
||||
* FluidStack(bronzeID, 2, 0), new FluidStack(copperID, 3, 0), new
|
||||
* FluidStack(tinID, 1, 0)); The example mixes 3 copper with 1 tin to make 2
|
||||
* bronze
|
||||
*
|
||||
*
|
||||
* @param result The output of the combination of mixers. The quantity is used for amount of a successful mix
|
||||
* @param mixers the liquids to be mixed. Quantities are used as ratios
|
||||
*/
|
||||
public static void addAlloyMixing (FluidStack result, FluidStack... mixers)
|
||||
{
|
||||
public static void addAlloyMixing(FluidStack result, FluidStack... mixers) {
|
||||
ArrayList inputs = new ArrayList();
|
||||
for (FluidStack liquid : mixers)
|
||||
inputs.add(liquid);
|
||||
for (FluidStack liquid : mixers) inputs.add(liquid);
|
||||
|
||||
instance.alloys.add(new AlloyMix(result, inputs));
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the resulting temperature from a source ItemStack
|
||||
*
|
||||
*
|
||||
* @param item The Source ItemStack
|
||||
* @return The result temperature
|
||||
*/
|
||||
public static Integer getLiquifyTemperature (ItemStack item)
|
||||
{
|
||||
if (item == null)
|
||||
return 20;
|
||||
public static Integer getLiquifyTemperature(ItemStack item) {
|
||||
if (item == null) return 20;
|
||||
|
||||
Integer temp = instance.temperatureList.get(new ItemMetaWrapper(item));
|
||||
if (temp == null)
|
||||
return 20;
|
||||
else
|
||||
return temp;
|
||||
if (temp == null) return 20;
|
||||
else return temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the resulting temperature from a source Block
|
||||
*
|
||||
*
|
||||
* @param block The Source Block
|
||||
* @return The result ItemStack
|
||||
*/
|
||||
public static Integer getLiquifyTemperature (Block block, int metadata)
|
||||
{
|
||||
public static Integer getLiquifyTemperature(Block block, int metadata) {
|
||||
return instance.getLiquifyTemperature(new ItemStack(block, 1, metadata));
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the resulting ItemStack from a source ItemStack
|
||||
*
|
||||
*
|
||||
* @param item The Source ItemStack
|
||||
* @return The result ItemStack
|
||||
*/
|
||||
public static FluidStack getSmelteryResult (ItemStack item)
|
||||
{
|
||||
if (item == null)
|
||||
return null;
|
||||
public static FluidStack getSmelteryResult(ItemStack item) {
|
||||
if (item == null) return null;
|
||||
|
||||
FluidStack stack = instance.smeltingList.get(new ItemMetaWrapper(item));
|
||||
if (stack == null)
|
||||
return null;
|
||||
if (stack == null) return null;
|
||||
return stack.copy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the resulting ItemStack from a source Block
|
||||
*
|
||||
*
|
||||
* @param block The Source Block
|
||||
* @return The result ItemStack
|
||||
*/
|
||||
public static FluidStack getSmelteryResult (Block block, int metadata)
|
||||
{
|
||||
public static FluidStack getSmelteryResult(Block block, int metadata) {
|
||||
return instance.getSmelteryResult(new ItemStack(block, 1, metadata));
|
||||
}
|
||||
|
||||
public static ItemStack getRenderIndex (ItemStack input)
|
||||
{
|
||||
public static ItemStack getRenderIndex(ItemStack input) {
|
||||
return instance.renderIndex.get(new ItemMetaWrapper(input));
|
||||
}
|
||||
|
||||
public static ArrayList mixMetals (ArrayList<FluidStack> moltenMetal)
|
||||
{
|
||||
public static ArrayList mixMetals(ArrayList<FluidStack> moltenMetal) {
|
||||
ArrayList liquids = new ArrayList();
|
||||
for (AlloyMix alloy : instance.alloys)
|
||||
{
|
||||
for (AlloyMix alloy : instance.alloys) {
|
||||
FluidStack liquid = alloy.mix(moltenMetal);
|
||||
if (liquid != null)
|
||||
liquids.add(liquid);
|
||||
if (liquid != null) liquids.add(liquid);
|
||||
}
|
||||
return liquids;
|
||||
}
|
||||
|
||||
public static Map<ItemMetaWrapper, FluidStack> getSmeltingList ()
|
||||
{
|
||||
public static Map<ItemMetaWrapper, FluidStack> getSmeltingList() {
|
||||
return instance.smeltingList;
|
||||
}
|
||||
|
||||
public static Map<ItemMetaWrapper, Integer> getTemperatureList ()
|
||||
{
|
||||
public static Map<ItemMetaWrapper, Integer> getTemperatureList() {
|
||||
return instance.temperatureList;
|
||||
}
|
||||
|
||||
public static Map<ItemMetaWrapper, ItemStack> getRenderIndex ()
|
||||
{
|
||||
public static Map<ItemMetaWrapper, ItemStack> getRenderIndex() {
|
||||
return instance.renderIndex;
|
||||
}
|
||||
|
||||
public static List<AlloyMix> getAlloyList ()
|
||||
{
|
||||
public static List<AlloyMix> getAlloyList() {
|
||||
return instance.alloys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a mapping between FluidType and ItemStack
|
||||
*
|
||||
*
|
||||
* @author samtrion
|
||||
*
|
||||
*
|
||||
* @param type Type of Fluid
|
||||
* @param input The item to liquify
|
||||
* @param temperatureDifference Difference between FluidType BaseTemperature
|
||||
* @param fluidAmount Amount of Fluid
|
||||
*/
|
||||
public static void addMelting (FluidType type, ItemStack input, int temperatureDifference, int fluidAmount)
|
||||
{
|
||||
public static void addMelting(FluidType type, ItemStack input, int temperatureDifference, int fluidAmount) {
|
||||
int temp = type.baseTemperature + temperatureDifference;
|
||||
if (temp <= 20)
|
||||
temp = type.baseTemperature;
|
||||
if (temp <= 20) temp = type.baseTemperature;
|
||||
|
||||
if (input.getItem() instanceof ItemBlock)
|
||||
addMelting(input, ((ItemBlock) input.getItem()).field_150939_a, input.getItemDamage(), type.baseTemperature + temperatureDifference, new FluidStack(type.fluid, fluidAmount));
|
||||
addMelting(
|
||||
input,
|
||||
((ItemBlock) input.getItem()).field_150939_a,
|
||||
input.getItemDamage(),
|
||||
type.baseTemperature + temperatureDifference,
|
||||
new FluidStack(type.fluid, fluidAmount));
|
||||
else
|
||||
addMelting(input, type.renderBlock, type.renderMeta, type.baseTemperature + temperatureDifference, new FluidStack(type.fluid, fluidAmount));
|
||||
addMelting(
|
||||
input,
|
||||
type.renderBlock,
|
||||
type.renderMeta,
|
||||
type.baseTemperature + temperatureDifference,
|
||||
new FluidStack(type.fluid, fluidAmount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all Items to the Smeltery based on the oreDictionary Name
|
||||
*
|
||||
*
|
||||
* @author samtrion
|
||||
*
|
||||
*
|
||||
* @param oreName oreDictionary name e.g. oreIron
|
||||
* @param type Type of Fluid
|
||||
* @param temperatureDifference Difference between FluidType BaseTemperature
|
||||
* @param fluidAmount Amount of Fluid
|
||||
*/
|
||||
public static void addDictionaryMelting (String oreName, FluidType type, int temperatureDifference, int fluidAmount)
|
||||
{
|
||||
for (ItemStack is : OreDictionary.getOres(oreName))
|
||||
addMelting(type, is, temperatureDifference, fluidAmount);
|
||||
public static void addDictionaryMelting(
|
||||
String oreName, FluidType type, int temperatureDifference, int fluidAmount) {
|
||||
for (ItemStack is : OreDictionary.getOres(oreName)) addMelting(type, is, temperatureDifference, fluidAmount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,71 +4,62 @@ import java.util.*;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class StencilBuilder
|
||||
{
|
||||
public class StencilBuilder {
|
||||
public static StencilBuilder instance = new StencilBuilder();
|
||||
|
||||
public List<ItemStack> blanks = new LinkedList<ItemStack>(); // i wish ItemStack would support equals so i could use a Set here...
|
||||
public List<ItemStack> blanks =
|
||||
new LinkedList<ItemStack>(); // i wish ItemStack would support equals so i could use a Set here...
|
||||
public Map<Integer, ItemStack> stencils = new TreeMap<Integer, ItemStack>();
|
||||
|
||||
/**
|
||||
* Returns whether the given ItemStack is a blank pattern and therefore usable for stencil crafting.
|
||||
*/
|
||||
public static boolean isBlank (ItemStack stack)
|
||||
{
|
||||
public static boolean isBlank(ItemStack stack) {
|
||||
for (ItemStack blank : instance.blanks)
|
||||
if (OreDictionary.itemMatches(stack, blank, false)) // this has nothing to do with the oredictionary.
|
||||
return true;
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void registerBlankStencil (ItemStack itemStack)
|
||||
{
|
||||
public static void registerBlankStencil(ItemStack itemStack) {
|
||||
instance.blanks.add(itemStack);
|
||||
}
|
||||
|
||||
public static void registerStencil (int id, Item item, int meta)
|
||||
{
|
||||
public static void registerStencil(int id, Item item, int meta) {
|
||||
registerStencil(id, new ItemStack(item, 1, meta));
|
||||
}
|
||||
|
||||
public static void registerStencil (int id, ItemStack pattern)
|
||||
{
|
||||
if(instance.stencils.containsKey(id))
|
||||
throw new IllegalArgumentException("[TCon API] Stencil ID " + id + " is already occupied by " + instance.stencils.get(id).getDisplayName());
|
||||
public static void registerStencil(int id, ItemStack pattern) {
|
||||
if (instance.stencils.containsKey(id))
|
||||
throw new IllegalArgumentException("[TCon API] Stencil ID " + id + " is already occupied by "
|
||||
+ instance.stencils.get(id).getDisplayName());
|
||||
|
||||
instance.stencils.put(id, pattern);
|
||||
}
|
||||
|
||||
public static Collection<ItemStack> getStencils ()
|
||||
{
|
||||
public static Collection<ItemStack> getStencils() {
|
||||
return instance.stencils.values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the given stencil. If no stencil is found, returns -1.
|
||||
*/
|
||||
public static int getId(ItemStack stencil)
|
||||
{
|
||||
for(Map.Entry<Integer, ItemStack> entry : instance.stencils.entrySet())
|
||||
if (OreDictionary.itemMatches(stencil, entry.getValue(), false))
|
||||
return entry.getKey();
|
||||
public static int getId(ItemStack stencil) {
|
||||
for (Map.Entry<Integer, ItemStack> entry : instance.stencils.entrySet())
|
||||
if (OreDictionary.itemMatches(stencil, entry.getValue(), false)) return entry.getKey();
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// returns the stencil with the given index
|
||||
public static ItemStack getStencil (int num)
|
||||
{
|
||||
if (!instance.stencils.containsKey(num))
|
||||
return null;
|
||||
public static ItemStack getStencil(int num) {
|
||||
if (!instance.stencils.containsKey(num)) return null;
|
||||
|
||||
return instance.stencils.get(num).copy();
|
||||
}
|
||||
|
||||
public static int getStencilCount ()
|
||||
{
|
||||
public static int getStencilCount() {
|
||||
return instance.stencils.size();
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,7 @@ package tconstruct.library.crafting;
|
||||
|
||||
/** Once upon a time, too many tools to count. Let's put them together automatically */
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
@@ -15,8 +13,7 @@ import tconstruct.library.modifier.ItemModifier;
|
||||
import tconstruct.library.tools.*;
|
||||
import tconstruct.library.util.IToolPart;
|
||||
|
||||
public class ToolBuilder
|
||||
{
|
||||
public class ToolBuilder {
|
||||
public static ToolBuilder instance = new ToolBuilder();
|
||||
|
||||
public HashMap<String, ToolRecipe> recipeList = new HashMap<String, ToolRecipe>();
|
||||
@@ -24,110 +21,89 @@ public class ToolBuilder
|
||||
public HashMap<String, String> modifiers = new HashMap<String, String>();
|
||||
|
||||
/* Build tools */
|
||||
public static void addNormalToolRecipe (ToolCore output, Item head, Item handle)
|
||||
{
|
||||
public static void addNormalToolRecipe(ToolCore output, Item head, Item handle) {
|
||||
ToolRecipe recipe = instance.recipeList.get(output.getToolName());
|
||||
if (recipe != null)
|
||||
{
|
||||
if (recipe != null) {
|
||||
recipe.addHeadItem(head);
|
||||
recipe.addHandleItem(handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
recipe = new ToolRecipe(head, handle, output);
|
||||
instance.combos.add(recipe);
|
||||
instance.recipeList.put(output.getToolName(), recipe);
|
||||
}
|
||||
}
|
||||
|
||||
public static void addNormalToolRecipe (ToolCore output, Item head, Item handle, Item accessory)
|
||||
{
|
||||
//instance.combos.add(new ToolRecipe(head, accessory, output));
|
||||
public static void addNormalToolRecipe(ToolCore output, Item head, Item handle, Item accessory) {
|
||||
// instance.combos.add(new ToolRecipe(head, accessory, output));
|
||||
ToolRecipe recipe = instance.recipeList.get(output.getToolName());
|
||||
if (recipe != null)
|
||||
{
|
||||
if (recipe != null) {
|
||||
recipe.addHeadItem(head);
|
||||
recipe.addHandleItem(handle);
|
||||
recipe.addAccessoryItem(accessory);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
recipe = new ToolRecipe(head, handle, accessory, output);
|
||||
instance.combos.add(recipe);
|
||||
instance.recipeList.put(output.getToolName(), recipe);
|
||||
}
|
||||
}
|
||||
|
||||
public static void addNormalToolRecipe (ToolCore output, Item head, Item handle, Item accessory, Item extra)
|
||||
{
|
||||
public static void addNormalToolRecipe(ToolCore output, Item head, Item handle, Item accessory, Item extra) {
|
||||
ToolRecipe recipe = instance.recipeList.get(output.getToolName());
|
||||
if (recipe != null)
|
||||
{
|
||||
if (recipe != null) {
|
||||
recipe.addHeadItem(head);
|
||||
recipe.addHandleItem(handle);
|
||||
recipe.addAccessoryItem(accessory);
|
||||
recipe.addExtraItem(extra);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
recipe = new ToolRecipe(head, handle, accessory, extra, output);
|
||||
instance.combos.add(recipe);
|
||||
instance.recipeList.put(output.getToolName(), recipe);
|
||||
}
|
||||
}
|
||||
|
||||
public static void addCustomToolRecipe (ToolRecipe recipe)
|
||||
{
|
||||
public static void addCustomToolRecipe(ToolRecipe recipe) {
|
||||
instance.combos.add(recipe);
|
||||
}
|
||||
|
||||
public static void addToolRecipe (ToolCore output, Item... items)
|
||||
{
|
||||
if (items.length == 2)
|
||||
addNormalToolRecipe(output, items[0], items[1]);
|
||||
if (items.length == 3)
|
||||
addNormalToolRecipe(output, items[0], items[1], items[2]);
|
||||
if (items.length == 4)
|
||||
addNormalToolRecipe(output, items[0], items[1], items[2], items[3]);
|
||||
public static void addToolRecipe(ToolCore output, Item... items) {
|
||||
if (items.length == 2) addNormalToolRecipe(output, items[0], items[1]);
|
||||
if (items.length == 3) addNormalToolRecipe(output, items[0], items[1], items[2]);
|
||||
if (items.length == 4) addNormalToolRecipe(output, items[0], items[1], items[2], items[3]);
|
||||
}
|
||||
|
||||
public ToolCore getMatchingRecipe (Item head, Item handle, Item accessory, Item extra)
|
||||
{
|
||||
for (ToolRecipe recipe : combos)
|
||||
{
|
||||
if (recipe.validHead(head) && recipe.validHandle(handle) && recipe.validAccessory(accessory) && recipe.validExtra(extra))
|
||||
return recipe.getType();
|
||||
public ToolCore getMatchingRecipe(Item head, Item handle, Item accessory, Item extra) {
|
||||
for (ToolRecipe recipe : combos) {
|
||||
if (recipe.validHead(head)
|
||||
&& recipe.validHandle(handle)
|
||||
&& recipe.validAccessory(accessory)
|
||||
&& recipe.validExtra(extra)) return recipe.getType();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//Builds a tool from the parts given
|
||||
public ItemStack buildTool (ItemStack headStack, ItemStack handleStack, ItemStack accessoryStack, String name)
|
||||
{
|
||||
// Builds a tool from the parts given
|
||||
public ItemStack buildTool(ItemStack headStack, ItemStack handleStack, ItemStack accessoryStack, String name) {
|
||||
return buildTool(headStack, handleStack, accessoryStack, null, name);
|
||||
}
|
||||
|
||||
public int getMaterialID (ItemStack stack)
|
||||
{
|
||||
if (stack == null)
|
||||
return -1;
|
||||
public int getMaterialID(ItemStack stack) {
|
||||
if (stack == null) return -1;
|
||||
Item item = stack.getItem();
|
||||
|
||||
if (item instanceof IToolPart)
|
||||
return ((IToolPart) item).getMaterialID(stack);
|
||||
if (item instanceof IToolPart) return ((IToolPart) item).getMaterialID(stack);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public ItemStack buildTool (ItemStack headStack, ItemStack handleStack, ItemStack accessoryStack, ItemStack extraStack, String name)
|
||||
{
|
||||
public ItemStack buildTool(
|
||||
ItemStack headStack, ItemStack handleStack, ItemStack accessoryStack, ItemStack extraStack, String name) {
|
||||
/*if (headStack != null && headStack.getItem() instanceof ToolCore)
|
||||
return modifyTool(headStack, new ItemStack[] { handleStack, accessoryStack, extraStack }, name);*/
|
||||
return modifyTool(headStack, new ItemStack[] { handleStack, accessoryStack, extraStack }, name);*/
|
||||
|
||||
if (headStack == null || handleStack == null) //Nothing to build without these. All tools need at least two parts!
|
||||
return null;
|
||||
if (name == null)
|
||||
name = "";
|
||||
if (headStack == null
|
||||
|| handleStack == null) // Nothing to build without these. All tools need at least two parts!
|
||||
return null;
|
||||
if (name == null) name = "";
|
||||
|
||||
// fire the ToolBuild event to get the correct items
|
||||
ToolBuildEvent buildEvent = new ToolBuildEvent(headStack, handleStack, accessoryStack, extraStack, name);
|
||||
@@ -144,54 +120,41 @@ public class ToolBuilder
|
||||
boolean validMaterials = true;
|
||||
int head = -1, handle = -1, accessory = -1, extra = -1;
|
||||
head = getMaterialID(headStack);
|
||||
if (head == -1)
|
||||
validMaterials = false;
|
||||
if (head == -1) validMaterials = false;
|
||||
|
||||
handle = getMaterialID(handleStack);
|
||||
if (handle == -1)
|
||||
validMaterials = false;
|
||||
if (handle == -1) validMaterials = false;
|
||||
|
||||
if (!validMaterials)
|
||||
return null;
|
||||
if (!validMaterials) return null;
|
||||
|
||||
if (accessoryStack == null)
|
||||
{
|
||||
if (accessoryStack == null) {
|
||||
item = getMatchingRecipe(headStack.getItem(), handleStack.getItem(), null, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
|
||||
accessory = getMaterialID(accessoryStack);
|
||||
if (accessory == -1)
|
||||
return null;
|
||||
if (accessory == -1) return null;
|
||||
|
||||
if (extraStack != null)
|
||||
{
|
||||
if (extraStack != null) {
|
||||
|
||||
extra = getMaterialID(extraStack);
|
||||
if (extra == -1)
|
||||
return null;
|
||||
if (extra == -1) return null;
|
||||
|
||||
item = getMatchingRecipe(headStack.getItem(), handleStack.getItem(), accessoryStack.getItem(), extraStack.getItem());
|
||||
}
|
||||
else
|
||||
{
|
||||
item = getMatchingRecipe(
|
||||
headStack.getItem(), handleStack.getItem(), accessoryStack.getItem(), extraStack.getItem());
|
||||
} else {
|
||||
item = getMatchingRecipe(headStack.getItem(), handleStack.getItem(), accessoryStack.getItem(), null);
|
||||
}
|
||||
}
|
||||
|
||||
if (item == null)
|
||||
return null;
|
||||
if (item == null) return null;
|
||||
|
||||
ToolMaterial headMat = null, handleMat = null, accessoryMat = null, extraMat = null;
|
||||
headMat = TConstructRegistry.getMaterial(head);
|
||||
handleMat = TConstructRegistry.getMaterial(handle);
|
||||
|
||||
if (accessory != -1)
|
||||
accessoryMat = TConstructRegistry.getMaterial(accessory);
|
||||
if (accessory != -1) accessoryMat = TConstructRegistry.getMaterial(accessory);
|
||||
|
||||
if (extra != -1)
|
||||
extraMat = TConstructRegistry.getMaterial(extra);
|
||||
if (extra != -1) extraMat = TConstructRegistry.getMaterial(extra);
|
||||
|
||||
int durability = headMat.durability();
|
||||
int heads = 1;
|
||||
@@ -199,58 +162,45 @@ public class ToolBuilder
|
||||
float modifier = 1f;
|
||||
int attack = headMat.attack();
|
||||
|
||||
if (item.durabilityTypeHandle() == 2)
|
||||
{
|
||||
if (item.durabilityTypeHandle() == 2) {
|
||||
heads++;
|
||||
durability += handleMat.durability();
|
||||
attack += handleMat.attack();
|
||||
}
|
||||
else if (item.durabilityTypeHandle() == 1)
|
||||
{
|
||||
} else if (item.durabilityTypeHandle() == 1) {
|
||||
handles++;
|
||||
modifier = handleMat.handleDurability();
|
||||
}
|
||||
|
||||
if (accessory != -1)
|
||||
{
|
||||
if (item.durabilityTypeAccessory() == 2)
|
||||
{
|
||||
if (accessory != -1) {
|
||||
if (item.durabilityTypeAccessory() == 2) {
|
||||
heads++;
|
||||
durability += accessoryMat.durability();
|
||||
attack += accessoryMat.attack();
|
||||
}
|
||||
else if (item.durabilityTypeAccessory() == 1)
|
||||
{
|
||||
} else if (item.durabilityTypeAccessory() == 1) {
|
||||
handles++;
|
||||
modifier += accessoryMat.handleDurability();
|
||||
}
|
||||
}
|
||||
|
||||
if (extra != -1)
|
||||
{
|
||||
if (item.durabilityTypeExtra() == 2)
|
||||
{
|
||||
if (extra != -1) {
|
||||
if (item.durabilityTypeExtra() == 2) {
|
||||
heads++;
|
||||
durability += extraMat.durability();
|
||||
attack += extraMat.attack();
|
||||
}
|
||||
else if (item.durabilityTypeExtra() == 1)
|
||||
{
|
||||
} else if (item.durabilityTypeExtra() == 1) {
|
||||
handles++;
|
||||
modifier += extraMat.handleDurability();
|
||||
}
|
||||
}
|
||||
|
||||
if (handles > 0)
|
||||
{
|
||||
if (handles > 0) {
|
||||
modifier *= (0.5 + handles * 0.5);
|
||||
modifier /= handles;
|
||||
}
|
||||
|
||||
durability = (int) (durability / heads * (0.5 + heads * 0.5) * modifier * item.getDurabilityModifier());
|
||||
attack = attack / heads + item.getDamageVsEntity(null);
|
||||
if (attack % heads != 0)
|
||||
attack++;
|
||||
if (attack % heads != 0) attack++;
|
||||
|
||||
ItemStack tool = new ItemStack(item);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
@@ -262,75 +212,65 @@ public class ToolBuilder
|
||||
compound.getCompoundTag("InfiTool").setInteger("Handle", handle);
|
||||
compound.getCompoundTag("InfiTool").setInteger("RenderHandle", handle);
|
||||
|
||||
if (accessory != -1)
|
||||
{
|
||||
if (accessory != -1) {
|
||||
compound.getCompoundTag("InfiTool").setInteger("Accessory", accessory);
|
||||
compound.getCompoundTag("InfiTool").setInteger("RenderAccessory", accessory);
|
||||
}
|
||||
if (extra != -1)
|
||||
{
|
||||
if (extra != -1) {
|
||||
compound.getCompoundTag("InfiTool").setInteger("Extra", extra);
|
||||
compound.getCompoundTag("InfiTool").setInteger("RenderExtra", extra);
|
||||
}
|
||||
|
||||
compound.getCompoundTag("InfiTool").setInteger("Damage", 0); //Damage is damage to the tool
|
||||
compound.getCompoundTag("InfiTool").setInteger("Damage", 0); // Damage is damage to the tool
|
||||
compound.getCompoundTag("InfiTool").setInteger("TotalDurability", durability);
|
||||
compound.getCompoundTag("InfiTool").setInteger("BaseDurability", durability);
|
||||
compound.getCompoundTag("InfiTool").setInteger("BonusDurability", 0); //Modifier
|
||||
compound.getCompoundTag("InfiTool").setFloat("ModDurability", 0f); //Modifier
|
||||
compound.getCompoundTag("InfiTool").setInteger("BonusDurability", 0); // Modifier
|
||||
compound.getCompoundTag("InfiTool").setFloat("ModDurability", 0f); // Modifier
|
||||
compound.getCompoundTag("InfiTool").setBoolean("Broken", false);
|
||||
compound.getCompoundTag("InfiTool").setInteger("Attack", attack);
|
||||
compound.getCompoundTag("InfiTool").setInteger("BaseAttack", attack);
|
||||
|
||||
compound.getCompoundTag("InfiTool").setInteger("MiningSpeed", headMat.toolSpeed());
|
||||
compound.getCompoundTag("InfiTool").setInteger("HarvestLevel", headMat.harvestLevel());
|
||||
if (item.durabilityTypeHandle() == 2)
|
||||
{
|
||||
if (item.durabilityTypeHandle() == 2) {
|
||||
compound.getCompoundTag("InfiTool").setInteger("MiningSpeedHandle", handleMat.toolSpeed());
|
||||
compound.getCompoundTag("InfiTool").setInteger("HarvestLevelHandle", handleMat.harvestLevel());
|
||||
}
|
||||
if (accessory != -1 && item.durabilityTypeAccessory() == 2)
|
||||
{
|
||||
if (accessory != -1 && item.durabilityTypeAccessory() == 2) {
|
||||
compound.getCompoundTag("InfiTool").setInteger("MiningSpeed2", accessoryMat.toolSpeed());
|
||||
compound.getCompoundTag("InfiTool").setInteger("HarvestLevel2", accessoryMat.harvestLevel());
|
||||
}
|
||||
|
||||
if (extra != -1 && item.durabilityTypeExtra() == 2)
|
||||
{
|
||||
if (extra != -1 && item.durabilityTypeExtra() == 2) {
|
||||
compound.getCompoundTag("InfiTool").setInteger("MiningSpeedExtra", extraMat.toolSpeed());
|
||||
compound.getCompoundTag("InfiTool").setInteger("HarvestLevelExtra", extraMat.harvestLevel());
|
||||
}
|
||||
|
||||
compound.getCompoundTag("InfiTool").setInteger("Unbreaking", buildReinforced(headMat, handleMat, accessoryMat, extraMat));
|
||||
compound.getCompoundTag("InfiTool")
|
||||
.setInteger("Unbreaking", buildReinforced(headMat, handleMat, accessoryMat, extraMat));
|
||||
compound.getCompoundTag("InfiTool").setFloat("Shoddy", buildShoddy(headMat, handleMat, accessoryMat, extraMat));
|
||||
|
||||
compound.getCompoundTag("InfiTool").setInteger("Modifiers", item.getModifierAmount());
|
||||
|
||||
if (name != null && !name.equals(""))
|
||||
{
|
||||
if (name != null && !name.equals("")) {
|
||||
compound.setTag("display", new NBTTagCompound());
|
||||
compound.getCompoundTag("display").setString("Name", "\u00A7f" + name);
|
||||
}
|
||||
// set a nice default name
|
||||
else
|
||||
{
|
||||
else {
|
||||
compound.setTag("display", new NBTTagCompound());
|
||||
compound.getCompoundTag("display").setString("Name", "\u00A7f" + defaultToolName(headMat, item));
|
||||
}
|
||||
|
||||
ToolCraftEvent.NormalTool event = new ToolCraftEvent.NormalTool(item, compound, new ToolMaterial[] { headMat, handleMat, accessoryMat, extraMat });
|
||||
ToolCraftEvent.NormalTool event = new ToolCraftEvent.NormalTool(
|
||||
item, compound, new ToolMaterial[] {headMat, handleMat, accessoryMat, extraMat});
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
if (event.getResult() == Result.DEFAULT)
|
||||
{
|
||||
if (event.getResult() == Result.DEFAULT) {
|
||||
tool.setTagCompound(compound);
|
||||
}
|
||||
else if (event.getResult() == Result.ALLOW)
|
||||
{
|
||||
} else if (event.getResult() == Result.ALLOW) {
|
||||
tool = event.getResultStack();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
tool = null;
|
||||
}
|
||||
|
||||
@@ -375,78 +315,63 @@ public class ToolBuilder
|
||||
return null;
|
||||
}*/
|
||||
|
||||
int buildReinforced (ToolMaterial headMat, ToolMaterial handleMat, ToolMaterial accessoryMat, ToolMaterial extraMat)
|
||||
{
|
||||
int buildReinforced(
|
||||
ToolMaterial headMat, ToolMaterial handleMat, ToolMaterial accessoryMat, ToolMaterial extraMat) {
|
||||
int reinforced = 0;
|
||||
|
||||
int dHead = headMat.reinforced();
|
||||
int dHandle = handleMat.reinforced();
|
||||
int dAccessory = 0;
|
||||
if (accessoryMat != null)
|
||||
dAccessory = accessoryMat.reinforced();
|
||||
if (accessoryMat != null) dAccessory = accessoryMat.reinforced();
|
||||
int dExtra = 0;
|
||||
if (extraMat != null)
|
||||
dExtra = extraMat.reinforced();
|
||||
if (extraMat != null) dExtra = extraMat.reinforced();
|
||||
|
||||
if (dHead > reinforced)
|
||||
reinforced = dHead;
|
||||
if (dHandle > reinforced)
|
||||
reinforced = dHandle;
|
||||
if (dAccessory > reinforced)
|
||||
reinforced = dAccessory;
|
||||
if (dExtra > reinforced)
|
||||
reinforced = dExtra;
|
||||
if (dHead > reinforced) reinforced = dHead;
|
||||
if (dHandle > reinforced) reinforced = dHandle;
|
||||
if (dAccessory > reinforced) reinforced = dAccessory;
|
||||
if (dExtra > reinforced) reinforced = dExtra;
|
||||
|
||||
return reinforced;
|
||||
}
|
||||
|
||||
float buildShoddy (ToolMaterial headMat, ToolMaterial handleMat, ToolMaterial accessoryMat, ToolMaterial extraMat)
|
||||
{
|
||||
float buildShoddy(ToolMaterial headMat, ToolMaterial handleMat, ToolMaterial accessoryMat, ToolMaterial extraMat) {
|
||||
float sHead = headMat.shoddy();
|
||||
float sHandle = handleMat.shoddy();
|
||||
if (extraMat != null)
|
||||
{
|
||||
if (extraMat != null) {
|
||||
float sAccessory = accessoryMat.shoddy();
|
||||
float sExtra = extraMat.shoddy();
|
||||
return (sHead + sHandle + sAccessory + sExtra) / 4f;
|
||||
}
|
||||
|
||||
if (accessoryMat != null)
|
||||
{
|
||||
if (accessoryMat != null) {
|
||||
float sAccessory = accessoryMat.shoddy();
|
||||
return (sHead + sHandle + sAccessory) / 3f;
|
||||
}
|
||||
return (sHead + sHandle) / 2f;
|
||||
}
|
||||
|
||||
public static String defaultToolName (ItemStack stack)
|
||||
{
|
||||
if (!stack.hasTagCompound() || !stack.getTagCompound().hasKey("InfiTool"))
|
||||
return null;
|
||||
if (!(stack.getItem() instanceof ToolCore))
|
||||
return null;
|
||||
public static String defaultToolName(ItemStack stack) {
|
||||
if (!stack.hasTagCompound() || !stack.getTagCompound().hasKey("InfiTool")) return null;
|
||||
if (!(stack.getItem() instanceof ToolCore)) return null;
|
||||
|
||||
int mat = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Head");
|
||||
return defaultToolName(TConstructRegistry.getMaterial(mat), (ToolCore) stack.getItem());
|
||||
}
|
||||
|
||||
public static String defaultToolName (ToolMaterial headMat, ToolCore tool)
|
||||
{
|
||||
public static String defaultToolName(ToolMaterial headMat, ToolCore tool) {
|
||||
String toolName = tool.getToolName().toLowerCase();
|
||||
String matName = headMat.materialName.toLowerCase().replaceAll(" ", "").replaceAll("_","");
|
||||
|
||||
if (StatCollector.canTranslate("tool." + toolName + "." + matName))
|
||||
{
|
||||
String matName = headMat.materialName.toLowerCase().replaceAll(" ", "").replaceAll("_", "");
|
||||
|
||||
if (StatCollector.canTranslate("tool." + toolName + "." + matName)) {
|
||||
return StatCollector.translateToLocal("tool." + toolName + "." + matName);
|
||||
}
|
||||
|
||||
|
||||
return String.format("%s %s", headMat.prefixName(), tool.getLocalizedToolName());
|
||||
}
|
||||
|
||||
//Passthrough for now
|
||||
// Passthrough for now
|
||||
@Deprecated
|
||||
public static void registerToolMod (ItemModifier mod)
|
||||
{
|
||||
public static void registerToolMod(ItemModifier mod) {
|
||||
ModifyBuilder.registerModifier(mod);
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,7 @@ import tconstruct.library.tools.ToolCore;
|
||||
* Small class for checking if a particular tool combination is this one
|
||||
*/
|
||||
|
||||
public class ToolRecipe
|
||||
{
|
||||
public class ToolRecipe {
|
||||
protected LinkedList<Item> headList = new LinkedList<Item>();
|
||||
protected LinkedList<Item> handleList = new LinkedList<Item>();
|
||||
protected LinkedList<Item> accessoryList = new LinkedList<Item>();
|
||||
@@ -24,107 +23,78 @@ public class ToolRecipe
|
||||
* TContent.toolRod, null, null, tool); }
|
||||
*/
|
||||
|
||||
public ToolRecipe(Item head, Item handle, ToolCore tool)
|
||||
{
|
||||
public ToolRecipe(Item head, Item handle, ToolCore tool) {
|
||||
this(head, handle, null, null, tool);
|
||||
}
|
||||
|
||||
public ToolRecipe(Item head, Item handle, Item accessory, ToolCore tool)
|
||||
{
|
||||
public ToolRecipe(Item head, Item handle, Item accessory, ToolCore tool) {
|
||||
this(head, handle, accessory, null, tool);
|
||||
}
|
||||
|
||||
public ToolRecipe(Item head, Item handle, Item accessory, Item extra, ToolCore tool)
|
||||
{
|
||||
public ToolRecipe(Item head, Item handle, Item accessory, Item extra, ToolCore tool) {
|
||||
this.headList.add(head);
|
||||
this.handleList.add(handle);
|
||||
if (accessory != null)
|
||||
this.accessoryList.add(accessory);
|
||||
if (extra != null)
|
||||
this.extraList.add(extra);
|
||||
if (accessory != null) this.accessoryList.add(accessory);
|
||||
if (extra != null) this.extraList.add(extra);
|
||||
result = tool;
|
||||
}
|
||||
|
||||
public void addHeadItem (Item head)
|
||||
{
|
||||
public void addHeadItem(Item head) {
|
||||
this.headList.add(head);
|
||||
}
|
||||
|
||||
public void addHandleItem (Item head)
|
||||
{
|
||||
public void addHandleItem(Item head) {
|
||||
this.handleList.add(head);
|
||||
}
|
||||
|
||||
public void addAccessoryItem (Item head)
|
||||
{
|
||||
public void addAccessoryItem(Item head) {
|
||||
this.accessoryList.add(head);
|
||||
}
|
||||
|
||||
public void addExtraItem (Item head)
|
||||
{
|
||||
public void addExtraItem(Item head) {
|
||||
this.extraList.add(head);
|
||||
}
|
||||
|
||||
public boolean validHead (Item input)
|
||||
{
|
||||
for (Item part : headList)
|
||||
{
|
||||
if (part == input)
|
||||
return true;
|
||||
public boolean validHead(Item input) {
|
||||
for (Item part : headList) {
|
||||
if (part == input) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean validHandle (Item input)
|
||||
{
|
||||
for (Item part : handleList)
|
||||
{
|
||||
if (part == input)
|
||||
return true;
|
||||
if (toolRod != null && part == toolRod && (input == Items.stick || input == Items.bone))
|
||||
return true;
|
||||
public boolean validHandle(Item input) {
|
||||
for (Item part : handleList) {
|
||||
if (part == input) return true;
|
||||
if (toolRod != null && part == toolRod && (input == Items.stick || input == Items.bone)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean validAccessory (Item input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
if (accessoryList.size() < 1)
|
||||
return true;
|
||||
public boolean validAccessory(Item input) {
|
||||
if (input == null) {
|
||||
if (accessoryList.size() < 1) return true;
|
||||
return false;
|
||||
}
|
||||
for (Item part : accessoryList)
|
||||
{
|
||||
if (part == input)
|
||||
return true;
|
||||
if (toolRod != null && part == toolRod && (input == Items.stick || input == Items.bone))
|
||||
return true;
|
||||
for (Item part : accessoryList) {
|
||||
if (part == input) return true;
|
||||
if (toolRod != null && part == toolRod && (input == Items.stick || input == Items.bone)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean validExtra (Item input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
if (extraList.size() < 1)
|
||||
return true;
|
||||
public boolean validExtra(Item input) {
|
||||
if (input == null) {
|
||||
if (extraList.size() < 1) return true;
|
||||
return false;
|
||||
}
|
||||
for (Item part : extraList)
|
||||
{
|
||||
if (part == input)
|
||||
return true;
|
||||
if (toolRod != null && part == toolRod && (input == Items.stick || input == Items.bone))
|
||||
return true;
|
||||
for (Item part : extraList) {
|
||||
if (part == input) return true;
|
||||
if (toolRod != null && part == toolRod && (input == Items.stick || input == Items.bone)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ToolCore getType ()
|
||||
{
|
||||
public ToolCore getType() {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
package tconstruct.library.entity;
|
||||
|
||||
import tconstruct.library.weaponry.AmmoItem;
|
||||
import tconstruct.util.Reference;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
@@ -14,7 +13,6 @@ import net.minecraft.entity.monster.EntityEnderman;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.play.server.S2BPacketChangeGameState;
|
||||
@@ -24,14 +22,14 @@ import tconstruct.library.ActiveToolMod;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.library.weaponry.AmmoItem;
|
||||
import tconstruct.util.Reference;
|
||||
import tconstruct.weaponry.entity.ArrowEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
// have to base this on EntityArrow, otherwise minecraft does derp things because everything is handled based on class.
|
||||
public abstract class ProjectileBase extends EntityArrow implements IEntityAdditionalSpawnData {
|
||||
public final static String woodSound = Reference.resource("woodHit");
|
||||
public final static String stoneSound = Reference.resource("stoneHit");
|
||||
public static final String woodSound = Reference.resource("woodHit");
|
||||
public static final String stoneSound = Reference.resource("stoneHit");
|
||||
|
||||
public ItemStack returnStack;
|
||||
|
||||
@@ -55,18 +53,25 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
canBePickedUp = 1;
|
||||
|
||||
// stuff from the arrow
|
||||
this.setLocationAndAngles(player.posX, player.posY + (double)player.getEyeHeight(), player.posZ, player.rotationYaw, player.rotationPitch);
|
||||
this.setLocationAndAngles(
|
||||
player.posX,
|
||||
player.posY + (double) player.getEyeHeight(),
|
||||
player.posZ,
|
||||
player.rotationYaw,
|
||||
player.rotationPitch);
|
||||
this.setPosition(this.posX, this.posY, this.posZ);
|
||||
this.yOffset = 0.0F;
|
||||
this.motionX = -MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI);
|
||||
this.motionZ = +MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI);
|
||||
this.motionY = -MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI);
|
||||
this.motionX = -MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI)
|
||||
* MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI);
|
||||
this.motionZ = +MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI)
|
||||
* MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI);
|
||||
this.motionY = -MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI);
|
||||
this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, speed, accuracy);
|
||||
|
||||
// our stuff
|
||||
returnStack = stack;
|
||||
|
||||
/*
|
||||
/*
|
||||
// fix upward default angle
|
||||
motionY = -MathHelper.sin((rotationPitch / 180F) * 3.141593F - 0.2f);
|
||||
setArrowHeading(motionX, motionY, motionZ, speed, 0.0f);
|
||||
@@ -85,68 +90,66 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
posZ += vz*1.5f;
|
||||
*/
|
||||
|
||||
//init();
|
||||
// init();
|
||||
}
|
||||
|
||||
public ItemStack getEntityItem ()
|
||||
{
|
||||
public ItemStack getEntityItem() {
|
||||
return returnStack;
|
||||
}
|
||||
|
||||
protected void playHitBlockSound(int x, int y, int z)
|
||||
{
|
||||
Block block = worldObj.getBlock(x,y,z);
|
||||
if(block != null && block.blockMaterial == Material.wood)
|
||||
protected void playHitBlockSound(int x, int y, int z) {
|
||||
Block block = worldObj.getBlock(x, y, z);
|
||||
if (block != null && block.blockMaterial == Material.wood)
|
||||
worldObj.playSoundAtEntity(this, woodSound, 1.0f, 1.0f);
|
||||
else {
|
||||
worldObj.playSoundAtEntity(this, stoneSound, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
if(block != null)
|
||||
worldObj.playSoundAtEntity(this, block.stepSound.getBreakSound(), 0.7f, 1.0f);
|
||||
if (block != null) worldObj.playSoundAtEntity(this, block.stepSound.getBreakSound(), 0.7f, 1.0f);
|
||||
}
|
||||
|
||||
protected void playHitEntitySound()
|
||||
{
|
||||
|
||||
}
|
||||
protected void playHitEntitySound() {}
|
||||
|
||||
/**
|
||||
* How deep the item enters stuff it hits. Should be bigger for bigger objects, and smaller for smaller objects.
|
||||
* 1.0f is exactly halfway in.
|
||||
*/
|
||||
protected double getStuckDepth() { return 0.5f; }
|
||||
protected double getStuckDepth() {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
protected void doLivingHit(EntityLivingBase entityHit)
|
||||
{
|
||||
float knockback = returnStack.getTagCompound().getCompoundTag("InfiTool").getFloat("Knockback");
|
||||
if(shootingEntity instanceof EntityLivingBase)
|
||||
protected void doLivingHit(EntityLivingBase entityHit) {
|
||||
float knockback =
|
||||
returnStack.getTagCompound().getCompoundTag("InfiTool").getFloat("Knockback");
|
||||
if (shootingEntity instanceof EntityLivingBase)
|
||||
knockback += EnchantmentHelper.getKnockbackModifier((EntityLivingBase) shootingEntity, entityHit);
|
||||
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (!this.worldObj.isRemote) {
|
||||
entityHit.setArrowCountInEntity(entityHit.getArrowCountInEntity() + 1);
|
||||
}
|
||||
|
||||
if (knockback > 0)
|
||||
{
|
||||
if (knockback > 0) {
|
||||
double horizontalSpeed = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||
|
||||
if (horizontalSpeed > 0.0F)
|
||||
{
|
||||
entityHit.addVelocity(this.motionX * (double) knockback * 0.6000000238418579D / horizontalSpeed, 0.1D, this.motionZ * (double) knockback * 0.6000000238418579D / (double) horizontalSpeed);
|
||||
if (horizontalSpeed > 0.0F) {
|
||||
entityHit.addVelocity(
|
||||
this.motionX * (double) knockback * 0.6000000238418579D / horizontalSpeed,
|
||||
0.1D,
|
||||
this.motionZ * (double) knockback * 0.6000000238418579D / (double) horizontalSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.shootingEntity != null && this.shootingEntity instanceof EntityLivingBase)
|
||||
{
|
||||
if (this.shootingEntity != null && this.shootingEntity instanceof EntityLivingBase) {
|
||||
EnchantmentHelper.func_151384_a(entityHit, this.shootingEntity);
|
||||
EnchantmentHelper.func_151385_b((EntityLivingBase)this.shootingEntity, entityHit);
|
||||
EnchantmentHelper.func_151385_b((EntityLivingBase) this.shootingEntity, entityHit);
|
||||
}
|
||||
|
||||
if (this.shootingEntity != null && entityHit != this.shootingEntity && entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP)
|
||||
{
|
||||
((EntityPlayerMP)this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F));
|
||||
if (this.shootingEntity != null
|
||||
&& entityHit != this.shootingEntity
|
||||
&& entityHit instanceof EntityPlayer
|
||||
&& this.shootingEntity instanceof EntityPlayerMP) {
|
||||
((EntityPlayerMP) this.shootingEntity)
|
||||
.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +162,9 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
this.motionX = movingobjectposition.hitVec.xCoord - this.posX;
|
||||
this.motionY = movingobjectposition.hitVec.yCoord - this.posY;
|
||||
this.motionZ = movingobjectposition.hitVec.zCoord - this.posZ;
|
||||
double speed = getStuckDepth() * MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
|
||||
double speed = getStuckDepth()
|
||||
* MathHelper.sqrt_double(
|
||||
this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
|
||||
this.posX -= this.motionX / speed * 0.05000000074505806D;
|
||||
this.posY -= this.motionY / speed * 0.05000000074505806D;
|
||||
this.posZ -= this.motionZ / speed * 0.05000000074505806D;
|
||||
@@ -171,36 +176,36 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
this.setIsCritical(false);
|
||||
this.defused = true; // defuse it so it doesn't hit stuff anymore, being weird
|
||||
|
||||
if (this.field_145790_g.getMaterial() != Material.air)
|
||||
{
|
||||
this.field_145790_g.onEntityCollidedWithBlock(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f, this);
|
||||
if (this.field_145790_g.getMaterial() != Material.air) {
|
||||
this.field_145790_g.onEntityCollidedWithBlock(
|
||||
this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f, this);
|
||||
}
|
||||
}
|
||||
|
||||
public void onHitEntity(MovingObjectPosition movingobjectposition) {
|
||||
NBTTagCompound tags = returnStack.getTagCompound().getCompoundTag("InfiTool");
|
||||
float speed = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
|
||||
float speed = MathHelper.sqrt_double(
|
||||
this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
|
||||
|
||||
// absolute distance travelled minus the current tick
|
||||
float distance = speed * (this.ticksInAir-1);
|
||||
float distance = speed * (this.ticksInAir - 1);
|
||||
// distance travelled in the current tick
|
||||
float dist2 = 0;
|
||||
dist2 += MathHelper.abs((float)movingobjectposition.entityHit.lastTickPosX - (float)this.lastTickPosX);
|
||||
dist2 += MathHelper.abs((float)movingobjectposition.entityHit.lastTickPosY - (float)this.lastTickPosY);
|
||||
dist2 += MathHelper.abs((float)movingobjectposition.entityHit.lastTickPosZ - (float)this.lastTickPosZ);
|
||||
dist2 += MathHelper.abs((float) movingobjectposition.entityHit.lastTickPosX - (float) this.lastTickPosX);
|
||||
dist2 += MathHelper.abs((float) movingobjectposition.entityHit.lastTickPosY - (float) this.lastTickPosY);
|
||||
dist2 += MathHelper.abs((float) movingobjectposition.entityHit.lastTickPosZ - (float) this.lastTickPosZ);
|
||||
dist2 = MathHelper.sqrt_double(dist2);
|
||||
|
||||
distance += dist2;
|
||||
|
||||
if(!tags.hasKey("BaseAttack"))
|
||||
{
|
||||
if (!tags.hasKey("BaseAttack")) {
|
||||
// quickly calculate the base attack damage from the actual attack damage and quartz modifiers
|
||||
// yes, this relies on quartz being the only modifier that modifiers damage, but at the point of writing this
|
||||
// yes, this relies on quartz being the only modifier that modifiers damage, but at the point of writing
|
||||
// this
|
||||
// that is the case, and later tools should have the tag
|
||||
int atk = tags.getInteger("Attack");
|
||||
if(tags.hasKey("ModAttack"))
|
||||
{
|
||||
int bonusDmg = tags.getIntArray("ModAttack")[0]/24 + 1;
|
||||
if (tags.hasKey("ModAttack")) {
|
||||
int bonusDmg = tags.getIntArray("ModAttack")[0] / 24 + 1;
|
||||
atk -= bonusDmg;
|
||||
}
|
||||
tags.setInteger("BaseAttack", atk);
|
||||
@@ -208,65 +213,79 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
|
||||
float baseAttack = tags.getInteger("BaseAttack");
|
||||
float totalAttack = tags.getInteger("Attack");
|
||||
float damage = speed * baseAttack; // todo: potentially change this back to MathHelper.ceiling_float_int to get 1/2 heart steps back
|
||||
float damage = speed
|
||||
* baseAttack; // todo: potentially change this back to MathHelper.ceiling_float_int to get 1/2 heart
|
||||
// steps back
|
||||
|
||||
// add quartz damage
|
||||
damage += (totalAttack - baseAttack);
|
||||
|
||||
// this is needed so really high scaling bow&arrow combinations don't get out of hand
|
||||
if(this instanceof ArrowEntity)
|
||||
damage = Math.max(0, damage - totalAttack/2f);
|
||||
if (this instanceof ArrowEntity) damage = Math.max(0, damage - totalAttack / 2f);
|
||||
|
||||
boolean shotByPlayer = this.shootingEntity != null && this.shootingEntity instanceof EntityPlayer;
|
||||
|
||||
// Damage calculations and stuff. For reference see AbilityHelper.onLeftClickEntity
|
||||
ToolCore ammo = (ToolCore)returnStack.getItem();
|
||||
ToolCore ammo = (ToolCore) returnStack.getItem();
|
||||
|
||||
// factor in modified stuff for base damage
|
||||
// basically we pass the base damage to all modifiers and take the highest one
|
||||
int baseDamage = 0;
|
||||
if(shotByPlayer) // prevent crashes with other things reflecting/shooting them
|
||||
for(ActiveToolMod toolmod : TConstructRegistry.activeModifiers) {
|
||||
int dmg = toolmod.baseAttackDamage(baseDamage, (int)damage, ammo, returnStack.getTagCompound(), tags, returnStack, (EntityPlayer)this.shootingEntity, movingobjectposition.entityHit);
|
||||
if(dmg > baseDamage)
|
||||
baseDamage = dmg;
|
||||
if (shotByPlayer) // prevent crashes with other things reflecting/shooting them
|
||||
for (ActiveToolMod toolmod : TConstructRegistry.activeModifiers) {
|
||||
int dmg = toolmod.baseAttackDamage(
|
||||
baseDamage,
|
||||
(int) damage,
|
||||
ammo,
|
||||
returnStack.getTagCompound(),
|
||||
tags,
|
||||
returnStack,
|
||||
(EntityPlayer) this.shootingEntity,
|
||||
movingobjectposition.entityHit);
|
||||
if (dmg > baseDamage) baseDamage = dmg;
|
||||
}
|
||||
damage += baseDamage;
|
||||
|
||||
// damage modification from the weapon itself
|
||||
damage *= ammo.getDamageModifier();
|
||||
|
||||
// unlike the regular weapons, we do no gain more damage from potion of strength/weakness since we don't hit stuff directly
|
||||
// unlike the regular weapons, we do no gain more damage from potion of strength/weakness since we don't hit
|
||||
// stuff directly
|
||||
|
||||
// stonebound decreases, jagged increases damage too
|
||||
float bonusDamage = -AbilityHelper.calcStoneboundBonus(ammo, tags);
|
||||
// enchantments might add too
|
||||
if(shootingEntity != null && movingobjectposition.entityHit instanceof EntityLivingBase)
|
||||
bonusDamage += EnchantmentHelper.getEnchantmentModifierLiving((EntityLivingBase)this.shootingEntity, (EntityLivingBase)movingobjectposition.entityHit);
|
||||
if (shootingEntity != null && movingobjectposition.entityHit instanceof EntityLivingBase)
|
||||
bonusDamage += EnchantmentHelper.getEnchantmentModifierLiving(
|
||||
(EntityLivingBase) this.shootingEntity, (EntityLivingBase) movingobjectposition.entityHit);
|
||||
damage += bonusDamage;
|
||||
|
||||
// ensure we still have damage
|
||||
if(damage < 1)
|
||||
damage = 1;
|
||||
if (damage < 1) damage = 1;
|
||||
|
||||
// the regular tool modifier damage stuff
|
||||
int modDamage = 0;
|
||||
if(shotByPlayer)
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
modDamage += mod.attackDamage(modDamage, (int)damage, ammo, returnStack.getTagCompound(), tags, returnStack, (EntityPlayer)this.shootingEntity, movingobjectposition.entityHit);
|
||||
if (shotByPlayer)
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers) {
|
||||
modDamage += mod.attackDamage(
|
||||
modDamage,
|
||||
(int) damage,
|
||||
ammo,
|
||||
returnStack.getTagCompound(),
|
||||
tags,
|
||||
returnStack,
|
||||
(EntityPlayer) this.shootingEntity,
|
||||
movingobjectposition.entityHit);
|
||||
}
|
||||
damage += modDamage;
|
||||
|
||||
// calculate critical damaaage
|
||||
if (this.getIsCritical())
|
||||
damage += (this.rand.nextFloat()/4f + Math.min(0.75f, distance/25f)) * (damage / 2f + 2f);
|
||||
damage += (this.rand.nextFloat() / 4f + Math.min(0.75f, distance / 25f)) * (damage / 2f + 2f);
|
||||
|
||||
// and now we come to the part where we actually deal the damage!
|
||||
if(!dealDamage(damage, ammo, tags, movingobjectposition.entityHit))
|
||||
{
|
||||
if(!bounceOnNoDamage)
|
||||
this.setDead();
|
||||
if (!dealDamage(damage, ammo, tags, movingobjectposition.entityHit)) {
|
||||
if (!bounceOnNoDamage) this.setDead();
|
||||
|
||||
// bounce off if we didn't deal damage
|
||||
this.motionX *= -0.10000000149011612D;
|
||||
@@ -278,46 +297,38 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
return;
|
||||
}
|
||||
// we hit it, BURNNNNNN
|
||||
else
|
||||
AbilityHelper.processFiery(shootingEntity, movingobjectposition.entityHit, tags);
|
||||
|
||||
else AbilityHelper.processFiery(shootingEntity, movingobjectposition.entityHit, tags);
|
||||
|
||||
if (movingobjectposition.entityHit instanceof EntityLivingBase)
|
||||
doLivingHit((EntityLivingBase)movingobjectposition.entityHit);
|
||||
doLivingHit((EntityLivingBase) movingobjectposition.entityHit);
|
||||
|
||||
playHitEntitySound();
|
||||
|
||||
if (!(movingobjectposition.entityHit instanceof EntityEnderman))
|
||||
{
|
||||
if (!(movingobjectposition.entityHit instanceof EntityEnderman)) {
|
||||
// reinforced helps for them to not break!
|
||||
if(rand.nextInt(10)+1 > tags.getInteger("Reinforced"))
|
||||
this.setDead();
|
||||
else
|
||||
{
|
||||
this.motionX = Math.max(-0.1,Math.min(0.1, -motionX));
|
||||
if (rand.nextInt(10) + 1 > tags.getInteger("Reinforced")) this.setDead();
|
||||
else {
|
||||
this.motionX = Math.max(-0.1, Math.min(0.1, -motionX));
|
||||
this.motionY = 0.2;
|
||||
this.motionZ = Math.max(-0.1,Math.min(0.1, -motionZ));
|
||||
this.motionZ = Math.max(-0.1, Math.min(0.1, -motionZ));
|
||||
this.ticksInAir = 0;
|
||||
this.posX = movingobjectposition.entityHit.posX;
|
||||
this.posY = movingobjectposition.entityHit.posY + movingobjectposition.entityHit.height/2d;
|
||||
this.posY = movingobjectposition.entityHit.posY + movingobjectposition.entityHit.height / 2d;
|
||||
this.posZ = movingobjectposition.entityHit.posZ;
|
||||
this.defused = true;
|
||||
//this.shootingEntity = movingobjectposition.entityHit;
|
||||
// this.shootingEntity = movingobjectposition.entityHit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// returns true if it was successful
|
||||
public boolean dealDamage(float damage, ToolCore ammo, NBTTagCompound tags, Entity entityHit)
|
||||
{
|
||||
public boolean dealDamage(float damage, ToolCore ammo, NBTTagCompound tags, Entity entityHit) {
|
||||
boolean dealtDamage = false;
|
||||
|
||||
// deal regular damage
|
||||
DamageSource damagesource;
|
||||
if (this.shootingEntity == null)
|
||||
damagesource = DamageSource.causeArrowDamage(this, this);
|
||||
else
|
||||
damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity);
|
||||
if (this.shootingEntity == null) damagesource = DamageSource.causeArrowDamage(this, this);
|
||||
else damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity);
|
||||
dealtDamage = entityHit.attackEntityFrom(damagesource, damage);
|
||||
|
||||
return dealtDamage;
|
||||
@@ -326,7 +337,8 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
@Override
|
||||
public void setVelocity(double p_70016_1_, double p_70016_3_, double p_70016_5_) {
|
||||
// don't do anything, we set it ourselves at spawn
|
||||
// Mojangs code has a hard cap of 3.9 speed, but our projectiles can go faster, which desyncs client and server speeds
|
||||
// Mojangs code has a hard cap of 3.9 speed, but our projectiles can go faster, which desyncs client and server
|
||||
// speeds
|
||||
// Packet that's causing it: S12PacketEntityVelocity
|
||||
}
|
||||
|
||||
@@ -334,75 +346,71 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
// this function is the same as the vanilla EntityArrow
|
||||
public void onUpdate() {
|
||||
// call the entity update routine
|
||||
// luckily we can call this directly and take the arrow-code, since we'd have to call super.onUpdate otherwise. Which would not work.
|
||||
// luckily we can call this directly and take the arrow-code, since we'd have to call super.onUpdate otherwise.
|
||||
// Which would not work.
|
||||
onEntityUpdate();
|
||||
|
||||
// boioioiooioing
|
||||
if (this.arrowShake > 0)
|
||||
--this.arrowShake;
|
||||
if (this.arrowShake > 0) --this.arrowShake;
|
||||
|
||||
// If we don't have our rotation set correctly, infer it from our motion direction
|
||||
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
|
||||
{
|
||||
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
|
||||
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||
this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
|
||||
this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f) * 180.0D / Math.PI);
|
||||
this.prevRotationYaw =
|
||||
this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
|
||||
this.prevRotationPitch =
|
||||
this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f) * 180.0D / Math.PI);
|
||||
}
|
||||
|
||||
// we previously hit something. Check if the block is still there.
|
||||
Block block = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
|
||||
if (block.getMaterial() != Material.air)
|
||||
{
|
||||
block.setBlockBoundsBasedOnState(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
|
||||
AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
|
||||
if (block.getMaterial() != Material.air) {
|
||||
block.setBlockBoundsBasedOnState(
|
||||
this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
|
||||
AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(
|
||||
this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
|
||||
|
||||
// we are stuck in a block. yay.
|
||||
if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ)))
|
||||
if (axisalignedbb != null
|
||||
&& axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ)))
|
||||
this.inGround = true;
|
||||
}
|
||||
|
||||
if (this.inGround)
|
||||
updateInGround();
|
||||
else
|
||||
updateInAir();
|
||||
if (this.inGround) updateInGround();
|
||||
else updateInAir();
|
||||
}
|
||||
|
||||
// Update while we're stuck in a block
|
||||
protected void updateInGround()
|
||||
{
|
||||
protected void updateInGround() {
|
||||
Block block = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
|
||||
int j = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);
|
||||
|
||||
// check if it's still the same block
|
||||
if (block == this.field_145790_g && j == this.inData)
|
||||
{
|
||||
if (block == this.field_145790_g && j == this.inData) {
|
||||
++this.ticksInGround;
|
||||
|
||||
if (this.ticksInGround == 1200)
|
||||
{
|
||||
if (this.ticksInGround == 1200) {
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.inGround = false;
|
||||
this.motionX *= (double)(this.rand.nextFloat() * 0.2F);
|
||||
this.motionY *= (double)(this.rand.nextFloat() * 0.2F);
|
||||
this.motionZ *= (double)(this.rand.nextFloat() * 0.2F);
|
||||
this.motionX *= (double) (this.rand.nextFloat() * 0.2F);
|
||||
this.motionY *= (double) (this.rand.nextFloat() * 0.2F);
|
||||
this.motionZ *= (double) (this.rand.nextFloat() * 0.2F);
|
||||
this.ticksInGround = 0;
|
||||
this.ticksInAir = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// update while traveling
|
||||
protected void updateInAir()
|
||||
{
|
||||
protected void updateInAir() {
|
||||
// tick tock
|
||||
++this.ticksInAir;
|
||||
|
||||
// do a raytrace from old to new position
|
||||
Vec3 curPos = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
|
||||
Vec3 newPos = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
Vec3 newPos =
|
||||
Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(curPos, newPos, false, true, false);
|
||||
|
||||
// raytrace messes with the positions. get new ones!
|
||||
@@ -410,24 +418,29 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
|
||||
// if we hit something, the collision point is our new position
|
||||
if (movingobjectposition != null)
|
||||
newPos = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
|
||||
newPos = Vec3.createVectorHelper(
|
||||
movingobjectposition.hitVec.xCoord,
|
||||
movingobjectposition.hitVec.yCoord,
|
||||
movingobjectposition.hitVec.zCoord);
|
||||
else
|
||||
newPos = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
newPos = Vec3.createVectorHelper(
|
||||
this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
|
||||
|
||||
if(!defused) {
|
||||
if (!defused) {
|
||||
// Check all the entities we on our way
|
||||
Entity entity = null;
|
||||
List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
|
||||
List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(
|
||||
this,
|
||||
this.boundingBox
|
||||
.addCoord(this.motionX, this.motionY, this.motionZ)
|
||||
.expand(1.0D, 1.0D, 1.0D));
|
||||
double distance = 0.0D;
|
||||
float f1;
|
||||
|
||||
for (Entity ent : list) {
|
||||
if (!ent.canBeCollidedWith())
|
||||
continue;
|
||||
if (!ent.canBeCollidedWith()) continue;
|
||||
// we don't shoot ourselves into the foot.
|
||||
if (ent == this.shootingEntity && this.ticksInAir < 5)
|
||||
continue;
|
||||
if (ent == this.shootingEntity && this.ticksInAir < 5) continue;
|
||||
|
||||
f1 = 0.3F;
|
||||
AxisAlignedBB axisalignedbb1 = ent.boundingBox.expand((double) f1, (double) f1, (double) f1);
|
||||
@@ -446,54 +459,57 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
}
|
||||
|
||||
// if we hit something, new collision point!
|
||||
if (entity != null)
|
||||
movingobjectposition = new MovingObjectPosition(entity);
|
||||
if (entity != null) movingobjectposition = new MovingObjectPosition(entity);
|
||||
|
||||
// did we hit a player?
|
||||
if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) {
|
||||
if (movingobjectposition != null
|
||||
&& movingobjectposition.entityHit != null
|
||||
&& movingobjectposition.entityHit instanceof EntityPlayer) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit;
|
||||
|
||||
// can we attack said player?
|
||||
if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer))
|
||||
if (entityplayer.capabilities.disableDamage
|
||||
|| this.shootingEntity instanceof EntityPlayer
|
||||
&& !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer))
|
||||
movingobjectposition = null;
|
||||
|
||||
// this check should probably done inside of the loop for accuracy..
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// time to hit the object
|
||||
if (movingobjectposition != null) {
|
||||
if (movingobjectposition.entityHit != null)
|
||||
onHitEntity(movingobjectposition);
|
||||
else
|
||||
onHitBlock(movingobjectposition);
|
||||
if (movingobjectposition.entityHit != null) onHitEntity(movingobjectposition);
|
||||
else onHitBlock(movingobjectposition);
|
||||
}
|
||||
|
||||
// crithit particles
|
||||
if (this.getIsCritical())
|
||||
drawCritParticles();
|
||||
if (this.getIsCritical()) drawCritParticles();
|
||||
|
||||
// MOVEMENT! yay.
|
||||
doMoveUpdate();
|
||||
double slowdown = 1.0d - getSlowdown();
|
||||
|
||||
// bubblez
|
||||
if (this.isInWater())
|
||||
{
|
||||
for (int l = 0; l < 4; ++l)
|
||||
{
|
||||
if (this.isInWater()) {
|
||||
for (int l = 0; l < 4; ++l) {
|
||||
float f4 = 0.25F;
|
||||
this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ);
|
||||
this.worldObj.spawnParticle(
|
||||
"bubble",
|
||||
this.posX - this.motionX * (double) f4,
|
||||
this.posY - this.motionY * (double) f4,
|
||||
this.posZ - this.motionZ * (double) f4,
|
||||
this.motionX,
|
||||
this.motionY,
|
||||
this.motionZ);
|
||||
}
|
||||
|
||||
// more slowdown in water
|
||||
slowdown = 1d - 20d*getSlowdown();
|
||||
slowdown = 1d - 20d * getSlowdown();
|
||||
}
|
||||
|
||||
// phshshshshshs
|
||||
if (this.isWet())
|
||||
this.extinguish();
|
||||
if (this.isWet()) this.extinguish();
|
||||
|
||||
// minimalistic slowdown!
|
||||
this.motionX *= slowdown;
|
||||
@@ -507,35 +523,35 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
this.func_145775_I();
|
||||
}
|
||||
|
||||
public void drawCritParticles()
|
||||
{
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
this.worldObj.spawnParticle("crit", this.posX + this.motionX * (double)i / 4.0D, this.posY + this.motionY * (double)i / 4.0D, this.posZ + this.motionZ * (double)i / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ);
|
||||
public void drawCritParticles() {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
this.worldObj.spawnParticle(
|
||||
"crit",
|
||||
this.posX + this.motionX * (double) i / 4.0D,
|
||||
this.posY + this.motionY * (double) i / 4.0D,
|
||||
this.posZ + this.motionZ * (double) i / 4.0D,
|
||||
-this.motionX,
|
||||
-this.motionY + 0.2D,
|
||||
-this.motionZ);
|
||||
}
|
||||
}
|
||||
|
||||
protected void doMoveUpdate()
|
||||
{
|
||||
protected void doMoveUpdate() {
|
||||
this.posX += this.motionX;
|
||||
this.posY += this.motionY;
|
||||
this.posZ += this.motionZ;
|
||||
double f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||
this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
|
||||
this.rotationPitch = (float)(Math.atan2(this.motionY, f2) * 180.0D / Math.PI);
|
||||
this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
|
||||
this.rotationPitch = (float) (Math.atan2(this.motionY, f2) * 180.0D / Math.PI);
|
||||
|
||||
// normalize rotations
|
||||
while (this.rotationPitch - this.prevRotationPitch < -180.0F)
|
||||
this.prevRotationPitch -= 360.0F;
|
||||
while (this.rotationPitch - this.prevRotationPitch < -180.0F) this.prevRotationPitch -= 360.0F;
|
||||
|
||||
while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
|
||||
this.prevRotationPitch += 360.0F;
|
||||
while (this.rotationPitch - this.prevRotationPitch >= 180.0F) this.prevRotationPitch += 360.0F;
|
||||
|
||||
while (this.rotationYaw - this.prevRotationYaw < -180.0F)
|
||||
this.prevRotationYaw -= 360.0F;
|
||||
while (this.rotationYaw - this.prevRotationYaw < -180.0F) this.prevRotationYaw -= 360.0F;
|
||||
|
||||
while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
|
||||
this.prevRotationYaw += 360.0F;
|
||||
while (this.rotationYaw - this.prevRotationYaw >= 180.0F) this.prevRotationYaw += 360.0F;
|
||||
|
||||
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
|
||||
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
|
||||
@@ -544,58 +560,54 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
/**
|
||||
* Factor for the slowdown. 0 = no slowdown, >0 = (1-slowdown)*speed slowdown, <0 = speedup
|
||||
*/
|
||||
protected double getSlowdown() { return 0.01; }
|
||||
protected double getSlowdown() {
|
||||
return 0.01;
|
||||
}
|
||||
|
||||
/**
|
||||
* Added to the y-velocity as gravitational pull. Otherwise stuff would simply float midair.
|
||||
*/
|
||||
protected double getGravity() { return 0.05; }
|
||||
protected double getGravity() {
|
||||
return 0.05;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by a player entity when they collide with an entity
|
||||
*/
|
||||
public void onCollideWithPlayer(EntityPlayer player)
|
||||
{
|
||||
if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0)
|
||||
{
|
||||
public void onCollideWithPlayer(EntityPlayer player) {
|
||||
if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0) {
|
||||
boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && player.capabilities.isCreativeMode;
|
||||
|
||||
if (this.canBePickedUp == 1)
|
||||
{
|
||||
if (this.canBePickedUp == 1) {
|
||||
// ammo pickup
|
||||
if(this.returnStack != null && this.returnStack.getItem() instanceof AmmoItem)
|
||||
{
|
||||
if(!((AmmoItem) this.returnStack.getItem()).pickupAmmo(returnStack, null, player))
|
||||
flag = false;
|
||||
if (this.returnStack != null && this.returnStack.getItem() instanceof AmmoItem) {
|
||||
if (!((AmmoItem) this.returnStack.getItem()).pickupAmmo(returnStack, null, player)) flag = false;
|
||||
}
|
||||
// regular pickup.
|
||||
// Note that you can't pick up ammo items without the proper itemstack in your inventory to prevent dupes
|
||||
else if(returnStack != null && !player.inventory.addItemStackToInventory(returnStack))
|
||||
{
|
||||
// Note that you can't pick up ammo items without the proper itemstack in your inventory to prevent
|
||||
// dupes
|
||||
else if (returnStack != null && !player.inventory.addItemStackToInventory(returnStack)) {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
if (flag) {
|
||||
this.playSound(
|
||||
"random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
player.onItemPickup(this, 1);
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** NBT stuff **/
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT (NBTTagCompound tags)
|
||||
{
|
||||
public void writeEntityToNBT(NBTTagCompound tags) {
|
||||
super.writeEntityToNBT(tags);
|
||||
|
||||
tags.setTag("Throwable", this.returnStack.writeToNBT(new NBTTagCompound()));
|
||||
tags.setByte("onGround", (byte) (onGround ? 1 : 0));
|
||||
//tags.setBoolean("Retrieval", doNotRetrieve);
|
||||
// tags.setBoolean("Retrieval", doNotRetrieve);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -604,10 +616,10 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
|
||||
this.returnStack = ItemStack.loadItemStackFromNBT(tags.getCompoundTag("Throwable"));
|
||||
onGround = tags.getByte("onGround") == 1;
|
||||
//doNotRetrieve = tags.getBoolean("Retrieval");
|
||||
// doNotRetrieve = tags.getBoolean("Retrieval");
|
||||
|
||||
// ensure that nothing can crash because something went wrong in the world...
|
||||
if(this.returnStack == null || !(this.returnStack.getItem() instanceof ToolCore)) {
|
||||
if (this.returnStack == null || !(this.returnStack.getItem() instanceof ToolCore)) {
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
@@ -636,10 +648,10 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
this.motionX = data.readDouble();
|
||||
this.motionY = data.readDouble();
|
||||
this.motionZ = data.readDouble();
|
||||
|
||||
|
||||
// position offset so it doesn't shoot from the player's eyes
|
||||
this.posX -= MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F;
|
||||
this.posX -= MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
|
||||
this.posY -= 0.10000000149011612D;
|
||||
this.posZ -= MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F;
|
||||
this.posZ -= MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package tconstruct.library.event;
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.modifier.IModifyable;
|
||||
import tconstruct.library.modifier.ItemModifier;
|
||||
|
||||
|
||||
@@ -3,47 +3,40 @@ package tconstruct.library.event;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/* This event fires after all of the other construction. The resulting nbttag is added to the tool
|
||||
/* This event fires after all of the other construction. The resulting nbttag is added to the tool
|
||||
* Note: The tag is the base tag. toolTag.getCompoundTag("InfiTool") will have all of the tool's data.
|
||||
*/
|
||||
|
||||
public class PartBuilderEvent extends Event
|
||||
{
|
||||
public class PartBuilderEvent extends Event {
|
||||
public final ItemStack material;
|
||||
public final ItemStack pattern;
|
||||
public final ItemStack otherPattern;
|
||||
protected ItemStack[] resultStacks;
|
||||
|
||||
public PartBuilderEvent(ItemStack material, ItemStack pattern, ItemStack otherPattern)
|
||||
{
|
||||
public PartBuilderEvent(ItemStack material, ItemStack pattern, ItemStack otherPattern) {
|
||||
this.material = material;
|
||||
this.pattern = pattern;
|
||||
this.otherPattern = otherPattern;
|
||||
}
|
||||
|
||||
@HasResult
|
||||
public static class NormalPart extends PartBuilderEvent
|
||||
{
|
||||
public NormalPart(ItemStack material, ItemStack pattern, ItemStack otherPattern)
|
||||
{
|
||||
public static class NormalPart extends PartBuilderEvent {
|
||||
public NormalPart(ItemStack material, ItemStack pattern, ItemStack otherPattern) {
|
||||
super(material, pattern, otherPattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires before other processing is done
|
||||
*
|
||||
*
|
||||
* Result is significant: DEFAULT: Allows part to be crafted normally
|
||||
* ALLOW: Uses resultStack instead DENY: Stops part crafting altogether
|
||||
*/
|
||||
|
||||
public void overrideResult (ItemStack[] result)
|
||||
{
|
||||
public void overrideResult(ItemStack[] result) {
|
||||
resultStacks = result;
|
||||
this.setResult(Result.ALLOW);
|
||||
}
|
||||
|
||||
public ItemStack[] getResultStacks ()
|
||||
{
|
||||
public ItemStack[] getResultStacks() {
|
||||
return resultStacks;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,29 +9,23 @@ import tconstruct.library.crafting.CastingRecipe;
|
||||
*
|
||||
* Set result to DENY to prevent casting.
|
||||
*/
|
||||
public abstract class SmelteryCastEvent extends Event
|
||||
{
|
||||
public abstract class SmelteryCastEvent extends Event {
|
||||
public final CastingRecipe recipe;
|
||||
public final FluidStack fluid;
|
||||
|
||||
public SmelteryCastEvent(CastingRecipe recipe, FluidStack fluid)
|
||||
{
|
||||
public SmelteryCastEvent(CastingRecipe recipe, FluidStack fluid) {
|
||||
this.recipe = recipe;
|
||||
this.fluid = fluid;
|
||||
}
|
||||
|
||||
public static class CastingTable extends SmelteryCastEvent
|
||||
{
|
||||
public CastingTable(CastingRecipe recipe, FluidStack fluid)
|
||||
{
|
||||
public static class CastingTable extends SmelteryCastEvent {
|
||||
public CastingTable(CastingRecipe recipe, FluidStack fluid) {
|
||||
super(recipe, fluid);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CastingBasin extends SmelteryCastEvent
|
||||
{
|
||||
public CastingBasin(CastingRecipe recipe, FluidStack fluid)
|
||||
{
|
||||
public static class CastingBasin extends SmelteryCastEvent {
|
||||
public CastingBasin(CastingRecipe recipe, FluidStack fluid) {
|
||||
super(recipe, fluid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,31 +8,25 @@ import tconstruct.library.crafting.CastingRecipe;
|
||||
* Fired when an item is cast in the casting table.
|
||||
* If consumeCast is set to true, the cast will be destroyed.
|
||||
*/
|
||||
public abstract class SmelteryCastedEvent extends Event
|
||||
{
|
||||
public abstract class SmelteryCastedEvent extends Event {
|
||||
public final CastingRecipe recipe;
|
||||
public ItemStack output;
|
||||
public boolean consumeCast;
|
||||
|
||||
public SmelteryCastedEvent(CastingRecipe recipe, ItemStack output)
|
||||
{
|
||||
public SmelteryCastedEvent(CastingRecipe recipe, ItemStack output) {
|
||||
this.recipe = recipe;
|
||||
this.consumeCast = recipe.consumeCast;
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
public static class CastingTable extends SmelteryCastedEvent
|
||||
{
|
||||
public CastingTable(CastingRecipe recipe, ItemStack output)
|
||||
{
|
||||
public static class CastingTable extends SmelteryCastedEvent {
|
||||
public CastingTable(CastingRecipe recipe, ItemStack output) {
|
||||
super(recipe, output);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CastingBasin extends SmelteryCastedEvent
|
||||
{
|
||||
public CastingBasin(CastingRecipe recipe, ItemStack output)
|
||||
{
|
||||
public static class CastingBasin extends SmelteryCastedEvent {
|
||||
public CastingBasin(CastingRecipe recipe, ItemStack output) {
|
||||
super(recipe, output);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,14 +6,12 @@ import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SmelteryEvent extends Event
|
||||
{
|
||||
public class SmelteryEvent extends Event {
|
||||
|
||||
public InventoryLogic component;
|
||||
public int x, y, z;
|
||||
|
||||
public SmelteryEvent(InventoryLogic component, int x, int y, int z)
|
||||
{
|
||||
public SmelteryEvent(InventoryLogic component, int x, int y, int z) {
|
||||
this.component = component;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -21,32 +19,31 @@ public class SmelteryEvent extends Event
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class ItemInsertedIntoCasting extends SmelteryEvent
|
||||
{
|
||||
public static class ItemInsertedIntoCasting extends SmelteryEvent {
|
||||
/** Item that will be inserted into the casting block */
|
||||
public ItemStack item;
|
||||
|
||||
public EntityPlayer player;
|
||||
|
||||
public ItemInsertedIntoCasting(InventoryLogic component, int x, int y, int z, ItemStack item, EntityPlayer player)
|
||||
{
|
||||
public ItemInsertedIntoCasting(
|
||||
InventoryLogic component, int x, int y, int z, ItemStack item, EntityPlayer player) {
|
||||
super(component, x, y, z);
|
||||
this.item = item;
|
||||
this.player = player;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ItemRemovedFromCasting extends SmelteryEvent
|
||||
{
|
||||
public static class ItemRemovedFromCasting extends SmelteryEvent {
|
||||
/** Item that will be returned to the player */
|
||||
public ItemStack item;
|
||||
|
||||
public EntityPlayer player;
|
||||
|
||||
public ItemRemovedFromCasting(InventoryLogic component, int x, int y, int z, ItemStack item, EntityPlayer player)
|
||||
{
|
||||
public ItemRemovedFromCasting(
|
||||
InventoryLogic component, int x, int y, int z, ItemStack item, EntityPlayer player) {
|
||||
super(component, x, y, z);
|
||||
this.item = item;
|
||||
this.player = player;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,16 +7,15 @@ import net.minecraft.item.ItemStack;
|
||||
* Called when the ToolBuilder tries to piece together the Parts of a tool.
|
||||
*
|
||||
*/
|
||||
public class ToolBuildEvent extends Event
|
||||
{
|
||||
public class ToolBuildEvent extends Event {
|
||||
public ItemStack headStack;
|
||||
public ItemStack handleStack;
|
||||
public ItemStack accessoryStack;
|
||||
public ItemStack extraStack;
|
||||
public String name; // to allow shenanigans
|
||||
|
||||
public ToolBuildEvent(ItemStack headStack, ItemStack handleStack, ItemStack accessoryStack, ItemStack extraStack, String name)
|
||||
{
|
||||
public ToolBuildEvent(
|
||||
ItemStack headStack, ItemStack handleStack, ItemStack accessoryStack, ItemStack extraStack, String name) {
|
||||
this.headStack = headStack;
|
||||
this.handleStack = handleStack;
|
||||
this.accessoryStack = accessoryStack;
|
||||
|
||||
@@ -5,47 +5,40 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.tools.*;
|
||||
|
||||
/* This event fires after all of the other construction. The resulting nbttag is added to the tool
|
||||
/* This event fires after all of the other construction. The resulting nbttag is added to the tool
|
||||
* Note: The tag is the base tag. toolTag.getCompoundTag("InfiTool") will have all of the tool's data.
|
||||
*/
|
||||
|
||||
public class ToolCraftEvent extends Event
|
||||
{
|
||||
public class ToolCraftEvent extends Event {
|
||||
public final ToolCore tool;
|
||||
public final NBTTagCompound toolTag;
|
||||
public final ToolMaterial[] materials;
|
||||
protected ItemStack resultStack;
|
||||
|
||||
public ToolCraftEvent(ToolCore tool, NBTTagCompound toolTag, ToolMaterial[] materials)
|
||||
{
|
||||
public ToolCraftEvent(ToolCore tool, NBTTagCompound toolTag, ToolMaterial[] materials) {
|
||||
this.tool = tool;
|
||||
this.toolTag = toolTag;
|
||||
this.materials = materials;
|
||||
}
|
||||
|
||||
@HasResult
|
||||
public static class NormalTool extends ToolCraftEvent
|
||||
{
|
||||
public NormalTool(ToolCore tool, NBTTagCompound toolTag, ToolMaterial[] materials)
|
||||
{
|
||||
public static class NormalTool extends ToolCraftEvent {
|
||||
public NormalTool(ToolCore tool, NBTTagCompound toolTag, ToolMaterial[] materials) {
|
||||
super(tool, toolTag, materials);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires just before the tool is put together
|
||||
*
|
||||
*
|
||||
* Result is significant: DEFAULT: Allows tool to be crafted normally
|
||||
* ALLOW: Uses resultStack instead DENY: Stops tool crafting altogether
|
||||
*/
|
||||
|
||||
public void overrideResult (ItemStack result)
|
||||
{
|
||||
public void overrideResult(ItemStack result) {
|
||||
resultStack = result;
|
||||
this.setResult(Result.ALLOW);
|
||||
}
|
||||
|
||||
public ItemStack getResultStack ()
|
||||
{
|
||||
public ItemStack getResultStack() {
|
||||
return resultStack;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,18 +5,15 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ToolCraftedEvent extends Event
|
||||
{
|
||||
public class ToolCraftedEvent extends Event {
|
||||
|
||||
public IInventory inventory;
|
||||
public EntityPlayer player;
|
||||
public ItemStack tool;
|
||||
|
||||
public ToolCraftedEvent(IInventory inventory, EntityPlayer player, ItemStack tool)
|
||||
{
|
||||
public ToolCraftedEvent(IInventory inventory, EntityPlayer player, ItemStack tool) {
|
||||
this.inventory = inventory;
|
||||
this.player = player;
|
||||
this.tool = tool;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,11 +5,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.armor.*;
|
||||
|
||||
public class ActiveArmorMod
|
||||
{
|
||||
public class ActiveArmorMod {
|
||||
/* Ticks for every armor piece on client and server */
|
||||
public void onArmorTick (World world, EntityPlayer player, ItemStack itemStack, ArmorCore armor, ArmorPart type)
|
||||
{
|
||||
|
||||
}
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack, ArmorCore armor, ArmorPart type) {}
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
package tconstruct.library.modifier;
|
||||
|
||||
public interface IModifyable
|
||||
{
|
||||
public interface IModifyable {
|
||||
/**
|
||||
* @return The base tag to modify. Ex: InfiTool
|
||||
*/
|
||||
public String getBaseTagName ();
|
||||
public String getBaseTagName();
|
||||
|
||||
public String getModifyType ();
|
||||
public String getModifyType();
|
||||
|
||||
public String[] getTraits ();
|
||||
public String[] getTraits();
|
||||
}
|
||||
@@ -4,25 +4,21 @@ import java.util.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public abstract class ItemModifier
|
||||
{
|
||||
public abstract class ItemModifier {
|
||||
public final String key;
|
||||
public final List stacks;
|
||||
public final int effectIndex;
|
||||
public static Random random = new Random();
|
||||
|
||||
/** Default constructor
|
||||
*
|
||||
*
|
||||
* @param recipe Items to compare against when checking the modifier
|
||||
* @param effect Render index for sprite layering
|
||||
* @param dataKey NBT string to put on the item
|
||||
*/
|
||||
|
||||
public ItemModifier(ItemStack[] recipe, int effect, String dataKey)
|
||||
{
|
||||
public ItemModifier(ItemStack[] recipe, int effect, String dataKey) {
|
||||
List<ItemStack> itemstacks = new ArrayList<ItemStack>();
|
||||
for (int iter = 0; iter < recipe.length; iter++)
|
||||
itemstacks.add(recipe[iter]);
|
||||
for (int iter = 0; iter < recipe.length; iter++) itemstacks.add(recipe[iter]);
|
||||
stacks = itemstacks;
|
||||
effectIndex = effect;
|
||||
key = dataKey;
|
||||
@@ -30,41 +26,36 @@ public abstract class ItemModifier
|
||||
|
||||
/** Checks to see if the inputs match the stored items
|
||||
* Note: Works like ShapelessRecipes
|
||||
*
|
||||
*
|
||||
* @param recipe The ItemStacks to compare against
|
||||
* @param input Item to modify, used for restrictions
|
||||
* @return Whether the recipe matches the input
|
||||
*/
|
||||
public boolean matches (ItemStack[] recipe, ItemStack input)
|
||||
{
|
||||
if (!canModify(input, recipe))
|
||||
return false;
|
||||
public boolean matches(ItemStack[] recipe, ItemStack input) {
|
||||
if (!canModify(input, recipe)) return false;
|
||||
|
||||
ArrayList list = new ArrayList(this.stacks);
|
||||
|
||||
for (int iter = 0; iter < recipe.length; ++iter)
|
||||
{
|
||||
for (int iter = 0; iter < recipe.length; ++iter) {
|
||||
ItemStack craftingStack = recipe[iter];
|
||||
|
||||
if (craftingStack != null)
|
||||
{
|
||||
if (craftingStack != null) {
|
||||
boolean canCraft = false;
|
||||
Iterator iterate = list.iterator();
|
||||
|
||||
while (iterate.hasNext())
|
||||
{
|
||||
while (iterate.hasNext()) {
|
||||
ItemStack removeStack = (ItemStack) iterate.next();
|
||||
|
||||
if (craftingStack.getItem() == removeStack.getItem() && (removeStack.getItemDamage() == Short.MAX_VALUE || craftingStack.getItemDamage() == removeStack.getItemDamage()))
|
||||
{
|
||||
if (craftingStack.getItem() == removeStack.getItem()
|
||||
&& (removeStack.getItemDamage() == Short.MAX_VALUE
|
||||
|| craftingStack.getItemDamage() == removeStack.getItemDamage())) {
|
||||
canCraft = true;
|
||||
list.remove(removeStack);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!canCraft)
|
||||
{
|
||||
if (!canCraft) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -73,13 +64,11 @@ public abstract class ItemModifier
|
||||
return list.isEmpty();
|
||||
}
|
||||
|
||||
protected String getTagName (ItemStack stack)
|
||||
{
|
||||
protected String getTagName(ItemStack stack) {
|
||||
return ((IModifyable) stack.getItem()).getBaseTagName();
|
||||
}
|
||||
|
||||
protected NBTTagCompound getModifierTag (ItemStack stack)
|
||||
{
|
||||
protected NBTTagCompound getModifierTag(ItemStack stack) {
|
||||
return stack.getTagCompound().getCompoundTag(getTagName(stack));
|
||||
}
|
||||
|
||||
@@ -88,63 +77,44 @@ public abstract class ItemModifier
|
||||
* @param recipe Items to modify with
|
||||
* @return Whether the tool can be modified
|
||||
*/
|
||||
|
||||
protected boolean canModify (ItemStack input, ItemStack[] recipe)
|
||||
{
|
||||
protected boolean canModify(ItemStack input, ItemStack[] recipe) {
|
||||
NBTTagCompound tags = input.getTagCompound().getCompoundTag(getTagName(input));
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
}
|
||||
|
||||
/** Modifies the tool. Adds nbttags, changes existing ones, ticks down modification counter, etc
|
||||
*
|
||||
*
|
||||
* @param recipe ItemStacks to pull info from
|
||||
* @param input The tool to modify
|
||||
*/
|
||||
public abstract void modify (ItemStack[] recipe, ItemStack input);
|
||||
public abstract void modify(ItemStack[] recipe, ItemStack input);
|
||||
|
||||
public void addMatchingEffect (ItemStack input)
|
||||
{
|
||||
public void addMatchingEffect(ItemStack input) {
|
||||
NBTTagCompound tags = input.getTagCompound().getCompoundTag(getTagName(input));
|
||||
if (tags.hasKey("Effect6") || tags.hasKey(key))
|
||||
return;
|
||||
|
||||
else if (tags.hasKey("Effect5"))
|
||||
{
|
||||
if (tags.hasKey("Effect6") || tags.hasKey(key)) return;
|
||||
else if (tags.hasKey("Effect5")) {
|
||||
tags.setInteger("Effect6", effectIndex);
|
||||
}
|
||||
else if (tags.hasKey("Effect4"))
|
||||
{
|
||||
} else if (tags.hasKey("Effect4")) {
|
||||
tags.setInteger("Effect5", effectIndex);
|
||||
}
|
||||
else if (tags.hasKey("Effect3"))
|
||||
{
|
||||
} else if (tags.hasKey("Effect3")) {
|
||||
tags.setInteger("Effect4", effectIndex);
|
||||
}
|
||||
else if (tags.hasKey("Effect2"))
|
||||
{
|
||||
} else if (tags.hasKey("Effect2")) {
|
||||
tags.setInteger("Effect3", effectIndex);
|
||||
}
|
||||
else if (tags.hasKey("Effect1"))
|
||||
{
|
||||
} else if (tags.hasKey("Effect1")) {
|
||||
tags.setInteger("Effect2", effectIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
tags.setInteger("Effect1", effectIndex);
|
||||
}
|
||||
}
|
||||
|
||||
//Gui
|
||||
protected int addModifierTip (ItemStack input, String modifierTip)
|
||||
{
|
||||
// Gui
|
||||
protected int addModifierTip(ItemStack input, String modifierTip) {
|
||||
NBTTagCompound tags = input.getTagCompound().getCompoundTag(getTagName(input));
|
||||
int tipNum = 0;
|
||||
while (true)
|
||||
{
|
||||
while (true) {
|
||||
tipNum++;
|
||||
String tip = "Tooltip" + tipNum;
|
||||
if (!tags.hasKey(tip))
|
||||
{
|
||||
if (!tags.hasKey(tip)) {
|
||||
tags.setString(tip, "");
|
||||
String modTip = "ModifierTip" + tipNum;
|
||||
tags.setString(modTip, modifierTip);
|
||||
@@ -153,27 +123,21 @@ public abstract class ItemModifier
|
||||
}
|
||||
}
|
||||
|
||||
//Item
|
||||
protected int addToolTip (ItemStack input, String tooltip, String modifierTip)
|
||||
{
|
||||
// Item
|
||||
protected int addToolTip(ItemStack input, String tooltip, String modifierTip) {
|
||||
NBTTagCompound tags = input.getTagCompound().getCompoundTag(getTagName(input));
|
||||
int tipNum = 0;
|
||||
while (true)
|
||||
{
|
||||
while (true) {
|
||||
tipNum++;
|
||||
String tip = "Tooltip" + tipNum;
|
||||
if (!tags.hasKey(tip))
|
||||
{
|
||||
if (!tags.hasKey(tip)) {
|
||||
tags.setString(tip, tooltip);
|
||||
String modTip = "ModifierTip" + tipNum;
|
||||
tags.setString(modTip, modifierTip);
|
||||
return tipNum;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
String tag = tags.getString(tip);
|
||||
if (tag.contains(tooltip))
|
||||
{
|
||||
if (tag.contains(tooltip)) {
|
||||
tags.setString(tip, getProperName(tooltip, tag));
|
||||
String modTip = "ModifierTip" + tipNum;
|
||||
tag = tags.getString(modTip);
|
||||
@@ -184,70 +148,53 @@ public abstract class ItemModifier
|
||||
}
|
||||
}
|
||||
|
||||
protected String getProperName (String tooltip, String tag)
|
||||
{
|
||||
if (tag.isEmpty())
|
||||
return tooltip + " I";
|
||||
protected String getProperName(String tooltip, String tag) {
|
||||
if (tag.isEmpty()) return tooltip + " I";
|
||||
|
||||
if (tag.equals(tooltip) || tag.equals(tooltip + " I"))
|
||||
return tooltip + " II";
|
||||
if (tag.equals(tooltip) || tag.equals(tooltip + " I")) return tooltip + " II";
|
||||
|
||||
if (tag.equals(tooltip + " II"))
|
||||
return tooltip + " III";
|
||||
if (tag.equals(tooltip + " II")) return tooltip + " III";
|
||||
|
||||
if (tag.equals(tooltip + " III"))
|
||||
return tooltip + " IV";
|
||||
if (tag.equals(tooltip + " III")) return tooltip + " IV";
|
||||
|
||||
if (tag.equals(tooltip + " IV"))
|
||||
return tooltip + " V";
|
||||
if (tag.equals(tooltip + " IV")) return tooltip + " V";
|
||||
|
||||
if (tag.equals(tooltip + " V"))
|
||||
return tooltip + " VI";
|
||||
if (tag.equals(tooltip + " V")) return tooltip + " VI";
|
||||
|
||||
if (tag.equals(tooltip + " VI"))
|
||||
return tooltip + " VII";
|
||||
if (tag.equals(tooltip + " VI")) return tooltip + " VII";
|
||||
|
||||
if (tag.equals(tooltip + " VII"))
|
||||
return tooltip + " VIII";
|
||||
if (tag.equals(tooltip + " VII")) return tooltip + " VIII";
|
||||
|
||||
if (tag.equals(tooltip + " VIII"))
|
||||
return tooltip + " IX";
|
||||
if (tag.equals(tooltip + " VIII")) return tooltip + " IX";
|
||||
|
||||
if (tag.equals(tooltip + " IX"))
|
||||
return tooltip + " X";
|
||||
if (tag.equals(tooltip + " IX")) return tooltip + " X";
|
||||
|
||||
return tooltip + " X+";
|
||||
}
|
||||
|
||||
public boolean validType (IModifyable input)
|
||||
{
|
||||
public boolean validType(IModifyable input) {
|
||||
return input.getModifyType().equals("Tool");
|
||||
}
|
||||
|
||||
// Helper methods
|
||||
public boolean areItemsEquivalent (ItemStack stack1, ItemStack stack2)
|
||||
{
|
||||
if (stack1.getItem() != stack2.getItem())
|
||||
return false;
|
||||
public boolean areItemsEquivalent(ItemStack stack1, ItemStack stack2) {
|
||||
if (stack1.getItem() != stack2.getItem()) return false;
|
||||
return ItemStack.areItemStackTagsEqual(stack1, stack2);
|
||||
}
|
||||
|
||||
public boolean areItemStacksEquivalent (ItemStack stack1, ItemStack stack2)
|
||||
{
|
||||
if (stack1.getItem() != stack2.getItem())
|
||||
return false;
|
||||
if (stack1.getItemDamage() != stack2.getItemDamage())
|
||||
return false;
|
||||
public boolean areItemStacksEquivalent(ItemStack stack1, ItemStack stack2) {
|
||||
if (stack1.getItem() != stack2.getItem()) return false;
|
||||
if (stack1.getItemDamage() != stack2.getItemDamage()) return false;
|
||||
return ItemStack.areItemStackTagsEqual(stack1, stack2);
|
||||
}
|
||||
|
||||
public static NBTTagCompound getAttributeTag (String attributeType, String modifierName, double amount, boolean flat, UUID uuid)
|
||||
{
|
||||
public static NBTTagCompound getAttributeTag(
|
||||
String attributeType, String modifierName, double amount, boolean flat, UUID uuid) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setString("AttributeName", attributeType);
|
||||
tag.setString("Name", modifierName);
|
||||
tag.setDouble("Amount", amount);
|
||||
tag.setInteger("Operation", flat ? 0 : 1);//0 = flat increase, 1 = % increase
|
||||
tag.setInteger("Operation", flat ? 0 : 1); // 0 = flat increase, 1 = % increase
|
||||
tag.setLong("UUIDMost", uuid.getMostSignificantBits());
|
||||
tag.setLong("UUIDLeast", uuid.getLeastSignificantBits());
|
||||
return tag;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@ import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
||||
import net.minecraft.dispenser.IBlockSource;
|
||||
import net.minecraft.dispenser.IPosition;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.IProjectile;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
@@ -17,29 +15,29 @@ public abstract class BehaviorProjectileBaseDispense extends BehaviorDefaultDisp
|
||||
* Dispense the specified stack, play the dispense sound and spawn particles.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack dispenseStack(IBlockSource blockSource, ItemStack stack)
|
||||
{
|
||||
public ItemStack dispenseStack(IBlockSource blockSource, ItemStack stack) {
|
||||
World world = blockSource.getWorld();
|
||||
IPosition iposition = BlockDispenser.func_149939_a(blockSource);
|
||||
EnumFacing enumfacing = BlockDispenser.func_149937_b(blockSource.getBlockMetadata());
|
||||
|
||||
ItemStack reference;
|
||||
|
||||
if(stack.getItem() instanceof IAmmo)
|
||||
{
|
||||
if (stack.getItem() instanceof IAmmo) {
|
||||
IAmmo ammo = (IAmmo) stack.getItem();
|
||||
// needs ammo to shoot
|
||||
if(ammo.getAmmoCount(stack) <= 0)
|
||||
return stack;
|
||||
if (ammo.getAmmoCount(stack) <= 0) return stack;
|
||||
ammo.consumeAmmo(1, stack);
|
||||
reference = stack.copy();
|
||||
((IAmmo)reference.getItem()).setAmmo(1, reference);
|
||||
}
|
||||
else
|
||||
reference = stack.splitStack(1);
|
||||
((IAmmo) reference.getItem()).setAmmo(1, reference);
|
||||
} else reference = stack.splitStack(1);
|
||||
|
||||
ProjectileBase projectile = this.getProjectileEntity(world, iposition, reference);
|
||||
projectile.setThrowableHeading((double)enumfacing.getFrontOffsetX(), (double)((float)enumfacing.getFrontOffsetY() + ballistic()), (double)enumfacing.getFrontOffsetZ(), this.accuraccy(), this.speed());
|
||||
projectile.setThrowableHeading(
|
||||
(double) enumfacing.getFrontOffsetX(),
|
||||
(double) ((float) enumfacing.getFrontOffsetY() + ballistic()),
|
||||
(double) enumfacing.getFrontOffsetZ(),
|
||||
this.accuraccy(),
|
||||
this.speed());
|
||||
projectile.returnStack = reference;
|
||||
projectile.canBePickedUp = 1;
|
||||
world.spawnEntityInWorld(projectile);
|
||||
@@ -50,8 +48,7 @@ public abstract class BehaviorProjectileBaseDispense extends BehaviorDefaultDisp
|
||||
/**
|
||||
* Play the dispense sound from the specified block.
|
||||
*/
|
||||
protected void playDispenseSound(IBlockSource p_82485_1_)
|
||||
{
|
||||
protected void playDispenseSound(IBlockSource p_82485_1_) {
|
||||
p_82485_1_.getWorld().playAuxSFX(1002, p_82485_1_.getXInt(), p_82485_1_.getYInt(), p_82485_1_.getZInt(), 0);
|
||||
}
|
||||
|
||||
@@ -60,15 +57,15 @@ public abstract class BehaviorProjectileBaseDispense extends BehaviorDefaultDisp
|
||||
*/
|
||||
protected abstract ProjectileBase getProjectileEntity(World world, IPosition position, ItemStack stack);
|
||||
|
||||
protected float speed()
|
||||
{
|
||||
protected float speed() {
|
||||
return 6.0F;
|
||||
}
|
||||
|
||||
protected float accuraccy()
|
||||
{
|
||||
protected float accuraccy() {
|
||||
return 1.1F;
|
||||
}
|
||||
|
||||
protected float ballistic() { return 0.1f; }
|
||||
protected float ballistic() {
|
||||
return 0.1f;
|
||||
}
|
||||
}
|
||||
@@ -6,26 +6,20 @@ import net.minecraft.util.StatCollector;
|
||||
/**
|
||||
* Lookup for the name of each harvest level. Use this clientside only for display purposes.
|
||||
*/
|
||||
public final class HarvestLevels
|
||||
{
|
||||
private HarvestLevels()
|
||||
{
|
||||
} // non-instantiable
|
||||
public final class HarvestLevels {
|
||||
private HarvestLevels() {} // non-instantiable
|
||||
|
||||
public static final Map<Integer, String> harvestLevelNames = new HashMap<Integer, String>();
|
||||
|
||||
public static String getHarvestLevelName (int num)
|
||||
{
|
||||
public static String getHarvestLevelName(int num) {
|
||||
return harvestLevelNames.containsKey(num) ? harvestLevelNames.get(num) : String.valueOf(num);
|
||||
}
|
||||
|
||||
// initialization
|
||||
static
|
||||
{
|
||||
static {
|
||||
String base = "gui.mining";
|
||||
int i = 0;
|
||||
while (StatCollector.canTranslate(String.format("%s%d", base, i + 1)))
|
||||
{
|
||||
while (StatCollector.canTranslate(String.format("%s%d", base, i + 1))) {
|
||||
harvestLevelNames.put(i, StatCollector.translateToLocal(String.format("%s%d", base, i + 1)));
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,8 @@ package tconstruct.library.util;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.library.crafting.PatternBuilder.MaterialSet;
|
||||
|
||||
public interface IPattern
|
||||
{
|
||||
public int getPatternCost (ItemStack pattern);
|
||||
public interface IPattern {
|
||||
public int getPatternCost(ItemStack pattern);
|
||||
|
||||
public ItemStack getPatternOutput (ItemStack pattern, ItemStack input, MaterialSet set);
|
||||
public ItemStack getPatternOutput(ItemStack pattern, ItemStack input, MaterialSet set);
|
||||
}
|
||||
@@ -2,14 +2,13 @@ package tconstruct.library.util;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IToolPart
|
||||
{
|
||||
public interface IToolPart {
|
||||
/**
|
||||
* Parts to build tools from. ex: Pickaxe Head
|
||||
*
|
||||
*
|
||||
* @param stack
|
||||
* This item
|
||||
* @return Proper material ID. -1 for invalid
|
||||
*/
|
||||
public int getMaterialID (ItemStack stack);
|
||||
public int getMaterialID(ItemStack stack);
|
||||
}
|
||||
@@ -3,10 +3,8 @@ package tconstruct.library.util;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.EntityDamageSource;
|
||||
|
||||
public class PiercingEntityDamage extends EntityDamageSource
|
||||
{
|
||||
public PiercingEntityDamage(String str, Entity entity)
|
||||
{
|
||||
public class PiercingEntityDamage extends EntityDamageSource {
|
||||
public PiercingEntityDamage(String str, Entity entity) {
|
||||
super(str, entity);
|
||||
this.setDamageBypassesArmor();
|
||||
}
|
||||
|
||||
@@ -2,22 +2,16 @@ package tconstruct.library.weaponry;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import tconstruct.util.Reference;
|
||||
import mods.battlegear2.api.PlayerEventChild;
|
||||
import mods.battlegear2.api.weapons.IBattlegearWeapon;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import mods.battlegear2.api.PlayerEventChild;
|
||||
import mods.battlegear2.api.weapons.IBattlegearWeapon;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon")
|
||||
@@ -30,14 +24,14 @@ public abstract class AmmoItem extends ToolCore implements IBattlegearWeapon, IA
|
||||
|
||||
@Override
|
||||
public int getAmmoCount(ItemStack stack) {
|
||||
if(!stack.hasTagCompound()) return 0;
|
||||
if (!stack.hasTagCompound()) return 0;
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
return tags.getInteger("Ammo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxAmmo(ItemStack stack) {
|
||||
if(!stack.hasTagCompound()) return 0;
|
||||
if (!stack.hasTagCompound()) return 0;
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
return getMaxAmmo(tags);
|
||||
}
|
||||
@@ -50,7 +44,7 @@ public abstract class AmmoItem extends ToolCore implements IBattlegearWeapon, IA
|
||||
|
||||
@Override
|
||||
public int addAmmo(int toAdd, ItemStack stack) {
|
||||
if(!stack.hasTagCompound()) return toAdd;
|
||||
if (!stack.hasTagCompound()) return toAdd;
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
int oldCount = tags.getInteger("Ammo");
|
||||
int newCount = Math.min(oldCount + toAdd, getMaxAmmo(stack));
|
||||
@@ -60,7 +54,7 @@ public abstract class AmmoItem extends ToolCore implements IBattlegearWeapon, IA
|
||||
|
||||
@Override
|
||||
public int consumeAmmo(int toUse, ItemStack stack) {
|
||||
if(!stack.hasTagCompound()) return toUse;
|
||||
if (!stack.hasTagCompound()) return toUse;
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
int oldCount = tags.getInteger("Ammo");
|
||||
int newCount = Math.max(oldCount - toUse, 0);
|
||||
@@ -70,42 +64,39 @@ public abstract class AmmoItem extends ToolCore implements IBattlegearWeapon, IA
|
||||
|
||||
@Override
|
||||
public void setAmmo(int count, ItemStack stack) {
|
||||
if(!stack.hasTagCompound()) return;
|
||||
if (!stack.hasTagCompound()) return;
|
||||
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
tags.setInteger("Ammo", count);
|
||||
}
|
||||
|
||||
public float getAmmoModifier() { return 0.1f; }
|
||||
public float getAmmoModifier() {
|
||||
return 0.1f;
|
||||
}
|
||||
|
||||
public boolean pickupAmmo(ItemStack stack, ItemStack candidate, EntityPlayer player)
|
||||
{
|
||||
if(stack.getItem() == null || !stack.hasTagCompound() || !(stack.getItem() instanceof IAmmo))
|
||||
return false;
|
||||
public boolean pickupAmmo(ItemStack stack, ItemStack candidate, EntityPlayer player) {
|
||||
if (stack.getItem() == null || !stack.hasTagCompound() || !(stack.getItem() instanceof IAmmo)) return false;
|
||||
|
||||
// check if our candidate fits
|
||||
if(candidate != null)
|
||||
{
|
||||
if (candidate != null) {
|
||||
// same item
|
||||
if(testIfAmmoMatches(stack, candidate)) {
|
||||
if (testIfAmmoMatches(stack, candidate)) {
|
||||
IAmmo pickedup = ((IAmmo) stack.getItem());
|
||||
IAmmo ininventory = ((IAmmo) candidate.getItem());
|
||||
// we can be sure that it's ammo, since stack is ammo and they're equal
|
||||
int count = pickedup.getAmmoCount(stack);
|
||||
if(count != ininventory.addAmmo(count, candidate))
|
||||
return true;
|
||||
if (count != ininventory.addAmmo(count, candidate)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
// search the players inventory
|
||||
for(ItemStack invItem : player.inventory.mainInventory) {
|
||||
for (ItemStack invItem : player.inventory.mainInventory) {
|
||||
if (testIfAmmoMatches(stack, invItem)) {
|
||||
IAmmo pickedup = ((IAmmo) stack.getItem());
|
||||
IAmmo ininventory = ((IAmmo) invItem.getItem());
|
||||
// we can be sure that it's ammo, since stack is ammo and they're equal
|
||||
int count = pickedup.getAmmoCount(stack);
|
||||
if(count != ininventory.addAmmo(count, invItem))
|
||||
return true;
|
||||
if (count != ininventory.addAmmo(count, invItem)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,15 +104,11 @@ public abstract class AmmoItem extends ToolCore implements IBattlegearWeapon, IA
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean testIfAmmoMatches(ItemStack reference, ItemStack candidate)
|
||||
{
|
||||
if(candidate == null)
|
||||
return false;
|
||||
if(!candidate.hasTagCompound() || !candidate.getTagCompound().hasKey("InfiTool"))
|
||||
return false;
|
||||
private boolean testIfAmmoMatches(ItemStack reference, ItemStack candidate) {
|
||||
if (candidate == null) return false;
|
||||
if (!candidate.hasTagCompound() || !candidate.getTagCompound().hasKey("InfiTool")) return false;
|
||||
|
||||
if(reference.getItem() != candidate.getItem())
|
||||
return false;
|
||||
if (reference.getItem() != candidate.getItem()) return false;
|
||||
|
||||
NBTTagCompound referenceTags = getComparisonTags(reference);
|
||||
NBTTagCompound testTags = getComparisonTags(candidate);
|
||||
@@ -151,22 +138,18 @@ public abstract class AmmoItem extends ToolCore implements IBattlegearWeapon, IA
|
||||
}
|
||||
|
||||
private void copyTag(NBTTagCompound out, NBTTagCompound in, String tag) {
|
||||
if(in.hasKey(tag))
|
||||
out.setInteger(tag, in.getInteger(tag));
|
||||
if (in.hasKey(tag)) out.setInteger(tag, in.getInteger(tag));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onLeftClickEntity (ItemStack stack, EntityPlayer player, Entity entity)
|
||||
{
|
||||
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
|
||||
// ammo doesn't hurt on smacking stuff with it
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean sheatheOnBack(ItemStack item)
|
||||
{
|
||||
public boolean sheatheOnBack(ItemStack item) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -178,7 +161,8 @@ public abstract class AmmoItem extends ToolCore implements IBattlegearWeapon, IA
|
||||
|
||||
@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) {
|
||||
event.cancelParent = false;
|
||||
event.swingOffhand = false;
|
||||
event.shouldAttack = false;
|
||||
@@ -195,7 +179,7 @@ public abstract class AmmoItem extends ToolCore implements IBattlegearWeapon, IA
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean offhandClickBlock(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
|
||||
event.setCanceled(false);
|
||||
event.setCanceled(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -208,9 +192,10 @@ public abstract class AmmoItem extends ToolCore implements IBattlegearWeapon, IA
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean allowOffhand(ItemStack mainhand, ItemStack offhand) {
|
||||
if(offhand == null)
|
||||
return true;
|
||||
return (mainhand != null && mainhand.getItem() != TinkerTools.cleaver && mainhand.getItem() != TinkerTools.battleaxe)
|
||||
if (offhand == null) return true;
|
||||
return (mainhand != null
|
||||
&& mainhand.getItem() != TinkerTools.cleaver
|
||||
&& mainhand.getItem() != TinkerTools.battleaxe)
|
||||
&& (offhand.getItem() != TinkerTools.cleaver && offhand.getItem() != TinkerTools.battleaxe);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,19 @@
|
||||
package tconstruct.library.weaponry;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import tconstruct.weaponry.client.CrosshairType;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import mods.battlegear2.api.PlayerEventChild;
|
||||
import mods.battlegear2.api.weapons.IBattlegearWeapon;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import mods.battlegear2.api.PlayerEventChild;
|
||||
import mods.battlegear2.api.weapons.IBattlegearWeapon;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.weaponry.client.CrosshairType;
|
||||
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon")
|
||||
})
|
||||
@@ -36,16 +37,23 @@ public abstract class AmmoWeapon extends AmmoItem implements IBattlegearWeapon,
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if(getAmmoCount(stack) > 0)
|
||||
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
if (getAmmoCount(stack) > 0) 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;
|
||||
}
|
||||
|
||||
@@ -53,43 +61,43 @@ public abstract class AmmoWeapon extends AmmoItem implements IBattlegearWeapon,
|
||||
* How long it takes to "ready" the weapon. To reach the point, where holding the right mouse button any longer doesn't have an impact.
|
||||
*/
|
||||
@Override
|
||||
public int getWindupTime(ItemStack itemStack) { return 0; }
|
||||
public int getWindupTime(ItemStack itemStack) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMinWindupProgress(ItemStack itemStack) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float getWindupProgress(ItemStack itemStack, int timeInUse)
|
||||
{
|
||||
public float getWindupProgress(ItemStack itemStack, int timeInUse) {
|
||||
float time = (float) timeInUse;
|
||||
float windup = getWindupTime(itemStack);
|
||||
if(time > windup)
|
||||
time = windup;
|
||||
if (time > windup) time = windup;
|
||||
|
||||
return time/windup;
|
||||
return time / windup;
|
||||
}
|
||||
|
||||
public float minAccuracy(ItemStack itemStack) {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
public float minAccuracy(ItemStack itemStack) { return 0.5f; }
|
||||
public float maxAccuracy(ItemStack itemStack) { return 0.5f; }
|
||||
public float maxAccuracy(ItemStack itemStack) {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getWindupProgress(ItemStack itemStack, EntityPlayer player)
|
||||
{
|
||||
public float getWindupProgress(ItemStack itemStack, EntityPlayer player) {
|
||||
// what are you doing!
|
||||
if(player.inventory.getCurrentItem() != itemStack)
|
||||
return 0f;
|
||||
if (player.inventory.getCurrentItem() != itemStack) return 0f;
|
||||
|
||||
// are we using it?
|
||||
if(player.getItemInUse() == null)
|
||||
return 0f;
|
||||
if (player.getItemInUse() == null) return 0f;
|
||||
|
||||
return getWindupProgress(itemStack, getMaxItemUseDuration(itemStack) - player.getItemInUseCount());
|
||||
return getWindupProgress(itemStack, getMaxItemUseDuration(itemStack) - player.getItemInUseCount());
|
||||
}
|
||||
|
||||
public float getAccuracy(ItemStack itemStack, int time)
|
||||
{
|
||||
public float getAccuracy(ItemStack itemStack, int time) {
|
||||
float dif = minAccuracy(itemStack) - maxAccuracy(itemStack);
|
||||
|
||||
return minAccuracy(itemStack) - dif * getWindupProgress(itemStack, time);
|
||||
@@ -103,34 +111,35 @@ public abstract class AmmoWeapon extends AmmoItem implements IBattlegearWeapon,
|
||||
@Override
|
||||
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int durationLeft) {
|
||||
int time = this.getMaxItemUseDuration(stack) - durationLeft;
|
||||
if(getWindupProgress(stack, time) >= getMinWindupProgress(stack))
|
||||
launchProjectile(stack, world, player, time);
|
||||
if (getWindupProgress(stack, time) >= getMinWindupProgress(stack)) launchProjectile(stack, world, player, time);
|
||||
}
|
||||
|
||||
protected void launchProjectile(ItemStack stack, World world, EntityPlayer player, int time) {
|
||||
// spawn projectile on server
|
||||
if(!world.isRemote) {
|
||||
if (!world.isRemote) {
|
||||
ItemStack reference = stack.copy();
|
||||
reference.stackSize = 1;
|
||||
((IAmmo)reference.getItem()).setAmmo(1, reference);
|
||||
((IAmmo) reference.getItem()).setAmmo(1, reference);
|
||||
|
||||
Entity projectile = createProjectile(reference, world, player, getAccuracy(stack, time), time);
|
||||
world.spawnEntityInWorld(projectile);
|
||||
}
|
||||
|
||||
// reduce ammo
|
||||
if(!player.capabilities.isCreativeMode)
|
||||
this.consumeAmmo(1, stack);
|
||||
if (!player.capabilities.isCreativeMode) this.consumeAmmo(1, stack);
|
||||
}
|
||||
|
||||
protected abstract Entity createProjectile(ItemStack reference, World world, EntityPlayer player, float accuracy, int time);
|
||||
protected abstract Entity createProjectile(
|
||||
ItemStack reference, World world, EntityPlayer player, float accuracy, int time);
|
||||
|
||||
/** used for displaying the damage, return the value used for pseed in createProjectile/ProjectileBase constructor
|
||||
*/
|
||||
public abstract float getProjectileSpeed();
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CrosshairType getCrosshairType() { return CrosshairType.SQUARE; }
|
||||
public CrosshairType getCrosshairType() {
|
||||
return CrosshairType.SQUARE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean zoomOnWindup(ItemStack itemStack) {
|
||||
@@ -146,8 +155,7 @@ public abstract class AmmoWeapon extends AmmoItem implements IBattlegearWeapon,
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean sheatheOnBack(ItemStack item)
|
||||
{
|
||||
public boolean sheatheOnBack(ItemStack item) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -159,7 +167,8 @@ public abstract class AmmoWeapon extends AmmoItem implements IBattlegearWeapon,
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@@ -185,9 +194,10 @@ public abstract class AmmoWeapon extends AmmoItem implements IBattlegearWeapon,
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean allowOffhand(ItemStack mainhand, ItemStack offhand) {
|
||||
if(offhand == null)
|
||||
return true;
|
||||
return (mainhand != null && mainhand.getItem() != TinkerTools.cleaver && mainhand.getItem() != TinkerTools.battleaxe)
|
||||
if (offhand == null) return true;
|
||||
return (mainhand != null
|
||||
&& mainhand.getItem() != TinkerTools.cleaver
|
||||
&& mainhand.getItem() != TinkerTools.battleaxe)
|
||||
&& (offhand.getItem() != TinkerTools.cleaver && offhand.getItem() != TinkerTools.battleaxe);
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,45 @@
|
||||
package tconstruct.library.weaponry;
|
||||
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.library.tools.CustomMaterial;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
|
||||
public class ArrowShaftMaterial extends CustomMaterial {
|
||||
public final float durabilityModifier; // like the durability modifier of handles, but for arrows!
|
||||
public final float fragility; // 1.0 = breaks 100%, 0.0 = never breaks
|
||||
public final float weight; // baseline: 1.0 = default, smaller = lighter, higher = heavier
|
||||
|
||||
public ArrowShaftMaterial(int materialID, int value, ItemStack input, ItemStack craftingItem, float durabilityModifier, float weight, float fragility, int color) {
|
||||
public ArrowShaftMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
ItemStack input,
|
||||
ItemStack craftingItem,
|
||||
float durabilityModifier,
|
||||
float weight,
|
||||
float fragility,
|
||||
int color) {
|
||||
super(materialID, value, input, craftingItem, color);
|
||||
this.durabilityModifier = durabilityModifier;
|
||||
this.fragility = fragility;
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public static ArrowShaftMaterial createMaterial(int id, Item input, float durabilityModifier, float weight, float fragility, int color)
|
||||
{
|
||||
public static ArrowShaftMaterial createMaterial(
|
||||
int id, Item input, float durabilityModifier, float weight, float fragility, int color) {
|
||||
return createMaterial(id, input, 0, durabilityModifier, weight, fragility, color);
|
||||
}
|
||||
|
||||
public static ArrowShaftMaterial createMaterial(int id, Item input, int inputMeta, float durabilityModifier, float weight, float fragility, int color)
|
||||
{
|
||||
return new ArrowShaftMaterial(id, 2, new ItemStack(input, 1, inputMeta), new ItemStack(TinkerWeaponry.partArrowShaft, 0, id), durabilityModifier, weight, fragility, color);
|
||||
public static ArrowShaftMaterial createMaterial(
|
||||
int id, Item input, int inputMeta, float durabilityModifier, float weight, float fragility, int color) {
|
||||
return new ArrowShaftMaterial(
|
||||
id,
|
||||
2,
|
||||
new ItemStack(input, 1, inputMeta),
|
||||
new ItemStack(TinkerWeaponry.partArrowShaft, 0, id),
|
||||
durabilityModifier,
|
||||
weight,
|
||||
fragility,
|
||||
color);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
package tconstruct.library.weaponry;
|
||||
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.BowstringMaterial;
|
||||
import tconstruct.library.tools.CustomMaterial;
|
||||
import tconstruct.weaponry.ammo.ArrowAmmo;
|
||||
import tconstruct.weaponry.entity.ArrowEntity;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import java.util.List;
|
||||
import mods.battlegear2.api.core.InventoryPlayerBattle;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -14,11 +12,12 @@ import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import mods.battlegear2.api.core.InventoryPlayerBattle;
|
||||
|
||||
import java.util.List;
|
||||
import tconstruct.library.tools.BowstringMaterial;
|
||||
import tconstruct.library.tools.CustomMaterial;
|
||||
import tconstruct.weaponry.ammo.ArrowAmmo;
|
||||
import tconstruct.weaponry.entity.ArrowEntity;
|
||||
|
||||
public abstract class BowBaseAmmo extends ProjectileWeapon {
|
||||
public BowBaseAmmo(int baseDamage, String name) {
|
||||
@@ -56,13 +55,11 @@ public abstract class BowBaseAmmo extends ProjectileWeapon {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack searchForAmmo(EntityPlayer player, ItemStack weapon)
|
||||
{
|
||||
public ItemStack searchForAmmo(EntityPlayer player, ItemStack weapon) {
|
||||
// arrow priority: hotbar > inventory, tinker arrows > regular arrows
|
||||
if(Loader.isModLoaded("battlegear2")){
|
||||
if (Loader.isModLoaded("battlegear2")) {
|
||||
ItemStack offhand = ((InventoryPlayerBattle) player.inventory).getCurrentOffhandWeapon();
|
||||
if(offhand != null && (checkTinkerArrow(offhand) || checkVanillaArrow(offhand)))
|
||||
{
|
||||
if (offhand != null && (checkTinkerArrow(offhand) || checkVanillaArrow(offhand))) {
|
||||
return offhand;
|
||||
}
|
||||
}
|
||||
@@ -70,103 +67,90 @@ public abstract class BowBaseAmmo extends ProjectileWeapon {
|
||||
ItemStack[] inventory = player.inventory.mainInventory;
|
||||
|
||||
// check hotbar for tinker arrows
|
||||
for(int i = 0; i < InventoryPlayer.getHotbarSize(); i++)
|
||||
if(checkTinkerArrow(inventory[i]))
|
||||
return inventory[i];
|
||||
for (int i = 0; i < InventoryPlayer.getHotbarSize(); i++)
|
||||
if (checkTinkerArrow(inventory[i])) return inventory[i];
|
||||
|
||||
// check hotbar for vanilla arrows
|
||||
for(int i = 0; i < InventoryPlayer.getHotbarSize(); i++)
|
||||
if(checkVanillaArrow(inventory[i]))
|
||||
return inventory[i];
|
||||
for (int i = 0; i < InventoryPlayer.getHotbarSize(); i++)
|
||||
if (checkVanillaArrow(inventory[i])) return inventory[i];
|
||||
|
||||
// check the rest of the inventory for tinker arrows
|
||||
for(int i = InventoryPlayer.getHotbarSize(); i < inventory.length; i++)
|
||||
if(checkTinkerArrow(inventory[i]))
|
||||
return inventory[i];
|
||||
for (int i = InventoryPlayer.getHotbarSize(); i < inventory.length; i++)
|
||||
if (checkTinkerArrow(inventory[i])) return inventory[i];
|
||||
|
||||
// check the rest of the inventory for vanilla arrows
|
||||
for(int i = InventoryPlayer.getHotbarSize(); i < inventory.length; i++)
|
||||
if(checkVanillaArrow(inventory[i]))
|
||||
return inventory[i];
|
||||
for (int i = InventoryPlayer.getHotbarSize(); i < inventory.length; i++)
|
||||
if (checkVanillaArrow(inventory[i])) return inventory[i];
|
||||
|
||||
// creative mode
|
||||
if(player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, weapon) > 0)
|
||||
if (player.capabilities.isCreativeMode
|
||||
|| EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, weapon) > 0)
|
||||
return new ItemStack(Items.arrow);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean checkTinkerArrow(ItemStack stack)
|
||||
{
|
||||
private boolean checkTinkerArrow(ItemStack stack) {
|
||||
// null
|
||||
if(stack == null)
|
||||
return false;
|
||||
if (stack == null) return false;
|
||||
// no tinker arrow
|
||||
if(!(stack.getItem() instanceof ArrowAmmo))
|
||||
return false;
|
||||
if (!(stack.getItem() instanceof ArrowAmmo)) return false;
|
||||
// no ammo left
|
||||
if(((IAmmo) stack.getItem()).getAmmoCount(stack) <= 0)
|
||||
return false;
|
||||
if (((IAmmo) stack.getItem()).getAmmoCount(stack) <= 0) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean checkVanillaArrow(ItemStack stack)
|
||||
{
|
||||
private boolean checkVanillaArrow(ItemStack stack) {
|
||||
// null
|
||||
if(stack == null)
|
||||
return false;
|
||||
if (stack == null) return false;
|
||||
// no arrow
|
||||
if(!(stack.getItem() == Items.arrow))
|
||||
return false;
|
||||
if (!(stack.getItem() == Items.arrow)) return false;
|
||||
// inventory shouldn't contain stacksize 0 items so we don't have to check that.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Entity createProjectile(ItemStack arrows, World world, EntityPlayer player, float speed, float accuracy, float windup) {
|
||||
protected Entity createProjectile(
|
||||
ItemStack arrows, World world, EntityPlayer player, float speed, float accuracy, float windup) {
|
||||
EntityArrow arrow;
|
||||
|
||||
if(arrows.getItem() == Items.arrow) {
|
||||
arrow = new EntityArrow(world, player, speed/1.5f); // vanilla arrows internally do x1.5
|
||||
}
|
||||
else {
|
||||
if (arrows.getItem() == Items.arrow) {
|
||||
arrow = new EntityArrow(world, player, speed / 1.5f); // vanilla arrows internally do x1.5
|
||||
} else {
|
||||
ItemStack reference = arrows.copy();
|
||||
reference.stackSize = 1;
|
||||
reference.getTagCompound().getCompoundTag("InfiTool").setInteger("Ammo", 1);
|
||||
arrow = new ArrowEntity(world, player, speed, accuracy, reference);
|
||||
}
|
||||
|
||||
if(player.capabilities.isCreativeMode)
|
||||
arrow.canBePickedUp = 2;
|
||||
if (player.capabilities.isCreativeMode) arrow.canBePickedUp = 2;
|
||||
|
||||
if(windup >= 1f)
|
||||
arrow.setIsCritical(true);
|
||||
if (windup >= 1f) arrow.setIsCritical(true);
|
||||
|
||||
return arrow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playFiringSound(World world, EntityPlayer player, ItemStack weapon, ItemStack ammo, float speed, float accuracy) {
|
||||
public void playFiringSound(
|
||||
World world, EntityPlayer player, ItemStack weapon, ItemStack ammo, float speed, float accuracy) {
|
||||
world.playSoundAtEntity(player, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + speed * 0.5F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildTool (int id, String name, List list)
|
||||
{
|
||||
public void buildTool(int id, String name, List list) {
|
||||
// does the material have a bow material?
|
||||
if(TConstructRegistry.getBowMaterial(id) == null)
|
||||
return;
|
||||
if (TConstructRegistry.getBowMaterial(id) == null) return;
|
||||
|
||||
// all creative bows use regular bowstring
|
||||
ItemStack handleStack = new ItemStack(getHandleItem(), 1, 0); // regular bowstring
|
||||
ItemStack accessoryStack = getPartAmount() > 2 ? new ItemStack(getAccessoryItem(), 1, id) : null;
|
||||
ItemStack extraStack = getPartAmount() > 3 ? new ItemStack(getExtraItem(), 1, id) : null;
|
||||
|
||||
ItemStack tool = ToolBuilder.instance.buildTool(new ItemStack(getHeadItem(), 1, id), handleStack, accessoryStack, extraStack, "");
|
||||
if (tool != null)
|
||||
{
|
||||
ItemStack tool = ToolBuilder.instance.buildTool(
|
||||
new ItemStack(getHeadItem(), 1, id), handleStack, accessoryStack, extraStack, "");
|
||||
if (tool != null) {
|
||||
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
|
||||
list.add(tool);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package tconstruct.library.weaponry;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IAccuracy {
|
||||
public float minAccuracy(ItemStack itemStack);
|
||||
|
||||
public float maxAccuracy(ItemStack itemStack);
|
||||
|
||||
public float getAccuracy(ItemStack itemStack, int time);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package tconstruct.library.weaponry;
|
||||
|
||||
import tconstruct.weaponry.client.CrosshairType;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.weaponry.client.CrosshairType;
|
||||
|
||||
/**
|
||||
* This class has a windup time, meaning it takes some time to reach full potency.
|
||||
@@ -10,11 +10,14 @@ import net.minecraft.item.ItemStack;
|
||||
*/
|
||||
public interface IWindup {
|
||||
public int getWindupTime(ItemStack itemStack); // how long it takes to fully wind up
|
||||
|
||||
public float getWindupProgress(ItemStack itemStack, EntityPlayer player); // how far we've winded up, 0.0-1.0
|
||||
|
||||
public float getMinWindupProgress(ItemStack itemStack); // how long it has been winded up at least to fire (0.0-1.0)
|
||||
|
||||
public CrosshairType getCrosshairType();
|
||||
|
||||
public boolean zoomOnWindup(ItemStack itemStack);
|
||||
|
||||
public float getZoom(ItemStack itemStack);
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
package tconstruct.library.weaponry;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mods.battlegear2.api.PlayerEventChild;
|
||||
import mods.battlegear2.api.weapons.IBattlegearWeapon;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
@@ -27,9 +29,6 @@ import tconstruct.library.util.TextureHelper;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import tconstruct.weaponry.client.CrosshairType;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon")
|
||||
@@ -76,20 +75,19 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
* @param accuracy the accuracy calculated for the projectile
|
||||
* @return A banana.
|
||||
*/
|
||||
protected abstract Entity createProjectile(ItemStack ammo, World world, EntityPlayer player, float speed, float accuracy, float windup);
|
||||
|
||||
protected abstract Entity createProjectile(
|
||||
ItemStack ammo, World world, EntityPlayer player, float speed, float accuracy, float windup);
|
||||
|
||||
/* Accuracy */
|
||||
public abstract float minAccuracy(ItemStack itemStack);
|
||||
|
||||
public abstract float maxAccuracy(ItemStack itemStack);
|
||||
|
||||
public float getAccuracy(ItemStack itemStack, EntityPlayer player)
|
||||
{
|
||||
return getAccuracy(itemStack, getMaxItemUseDuration(itemStack) - player.getItemInUseCount());
|
||||
public float getAccuracy(ItemStack itemStack, EntityPlayer player) {
|
||||
return getAccuracy(itemStack, getMaxItemUseDuration(itemStack) - player.getItemInUseCount());
|
||||
}
|
||||
|
||||
public float getAccuracy(ItemStack itemStack, int time)
|
||||
{
|
||||
public float getAccuracy(ItemStack itemStack, int time) {
|
||||
float dif = minAccuracy(itemStack) - maxAccuracy(itemStack);
|
||||
|
||||
return minAccuracy(itemStack) - dif * getWindupProgress(itemStack, time);
|
||||
@@ -97,40 +95,32 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
|
||||
/* Windup */
|
||||
public int getWindupTime(ItemStack itemStack) {
|
||||
if(itemStack == null || !itemStack.hasTagCompound())
|
||||
return 1;
|
||||
|
||||
if (itemStack == null || !itemStack.hasTagCompound()) return 1;
|
||||
|
||||
NBTTagCompound toolTag = itemStack.getTagCompound().getCompoundTag("InfiTool");
|
||||
return toolTag.getInteger("DrawSpeed");
|
||||
}
|
||||
|
||||
public float getWindupProgress(ItemStack itemStack, EntityPlayer player)
|
||||
{
|
||||
public float getWindupProgress(ItemStack itemStack, EntityPlayer player) {
|
||||
// what are you doing!
|
||||
if(player.inventory.getCurrentItem() != itemStack)
|
||||
return 0f;
|
||||
if (player.inventory.getCurrentItem() != itemStack) return 0f;
|
||||
|
||||
// are we using it?
|
||||
if(player.getItemInUse() == null)
|
||||
return 0f;
|
||||
if (player.getItemInUse() == null) return 0f;
|
||||
|
||||
return getWindupProgress(itemStack, getMaxItemUseDuration(itemStack) - player.getItemInUseCount());
|
||||
return getWindupProgress(itemStack, getMaxItemUseDuration(itemStack) - player.getItemInUseCount());
|
||||
}
|
||||
|
||||
public float getWindupProgress(ItemStack itemStack, int timeInUse)
|
||||
{
|
||||
public float getWindupProgress(ItemStack itemStack, int timeInUse) {
|
||||
float time = (float) timeInUse;
|
||||
float windup = getWindupTime(itemStack);
|
||||
if(time > windup)
|
||||
return 1.0f;
|
||||
if (time > windup) return 1.0f;
|
||||
|
||||
return time/windup;
|
||||
return time / windup;
|
||||
}
|
||||
|
||||
public float getProjectileSpeed(ItemStack itemStack)
|
||||
{
|
||||
if (itemStack != null && itemStack.hasTagCompound())
|
||||
{
|
||||
public float getProjectileSpeed(ItemStack itemStack) {
|
||||
if (itemStack != null && itemStack.hasTagCompound()) {
|
||||
NBTTagCompound toolTag = itemStack.getTagCompound().getCompoundTag("InfiTool");
|
||||
return toolTag.getFloat("FlightSpeed");
|
||||
}
|
||||
@@ -149,26 +139,22 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if(getWindupTime(stack) == 0.0f)
|
||||
return stack;
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
if (getWindupTime(stack) == 0.0f) return stack;
|
||||
|
||||
// broken tool?
|
||||
if(stack.hasTagCompound() && stack.getTagCompound().hasKey(getBaseTagName()) && stack.getTagCompound().getCompoundTag(getBaseTagName()).getBoolean("Broken"))
|
||||
return stack;
|
||||
if (stack.hasTagCompound()
|
||||
&& stack.getTagCompound().hasKey(getBaseTagName())
|
||||
&& stack.getTagCompound().getCompoundTag(getBaseTagName()).getBoolean("Broken")) return stack;
|
||||
|
||||
// only if ammo is present
|
||||
if(searchForAmmo(player, stack) != null)
|
||||
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
||||
if (searchForAmmo(player, stack) != null) player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerStoppedUsing (ItemStack weapon, World world, EntityPlayer player, int useRemaining)
|
||||
{
|
||||
if (!weapon.hasTagCompound())
|
||||
{
|
||||
public void onPlayerStoppedUsing(ItemStack weapon, World world, EntityPlayer player, int useRemaining) {
|
||||
if (!weapon.hasTagCompound()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -177,8 +163,7 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
// we abuse the arrowLooseEvent for all projectiles
|
||||
ArrowLooseEvent event = new ArrowLooseEvent(player, weapon, time);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
if (event.isCanceled())
|
||||
{
|
||||
if (event.isCanceled()) {
|
||||
return;
|
||||
}
|
||||
time = event.charge;
|
||||
@@ -187,8 +172,7 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
ItemStack ammo = searchForAmmo(player, weapon);
|
||||
|
||||
// no ammo found. :(
|
||||
if(ammo == null)
|
||||
return;
|
||||
if (ammo == null) return;
|
||||
|
||||
NBTTagCompound toolTag = weapon.getTagCompound().getCompoundTag("InfiTool");
|
||||
float projectileSpeed = getProjectileSpeed(weapon);
|
||||
@@ -196,39 +180,32 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
float accuracy = getAccuracy(weapon, time);
|
||||
|
||||
// needs a minimum windup
|
||||
if(windup < this.getMinWindupProgress(weapon))
|
||||
return;
|
||||
if (windup < this.getMinWindupProgress(weapon)) return;
|
||||
|
||||
// take windup time into account
|
||||
projectileSpeed *= windup;
|
||||
|
||||
Entity projectile = createProjectile(ammo, world, player, projectileSpeed, accuracy, windup);
|
||||
|
||||
|
||||
int reinforced = 0;
|
||||
if (toolTag.hasKey("Unbreaking"))
|
||||
reinforced = toolTag.getInteger("Unbreaking");
|
||||
if (toolTag.hasKey("Unbreaking")) reinforced = toolTag.getInteger("Unbreaking");
|
||||
|
||||
if (random.nextInt(10) < 10 - reinforced)
|
||||
AbilityHelper.damageTool(weapon, 1, player, false);
|
||||
if (random.nextInt(10) < 10 - reinforced) AbilityHelper.damageTool(weapon, 1, player, false);
|
||||
|
||||
playFiringSound(world, player, weapon, ammo, projectileSpeed, accuracy);
|
||||
|
||||
|
||||
// use up ammo
|
||||
if(!player.capabilities.isCreativeMode) {
|
||||
if (ammo.getItem() instanceof IAmmo)
|
||||
((IAmmo) ammo.getItem()).consumeAmmo(1, ammo);
|
||||
else
|
||||
player.inventory.consumeInventoryItem(ammo.getItem());
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
if (ammo.getItem() instanceof IAmmo) ((IAmmo) ammo.getItem()).consumeAmmo(1, ammo);
|
||||
else player.inventory.consumeInventoryItem(ammo.getItem());
|
||||
}
|
||||
|
||||
// FIREEEEEEE
|
||||
if (!world.isRemote)
|
||||
world.spawnEntityInWorld(projectile);
|
||||
if (!world.isRemote) world.spawnEntityInWorld(projectile);
|
||||
}
|
||||
|
||||
public abstract void playFiringSound(World world, EntityPlayer player, ItemStack weapon, ItemStack ammo, float speed, float accuracy);
|
||||
public abstract void playFiringSound(
|
||||
World world, EntityPlayer player, ItemStack weapon, ItemStack ammo, float speed, float accuracy);
|
||||
|
||||
public HashMap<Integer, IIcon[]> animationHeadIcons = new HashMap<Integer, IIcon[]>();
|
||||
public HashMap<Integer, IIcon[]> animationHandleIcons = new HashMap<Integer, IIcon[]>();
|
||||
@@ -243,8 +220,7 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
* 2 == accessory
|
||||
* 3 == extra
|
||||
*/
|
||||
protected boolean animateLayer(int renderPass)
|
||||
{
|
||||
protected boolean animateLayer(int renderPass) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -252,20 +228,21 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) {
|
||||
NBTTagCompound tags = null;
|
||||
|
||||
if(stack.hasTagCompound())
|
||||
tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (stack.hasTagCompound()) tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
|
||||
if(tags == null || renderPass > 10)
|
||||
return super.getIcon(stack, renderPass, player, usingItem, useRemaining);
|
||||
if (tags == null || renderPass > 10) return super.getIcon(stack, renderPass, player, usingItem, useRemaining);
|
||||
|
||||
// are we drawing an effect?
|
||||
if(renderPass >= getPartAmount()) {
|
||||
if (renderPass >= getPartAmount()) {
|
||||
// is the effect animated?
|
||||
String effect = "Effect" + (1 + renderPass - getPartAmount());
|
||||
if(tags.hasKey(effect)) {
|
||||
if (tags.hasKey(effect)) {
|
||||
int index = tags.getInteger(effect);
|
||||
if(animationEffectIcons.get(index) != null)
|
||||
return getCorrectAnimationIcon(animationEffectIcons, index, getWindupProgress(usingItem, getMaxItemUseDuration(usingItem) - useRemaining));
|
||||
if (animationEffectIcons.get(index) != null)
|
||||
return getCorrectAnimationIcon(
|
||||
animationEffectIcons,
|
||||
index,
|
||||
getWindupProgress(usingItem, getMaxItemUseDuration(usingItem) - useRemaining));
|
||||
else
|
||||
// non-animated
|
||||
return effectIcons.get(index);
|
||||
@@ -274,35 +251,35 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
}
|
||||
|
||||
// animate?
|
||||
if(!animateLayer(renderPass))
|
||||
return super.getIcon(stack, renderPass, player, usingItem, useRemaining);
|
||||
if (!animateLayer(renderPass)) return super.getIcon(stack, renderPass, player, usingItem, useRemaining);
|
||||
|
||||
if(usingItem == null || stack != usingItem || !stack.hasTagCompound())
|
||||
if (usingItem == null || stack != usingItem || !stack.hasTagCompound())
|
||||
return super.getIcon(stack, renderPass, player, usingItem, useRemaining);
|
||||
|
||||
float progress = getWindupProgress(usingItem, getMaxItemUseDuration(usingItem) - useRemaining);
|
||||
// get the correct icon
|
||||
switch (renderPass)
|
||||
{
|
||||
case 0: return getCorrectAnimationIcon(animationHandleIcons, tags.getInteger("RenderHandle"), progress);
|
||||
case 1: return getCorrectAnimationIcon(animationHeadIcons, tags.getInteger("RenderHead"), progress);
|
||||
case 2: return getCorrectAnimationIcon(animationAccessoryIcons, tags.getInteger("RenderAccessory"), progress);
|
||||
case 3: return getCorrectAnimationIcon(animationExtraIcons, tags.getInteger("RenderExtra"), progress);
|
||||
switch (renderPass) {
|
||||
case 0:
|
||||
return getCorrectAnimationIcon(animationHandleIcons, tags.getInteger("RenderHandle"), progress);
|
||||
case 1:
|
||||
return getCorrectAnimationIcon(animationHeadIcons, tags.getInteger("RenderHead"), progress);
|
||||
case 2:
|
||||
return getCorrectAnimationIcon(animationAccessoryIcons, tags.getInteger("RenderAccessory"), progress);
|
||||
case 3:
|
||||
return getCorrectAnimationIcon(animationExtraIcons, tags.getInteger("RenderExtra"), progress);
|
||||
}
|
||||
|
||||
return emptyIcon;
|
||||
}
|
||||
|
||||
protected IIcon getCorrectAnimationIcon(Map<Integer, IIcon[]> icons, int id, float progress)
|
||||
{
|
||||
protected IIcon getCorrectAnimationIcon(Map<Integer, IIcon[]> icons, int id, float progress) {
|
||||
// animation count, standard texture as reference
|
||||
float count = icons.get(-1).length - 1;
|
||||
int step = Math.round(progress * count);
|
||||
|
||||
step = Math.max(0, step);
|
||||
|
||||
if(icons.containsKey(id))
|
||||
return icons.get(id)[step];
|
||||
if (icons.containsKey(id)) return icons.get(id)[step];
|
||||
|
||||
// default icon
|
||||
return icons.get(-1)[step];
|
||||
@@ -311,40 +288,30 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
// exactly the same as the ToolCore one but with broken check for Handle instead of Head
|
||||
public IIcon getIcon (ItemStack stack, int renderPass)
|
||||
{
|
||||
public IIcon getIcon(ItemStack stack, int renderPass) {
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
|
||||
if (tags != null)
|
||||
{
|
||||
if (tags != null) {
|
||||
tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (renderPass < getPartAmount())
|
||||
{
|
||||
if (renderPass < getPartAmount()) {
|
||||
// Handle
|
||||
if (renderPass == 0) {
|
||||
if (tags.getBoolean("Broken"))
|
||||
return getCorrectIcon(brokenIcons, tags.getInteger("RenderHandle"));
|
||||
else
|
||||
return getCorrectIcon(handleIcons, tags.getInteger("RenderHandle"));
|
||||
if (tags.getBoolean("Broken")) return getCorrectIcon(brokenIcons, tags.getInteger("RenderHandle"));
|
||||
else return getCorrectIcon(handleIcons, tags.getInteger("RenderHandle"));
|
||||
}
|
||||
// Head
|
||||
else if (renderPass == 1)
|
||||
{
|
||||
// Head
|
||||
else if (renderPass == 1) {
|
||||
return getCorrectIcon(headIcons, tags.getInteger("RenderHead"));
|
||||
}
|
||||
// Accessory
|
||||
else if (renderPass == 2)
|
||||
return getCorrectIcon(accessoryIcons, tags.getInteger("RenderAccessory"));
|
||||
// Extra
|
||||
else if (renderPass == 3)
|
||||
return getCorrectIcon(extraIcons, tags.getInteger("RenderExtra"));
|
||||
else if (renderPass == 2) return getCorrectIcon(accessoryIcons, tags.getInteger("RenderAccessory"));
|
||||
// Extra
|
||||
else if (renderPass == 3) return getCorrectIcon(extraIcons, tags.getInteger("RenderExtra"));
|
||||
}
|
||||
// Effects
|
||||
else if (renderPass <= 10)
|
||||
{
|
||||
else if (renderPass <= 10) {
|
||||
String effect = "Effect" + (1 + renderPass - getPartAmount());
|
||||
if(tags.hasKey(effect))
|
||||
return effectIcons.get(tags.getInteger(effect));
|
||||
if (tags.hasKey(effect)) return effectIcons.get(tags.getInteger(effect));
|
||||
}
|
||||
return blankSprite;
|
||||
}
|
||||
@@ -363,73 +330,63 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
// animated effects...
|
||||
// find out the longest animation
|
||||
int count = 0;
|
||||
if(animationHeadIcons.get(-1) != null)
|
||||
count = Math.max(count, animationHeadIcons.get(-1).length);
|
||||
if(animationHandleIcons.get(-1) != null)
|
||||
count = Math.max(count, animationHandleIcons.get(-1).length);
|
||||
if(animationAccessoryIcons.get(-1) != null)
|
||||
count = Math.max(count, animationAccessoryIcons.get(-1).length);
|
||||
if(animationExtraIcons.get(-1) != null)
|
||||
count = Math.max(count, animationExtraIcons.get(-1).length);
|
||||
if (animationHeadIcons.get(-1) != null) count = Math.max(count, animationHeadIcons.get(-1).length);
|
||||
if (animationHandleIcons.get(-1) != null) count = Math.max(count, animationHandleIcons.get(-1).length);
|
||||
if (animationAccessoryIcons.get(-1) != null) count = Math.max(count, animationAccessoryIcons.get(-1).length);
|
||||
if (animationExtraIcons.get(-1) != null) count = Math.max(count, animationExtraIcons.get(-1).length);
|
||||
|
||||
|
||||
for(Map.Entry<Integer, String> entry : effectStrings.entrySet())
|
||||
{
|
||||
for (Map.Entry<Integer, String> entry : effectStrings.entrySet()) {
|
||||
IIcon[] anims = new IIcon[count];
|
||||
boolean empty = true;
|
||||
for(int i = 0; i < count; i++) {
|
||||
String tex = entry.getValue() + "_" + (i+1);
|
||||
for (int i = 0; i < count; i++) {
|
||||
String tex = entry.getValue() + "_" + (i + 1);
|
||||
if (TextureHelper.itemTextureExists(tex)) {
|
||||
anims[i] = iconRegister.registerIcon(tex);
|
||||
empty = false;
|
||||
}
|
||||
}
|
||||
if(!empty)
|
||||
animationEffectIcons.put(entry.getKey(), anims);
|
||||
if (!empty) animationEffectIcons.put(entry.getKey(), anims);
|
||||
}
|
||||
|
||||
// default for effects is blank
|
||||
IIcon[] anims = new IIcon[count];
|
||||
for(int i = 0; i < count; i++)
|
||||
anims[i] = blankSprite;
|
||||
for (int i = 0; i < count; i++) anims[i] = blankSprite;
|
||||
animationEffectIcons.put(-1, anims);
|
||||
}
|
||||
|
||||
private void addAnimationIcons(HashMap<Integer, String> textures, HashMap<Integer, IIcon[]> icons, IIconRegister iconRegister, String standard)
|
||||
{
|
||||
private void addAnimationIcons(
|
||||
HashMap<Integer, String> textures,
|
||||
HashMap<Integer, IIcon[]> icons,
|
||||
IIconRegister iconRegister,
|
||||
String standard) {
|
||||
icons.clear();
|
||||
|
||||
// we use the standard to determine how many animations there are
|
||||
if(standard == null || standard.isEmpty())
|
||||
return;
|
||||
if (standard == null || standard.isEmpty()) return;
|
||||
|
||||
int count = 1;
|
||||
standard = getDefaultTexturePath() + "/" + standard;
|
||||
while(TextureHelper.itemTextureExists(standard + "_" + count))
|
||||
count++;
|
||||
standard = getDefaultTexturePath() + "/" + standard;
|
||||
while (TextureHelper.itemTextureExists(standard + "_" + count)) count++;
|
||||
|
||||
count--;
|
||||
|
||||
// add the standard icons
|
||||
IIcon[] anims = new IIcon[count];
|
||||
for(int i = 0; i < count; i++)
|
||||
anims[i] = iconRegister.registerIcon(standard + "_" + (i+1));
|
||||
for (int i = 0; i < count; i++) anims[i] = iconRegister.registerIcon(standard + "_" + (i + 1));
|
||||
icons.put(-1, anims);
|
||||
|
||||
// now do the same for each entry
|
||||
for(Map.Entry<Integer, String> entry : textures.entrySet())
|
||||
{
|
||||
for (Map.Entry<Integer, String> entry : textures.entrySet()) {
|
||||
anims = new IIcon[count];
|
||||
boolean empty = true;
|
||||
for(int i = 0; i < count; i++) {
|
||||
String tex = entry.getValue() + "_" + (i+1);
|
||||
for (int i = 0; i < count; i++) {
|
||||
String tex = entry.getValue() + "_" + (i + 1);
|
||||
if (TextureHelper.itemTextureExists(tex)) {
|
||||
anims[i] = iconRegister.registerIcon(tex);
|
||||
empty = false;
|
||||
}
|
||||
}
|
||||
if(!empty)
|
||||
icons.put(entry.getKey(), anims);
|
||||
if (!empty) icons.put(entry.getKey(), anims);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -438,29 +395,25 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
|
||||
super.addInformation(stack, player, list, par4);
|
||||
|
||||
if(!stack.hasTagCompound())
|
||||
return;
|
||||
if (!stack.hasTagCompound()) return;
|
||||
|
||||
// also display max damage with current ammo
|
||||
ItemStack currentAmmo = searchForAmmo(player, stack);
|
||||
if(currentAmmo == null)
|
||||
return;
|
||||
if (currentAmmo == null) return;
|
||||
|
||||
float damage;
|
||||
if(currentAmmo.getItem() == Items.arrow) {
|
||||
if (currentAmmo.getItem() == Items.arrow) {
|
||||
damage = 2 * getProjectileSpeed(stack);
|
||||
}
|
||||
else if(currentAmmo.getItem() instanceof AmmoItem && currentAmmo.hasTagCompound()) {
|
||||
} else if (currentAmmo.getItem() instanceof AmmoItem && currentAmmo.hasTagCompound()) {
|
||||
NBTTagCompound tags = currentAmmo.getTagCompound().getCompoundTag("InfiTool");
|
||||
if(!tags.hasKey("BaseAttack"))
|
||||
{
|
||||
if (!tags.hasKey("BaseAttack")) {
|
||||
// quickly calculate the base attack damage from the actual attack damage and quartz modifiers
|
||||
// yes, this relies on quartz being the only modifier that modifiers damage, but at the point of writing this
|
||||
// yes, this relies on quartz being the only modifier that modifiers damage, but at the point of writing
|
||||
// this
|
||||
// that is the case, and later tools should have the tag
|
||||
int atk = tags.getInteger("Attack");
|
||||
if(tags.hasKey("ModAttack"))
|
||||
{
|
||||
int bonusDmg = tags.getIntArray("ModAttack")[0]/24 + 1;
|
||||
if (tags.hasKey("ModAttack")) {
|
||||
int bonusDmg = tags.getIntArray("ModAttack")[0] / 24 + 1;
|
||||
atk -= bonusDmg;
|
||||
}
|
||||
tags.setInteger("BaseAttack", atk);
|
||||
@@ -472,32 +425,37 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
damage = baseAttack * getProjectileSpeed(stack);
|
||||
damage += (totalAttack - baseAttack);
|
||||
|
||||
if(currentAmmo.getItem() == TinkerWeaponry.arrowAmmo || currentAmmo.getItem() == TinkerWeaponry.boltAmmo)
|
||||
damage = Math.max(0, damage - currentAmmo.getTagCompound().getCompoundTag("InfiTool").getInteger("Attack")/2f);
|
||||
if (currentAmmo.getItem() == TinkerWeaponry.arrowAmmo || currentAmmo.getItem() == TinkerWeaponry.boltAmmo)
|
||||
damage = Math.max(
|
||||
0,
|
||||
damage
|
||||
- currentAmmo
|
||||
.getTagCompound()
|
||||
.getCompoundTag("InfiTool")
|
||||
.getInteger("Attack")
|
||||
/ 2f);
|
||||
|
||||
damage *= ((AmmoItem) currentAmmo.getItem()).getDamageModifier();
|
||||
|
||||
// since most arrows will be criticals, we factor in an average crit
|
||||
if(currentAmmo.getItem() == TinkerWeaponry.arrowAmmo || currentAmmo.getItem() == TinkerWeaponry.boltAmmo)
|
||||
damage += (0.5f/4f + Math.min(0.75f, getProjectileSpeed(stack)/25f)) * (damage / 2f + 2f);
|
||||
}
|
||||
else
|
||||
return;
|
||||
if (currentAmmo.getItem() == TinkerWeaponry.arrowAmmo || currentAmmo.getItem() == TinkerWeaponry.boltAmmo)
|
||||
damage += (0.5f / 4f + Math.min(0.75f, getProjectileSpeed(stack) / 25f)) * (damage / 2f + 2f);
|
||||
} else return;
|
||||
|
||||
// convert to hearts
|
||||
damage /= 2;
|
||||
|
||||
list.remove(list.size()-1); // remove last item (the damage of the bow itself)
|
||||
list.remove(list.size() - 1); // remove last item (the damage of the bow itself)
|
||||
list.add(currentAmmo.getDisplayName());
|
||||
list.add(StatCollector.translateToLocal("attribute.name.ammo.maxAttackDamage") + ": " + TProxyClient.df.format(damage));
|
||||
list.add(StatCollector.translateToLocal("attribute.name.ammo.maxAttackDamage") + ": "
|
||||
+ TProxyClient.df.format(damage));
|
||||
}
|
||||
|
||||
/*---- Battlegear Support START ----*/
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean sheatheOnBack(ItemStack item)
|
||||
{
|
||||
public boolean sheatheOnBack(ItemStack item) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -509,7 +467,8 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
|
||||
@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 false;
|
||||
}
|
||||
|
||||
@@ -534,9 +493,10 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean allowOffhand(ItemStack mainhand, ItemStack offhand) {
|
||||
if(offhand == null)
|
||||
return true;
|
||||
return (mainhand != null && mainhand.getItem() != TinkerTools.cleaver && mainhand.getItem() != TinkerTools.battleaxe)
|
||||
if (offhand == null) return true;
|
||||
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