Reorganize folders for modules

This commit is contained in:
mDiyo committed 2014-06-04 21:44:48 -08:00
1 parent 2c14f315de
commit e2f0558b6f
370 files changed
+4274 -4788

No files matched your search

@@ -0,0 +1,147 @@
package tconstruct.util;
import java.util.HashMap;
import java.util.List;
import net.minecraft.block.Block;
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 CraftingRecipeHelper
{
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--);
}
}
}
}
public static void addShapedRecipeFirst (List recipeList, ItemStack itemstack, Object... objArray)
{
String var3 = "";
int var4 = 0;
int var5 = 0;
int var6 = 0;
if (objArray[var4] instanceof String[])
{
String[] var7 = ((String[]) objArray[var4++]);
for (int var8 = 0; var8 < var7.length; ++var8)
{
String var9 = var7[var8];
++var6;
var5 = var9.length();
var3 = var3 + var9;
}
}
else
{
while (objArray[var4] instanceof String)
{
String var11 = (String) objArray[var4++];
++var6;
var5 = var11.length();
var3 = var3 + var11;
}
}
HashMap var12;
for (var12 = new HashMap(); var4 < objArray.length; var4 += 2)
{
Character var13 = (Character) objArray[var4];
ItemStack var14 = null;
if (objArray[var4 + 1] instanceof Item)
{
var14 = new ItemStack((Item) objArray[var4 + 1]);
}
else if (objArray[var4 + 1] instanceof Block)
{
var14 = new ItemStack((Block) objArray[var4 + 1], 1, Short.MAX_VALUE);
}
else if (objArray[var4 + 1] instanceof ItemStack)
{
var14 = (ItemStack) objArray[var4 + 1];
}
var12.put(var13, var14);
}
ItemStack[] var15 = new ItemStack[var5 * var6];
for (int var16 = 0; var16 < var5 * var6; ++var16)
{
char var10 = var3.charAt(var16);
if (var12.containsKey(Character.valueOf(var10)))
{
var15[var16] = ((ItemStack) var12.get(Character.valueOf(var10))).copy();
}
else
{
var15[var16] = null;
}
}
ShapedRecipes var17 = new ShapedRecipes(var5, var6, var15, itemstack);
recipeList.add(0, var17);
}
}
@@ -0,0 +1,33 @@
package tconstruct.util;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ShapedRecipes;
import tconstruct.TConstruct;
public class ItemHelper
{
public static Object getStaticItem (String name, String classPackage)
{
try
{
Class clazz = Class.forName(classPackage);
Field field = clazz.getDeclaredField(name);
Object ret = field.get(null);
if (ret != null && (ret instanceof ItemStack || ret instanceof Item))
return ret;
return null;
}
catch (Exception e)
{
TConstruct.logger.warn("Could not find " + name + "from " + classPackage);
return null;
}
}
}
@@ -1,70 +0,0 @@
package tconstruct.util;
import java.util.List;
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--);
}
}
}
}
}
@@ -5,8 +5,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.TConstruct;
import tconstruct.achievements.TAchievements;
import tconstruct.common.TRepo;
import tconstruct.library.tools.AbilityHelper;
import tconstruct.smeltery.TinkerSmeltery;
import tconstruct.tools.TinkerTools;
import tconstruct.util.player.TPlayerStats;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
@@ -22,31 +23,31 @@ public class TCraftingHandler // implements ICraftingHandler
Item item = event.crafting.getItem();
if (!event.player.worldObj.isRemote)
{
if (item == Item.getItemFromBlock(TRepo.toolStationWood))
if (item == Item.getItemFromBlock(TinkerTools.toolStationWood))
{
TPlayerStats stats = TPlayerStats.get(event.player);
if (!stats.materialManual)
{
stats.materialManual = true;
AbilityHelper.spawnItemAtPlayer(event.player, new ItemStack(TRepo.manualBook, 1, 1));
AbilityHelper.spawnItemAtPlayer(event.player, new ItemStack(TinkerTools.manualBook, 1, 1));
}
}
if (item == Item.getItemFromBlock(TRepo.smeltery) || item == Item.getItemFromBlock(TRepo.lavaTank))
if (item == Item.getItemFromBlock(TinkerSmeltery.smeltery) || item == Item.getItemFromBlock(TinkerSmeltery.lavaTank))
{
TPlayerStats stats = TPlayerStats.get(event.player);
if (!stats.smelteryManual)
{
stats.smelteryManual = true;
AbilityHelper.spawnItemAtPlayer(event.player, new ItemStack(TRepo.manualBook, 1, 2));
AbilityHelper.spawnItemAtPlayer(event.player, new ItemStack(TinkerTools.manualBook, 1, 2));
}
event.player.addStat(TAchievements.achievements.get("tconstruct:smelteryMaker"), 1);
}
if (item == Item.getItemFromBlock(TRepo.craftingStationWood))
if (item == Item.getItemFromBlock(TinkerTools.craftingStationWood))
{
event.player.addStat(TAchievements.achievements.get("tconstruct:betterCrafting"), 1);
}
else if (item == TRepo.blankPattern)
else if (item == TinkerTools.blankPattern)
{
event.player.addStat(TAchievements.achievements.get("tconstruct:pattern"), 1);
}
@@ -7,7 +7,7 @@ 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;
import tconstruct.tools.entity.ArrowEntity;
public class TDispenserBehaviorArrow extends BehaviorDefaultDispenseItem
{
@@ -6,7 +6,7 @@ import net.minecraft.dispenser.IBlockSource;
import net.minecraft.entity.EntityLiving;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import tconstruct.items.TitleIcon;
import tconstruct.tools.items.TitleIcon;
public class TDispenserBehaviorSpawnEgg extends BehaviorDefaultDispenseItem
{
@@ -52,10 +52,7 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
import net.minecraftforge.oredict.OreDictionary.OreRegisterEvent;
import tconstruct.TConstruct;
import tconstruct.achievements.TAchievements;
import tconstruct.blocks.LiquidMetalFinite;
import tconstruct.blocks.TankAirBlock;
import tconstruct.common.TRepo;
import tconstruct.entity.BlueSlime;
import tconstruct.armor.TinkerArmor;
import tconstruct.items.tools.FryingPan;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.event.PartBuilderEvent;
@@ -66,9 +63,15 @@ import tconstruct.library.tools.BowstringMaterial;
import tconstruct.library.tools.FletchingMaterial;
import tconstruct.library.tools.ToolCore;
import tconstruct.library.tools.Weapon;
import tconstruct.smeltery.TinkerSmeltery;
import tconstruct.smeltery.blocks.LiquidMetalFinite;
import tconstruct.smeltery.blocks.TankAirBlock;
import tconstruct.tools.TinkerTools;
import tconstruct.util.config.PHConstruct;
import tconstruct.util.player.ArmorExtended;
import tconstruct.util.player.TPlayerStats;
import tconstruct.world.TinkerWorld;
import tconstruct.world.entity.BlueSlime;
import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.common.eventhandler.Event.Result;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@@ -82,7 +85,7 @@ public class TEventHandler
public void craftTool (ToolCraftEvent.NormalTool event)
{
NBTTagCompound toolTag = event.toolTag.getCompoundTag("InfiTool");
if (PHConstruct.denyMattock && event.tool == TRepo.mattock)
if (PHConstruct.denyMattock && event.tool == TinkerTools.mattock)
{
int head = toolTag.getInteger("Head");
int handle = toolTag.getInteger("Handle");
@@ -118,7 +121,7 @@ public class TEventHandler
toolTag.setInteger("Modifiers", modifiers);
}
if (event.tool == TRepo.shortbow)
if (event.tool == TinkerTools.shortbow)
{
BowMaterial top = TConstructRegistry.getBowMaterial(toolTag.getInteger("Head"));
BowMaterial bottom = TConstructRegistry.getBowMaterial(toolTag.getInteger("Accessory"));
@@ -146,7 +149,7 @@ public class TEventHandler
}
}
if (event.tool == TRepo.arrow)
if (event.tool == TinkerTools.arrow)
{
ArrowMaterial head = TConstructRegistry.getArrowMaterial(toolTag.getInteger("Head"));
ArrowMaterial shaft = TConstructRegistry.getArrowMaterial(toolTag.getInteger("Handle"));
@@ -169,7 +172,7 @@ public class TEventHandler
}
}
if (event.tool == TRepo.battlesign)
if (event.tool == TinkerTools.battlesign)
{
int modifiers = toolTag.getInteger("Modifiers");
modifiers += 1;
@@ -191,7 +194,7 @@ public class TEventHandler
@SubscribeEvent
public void craftPart (PartBuilderEvent.NormalPart event)
{
if (event.pattern.getItem() == TRepo.woodPattern && event.pattern.getItemDamage() == 23)
if (event.pattern.getItem() == TinkerTools.woodPattern && event.pattern.getItemDamage() == 23)
{
ItemStack result = craftBowString(event.material);
if (result != null)
@@ -200,7 +203,7 @@ public class TEventHandler
}
}
if (event.pattern.getItem() == TRepo.woodPattern && event.pattern.getItemDamage() == 24)
if (event.pattern.getItem() == TinkerTools.woodPattern && event.pattern.getItemDamage() == 24)
{
ItemStack result = craftFletching(event.material);
if (result != null)
@@ -262,11 +265,11 @@ public class TEventHandler
if (stack != null && player.isUsingItem())
{
Item item = stack.getItem();
if (item == TRepo.cutlass)
if (item == TinkerTools.cutlass)
{
player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 3 * 20, 1));
}
else if (item == TRepo.battlesign)
else if (item == TinkerTools.battlesign)
{
event.ammount *= 1.5; //Puts battlesign blocking at 3/4 instead of 1/2
}
@@ -300,7 +303,7 @@ public class TEventHandler
EntityPlayer player = (EntityPlayer) event.entityLiving;
//Cutlass
ItemStack stack = player.getCurrentEquippedItem();
if (stack != null && stack.getItem() == TRepo.battlesign && player.isUsingItem())
if (stack != null && stack.getItem() == TinkerTools.battlesign && player.isUsingItem())
{
DamageSource source = event.source;
if (!source.isUnblockable() && !source.isMagicDamage() && !source.isExplosion())
@@ -389,7 +392,7 @@ public class TEventHandler
int count = event.entityLiving instanceof EntityDragon ? 5 : 1;
for (int i = 0; i < count; i++)
{
ItemStack dropStack = new ItemStack(TRepo.heartCanister, 1, 1);
ItemStack dropStack = new ItemStack(TinkerArmor.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);
@@ -398,7 +401,7 @@ public class TEventHandler
if (event.entityLiving instanceof IBossDisplayData)
{
ItemStack dropStack = new ItemStack(TRepo.heartCanister, 1, 3);
ItemStack dropStack = new ItemStack(TinkerArmor.heartCanister, 1, 3);
EntityItem entityitem = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, dropStack);
entityitem.delayBeforeCanPickup = 10;
event.drops.add(entityitem);
@@ -441,7 +444,7 @@ public class TEventHandler
if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore)
{
int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
if (stack.getItem() == TRepo.cleaver)
if (stack.getItem() == TinkerTools.cleaver)
beheading += 2;
if (beheading > 0 && random.nextInt(100) < beheading * 10)
{
@@ -451,7 +454,7 @@ public class TEventHandler
}
if (enemy.getSkeletonType() == 1 && random.nextInt(Math.max(1, 5 - event.lootingLevel)) == 0)
{
addDrops(event, new ItemStack(TRepo.materials, 1, 8));
addDrops(event, new ItemStack(TinkerTools.materials, 1, 8));
}
}
@@ -467,7 +470,7 @@ public class TEventHandler
if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore)
{
int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
if (stack != null && stack.hasTagCompound() && stack.getItem() == TRepo.cleaver)
if (stack != null && stack.hasTagCompound() && stack.getItem() == TinkerTools.cleaver)
beheading += 2;
if (beheading > 0 && random.nextInt(100) < beheading * 10)
{
@@ -475,7 +478,7 @@ public class TEventHandler
}
}
if (stack != null && stack.hasTagCompound() && stack.getItem() == TRepo.cleaver && random.nextInt(100) < 10) //Swap out for real beheading
if (stack != null && stack.hasTagCompound() && stack.getItem() == TinkerTools.cleaver && random.nextInt(100) < 10) //Swap out for real beheading
{
addDrops(event, new ItemStack(Items.skull, 1, 2));
}
@@ -494,7 +497,7 @@ public class TEventHandler
if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore)
{
int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
if (stack.getItem() == TRepo.cleaver)
if (stack.getItem() == TinkerTools.cleaver)
beheading += 2;
if (beheading > 0 && random.nextInt(100) < beheading * 5)
{
@@ -544,7 +547,7 @@ public class TEventHandler
if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore)
{
int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
if (stack.getItem() == TRepo.cleaver)
if (stack.getItem() == TinkerTools.cleaver)
beheading += 2;
if (beheading > 0 && random.nextInt(100) < beheading * 50)
{
@@ -622,9 +625,9 @@ public class TEventHandler
{
if (!event.world.isRemote)
{
if (event.block == TRepo.slimeSapling)
if (event.block == TinkerWorld.slimeSapling)
{
if (TRepo.slimeSapling.boneFertilize(event.world, event.x, event.y, event.z, event.world.rand, event.entityPlayer))
if (TinkerWorld.slimeSapling.boneFertilize(event.world, event.x, event.y, event.z, event.world.rand, event.entityPlayer))
event.setResult(Event.Result.ALLOW);
}
}
@@ -637,12 +640,12 @@ public class TEventHandler
if (evt.Name == "crystalQuartz")
{
TRepo.modAttack.addStackToMatchList(evt.Ore, 2);
TinkerTools.modAttack.addStackToMatchList(evt.Ore, 2);
}
else if (evt.Name == "crystalCerusQuartz")
{
TRepo.modAttack.addStackToMatchList(evt.Ore, 24);
TinkerTools.modAttack.addStackToMatchList(evt.Ore, 24);
}
}
@@ -661,9 +664,9 @@ public class TEventHandler
}
Block bID = evt.world.getBlock(hitX, hitY, hitZ);
for (int id = 0; id < TRepo.fluidBlocks.length; id++)
for (int id = 0; id < TinkerSmeltery.fluidBlocks.length; id++)
{
if (bID == TRepo.fluidBlocks[id])
if (bID == TinkerSmeltery.fluidBlocks[id])
{
if (evt.entityPlayer.capabilities.isCreativeMode)
{
@@ -671,7 +674,7 @@ public class TEventHandler
}
else
{
if (TRepo.fluidBlocks[id] instanceof LiquidMetalFinite)
if (TinkerSmeltery.fluidBlocks[id] instanceof LiquidMetalFinite)
{
WorldHelper.setBlockToAir(evt.world, hitX, hitY, hitZ);
/*
@@ -701,7 +704,7 @@ public class TEventHandler
}
evt.setResult(Result.ALLOW);
evt.result = new ItemStack(TRepo.buckets, 1, id);
evt.result = new ItemStack(TinkerSmeltery.buckets, 1, id);
}
}
}
@@ -1,16 +1,12 @@
package tconstruct.util;
import tconstruct.common.TRepo;
import mantle.event.ManualOpenEvent;
import net.minecraftforge.common.util.FakePlayer;
import tconstruct.achievements.TAchievements;
import tconstruct.blocks.logic.ToolForgeLogic;
import tconstruct.library.event.SmelteryEvent;
import tconstruct.library.event.ToolCraftedEvent;
import tconstruct.library.tools.ToolCore;
import tconstruct.library.tools.Weapon;
import tconstruct.tools.logic.ToolForgeLogic;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
public class TEventHandlerAchievement
@@ -4,8 +4,8 @@ import java.io.File;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import tconstruct.common.TRepo;
import tconstruct.library.tools.AbilityHelper;
import tconstruct.tools.TinkerTools;
import cpw.mods.fml.common.Loader;
public class PHConstruct
@@ -20,7 +20,7 @@ public class PHConstruct
config.load();
superfunWorld = config.get("Superfun", "All the world is Superfun", false).getBoolean(false);
TRepo.supressMissingToolLogs = config.get("Logging", "Disable tool build messages", false).getBoolean(false);
TinkerTools.supressMissingToolLogs = 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);
@@ -41,7 +41,6 @@ public class PHConstruct
lavaFortuneInteraction = config.get("Difficulty Changes", "Enable Auto-Smelt and Fortune interaction", true).getBoolean(true);
removeVanillaToolRecipes = config.get("Difficulty Changes", "Remove Vanilla Tool Recipes", false).getBoolean(false);
labotimizeVanillaTools = config.get("Difficulty Changes", "Remove Vanilla Tool Effectiveness", false).getBoolean(false);
stencilTableCrafting = config.get("Difficulty Changes", "Craft Stencil Tables", true).getBoolean(true);
miningLevelIncrease = config.get("Difficulty Changes", "Modifiers increase Mining Level", true).getBoolean(true);
denyMattock = config.get("Difficulty Changes", "Deny creation of non-metal mattocks", false).getBoolean(false);
craftEndstone = config.get("Difficulty Changes", "Allow creation of endstone", true).getBoolean(true);
@@ -281,7 +280,6 @@ public class PHConstruct
public static boolean vanillaMetalBlocks;
public static boolean removeVanillaToolRecipes;
public static boolean labotimizeVanillaTools;
public static boolean stencilTableCrafting;
public static boolean miningLevelIncrease;
public static boolean denyMattock;
@@ -1,76 +0,0 @@
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.util.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();
}
}
@@ -1,81 +0,0 @@
package tconstruct.util.landmine;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class LandmineStack
{
public final boolean isBlock;
public final Block block;
public final Item item;
public final int meta;
public LandmineStack(Block block)
{
this(block, -314159265);
}
public LandmineStack(Item item)
{
this(item, -314159265);
}
public LandmineStack(Block block, int meta)
{
isBlock = true;
this.block = block;
this.item = null;
this.meta = meta;
}
public LandmineStack(Item item, int meta)
{
isBlock = false;
this.block = null;
this.item = item;
this.meta = meta;
}
@Override
public boolean equals (Object o)
{
// Comparing landmine stacks
if (o instanceof LandmineStack)
{
LandmineStack stack = (LandmineStack) o;
if (isBlock)
{
return block == stack.block && (meta == stack.meta || meta == -314159265);
}
else
{
return item == stack.item && (meta == stack.meta || meta == -314159265);
}
// Comparing landmine stacks with item stacks
}
else if (o instanceof ItemStack)
{
ItemStack stack = (ItemStack) o;
if (isBlock && stack.getItem() instanceof ItemBlock)
{
return block == ((ItemBlock) stack.getItem()).field_150939_a && (meta == stack.getItemDamage() || meta == -314159265);
}
else if (!isBlock)
{
return item == stack.getItem() && (meta == stack.getItemDamage() || meta == -314159265);
}
else
{
return false;
}
}
else
{
return false;
}
}
}
@@ -1,249 +0,0 @@
package tconstruct.util.landmine.behavior;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import tconstruct.util.landmine.Helper;
import tconstruct.util.landmine.LandmineStack;
/**
*
* @author fuj1n
*
*/
public abstract class Behavior
{
public static HashMap<LandmineStack, Behavior> behaviorsListItems = new HashMap<LandmineStack, Behavior>();
public static HashMap<LandmineStack, Behavior> behaviorsListBlocks = new HashMap<LandmineStack, 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 LandmineStack(Items.stick), dummy);
addBehavior(new LandmineStack(Items.redstone), utilityMode);
addBehavior(new LandmineStack(Blocks.torch), blockThrow);
addBehavior(new LandmineStack(Items.gunpowder), explosive);
addBehavior(new LandmineStack(Blocks.tnt), explosive);
addBehavior(new LandmineStack(Items.fireworks), firework);
addBehavior(new LandmineStack(Items.potionitem), potion);
addBehavior(new LandmineStack(Items.fire_charge), fireball);
addBehavior(new LandmineStack(Items.spawn_egg), spawn);
addBehavior(new LandmineStack(Items.arrow), shoot);
addBehavior(new LandmineStack(Items.snowball), shoot);
addBehavior(new LandmineStack(Items.ender_pearl), shoot);
addBehavior(new LandmineStack(Items.shears), shear);
// Make sure the part below this comment is executed last(to avoid
// conflicts)
Iterator i1 = Block.blockRegistry.iterator();
while (i1.hasNext())
{
Object ob = i1.next();
if (ob != null && ob instanceof Block)
{
Block b = (Block) ob;
if (b.getMaterial().isOpaque() && b.renderAsNormalBlock() && !b.canProvidePower() && !(b instanceof ITileEntityProvider) && !behaviorsListBlocks.containsKey(new ItemStack(b)))
{
addBehavior(new LandmineStack(b), blockThrow);
}
}
}
}
public static Behavior getBehaviorFromStack (ItemStack par1ItemStack)
{
if (par1ItemStack == null)
{
return null;
}
if (par1ItemStack.getItem() instanceof ItemBlock)
{
if (!behaviorsListBlocks.isEmpty())
{
for (int i = 0; i < behaviorsListBlocks.size(); i++)
{
LandmineStack st = (LandmineStack) behaviorsListBlocks.keySet().toArray()[i];
if (st.equals(par1ItemStack))
{
return (Behavior) behaviorsListBlocks.values().toArray()[i];
}
}
return null;
}
else
{
return null;
}
}
else
{
if (!behaviorsListItems.isEmpty())
{
for (int i = 0; i < behaviorsListItems.size(); i++)
{
LandmineStack st = (LandmineStack) behaviorsListItems.keySet().toArray()[i];
if (st.equals(par1ItemStack))
{
return (Behavior) behaviorsListItems.values().toArray()[i];
}
}
return null;
}
else
{
return null;
}
}
}
public static Behavior getDefaulBehavior ()
{
return defaultBehavior;
}
public static void addBehavior (LandmineStack par1LandmineStack, Behavior par2Behavior)
{
if (par1LandmineStack.isBlock)
{
if (!behaviorsListBlocks.containsKey(par1LandmineStack))
{
behaviorsListBlocks.put(par1LandmineStack, par2Behavior);
}
}
else
{
if (!behaviorsListItems.containsKey(par1LandmineStack))
{
behaviorsListItems.put(par1LandmineStack, 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;
}
}
@@ -1,86 +0,0 @@
package tconstruct.util.landmine.behavior;
import mantle.blocks.BlockUtils;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityFallingBlock;
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;
}
EntityFallingBlock entityfallingsand = new EntityFallingBlock(par1World, (double) ((float) par2 + 0.5F), (double) ((float) par3 + 2F), (double) ((float) par4 + 0.5F),
BlockUtils.getBlockFromItemStack(par5ItemStack), par5ItemStack.getItemDamage());
entityfallingsand.preventEntitySpawning = false;
entityfallingsand.ticksExisted = 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;
}
}
@@ -1,20 +0,0 @@
package tconstruct.util.landmine.behavior;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import tconstruct.util.DamageSourceLandmine;
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);
}
}
}
@@ -1,19 +0,0 @@
package tconstruct.util.landmine.behavior;
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)
{
}
}
@@ -1,70 +0,0 @@
package tconstruct.util.landmine.behavior;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityTNTPrimed;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Item;
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.getItem() == Item.getItemFromBlock(Blocks.tnt))
{
explodeStrenght = 4.0F * par5ItemStack.stackSize;
}
else if (par5ItemStack.getItem() == Items.gunpowder)
{
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.getItem() == Item.getItemFromBlock(Blocks.tnt))
{
str = "medium";
}
else if (par1ItemStack.getItem() == Items.gunpowder)
{
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;
}
}
@@ -1,59 +0,0 @@
package tconstruct.util.landmine.behavior;
import java.util.Random;
import net.minecraft.entity.Entity;
import net.minecraft.entity.projectile.EntitySmallFireball;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import tconstruct.items.blocks.ItemBlockLandmine;
/**
*
* @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.getBlock(i, par3, j) == null || (par1World.getBlock(i, par3, j) != null && par1World.getBlock(i, par3, j).isReplaceable(par1World, i, par3, j)))
&& ItemBlockLandmine.getRandom().nextInt(5) == 0 && Blocks.fire.canPlaceBlockAt(par1World, i, par3, j))
{
par1World.setBlock(i, par3, j, Blocks.fire);
}
}
}
}
}
@Override
public boolean isOffensive (ItemStack par1ItemStack)
{
return true;
}
}
@@ -1,61 +0,0 @@
package tconstruct.util.landmine.behavior;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
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;
}
}
@@ -1,76 +0,0 @@
package tconstruct.util.landmine.behavior;
import java.util.Iterator;
import java.util.List;
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.init.Items;
import net.minecraft.item.ItemPotion;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import tconstruct.items.blocks.ItemBlockLandmine;
/**
*
* @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)
{
Items.potionitem.onEaten(par5ItemStack, par1World, (EntityPlayer) triggerer);
}
else if (triggerer instanceof EntityLivingBase)
{
if (!par1World.isRemote)
{
List list = Items.potionitem.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;
}
}
@@ -1,39 +0,0 @@
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;
}
}
@@ -1,69 +0,0 @@
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.init.Items;
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.getItem() == Items.arrow)
{
entity = new EntityArrow(par1World, par2, par3, par4);
((EntityArrow) entity).canBePickedUp = 1;
}
else if (par5ItemStack.getItem() == Items.snowball)
{
entity = new EntitySnowball(par1World, par2, par3, par4);
}
else if (par5ItemStack.getItem() == Items.ender_pearl)
{
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;
}
}
@@ -1,110 +0,0 @@
package tconstruct.util.landmine.behavior;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
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;
import tconstruct.items.blocks.ItemBlockLandmine;
//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;
}
}
@@ -1,46 +0,0 @@
package tconstruct.util.landmine.behavior;
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;
}
}
@@ -1,108 +0,0 @@
package tconstruct.util.landmine.behavior.stackCombo;
import java.util.ArrayList;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import tconstruct.blocks.logic.TileEntityLandmine;
import tconstruct.util.landmine.Helper;
import tconstruct.util.landmine.behavior.Behavior;
/**
*
* @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.getTileEntity(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;
}
}
@@ -1,72 +0,0 @@
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.init.Items;
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(Items.fireworks)) && this.arrayContainsEqualStack(stacks, new ItemStack(Items.fire_charge)))
{
int index0 = this.arrayIndexOfStack(stacks, new ItemStack(Items.fireworks));
int index1 = this.arrayIndexOfStack(stacks, new ItemStack(Items.fire_charge));
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(Items.fireworks, 1));
stacks.get(index0).stackSize--;
this.removeItemFromInventory(par1World, par2, par3, par4, new ItemStack(Items.fire_charge, 1));
stacks.get(index1).stackSize--;
}
}
}
}
@@ -11,7 +11,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import tconstruct.TConstruct;
import tconstruct.blocks.logic.SmelteryLogic;
import tconstruct.smeltery.logic.SmelteryLogic;
public class PacketSmeltery extends AbstractPacket
{
@@ -6,8 +6,8 @@ import mantle.common.network.AbstractPacket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import tconstruct.blocks.logic.ToolForgeLogic;
import tconstruct.blocks.logic.ToolStationLogic;
import tconstruct.tools.logic.ToolForgeLogic;
import tconstruct.tools.logic.ToolStationLogic;
import cpw.mods.fml.common.network.ByteBufUtils;
public class PacketToolStation extends AbstractPacket
@@ -18,9 +18,8 @@ import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingFallEvent;
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
import tconstruct.common.TContent;
import tconstruct.common.TRepo;
import tconstruct.library.tools.AbilityHelper;
import tconstruct.tools.TinkerTools;
import tconstruct.util.config.PHConstruct;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
@@ -83,7 +82,7 @@ public class TPlayerHandler
stats.battlesignBonus = true;
if (PHConstruct.beginnerBook)
{
ItemStack diary = new ItemStack(TRepo.manualBook);
ItemStack diary = new ItemStack(TinkerTools.manualBook);
if (!entityplayer.inventory.addItemStackToInventory(diary))
{
AbilityHelper.spawnItemAtPlayer(entityplayer, diary);
@@ -92,7 +91,7 @@ public class TPlayerHandler
if (entityplayer.getDisplayName().toLowerCase().equals("fudgy_fetus"))
{
ItemStack pattern = new ItemStack(TRepo.woodPattern, 1, 22);
ItemStack pattern = new ItemStack(TinkerTools.woodPattern, 1, 22);
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("display", new NBTTagCompound());
@@ -130,7 +129,7 @@ public class TPlayerHandler
if (!stats.battlesignBonus)
{
stats.battlesignBonus = true;
ItemStack modifier = new ItemStack(TRepo.creativeModifier);
ItemStack modifier = new ItemStack(TinkerTools.creativeModifier);
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("display", new NBTTagCompound());
@@ -138,7 +137,7 @@ public class TPlayerHandler
list.appendTag(new NBTTagString("Battlesigns were buffed recently."));
list.appendTag(new NBTTagString("This might make up for it."));
compound.getCompoundTag("display").setTag("Lore", list);
compound.setString("TargetLock", TRepo.battlesign.getToolName());
compound.setString("TargetLock", TinkerTools.battlesign.getToolName());
modifier.setTagCompound(compound);
AbilityHelper.spawnItemAtPlayer(entityplayer, modifier);
@@ -164,7 +163,7 @@ public class TPlayerHandler
void spawnPigmanModifier (EntityPlayer entityplayer)
{
ItemStack modifier = new ItemStack(TRepo.creativeModifier);
ItemStack modifier = new ItemStack(TinkerTools.creativeModifier);
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("display", new NBTTagCompound());
@@ -173,7 +172,7 @@ public class TPlayerHandler
list.appendTag(new NBTTagString("Zombie Pigmen seem to have a natural affinty"));
list.appendTag(new NBTTagString("for these types of weapons."));
compound.getCompoundTag("display").setTag("Lore", list);
compound.setString("TargetLock", TRepo.battlesign.getToolName());
compound.setString("TargetLock", TinkerTools.battlesign.getToolName());
modifier.setTagCompound(compound);
AbilityHelper.spawnItemAtPlayer(entityplayer, modifier);