mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-26 06:52:58 +00:00
Move to Maven structure
This commit is contained in:
1 parent
ad86fccb88
commit
5cdc894dad
537 files changed
No files matched your search
@@ -0,0 +1,27 @@
|
||||
package tconstruct.util;
|
||||
|
||||
import cpw.mods.fml.common.ICrashCallable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
// Crash handler for when an unsupported mod is running alongside us
|
||||
public class CallableSuppConfig implements ICrashCallable
|
||||
{
|
||||
|
||||
public CallableSuppConfig()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel ()
|
||||
{
|
||||
return "TConstruct Environment";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String call () throws Exception
|
||||
{
|
||||
return "Sane and ready for action. Bugs may be reported.";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package tconstruct.util;
|
||||
|
||||
import cpw.mods.fml.common.ICrashCallable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
// Crash handler for when an unsupported mod is running alongside us
|
||||
public class CallableUnsuppConfig implements ICrashCallable
|
||||
{
|
||||
|
||||
private List<String> modIds;
|
||||
|
||||
public CallableUnsuppConfig(List<String> modIds)
|
||||
{
|
||||
this.modIds = modIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel ()
|
||||
{
|
||||
return "TConstruct Environment";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String call () throws Exception
|
||||
{
|
||||
String str = "DO NOT REPORT THIS CRASH! Unsupported mods in environment: ";
|
||||
Boolean firstEntry = true;
|
||||
for (String id : modIds)
|
||||
{
|
||||
str = str + (firstEntry ? id : ", " + id);
|
||||
firstEntry = false;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package tconstruct.util;
|
||||
|
||||
import net.minecraft.util.DamageSource;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
|
||||
public class DamageSourceFireworkExplode extends DamageSource
|
||||
{
|
||||
|
||||
public DamageSourceFireworkExplode(String s)
|
||||
{
|
||||
super(s);
|
||||
this.setDamageBypassesArmor();
|
||||
}
|
||||
|
||||
public ChatMessageComponent getDeathMessage (EntityLivingBase par1EntityLivingBase)
|
||||
{
|
||||
return super.getDeathMessage(par1EntityLivingBase);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package tconstruct.util;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class DamageSourceLandmine extends DamageSource
|
||||
{
|
||||
|
||||
public DamageSourceLandmine(String s)
|
||||
{
|
||||
super(s);
|
||||
this.setDamageBypassesArmor();
|
||||
}
|
||||
|
||||
public ChatMessageComponent getDeathMessage (EntityLivingBase par1EntityLivingBase)
|
||||
{
|
||||
return super.getDeathMessage(par1EntityLivingBase);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package tconstruct.util;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class DozenalConverter
|
||||
{
|
||||
public static String convertToDozenal (byte i)
|
||||
{
|
||||
return convertDecimal(i);
|
||||
}
|
||||
|
||||
public static String convertToDozenal (short i)
|
||||
{
|
||||
return convertDecimal(i);
|
||||
}
|
||||
|
||||
public static String convertToDozenal (int i)
|
||||
{
|
||||
return convertDecimal(i);
|
||||
}
|
||||
|
||||
public static String convertDecimal (int i)
|
||||
{
|
||||
int num = i;
|
||||
LinkedList<Character> list = new LinkedList();
|
||||
while (num > 0)
|
||||
{
|
||||
list.add(getDozenalCharacter(num % 12));
|
||||
num /= 12;
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int iter = list.size() - 1; iter > 0; iter--)
|
||||
{
|
||||
builder.append(list.get(iter));
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static char getDozenalCharacter (int i)
|
||||
{
|
||||
assert i < 12 : "Base 10 number should be less than 12";
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
return '0'; //Zero
|
||||
case 1:
|
||||
return '1'; //One
|
||||
case 2:
|
||||
return '2'; //Two
|
||||
case 3:
|
||||
return '3'; //Three
|
||||
case 4:
|
||||
return '4'; //Four
|
||||
case 5:
|
||||
return '5'; //Five
|
||||
case 6:
|
||||
return '6'; //Six
|
||||
case 7:
|
||||
return '7'; //Seven
|
||||
case 8:
|
||||
return '8'; //Eight
|
||||
case 9:
|
||||
return '9'; //Nine
|
||||
case 10:
|
||||
return 'X'; //Dec
|
||||
case 11:
|
||||
return 'E'; //El
|
||||
}
|
||||
|
||||
return 'Q';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package tconstruct.util;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.ICrashCallable;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import tconstruct.TConstruct;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class EnvironmentChecks
|
||||
{
|
||||
|
||||
private EnvironmentChecks()
|
||||
{
|
||||
} // Singleton
|
||||
|
||||
/**
|
||||
* Checks for conflicting stuff in environment; adds callable to any crash logs if so.
|
||||
* Note: This code adds additional data to crashlogs. It does not trigger any crashes.
|
||||
*/
|
||||
public static void verifyEnvironmentSanity ()
|
||||
{
|
||||
List<String> modIds = new ArrayList<String>();
|
||||
|
||||
if (Loader.isModLoaded("gregtech_addon"))
|
||||
{
|
||||
TConstruct.logger.severe("[Environment Checks] Gelatinous iceberg dead ahead! Entering Greggy waters! Abandon hope all ye who enter here! (No, seriously, we don't support GT. Don't report any issues. Thanks.)");
|
||||
TConstruct.logger.severe("[Environment Checks] A NOTE TO THE USER: Gregtech has been known to crash the game with Metallurgy and for certain specific 'banished' players.");
|
||||
TConstruct.logger.severe("[Environment Checks] For this reason, the TCon dev team urge you to seek your tedium fix from someone else, as Greg disobeys");
|
||||
TConstruct.logger.severe("[Environment Checks] the basic tenets of good modders conduct. We log this message rather than sabotage. We'd hope he'd do the same.");
|
||||
TConstruct.logger.severe("[Environment Checks] In the meantime, we recommend not playing anything but IC2 alongside Gregtech. ~ Sunstrike");
|
||||
TConstruct.logger.severe("[Environment Checks] GT Appendum I: And now he's going after Forge Mod Loader too...");
|
||||
TConstruct.logger.severe("[Environment Checks] http://forum.industrial-craft.net/index.php?page=Thread&postID=138551#post138551 ~ SlimeKnights");
|
||||
modIds.add("gregtech_addon");
|
||||
}
|
||||
|
||||
if (FMLCommonHandler.instance().getSide() == Side.CLIENT && FMLClientHandler.instance().hasOptifine() || Loader.isModLoaded("optifine"))
|
||||
{
|
||||
TConstruct.logger.severe("[Environment Checks] Optifine detected. This is a Bad Thing(tm) and can crash Minecraft due to an Optifine bug during TCon armor renders!");
|
||||
modIds.add("optifine");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Class cl = Class.forName("org.bukkit.Bukkit");
|
||||
if (cl != null)
|
||||
{
|
||||
TConstruct.logger.severe("[Environment Checks] Bukkit implementation detected. This may be crashy. Bukkit implementations include Craftbukkit and MCPC+.");
|
||||
modIds.add("bukkit");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// No Bukkit in environment.
|
||||
}
|
||||
|
||||
if (modIds.size() == 0)
|
||||
{
|
||||
ICrashCallable callable = new CallableSuppConfig();
|
||||
FMLCommonHandler.instance().registerCrashCallable(callable);
|
||||
}
|
||||
else
|
||||
{
|
||||
ICrashCallable callable = new CallableUnsuppConfig(modIds);
|
||||
FMLCommonHandler.instance().registerCrashCallable(callable);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
package tconstruct.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.enchantment.EnchantmentProtection;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class MiningExplosion extends Explosion
|
||||
{
|
||||
World world;
|
||||
private Random random = new Random();
|
||||
private int field_77289_h = 16;
|
||||
private Map field_77288_k = new HashMap();
|
||||
|
||||
public MiningExplosion(World par1World, Entity par2Entity, double par3, double par5, double par7, float par9)
|
||||
{
|
||||
super(par1World, par2Entity, par3, par5, par7, par9);
|
||||
world = par1World;
|
||||
}
|
||||
|
||||
public void doExplosionA ()
|
||||
{
|
||||
float f = this.explosionSize;
|
||||
HashSet hashset = new HashSet();
|
||||
int i;
|
||||
int j;
|
||||
int k;
|
||||
double d0;
|
||||
double d1;
|
||||
double d2;
|
||||
|
||||
for (i = 0; i < this.field_77289_h; ++i)
|
||||
{
|
||||
for (j = 0; j < this.field_77289_h; ++j)
|
||||
{
|
||||
for (k = 0; k < this.field_77289_h; ++k)
|
||||
{
|
||||
if (i == 0 || i == this.field_77289_h - 1 || j == 0 || j == this.field_77289_h - 1 || k == 0 || k == this.field_77289_h - 1)
|
||||
{
|
||||
double d3 = (double) ((float) i / ((float) this.field_77289_h - 1.0F) * 2.0F - 1.0F);
|
||||
double d4 = (double) ((float) j / ((float) this.field_77289_h - 1.0F) * 2.0F - 1.0F);
|
||||
double d5 = (double) ((float) k / ((float) this.field_77289_h - 1.0F) * 2.0F - 1.0F);
|
||||
double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
|
||||
d3 /= d6;
|
||||
d4 /= d6;
|
||||
d5 /= d6;
|
||||
float f1 = this.explosionSize * (0.7F + this.world.rand.nextFloat() * 0.6F);
|
||||
d0 = this.explosionX;
|
||||
d1 = this.explosionY;
|
||||
d2 = this.explosionZ;
|
||||
|
||||
for (float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F)
|
||||
{
|
||||
int l = MathHelper.floor_double(d0);
|
||||
int i1 = MathHelper.floor_double(d1);
|
||||
int j1 = MathHelper.floor_double(d2);
|
||||
int k1 = this.world.getBlockId(l, i1, j1);
|
||||
|
||||
if (k1 > 0)
|
||||
{
|
||||
Block block = Block.blocksList[k1];
|
||||
float f3 = this.exploder != null ? this.exploder.getBlockExplosionResistance(this, this.world, l, i1, j1, block) : block.getExplosionResistance(this.exploder, world,
|
||||
l, i1, j1, explosionX, explosionY, explosionZ);
|
||||
f1 -= (f3 + 0.8F) * f2 * 0.25f;
|
||||
}
|
||||
|
||||
if (f1 > 0.0F && (this.exploder == null || this.exploder.shouldExplodeBlock(this, this.world, l, i1, j1, k1, f1)))
|
||||
{
|
||||
hashset.add(new ChunkPosition(l, i1, j1));
|
||||
}
|
||||
|
||||
d0 += d3 * (double) f2;
|
||||
d1 += d4 * (double) f2;
|
||||
d2 += d5 * (double) f2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.affectedBlockPositions.addAll(hashset);
|
||||
this.explosionSize *= 2.0F;
|
||||
i = MathHelper.floor_double(this.explosionX - (double) this.explosionSize - 1.0D);
|
||||
j = MathHelper.floor_double(this.explosionX + (double) this.explosionSize + 1.0D);
|
||||
k = MathHelper.floor_double(this.explosionY - (double) this.explosionSize - 1.0D);
|
||||
int l1 = MathHelper.floor_double(this.explosionY + (double) this.explosionSize + 1.0D);
|
||||
int i2 = MathHelper.floor_double(this.explosionZ - (double) this.explosionSize - 1.0D);
|
||||
int j2 = MathHelper.floor_double(this.explosionZ + (double) this.explosionSize + 1.0D);
|
||||
List list = this.world.getEntitiesWithinAABBExcludingEntity(this.exploder, AxisAlignedBB.getAABBPool().getAABB((double) i, (double) k, (double) i2, (double) j, (double) l1, (double) j2));
|
||||
Vec3 vec3 = this.world.getWorldVec3Pool().getVecFromPool(this.explosionX, this.explosionY, this.explosionZ);
|
||||
|
||||
for (int k2 = 0; k2 < list.size(); ++k2)
|
||||
{
|
||||
Entity entity = (Entity) list.get(k2);
|
||||
double d7 = entity.getDistance(this.explosionX, this.explosionY, this.explosionZ) / (double) this.explosionSize;
|
||||
|
||||
if (d7 <= 1.0D)
|
||||
{
|
||||
d0 = entity.posX - this.explosionX;
|
||||
d1 = entity.posY + (double) entity.getEyeHeight() - this.explosionY;
|
||||
d2 = entity.posZ - this.explosionZ;
|
||||
double d8 = (double) MathHelper.sqrt_double(d0 * d0 + d1 * d1 + d2 * d2);
|
||||
|
||||
if (d8 != 0.0D)
|
||||
{
|
||||
d0 /= d8;
|
||||
d1 /= d8;
|
||||
d2 /= d8;
|
||||
double d9 = (double) this.world.getBlockDensity(vec3, entity.boundingBox);
|
||||
double d10 = (1.0D - d7) * d9;
|
||||
if (!(entity instanceof EntityItem))
|
||||
entity.attackEntityFrom(DamageSource.setExplosionSource(this), (float) ((int) ((d10 * d10 + d10) / 2.0D * 8.0D * (double) this.explosionSize + 1.0D)));
|
||||
double d11 = EnchantmentProtection.func_92092_a(entity, d10);
|
||||
entity.motionX += d0 * d11;
|
||||
entity.motionY += d1 * d11;
|
||||
entity.motionZ += d2 * d11;
|
||||
|
||||
if (entity instanceof EntityPlayer)
|
||||
{
|
||||
this.field_77288_k.put((EntityPlayer) entity, this.world.getWorldVec3Pool().getVecFromPool(d0 * d10, d1 * d10, d2 * d10));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.explosionSize = f;
|
||||
}
|
||||
|
||||
public void doExplosionB (boolean par1)
|
||||
{
|
||||
this.world.playSoundEffect(this.explosionX, this.explosionY, this.explosionZ, "random.explode", 4.0F, (1.0F + (this.world.rand.nextFloat() - this.world.rand.nextFloat()) * 0.2F) * 0.7F);
|
||||
|
||||
if (this.explosionSize >= 2.0F && this.isSmoking)
|
||||
{
|
||||
this.world.spawnParticle("hugeexplosion", this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.world.spawnParticle("largeexplode", this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D);
|
||||
}
|
||||
|
||||
Iterator iterator;
|
||||
ChunkPosition chunkposition;
|
||||
int i;
|
||||
int j;
|
||||
int k;
|
||||
int l;
|
||||
|
||||
if (this.isSmoking)
|
||||
{
|
||||
iterator = this.affectedBlockPositions.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
chunkposition = (ChunkPosition) iterator.next();
|
||||
i = chunkposition.x;
|
||||
j = chunkposition.y;
|
||||
k = chunkposition.z;
|
||||
l = this.world.getBlockId(i, j, k);
|
||||
|
||||
if (par1)
|
||||
{
|
||||
double d0 = (double) ((float) i + this.world.rand.nextFloat());
|
||||
double d1 = (double) ((float) j + this.world.rand.nextFloat());
|
||||
double d2 = (double) ((float) k + this.world.rand.nextFloat());
|
||||
double d3 = d0 - this.explosionX;
|
||||
double d4 = d1 - this.explosionY;
|
||||
double d5 = d2 - this.explosionZ;
|
||||
double d6 = (double) MathHelper.sqrt_double(d3 * d3 + d4 * d4 + d5 * d5);
|
||||
d3 /= d6;
|
||||
d4 /= d6;
|
||||
d5 /= d6;
|
||||
double d7 = 0.5D / (d6 / (double) this.explosionSize + 0.1D);
|
||||
d7 *= (double) (this.world.rand.nextFloat() * this.world.rand.nextFloat() + 0.3F);
|
||||
d3 *= d7;
|
||||
d4 *= d7;
|
||||
d5 *= d7;
|
||||
this.world.spawnParticle("explode", (d0 + this.explosionX * 1.0D) / 2.0D, (d1 + this.explosionY * 1.0D) / 2.0D, (d2 + this.explosionZ * 1.0D) / 2.0D, d3, d4, d5);
|
||||
this.world.spawnParticle("smoke", d0, d1, d2, d3, d4, d5);
|
||||
}
|
||||
|
||||
if (l > 0)
|
||||
{
|
||||
Block block = Block.blocksList[l];
|
||||
|
||||
if (block.canDropFromExplosion(this))
|
||||
{
|
||||
block.dropBlockAsItemWithChance(this.world, i, j, k, this.world.getBlockMetadata(i, j, k), 1.0F, 0);
|
||||
}
|
||||
|
||||
block.onBlockExploded(this.world, i, j, k, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isFlaming)
|
||||
{
|
||||
iterator = this.affectedBlockPositions.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
chunkposition = (ChunkPosition) iterator.next();
|
||||
i = chunkposition.x;
|
||||
j = chunkposition.y;
|
||||
k = chunkposition.z;
|
||||
l = this.world.getBlockId(i, j, k);
|
||||
int i1 = this.world.getBlockId(i, j - 1, k);
|
||||
|
||||
if (l == 0 && Block.opaqueCubeLookup[i1] && this.random.nextInt(3) == 0)
|
||||
{
|
||||
this.world.setBlock(i, j, k, Block.fire.blockID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package tconstruct.util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.ShapedRecipes;
|
||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
||||
|
||||
public class RecipeRemover
|
||||
{
|
||||
public static void removeShapedRecipes (List<ItemStack> removelist)
|
||||
{
|
||||
for (ItemStack stack : removelist)
|
||||
removeShapedRecipe(stack);
|
||||
}
|
||||
|
||||
public static void removeAnyRecipe (ItemStack resultItem)
|
||||
{
|
||||
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (int i = 0; i < recipes.size(); i++)
|
||||
{
|
||||
IRecipe tmpRecipe = recipes.get(i);
|
||||
ItemStack recipeResult = tmpRecipe.getRecipeOutput();
|
||||
if (ItemStack.areItemStacksEqual(resultItem, recipeResult))
|
||||
{
|
||||
recipes.remove(i--);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeShapedRecipe (ItemStack resultItem)
|
||||
{
|
||||
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (int i = 0; i < recipes.size(); i++)
|
||||
{
|
||||
IRecipe tmpRecipe = recipes.get(i);
|
||||
if (tmpRecipe instanceof ShapedRecipes)
|
||||
{
|
||||
ShapedRecipes recipe = (ShapedRecipes) tmpRecipe;
|
||||
ItemStack recipeResult = recipe.getRecipeOutput();
|
||||
|
||||
if (ItemStack.areItemStacksEqual(resultItem, recipeResult))
|
||||
{
|
||||
recipes.remove(i--);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeShapelessRecipe (ItemStack resultItem)
|
||||
{
|
||||
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (int i = 0; i < recipes.size(); i++)
|
||||
{
|
||||
IRecipe tmpRecipe = recipes.get(i);
|
||||
if (tmpRecipe instanceof ShapelessRecipes)
|
||||
{
|
||||
ShapelessRecipes recipe = (ShapelessRecipes) tmpRecipe;
|
||||
ItemStack recipeResult = recipe.getRecipeOutput();
|
||||
|
||||
if (ItemStack.areItemStacksEqual(resultItem, recipeResult))
|
||||
{
|
||||
recipes.remove(i--);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package tconstruct.util;
|
||||
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class SmelteryDamageSource extends DamageSource
|
||||
{
|
||||
public SmelteryDamageSource()
|
||||
{
|
||||
super("smeltery");
|
||||
}
|
||||
|
||||
public String getDeathMessage (EntityLiving par1EntityLiving)
|
||||
{
|
||||
String type = "";
|
||||
switch (AbilityHelper.random.nextInt(4))
|
||||
{
|
||||
case 0:
|
||||
type = "one.";
|
||||
break;
|
||||
case 1:
|
||||
type = "two.";
|
||||
break;
|
||||
case 2:
|
||||
type = "three.";
|
||||
break;
|
||||
case 3:
|
||||
type = "four.";
|
||||
break;
|
||||
}
|
||||
EntityLivingBase entityliving1 = par1EntityLiving.func_94060_bK();
|
||||
String s = "death." + type + this.damageType;
|
||||
String s1 = s + ".player";
|
||||
return entityliving1 != null && StatCollector.func_94522_b(s1) ? StatCollector.translateToLocalFormatted(s1,
|
||||
new Object[] { par1EntityLiving.getTranslatedEntityName(), entityliving1.getTranslatedEntityName() }) : StatCollector.translateToLocalFormatted(s,
|
||||
new Object[] { par1EntityLiving.getTranslatedEntityName() });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package tconstruct.util;
|
||||
|
||||
import tconstruct.achievements.TAchievements;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.util.player.TPlayerStats;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import cpw.mods.fml.common.ICraftingHandler;
|
||||
|
||||
public class TCraftingHandler implements ICraftingHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onCrafting (EntityPlayer player, ItemStack item, IInventory craftMatrix)
|
||||
{
|
||||
int itemID = item.getItem().itemID;
|
||||
if (!player.worldObj.isRemote)
|
||||
{
|
||||
if (itemID == TContent.toolStationWood.blockID)
|
||||
{
|
||||
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username);
|
||||
NBTTagCompound tags = player.getEntityData().getCompoundTag("TConstruct");
|
||||
if (!tags.getBoolean("materialManual") || !stats.materialManual)
|
||||
{
|
||||
stats.materialManual = true;
|
||||
tags.setBoolean("materialManual", true);
|
||||
AbilityHelper.spawnItemAtPlayer(player, new ItemStack(TContent.manualBook, 1, 1));
|
||||
}
|
||||
}
|
||||
if (itemID == TContent.smeltery.blockID || itemID == TContent.lavaTank.blockID)
|
||||
{
|
||||
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username);
|
||||
NBTTagCompound tags = player.getEntityData().getCompoundTag("TConstruct");
|
||||
if (!tags.getBoolean("smelteryManual") || !stats.smelteryManual)
|
||||
{
|
||||
stats.smelteryManual = true;
|
||||
tags.setBoolean("smelteryManual", true);
|
||||
AbilityHelper.spawnItemAtPlayer(player, new ItemStack(TContent.manualBook, 1, 2));
|
||||
}
|
||||
player.addStat(TAchievements.achievements.get("tconstruct.smelteryMaker"), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSmelting (EntityPlayer player, ItemStack item)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package tconstruct.util;
|
||||
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
||||
import net.minecraft.dispenser.IBlockSource;
|
||||
import net.minecraft.dispenser.IPosition;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.entity.projectile.ArrowEntity;
|
||||
|
||||
public class TDispenserBehaviorArrow extends BehaviorDefaultDispenseItem
|
||||
{
|
||||
|
||||
public ItemStack dispenseStack (IBlockSource dispenser, ItemStack stack)
|
||||
{
|
||||
World world = dispenser.getWorld();
|
||||
IPosition iposition = BlockDispenser.getIPositionFromBlockSource(dispenser);
|
||||
EnumFacing enumfacing = BlockDispenser.getFacing(dispenser.getBlockMetadata());
|
||||
|
||||
ItemStack arrowItem = stack.splitStack(1);
|
||||
|
||||
ArrowEntity projectile = new ArrowEntity(world, iposition.getX(), iposition.getY(), iposition.getZ(), arrowItem);
|
||||
projectile.canBePickedUp = 1;
|
||||
projectile.setThrowableHeading((double) enumfacing.getFrontOffsetX(), (double) ((float) enumfacing.getFrontOffsetY() + 0.1F), (double) enumfacing.getFrontOffsetZ(), this.func_82500_b(),
|
||||
this.func_82498_a());
|
||||
world.spawnEntityInWorld(projectile);
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
protected void playDispenseSound (IBlockSource dispenser)
|
||||
{
|
||||
dispenser.getWorld().playAuxSFX(1002, dispenser.getXInt(), dispenser.getYInt(), dispenser.getZInt(), 0);
|
||||
}
|
||||
|
||||
protected float func_82498_a ()
|
||||
{
|
||||
return 6.0F;
|
||||
}
|
||||
|
||||
protected float func_82500_b ()
|
||||
{
|
||||
return 1.1F;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package tconstruct.util;
|
||||
|
||||
import tconstruct.items.TitleIcon;
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
||||
import net.minecraft.dispenser.IBlockSource;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public class TDispenserBehaviorSpawnEgg extends BehaviorDefaultDispenseItem
|
||||
{
|
||||
/**
|
||||
* Dispense the specified stack, play the dispense sound and spawn particles.
|
||||
*/
|
||||
public ItemStack dispenseStack (IBlockSource par1IBlockSource, ItemStack par2ItemStack)
|
||||
{
|
||||
EnumFacing enumfacing = BlockDispenser.getFacing(par1IBlockSource.getBlockMetadata());
|
||||
double d0 = par1IBlockSource.getX() + (double) enumfacing.getFrontOffsetX();
|
||||
double d1 = (double) ((float) par1IBlockSource.getYInt() + 0.2F);
|
||||
double d2 = par1IBlockSource.getZ() + (double) enumfacing.getFrontOffsetZ();
|
||||
EntityLiving entity = TitleIcon.activateSpawnEgg(par2ItemStack, par1IBlockSource.getWorld(), d0, d1, d2, 0);
|
||||
|
||||
if (par2ItemStack.hasDisplayName())
|
||||
{
|
||||
((EntityLiving) entity).setCustomNameTag(par2ItemStack.getDisplayName());
|
||||
}
|
||||
|
||||
par2ItemStack.splitStack(1);
|
||||
return par2ItemStack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,632 @@
|
||||
package tconstruct.util;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.EntityLivingData;
|
||||
import net.minecraft.entity.boss.EntityWither;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.item.EntityXPOrb;
|
||||
import net.minecraft.entity.monster.EntityCreeper;
|
||||
import net.minecraft.entity.monster.EntityGhast;
|
||||
import net.minecraft.entity.monster.EntitySkeleton;
|
||||
import net.minecraft.entity.monster.EntitySpider;
|
||||
import net.minecraft.entity.monster.EntityZombie;
|
||||
import net.minecraft.entity.monster.IMob;
|
||||
import net.minecraft.entity.passive.EntityChicken;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemFood;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.EnumMovingObjectType;
|
||||
import net.minecraft.world.GameRules;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.Event;
|
||||
import net.minecraftforge.event.Event.Result;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingSpawnEvent;
|
||||
import net.minecraftforge.event.entity.player.BonemealEvent;
|
||||
import net.minecraftforge.event.entity.player.FillBucketEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
|
||||
import net.minecraftforge.oredict.OreDictionary.OreRegisterEvent;
|
||||
|
||||
import tconstruct.*;
|
||||
import tconstruct.achievements.*;
|
||||
import tconstruct.blocks.*;
|
||||
import tconstruct.common.*;
|
||||
import tconstruct.items.tools.*;
|
||||
import tconstruct.library.*;
|
||||
import tconstruct.library.crafting.*;
|
||||
import tconstruct.library.event.*;
|
||||
import tconstruct.library.tools.*;
|
||||
import tconstruct.modifiers.*;
|
||||
import tconstruct.util.config.*;
|
||||
import tconstruct.util.player.*;
|
||||
|
||||
public class TEventHandler
|
||||
{
|
||||
Random random = new Random();
|
||||
private Object evt;
|
||||
|
||||
/* Crafting */
|
||||
@ForgeSubscribe
|
||||
public void craftTool (ToolCraftEvent.NormalTool event)
|
||||
{
|
||||
NBTTagCompound toolTag = event.toolTag.getCompoundTag("InfiTool");
|
||||
if (PHConstruct.denyMattock && event.tool == TContent.mattock)
|
||||
{
|
||||
int head = toolTag.getInteger("Head");
|
||||
int handle = toolTag.getInteger("Handle");
|
||||
int accessory = toolTag.getInteger("Accessory");
|
||||
|
||||
if (!allowCrafting(head, handle, accessory))
|
||||
{
|
||||
event.setResult(Result.DENY);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int thaum = 0;
|
||||
if (toolTag.getInteger("Head") == 31)
|
||||
thaum++;
|
||||
if (toolTag.getInteger("Handle") == 31)
|
||||
thaum++;
|
||||
if (toolTag.getInteger("Accessory") == 31)
|
||||
thaum++;
|
||||
if (toolTag.getInteger("Extra") == 31)
|
||||
thaum++;
|
||||
|
||||
if ((thaum >= 3) || (!toolTag.hasKey("Accessory") && thaum >= 2))
|
||||
{
|
||||
int modifiers = toolTag.getInteger("Modifiers");
|
||||
modifiers += 2;
|
||||
toolTag.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
else if (thaum >= 1)
|
||||
{
|
||||
int modifiers = toolTag.getInteger("Modifiers");
|
||||
modifiers += 1;
|
||||
toolTag.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
|
||||
if (event.tool == TContent.shortbow)
|
||||
{
|
||||
BowMaterial top = TConstructRegistry.getBowMaterial(toolTag.getInteger("Head"));
|
||||
BowMaterial bottom = TConstructRegistry.getBowMaterial(toolTag.getInteger("Accessory"));
|
||||
BowstringMaterial string = (BowstringMaterial) TConstructRegistry.getCustomMaterial(toolTag.getInteger("Handle"), BowstringMaterial.class);
|
||||
|
||||
if (top != null && bottom != null && string != null)
|
||||
{
|
||||
if (toolTag.getInteger("Handle") == 1)
|
||||
{
|
||||
int modifiers = toolTag.getInteger("Modifiers");
|
||||
modifiers += 1;
|
||||
toolTag.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
|
||||
int durability = (int) ((top.durability + bottom.durability) / 2 * string.durabilityModifier);
|
||||
toolTag.setInteger("TotalDurability", durability);
|
||||
toolTag.setInteger("BaseDurability", durability);
|
||||
|
||||
int drawSpeed = (int) ((top.drawspeed + bottom.drawspeed) / 2 * string.drawspeedModifier);
|
||||
toolTag.setInteger("DrawSpeed", drawSpeed);
|
||||
toolTag.setInteger("BaseDrawSpeed", drawSpeed);
|
||||
|
||||
float flightSpeed = (top.flightSpeedMax + bottom.flightSpeedMax) / 2f * string.flightSpeedModifier;
|
||||
toolTag.setFloat("FlightSpeed", flightSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.tool == TContent.arrow)
|
||||
{
|
||||
ArrowMaterial head = TConstructRegistry.getArrowMaterial(toolTag.getInteger("Head"));
|
||||
ArrowMaterial shaft = TConstructRegistry.getArrowMaterial(toolTag.getInteger("Handle"));
|
||||
FletchingMaterial fletching = (FletchingMaterial) TConstructRegistry.getCustomMaterial(toolTag.getInteger("Accessory"), FletchingMaterial.class);
|
||||
|
||||
if (head != null && shaft != null && fletching != null)
|
||||
{
|
||||
float mass = head.mass / 5f + shaft.mass + fletching.mass;
|
||||
float shatter = (head.breakChance + shaft.breakChance + fletching.breakChance) / 4f;
|
||||
float accuracy = (head.accuracy + shaft.accuracy + fletching.accuracy) / 3;
|
||||
|
||||
ItemStack arrow = new ItemStack(event.tool, 4);
|
||||
toolTag.setInteger("TotalDurability", 0);
|
||||
toolTag.setFloat("Mass", mass);
|
||||
toolTag.setFloat("BreakChance", shatter);
|
||||
toolTag.setFloat("Accuracy", accuracy);
|
||||
toolTag.setInteger("Unbreaking", 10);
|
||||
arrow.setTagCompound(event.toolTag);
|
||||
event.overrideResult(arrow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean allowCrafting (int head, int handle, int accessory)
|
||||
{
|
||||
int[] nonMetals = { 0, 1, 3, 4, 5, 6, 7, 8, 9, 17 };
|
||||
for (int i = 0; i < nonMetals.length; i++)
|
||||
{
|
||||
if (head == nonMetals[i] || handle == nonMetals[i] || accessory == nonMetals[i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void craftPart (PartBuilderEvent.NormalPart event)
|
||||
{
|
||||
if (event.pattern.getItem() == TContent.woodPattern && event.pattern.getItemDamage() == 23)
|
||||
{
|
||||
ItemStack result = craftBowString(event.material);
|
||||
if (result != null)
|
||||
{
|
||||
event.overrideResult(new ItemStack[] { result, null });
|
||||
}
|
||||
}
|
||||
|
||||
if (event.pattern.getItem() == TContent.woodPattern && event.pattern.getItemDamage() == 24)
|
||||
{
|
||||
ItemStack result = craftFletching(event.material);
|
||||
if (result != null)
|
||||
{
|
||||
event.overrideResult(new ItemStack[] { result, null });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack craftBowString (ItemStack stack)
|
||||
{
|
||||
if (stack.stackSize < 3)
|
||||
return null;
|
||||
|
||||
BowstringMaterial mat = (BowstringMaterial) TConstructRegistry.getCustomMaterial(stack, BowstringMaterial.class);
|
||||
if (mat != null)
|
||||
return mat.craftingItem.copy();
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ItemStack craftFletching (ItemStack stack)
|
||||
{
|
||||
if (matchesLeaves(stack))
|
||||
{
|
||||
FletchingMaterial leaves = (FletchingMaterial) TConstructRegistry.getCustomMaterial(new ItemStack(Block.leaves), FletchingMaterial.class);
|
||||
return leaves.craftingItem.copy();
|
||||
}
|
||||
|
||||
FletchingMaterial mat = (FletchingMaterial) TConstructRegistry.getCustomMaterial(stack, FletchingMaterial.class);
|
||||
if (mat != null)
|
||||
return mat.craftingItem.copy();
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean matchesLeaves (ItemStack stack)
|
||||
{
|
||||
if (stack.itemID >= 4096)
|
||||
return false;
|
||||
|
||||
Block block = Block.blocksList[stack.itemID];
|
||||
if (block != null)
|
||||
{
|
||||
if (block.isLeaves(null, 0, 0, 0))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Damage */
|
||||
@ForgeSubscribe
|
||||
public void onHurt (LivingHurtEvent event)
|
||||
{
|
||||
//System.out.println("Damage: "+event.ammount);
|
||||
if (event.entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
//Cutlass
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if (stack != null && stack.getItem() == TContent.cutlass && player.isUsingItem())
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 3 * 20, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Drops */
|
||||
@ForgeSubscribe
|
||||
public void onLivingDrop (LivingDropsEvent event)
|
||||
{
|
||||
if (event.entityLiving == null)
|
||||
return;
|
||||
|
||||
if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) event.source.getEntity();
|
||||
if (player.getHeldItem() != null && player.getHeldItem().getItem() instanceof FryingPan)
|
||||
{
|
||||
for (int i = 0; i < event.drops.size(); i++)
|
||||
{
|
||||
ItemStack is = event.drops.get(i).getEntityItem();
|
||||
if (FurnaceRecipes.smelting().getSmeltingResult(is) != null && FurnaceRecipes.smelting().getSmeltingResult(is).getItem() instanceof ItemFood)
|
||||
{
|
||||
NBTTagCompound stackCompound = is.getTagCompound();
|
||||
if (stackCompound == null)
|
||||
{
|
||||
stackCompound = new NBTTagCompound();
|
||||
}
|
||||
stackCompound.setBoolean("frypanKill", true);
|
||||
is.setTagCompound(stackCompound);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (random.nextInt(500) == 0 && event.entityLiving instanceof IMob)
|
||||
{
|
||||
ItemStack dropStack = new ItemStack(TContent.heartCanister, 1, 1);
|
||||
EntityItem entityitem = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, dropStack);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
event.drops.add(entityitem);
|
||||
}
|
||||
|
||||
if (event.entityLiving instanceof EntityWither && random.nextInt(5) == 0)
|
||||
{
|
||||
ItemStack dropStack = new ItemStack(TContent.heartCanister, 1, 1);
|
||||
EntityItem entityitem = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, dropStack);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
event.drops.add(entityitem);
|
||||
}
|
||||
|
||||
//if (event.entityLiving.worldObj.getGameRules().getGameRuleBooleanValue("doMobLoot"))
|
||||
//{
|
||||
if (!event.entityLiving.isChild())
|
||||
{
|
||||
/*if (event.entityLiving.getClass() == EntityCow.class)
|
||||
{
|
||||
int amount = random.nextInt(3) + random.nextInt(1 + event.lootingLevel) + random.nextInt(3) + random.nextInt(1 + event.lootingLevel) + 1;
|
||||
|
||||
for (int iter = 0; iter < amount; ++iter)
|
||||
{
|
||||
addDrops(event, new ItemStack(Item.leather, 1));
|
||||
}
|
||||
}*/
|
||||
|
||||
if (event.entityLiving.getClass() == EntityChicken.class)
|
||||
{
|
||||
int amount = random.nextInt(3) + random.nextInt(1 + event.lootingLevel) + random.nextInt(3) + random.nextInt(1 + event.lootingLevel) + 1;
|
||||
|
||||
for (int iter = 0; iter < amount; ++iter)
|
||||
{
|
||||
addDrops(event, new ItemStack(Item.feather, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.recentlyHit)
|
||||
{
|
||||
if (event.entityLiving.getClass() == EntitySkeleton.class)
|
||||
{
|
||||
EntitySkeleton enemy = (EntitySkeleton) event.entityLiving;
|
||||
|
||||
if (event.source.damageType.equals("player"))
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) event.source.getEntity();
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore)
|
||||
{
|
||||
int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
|
||||
if (stack.getItem() == TContent.cleaver)
|
||||
beheading += 2;
|
||||
if (beheading > 0 && random.nextInt(100) < beheading * 10)
|
||||
{
|
||||
addDrops(event, new ItemStack(Item.skull.itemID, 1, enemy.getSkeletonType()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (enemy.getSkeletonType() == 1 && random.nextInt(Math.max(1, 5 - event.lootingLevel)) == 0)
|
||||
{
|
||||
addDrops(event, new ItemStack(TContent.materials, 1, 8));
|
||||
}
|
||||
}
|
||||
|
||||
if (event.entityLiving.getClass() == EntityZombie.class)
|
||||
{
|
||||
EntityZombie enemy = (EntityZombie) event.entityLiving;
|
||||
|
||||
if (event.source.damageType.equals("player"))
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) event.source.getEntity();
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
|
||||
if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore)
|
||||
{
|
||||
int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
|
||||
if (stack.getItem() == TContent.cleaver)
|
||||
beheading += 2;
|
||||
if (beheading > 0 && random.nextInt(100) < beheading * 10)
|
||||
{
|
||||
addDrops(event, new ItemStack(Item.skull.itemID, 1, 2));
|
||||
}
|
||||
}
|
||||
/*if (stack.getItem() == TContent.breakerBlade && random.nextInt(100) < 10) //Swap out for real beheading
|
||||
{
|
||||
addDrops(event, new ItemStack(Item.skull.itemID, 1, 2));
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
if (event.entityLiving.getClass() == EntityCreeper.class)
|
||||
{
|
||||
EntityCreeper enemy = (EntityCreeper) event.entityLiving;
|
||||
|
||||
if (event.source.damageType.equals("player"))
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) event.source.getEntity();
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore)
|
||||
{
|
||||
int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
|
||||
if (stack.getItem() == TContent.cleaver)
|
||||
beheading += 2;
|
||||
if (beheading > 0 && random.nextInt(100) < beheading * 5)
|
||||
{
|
||||
addDrops(event, new ItemStack(Item.skull.itemID, 1, 4));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.entityLiving.getClass() == EntityGhast.class)
|
||||
{
|
||||
if (PHConstruct.uhcGhastDrops)
|
||||
{
|
||||
for (EntityItem o : event.drops)
|
||||
{
|
||||
if (o.getEntityItem().itemID == Item.ghastTear.itemID)
|
||||
{
|
||||
o.setEntityItemStack(new ItemStack(Item.ingotGold, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
addDrops(event, new ItemStack(Item.ghastTear, 1));
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
if (event.entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
|
||||
if (PHConstruct.dropPlayerHeads)
|
||||
{
|
||||
ItemStack dropStack = new ItemStack(Item.skull.itemID, 1, 3);
|
||||
NBTTagCompound nametag = new NBTTagCompound();
|
||||
nametag.setString("SkullOwner", player.username);
|
||||
addDrops(event, dropStack);
|
||||
}
|
||||
|
||||
else if (event.source.damageType.equals("player"))
|
||||
{
|
||||
EntityPlayer source = (EntityPlayer) event.source.getEntity();
|
||||
ItemStack stack = source.getCurrentEquippedItem();
|
||||
if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore)
|
||||
{
|
||||
int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
|
||||
if (stack.getItem() == TContent.cleaver)
|
||||
beheading += 2;
|
||||
if (beheading > 0 && random.nextInt(100) < beheading * 50)
|
||||
{
|
||||
ItemStack dropStack = new ItemStack(Item.skull.itemID, 1, 3);
|
||||
NBTTagCompound nametag = new NBTTagCompound();
|
||||
nametag.setString("SkullOwner", player.username);
|
||||
addDrops(event, dropStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GameRules rules = player.worldObj.getGameRules(); //Player is null if this crashes
|
||||
if (rules == null || !rules.getGameRuleBooleanValue("keepInventory"))
|
||||
{
|
||||
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username);
|
||||
if (stats != null)
|
||||
{
|
||||
stats.armor.dropItems();
|
||||
stats.knapsack.dropItems();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onLivingDeath (LivingDeathEvent event)
|
||||
{
|
||||
Entity cause = event.source.getSourceOfDamage();
|
||||
if (cause != null && cause instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer murderer = (EntityPlayer) cause;
|
||||
ItemStack stack = murderer.getHeldItem();
|
||||
if (stack != null && stack.getItem() instanceof Weapon)
|
||||
{
|
||||
murderer.addStat(TAchievements.achievements.get("tconstruct.enemySlayer"), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void addDrops (LivingDropsEvent event, ItemStack dropStack)
|
||||
{
|
||||
EntityItem entityitem = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, dropStack);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
event.drops.add(entityitem);
|
||||
}
|
||||
|
||||
/*@ForgeSubscribe
|
||||
public void onLivingSpawn (EntityJoinWorldEvent event)
|
||||
{
|
||||
if (event.entity instanceof EntityXPOrb)
|
||||
{
|
||||
TConstruct.logger.info("Entity: " + event.entity);
|
||||
}
|
||||
}*/
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onLivingSpawn (LivingSpawnEvent.SpecialSpawn event)
|
||||
{
|
||||
EntityLivingBase living = event.entityLiving;
|
||||
if (living.getClass() == EntitySpider.class && random.nextInt(100) == 0)
|
||||
{
|
||||
EntityCreeper creeper = new EntityCreeper(living.worldObj);
|
||||
spawnEntityLiving(living.posX, living.posY + 1, living.posZ, creeper, living.worldObj);
|
||||
if (living.riddenByEntity != null)
|
||||
creeper.mountEntity(living.riddenByEntity);
|
||||
else
|
||||
creeper.mountEntity(living);
|
||||
|
||||
EntityXPOrb orb = new EntityXPOrb(living.worldObj, living.posX, living.posY, living.posZ, random.nextInt(20) + 20);
|
||||
orb.mountEntity(creeper);
|
||||
}
|
||||
}
|
||||
|
||||
public static void spawnEntityLiving (double x, double y, double z, EntityLiving entity, World world)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
entity.setPosition(x, y, z);
|
||||
entity.onSpawnWithEgg((EntityLivingData) null);
|
||||
world.spawnEntityInWorld(entity);
|
||||
}
|
||||
}
|
||||
|
||||
/* Bonemeal */
|
||||
|
||||
@ForgeSubscribe
|
||||
public void bonemealEvent (BonemealEvent event)
|
||||
{
|
||||
if (!event.world.isRemote)
|
||||
{
|
||||
if (event.ID == TContent.slimeSapling.blockID)
|
||||
{
|
||||
if (TContent.slimeSapling.boneFertilize(event.world, event.X, event.Y, event.Z, event.world.rand, event.entityPlayer))
|
||||
event.setResult(Event.Result.ALLOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Ore Dictionary */
|
||||
@ForgeSubscribe
|
||||
public void registerOre (OreRegisterEvent evt)
|
||||
{
|
||||
if (evt.Name == "crystalQuartz")
|
||||
{
|
||||
TContent.modAttack.addStackToMatchList(evt.Ore, 2);
|
||||
}
|
||||
|
||||
else if (evt.Name == "crystalCerusQuartz")
|
||||
{
|
||||
TContent.modAttack.addStackToMatchList(evt.Ore, 24);
|
||||
}
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void bucketFill (FillBucketEvent evt)
|
||||
{
|
||||
if (evt.current.getItem() == Item.bucketEmpty && evt.target.typeOfHit == EnumMovingObjectType.TILE)
|
||||
{
|
||||
int hitX = evt.target.blockX;
|
||||
int hitY = evt.target.blockY;
|
||||
int hitZ = evt.target.blockZ;
|
||||
|
||||
if (evt.entityPlayer != null && !evt.entityPlayer.canPlayerEdit(hitX, hitY, hitZ, evt.target.sideHit, evt.current))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int bID = evt.world.getBlockId(hitX, hitY, hitZ);
|
||||
for (int id = 0; id < TContent.fluidBlocks.length; id++)
|
||||
{
|
||||
if (bID == TContent.fluidBlocks[id].blockID)
|
||||
{
|
||||
if (evt.entityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
evt.world.setBlockToAir(hitX, hitY, hitZ);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TContent.fluidBlocks[id] instanceof LiquidMetalFinite)
|
||||
{
|
||||
evt.world.setBlockToAir(hitX, hitY, hitZ);
|
||||
/*int quanta = 0;
|
||||
for (int posX = -1; posX <= 1; posX++)
|
||||
{
|
||||
for (int posZ = -1; posZ <= 1; posZ++)
|
||||
{
|
||||
int localID = evt.world.getBlockId(hitX + posX, hitY, hitZ + posZ);
|
||||
if (localID == bID)
|
||||
{
|
||||
quanta += evt.world.getBlockMetadata(hitX + posX, hitY, hitZ + posZ) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (quanta >= 8)
|
||||
{
|
||||
while (quanta > 0)
|
||||
{
|
||||
for (int posX = -1; posX <= 1; posX++)
|
||||
{
|
||||
for (int posZ = -1; posZ <= 1; posZ++)
|
||||
{
|
||||
int localID = evt.world.getBlockId(hitX + posX, hitY, hitZ + posZ);
|
||||
if (localID == bID)
|
||||
{
|
||||
quanta -= 1;
|
||||
int meta = evt.world.getBlockMetadata(hitX + posX, hitY, hitZ + posZ);
|
||||
if (meta > 0)
|
||||
evt.world.setBlockMetadataWithNotify(hitX + posX, hitY, hitZ + posZ, meta - 1, 3);
|
||||
else
|
||||
evt.world.setBlockToAir(hitX + posX, hitY, hitZ + posZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{
|
||||
evt.world.setBlockToAir(hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
evt.setResult(Result.ALLOW);
|
||||
evt.result = new ItemStack(TContent.buckets, 1, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Player interact event - prevent breaking of tank air blocks in creative
|
||||
@ForgeSubscribe
|
||||
public void playerInteract (PlayerInteractEvent event)
|
||||
{
|
||||
if (event.action == Action.LEFT_CLICK_BLOCK)
|
||||
{
|
||||
Block block = Block.blocksList[event.entity.worldObj.getBlockId(event.x, event.y, event.z)];
|
||||
if (block instanceof TankAirBlock)
|
||||
{
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package tconstruct.util;
|
||||
|
||||
import net.minecraftforge.common.FakePlayer;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import tconstruct.achievements.TAchievements;
|
||||
import tconstruct.blocks.logic.ToolForgeLogic;
|
||||
import tconstruct.library.event.ToolCraftedEvent;
|
||||
import tconstruct.library.tools.*;
|
||||
|
||||
public class TEventHandlerAchievement {
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onToolCrafted(ToolCraftedEvent event){
|
||||
if(event.player != null && !(event.player instanceof FakePlayer)){
|
||||
event.player.addStat(TAchievements.achievements.get("tconstruct.tinkerer"), 1);
|
||||
|
||||
if(event.tool != null && event.tool.getItem() instanceof Weapon){
|
||||
event.player.addStat(TAchievements.achievements.get("tconstruct.preparedFight"), 1);
|
||||
}
|
||||
|
||||
if(event.inventory != null && event.inventory instanceof ToolForgeLogic && event.tool.getItem() instanceof ToolCore && ((ToolCore)event.tool.getItem()).durabilityTypeExtra() != 0){
|
||||
event.player.addStat(TAchievements.achievements.get("tconstruct.proTinkerer"), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package tconstruct.util.config;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
|
||||
public class AEImcHandler
|
||||
{
|
||||
private static List<String> spatialIOLogics = Arrays.asList("AdaptiveSmelteryLogic", "AdvancedDrawbridgeLogic", "AqueductLogic", "CastingBasinLogic", "CastingChannelLogic", "CastingTableLogic",
|
||||
"CraftingStationLogic", "DrawbridgeLogic", "DryingRackLogic", "EssenceExtractorLogic", "FaucetLogic", "FirestarterLogic", "FrypanLogic", "GolemPedestalLogic", "LavaTankLogic",
|
||||
"PartBuilderLogic", "PatternChestLogic", "RedwireLogic", "SmelteryDrainLogic", "SmelteryLogic", "StencilTableLogic", "TankAirLogic", "TileEntityLandmine", "ToolForgeLogic",
|
||||
"ToolStationLogic", "TowerFurnaceLogic", "MultiServantLogic");
|
||||
|
||||
public static void registerForSpatialIO ()
|
||||
{
|
||||
for (String s : spatialIOLogics)
|
||||
{
|
||||
FMLInterModComms.sendMessage("AppliedEnergistics", "movabletile", "tconstruct.blocks.logic." + s);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package tconstruct.util.config;
|
||||
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
import tconstruct.common.TContent;
|
||||
|
||||
public class BCImcHandler
|
||||
{
|
||||
public static void registerFacades ()
|
||||
{
|
||||
// Smeltery Blocks
|
||||
addFacade(TContent.smeltery.blockID, 2);
|
||||
for (int sc = 4; sc < 11; sc++)
|
||||
{
|
||||
addFacade(TContent.smeltery.blockID, sc);
|
||||
}
|
||||
// Multi Brick + Fancy
|
||||
for (int sc = 0; sc < 13; sc++)
|
||||
{
|
||||
addFacade(TContent.multiBrick.blockID, sc);
|
||||
}
|
||||
for (int sc = 0; sc < 16; sc++)
|
||||
{
|
||||
addFacade(TContent.multiBrickFancy.blockID, sc);
|
||||
}
|
||||
// Special Soil
|
||||
for (int sc = 0; sc < 6; sc++)
|
||||
{
|
||||
addFacade(TContent.craftedSoil.blockID, sc);
|
||||
}
|
||||
// Metal Storage
|
||||
for (int sc = 0; sc < 11; sc++)
|
||||
{
|
||||
addFacade(TContent.metalBlock.blockID, sc);
|
||||
}
|
||||
// Speed Block
|
||||
for (int sc = 0; sc < 7; sc++)
|
||||
{
|
||||
addFacade(TContent.speedBlock.blockID, sc);
|
||||
}
|
||||
// Hambone
|
||||
addFacade(TContent.meatBlock.blockID, 4);
|
||||
addFacade(TContent.meatBlock.blockID, 8);
|
||||
|
||||
// Slime Gel
|
||||
addFacade(TContent.slimeGel.blockID, 0);
|
||||
addFacade(TContent.slimeGel.blockID, 1);
|
||||
}
|
||||
|
||||
private static void addFacade (int blockId, int meta)
|
||||
{
|
||||
FMLInterModComms.sendMessage("BuildCraft|Transport", "add-facade", String.format("%d@%d", blockId, meta));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package tconstruct.util.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import tconstruct.TConstruct;
|
||||
|
||||
public class BOPConfig
|
||||
{
|
||||
public static void initProps (File location)
|
||||
{
|
||||
/* Here we will set up the config file for the mod
|
||||
* First: Create a folder inside the config folder
|
||||
* Second: Create the actual config file
|
||||
* Note: Configs are a pain, but absolutely necessary for every mod.
|
||||
*/
|
||||
|
||||
File newFile = new File(location + "/biomesoplenty/ids.cfg");
|
||||
if (newFile.exists())
|
||||
{
|
||||
|
||||
/* [Forge] Configuration class, used as config method */
|
||||
Configuration config = new Configuration(newFile);
|
||||
|
||||
/* Load the configuration file */
|
||||
config.load();
|
||||
|
||||
promisedLandDimensionID = config.get("dimension settings", "Promised Land Dimension ID", -200).getInt();
|
||||
TConstruct.logger.info("PL Dim ID: " + promisedLandDimensionID);
|
||||
}
|
||||
else
|
||||
{
|
||||
promisedLandDimensionID = -100;
|
||||
}
|
||||
}
|
||||
|
||||
public static int promisedLandDimensionID;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package tconstruct.util.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class DimensionBlacklist
|
||||
{
|
||||
public static ArrayList<Integer> blacklist = new ArrayList<Integer>();
|
||||
public static ArrayList<Integer> nopool = new ArrayList<Integer>();
|
||||
|
||||
public static void getbaddimensions ()
|
||||
{
|
||||
blacklist.add(1);
|
||||
if (TwilightForestConfig.twilightForestDimensionID != -100)
|
||||
{
|
||||
blacklist.add(TwilightForestConfig.twilightForestDimensionID);
|
||||
}
|
||||
if (PHConstruct.cfgDimBlackList.length > 0)
|
||||
{
|
||||
for (int numdim = 0; numdim < PHConstruct.cfgDimBlackList.length; numdim++)
|
||||
{
|
||||
blacklist.add(PHConstruct.cfgDimBlackList[numdim]);
|
||||
}
|
||||
}
|
||||
if (BOPConfig.promisedLandDimensionID != -100)
|
||||
{
|
||||
nopool.add(BOPConfig.promisedLandDimensionID);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isDimInBlacklist (int dim)
|
||||
{
|
||||
if (dim < 0)
|
||||
return false;
|
||||
if (dim == 0)
|
||||
return PHConstruct.slimeIslGenDim0;
|
||||
if (PHConstruct.slimeIslGenDim0Only && dim != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (int len = 0; len < blacklist.size(); len++)
|
||||
{
|
||||
if (blacklist.get(len) == dim)
|
||||
return false;
|
||||
//TConstruct.logger.info("diminblist +" + blacklist.get(len));
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public static boolean isDimNoPool (int dim)
|
||||
{
|
||||
for (int len = 0; len < nopool.size(); len++)
|
||||
{
|
||||
if (nopool.get(len) == dim)
|
||||
//TConstruct.logger.info("DimNoPool "+ nopool.get(len));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package tconstruct.util.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.common.TContent;
|
||||
|
||||
public class MystImcHandler
|
||||
{
|
||||
private static String[] FluidBlackList = new String[] { "invar.molten", "electrum.molten", "bronze.molten", "aluminumbrass.molten", "manyullyn.molten", "alumite.molten", "cobalt.molten",
|
||||
"moltenArdite", "ender", "steel.molten", "platinum.molten" };// = new String[]();
|
||||
private static ArrayList<String> additionalFluids = new ArrayList<String>();
|
||||
|
||||
public static void addFluidToBlacklist (String fluidName)
|
||||
{
|
||||
additionalFluids.add(fluidName);
|
||||
}
|
||||
|
||||
public static void blacklistFluids ()
|
||||
{
|
||||
for (String nm : additionalFluids)
|
||||
{
|
||||
// check if exists??
|
||||
SendFluidIMCBLMsg(nm);
|
||||
}
|
||||
for (String nm : FluidBlackList)
|
||||
{
|
||||
// check if exists??
|
||||
SendFluidIMCBLMsg(nm);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SendFluidIMCBLMsg (String FluidName)
|
||||
{
|
||||
NBTTagCompound NBTMsg = new NBTTagCompound();
|
||||
NBTMsg.setCompoundTag("fluidsymbol", new NBTTagCompound());
|
||||
NBTMsg.getCompoundTag("fluidsymbol").setFloat("rarity", 0.0F);
|
||||
NBTMsg.getCompoundTag("fluidsymbol").setFloat("grammarweight", 0.0F);
|
||||
NBTMsg.getCompoundTag("fluidsymbol").setFloat("instabilityPerBlock", 10000F);// renders creative symbol useless
|
||||
NBTMsg.getCompoundTag("fluidsymbol").setString("fluidname", FluidName);
|
||||
FMLInterModComms.sendMessage("Mystcraft", "fluidsymbol", NBTMsg);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,744 @@
|
||||
package tconstruct.util.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.Property;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
|
||||
public class PHConstruct
|
||||
{
|
||||
|
||||
public static void initProps (File location)
|
||||
{
|
||||
/* Here we will set up the config file for the mod
|
||||
* First: Create a folder inside the config folder
|
||||
* Second: Create the actual config file
|
||||
* Note: Configs are a pain, but absolutely necessary for every mod.
|
||||
*/
|
||||
File newFile = new File(location + "/TinkersWorkshop.txt");
|
||||
|
||||
/* Some basic debugging will go a long way */
|
||||
try
|
||||
{
|
||||
newFile.createNewFile();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
TConstruct.logger.severe("Could not create configuration file for TConstruct. Reason:");
|
||||
TConstruct.logger.severe(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
/* [Forge] Configuration class, used as config method */
|
||||
Configuration config = new Configuration(newFile);
|
||||
cfglocation = location;
|
||||
/* Load the configuration file */
|
||||
config.load();
|
||||
|
||||
/* Define the mod's IDs.
|
||||
* Avoid values below 4096 for items and in the 250-450 range for blocks
|
||||
*/
|
||||
|
||||
superfunWorld = config.get("Superfun", "All the world is Superfun", false).getBoolean(false);
|
||||
forceToolLogsOff = config.get("Logging", "Disable tool build messages", false).getBoolean(false);
|
||||
|
||||
keepHunger = config.get("Difficulty Changes", "Keep hunger on death", true).getBoolean(true);
|
||||
keepLevels = config.get("Difficulty Changes", "Keep levels on death", true).getBoolean(true);
|
||||
beginnerBook = config.get("Difficulty Changes", "Spawn beginner book", true).getBoolean(true);
|
||||
|
||||
enableTWood = config.get("Difficulty Changes", "Enable mod wooden tools", true).getBoolean(true);
|
||||
enableTStone = config.get("Difficulty Changes", "Enable mod stone tools", true).getBoolean(true);
|
||||
enableTCactus = config.get("Difficulty Changes", "Enable mod cactus tools", true).getBoolean(true);
|
||||
enableTBone = config.get("Difficulty Changes", "Enable mod bone tools", true).getBoolean(true);
|
||||
enableTFlint = config.get("Difficulty Changes", "Enable mod flint tools", true).getBoolean(true);
|
||||
enableTNetherrack = config.get("Difficulty Changes", "Enable mod netherrack tools", true).getBoolean(true);
|
||||
enableTSlime = config.get("Difficulty Changes", "Enable mod slime tools", true).getBoolean(true);
|
||||
enableTPaper = config.get("Difficulty Changes", "Enable mod paper tools", true).getBoolean(true);
|
||||
enableTBlueSlime = config.get("Difficulty Changes", "Enable mod blue slime tools", true).getBoolean(true);
|
||||
|
||||
craftMetalTools = config.get("Difficulty Changes", "Craft metals with Wood Patterns", false).getBoolean(false);
|
||||
vanillaMetalBlocks = config.get("Difficulty Changes", "Craft vanilla metal blocks", true).getBoolean(true);
|
||||
lavaFortuneInteraction = config.get("Difficulty Changes", "Enable Auto-Smelt and Fortune interaction", true).getBoolean(true);
|
||||
removeVanillaToolRecipes = config.get("Difficulty Changes", "Remove Vanilla Tool Recipes", false).getBoolean(false);
|
||||
stencilTableCrafting = config.get("Difficulty Changes", "Craft Stencil Tables", true).getBoolean(true);
|
||||
miningLevelIncrease = config.get("Difficulty Changes", "Modifiers increase Mining Level", true).getBoolean(true);
|
||||
denyMattock = config.get("Difficulty Changes", "Deny creation of non-metal mattocks", false).getBoolean(false);
|
||||
craftEndstone = config.get("Difficulty Changes", "Allow creation of endstone", true).getBoolean(true);
|
||||
|
||||
ingotsPerOre = config.get("Smeltery Output Modification", "Ingots per ore", 2, "Number of ingots returned from smelting ores in the smeltery").getInt(2);
|
||||
ingotsBronzeAlloy = config.get("Smeltery Output Modification", "Bronze ingot return", 4, "Number of ingots returned from smelting Bronze in the smeltery").getInt(4);
|
||||
ingotsAluminumBrassAlloy = config.get("Smeltery Output Modification", "Aluminum Brass ingot return", 4, "Number of ingots returned from smelting Aluminum Brass in the smeltery").getInt(4);
|
||||
ingotsAlumiteAlloy = config.get("Smeltery Output Modification", "Alumite ingot return", 3, "Number of ingots returned from smelting Alumite in the smeltery").getInt(3);
|
||||
ingotsManyullynAlloy = config.get("Smeltery Output Modification", "Manyullyn ingot return", 1, "Number of ingots returned from smelting Manyullyn in the smeltery").getInt(1);
|
||||
ingotsPigironAlloy = config.get("Smeltery Output Modification", "Pig Iron ingot return", 1, "Number of ingots returned from smelting Pig Iron in the smeltery").getInt(1);
|
||||
|
||||
//1467-1489
|
||||
woodStation = config.getBlock("Wood Tool Station", 1471).getInt(1471);
|
||||
heldItemBlock = config.getBlock("Held Item Block", 1472).getInt(1472);
|
||||
lavaTank = config.getBlock("Lava Tank", 1473).getInt(1473);
|
||||
smeltery = config.getBlock("Smeltery", 1474).getInt(1474);
|
||||
oreSlag = config.getBlock("Ores Slag", 1475).getInt(1475);
|
||||
craftedSoil = config.getBlock("Special Soil", 1476).getInt(1476);
|
||||
searedTable = config.getBlock("Seared Table", 1477).getInt(1477);
|
||||
metalBlock = config.getBlock("Metal Storage", 1478).getInt(1478);
|
||||
/*metalFlowing = config.getBlock("Liquid Metal Flowing", 1479).getInt(1479);
|
||||
metalStill = config.getBlock("Liquid Metal Still", 1480).getInt(1480);*/
|
||||
|
||||
multiBrick = config.getBlock("Multi Brick", 1481).getInt(1481);
|
||||
|
||||
stoneTorch = config.getBlock("Stone Torch", 1484).getInt(1484);
|
||||
stoneLadder = config.getBlock("Stone Ladder", 1479).getInt(1479);
|
||||
oreBerry = config.getBlock("Ore Berry One", 1485).getInt(1485);
|
||||
oreBerrySecond = config.getBlock("Ore Berry Two", 1486).getInt(1486);
|
||||
|
||||
oreGravel = config.getBlock("Ores Gravel", 1488).getInt(1488);
|
||||
speedBlock = config.getBlock("Speed Block", 1489).getInt(1489);
|
||||
|
||||
landmine = config.getBlock("Landmine", 1470).getInt(1470);
|
||||
toolForge = config.getBlock("Tool Forge", 1468).getInt(1468);
|
||||
multiBrickFancy = config.getBlock("Multi Brick Fancy", 1467).getInt(1467);
|
||||
|
||||
barricadeOak = config.getBlock("Oak Barricade", 1469).getInt(1469);
|
||||
barricadeSpruce = config.getBlock("Spruce Barricade", 1482).getInt(1482);
|
||||
barricadeBirch = config.getBlock("Birch Barricade", 1483).getInt(1483);
|
||||
barricadeJungle = config.getBlock("Jungle Barricade", 1487).getInt(1487);
|
||||
|
||||
lavaTankNether = config.getBlock("Nether Lava Tank", 3186).getInt(3186);
|
||||
smelteryNether = config.getBlock("Nether Smeltery", 3187).getInt(3187);
|
||||
searedTableNether = config.getBlock("Nether Seared Block", 3188).getInt(3188);
|
||||
|
||||
bloodChannel = config.getBlock("Blood Channel", 3189).getInt(3189);
|
||||
slimeChannel = config.getBlock("Slime Channel", 3190).getInt(3190);
|
||||
slimePad = config.getBlock("Slime Pad", 3191).getInt(3191);
|
||||
|
||||
furnaceSlab = config.getBlock("Furnace Slab", 3192).getInt(3192);
|
||||
|
||||
//Thermal Expansion
|
||||
moltenSilver = config.getBlock("Molten Silver", 3195).getInt(3195);
|
||||
moltenLead = config.getBlock("Molten Lead", 3196).getInt(3196);
|
||||
moltenNickel = config.getBlock("Molten Nickel", 3197).getInt(3197);
|
||||
moltenShiny = config.getBlock("Molten Platinum", 3198).getInt(3198);
|
||||
moltenInvar = config.getBlock("Molten Invar", 3199).getInt(3199);
|
||||
moltenElectrum = config.getBlock("Molten Electrum", 3200).getInt(3200);
|
||||
moltenIron = config.getBlock("Molten Iron", 3201).getInt(3201);
|
||||
moltenGold = config.getBlock("Molten Gold", 3202).getInt(3202);
|
||||
moltenCopper = config.getBlock("Molten Copper", 3203).getInt(3203);
|
||||
moltenTin = config.getBlock("Molten Tin", 3204).getInt(3204);
|
||||
moltenAluminum = config.getBlock("Molten Aluminum", 3205).getInt(3205);
|
||||
moltenCobalt = config.getBlock("Molten Cobalt", 3206).getInt(3206);
|
||||
moltenArdite = config.getBlock("Molten Ardite", 3207).getInt(3207);
|
||||
moltenBronze = config.getBlock("Molten Bronze", 3208).getInt(3208);
|
||||
moltenAlubrass = config.getBlock("Molten Aluminum Brass", 3209).getInt(3209);
|
||||
moltenManyullyn = config.getBlock("Molten Manyullyn", 3210).getInt(3210);
|
||||
moltenAlumite = config.getBlock("Molten Alumite", 3211).getInt(3211);
|
||||
moltenObsidian = config.getBlock("Molten Obsidian", 3212).getInt(3212);
|
||||
moltenSteel = config.getBlock("Molten Steel", 3213).getInt(3213);
|
||||
moltenGlass = config.getBlock("Molten Glass", 3214).getInt(3214);
|
||||
moltenStone = config.getBlock("Molten Stone", 3215).getInt(3215);
|
||||
moltenEmerald = config.getBlock("Molten Emerald", 3216).getInt(3216);
|
||||
blood = config.getBlock("Liquid Cow", 3217).getInt(3217);
|
||||
moltenEnder = config.getBlock("Molten Ender", 3218).getInt(3218);
|
||||
|
||||
glueBlock = config.getBlock("Glue Block", 3219).getInt(3219);
|
||||
glueFluidBlock = config.getBlock("Glue Fluid Block", 3220).getInt(3220);
|
||||
|
||||
// signalBus = config.getBlock("Signal Bus", 3221).getInt(3221);
|
||||
// signalTerminal = config.getBlock("Signal Terminal", 3222).getInt(3222);
|
||||
glass = config.getBlock("Clear Glass", 3223).getInt(3223);
|
||||
stainedGlass = config.getBlock("Stained Glass", 3224).getInt(3224);
|
||||
stainedGlassClear = config.getBlock("Clear Stained Glass", 3225).getInt(3225);
|
||||
// redstoneMachine = config.getBlock("Redstone Machines", 3226).getInt(3226); // Migrated to TMechworks
|
||||
dryingRack = config.getBlock("Drying Rack", 3227).getInt(3227);
|
||||
glassPane = config.getBlock("Glass Pane", 3228).getInt(3228);
|
||||
stainedGlassClearPane = config.getBlock("Clear Stained Glass Pane", 3229).getInt(3229);
|
||||
|
||||
searedSlab = config.getBlock("Seared Slab", 3230).getInt(3230);
|
||||
speedSlab = config.getBlock("Speed Slab", 3231).getInt(3231);
|
||||
|
||||
punji = config.getBlock("Punji", 3232).getInt(3232);
|
||||
woodCrafter = config.getBlock("Crafting Station", 3233).getInt(3233);
|
||||
|
||||
slimePoolBlue = config.getBlock("Liquid Blue Slime", 3235).getInt(3235);
|
||||
slimeGel = config.getBlock("Congealed Slime", 3237).getInt(3237);
|
||||
slimeGrass = config.getBlock("Slime Grass", 3238).getInt(3238);
|
||||
slimeTallGrass = config.getBlock("Slime Tall Grass", 3239).getInt(3239);
|
||||
slimeLeaves = config.getBlock("Slime Grass Leaves", 3240).getInt(3240);
|
||||
slimeSapling = config.getBlock("Slime Tree Sapling", 3241).getInt(3241);
|
||||
|
||||
meatBlock = config.getBlock("Meat Block", 3242).getInt(3242);
|
||||
woodCrafterSlab = config.getBlock("Crafting Slab", 3243).getInt(3243);
|
||||
woolSlab1 = config.getBlock("Wool Slab 1", 3244).getInt(3244);
|
||||
woolSlab2 = config.getBlock("Wool Slab 2", 3245).getInt(3245);
|
||||
airTank = config.getBlock("Air Tank", 3246).getInt(3246);
|
||||
slimeExplosive = config.getBlock("SDX", 3247).getInt(3247);
|
||||
castingChannel = config.getBlock("Casting Channel", 3249).getInt(3249);
|
||||
woodenRail = config.getBlock("Wooden Rail", 3250).getInt(3250);
|
||||
//3251+ belongs to Natura. Go backwards!
|
||||
|
||||
manual = config.getItem("Patterns and Misc", "Tinker's Manual", 14018).getInt(14018);
|
||||
blankPattern = config.getItem("Patterns and Misc", "Blank Patterns", 14019).getInt(14019);
|
||||
materials = config.getItem("Patterns and Misc", "Materials", 14020).getInt(14020);
|
||||
toolRod = config.getItem("Patterns and Misc", "Tool Rod", 14021).getInt(14021);
|
||||
toolShard = config.getItem("Patterns and Misc", "Tool Shard", 14022).getInt(14022);
|
||||
woodPattern = config.getItem("Patterns and Misc", "Wood Pattern", 14023).getInt(14023);
|
||||
metalPattern = config.getItem("Patterns and Misc", "Metal Pattern", 14024).getInt(14024);
|
||||
armorPattern = config.getItem("Patterns and Misc", "Armor Pattern", 14025).getInt(14025);
|
||||
|
||||
pickaxeHead = config.getItem("Tool Parts", "Pickaxe Head", 14026).getInt(14026);
|
||||
shovelHead = config.getItem("Tool Parts", "Shovel Head", 14027).getInt(14027);
|
||||
axeHead = config.getItem("Tool Parts", "Axe Head", 14028).getInt(14028);
|
||||
hoeHead = config.getItem("Tool Parts", "Hoe Head", 14029).getInt(14029);
|
||||
|
||||
swordBlade = config.getItem("Tool Parts", "Sword Blade", 14030).getInt(14030);
|
||||
largeGuard = config.getItem("Tool Parts", "Large Guard", 14031).getInt(14031);
|
||||
medGuard = config.getItem("Tool Parts", "Medium Guard", 14032).getInt(14032);
|
||||
crossbar = config.getItem("Tool Parts", "Crossbar", 14033).getInt(14033);
|
||||
binding = config.getItem("Tool Parts", "Tool Binding", 14034).getInt(14034);
|
||||
|
||||
frypanHead = config.getItem("Tool Parts", "Frypan Head", 14035).getInt(14035);
|
||||
signHead = config.getItem("Tool Parts", "Sign Head", 14036).getInt(14036);
|
||||
|
||||
lumberHead = config.getItem("Tool Parts", "Lumber Axe Head", 14037).getInt(14037);
|
||||
knifeBlade = config.getItem("Tool Parts", "Knife Blade", 14038).getInt(14038);
|
||||
chiselHead = config.getItem("Tool Parts", "Chisel Head", 14039).getInt(14039);
|
||||
scytheBlade = config.getItem("Tool Parts", "Scythe Head", 14040).getInt(14040);
|
||||
toughBinding = config.getItem("Tool Parts", "Tough Binding", 14041).getInt(14041);
|
||||
toughRod = config.getItem("Tool Parts", "Tough Rod", 14042).getInt(14042);
|
||||
largeSwordBlade = config.getItem("Tool Parts", "Large Sword Blade", 14043).getInt(14043);
|
||||
largePlate = config.getItem("Tool Parts", "Large Plate", 14044).getInt(14044);
|
||||
excavatorHead = config.getItem("Tool Parts", "Excavator Head", 14045).getInt(14045);
|
||||
hammerHead = config.getItem("Tool Parts", "Hammer Head", 14046).getInt(14046);
|
||||
fullGuard = config.getItem("Tool Parts", "Full Guard", 14047).getInt(14047);
|
||||
bowstring = config.getItem("Tool Parts", "Bowstring", 14048).getInt(14048);
|
||||
arrowhead = config.getItem("Tool Parts", "Arrowhead", 14049).getInt(14049);
|
||||
fletching = config.getItem("Tool Parts", "Fletching", 14050).getInt(14050);
|
||||
|
||||
pickaxe = config.getItem("Tools", "Pickaxe", 14051).getInt(14051);
|
||||
shovel = config.getItem("Tools", "Shovel", 14052).getInt(14052);
|
||||
axe = config.getItem("Tools", "Axe", 14053).getInt(14053);
|
||||
hoe = config.getItem("Tools", "Hoe", 14054).getInt(14054);
|
||||
|
||||
broadsword = config.getItem("Tools", "Broadsword", 14055).getInt(14055);
|
||||
rapier = config.getItem("Tools", "Rapier", 14057).getInt(14057);
|
||||
longsword = config.getItem("Tools", "Longsword", 14056).getInt(14056);
|
||||
dagger = config.getItem("Tools", "Dagger", 14065).getInt(14065);
|
||||
|
||||
frypan = config.getItem("Tools", "Frying Pan", 14058).getInt(14058);
|
||||
battlesign = config.getItem("Tools", "Battlesign", 14059).getInt(14059);
|
||||
mattock = config.getItem("Tools", "Mattock", 14060).getInt(14060);
|
||||
lumberaxe = config.getItem("Tools", "Lumber Axe", 14061).getInt(14061);
|
||||
longbow = config.getItem("Tools", "Longbow", 14062).getInt(14062);
|
||||
shortbow = config.getItem("Tools", "Shortbow", 14063).getInt(14063);
|
||||
potionLauncher = config.getItem("Tools", "Potion Launcher", 14064).getInt(14064);
|
||||
|
||||
chisel = config.getItem("Tools", "Chisel", 14066).getInt(14066);
|
||||
scythe = config.getItem("Tools", "Scythe", 14067).getInt(14067);
|
||||
cleaver = config.getItem("Tools", "Cleaver", 14068).getInt(14068);
|
||||
excavator = config.getItem("Tools", "Excavator", 14069).getInt(14069);
|
||||
hammer = config.getItem("Tools", "Hammer", 14070).getInt(14070);
|
||||
battleaxe = config.getItem("Tools", "Battleaxe", 14071).getInt(14071);
|
||||
|
||||
cutlass = config.getItem("Tools", "Cutlass", 14072).getInt(14072);
|
||||
arrow = config.getItem("Tools", "Arrow", 14073).getInt(14073);
|
||||
|
||||
buckets = config.getItem("Patterns and Misc", "Buckets", 14101).getInt(14101);
|
||||
uselessItem = config.getItem("Patterns and Misc", "Title Icon", 14102).getInt(14102);
|
||||
slimefood = config.getItem("Patterns and Misc", "Strange Food", 14103).getInt(14103);
|
||||
oreChunks = config.getItem("Patterns and Misc", "Ore Chunks", 14104).getInt(14104);
|
||||
|
||||
heartCanister = config.getItem("Equipables", "Heart Canister", 14105).getInt(14105);
|
||||
diamondApple = config.getItem("Patterns and Misc", "Jeweled Apple", 14107).getInt(14107);
|
||||
woodHelmet = config.getItem("Equipables", "Wooden Helmet", 14106).getInt(14106);
|
||||
woodChestplate = config.getItem("Equipables", "Wooden Chestplate", 14108).getInt(14108);
|
||||
woodPants = config.getItem("Equipables", "Wooden Pants", 14109).getInt(14109);
|
||||
woodBoots = config.getItem("Equipables", "Wooden Boots", 14110).getInt(14110);
|
||||
glove = config.getItem("Equipables", "Gloves", 14111).getInt(14111);
|
||||
knapsack = config.getItem("Equipables", "Knapsack", 14112).getInt(14112);
|
||||
goldHead = config.getItem("Patterns and Misc", "Golden Head", 14113).getInt(14113);
|
||||
jerky = config.getItem("Patterns and Misc", "Jerky", 14115).getInt(14115);
|
||||
|
||||
exoGoggles = config.getItem("Equipables", "Exo-Goggles", 14116).getInt(14116);
|
||||
exoChest = config.getItem("Equipables", "Exo-Chestpiece", 14117).getInt(14117);
|
||||
exoPants = config.getItem("Equipables", "Exo-Legs", 14118).getInt(14118);
|
||||
exoShoes = config.getItem("Equipables", "Exo-Boots", 14119).getInt(14119);
|
||||
|
||||
boolean ic2 = true;
|
||||
boolean xycraft = true;
|
||||
try
|
||||
{
|
||||
Class c = Class.forName("ic2.core.IC2");
|
||||
ic2 = false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
try
|
||||
{
|
||||
Class c = Class.forName("soaryn.xycraft.core.XyCraft");
|
||||
xycraft = false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
generateCopper = config.get("Worldgen Disabler", "Generate Copper", ic2).getBoolean(ic2);
|
||||
generateTin = config.get("Worldgen Disabler", "Generate Tin", ic2).getBoolean(ic2);
|
||||
generateAluminum = config.get("Worldgen Disabler", "Generate Aluminum", xycraft).getBoolean(xycraft);
|
||||
generateNetherOres = config.get("Worldgen Disabler", "Generate Cobalt and Ardite", true).getBoolean(true);
|
||||
|
||||
generateIronSurface = config.get("Worldgen Disabler", "Generate Surface Iron", true).getBoolean(true);
|
||||
generateGoldSurface = config.get("Worldgen Disabler", "Generate Surface Gold", true).getBoolean(true);
|
||||
generateCopperSurface = config.get("Worldgen Disabler", "Generate Surface Copper", true).getBoolean(true);
|
||||
generateTinSurface = config.get("Worldgen Disabler", "Generate Surface Tin", true).getBoolean(true);
|
||||
generateAluminumSurface = config.get("Worldgen Disabler", "Generate Surface Aluminum", true).getBoolean(true);
|
||||
|
||||
generateIronBush = config.get("Worldgen Disabler", "Generate Iron Bushes", true).getBoolean(true);
|
||||
generateGoldBush = config.get("Worldgen Disabler", "Generate Gold Bushes", true).getBoolean(true);
|
||||
generateCopperBush = config.get("Worldgen Disabler", "Generate Copper Bushes", true).getBoolean(true);
|
||||
generateTinBush = config.get("Worldgen Disabler", "Generate Tin Bushes", true).getBoolean(true);
|
||||
generateAluminumBush = config.get("Worldgen Disabler", "Generate Aluminum Bushes", true).getBoolean(true);
|
||||
generateEssenceBush = config.get("Worldgen Disabler", "Generate Essence Bushes", true).getBoolean(true);
|
||||
addToVillages = config.get("Worldgen Disabler", "Add Village Generation", true).getBoolean(true);
|
||||
|
||||
copperuDensity = config.get("Worldgen", "Copper Underground Density", 2, "Density: Chances per chunk").getInt(2);
|
||||
tinuDensity = config.get("Worldgen", "Tin Underground Density", 2).getInt(2);
|
||||
aluminumuDensity = config.get("Worldgen", "Aluminum Underground Density", 3).getInt(3);
|
||||
netherDensity = config.get("Worldgen", "Nether Ores Density", 8).getInt(8);
|
||||
|
||||
copperuMinY = config.get("Worldgen", "Copper Underground Min Y", 20).getInt(20);
|
||||
copperuMaxY = config.get("Worldgen", "Copper Underground Max Y", 60).getInt(60);
|
||||
tinuMinY = config.get("Worldgen", "Tin Underground Min Y", 0).getInt(0);
|
||||
tinuMaxY = config.get("Worldgen", "Tin Underground Max Y", 40).getInt(40);
|
||||
aluminumuMinY = config.get("Worldgen", "Aluminum Underground Min Y", 0).getInt(0);
|
||||
aluminumuMaxY = config.get("Worldgen", "Aluminum Underground Max Y", 64).getInt(64);
|
||||
|
||||
ironsRarity = config.get("Worldgen", "Iron Surface Rarity", 400).getInt(400);
|
||||
goldsRarity = config.get("Worldgen", "Gold Surface Rarity", 900).getInt(900);
|
||||
coppersRarity = config.get("Worldgen", "Copper Surface Rarity", 100, "Rarity: 1/num to generate in chunk").getInt(100);
|
||||
tinsRarity = config.get("Worldgen", "Tin Surface Rarity", 100).getInt(100);
|
||||
aluminumsRarity = config.get("Worldgen", "Aluminum Surface Rarity", 50).getInt(50);
|
||||
cobaltsRarity = config.get("Worldgen", "Cobalt Surface Rarity", 2000).getInt(2000);
|
||||
|
||||
ironBushDensity = config.get("Worldgen", "Iron Bush Density", 1).getInt(1);
|
||||
goldBushDensity = config.get("Worldgen", "Gold Bush Density", 1).getInt(1);
|
||||
copperBushDensity = config.get("Worldgen", "Copper Bush Density", 2).getInt(2);
|
||||
tinBushDensity = config.get("Worldgen", "Tin Bush Density", 2).getInt(2);
|
||||
aluminumBushDensity = config.get("Worldgen", "Aluminum Bush Density", 2).getInt(2);
|
||||
silverBushDensity = config.get("Worldgen", "Silver Bush Density", 1).getInt(1);
|
||||
|
||||
ironBushRarity = config.get("Worldgen", "Iron Bush Rarity", 5).getInt(5);
|
||||
goldBushRarity = config.get("Worldgen", "Gold Bush Rarity", 8).getInt(8);
|
||||
copperBushRarity = config.get("Worldgen", "Copper Bush Rarity", 3).getInt(3);
|
||||
tinBushRarity = config.get("Worldgen", "Tin Bush Rarity", 3).getInt(3);
|
||||
aluminumBushRarity = config.get("Worldgen", "Aluminum Bush Rarity", 2).getInt(2);
|
||||
essenceBushRarity = config.get("Worldgen", "Essence Bush Rarity", 6).getInt(6);
|
||||
|
||||
copperBushMinY = config.get("Worldgen", "Copper Bush Min Y", 20).getInt(20);
|
||||
copperBushMaxY = config.get("Worldgen", "Copper Bush Max Y", 60).getInt(60);
|
||||
tinBushMinY = config.get("Worldgen", "Tin Bush Min Y", 0).getInt(0);
|
||||
tinBushMaxY = config.get("Worldgen", "Tin Bush Max Y", 40).getInt(40);
|
||||
aluminumBushMinY = config.get("Worldgen", "Aluminum Bush Min Y", 0).getInt(0);
|
||||
aluminumBushMaxY = config.get("Worldgen", "Aluminum Bush Max Y", 60).getInt(60);
|
||||
|
||||
seaLevel = config.get("general", "Sea level", 64).getInt(64);
|
||||
|
||||
enableHealthRegen = config.get("Ultra Hardcore Changes", "Passive Health Regen", true).getBoolean(true);
|
||||
goldAppleRecipe = config.get("Ultra Hardcore Changes", "Change Crafting Recipes", false, "Makes recipes for gold apples, carrots, and melon potions more expensive").getBoolean(false);
|
||||
dropPlayerHeads = config.get("Ultra Hardcore Changes", "Players drop heads on death", false).getBoolean(false);
|
||||
uhcGhastDrops = config.get("Ultra Hardcore Changes", "Change Ghast drops to Gold Ingots", false).getBoolean(false);
|
||||
worldBorder = config.get("Ultra Hardcore Changes", "Add World Border", false).getBoolean(false);
|
||||
worldBorderSize = config.get("Ultra Hardcore Changes", "World Border Radius", 1000).getInt(1000);
|
||||
freePatterns = config.get("Ultra Hardcore Changes", "Add Patterns to Pattern Chests", false, "Gives all tier 1 patterns when pattern chest is placed").getBoolean(false);
|
||||
AbilityHelper.necroticUHS = config.get("Ultra Hardcore Changes", "Necrotic modifier only heals on hostile mob kills", false).getBoolean(false);
|
||||
|
||||
//Slime pools
|
||||
islandRarity = config.get("Worldgen", "Slime Island Rarity", 1450).getInt(1450);
|
||||
|
||||
//Looks
|
||||
Property conTexMode = config.get("Looks", "Connected Textures Enabled", true);
|
||||
conTexMode.comment = "0 = disabled, 1 = enabled, 2 = enabled + ignore stained glass meta";
|
||||
connectedTexturesMode = conTexMode.getInt(2);
|
||||
|
||||
//dimension blacklist
|
||||
cfgDimBlackList = config.get("DimBlackList", "SlimeIslandDimBlacklist", new int[] {}, "Add dimension ID's to prevent slime islands from generating in them").getIntList();
|
||||
slimeIslGenDim0Only = config.get("DimBlackList", "GenerateSlimeIslandInDim0Only", false,
|
||||
"True: slime islands wont generate in any ages other than overworld(if enabled); False: will generate in all non-blackisted ages").getBoolean(false);
|
||||
slimeIslGenDim0 = config.get("DimBlackList", "slimeIslGenDim0", true, "True: slime islands generate in overworld; False they do not generate").getBoolean(true);
|
||||
genIslandsFlat = config.get("DimBlacklist", "genIslandsFlat", false, "Generate slime islands in flat worlds").getBoolean(false);
|
||||
|
||||
//Experimental functionality
|
||||
throwableSmeltery = config.get("Experimental", "Items can be thrown into smelteries", true).getBoolean(true);
|
||||
newSmeltery = config.get("Experimental", "Use new adaptive Smeltery code", false, "Warning: Very buggy").getBoolean(false);
|
||||
meltableHorses = config.get("Experimental", "Allow horses to be melted down for glue", true).getBoolean(true);
|
||||
|
||||
//Addon stuff
|
||||
isCleaverTwoHanded = config.get("Battlegear", "Can Cleavers have shields", true).getBoolean(true);
|
||||
isHatchetWeapon = config.get("Battlegear", "Are Hatches also weapons", true).getBoolean(true);
|
||||
|
||||
//Achievement Properties
|
||||
achievementsEnabled = config.get("Achievement Properties", "AchievementsEnabled", true).getBoolean(true);
|
||||
|
||||
/* Save the configuration file */
|
||||
config.save();
|
||||
|
||||
File gt = new File(location + "/GregTech");
|
||||
if (gt.exists())
|
||||
{
|
||||
File gtDyn = new File(location + "/GregTech/DynamicConfig.cfg");
|
||||
Configuration gtConfig = new Configuration(gtDyn);
|
||||
gtConfig.load();
|
||||
gregtech = gtConfig.get("smelting", "tile.anvil.slightlyDamaged", false).getBoolean(false);
|
||||
}
|
||||
}
|
||||
|
||||
//Blocks
|
||||
public static int woodStation;
|
||||
public static int toolForge;
|
||||
public static int heldItemBlock;
|
||||
public static int woodCrafter;
|
||||
public static int woodCrafterSlab;
|
||||
public static int furnaceSlab;
|
||||
|
||||
public static int ores;
|
||||
public static int lavaTank;
|
||||
public static int smeltery;
|
||||
public static int searedTable;
|
||||
public static int lavaTankNether;
|
||||
public static int smelteryNether;
|
||||
public static int searedTableNether;
|
||||
public static int castingChannel;
|
||||
public static int airTank;
|
||||
|
||||
public static int craftedSoil;
|
||||
public static int oreSlag;
|
||||
public static int oreGravel;
|
||||
public static int metalBlock;
|
||||
|
||||
public static int redstoneMachine;
|
||||
public static int dryingRack;
|
||||
|
||||
public static int woodenRail;
|
||||
|
||||
//Crops
|
||||
public static int oreBerry;
|
||||
public static int oreBerrySecond;
|
||||
public static int netherOreBerry;
|
||||
|
||||
//Traps
|
||||
public static int landmine;
|
||||
public static int punji;
|
||||
public static int barricadeOak;
|
||||
public static int barricadeSpruce;
|
||||
public static int barricadeBirch;
|
||||
public static int barricadeJungle;
|
||||
public static int slimeExplosive;
|
||||
|
||||
//InfiBlocks
|
||||
public static int speedBlock;
|
||||
public static int glass;
|
||||
public static int glassPane;
|
||||
public static int stainedGlass;
|
||||
public static int stainedGlassClear;
|
||||
public static int stainedGlassClearPane;
|
||||
|
||||
//Liquids
|
||||
public static int metalFlowing;
|
||||
public static int metalStill;
|
||||
|
||||
public static int moltenIron;
|
||||
public static int moltenGold;
|
||||
public static int moltenCopper;
|
||||
public static int moltenTin;
|
||||
public static int moltenAluminum;
|
||||
public static int moltenCobalt;
|
||||
public static int moltenArdite;
|
||||
public static int moltenBronze;
|
||||
public static int moltenAlubrass;
|
||||
public static int moltenManyullyn;
|
||||
public static int moltenAlumite;
|
||||
public static int moltenObsidian;
|
||||
public static int moltenSteel;
|
||||
public static int moltenGlass;
|
||||
public static int moltenStone;
|
||||
public static int moltenEmerald;
|
||||
public static int blood;
|
||||
public static int moltenEnder;
|
||||
public static int moltenSilver; //Thermal Expansion
|
||||
public static int moltenLead;
|
||||
public static int moltenNickel;
|
||||
public static int moltenShiny;
|
||||
public static int moltenInvar;
|
||||
public static int moltenElectrum;
|
||||
|
||||
//Slime
|
||||
public static int slimePoolBlue;
|
||||
public static int slimeGel;
|
||||
public static int slimeGrass;
|
||||
public static int slimeTallGrass;
|
||||
public static int slimeLeaves;
|
||||
public static int slimeSapling;
|
||||
|
||||
public static int slimeChannel;
|
||||
public static int slimePad;
|
||||
public static int bloodChannel;
|
||||
|
||||
// Glue
|
||||
public static int glueFluidBlock;
|
||||
public static int glueBlock;
|
||||
|
||||
//Decoration
|
||||
public static int stoneTorch;
|
||||
public static int stoneLadder;
|
||||
public static int multiBrick;
|
||||
public static int multiBrickFancy;
|
||||
public static int redstoneBallRepeater;
|
||||
public static int searedSlab;
|
||||
public static int speedSlab;
|
||||
public static int meatBlock;
|
||||
public static int woolSlab1;
|
||||
public static int woolSlab2;
|
||||
|
||||
//Patterns and misc
|
||||
public static int blankPattern;
|
||||
public static int materials;
|
||||
public static int toolRod;
|
||||
public static int toolShard;
|
||||
public static int woodPattern;
|
||||
public static int metalPattern;
|
||||
public static int armorPattern;
|
||||
|
||||
public static int manual;
|
||||
public static int buckets;
|
||||
public static int uselessItem;
|
||||
public static int oreChunks;
|
||||
|
||||
//Food
|
||||
public static int diamondApple;
|
||||
public static int slimefood;
|
||||
public static int jerky;
|
||||
|
||||
//Tools
|
||||
public static int pickaxe;
|
||||
public static int shovel;
|
||||
public static int axe;
|
||||
public static int hoe;
|
||||
|
||||
public static int broadsword;
|
||||
public static int longsword;
|
||||
public static int rapier;
|
||||
public static int dagger;
|
||||
public static int cutlass;
|
||||
|
||||
public static int frypan;
|
||||
public static int battlesign;
|
||||
public static int longbow;
|
||||
public static int shortbow;
|
||||
public static int potionLauncher;
|
||||
public static int mattock;
|
||||
|
||||
public static int lumberaxe;
|
||||
public static int scythe;
|
||||
public static int cleaver;
|
||||
public static int excavator;
|
||||
public static int hammer;
|
||||
public static int battleaxe;
|
||||
|
||||
public static int chisel;
|
||||
public static int arrow;
|
||||
|
||||
//Tool parts
|
||||
public static int swordBlade;
|
||||
public static int largeGuard;
|
||||
public static int medGuard;
|
||||
public static int crossbar;
|
||||
public static int knifeBlade;
|
||||
public static int fullGuard;
|
||||
|
||||
public static int pickaxeHead;
|
||||
public static int axeHead;
|
||||
public static int shovelHead;
|
||||
public static int hoeHead;
|
||||
|
||||
public static int frypanHead;
|
||||
public static int signHead;
|
||||
public static int chiselHead;
|
||||
|
||||
public static int scytheBlade;
|
||||
public static int lumberHead;
|
||||
public static int largeSwordBlade;
|
||||
public static int excavatorHead;
|
||||
public static int hammerHead;
|
||||
|
||||
public static int binding;
|
||||
public static int toughBinding;
|
||||
public static int toughRod;
|
||||
public static int largePlate;
|
||||
|
||||
public static int bowstring;
|
||||
public static int arrowhead;
|
||||
public static int fletching;
|
||||
|
||||
//Wearables
|
||||
public static int woodHelmet;
|
||||
public static int woodChestplate;
|
||||
public static int woodPants;
|
||||
public static int woodBoots;
|
||||
public static int glove;
|
||||
public static int knapsack;
|
||||
|
||||
public static int heartCanister;
|
||||
|
||||
public static int exoGoggles;
|
||||
public static int exoChest;
|
||||
public static int exoPants;
|
||||
public static int exoShoes;
|
||||
|
||||
|
||||
//Ore values
|
||||
public static boolean generateCopper;
|
||||
public static boolean generateTin;
|
||||
public static boolean generateAluminum;
|
||||
public static boolean generateNetherOres;
|
||||
|
||||
public static boolean generateIronSurface;
|
||||
public static boolean generateGoldSurface;
|
||||
public static boolean generateCopperSurface;
|
||||
public static boolean generateTinSurface;
|
||||
public static boolean generateAluminumSurface;
|
||||
public static boolean generateCobaltSurface;
|
||||
|
||||
public static boolean generateIronBush;
|
||||
public static boolean generateGoldBush;
|
||||
public static boolean generateCopperBush;
|
||||
public static boolean generateTinBush;
|
||||
public static boolean generateAluminumBush;
|
||||
public static boolean generateEssenceBush;
|
||||
|
||||
public static boolean addToVillages;
|
||||
|
||||
public static int copperuDensity;
|
||||
public static int tinuDensity;
|
||||
public static int aluminumuDensity;
|
||||
public static int netherDensity;
|
||||
|
||||
public static int ironsRarity;
|
||||
public static int goldsRarity;
|
||||
public static int coppersRarity;
|
||||
public static int tinsRarity;
|
||||
public static int aluminumsRarity;
|
||||
public static int cobaltsRarity;
|
||||
|
||||
public static int ironBushDensity;
|
||||
public static int goldBushDensity;
|
||||
public static int copperBushDensity;
|
||||
public static int tinBushDensity;
|
||||
public static int aluminumBushDensity;
|
||||
public static int silverBushDensity;
|
||||
|
||||
public static int ironBushRarity;
|
||||
public static int goldBushRarity;
|
||||
public static int copperBushRarity;
|
||||
public static int tinBushRarity;
|
||||
public static int aluminumBushRarity;
|
||||
public static int essenceBushRarity;
|
||||
|
||||
public static int copperuMinY;
|
||||
public static int copperuMaxY;
|
||||
public static int tinuMinY;
|
||||
public static int tinuMaxY;
|
||||
public static int aluminumuMinY;
|
||||
public static int aluminumuMaxY;
|
||||
|
||||
public static int copperBushMinY;
|
||||
public static int copperBushMaxY;
|
||||
public static int tinBushMinY;
|
||||
public static int tinBushMaxY;
|
||||
public static int aluminumBushMinY;
|
||||
public static int aluminumBushMaxY;
|
||||
|
||||
public static int seaLevel;
|
||||
|
||||
//Mobs
|
||||
|
||||
//Difficulty modifiers
|
||||
public static boolean keepHunger;
|
||||
public static boolean keepLevels;
|
||||
public static boolean alphaRegen;
|
||||
public static boolean alphaHunger;
|
||||
|
||||
public static boolean disableWoodTools;
|
||||
public static boolean disableStoneTools;
|
||||
public static boolean disableIronTools;
|
||||
public static boolean disableDiamondTools;
|
||||
public static boolean disableGoldTools;
|
||||
|
||||
public static boolean enableTWood;
|
||||
public static boolean enableTStone;
|
||||
public static boolean enableTCactus;
|
||||
public static boolean enableTBone;
|
||||
public static boolean enableTFlint;
|
||||
public static boolean enableTNetherrack;
|
||||
public static boolean enableTSlime;
|
||||
public static boolean enableTPaper;
|
||||
public static boolean enableTBlueSlime;
|
||||
|
||||
public static boolean craftMetalTools;
|
||||
public static boolean vanillaMetalBlocks;
|
||||
public static boolean removeVanillaToolRecipes;
|
||||
public static boolean stencilTableCrafting;
|
||||
public static boolean miningLevelIncrease;
|
||||
public static boolean denyMattock;
|
||||
|
||||
//Smeltery Output Modification
|
||||
public static int ingotsPerOre;
|
||||
public static int ingotsBronzeAlloy;
|
||||
public static int ingotsAluminumBrassAlloy;
|
||||
public static int ingotsAlumiteAlloy;
|
||||
public static int ingotsManyullynAlloy;
|
||||
public static int ingotsPigironAlloy;
|
||||
public static boolean craftEndstone;
|
||||
|
||||
//Ultra Hardcore modifiers
|
||||
public static boolean enableHealthRegen;
|
||||
public static boolean goldAppleRecipe;
|
||||
public static boolean dropPlayerHeads;
|
||||
public static boolean uhcGhastDrops;
|
||||
public static boolean worldBorder;
|
||||
public static int worldBorderSize;
|
||||
public static boolean freePatterns;
|
||||
public static int goldHead;
|
||||
|
||||
//Superfun
|
||||
public static boolean superfunWorld;
|
||||
public static boolean beginnerBook;
|
||||
|
||||
public static boolean gregtech;
|
||||
public static boolean lavaFortuneInteraction;
|
||||
public static boolean forceToolLogsOff;
|
||||
|
||||
public static int islandRarity;
|
||||
|
||||
//Looks
|
||||
public static int connectedTexturesMode;
|
||||
public static File cfglocation;
|
||||
|
||||
//dimensionblacklist
|
||||
public static boolean slimeIslGenDim0Only;
|
||||
public static int[] cfgDimBlackList;
|
||||
public static boolean slimeIslGenDim0;
|
||||
public static boolean genIslandsFlat;
|
||||
|
||||
//Experimental functionality
|
||||
public static boolean throwableSmeltery;
|
||||
public static boolean newSmeltery;
|
||||
public static boolean meltableHorses;
|
||||
|
||||
//Addon stuff
|
||||
public static boolean isCleaverTwoHanded;
|
||||
public static boolean isHatchetWeapon;
|
||||
|
||||
//Achievement options
|
||||
public static boolean achievementsEnabled;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package tconstruct.util.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import tconstruct.TConstruct;
|
||||
|
||||
public class TwilightForestConfig
|
||||
{
|
||||
public static void initProps (File location)
|
||||
{
|
||||
File newFile = new File(location + "/TwilightForest.cfg");
|
||||
if (newFile.exists())
|
||||
{
|
||||
Configuration config = new Configuration(newFile);
|
||||
|
||||
config.load();
|
||||
|
||||
twilightForestDimensionID = config.get("dimension", "dimensionID", -100).getInt();
|
||||
TConstruct.logger.info("TF Dim ID: " + twilightForestDimensionID);
|
||||
}
|
||||
else
|
||||
{
|
||||
twilightForestDimensionID = -100;
|
||||
}
|
||||
}
|
||||
|
||||
public static int twilightForestDimensionID;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package tconstruct.util.landmine;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*/
|
||||
public class Helper
|
||||
{
|
||||
|
||||
public static ForgeDirection convertMetaToForgeOrientation (int metadata)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 6:
|
||||
return ForgeDirection.DOWN;
|
||||
case 7:
|
||||
return ForgeDirection.UP;
|
||||
case 1:
|
||||
return ForgeDirection.WEST;
|
||||
case 3:
|
||||
return ForgeDirection.NORTH;
|
||||
case 2:
|
||||
return ForgeDirection.EAST;
|
||||
case 4:
|
||||
return ForgeDirection.SOUTH;
|
||||
case 5:
|
||||
return ForgeDirection.DOWN;
|
||||
case 0:
|
||||
return ForgeDirection.UP;
|
||||
}
|
||||
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
public static void renderInventoryCube (Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
renderer.renderFaceYPos(block, 0, 0, 0, renderer.getBlockIconFromSideAndMetadata(block, 1, metadata));
|
||||
tessellator.draw();
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
||||
renderer.renderFaceYNeg(block, 0, 0, 0, renderer.getBlockIconFromSideAndMetadata(block, 0, metadata));
|
||||
tessellator.draw();
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXPos(block, 0, 0, 0, renderer.getBlockIconFromSideAndMetadata(block, 2, metadata));
|
||||
tessellator.draw();
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXNeg(block, 0, 0, 0, renderer.getBlockIconFromSideAndMetadata(block, 3, metadata));
|
||||
tessellator.draw();
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
renderer.renderFaceZPos(block, 0, 0, 0, renderer.getBlockIconFromSideAndMetadata(block, 4, metadata));
|
||||
tessellator.draw();
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1.0F);
|
||||
renderer.renderFaceZNeg(block, 0, 0, 0, renderer.getBlockIconFromSideAndMetadata(block, 5, metadata));
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
package tconstruct.util.landmine.behavior;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.util.landmine.Helper;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*/
|
||||
public abstract class Behavior
|
||||
{
|
||||
|
||||
public static HashMap<Integer, Behavior> behaviorsListItems = new HashMap<Integer, Behavior>();
|
||||
public static HashMap<Integer, Behavior> behaviorsListBlocks = new HashMap<Integer, Behavior>();
|
||||
protected static Behavior defaultBehavior;
|
||||
|
||||
public static Behavior dummy = new BehaviorDummy();
|
||||
public static Behavior utilityMode = new BehaviorPreventExplode();
|
||||
public static Behavior explosive = new BehaviorExplosive();
|
||||
public static Behavior firework = new BehaviorFirework();
|
||||
public static Behavior blockThrow = new BehaviorBlockThrow();
|
||||
public static Behavior potion = new BehaviorPotion();
|
||||
public static Behavior fireball = new BehaviorFirecharge();
|
||||
public static Behavior spawn = new BehaviorSpawnEgg();
|
||||
public static Behavior shoot = new BehaviorProjectile();
|
||||
public static Behavior shear = new BehaviorShears();
|
||||
|
||||
public static void registerBuiltInBehaviors ()
|
||||
{
|
||||
defaultBehavior = new BehaviorDefault();
|
||||
|
||||
addBehavior(new ItemStack(Item.stick), dummy);
|
||||
addBehavior(new ItemStack(Item.redstone), utilityMode);
|
||||
addBehavior(new ItemStack(Block.torchWood), blockThrow);
|
||||
addBehavior(new ItemStack(Item.gunpowder), explosive);
|
||||
addBehavior(new ItemStack(Block.tnt), explosive);
|
||||
addBehavior(new ItemStack(Item.firework), firework);
|
||||
addBehavior(new ItemStack(Item.potion), potion);
|
||||
addBehavior(new ItemStack(Item.fireballCharge), fireball);
|
||||
addBehavior(new ItemStack(Item.monsterPlacer), spawn);
|
||||
addBehavior(new ItemStack(Item.arrow), shoot);
|
||||
addBehavior(new ItemStack(Item.snowball), shoot);
|
||||
addBehavior(new ItemStack(Item.enderPearl), shoot);
|
||||
addBehavior(new ItemStack(Item.shears), shear);
|
||||
|
||||
//Make sure the part below this comment is executed last(to avoid conflicts)
|
||||
for (int i = 1; i < Block.blocksList.length; i++)
|
||||
{
|
||||
if (Block.blocksList[i] != null && Block.blocksList[i].isOpaqueCube() && Block.blocksList[i].renderAsNormalBlock() && !(Block.blocksList[i] instanceof ITileEntityProvider)
|
||||
&& !behaviorsListBlocks.containsKey(new ItemStack(Block.blocksList[i])))
|
||||
{
|
||||
addBehavior(new ItemStack(Block.blocksList[i]), blockThrow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Behavior getBehaviorFromStack (ItemStack par1ItemStack)
|
||||
{
|
||||
if (par1ItemStack == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (par1ItemStack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
if (!behaviorsListBlocks.isEmpty())
|
||||
{
|
||||
return behaviorsListBlocks.get(par1ItemStack.itemID);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!behaviorsListItems.isEmpty())
|
||||
{
|
||||
return behaviorsListItems.get(par1ItemStack.itemID);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Behavior getDefaulBehavior ()
|
||||
{
|
||||
return defaultBehavior;
|
||||
}
|
||||
|
||||
public static void addBehavior (ItemStack par1ItemStack, Behavior par2Behavior)
|
||||
{
|
||||
if (par1ItemStack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
if (!behaviorsListBlocks.containsKey(par1ItemStack.itemID))
|
||||
{
|
||||
behaviorsListBlocks.put(par1ItemStack.itemID, par2Behavior);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!behaviorsListItems.containsKey(par1ItemStack.itemID))
|
||||
{
|
||||
behaviorsListItems.put(par1ItemStack.itemID, par2Behavior);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved);
|
||||
|
||||
public int getStackLimit (ItemStack par1ItemStack)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void getInformation (ItemStack par1ItemStack, List par2List)
|
||||
{
|
||||
}
|
||||
|
||||
//Will return false if the effect does not stack among the slots
|
||||
public boolean effectStacks ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public EnumFacing getFacing (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
ForgeDirection dir = Helper.convertMetaToForgeOrientation(par1World.getBlockMetadata(par2, par3, par4));
|
||||
|
||||
switch (dir)
|
||||
{
|
||||
case DOWN:
|
||||
return EnumFacing.UP;
|
||||
case UP:
|
||||
return EnumFacing.DOWN;
|
||||
case WEST:
|
||||
return EnumFacing.WEST;
|
||||
case EAST:
|
||||
return EnumFacing.EAST;
|
||||
case SOUTH:
|
||||
return EnumFacing.NORTH;
|
||||
case NORTH:
|
||||
return EnumFacing.SOUTH;
|
||||
default:
|
||||
return EnumFacing.UP;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean doesBehaviorPreventRemovalOfBlock (ItemStack par1ItemStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isBehaviorExchangableWithOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean shouldItemBeRemoved (ItemStack par1ItemStack, boolean willBlockGetRemoved)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public static final int arrayIndexOfStack (ArrayList<ItemStack> stacks, ItemStack item)
|
||||
{
|
||||
Iterator<ItemStack> i1 = stacks.iterator();
|
||||
|
||||
int index = 0;
|
||||
|
||||
while (i1.hasNext())
|
||||
{
|
||||
ItemStack stack = i1.next();
|
||||
if (stack.isItemEqual(item))
|
||||
{
|
||||
return index;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static final boolean arrayContainsEqualStack (ArrayList<ItemStack> stacks, ItemStack item)
|
||||
{
|
||||
Iterator<ItemStack> i1 = stacks.iterator();
|
||||
|
||||
while (i1.hasNext())
|
||||
{
|
||||
ItemStack stack = i1.next();
|
||||
if (stack.isItemEqual(item))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean overridesDefault ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package tconstruct.util.landmine.behavior;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityFallingSand;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*/
|
||||
public class BehaviorBlockThrow extends Behavior
|
||||
{
|
||||
|
||||
@Override
|
||||
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
|
||||
{
|
||||
for (int i = 0; i < par5ItemStack.stackSize; i++)
|
||||
{
|
||||
int direction = par1World.rand.nextInt(8);
|
||||
double speed = 2D * Math.random() + 0.01D;
|
||||
double upVecReduction = 0.25D;
|
||||
double randomnessFactor = 0.5D;
|
||||
double vec0 = 0, vec1 = par1World.rand.nextDouble() * upVecReduction, vec2 = 0;
|
||||
switch (direction)
|
||||
{
|
||||
case 0:
|
||||
vec0 = speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
//vec2 = par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 1:
|
||||
vec0 = -speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
//vec2 = par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 2:
|
||||
vec2 = speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
//vec0 = par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 3:
|
||||
vec2 = -speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
//vec0 = par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 4:
|
||||
vec0 = speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
vec2 = speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 5:
|
||||
vec0 = speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
vec2 = -speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 6:
|
||||
vec0 = -speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
vec2 = speed + par1World.rand.nextDouble() * randomnessFactor;
|
||||
break;
|
||||
case 7:
|
||||
vec0 = -speed;
|
||||
vec2 = -speed;
|
||||
break;
|
||||
default:
|
||||
vec0 = speed;
|
||||
break;
|
||||
}
|
||||
|
||||
EntityFallingSand entityfallingsand = new EntityFallingSand(par1World, (double) ((float) par2 + 0.5F), (double) ((float) par3 + 2F), (double) ((float) par4 + 0.5F), par5ItemStack.itemID,
|
||||
par5ItemStack.getItemDamage());
|
||||
entityfallingsand.preventEntitySpawning = false;
|
||||
entityfallingsand.fallTime = 2;
|
||||
entityfallingsand.setVelocity(vec0, vec1, vec2);
|
||||
par1World.spawnEntityInWorld(entityfallingsand);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackLimit (ItemStack par1ItemStack)
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package tconstruct.util.landmine.behavior;
|
||||
|
||||
import tconstruct.util.DamageSourceLandmine;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BehaviorDefault extends Behavior
|
||||
{
|
||||
|
||||
@Override
|
||||
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
|
||||
{
|
||||
if (triggerer != null)
|
||||
{
|
||||
triggerer.attackEntityFrom(new DamageSourceLandmine("Landmine"), 5F);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package tconstruct.util.landmine.behavior;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*/
|
||||
public class BehaviorDummy extends Behavior
|
||||
{
|
||||
|
||||
@Override
|
||||
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package tconstruct.util.landmine.behavior;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityTNTPrimed;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*/
|
||||
public class BehaviorExplosive extends Behavior
|
||||
{
|
||||
|
||||
@Override
|
||||
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
|
||||
{
|
||||
float explodeStrenght = 0;
|
||||
if (par5ItemStack.itemID == Block.tnt.blockID)
|
||||
{
|
||||
explodeStrenght = 4.0F * par5ItemStack.stackSize;
|
||||
}
|
||||
else if (par5ItemStack.itemID == Item.gunpowder.itemID)
|
||||
{
|
||||
explodeStrenght = 0.8F * par5ItemStack.stackSize;
|
||||
}
|
||||
|
||||
par1World.createExplosion(new EntityTNTPrimed(par1World, par2, par3, par4, (EntityLivingBase) null), par2, par3, par4, explodeStrenght, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getInformation (ItemStack par1ItemStack, List par2List)
|
||||
{
|
||||
String str = "UNDEFINED";
|
||||
if (par1ItemStack.itemID == Block.tnt.blockID)
|
||||
{
|
||||
str = "medium";
|
||||
}
|
||||
else if (par1ItemStack.itemID == Item.gunpowder.itemID)
|
||||
{
|
||||
str = "small";
|
||||
}
|
||||
|
||||
//par2List.add("This item explodes with " + str + " power when the landmine is triggered.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
//Change this to false to greatly decrease the maximum potential of explosions but at the same time, make them launch the player much higher(I mean the explosions with 2 or more TNT
|
||||
public boolean effectStacks ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package tconstruct.util.landmine.behavior;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import tconstruct.items.blocks.ItemBlockLandmine;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.projectile.EntitySmallFireball;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*/
|
||||
public class BehaviorFirecharge extends Behavior
|
||||
{
|
||||
|
||||
@Override
|
||||
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
|
||||
{
|
||||
EnumFacing face = getFacing(par1World, par2, par3, par4);
|
||||
|
||||
for (int n = 0; n < par5ItemStack.stackSize; n++)
|
||||
{
|
||||
triggerer.attackEntityFrom(DamageSource.generic, 9F);
|
||||
triggerer.setFire(4);
|
||||
double d0 = par2 + (double) ((float) face.getFrontOffsetX() * 0.3F);
|
||||
double d1 = par3 + (double) ((float) face.getFrontOffsetX() * 0.3F);
|
||||
double d2 = par4 + (double) ((float) face.getFrontOffsetZ() * 0.3F);
|
||||
Random random = par1World.rand;
|
||||
double d3 = random.nextGaussian() * 0.05D + (double) face.getFrontOffsetX();
|
||||
double d4 = random.nextGaussian() * 0.05D + (double) face.getFrontOffsetY();
|
||||
double d5 = random.nextGaussian() * 0.05D + (double) face.getFrontOffsetZ();
|
||||
par1World.spawnEntityInWorld(new EntitySmallFireball(par1World, d0, d1, d2, d3, d4, d5));
|
||||
|
||||
for (int i = par2 - 2; i <= (par2 + 2); i++)
|
||||
{
|
||||
for (int j = par4 - 2; j <= (par4 + 2); j++)
|
||||
{
|
||||
if ((par1World.getBlockId(i, par3, j) == 0 || (Block.blocksList[par1World.getBlockId(i, par3, j)] != null && Block.blocksList[par1World.getBlockId(i, par3, j)].isBlockReplaceable(
|
||||
par1World, i, par3, j))) && ItemBlockLandmine.getRandom().nextInt(5) == 0 && Block.fire.canPlaceBlockAt(par1World, i, par3, j))
|
||||
{
|
||||
par1World.setBlock(i, par3, j, Block.fire.blockID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package tconstruct.util.landmine.behavior;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.entity.item.EntityLandmineFirework;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*/
|
||||
public class BehaviorFirework extends Behavior
|
||||
{
|
||||
|
||||
@Override
|
||||
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
|
||||
{
|
||||
EnumFacing facing = getFacing(par1World, par2, par3, par4);
|
||||
|
||||
for (int i = 0; i < par5ItemStack.stackSize; i++)
|
||||
{
|
||||
//TODO entity registration and stuffs
|
||||
EntityLandmineFirework entityfireworkrocket = new EntityLandmineFirework(par1World, (double) par2, (double) par3, (double) par4, par5ItemStack, facing.ordinal())
|
||||
.setRider(i == 0 ? triggerer : null);
|
||||
par1World.spawnEntityInWorld(entityfireworkrocket);
|
||||
|
||||
boolean shouldRun = true;
|
||||
if (triggerer instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) triggerer;
|
||||
if (player.capabilities.isCreativeMode)
|
||||
{
|
||||
// Remove the bellow comment to make the player in creative
|
||||
// mode not get launched
|
||||
// shouldRun = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldRun)
|
||||
{
|
||||
triggerer.mountEntity(entityfireworkrocket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean overridesDefault ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package tconstruct.util.landmine.behavior;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.items.blocks.ItemBlockLandmine;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityPotion;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemPotion;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*/
|
||||
public class BehaviorPotion extends Behavior
|
||||
{
|
||||
|
||||
@Override
|
||||
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
|
||||
{
|
||||
if (ItemPotion.isSplash(par5ItemStack.getItemDamage()))
|
||||
{
|
||||
par1World.playSoundAtEntity(triggerer, "random.bow", 0.5F, 0.4F / (ItemBlockLandmine.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
if (triggerer instanceof EntityLivingBase)
|
||||
{
|
||||
par1World.spawnEntityInWorld(new EntityPotion(par1World, (EntityLivingBase) triggerer, par5ItemStack));
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.spawnEntityInWorld(new EntityPotion(par1World, par2, par3, par4, par5ItemStack));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (triggerer instanceof EntityPlayer)
|
||||
{
|
||||
Item.potion.onEaten(par5ItemStack, par1World, (EntityPlayer) triggerer);
|
||||
}
|
||||
else if (triggerer instanceof EntityLivingBase)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
List list = Item.potion.getEffects(par5ItemStack);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
Iterator iterator = list.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
PotionEffect potioneffect = (PotionEffect) iterator.next();
|
||||
((EntityLivingBase) triggerer).addPotionEffect(new PotionEffect(potioneffect));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package tconstruct.util.landmine.behavior;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BehaviorPreventExplode extends Behavior
|
||||
{
|
||||
|
||||
@Override
|
||||
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBehaviorExchangableWithOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesBehaviorPreventRemovalOfBlock (ItemStack par1ItemStack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldItemBeRemoved (ItemStack par1ItemStack, boolean willBlockBeRemoved)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package tconstruct.util.landmine.behavior;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.IProjectile;
|
||||
import net.minecraft.entity.item.EntityEnderPearl;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.entity.projectile.EntitySnowball;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*/
|
||||
public class BehaviorProjectile extends Behavior
|
||||
{
|
||||
|
||||
@Override
|
||||
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
|
||||
{
|
||||
IProjectile entity = null;
|
||||
|
||||
EnumFacing enumfacing = getFacing(par1World, par2, par3, par4);
|
||||
|
||||
if (par5ItemStack.itemID == Item.arrow.itemID)
|
||||
{
|
||||
entity = new EntityArrow(par1World, par2, par3, par4);
|
||||
((EntityArrow) entity).canBePickedUp = 1;
|
||||
}
|
||||
else if (par5ItemStack.itemID == Item.snowball.itemID)
|
||||
{
|
||||
entity = new EntitySnowball(par1World, par2, par3, par4);
|
||||
}
|
||||
else if (par5ItemStack.itemID == Item.enderPearl.itemID)
|
||||
{
|
||||
if (triggerer instanceof EntityLivingBase)
|
||||
{
|
||||
entity = new EntityEnderPearl(par1World, (EntityLivingBase) triggerer);
|
||||
((EntityEnderPearl) entity).setPosition(par2, par3, par4);
|
||||
}
|
||||
else
|
||||
{
|
||||
entity = new EntityEnderPearl(par1World, par2, par3, par4);
|
||||
}
|
||||
}
|
||||
|
||||
if (entity == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
entity.setThrowableHeading((double) enumfacing.getFrontOffsetX(), (double) ((float) enumfacing.getFrontOffsetY() + 0.1F), (double) enumfacing.getFrontOffsetZ(), 1.1F, 6.0F);
|
||||
par1World.spawnEntityInWorld((Entity) entity);
|
||||
par1World.playAuxSFX(1002, par2, par3, par4, 0);
|
||||
}
|
||||
|
||||
//Projectiles: snowballs, arrows
|
||||
|
||||
@Override
|
||||
public boolean isOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package tconstruct.util.landmine.behavior;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import tconstruct.items.blocks.ItemBlockLandmine;
|
||||
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IShearable;
|
||||
|
||||
//TODO Add a block that is similar to landmine, but only triggers by redstone, does not hurt the player, and does not disappear when used(also does not do anything that can deal damage)
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*/
|
||||
public class BehaviorShears extends Behavior
|
||||
{
|
||||
|
||||
@Override
|
||||
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
|
||||
{
|
||||
Random rand = ItemBlockLandmine.getRandom();
|
||||
|
||||
List<IShearable> sheeps = par1World.getEntitiesWithinAABB(IShearable.class, AxisAlignedBB.getAABBPool().getAABB(par2 - 2, par3 - 2, par4 - 2, par2 + 2, par3 + 2, par4 + 2));
|
||||
|
||||
if (sheeps != null && !sheeps.isEmpty())
|
||||
{
|
||||
Iterator<IShearable> i1 = sheeps.iterator();
|
||||
IShearable sheep;
|
||||
while (i1.hasNext())
|
||||
{
|
||||
sheep = i1.next();
|
||||
if (sheep.isShearable(par5ItemStack, par1World, par2, par3, par4))
|
||||
{
|
||||
if (rand.nextInt(2) == 0)
|
||||
{
|
||||
ArrayList<ItemStack> drops = sheep.onSheared(par5ItemStack, par1World, par2, par3, par4, EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, par5ItemStack));
|
||||
if (sheep instanceof EntityLivingBase)
|
||||
{
|
||||
par5ItemStack.damageItem(1, (EntityLivingBase) sheep);
|
||||
}
|
||||
Iterator<ItemStack> i2 = drops.iterator();
|
||||
while (i2.hasNext())
|
||||
{
|
||||
if (sheep instanceof Entity)
|
||||
{
|
||||
Entity ent = (Entity) sheep;
|
||||
dropItem(par1World, (int) ent.posX, (int) ent.posY, (int) ent.posZ, i2.next());
|
||||
}
|
||||
else
|
||||
{
|
||||
dropItem(par1World, par2, par3, par4, i2.next());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (willBlockBeRemoved)
|
||||
{
|
||||
dropItem(par1World, par2, par3, par4, par5ItemStack);
|
||||
}
|
||||
}
|
||||
|
||||
protected void dropItem (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack)
|
||||
{
|
||||
if (!par1World.isRemote && par1World.getGameRules().getGameRuleBooleanValue("doTileDrops"))
|
||||
{
|
||||
float f = 0.7F;
|
||||
double d0 = (double) (par1World.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
|
||||
double d1 = (double) (par1World.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
|
||||
double d2 = (double) (par1World.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
|
||||
EntityItem entityitem = new EntityItem(par1World, (double) par2 + d0, (double) par3 + d1, (double) par4 + d2, par5ItemStack);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
par1World.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
|
||||
//Shear some sheep around a small area
|
||||
|
||||
@Override
|
||||
public boolean shouldItemBeRemoved (ItemStack par1ItemStack, boolean willBlockBeRemoved)
|
||||
{
|
||||
return willBlockBeRemoved;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean effectStacks ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package tconstruct.util.landmine.behavior;
|
||||
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemMonsterPlacer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*/
|
||||
public class BehaviorSpawnEgg extends Behavior
|
||||
{
|
||||
|
||||
@Override
|
||||
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
|
||||
{
|
||||
EnumFacing enumfacing = getFacing(par1World, par2, par3, par4);
|
||||
double d0 = par2 + Math.random() + (double) enumfacing.getFrontOffsetX();
|
||||
double d1 = (double) ((float) par3 + 0.2F);
|
||||
double d2 = par4 + Math.random() + (double) enumfacing.getFrontOffsetZ();
|
||||
Entity entity = ItemMonsterPlacer.spawnCreature(par1World, par5ItemStack.getItemDamage(), d0, d1, d2);
|
||||
|
||||
if (entity instanceof EntityLivingBase && par5ItemStack.hasDisplayName())
|
||||
{
|
||||
((EntityLiving) entity).setCustomNameTag(par5ItemStack.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean effectStacks ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOffensive (ItemStack par1ItemStack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package tconstruct.util.landmine.behavior.stackCombo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.blocks.logic.TileEntityLandmine;
|
||||
import tconstruct.util.landmine.Helper;
|
||||
import tconstruct.util.landmine.behavior.Behavior;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*/
|
||||
public abstract class SpecialStackHandler
|
||||
{
|
||||
|
||||
public static ArrayList<SpecialStackHandler> handlers = new ArrayList<SpecialStackHandler>();
|
||||
|
||||
public static void registerBuiltInStackHandlers ()
|
||||
{
|
||||
addSpecialBehavior(new SpecialStackHandlerRocketFireball());
|
||||
}
|
||||
|
||||
public static void addSpecialBehavior (SpecialStackHandler handler)
|
||||
{
|
||||
if (!handlers.contains(handler))
|
||||
{
|
||||
handlers.add(handler);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void checkStack (World par1World, int par2, int par3, int par4, Entity triggerer, ArrayList<ItemStack> stacks);
|
||||
|
||||
public EnumFacing getFacing (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
ForgeDirection dir = Helper.convertMetaToForgeOrientation(par1World.getBlockMetadata(par2, par3, par4));
|
||||
|
||||
switch (dir)
|
||||
{
|
||||
case DOWN:
|
||||
return EnumFacing.UP;
|
||||
case UP:
|
||||
return EnumFacing.DOWN;
|
||||
case WEST:
|
||||
return EnumFacing.WEST;
|
||||
case EAST:
|
||||
return EnumFacing.EAST;
|
||||
case SOUTH:
|
||||
return EnumFacing.NORTH;
|
||||
case NORTH:
|
||||
return EnumFacing.SOUTH;
|
||||
default:
|
||||
return EnumFacing.UP;
|
||||
}
|
||||
}
|
||||
|
||||
public final void removeItemFromInventory (World par1World, int x, int y, int z, ItemStack item)
|
||||
{
|
||||
if (item == null || item.stackSize <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TileEntityLandmine tileEntity = (TileEntityLandmine) par1World.getBlockTileEntity(x, y, z);
|
||||
|
||||
while (item.stackSize > 0)
|
||||
{
|
||||
boolean hasRemovedThisIteration = false;
|
||||
for (int i = 0; i < tileEntity.getSizeTriggerInventory(); i++)
|
||||
{
|
||||
if (!hasRemovedThisIteration && tileEntity.getStackInSlot(i) != null)
|
||||
{
|
||||
if (tileEntity.getStackInSlot(i).isItemEqual(item))
|
||||
{
|
||||
tileEntity.decrStackSize(i, 1);
|
||||
item.stackSize--;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasRemovedThisIteration && i == tileEntity.getSizeTriggerInventory() - 1)
|
||||
{
|
||||
item.stackSize--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final int arrayIndexOfStack (ArrayList<ItemStack> stacks, ItemStack item)
|
||||
{
|
||||
return Behavior.arrayIndexOfStack(stacks, item);
|
||||
}
|
||||
|
||||
public static final boolean arrayContainsEqualStack (ArrayList<ItemStack> stacks, ItemStack item)
|
||||
{
|
||||
return Behavior.arrayContainsEqualStack(stacks, item);
|
||||
}
|
||||
|
||||
public boolean isOffensive (ArrayList<ItemStack> par1ArrayList)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
package tconstruct.util.landmine.behavior.stackCombo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityFireball;
|
||||
import net.minecraft.entity.projectile.EntityLargeFireball;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class SpecialStackHandlerRocketFireball extends SpecialStackHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public void checkStack (World par1World, int par2, int par3, int par4, Entity triggerer, ArrayList<ItemStack> stacks)
|
||||
{
|
||||
if (stacks.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.arrayContainsEqualStack(stacks, new ItemStack(Item.firework)) && this.arrayContainsEqualStack(stacks, new ItemStack(Item.fireballCharge)))
|
||||
{
|
||||
int index0 = this.arrayIndexOfStack(stacks, new ItemStack(Item.firework));
|
||||
int index1 = this.arrayIndexOfStack(stacks, new ItemStack(Item.fireballCharge));
|
||||
EnumFacing face = getFacing(par1World, par2, par3, par4);
|
||||
|
||||
while (stacks.get(index0).stackSize > 0 && stacks.get(index1).stackSize > 0)
|
||||
{
|
||||
double d0 = par2 + (double) ((float) face.getFrontOffsetX() * 0.3F);
|
||||
double d1 = par3 + (double) ((float) face.getFrontOffsetX() * 0.3F);
|
||||
double d2 = par4 + (double) ((float) face.getFrontOffsetZ() * 0.3F);
|
||||
Random random = par1World.rand;
|
||||
double d3 = random.nextGaussian() * 0.05D + (double) face.getFrontOffsetX();
|
||||
double d4 = random.nextGaussian() * 0.05D + (double) face.getFrontOffsetY();
|
||||
double d5 = random.nextGaussian() * 0.05D + (double) face.getFrontOffsetZ();
|
||||
EntityFireball fireball = new EntityLargeFireball(par1World, d0, d1, d2, d3, d4, d5);
|
||||
par1World.spawnEntityInWorld(fireball);
|
||||
|
||||
if (triggerer instanceof EntityLivingBase)
|
||||
{
|
||||
boolean shouldRun = true;
|
||||
if (triggerer instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) triggerer;
|
||||
if (player.capabilities.isCreativeMode)
|
||||
{
|
||||
// Remove the bellow comment to make the player in
|
||||
// creative mode not get launched
|
||||
// shouldRun = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldRun)
|
||||
{
|
||||
triggerer.mountEntity(fireball);
|
||||
}
|
||||
}
|
||||
|
||||
this.removeItemFromInventory(par1World, par2, par3, par4, new ItemStack(Item.firework, 1));
|
||||
stacks.get(index0).stackSize--;
|
||||
this.removeItemFromInventory(par1World, par2, par3, par4, new ItemStack(Item.fireballCharge, 1));
|
||||
stacks.get(index1).stackSize--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
package tconstruct.util.network;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.SmelteryLogic;
|
||||
import tconstruct.blocks.logic.ToolForgeLogic;
|
||||
import tconstruct.blocks.logic.ToolStationLogic;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.IPacketHandler;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class TPacketHandler implements IPacketHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onPacketData (INetworkManager manager, Packet250CustomPayload packet, Player player)
|
||||
{
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
|
||||
if (packet.channel.equals("TConstruct"))
|
||||
{
|
||||
if (side == Side.SERVER)
|
||||
handleServerPacket(packet, (EntityPlayerMP) player);
|
||||
else
|
||||
handleClientPacket(packet, (EntityPlayer) player);
|
||||
}
|
||||
}
|
||||
|
||||
void handleClientPacket (Packet250CustomPayload packet, EntityPlayer player)
|
||||
{
|
||||
DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));
|
||||
|
||||
byte packetID;
|
||||
|
||||
try
|
||||
{
|
||||
packetID = inputStream.readByte();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TConstruct.logger.warning("Failed at reading client packet for TConstruct.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
void handleServerPacket (Packet250CustomPayload packet, EntityPlayerMP player)
|
||||
{
|
||||
DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));
|
||||
|
||||
byte packetID;
|
||||
|
||||
try
|
||||
{
|
||||
packetID = inputStream.readByte();
|
||||
|
||||
if (packetID == 1) //Tool Station
|
||||
{
|
||||
int dimension = inputStream.readInt();
|
||||
World world = DimensionManager.getWorld(dimension);
|
||||
int x = inputStream.readInt();
|
||||
int y = inputStream.readInt();
|
||||
int z = inputStream.readInt();
|
||||
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
String toolName = inputStream.readUTF();
|
||||
if (te instanceof ToolStationLogic)
|
||||
{
|
||||
((ToolStationLogic) te).setToolname(toolName);
|
||||
}
|
||||
if (te instanceof ToolForgeLogic)
|
||||
{
|
||||
((ToolForgeLogic) te).setToolname(toolName);
|
||||
}
|
||||
}
|
||||
else if (packetID == 2) //Stencil Table
|
||||
{
|
||||
int dimension = inputStream.readInt();
|
||||
World world = DimensionManager.getWorld(dimension);
|
||||
int x = inputStream.readInt();
|
||||
int y = inputStream.readInt();
|
||||
int z = inputStream.readInt();
|
||||
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
Short itemID = inputStream.readShort();
|
||||
Short itemDamage = inputStream.readShort();
|
||||
if (te instanceof InventoryLogic)
|
||||
{
|
||||
((InventoryLogic) te).setInventorySlotContents(1, new ItemStack(itemID, 1, itemDamage));
|
||||
}
|
||||
}
|
||||
|
||||
else if (packetID == 3) //Armor
|
||||
{
|
||||
//String user = inputStream.readUTF();
|
||||
//EntityPlayer player = TConstruct.playerTracker.getEntityPlayer(user);
|
||||
switch (inputStream.readByte())
|
||||
{
|
||||
case 0:
|
||||
player.openGui(TConstruct.instance, TConstruct.proxy.inventoryGui, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
break;
|
||||
case 1:
|
||||
player.openGui(TConstruct.instance, TConstruct.proxy.armorGuiID, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
break;
|
||||
case 2:
|
||||
player.openGui(TConstruct.instance, TConstruct.proxy.knapsackGuiID, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else if (packetID == 10) //Double jump
|
||||
{
|
||||
//String user = inputStream.readUTF();
|
||||
//EntityPlayer player = TConstruct.playerTracker.getEntityPlayer(user);
|
||||
player.fallDistance = 0;
|
||||
}
|
||||
|
||||
else if (packetID == 11) //Smeltery
|
||||
{
|
||||
int dimension = inputStream.readInt();
|
||||
World world = DimensionManager.getWorld(dimension);
|
||||
int x = inputStream.readInt();
|
||||
int y = inputStream.readInt();
|
||||
int z = inputStream.readInt();
|
||||
|
||||
boolean isShiftPressed = inputStream.readBoolean();
|
||||
int fluidID = inputStream.readInt();
|
||||
|
||||
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (te instanceof SmelteryLogic)
|
||||
{
|
||||
FluidStack temp = null;
|
||||
|
||||
for (FluidStack liquid : ((SmelteryLogic) te).moltenMetal)
|
||||
{
|
||||
if (liquid.fluidID == fluidID)
|
||||
{
|
||||
temp = liquid;
|
||||
}
|
||||
}
|
||||
|
||||
if (temp != null)
|
||||
{
|
||||
((SmelteryLogic) te).moltenMetal.remove(temp);
|
||||
if (isShiftPressed)
|
||||
((SmelteryLogic) te).moltenMetal.add(temp);
|
||||
else
|
||||
((SmelteryLogic) te).moltenMetal.add(0, temp);
|
||||
}
|
||||
PacketDispatcher.sendPacketToAllInDimension(te.getDescriptionPacket(), dimension);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
TConstruct.logger.warning("Failed at reading server packet for TConstruct.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Entity getEntity (World world, int id)
|
||||
{
|
||||
for (Object o : world.loadedEntityList)
|
||||
{
|
||||
if (((Entity) o).entityId == id)
|
||||
return (Entity) o;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,287 @@
|
||||
package tconstruct.util.player;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeInstance;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.common.TContent;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class ArmorExtended implements IInventory
|
||||
{
|
||||
public ItemStack[] inventory = new ItemStack[7];
|
||||
public WeakReference<EntityPlayer> parent;
|
||||
public UUID globalID = UUID.fromString("B243BE32-DC1B-4C53-8D13-8752D5C69D5B");
|
||||
|
||||
public void init (EntityPlayer player)
|
||||
{
|
||||
parent = new WeakReference<EntityPlayer>(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory ()
|
||||
{
|
||||
return inventory.length;
|
||||
}
|
||||
|
||||
public boolean isStackInSlot (int slot)
|
||||
{
|
||||
return inventory[slot] != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot (int slot)
|
||||
{
|
||||
return inventory[slot];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize (int slot, int quantity)
|
||||
{
|
||||
if (inventory[slot] != null)
|
||||
{
|
||||
//TConstruct.logger.info("Took something from slot " + slot);
|
||||
if (inventory[slot].stackSize <= quantity)
|
||||
{
|
||||
ItemStack stack = inventory[slot];
|
||||
inventory[slot] = null;
|
||||
return stack;
|
||||
}
|
||||
ItemStack split = inventory[slot].splitStack(quantity);
|
||||
if (inventory[slot].stackSize == 0)
|
||||
{
|
||||
inventory[slot] = null;
|
||||
}
|
||||
EntityPlayer player = parent.get();
|
||||
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username);
|
||||
recalculateHealth(player, stats);
|
||||
return split;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing (int slot)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack itemstack)
|
||||
{
|
||||
inventory[slot] = itemstack;
|
||||
//TConstruct.logger.info("Changed slot " + slot + " on side " + FMLCommonHandler.instance().getEffectiveSide());
|
||||
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit())
|
||||
{
|
||||
itemstack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
|
||||
EntityPlayer player = parent.get();
|
||||
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username);
|
||||
recalculateHealth(player, stats);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName ()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvNameLocalized ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit ()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryChanged ()
|
||||
{
|
||||
EntityPlayer player = parent.get();
|
||||
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username);
|
||||
//recalculateSkills(player, stats);
|
||||
recalculateHealth(player, stats);
|
||||
|
||||
/*if (inventory[2] == null && stats.knapsack != null)
|
||||
{
|
||||
stats.knapsack.unequipItems();
|
||||
}*/
|
||||
}
|
||||
|
||||
/*public void recalculateSkills(EntityPlayer player, TPlayerStats stats)
|
||||
{
|
||||
if (inventory[1] != null && inventory[1].getItem() == TContent.glove)
|
||||
{
|
||||
if (stats.skillList.size() < 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
stats.skillList.add(SkillRegistry.skills.get("Wall Building").copy());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (stats.skillList.size() > 0)
|
||||
{
|
||||
stats.skillList.remove(0);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
public void recalculateHealth (EntityPlayer player, TPlayerStats stats)
|
||||
{
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
|
||||
if (inventory[6] != null && inventory[6].getItem() == TContent.heartCanister)
|
||||
{
|
||||
ItemStack stack = inventory[6];
|
||||
int meta = stack.getItemDamage();
|
||||
//TConstruct.logger.info("Calculating HP on side " + FMLCommonHandler.instance().getEffectiveSide());
|
||||
if (meta == 2)
|
||||
{
|
||||
int prevHealth = stats.bonusHealth;
|
||||
if (side == Side.CLIENT)
|
||||
prevHealth = stats.bonusHealthClient;
|
||||
|
||||
int bonusHP = stack.stackSize * 2;
|
||||
if (side == Side.CLIENT)
|
||||
stats.bonusHealthClient = bonusHP;
|
||||
else
|
||||
stats.bonusHealth = bonusHP;
|
||||
|
||||
int healthChange = bonusHP - prevHealth;
|
||||
//TConstruct.logger.info("healthChange: "+healthChange+" on side "+FMLCommonHandler.instance().getEffectiveSide());
|
||||
if (healthChange != 0)
|
||||
{
|
||||
AttributeInstance attributeinstance = player.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.maxHealth);
|
||||
try
|
||||
{
|
||||
attributeinstance.removeModifier(attributeinstance.getModifier(globalID));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
attributeinstance.applyModifier(new AttributeModifier(globalID, "tconstruct.heartCanister", bonusHP, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (parent != null && parent.get() != null)
|
||||
{
|
||||
int prevHealth = stats.bonusHealth;
|
||||
if (side == Side.CLIENT)
|
||||
prevHealth = stats.bonusHealthClient;
|
||||
int bonusHP = 0;
|
||||
if (side == Side.CLIENT)
|
||||
stats.bonusHealthClient = bonusHP;
|
||||
else
|
||||
stats.bonusHealth = bonusHP;
|
||||
int healthChange = bonusHP - prevHealth;
|
||||
if (healthChange != 0)
|
||||
{
|
||||
AttributeInstance attributeinstance = player.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.maxHealth);
|
||||
try
|
||||
{
|
||||
attributeinstance.removeModifier(attributeinstance.getModifier(globalID));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer (EntityPlayer entityplayer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void openChest ()
|
||||
{
|
||||
}
|
||||
|
||||
public void closeChest ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot (int slot, ItemStack itemstack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Save/Load */
|
||||
public void saveToNBT (EntityPlayer entityplayer)
|
||||
{
|
||||
NBTTagCompound tags = entityplayer.getEntityData();
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
NBTTagCompound invSlot;
|
||||
|
||||
for (int i = 0; i < this.inventory.length; ++i)
|
||||
{
|
||||
if (this.inventory[i] != null)
|
||||
{
|
||||
invSlot = new NBTTagCompound();
|
||||
invSlot.setByte("Slot", (byte) i);
|
||||
this.inventory[i].writeToNBT(invSlot);
|
||||
tagList.appendTag(invSlot);
|
||||
}
|
||||
}
|
||||
|
||||
tags.setTag("TConstruct.Inventory", tagList);
|
||||
}
|
||||
|
||||
public void readFromNBT (EntityPlayer entityplayer)
|
||||
{
|
||||
NBTTagCompound tags = entityplayer.getEntityData();
|
||||
NBTTagList tagList = tags.getTagList("TConstruct.Inventory");
|
||||
for (int i = 0; i < tagList.tagCount(); ++i)
|
||||
{
|
||||
NBTTagCompound nbttagcompound = (NBTTagCompound) tagList.tagAt(i);
|
||||
int j = nbttagcompound.getByte("Slot") & 255;
|
||||
ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttagcompound);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
this.inventory[j] = itemstack;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void dropItems ()
|
||||
{
|
||||
EntityPlayer player = parent.get();
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
if (this.inventory[i] != null)
|
||||
{
|
||||
player.dropPlayerItemWithRandomChoice(this.inventory[i], true);
|
||||
this.inventory[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package tconstruct.util.player;
|
||||
|
||||
public class ArmorExtendedClient extends ArmorExtended
|
||||
{
|
||||
/*public void recalculateSkills(EntityPlayer player, TPlayerStats stats)
|
||||
{
|
||||
TConstruct.logger.info("Client skills");
|
||||
if (inventory[1] != null && inventory[1].getItem() == TContent.glove)
|
||||
{
|
||||
if (TProxyClient.skillList.size() < 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
TProxyClient.skillList.add(SkillRegistry.skills.get("Wall Building").copy());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TProxyClient.skillList.size() > 0)
|
||||
{
|
||||
TProxyClient.skillList.remove(0);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
package tconstruct.util.player;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
public class KnapsackInventory implements IInventory
|
||||
{
|
||||
public ItemStack[] inventory = new ItemStack[27];
|
||||
public WeakReference<EntityPlayer> parent;
|
||||
|
||||
public void init (EntityPlayer player)
|
||||
{
|
||||
parent = new WeakReference<EntityPlayer>(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot (int slot)
|
||||
{
|
||||
return inventory[slot];
|
||||
}
|
||||
|
||||
public boolean isStackInSlot (int slot)
|
||||
{
|
||||
return inventory[slot] != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory ()
|
||||
{
|
||||
return inventory.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit ()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
public boolean canDropInventorySlot (int slot)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack itemstack)
|
||||
{
|
||||
inventory[slot] = itemstack;
|
||||
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit())
|
||||
{
|
||||
itemstack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize (int slot, int quantity)
|
||||
{
|
||||
if (inventory[slot] != null)
|
||||
{
|
||||
if (inventory[slot].stackSize <= quantity)
|
||||
{
|
||||
ItemStack stack = inventory[slot];
|
||||
inventory[slot] = null;
|
||||
return stack;
|
||||
}
|
||||
ItemStack split = inventory[slot].splitStack(quantity);
|
||||
if (inventory[slot].stackSize == 0)
|
||||
{
|
||||
inventory[slot] = null;
|
||||
}
|
||||
return split;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName ()
|
||||
{
|
||||
return "tconstruct.knapsack";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvNameLocalized ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryChanged ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ItemStack getStackInSlotOnClosing (int slot)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public void openChest ()
|
||||
{
|
||||
}
|
||||
|
||||
public void closeChest ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot (int i, ItemStack itemstack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer (EntityPlayer entityplayer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Save/Load */
|
||||
public void saveToNBT (EntityPlayer entityplayer)
|
||||
{
|
||||
NBTTagCompound tags = entityplayer.getEntityData();
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
NBTTagCompound invSlot;
|
||||
|
||||
for (int i = 0; i < this.inventory.length; ++i)
|
||||
{
|
||||
if (this.inventory[i] != null)
|
||||
{
|
||||
invSlot = new NBTTagCompound();
|
||||
invSlot.setByte("Slot", (byte) i);
|
||||
this.inventory[i].writeToNBT(invSlot);
|
||||
tagList.appendTag(invSlot);
|
||||
}
|
||||
}
|
||||
|
||||
tags.setTag("TConstruct.Knapsack", tagList);
|
||||
}
|
||||
|
||||
public void readFromNBT (EntityPlayer entityplayer)
|
||||
{
|
||||
NBTTagCompound tags = entityplayer.getEntityData();
|
||||
NBTTagList tagList = tags.getTagList("TConstruct.Knapsack");
|
||||
for (int i = 0; i < tagList.tagCount(); ++i)
|
||||
{
|
||||
NBTTagCompound nbttagcompound = (NBTTagCompound) tagList.tagAt(i);
|
||||
int j = nbttagcompound.getByte("Slot") & 255;
|
||||
ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttagcompound);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
this.inventory[j] = itemstack;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void dropItems ()
|
||||
{
|
||||
EntityPlayer player = parent.get();
|
||||
for (int i = 0; i < inventory.length; ++i)
|
||||
{
|
||||
if (this.inventory[i] != null)
|
||||
{
|
||||
player.dropPlayerItemWithRandomChoice(this.inventory[i], true);
|
||||
this.inventory[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void unequipItems ()
|
||||
{
|
||||
EntityPlayer player = parent.get();
|
||||
for (int i = 0; i < inventory.length; ++i)
|
||||
{
|
||||
if (this.inventory[i] != null)
|
||||
{
|
||||
dropItemEntity(player, inventory[i]);
|
||||
this.inventory[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void dropItemEntity (Entity dropper, ItemStack dropStack)
|
||||
{
|
||||
EntityItem entityitem = new EntityItem(dropper.worldObj, dropper.posX, dropper.posY, dropper.posZ, dropStack);
|
||||
dropper.worldObj.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,324 @@
|
||||
package tconstruct.util.player;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EnumEntitySize;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.IPlayerTracker;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class TPlayerHandler implements IPlayerTracker
|
||||
{
|
||||
/* Player */
|
||||
//public int hunger;
|
||||
public ConcurrentHashMap<String, TPlayerStats> playerStats = new ConcurrentHashMap<String, TPlayerStats>();
|
||||
|
||||
@Override
|
||||
public void onPlayerLogin (EntityPlayer entityplayer)
|
||||
{
|
||||
//TConstruct.logger.info("Player: "+entityplayer);
|
||||
//Lookup player
|
||||
NBTTagCompound tags = entityplayer.getEntityData();
|
||||
if (!tags.hasKey("TConstruct"))
|
||||
{
|
||||
tags.setCompoundTag("TConstruct", new NBTTagCompound());
|
||||
}
|
||||
TPlayerStats stats = new TPlayerStats();
|
||||
stats.player = new WeakReference<EntityPlayer>(entityplayer);
|
||||
stats.armor = new ArmorExtended();
|
||||
stats.armor.init(entityplayer);
|
||||
stats.armor.readFromNBT(entityplayer);
|
||||
|
||||
stats.knapsack = new KnapsackInventory();
|
||||
stats.knapsack.init(entityplayer);
|
||||
stats.knapsack.readFromNBT(entityplayer);
|
||||
|
||||
stats.level = entityplayer.experienceLevel;
|
||||
stats.hunger = entityplayer.getFoodStats().getFoodLevel();
|
||||
stats.beginnerManual = tags.getCompoundTag("TConstruct").getBoolean("beginnerManual");
|
||||
stats.materialManual = tags.getCompoundTag("TConstruct").getBoolean("materialManual");
|
||||
stats.smelteryManual = tags.getCompoundTag("TConstruct").getBoolean("smelteryManual");
|
||||
//gamerule naturalRegeneration false
|
||||
if (!PHConstruct.enableHealthRegen)
|
||||
entityplayer.worldObj.getGameRules().setOrCreateGameRule("naturalRegeneration", "false");
|
||||
if (!stats.beginnerManual)
|
||||
{
|
||||
stats.beginnerManual = true;
|
||||
tags.getCompoundTag("TConstruct").setBoolean("beginnerManual", true);
|
||||
if (PHConstruct.beginnerBook)
|
||||
{
|
||||
ItemStack diary = new ItemStack(TContent.manualBook);
|
||||
if (!entityplayer.inventory.addItemStackToInventory(diary))
|
||||
{
|
||||
AbilityHelper.spawnItemAtPlayer(entityplayer, diary);
|
||||
}
|
||||
}
|
||||
|
||||
if (entityplayer.username.toLowerCase().equals("fudgy_fetus"))
|
||||
{
|
||||
ItemStack pattern = new ItemStack(TContent.woodPattern, 1, 22);
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setCompoundTag("display", new NBTTagCompound());
|
||||
compound.getCompoundTag("display").setString("Name", "\u00A7f" + "Fudgy_Fetus' Full Guard Pattern");
|
||||
NBTTagList list = new NBTTagList();
|
||||
list.appendTag(new NBTTagString("Lore", "\u00A72\u00A7o" + "The creator and the creation"));
|
||||
list.appendTag(new NBTTagString("Lore", "\u00A72\u00A7o" + "are united at last!"));
|
||||
compound.getCompoundTag("display").setTag("Lore", list);
|
||||
pattern.setTagCompound(compound);
|
||||
|
||||
AbilityHelper.spawnItemAtPlayer(entityplayer, pattern);
|
||||
}
|
||||
|
||||
if (entityplayer.username.toLowerCase().equals("zerokyuuni"))
|
||||
{
|
||||
ItemStack pattern = new ItemStack(Item.stick);
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setCompoundTag("display", new NBTTagCompound());
|
||||
compound.getCompoundTag("display").setString("Name", "\u00A78" + "Cheaty Inventory");
|
||||
NBTTagList list = new NBTTagList();
|
||||
list.appendTag(new NBTTagString("Lore", "\u00A72\u00A7o" + "Nyaa~"));
|
||||
compound.getCompoundTag("display").setTag("Lore", list);
|
||||
pattern.setTagCompound(compound);
|
||||
|
||||
AbilityHelper.spawnItemAtPlayer(entityplayer, pattern);
|
||||
}
|
||||
}
|
||||
|
||||
playerStats.put(entityplayer.username, stats);
|
||||
|
||||
if (PHConstruct.gregtech && Loader.isModLoaded("GregTech-Addon"))
|
||||
{
|
||||
PHConstruct.gregtech = false;
|
||||
if (PHConstruct.lavaFortuneInteraction)
|
||||
{
|
||||
entityplayer.addChatMessage("Warning: Cross-mod Exploit Present!");
|
||||
entityplayer.addChatMessage("Solution 1: Disable Reverse Smelting recipes from GregTech.");
|
||||
entityplayer.addChatMessage("Solution 2: Disable Auto-Smelt/Fortune interaction from TConstruct.");
|
||||
}
|
||||
}
|
||||
|
||||
updatePlayerInventory(entityplayer, stats);
|
||||
}
|
||||
|
||||
void updatePlayerInventory (EntityPlayer entityplayer, TPlayerStats stats)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void updateClientPlayer (ByteArrayOutputStream bos, EntityPlayer player)
|
||||
{
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
packet.channel = "TConstruct";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();
|
||||
|
||||
PacketDispatcher.sendPacketToPlayer(packet, (Player) player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerLogout (EntityPlayer entityplayer)
|
||||
{
|
||||
savePlayerStats(entityplayer, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerChangedDimension (EntityPlayer entityplayer)
|
||||
{
|
||||
savePlayerStats(entityplayer, false);
|
||||
}
|
||||
|
||||
void savePlayerStats (EntityPlayer player, boolean clean)
|
||||
{
|
||||
if (player != null)
|
||||
{
|
||||
TPlayerStats stats = getPlayerStats(player.username);
|
||||
if (stats != null && stats.armor != null)
|
||||
{
|
||||
stats.armor.saveToNBT(player);
|
||||
stats.knapsack.saveToNBT(player);
|
||||
if (clean)
|
||||
playerStats.remove(player.username);
|
||||
}
|
||||
else
|
||||
//Revalidate all players
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerRespawn (EntityPlayer entityplayer)
|
||||
{
|
||||
//Boom!
|
||||
TPlayerStats stats = getPlayerStats(entityplayer.username);
|
||||
stats.player = new WeakReference<EntityPlayer>(entityplayer);
|
||||
stats.armor.recalculateHealth(entityplayer, stats);
|
||||
|
||||
/*TFoodStats food = new TFoodStats();
|
||||
entityplayer.foodStats = food;*/
|
||||
|
||||
if (PHConstruct.keepLevels)
|
||||
entityplayer.experienceLevel = stats.level;
|
||||
if (PHConstruct.keepHunger)
|
||||
entityplayer.getFoodStats().addStats(-1 * (20 - stats.hunger), 0);
|
||||
NBTTagCompound tags = entityplayer.getEntityData();
|
||||
NBTTagCompound tTag = new NBTTagCompound();
|
||||
tTag.setBoolean("beginnerManual", stats.beginnerManual);
|
||||
tTag.setBoolean("materialManual", stats.materialManual);
|
||||
tTag.setBoolean("smelteryManual", stats.smelteryManual);
|
||||
tags.setCompoundTag("TConstruct", tTag);
|
||||
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if (side == Side.CLIENT)
|
||||
{
|
||||
//TProxyClient.controlInstance.resetControls();
|
||||
if (PHConstruct.keepHunger)
|
||||
entityplayer.getFoodStats().setFoodLevel(stats.hunger);
|
||||
}
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void livingFall (LivingFallEvent evt) //Only for negating fall damage
|
||||
{
|
||||
if (evt.entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
evt.distance -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*@ForgeSubscribe
|
||||
public void livingUpdate (LivingUpdateEvent evt)
|
||||
{
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if (side == Side.CLIENT && evt.entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) evt.entityLiving;
|
||||
TPlayerStats stats = playerStats.get(player.username);
|
||||
if (player.onGround != stats.prevOnGround)
|
||||
{
|
||||
if (player.onGround)// && -stats.prevMotionY > 0.1)
|
||||
//player.motionY = 0.5;
|
||||
player.motionY = -stats.prevMotionY * 0.8;
|
||||
//player.motionY *= -1.2;
|
||||
stats.prevOnGround = player.onGround;
|
||||
//if ()
|
||||
|
||||
//TConstruct.logger.info("Fall: "+player.fallDistance);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@ForgeSubscribe
|
||||
public void playerDrops (PlayerDropsEvent evt)
|
||||
{
|
||||
TPlayerStats stats = getPlayerStats(evt.entityPlayer.username);
|
||||
stats.level = evt.entityPlayer.experienceLevel / 2;
|
||||
//stats.health = 20;
|
||||
int hunger = evt.entityPlayer.getFoodStats().getFoodLevel();
|
||||
if (hunger < 6)
|
||||
stats.hunger = 6;
|
||||
else
|
||||
stats.hunger = evt.entityPlayer.getFoodStats().getFoodLevel();
|
||||
}
|
||||
|
||||
/* Find the right player */
|
||||
public TPlayerStats getPlayerStats (String username)
|
||||
{
|
||||
TPlayerStats stats = playerStats.get(username);
|
||||
//TConstruct.logger.info("Stats: "+stats);
|
||||
if (stats == null)
|
||||
{
|
||||
stats = new TPlayerStats();
|
||||
playerStats.put(username, stats);
|
||||
}
|
||||
return stats;
|
||||
}
|
||||
|
||||
public EntityPlayer getEntityPlayer (String username)
|
||||
{
|
||||
TPlayerStats stats = playerStats.get(username);
|
||||
if (stats == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return stats.player.get();
|
||||
}
|
||||
}
|
||||
|
||||
/* Modify Player */
|
||||
public void updateSize (String user, float offset)
|
||||
{
|
||||
/*EntityPlayer player = getEntityPlayer(user);
|
||||
setEntitySize(0.6F, offset, player);
|
||||
player.yOffset = offset - 0.18f;*/
|
||||
}
|
||||
|
||||
public static void setEntitySize (float width, float height, Entity entity)
|
||||
{
|
||||
//TConstruct.logger.info("Size: " + height);
|
||||
if (width != entity.width || height != entity.height)
|
||||
{
|
||||
entity.width = width;
|
||||
entity.height = height;
|
||||
entity.boundingBox.maxX = entity.boundingBox.minX + (double) entity.width;
|
||||
entity.boundingBox.maxZ = entity.boundingBox.minZ + (double) entity.width;
|
||||
entity.boundingBox.maxY = entity.boundingBox.minY + (double) entity.height;
|
||||
}
|
||||
|
||||
float que = width % 2.0F;
|
||||
|
||||
if ((double) que < 0.375D)
|
||||
{
|
||||
entity.myEntitySize = EnumEntitySize.SIZE_1;
|
||||
}
|
||||
else if ((double) que < 0.75D)
|
||||
{
|
||||
entity.myEntitySize = EnumEntitySize.SIZE_2;
|
||||
}
|
||||
else if ((double) que < 1.0D)
|
||||
{
|
||||
entity.myEntitySize = EnumEntitySize.SIZE_3;
|
||||
}
|
||||
else if ((double) que < 1.375D)
|
||||
{
|
||||
entity.myEntitySize = EnumEntitySize.SIZE_4;
|
||||
}
|
||||
else if ((double) que < 1.75D)
|
||||
{
|
||||
entity.myEntitySize = EnumEntitySize.SIZE_5;
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.myEntitySize = EnumEntitySize.SIZE_6;
|
||||
}
|
||||
//entity.yOffset = height;
|
||||
}
|
||||
|
||||
Random rand = new Random();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package tconstruct.util.player;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public class TPlayerStats
|
||||
{
|
||||
public WeakReference<EntityPlayer> player;
|
||||
public int level;
|
||||
public int bonusHealth;
|
||||
public int bonusHealthClient;
|
||||
public int hunger;
|
||||
public boolean beginnerManual;
|
||||
public boolean materialManual;
|
||||
public boolean smelteryManual;
|
||||
public ArmorExtended armor;
|
||||
public KnapsackInventory knapsack;
|
||||
}
|
||||
Reference in new issue
Block a user