This commit is contained in:
mDiyo committed 2014-08-02 15:50:49 -08:00
commit 180ffe2ec1
36 files changed
+1103 -308

No files matched your search

+4
View File
@@ -22,6 +22,8 @@ import tconstruct.library.crafting.LiquidCasting;
import tconstruct.mechworks.TinkerMechworks;
import tconstruct.mechworks.landmine.behavior.Behavior;
import tconstruct.mechworks.landmine.behavior.stackCombo.SpecialStackHandler;
import tconstruct.plugins.imc.TinkerThaumcraft;
import tconstruct.plugins.nei.TinkerNEI;
import tconstruct.smeltery.TinkerSmeltery;
import tconstruct.tools.TinkerTools;
import tconstruct.util.EnvironmentChecks;
@@ -117,6 +119,8 @@ public class TConstruct
pulsar.registerPulse(new TinkerSmeltery());
pulsar.registerPulse(new TinkerMechworks());
pulsar.registerPulse(new TinkerArmor());
pulsar.registerPulse(new TinkerNEI());
pulsar.registerPulse(new TinkerThaumcraft());
/*pulsar.registerPulse(new TinkerPrayers());
pulsar.registerPulse(new TinkerCropify());*/
@@ -3,6 +3,7 @@ package tconstruct.armor;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.armor.items.TravelGear;
import tconstruct.armor.player.TPlayerStats;
import tconstruct.library.modifier.IModifyable;
import cpw.mods.fml.common.Loader;
@@ -15,11 +16,16 @@ public class ArmorAbilities
boolean morphed;
boolean morphLoaded = Loader.isModLoaded("Morph");
ItemStack prevFeet;
double prevMotionY;
@SubscribeEvent
public void playerTick (TickEvent.PlayerTickEvent event)
{
EntityPlayer player = event.player;
TPlayerStats stats = TPlayerStats.get(player);
// Wall climb
if (stats.climbWalls)
{
double motionX = player.posX - player.lastTickPosX;
@@ -30,6 +36,31 @@ public class ArmorAbilities
player.fallDistance = 0.0F;
}
}
//Feet changes
ItemStack feet = player.getCurrentArmor(0);
if (feet != null)
{
if (feet.getItem() instanceof IModifyable && !player.isSneaking())
{
NBTTagCompound tag = feet.getTagCompound().getCompoundTag(((IModifyable) feet.getItem()).getBaseTagName());
int sole = tag.getInteger("Slimy Soles");
if (sole > 0)
{
if (!player.isSneaking() && player.onGround && prevMotionY < -0.4)
player.motionY = -prevMotionY * (Math.min(0.99, sole * 0.2));
}
}
prevMotionY = player.motionY;
}
if (feet != prevFeet)
{
if (prevFeet != null && prevFeet.getItem() instanceof TravelGear)
player.stepHeight -= 0.6f;
if (feet != null && feet.getItem() instanceof TravelGear)
player.stepHeight += 0.6f;
prevFeet = feet;
}
//TODO: Proper minimap support
/*ItemStack stack = player.inventory.getStackInSlot(8);
if (stack != null && stack.getItem() instanceof ItemMap)
@@ -43,8 +43,8 @@ public class ArmorAbilitiesClient
player.fallDistance = 0.0f;
}
//Feet changes
ItemStack feet = player.getCurrentArmor(0);
//Feet changes - moved to server side
/*ItemStack feet = player.getCurrentArmor(0);
if (feet != null)
{
if (feet.getItem() instanceof TravelGear && player.stepHeight < 1.0f)
@@ -70,7 +70,7 @@ public class ArmorAbilitiesClient
if (feet != null && feet.getItem() instanceof TravelGear)
player.stepHeight += 0.6f;
prevFeet = feet;
}
}*/
//Legs or wing changes
/*ItemStack legs = player.getCurrentArmor(1);
@@ -160,6 +160,7 @@ public class TinkerArmor
public void init (FMLInitializationEvent event)
{
craftingTableRecipes();
registerModifiers();
addRecipesForDryingRack();
TConstructRegistry.equipableTab.init(travelGoggles.getDefaultItem());
proxy.initialize();
@@ -13,7 +13,6 @@ import tconstruct.armor.ArmorProxyClient;
import tconstruct.armor.ArmorProxyCommon;
import tconstruct.armor.PlayerAbilityHelper;
import tconstruct.armor.items.TravelGear;
import tconstruct.client.event.EventCloakRender;
import tconstruct.client.tabs.TabRegistry;
import tconstruct.util.network.AccessoryInventoryPacket;
import tconstruct.util.network.BeltPacket;
@@ -25,7 +24,6 @@ public class TControls extends TKeyHandler
{
public static final String keybindCategory = "tconstruct.keybindings";
public static KeyBinding armorKey = new KeyBinding("key.tarmor", 24, keybindCategory);
public static KeyBinding refreshCapes = new KeyBinding("key.tcapes.reload", 88, keybindCategory);
public static KeyBinding toggleGoggles = new KeyBinding("key.tgoggles", 34, keybindCategory);
public static KeyBinding beltSwap = new KeyBinding("key.tbelt", 48, keybindCategory);
public static KeyBinding zoomKey = new KeyBinding("key.tzoom", 44, keybindCategory); //TODO: Make this hold, not toggle
@@ -46,7 +44,7 @@ public class TControls extends TKeyHandler
public TControls()
{
super(new KeyBinding[] { armorKey, refreshCapes, toggleGoggles, beltSwap, zoomKey }, new boolean[] { false, false, false, false, false }, getVanillaKeyBindings(), new boolean[] { false, false });
super(new KeyBinding[] { armorKey, toggleGoggles, beltSwap, zoomKey }, new boolean[] { false, false, false, false }, getVanillaKeyBindings(), new boolean[] { false, false });
/*ClientRegistry.registerKeyBinding(armorKey);
ClientRegistry.registerKeyBinding(refreshCapes);
ClientRegistry.registerKeyBinding(toggleGoggles);
@@ -76,10 +74,6 @@ public class TControls extends TKeyHandler
{
TabRegistry.addTabsToInventory((GuiContainer) mc.currentScreen);
}
if (kb == refreshCapes && mc.currentScreen == null)
{
EventCloakRender.instance.refreshCapes();
}
if (kb == jumpKey) // Double jump
{
if (mc.thePlayer.capabilities.isCreativeMode)
@@ -1,175 +0,0 @@
package tconstruct.client.event;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.ImageIcon;
import mantle.lib.environment.EnvironmentChecks;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraftforge.client.event.RenderPlayerEvent;
import tconstruct.TConstruct;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
public class EventCloakRender
{
private final String serverLocation = "https://raw.github.com/SlimeKnights/TinkersConstruct/master/capes.txt";
private final int timeout = 1000;
private static final Graphics TEST_GRAPHICS = new BufferedImage(128, 128, BufferedImage.TYPE_INT_RGB).getGraphics();
private HashMap<String, String> cloaks = new HashMap<String, String>();
private ArrayList<AbstractClientPlayer> capePlayers = new ArrayList<AbstractClientPlayer>();
public static EventCloakRender instance;
public EventCloakRender()
{
buildCloakURLDatabase();
instance = this;
}
@SubscribeEvent
public void onPreRenderSpecials (RenderPlayerEvent.Specials.Pre event)
{
if (Loader.isModLoaded("shadersmod") || EnvironmentChecks.hasOptifine)
{
return;
}
if (event.entityPlayer instanceof AbstractClientPlayer)
{
AbstractClientPlayer abstractClientPlayer = (AbstractClientPlayer) event.entityPlayer;
if (!capePlayers.contains(abstractClientPlayer))
{
String cloakURL = cloaks.get(event.entityPlayer.getDisplayName());
if (cloakURL == null)
{
return;
}
capePlayers.add(abstractClientPlayer);
//abstractClientPlayer.getTextureCape().textureUploaded = false;
//new Thread(new CloakThread(abstractClientPlayer, cloakURL)).start();
//event.renderCape = true;
}
}
}
public void buildCloakURLDatabase ()
{
URL url;
try
{
url = new URL(serverLocation);
URLConnection con = url.openConnection();
con.setConnectTimeout(timeout);
con.setReadTimeout(timeout);
InputStream io = con.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(io));
String str;
int linetracker = 1;
while ((str = br.readLine()) != null)
{
if (!str.startsWith("--"))
{
if (str.contains(":"))
{
String nick = str.substring(0, str.indexOf(":"));
String link = str.substring(str.indexOf(":") + 1);
new Thread(new CloakPreload(link)).start();
cloaks.put(nick, link);
}
else
{
TConstruct.logger.error("[SkinLoader] Syntax error on line " + linetracker + ": " + str);
}
}
linetracker++;
}
br.close();
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
private class CloakThread implements Runnable
{
AbstractClientPlayer abstractClientPlayer;
String cloakURL;
public CloakThread(AbstractClientPlayer player, String cloak)
{
abstractClientPlayer = player;
cloakURL = cloak;
}
@Override
public void run ()
{
try
{
Image cape = new ImageIcon(new URL(cloakURL)).getImage();
//BufferedImage bo = new BufferedImage(cape.getWidth(null), cape.getHeight(null), BufferedImage.TYPE_INT_ARGB);
//bo.getGraphics().drawImage(cape, 0, 0, null);
//abstractClientPlayer.getTextureCape().setBufferedImage(bo);
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
}
}
private class CloakPreload implements Runnable
{
String cloakURL;
public CloakPreload(String link)
{
cloakURL = link;
}
@Override
public void run ()
{
try
{
TEST_GRAPHICS.drawImage(new ImageIcon(new URL(cloakURL)).getImage(), 0, 0, null);
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
}
}
public void refreshCapes ()
{
cloaks.clear();
capePlayers.clear();
buildCloakURLDatabase();
}
}
@@ -4,6 +4,7 @@ import mantle.world.WorldHelper;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -248,17 +249,16 @@ public class Battleaxe extends HarvestTool
return false;
World world = player.worldObj;
final Block wood = world.getBlock(x, y, z);
final Block block = world.getBlock(x, y, z);
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
final int meta = world.getBlockMetadata(x, y, z);
for (int yPos = y + 1; yPos < y + 9; yPos++)
{
Block block = world.getBlock(x, yPos, z);
if (!(tags.getBoolean("Broken")) && block != null && block.getMaterial() == Material.wood)
Block localBlock = world.getBlock(x, yPos, z);
if (!(tags.getBoolean("Broken")) && localBlock != null && localBlock.getMaterial() == Material.wood)
{
Block localblock = world.getBlock(x, yPos, z);
int localMeta = world.getBlockMetadata(x, yPos, z);
int hlvl = block.getHarvestLevel(meta);
int hlvl = localBlock.getHarvestLevel(localMeta);
if (hlvl <= tags.getInteger("HarvestLevel"))
{
@@ -271,18 +271,12 @@ public class Battleaxe extends HarvestTool
if (!cancelHarvest)
{
if (block != null && block.getMaterial() == Material.wood)
if (localBlock != null && localBlock.getMaterial() == Material.wood)
{
localMeta = world.getBlockMetadata(x, yPos, z);
if (!player.capabilities.isCreativeMode)
{
if (block.removedByPlayer(world, player, x, yPos, z))
{
block.onBlockDestroyedByPlayer(world, x, yPos, z, localMeta);
}
block.harvestBlock(world, player, x, yPos, z, localMeta);
block.onBlockHarvested(world, x, yPos, z, localMeta, player);
onBlockDestroyed(stack, world, block, x, yPos, z, player);
mineBlock(world, x, yPos, z, localMeta, player, localBlock);
onBlockDestroyed(stack, world, localBlock, x, yPos, z, player);
}
else
{
@@ -296,7 +290,7 @@ public class Battleaxe extends HarvestTool
break;
}
if (!world.isRemote)
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(wood) + (meta << 12));
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
return super.onBlockStartBreak(stack, x, y, z, player);
}
}
@@ -150,7 +150,7 @@ public class Cleaver extends Weapon
ItemStack equipped = player.getCurrentEquippedItem();
if (equipped == stack)
{
player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 1, 2));
player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 2, 2, true));
}
}
}
@@ -3,6 +3,7 @@ package tconstruct.items.tools;
import mantle.world.WorldHelper;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -192,11 +193,10 @@ public class Excavator extends HarvestTool
{
if (!(tags.getBoolean("Broken")))
{
Block localblock = world.getBlock(xPos, yPos, zPos);
block = localblock;
Block localBlock = world.getBlock(xPos, yPos, zPos);
int localMeta = world.getBlockMetadata(xPos, yPos, zPos);
int hlvl = block.getHarvestLevel(meta);
float localHardness = block == null ? Float.MAX_VALUE : block.getBlockHardness(world, xPos, yPos, zPos);
int hlvl = localBlock.getHarvestLevel(localMeta);
float localHardness = localBlock == null ? Float.MAX_VALUE : localBlock.getBlockHardness(world, xPos, yPos, zPos);
if (hlvl <= tags.getInteger("HarvestLevel") && localHardness - 1.5 <= blockHardness)
{
@@ -209,22 +209,17 @@ public class Excavator extends HarvestTool
if (!cancelHarvest)
{
if (block != null && !(localHardness < 0))
if (localBlock != null && !(localHardness < 0))
{
for (int iter = 0; iter < materials.length; iter++)
{
if (materials[iter] == block.getMaterial())
if (materials[iter] == localBlock.getMaterial())
{
if (!player.capabilities.isCreativeMode)
{
if (block.removedByPlayer(world, player, xPos, yPos, zPos))
{
block.onBlockDestroyedByPlayer(world, xPos, yPos, zPos, localMeta);
}
block.harvestBlock(world, player, xPos, yPos, zPos, localMeta);
block.onBlockHarvested(world, xPos, yPos, zPos, localMeta, player);
if (blockHardness > 0f)
onBlockDestroyed(stack, world, localblock, xPos, yPos, zPos, player);
mineBlock(world, xPos, yPos, zPos, localMeta, player, localBlock);
if (localHardness > 0f)
onBlockDestroyed(stack, world, localBlock, xPos, yPos, zPos, player);
}
else
{
@@ -6,6 +6,7 @@ import mantle.world.WorldHelper;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
@@ -298,6 +299,7 @@ public class Hammer extends HarvestTool
hlvl = localBlock.getHarvestLevel(localMeta);
float localHardness = localBlock == null ? Float.MAX_VALUE : localBlock.getBlockHardness(world, xPos, yPos, zPos);
//Choose blocks that aren't too much harder than the first block. Stone: 2.0, Ores: 3.0
if (hlvl <= toolLevel && localHardness - 1.5 <= blockHardness)
{
boolean cancelHarvest = false;
@@ -317,12 +319,8 @@ public class Hammer extends HarvestTool
{
if (!player.capabilities.isCreativeMode)
{
if (localBlock.removedByPlayer(world, player, xPos, yPos, zPos))
{
localBlock.onBlockDestroyedByPlayer(world, xPos, yPos, zPos, localMeta);
}
localBlock.harvestBlock(world, player, xPos, yPos, zPos, localMeta);
localBlock.onBlockHarvested(world, xPos, yPos, zPos, localMeta, player);
mineBlock(world, xPos, yPos, zPos, localMeta, player, localBlock);
if (blockHardness > 0f)
onBlockDestroyed(stack, world, localBlock, xPos, yPos, zPos, player);
world.func_147479_m(x, y, z);
@@ -3,6 +3,7 @@ package tconstruct.items.tools;
import mantle.world.WorldHelper;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
@@ -197,7 +198,6 @@ public class LumberAxe extends HarvestTool
void breakTree (World world, int x, int y, int z, ItemStack stack, NBTTagCompound tags, Block bID, int meta, EntityPlayer player)
{
Block block;
for (int xPos = x - 1; xPos <= x + 1; xPos++)
{
for (int yPos = y; yPos <= y + 1; yPos++)
@@ -206,12 +206,11 @@ public class LumberAxe extends HarvestTool
{
if (!(tags.getBoolean("Broken")))
{
Block localblock = world.getBlock(xPos, yPos, zPos);
if (bID == localblock)
Block localBlock = world.getBlock(xPos, yPos, zPos);
if (bID == localBlock)
{
block = localblock;
meta = world.getBlockMetadata(xPos, yPos, zPos);
int hlvl = block.getHarvestLevel(meta);
int localMeta = world.getBlockMetadata(xPos, yPos, zPos);
int hlvl = localBlock.getHarvestLevel(localMeta);
if (hlvl <= tags.getInteger("HarvestLevel"))
{
@@ -228,7 +227,7 @@ public class LumberAxe extends HarvestTool
}
else
{
if (localblock == bID && world.getBlockMetadata(xPos, yPos, zPos) % 4 == meta % 4)
if (localBlock == bID && localMeta % 4 == meta % 4)
{
/*
* world.setBlock(xPos, yPos, zPos, 0,
@@ -242,19 +241,15 @@ public class LumberAxe extends HarvestTool
*/
if (!player.capabilities.isCreativeMode)
{
if (block.removedByPlayer(world, player, xPos, yPos, zPos))
{
block.onBlockDestroyedByPlayer(world, xPos, yPos, zPos, meta);
}
block.harvestBlock(world, player, xPos, yPos, zPos, meta);
block.onBlockHarvested(world, xPos, yPos, zPos, meta, player);
onBlockDestroyed(stack, world, localblock, xPos, yPos, zPos, player);
mineBlock(world, xPos, yPos, zPos, localMeta, player, localBlock);
onBlockDestroyed(stack, world, localBlock, xPos, yPos, zPos, player);
}
else
{
WorldHelper.setBlockToAir(world, xPos, yPos, zPos);
}
breakTree(world, xPos, yPos, zPos, stack, tags, bID, meta, player);
if (!world.isRemote)
breakTree(world, xPos, yPos, zPos, stack, tags, bID, meta, player);
}
/*
* else { Block leaves =
@@ -288,11 +283,11 @@ public class LumberAxe extends HarvestTool
{
if (!(tags.getBoolean("Broken")))
{
Block block = world.getBlock(xPos, yPos, zPos);
int meta = world.getBlockMetadata(xPos, yPos, zPos);
int hlvl = block.getHarvestLevel(meta);
Block localBlock = world.getBlock(xPos, yPos, zPos);
int localMeta = world.getBlockMetadata(xPos, yPos, zPos);
int hlvl = localBlock.getHarvestLevel(localMeta);
if (block != null && block.getMaterial() == Material.wood)
if (localBlock != null && localBlock.getMaterial() == Material.wood)
{
if (hlvl <= tags.getInteger("HarvestLevel"))
{
@@ -305,13 +300,13 @@ public class LumberAxe extends HarvestTool
if (!cancelHarvest)
{
WorldHelper.setBlockToAir(world, xPos, yPos, zPos);
if (!player.capabilities.isCreativeMode)
{
// TODO harvestBlock
block.harvestBlock(world, player, xPos, yPos, zPos, meta);
onBlockDestroyed(stack, world, block, xPos, yPos, zPos, player);
mineBlock(world, xPos, yPos, zPos, localMeta, player, localBlock);
onBlockDestroyed(stack, world, localBlock, xPos, yPos, zPos, player);
}
WorldHelper.setBlockToAir(world, xPos, yPos, zPos);
world.func_147479_m(xPos, yPos, zPos);
}
}
}
@@ -169,6 +169,7 @@ public class Scythe extends Weapon
return false;
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
boolean butter = EnchantmentHelper.getEnchantmentLevel(Enchantment.silkTouch.effectId, stack) > 0;
int fortune = EnchantmentHelper.getFortuneModifier(player);
for (int xPos = x - 1; xPos <= x + 1; xPos++)
{
for (int yPos = y - 1; yPos <= y + 1; yPos++)
@@ -222,12 +223,26 @@ public class Scythe extends Weapon
}
else
{
if (localBlock.removedByPlayer(world, player, xPos, yPos, zPos))
if (!world.isRemote)
{
// Workaround for dropping experience
int exp = localBlock.getExpDrop(world, localMeta, fortune);
localBlock.onBlockHarvested(world, xPos, yPos, zPos, localMeta, player);
if (localBlock.removedByPlayer(world, player, xPos, yPos, zPos, true))
{
localBlock.onBlockDestroyedByPlayer(world, xPos, yPos, zPos, localMeta);
localBlock.harvestBlock(world, player, xPos, yPos, zPos, localMeta);
// Workaround for dropping experience
if (!butter)
localBlock.dropXpOnBlockBreak(world, xPos, yPos, zPos, exp);
}
}
else
{
localBlock.onBlockDestroyedByPlayer(world, xPos, yPos, zPos, localMeta);
}
localBlock.harvestBlock(world, player, xPos, yPos, zPos, localMeta);
localBlock.onBlockHarvested(world, xPos, yPos, zPos, localMeta, player);
if (localHardness > 0f)
onBlockDestroyed(stack, world, localBlock, xPos, yPos, zPos, player);
}
@@ -340,8 +340,8 @@ public class TConstructRegistry
ToolMaterial mat = toolMaterials.get(materialID);
if (mat == null)
{
toolMaterials.put(materialID, mat);
toolMaterialStrings.put(material.name(), mat);
toolMaterials.put(materialID, material);
toolMaterialStrings.put(material.name(), material);
}
else
throw new IllegalArgumentException("[TCon API] Material ID " + materialID + " is already occupied by " + mat.materialName);
@@ -3,6 +3,7 @@ package tconstruct.library.tools;
import mantle.world.WorldHelper;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
@@ -50,7 +51,9 @@ public abstract class DualHarvestTool extends HarvestTool
else
{
if (!player.capabilities.isCreativeMode)
onBlockDestroyed(stack, world, block, x, y, z, player);
{
mineBlock(world, x, y, z, meta, player, block);
}
WorldHelper.setBlockToAir(world, x, y, z);
if (!world.isRemote)
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
@@ -3,6 +3,7 @@ package tconstruct.library.tools;
import mantle.world.WorldHelper;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
@@ -38,15 +39,12 @@ public abstract class HarvestTool extends ToolCore
int hlvl = -1;
if (!(tags.getBoolean("Broken")))
{
Block localBlock = world.getBlock(x, y, z);
int localMeta = world.getBlockMetadata(x, y, z);
if (block.getHarvestTool(meta) != null && block.getHarvestTool(meta).equals(this.getHarvestType()))
hlvl = block.getHarvestLevel(meta);
int toolLevel = tags.getInteger("HarvestLevel");
float blockHardness = block.getBlockHardness(world, x, y, z);
float localHardness = localBlock == null ? Float.MAX_VALUE : localBlock.getBlockHardness(world, x, y, z);
if (hlvl <= toolLevel && localHardness - 1.5 <= blockHardness)
if (hlvl <= toolLevel)
{
boolean cancelHarvest = false;
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
@@ -57,21 +55,22 @@ public abstract class HarvestTool extends ToolCore
if (!cancelHarvest)
{
if (localBlock != null && !(localHardness < 0))
if (block != null)
{
boolean isEffective = false;
for (int iter = 0; iter < getEffectiveMaterials().length; iter++)
{
if (getEffectiveMaterials()[iter] == localBlock.getMaterial() || localBlock == Blocks.monster_egg)
if (getEffectiveMaterials()[iter] == block.getMaterial() || block == Blocks.monster_egg)
{
isEffective = true;
break;
}
}
if (localBlock.getMaterial().isToolNotRequired())
// Microblocks are registered as rock but no HarvestTool is set
if (block.getMaterial().isToolNotRequired() || block.getHarvestTool(meta) == null)
{
isEffective = true;
}
@@ -80,14 +79,9 @@ public abstract class HarvestTool extends ToolCore
{
if (isEffective)
{
if (localBlock.removedByPlayer(world, player, x, y, z))
{
localBlock.onBlockDestroyedByPlayer(world, x, y, z, localMeta);
}
localBlock.harvestBlock(world, player, x, y, z, localMeta);
localBlock.onBlockHarvested(world, x, y, z, localMeta, player);
mineBlock(world, x, y, z, meta, player, block);
if (blockHardness > 0f)
onBlockDestroyed(stack, world, localBlock, x, y, z, player);
onBlockDestroyed(stack, world, block, x, y, z, player);
world.func_147479_m(x, y, z);
}
else
@@ -288,4 +282,43 @@ public abstract class HarvestTool extends ToolCore
return used;
}
@Override
public int getHarvestLevel (ItemStack stack, String toolClass)
{
if (!(stack.getItem() instanceof HarvestTool) || !getHarvestType().equals(toolClass))
{
return -1;
}
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
int harvestLvl = tags.getInteger("HarvestLevel");
return harvestLvl;
}
// The Scythe is not a HarvestTool and can't call this method, if you change something here you might change it there too.
public void mineBlock(World world, int x, int y, int z, int meta, EntityPlayer player, Block block)
{
if (!world.isRemote)
{
// Workaround for dropping experience
boolean silktouch = EnchantmentHelper.getSilkTouchModifier(player);
int fortune = EnchantmentHelper.getFortuneModifier(player);
int exp = block.getExpDrop(world, meta, fortune);
block.onBlockHarvested(world, x, y, z, meta, player);
if (block.removedByPlayer(world, player, x, y, z, true))
{
block.onBlockDestroyedByPlayer(world, x, y, z, meta);
block.harvestBlock(world, player, x, y, z, meta);
// Workaround for dropping experience
if (!silktouch)
block.dropXpOnBlockBreak(world, x, y, z, exp);
}
}
else
{
block.onBlockDestroyedByPlayer(world, x, y, z, meta);
}
}
}
@@ -24,6 +24,9 @@ public class ModAntiSpider extends ItemModTypeFilter
if (!tags.hasKey(key))
return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
if(matchingAmount(input) > max)
return false;
int keyPair[] = tags.getIntArray(key);
if (keyPair[0] + matchingAmount(input) <= keyPair[1])
return true;
@@ -45,6 +45,9 @@ public class ModAttack extends ItemModTypeFilter
if (!validType(toolItem))
return false;
if(matchingAmount(input) > max)
return false;
NBTTagCompound tags = tool.getTagCompound().getCompoundTag(toolItem.getBaseTagName());
if (!tags.hasKey(key))
return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
@@ -28,6 +28,9 @@ public class ModBlaze extends ItemModTypeFilter
if (!validType(toolItem))
return false;
if(matchingAmount(input) > max)
return false;
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (!tags.hasKey(key))
return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
@@ -51,7 +54,7 @@ public class ModBlaze extends ItemModTypeFilter
if (tags.hasKey(key))
{
int[] keyPair = tags.getIntArray(key);
if (keyPair[0] == max)
if (keyPair[0] % max == 0)
{
keyPair[0] += increase;
keyPair[1] += max;
@@ -33,6 +33,9 @@ public class ModLapis extends ItemModTypeFilter
if (!validType(toolItem))
return false;
if(matchingAmount(input) > max)
return false;
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (tags.getBoolean("Silk Touch"))
@@ -29,6 +29,9 @@ public class ModPiston extends ItemModTypeFilter
if (!validType(toolItem))
return false;
if(matchingAmount(input) > max)
return false;
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (!tags.hasKey(key))
return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
@@ -28,14 +28,17 @@ public class ModRedstone extends ItemModTypeFilter
if (!validType(toolItem))
return false;
if(matchingAmount(input) > max)
return false;
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (!tags.hasKey(key))
return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
int keyPair[] = tags.getIntArray(key);
if (keyPair[0] + matchingAmount(input) <= keyPair[1])
return true;
else if (keyPair[0] == keyPair[1])
return tags.getInteger("Modifiers") > 0;
}
@@ -19,6 +19,9 @@ public class ModSmite extends ItemModTypeFilter
@Override
protected boolean canModify (ItemStack tool, ItemStack[] input)
{
if(matchingAmount(input) > max)
return false;
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (!tags.hasKey(key))
return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
@@ -0,0 +1,31 @@
package tconstruct.plugins.imc;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import mantle.pulsar.pulse.Handler;
import mantle.pulsar.pulse.Pulse;
import tconstruct.TConstruct;
import tconstruct.smeltery.TinkerSmeltery;
import tconstruct.world.TinkerWorld;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder;
@ObjectHolder(TConstruct.modID)
@Pulse(id = "Tinkers Thaumcraft Compatibility", description = "Tinkers Construct compatibility for Thaumcraft", modsRequired = "Thaumcraft")
public class TinkerThaumcraft
{
@Handler
public void init (FMLInitializationEvent event)
{
TConstruct.logger.info("[Thaumcraft] Registering harvestables.");
FMLInterModComms.sendMessage("Thaumcraft", "harvestClickableCrop", new ItemStack(TinkerWorld.oreBerry, 1, 12));
FMLInterModComms.sendMessage("Thaumcraft", "harvestClickableCrop", new ItemStack(TinkerWorld.oreBerry, 1, 13));
FMLInterModComms.sendMessage("Thaumcraft", "harvestClickableCrop", new ItemStack(TinkerWorld.oreBerry, 1, 14));
FMLInterModComms.sendMessage("Thaumcraft", "harvestClickableCrop", new ItemStack(TinkerWorld.oreBerry, 1, 15));
FMLInterModComms.sendMessage("Thaumcraft", "harvestClickableCrop", new ItemStack(TinkerWorld.oreBerrySecond, 1, 12));
FMLInterModComms.sendMessage("Thaumcraft", "harvestClickableCrop", new ItemStack(TinkerWorld.oreBerrySecond, 1, 13));
}
}
@@ -0,0 +1,21 @@
package tconstruct.plugins.nei;
import tconstruct.tools.gui.CraftingStationGui;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.common.FMLCommonHandler;
import codechicken.nei.recipe.DefaultOverlayHandler;
import codechicken.nei.api.API;
public class NEICompat
{
public static void registerNEICompat ()
{
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT)
{
API.registerGuiOverlay(CraftingStationGui.class, "crafting");
API.registerGuiOverlayHandler(CraftingStationGui.class, new DefaultOverlayHandler(), "crafting");
}
}
}
@@ -0,0 +1,23 @@
package tconstruct.plugins.nei;
import mantle.pulsar.pulse.Handler;
import mantle.pulsar.pulse.Pulse;
import tconstruct.TConstruct;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder;
import cpw.mods.fml.relauncher.Side;
@ObjectHolder(TConstruct.modID)
@Pulse(id = "Tinkers NEI Compatibility", description = "Tinkers Construct compatibility for NEI", modsRequired = "NotEnoughItems")
public class TinkerNEI
{
@Handler
public void init (FMLInitializationEvent event)
{
TConstruct.logger.info("NotEnoughItems detected. Registering TConstruct NEI plugin.");
NEICompat.registerNEICompat();
}
}
@@ -786,6 +786,9 @@ public class TinkerSmeltery
}
}
}
tableCasting.addCastingRecipe(new ItemStack(Items.ender_pearl), new FluidStack(TinkerSmeltery.moltenEnderFluid, 250), new ItemStack(TinkerSmeltery.metalPattern, 1, 10), 50);
tableCasting.addCastingRecipe(new ItemStack(Items.ender_pearl), new FluidStack(TinkerSmeltery.moltenEnderFluid, 250), new ItemStack(TinkerSmeltery.metalPattern, 1, 26), 50);
ItemStack[] ingotShapes = { new ItemStack(Items.brick), new ItemStack(Items.netherbrick), new ItemStack(TinkerTools.materials, 1, 2), new ItemStack(TinkerTools.materials, 1, 37) };
for (int i = 0; i < ingotShapes.length; i++)
@@ -915,7 +918,7 @@ public class TinkerSmeltery
// Items
Smeltery.addMelting(FluidType.getFluidType("AluminumBrass"), new ItemStack(TinkerTools.blankPattern, 4, 1), -50, TConstruct.ingotLiquidValue);
Smeltery.addMelting(gold, new ItemStack(TinkerTools.blankPattern, 4, 2), -50, TConstruct.ingotLiquidValue * 2);
Smeltery.addMelting(FluidType.getFluidType("Gold"), new ItemStack(TinkerTools.materials, 1, 36), 0, TConstruct.ingotLiquidValue);
Smeltery.addMelting(FluidType.getFluidType("Glue"), new ItemStack(TinkerTools.materials, 1, 36), 0, TConstruct.ingotLiquidValue);
Smeltery.addMelting(FluidType.getFluidType("Ender"), new ItemStack(Items.ender_pearl, 4), 0, 250);
Smeltery.addMelting(TinkerWorld.metalBlock, 10, 50, new FluidStack(moltenEnderFluid, 1000));
@@ -41,7 +41,7 @@ public class TinkerSmelteryEvents
@SubscribeEvent
public void bucketFill (FillBucketEvent evt)
{
if (evt.current.getItem() == Items.bucket && evt.target.typeOfHit == MovingObjectType.ENTITY)
if (evt.current.getItem() == Items.bucket && evt.target.typeOfHit == MovingObjectType.BLOCK)
{
int hitX = evt.target.blockX;
int hitY = evt.target.blockY;
@@ -418,12 +418,12 @@ public class TinkerToolEvents
public void registerOre (OreRegisterEvent evt)
{
if (evt.Name == "crystalQuartz")
if (evt.Name.equals("crystalQuartz"))
{
TinkerTools.modAttack.addStackToMatchList(evt.Ore, 2);
}
else if (evt.Name == "crystalCerusQuartz")
else if (evt.Name.equals("crystalCertusQuartz"))
{
TinkerTools.modAttack.addStackToMatchList(evt.Ore, 24);
}
@@ -477,9 +477,9 @@ public class TinkerTools
ItemStack diamond = new ItemStack(Items.diamond);
ModifyBuilder.registerModifier(new ModToolRepair());
ModifyBuilder.registerModifier(new ModDurability(new ItemStack[] { diamond }, 0, 500, 0f, 3, StatCollector.translateToLocal("gui.modifier.diamond"), "\u00a7b"
ModifyBuilder.registerModifier(new ModDurability(new ItemStack[] { diamond }, 0, 500, 0f, 3, "Diamond", "\u00a7b"
+ StatCollector.translateToLocal("modifier.tool.diamond"), "\u00a7b"));
ModifyBuilder.registerModifier(new ModDurability(new ItemStack[] { new ItemStack(Items.emerald) }, 1, 0, 0.5f, 2, StatCollector.translateToLocal("gui.modifier.emerald"), "\u00a72"
ModifyBuilder.registerModifier(new ModDurability(new ItemStack[] { new ItemStack(Items.emerald) }, 1, 0, 0.5f, 2, "Emerald", "\u00a72"
+ StatCollector.translateToLocal("modifier.tool.emerald"), "\u00a72"));
TinkerTools.modFlux = new ModFlux();
@@ -494,13 +494,13 @@ public class TinkerTools
TinkerTools.modLapis = new ModLapis(10, new ItemStack[] { lapisItem, lapisBlock }, new int[] { 1, 9 });
ModifyBuilder.registerModifier(TinkerTools.modLapis);
ModifyBuilder.registerModifier(new ModInteger(new ItemStack[] { new ItemStack(TinkerTools.materials, 1, 6) }, 4, StatCollector.translateToLocal("gui.modifier.moss"), 3, "\u00a72", StatCollector
ModifyBuilder.registerModifier(new ModInteger(new ItemStack[] { new ItemStack(TinkerTools.materials, 1, 6) }, 4, "Moss", 3, "\u00a72", StatCollector
.translateToLocal("modifier.tool.moss")));
ItemStack blazePowder = new ItemStack(Items.blaze_powder);
ModifyBuilder.registerModifier(new ModBlaze(7, new ItemStack[] { blazePowder }, new int[] { 1 }));
ModifyBuilder.registerModifier(new ModAutoSmelt(new ItemStack[] { new ItemStack(TinkerTools.materials, 1, 7) }, 6, StatCollector.translateToLocal("gui.modifier.lava"), "\u00a74", StatCollector
ModifyBuilder.registerModifier(new ModAutoSmelt(new ItemStack[] { new ItemStack(TinkerTools.materials, 1, 7) }, 6, "Lava", "\u00a74", StatCollector
.translateToLocal("modifier.tool.lava")));
ModifyBuilder.registerModifier(new ModInteger(new ItemStack[] { new ItemStack(TinkerTools.materials, 1, 8) }, 8, StatCollector.translateToLocal("gui.modifier.necro"), 1, "\u00a78", StatCollector
ModifyBuilder.registerModifier(new ModInteger(new ItemStack[] { new ItemStack(TinkerTools.materials, 1, 8) }, 8, "Necrotic", 1, "\u00a78", StatCollector
.translateToLocal("modifier.tool.necro")));
TinkerTools.modAttack = new ModAttack(StatCollector.translateToLocal("gui.modifier.quartz"), 11, new ItemStack[] { new ItemStack(Items.quartz),
@@ -518,7 +518,7 @@ public class TinkerTools
ItemStack piston = new ItemStack(Blocks.piston);
ModifyBuilder.registerModifier(new ModPiston(3, new ItemStack[] { piston }, new int[] { 1 }));
ModifyBuilder.registerModifier(new ModInteger(new ItemStack[] { new ItemStack(Blocks.obsidian), new ItemStack(Items.ender_pearl) }, 13, StatCollector.translateToLocal("modifier.tool.beheading"), 1,
ModifyBuilder.registerModifier(new ModInteger(new ItemStack[] { new ItemStack(Blocks.obsidian), new ItemStack(Items.ender_pearl) }, 13, "Beheading", 1,
"\u00a7d", StatCollector.translateToLocal("modifier.tool.beheading")));
ItemStack holySoil = new ItemStack(TinkerTools.craftedSoil, 1, 4);