mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-26 23:13:07 +00:00
[ci skip] spotlessApply with the new settings
This commit is contained in:
1 parent
83698cb73c
commit
84c2239244
561 files changed
+8872
-9300
No files matched your search
@@ -5,9 +5,11 @@ import net.minecraft.entity.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public class ActiveToolMod {
|
||||
|
||||
/* Updating */
|
||||
public void updateTool(ToolCore tool, ItemStack stack, World world, Entity entity) {}
|
||||
|
||||
@@ -18,67 +20,41 @@ public class ActiveToolMod {
|
||||
|
||||
@Deprecated
|
||||
public boolean afterBlockBreak() // Unfinished, not called
|
||||
{
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void afterBlockBreak(
|
||||
ToolCore tool, ItemStack stack, Block block, int x, int y, int z, EntityLivingBase entity) {}
|
||||
public void afterBlockBreak(ToolCore tool, ItemStack stack, Block block, int x, int y, int z,
|
||||
EntityLivingBase entity) {}
|
||||
|
||||
/* Attacking */
|
||||
|
||||
public int baseAttackDamage(
|
||||
int earlyModDamage,
|
||||
int damage,
|
||||
ToolCore tool,
|
||||
NBTTagCompound tags,
|
||||
NBTTagCompound toolTags,
|
||||
ItemStack stack,
|
||||
EntityLivingBase player,
|
||||
Entity entity) {
|
||||
public int baseAttackDamage(int earlyModDamage, int damage, ToolCore tool, NBTTagCompound tags,
|
||||
NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity) {
|
||||
return earlyModDamage;
|
||||
}
|
||||
|
||||
// Calculated after sprinting and enchant bonuses
|
||||
public float knockback(
|
||||
float modKnockback,
|
||||
float currentKnockback,
|
||||
ToolCore tool,
|
||||
NBTTagCompound tags,
|
||||
NBTTagCompound toolTags,
|
||||
ItemStack stack,
|
||||
EntityLivingBase player,
|
||||
Entity entity) {
|
||||
public float knockback(float modKnockback, float currentKnockback, ToolCore tool, NBTTagCompound tags,
|
||||
NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity) {
|
||||
return modKnockback;
|
||||
}
|
||||
|
||||
public int attackDamage(
|
||||
int modDamage,
|
||||
int currentDamage,
|
||||
ToolCore tool,
|
||||
NBTTagCompound tags,
|
||||
NBTTagCompound toolTags,
|
||||
ItemStack stack,
|
||||
EntityLivingBase player,
|
||||
Entity entity) {
|
||||
public int attackDamage(int modDamage, int currentDamage, ToolCore tool, NBTTagCompound tags,
|
||||
NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity) {
|
||||
return modDamage;
|
||||
}
|
||||
|
||||
public void lateAttackEntity() // Unfinished, not called
|
||||
{}
|
||||
{}
|
||||
|
||||
/* Damage tool */
|
||||
public boolean damageTool(ItemStack stack, int damage, EntityLivingBase entity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean doesCriticalHit(
|
||||
ToolCore tool,
|
||||
NBTTagCompound tags,
|
||||
NBTTagCompound toolTags,
|
||||
ItemStack stack,
|
||||
EntityLivingBase player,
|
||||
Entity entity) {
|
||||
public boolean doesCriticalHit(ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack,
|
||||
EntityLivingBase player, Entity entity) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
package tconstruct.library;
|
||||
|
||||
public interface ItemBlocklike {}
|
||||
public interface ItemBlocklike {
|
||||
}
|
||||
@@ -1,16 +1,18 @@
|
||||
package tconstruct.library;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import java.util.IdentityHashMap;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
|
||||
import tconstruct.gadgets.TinkerGadgets;
|
||||
import tconstruct.gadgets.item.ItemSlimeBoots;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
/** Logic for entities bouncing */
|
||||
public class SlimeBounceHandler {
|
||||
@@ -54,8 +56,7 @@ public class SlimeBounceHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Causes the entity to bounce, needed because the fall event will reset motion
|
||||
* afterwards
|
||||
* Causes the entity to bounce, needed because the fall event will reset motion afterwards
|
||||
*
|
||||
* @param entity Entity to bounce
|
||||
* @param bounce Bounce amount
|
||||
@@ -252,6 +253,7 @@ public class SlimeBounceHandler {
|
||||
|
||||
/** Data class to keep track of bouncing info for an entity */
|
||||
private static class BounceInfo {
|
||||
|
||||
/** Velocity the entity should have, unused if 0 */
|
||||
private double bounce;
|
||||
/** Time to update the entities velocity */
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.*;
|
||||
|
||||
public class TConstructCreativeTab extends CreativeTabs {
|
||||
|
||||
ItemStack display;
|
||||
|
||||
public TConstructCreativeTab(String label) {
|
||||
|
||||
@@ -2,8 +2,11 @@ package tconstruct.library;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.item.*;
|
||||
|
||||
import org.apache.logging.log4j.*;
|
||||
|
||||
import tconstruct.library.crafting.*;
|
||||
import tconstruct.library.modifier.ActiveArmorMod;
|
||||
import tconstruct.library.tools.*;
|
||||
@@ -15,6 +18,7 @@ import tconstruct.tools.TinkerTools;
|
||||
* @author mDiyo
|
||||
*/
|
||||
public class TConstructRegistry {
|
||||
|
||||
public static TConstructRegistry instance = new TConstructRegistry();
|
||||
|
||||
public static Logger logger = LogManager.getLogger("TCon-API");
|
||||
@@ -33,27 +37,22 @@ public class TConstructRegistry {
|
||||
/**
|
||||
* A directory of crafting items and tools used by the mod.
|
||||
*
|
||||
* Tools: pickaxe, shovel, hatchet, broadsword, longsword, rapier, dagger,
|
||||
* cutlass frypan, battlesign, mattock, chisel lumberaxe, cleaver, scythe,
|
||||
* excavator, hammer, battleaxe
|
||||
* Tools: pickaxe, shovel, hatchet, broadsword, longsword, rapier, dagger, cutlass frypan, battlesign, mattock,
|
||||
* chisel lumberaxe, cleaver, scythe, excavator, hammer, battleaxe
|
||||
*
|
||||
* Patterns: blankPattern, woodPattern, metalPattern, clayPattern
|
||||
*
|
||||
* Tool crafting parts: toolRod, toolShard, binding, toughBinding, toughRod,
|
||||
* heavyPlate pickaxeHead, shovelhead, hatchetHead, swordBlade, wideguard,
|
||||
* handGuard, crossbar, knifeBlade, fullGuard, frypanHead, signHead,
|
||||
* chiselHead scytheBlade, broadAxeHead, excavatorHead, largeSwordBlade,
|
||||
* hammerHead bowstring, fletching, arrowhead
|
||||
* Tool crafting parts: toolRod, toolShard, binding, toughBinding, toughRod, heavyPlate pickaxeHead, shovelhead,
|
||||
* hatchetHead, swordBlade, wideguard, handGuard, crossbar, knifeBlade, fullGuard, frypanHead, signHead, chiselHead
|
||||
* scytheBlade, broadAxeHead, excavatorHead, largeSwordBlade, hammerHead bowstring, fletching, arrowhead
|
||||
*/
|
||||
public static HashMap<String, Item> itemDirectory = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Adds an item to the directory
|
||||
*
|
||||
* @param name
|
||||
* Associates the name with the stack
|
||||
* @param itemstack
|
||||
* The stack to add to the directory
|
||||
* @param name Associates the name with the stack
|
||||
* @param itemstack The stack to add to the directory
|
||||
*/
|
||||
public static void addItemToDirectory(String name, Item itemstack) {
|
||||
Item add = itemDirectory.get(name);
|
||||
@@ -65,8 +64,7 @@ public class TConstructRegistry {
|
||||
/**
|
||||
* Retrieves an itemstack from the directory
|
||||
*
|
||||
* @param name
|
||||
* The name of the item to get
|
||||
* @param name The name of the item to get
|
||||
* @return Item associated with the name, or null if not present.
|
||||
*/
|
||||
public static Item getItem(String name) {
|
||||
@@ -79,31 +77,25 @@ public class TConstructRegistry {
|
||||
/**
|
||||
* A directory of ItemStacks. Contains mostly crafting items
|
||||
*
|
||||
* Materials: paperStack, greenSlimeCrystal, blueSlimeCrystal, searedBrick,
|
||||
* mossBall, lavaCrystal, necroticBone, silkyCloth, silkyJewel ingotCobalt,
|
||||
* ingotArdite, ingotManyullyn, ingotCopper, ingotTin, ingotAluminum,
|
||||
* rawAluminum, ingotBronze, ingotAluminumBrass, ingotAlumite, ingotSteel,
|
||||
* ingotObsidian nuggetIron, nuggetCopper, nuggetTin, nuggetAluminum,
|
||||
* nuggetSilver, nuggetAluminumBrass oreberryIron, oreberryGold,
|
||||
* oreberryCopper, oreberryTin, oreberryTin, oreberrySilver, diamondApple,
|
||||
* blueSlimeFood, canisterEmpty, miniRedHeart, canisterRedHeart
|
||||
* Materials: paperStack, greenSlimeCrystal, blueSlimeCrystal, searedBrick, mossBall, lavaCrystal, necroticBone,
|
||||
* silkyCloth, silkyJewel ingotCobalt, ingotArdite, ingotManyullyn, ingotCopper, ingotTin, ingotAluminum,
|
||||
* rawAluminum, ingotBronze, ingotAluminumBrass, ingotAlumite, ingotSteel, ingotObsidian nuggetIron, nuggetCopper,
|
||||
* nuggetTin, nuggetAluminum, nuggetSilver, nuggetAluminumBrass oreberryIron, oreberryGold, oreberryCopper,
|
||||
* oreberryTin, oreberryTin, oreberrySilver, diamondApple, blueSlimeFood, canisterEmpty, miniRedHeart,
|
||||
* canisterRedHeart
|
||||
*
|
||||
* Patterns - These have a suffix of Pattern or Cast. ex: hatchetHeadPattern
|
||||
* ingot, toolRod, pickaxeHead, shovelHead, hatchetHead, swordBlade,
|
||||
* wideGuard, handGuard, crossbar, binding, frypanHead, signHead,
|
||||
* knifeBlade, chiselHead, toughRod, toughBinding, largePlate, broadAxeHead,
|
||||
* scytheHead, excavatorHead, largeBlade, hammerHead, fullGuard, bowString,
|
||||
* fletching, arrowHead
|
||||
* Patterns - These have a suffix of Pattern or Cast. ex: hatchetHeadPattern ingot, toolRod, pickaxeHead,
|
||||
* shovelHead, hatchetHead, swordBlade, wideGuard, handGuard, crossbar, binding, frypanHead, signHead, knifeBlade,
|
||||
* chiselHead, toughRod, toughBinding, largePlate, broadAxeHead, scytheHead, excavatorHead, largeBlade, hammerHead,
|
||||
* fullGuard, bowString, fletching, arrowHead
|
||||
*/
|
||||
static HashMap<String, ItemStack> itemstackDirectory = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Adds an itemstack to the directory
|
||||
*
|
||||
* @param name
|
||||
* Associates the name with the stack
|
||||
* @param itemstack
|
||||
* The stack to add to the directory
|
||||
* @param name Associates the name with the stack
|
||||
* @param itemstack The stack to add to the directory
|
||||
*/
|
||||
public static void addItemStackToDirectory(String name, ItemStack itemstack) {
|
||||
ItemStack add = itemstackDirectory.get(name);
|
||||
@@ -115,8 +107,7 @@ public class TConstructRegistry {
|
||||
/**
|
||||
* Retrieves an itemstack from the directory
|
||||
*
|
||||
* @param name
|
||||
* The name of the item to get
|
||||
* @param name The name of the item to get
|
||||
* @return Item associated with the name, or null if not present.
|
||||
*/
|
||||
public static ItemStack getItemStack(String name) {
|
||||
@@ -131,22 +122,17 @@ public class TConstructRegistry {
|
||||
// Parts
|
||||
|
||||
/**
|
||||
* List: Item ID, metadata, material ID ItemStack: Output. Ex: Cactus
|
||||
* Binding
|
||||
* List: Item ID, metadata, material ID ItemStack: Output. Ex: Cactus Binding
|
||||
*/
|
||||
public static HashMap<List, ItemStack> patternPartMapping = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Maps an item and a material ID to an output part
|
||||
*
|
||||
* @param woodPattern
|
||||
* ID to check against
|
||||
* @param patternMeta
|
||||
* Metadata to check against
|
||||
* @param materialID
|
||||
* Material that goes with the item
|
||||
* @param output
|
||||
* The resulting part
|
||||
* @param woodPattern ID to check against
|
||||
* @param patternMeta Metadata to check against
|
||||
* @param materialID Material that goes with the item
|
||||
* @param output The resulting part
|
||||
*/
|
||||
public static void addPartMapping(Item woodPattern, int patternMeta, int materialID, ItemStack output) {
|
||||
patternPartMapping.put(Arrays.asList(woodPattern, patternMeta, materialID), output);
|
||||
@@ -179,15 +165,12 @@ public class TConstructRegistry {
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a tool to its crafting parts. If an output is registered
|
||||
* multiple times the parts are added to the recipe's input list Valid part
|
||||
* amounts are 2, 3, and 4.
|
||||
* Registers a tool to its crafting parts. If an output is registered multiple times the parts are added to the
|
||||
* recipe's input list Valid part amounts are 2, 3, and 4.
|
||||
*
|
||||
* @see ToolBuilder
|
||||
* @param output
|
||||
* The ToolCore to craft
|
||||
* @param parts
|
||||
* Pieces to make the tool with
|
||||
* @param output The ToolCore to craft
|
||||
* @param parts Pieces to make the tool with
|
||||
*/
|
||||
public static void addToolRecipe(ToolCore output, Item... parts) {
|
||||
ToolBuilder tb = ToolBuilder.instance;
|
||||
@@ -217,39 +200,19 @@ public class TConstructRegistry {
|
||||
/**
|
||||
* Adds a tool material to the registry
|
||||
*
|
||||
* @param materialID
|
||||
* Unique ID, stored for each part
|
||||
* @param materialName
|
||||
* Unique name for data lookup purposes
|
||||
* @param harvestLevel
|
||||
* The materials which the tool can harvest. Pickaxe levels - 0:
|
||||
* Wood, 1: Stone, 2: Redstone/Diamond, 3: Obsidian, 4:
|
||||
* Cobalt/Ardite, 5: Manyullyn
|
||||
* @param durability
|
||||
* Base durability of the tool, affects tool heads.
|
||||
* @param miningspeed
|
||||
* Base mining speed, divided by 100 in use
|
||||
* @param attack
|
||||
* Base attack
|
||||
* @param handleModifier
|
||||
* Durability multiplier on the tool
|
||||
* @param reinforced
|
||||
* Reinforced level
|
||||
* @param stonebound
|
||||
* Amount of Stonebound to put on the tool. Negative numbers are
|
||||
* Spiny.
|
||||
* @param materialID Unique ID, stored for each part
|
||||
* @param materialName Unique name for data lookup purposes
|
||||
* @param harvestLevel The materials which the tool can harvest. Pickaxe levels - 0: Wood, 1: Stone, 2:
|
||||
* Redstone/Diamond, 3: Obsidian, 4: Cobalt/Ardite, 5: Manyullyn
|
||||
* @param durability Base durability of the tool, affects tool heads.
|
||||
* @param miningspeed Base mining speed, divided by 100 in use
|
||||
* @param attack Base attack
|
||||
* @param handleModifier Durability multiplier on the tool
|
||||
* @param reinforced Reinforced level
|
||||
* @param stonebound Amount of Stonebound to put on the tool. Negative numbers are Spiny.
|
||||
*/
|
||||
public static void addToolMaterial(
|
||||
int materialID,
|
||||
String materialName,
|
||||
int harvestLevel,
|
||||
int durability,
|
||||
int miningspeed,
|
||||
int attack,
|
||||
float handleModifier,
|
||||
int reinforced,
|
||||
float stonebound,
|
||||
String style,
|
||||
public static void addToolMaterial(int materialID, String materialName, int harvestLevel, int durability,
|
||||
int miningspeed, int attack, float handleModifier, int reinforced, float stonebound, String style,
|
||||
int primaryColor) {
|
||||
ToolMaterial mat = toolMaterials.get(materialID);
|
||||
if (mat == null) {
|
||||
@@ -266,51 +229,28 @@ public class TConstructRegistry {
|
||||
primaryColor);
|
||||
toolMaterials.put(materialID, mat);
|
||||
toolMaterialStrings.put(materialName, mat);
|
||||
} else
|
||||
throw new IllegalArgumentException(
|
||||
"[TCon API] Material ID " + materialID + " is already occupied by " + mat.materialName);
|
||||
} else throw new IllegalArgumentException(
|
||||
"[TCon API] Material ID " + materialID + " is already occupied by " + mat.materialName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a tool material to the registry
|
||||
*
|
||||
* @param materialID
|
||||
* Unique ID, stored for each part
|
||||
* @param materialName
|
||||
* Unique name for data lookup purposes
|
||||
* @param localizationName
|
||||
* The string used to localize the material name
|
||||
* @param harvestLevel
|
||||
* The materials which the tool can harvest. Pickaxe levels - 0:
|
||||
* Wood, 1: Stone, 2: Redstone/Diamond, 3: Obsidian, 4:
|
||||
* Cobalt/Ardite, 5: Manyullyn
|
||||
* @param durability
|
||||
* Base durability of the tool, affects tool heads.
|
||||
* @param miningspeed
|
||||
* Base mining speed, divided by 100 in use
|
||||
* @param attack
|
||||
* Base attack
|
||||
* @param handleModifier
|
||||
* Durability multiplier on the tool
|
||||
* @param reinforced
|
||||
* Reinforced level
|
||||
* @param stonebound
|
||||
* Amount of Stonebound to put on the tool. Negative numbers are
|
||||
* Spiny.
|
||||
* @param materialID Unique ID, stored for each part
|
||||
* @param materialName Unique name for data lookup purposes
|
||||
* @param localizationName The string used to localize the material name
|
||||
* @param harvestLevel The materials which the tool can harvest. Pickaxe levels - 0: Wood, 1: Stone, 2:
|
||||
* Redstone/Diamond, 3: Obsidian, 4: Cobalt/Ardite, 5: Manyullyn
|
||||
* @param durability Base durability of the tool, affects tool heads.
|
||||
* @param miningspeed Base mining speed, divided by 100 in use
|
||||
* @param attack Base attack
|
||||
* @param handleModifier Durability multiplier on the tool
|
||||
* @param reinforced Reinforced level
|
||||
* @param stonebound Amount of Stonebound to put on the tool. Negative numbers are Spiny.
|
||||
*/
|
||||
public static void addToolMaterial(
|
||||
int materialID,
|
||||
String materialName,
|
||||
String localizationName,
|
||||
int harvestLevel,
|
||||
int durability,
|
||||
int miningspeed,
|
||||
int attack,
|
||||
float handleModifier,
|
||||
int reinforced,
|
||||
float stonebound,
|
||||
String style,
|
||||
int primaryColor) {
|
||||
public static void addToolMaterial(int materialID, String materialName, String localizationName, int harvestLevel,
|
||||
int durability, int miningspeed, int attack, float handleModifier, int reinforced, float stonebound,
|
||||
String style, int primaryColor) {
|
||||
ToolMaterial mat = toolMaterials.get(materialID);
|
||||
if (mat == null) {
|
||||
mat = new ToolMaterial(
|
||||
@@ -327,23 +267,13 @@ public class TConstructRegistry {
|
||||
primaryColor);
|
||||
toolMaterials.put(materialID, mat);
|
||||
toolMaterialStrings.put(materialName, mat);
|
||||
} else
|
||||
throw new IllegalArgumentException(
|
||||
"[TCon API] Material ID " + materialID + " is already occupied by " + mat.materialName);
|
||||
} else throw new IllegalArgumentException(
|
||||
"[TCon API] Material ID " + materialID + " is already occupied by " + mat.materialName);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addToolMaterial(
|
||||
int materialID,
|
||||
String materialName,
|
||||
int harvestLevel,
|
||||
int durability,
|
||||
int miningspeed,
|
||||
int attack,
|
||||
float handleModifier,
|
||||
int reinforced,
|
||||
float stonebound,
|
||||
String style) {
|
||||
public static void addToolMaterial(int materialID, String materialName, int harvestLevel, int durability,
|
||||
int miningspeed, int attack, float handleModifier, int reinforced, float stonebound, String style) {
|
||||
logger.warn(
|
||||
"[TCon API] Using deprecated addToolMaterial with no primary color. A fallback of white will be used.");
|
||||
addToolMaterial(
|
||||
@@ -361,17 +291,8 @@ public class TConstructRegistry {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addToolMaterial(
|
||||
int materialID,
|
||||
String materialName,
|
||||
int harvestLevel,
|
||||
int durability,
|
||||
int miningspeed,
|
||||
int attack,
|
||||
float handleModifier,
|
||||
int reinforced,
|
||||
float stonebound,
|
||||
String style,
|
||||
public static void addToolMaterial(int materialID, String materialName, int harvestLevel, int durability,
|
||||
int miningspeed, int attack, float handleModifier, int reinforced, float stonebound, String style,
|
||||
String ability) {
|
||||
logger.warn(
|
||||
"[TCon API] Using deprecated addToolMaterial with ability name. ability will be ignored, use languages files for that.");
|
||||
@@ -389,19 +310,9 @@ public class TConstructRegistry {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addToolMaterial(
|
||||
int materialID,
|
||||
String materialName,
|
||||
String displayName,
|
||||
int harvestLevel,
|
||||
int durability,
|
||||
int miningspeed,
|
||||
int attack,
|
||||
float handleModifier,
|
||||
int reinforced,
|
||||
float stonebound,
|
||||
String style,
|
||||
String ability) {
|
||||
public static void addToolMaterial(int materialID, String materialName, String displayName, int harvestLevel,
|
||||
int durability, int miningspeed, int attack, float handleModifier, int reinforced, float stonebound,
|
||||
String style, String ability) {
|
||||
logger.warn(
|
||||
"[TCon API] Using deprecated addToolMaterial with display and ability name. displayName and ability will be ignored, use languages files for that.");
|
||||
addToolMaterial(
|
||||
@@ -420,27 +331,22 @@ public class TConstructRegistry {
|
||||
/**
|
||||
* Adds a tool material to the registry
|
||||
*
|
||||
* @param materialID
|
||||
* Unique ID, stored for each part
|
||||
* @param material
|
||||
* Complete tool material to add. Uses the name in the material
|
||||
* for lookup purposes.
|
||||
* @param materialID Unique ID, stored for each part
|
||||
* @param material Complete tool material to add. Uses the name in the material for lookup purposes.
|
||||
*/
|
||||
public static void addtoolMaterial(int materialID, ToolMaterial material) {
|
||||
ToolMaterial mat = toolMaterials.get(materialID);
|
||||
if (mat == null) {
|
||||
toolMaterials.put(materialID, material);
|
||||
toolMaterialStrings.put(material.name(), material);
|
||||
} else
|
||||
throw new IllegalArgumentException(
|
||||
"[TCon API] Material ID " + materialID + " is already occupied by " + mat.materialName);
|
||||
} else throw new IllegalArgumentException(
|
||||
"[TCon API] Material ID " + materialID + " is already occupied by " + mat.materialName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks up a tool material by ID
|
||||
*
|
||||
* @param key
|
||||
* The ID to look up
|
||||
* @param key The ID to look up
|
||||
* @return Tool Material
|
||||
*/
|
||||
public static ToolMaterial getMaterial(int key) {
|
||||
@@ -456,8 +362,7 @@ public class TConstructRegistry {
|
||||
/**
|
||||
* Looks up a tool material by name
|
||||
*
|
||||
* @param key
|
||||
* the name to look up
|
||||
* @param key the name to look up
|
||||
* @return Tool Material
|
||||
*/
|
||||
public static ToolMaterial getMaterial(String key) {
|
||||
@@ -519,59 +424,59 @@ public class TConstructRegistry {
|
||||
if (mat != null) customMaterials.add(mat);
|
||||
}
|
||||
|
||||
public static void addBowstringMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
ItemStack input,
|
||||
ItemStack craftingMaterial,
|
||||
float durability,
|
||||
float drawSpeed,
|
||||
float flightSpeed,
|
||||
int color) {
|
||||
public static void addBowstringMaterial(int materialID, int value, ItemStack input, ItemStack craftingMaterial,
|
||||
float durability, float drawSpeed, float flightSpeed, int color) {
|
||||
BowstringMaterial mat = new BowstringMaterial(
|
||||
materialID, value, input, craftingMaterial, durability, drawSpeed, flightSpeed, color);
|
||||
materialID,
|
||||
value,
|
||||
input,
|
||||
craftingMaterial,
|
||||
durability,
|
||||
drawSpeed,
|
||||
flightSpeed,
|
||||
color);
|
||||
customMaterials.add(mat);
|
||||
}
|
||||
|
||||
public static void addFletchingMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
ItemStack input,
|
||||
ItemStack craftingMaterial,
|
||||
float accuracy,
|
||||
float breakChance,
|
||||
float durabilityModifier,
|
||||
int color) {
|
||||
public static void addFletchingMaterial(int materialID, int value, ItemStack input, ItemStack craftingMaterial,
|
||||
float accuracy, float breakChance, float durabilityModifier, int color) {
|
||||
FletchingMaterial mat = new FletchingMaterial(
|
||||
materialID, value, input, craftingMaterial, accuracy, breakChance, durabilityModifier, color);
|
||||
materialID,
|
||||
value,
|
||||
input,
|
||||
craftingMaterial,
|
||||
accuracy,
|
||||
breakChance,
|
||||
durabilityModifier,
|
||||
color);
|
||||
customMaterials.add(mat);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addBowstringMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
ItemStack input,
|
||||
ItemStack craftingMaterial,
|
||||
float durability,
|
||||
float drawSpeed,
|
||||
float flightSpeed) {
|
||||
BowstringMaterial mat =
|
||||
new BowstringMaterial(materialID, value, input, craftingMaterial, durability, drawSpeed, flightSpeed);
|
||||
public static void addBowstringMaterial(int materialID, int value, ItemStack input, ItemStack craftingMaterial,
|
||||
float durability, float drawSpeed, float flightSpeed) {
|
||||
BowstringMaterial mat = new BowstringMaterial(
|
||||
materialID,
|
||||
value,
|
||||
input,
|
||||
craftingMaterial,
|
||||
durability,
|
||||
drawSpeed,
|
||||
flightSpeed);
|
||||
customMaterials.add(mat);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addFletchingMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
ItemStack input,
|
||||
ItemStack craftingMaterial,
|
||||
float accuracy,
|
||||
float breakChance,
|
||||
float mass) {
|
||||
FletchingMaterial mat =
|
||||
new FletchingMaterial(materialID, value, input, craftingMaterial, accuracy, breakChance, mass);
|
||||
public static void addFletchingMaterial(int materialID, int value, ItemStack input, ItemStack craftingMaterial,
|
||||
float accuracy, float breakChance, float mass) {
|
||||
FletchingMaterial mat = new FletchingMaterial(
|
||||
materialID,
|
||||
value,
|
||||
input,
|
||||
craftingMaterial,
|
||||
accuracy,
|
||||
breakChance,
|
||||
mass);
|
||||
customMaterials.add(mat);
|
||||
}
|
||||
|
||||
@@ -590,24 +495,16 @@ public class TConstructRegistry {
|
||||
}
|
||||
|
||||
/*
|
||||
* public static CustomMaterial getCustomMaterial(ItemStack input, ItemStack
|
||||
* pattern) { for (CustomMaterial mat : customMaterials) { if
|
||||
* (mat.matches(input, pattern)) return mat; } return null; }
|
||||
* public static CustomMaterial getCustomMaterial(ItemStack input, ItemStack pattern) { for (CustomMaterial mat :
|
||||
* customMaterials) { if (mat.matches(input, pattern)) return mat; } return null; }
|
||||
*/
|
||||
|
||||
/*
|
||||
* public static ItemStack craftBowString(ItemStack stack) { if
|
||||
* (stack.stackSize < 3) return null;
|
||||
*
|
||||
* for (BowstringMaterial mat : bowstringMaterials) { if
|
||||
* (stack.isItemEqual(mat.input)) return mat.craftingItem.copy(); } return
|
||||
* null; }
|
||||
*
|
||||
* public static BowstringMaterial getBowstringMaterial(ItemStack stack) {
|
||||
* if (stack.stackSize < 3) return null;
|
||||
*
|
||||
* for (BowstringMaterial mat : bowstringMaterials) { if
|
||||
* (stack.isItemEqual(mat.input)) return mat; } return null; }
|
||||
* public static ItemStack craftBowString(ItemStack stack) { if (stack.stackSize < 3) return null; for
|
||||
* (BowstringMaterial mat : bowstringMaterials) { if (stack.isItemEqual(mat.input)) return mat.craftingItem.copy();
|
||||
* } return null; } public static BowstringMaterial getBowstringMaterial(ItemStack stack) { if (stack.stackSize < 3)
|
||||
* return null; for (BowstringMaterial mat : bowstringMaterials) { if (stack.isItemEqual(mat.input)) return mat; }
|
||||
* return null; }
|
||||
*/
|
||||
|
||||
public static LiquidCasting getTableCasting() {
|
||||
@@ -667,9 +564,7 @@ public class TConstructRegistry {
|
||||
}
|
||||
|
||||
/**
|
||||
* Default Material Index 0: Wood 1: Stone 2: Iron 3: Flint 4: Cactus 5:
|
||||
* Bone 6: Obsidian 7: Netherrack 8: Green Slime 9: Paper 10: Cobalt 11:
|
||||
* Ardite 12: Manyullyn 13: Copper 14: Bronze 15: Alumite 16: Steel 17: Blue
|
||||
* Slime
|
||||
* Default Material Index 0: Wood 1: Stone 2: Iron 3: Flint 4: Cactus 5: Bone 6: Obsidian 7: Netherrack 8: Green
|
||||
* Slime 9: Paper 10: Cobalt 11: Ardite 12: Manyullyn 13: Copper 14: Bronze 15: Alumite 16: Steel 17: Blue Slime
|
||||
*/
|
||||
}
|
||||
@@ -1,18 +1,21 @@
|
||||
package tconstruct.library.accessory;
|
||||
|
||||
import cpw.mods.fml.relauncher.*;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.modifier.IModifyable;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import cpw.mods.fml.relauncher.*;
|
||||
|
||||
public abstract class AccessoryCore extends Item implements IAccessory, IModifyable {
|
||||
|
||||
/**
|
||||
* Override getArmorModel() to have render on the player.
|
||||
*/
|
||||
@@ -35,24 +38,19 @@ public abstract class AccessoryCore extends Item implements IAccessory, IModifya
|
||||
return "Accessory";
|
||||
}
|
||||
|
||||
static final String[] traits = new String[] {"accessory"};
|
||||
static final String[] traits = new String[] { "accessory" };
|
||||
|
||||
@Override
|
||||
public String[] getTraits() {
|
||||
return traits;
|
||||
}
|
||||
|
||||
/*public void getSubItems (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
ItemStack glove = new ItemStack(this);
|
||||
NBTTagCompound baseTag = new NBTTagCompound();
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setBoolean("Built", true);
|
||||
tag.setInteger("Modifiers", 5);
|
||||
baseTag.setTag(getBaseTag(), tag);
|
||||
glove.setTagCompound(baseTag);
|
||||
list.add(glove);
|
||||
}*/
|
||||
/*
|
||||
* public void getSubItems (int id, CreativeTabs tab, List list) { ItemStack glove = new ItemStack(this);
|
||||
* NBTTagCompound baseTag = new NBTTagCompound(); NBTTagCompound tag = new NBTTagCompound(); tag.setBoolean("Built",
|
||||
* true); tag.setInteger("Modifiers", 5); baseTag.setTag(getBaseTag(), tag); glove.setTagCompound(baseTag);
|
||||
* list.add(glove); }
|
||||
*/
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -3,7 +3,9 @@ package tconstruct.library.accessory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IAccessory {
|
||||
/** Accessory slots are not the same as armor slots!
|
||||
|
||||
/**
|
||||
* Accessory slots are not the same as armor slots!
|
||||
*
|
||||
* @param item Instance of the item
|
||||
* @param slot Accessory slot
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package tconstruct.library.accessory;
|
||||
|
||||
import cpw.mods.fml.relauncher.*;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import cpw.mods.fml.relauncher.*;
|
||||
|
||||
public interface IAccessoryModel {
|
||||
/** Similar to how armor is rendered.
|
||||
|
||||
/**
|
||||
* Similar to how armor is rendered.
|
||||
*
|
||||
* @param stack
|
||||
* @param entity
|
||||
|
||||
@@ -3,5 +3,6 @@ package tconstruct.library.accessory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IHealthAccessory extends IAccessory {
|
||||
|
||||
int getHealthBoost(ItemStack item);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package tconstruct.library.armor;
|
||||
|
||||
import cpw.mods.fml.relauncher.*;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
@@ -14,12 +14,15 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ISpecialArmor;
|
||||
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.modifier.*;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.tools.entity.FancyEntityItem;
|
||||
import cpw.mods.fml.relauncher.*;
|
||||
|
||||
public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IModifyable {
|
||||
|
||||
public final ArmorPart armorPart;
|
||||
private static final IBehaviorDispenseItem dispenserBehavior = new BehaviorDispenseArmorCopy();
|
||||
public final int baseProtection;
|
||||
@@ -63,7 +66,7 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
|
||||
@Override
|
||||
public String[] getTraits() {
|
||||
return new String[] {"armor"};
|
||||
return new String[] { "armor" };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,9 +75,8 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
ItemStack itemstack1 = player.getCurrentArmor(i);
|
||||
|
||||
if (itemstack1 == null) {
|
||||
player.setCurrentItemOrArmor(
|
||||
i + 1,
|
||||
stack.copy()); // Forge: Vanilla bug fix associated with fixed setCurrentItemOrArmor indexs for
|
||||
player.setCurrentItemOrArmor(i + 1, stack.copy()); // Forge: Vanilla bug fix associated with fixed
|
||||
// setCurrentItemOrArmor indexs for
|
||||
// players.
|
||||
stack.stackSize = 0;
|
||||
}
|
||||
@@ -102,12 +104,13 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
this.itemIcon = iconRegister.registerIcon("tinker:" + textureFolder + "/" + textureName
|
||||
+ (this.armorType == 0
|
||||
? "helmet"
|
||||
: this.armorType == 1
|
||||
? "chestplate"
|
||||
: this.armorType == 2 ? "pants" : this.armorType == 3 ? "boots" : "helmet"));
|
||||
this.itemIcon = iconRegister.registerIcon(
|
||||
"tinker:" + textureFolder
|
||||
+ "/"
|
||||
+ textureName
|
||||
+ (this.armorType == 0 ? "helmet"
|
||||
: this.armorType == 1 ? "chestplate"
|
||||
: this.armorType == 2 ? "pants" : this.armorType == 3 ? "boots" : "helmet"));
|
||||
registerModifiers(iconRegister);
|
||||
}
|
||||
|
||||
@@ -156,8 +159,8 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
|
||||
// ISpecialArmor overrides
|
||||
@Override
|
||||
public ArmorProperties getProperties(
|
||||
EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) {
|
||||
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage,
|
||||
int slot) {
|
||||
// Priority, absorbRatio, max
|
||||
if (!armor.hasTagCompound() || source.isUnblockable()) return new ArmorProperties(0, 0, 0);
|
||||
|
||||
@@ -207,8 +210,8 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
}
|
||||
|
||||
protected int combinedArmorDisplay(EntityPlayer player, ItemStack legs) {
|
||||
ItemStack[] armors =
|
||||
new ItemStack[] {player.getCurrentArmor(3), player.getCurrentArmor(2), legs, player.getCurrentArmor(0)};
|
||||
ItemStack[] armors = new ItemStack[] { player.getCurrentArmor(3), player.getCurrentArmor(2), legs,
|
||||
player.getCurrentArmor(0) };
|
||||
int types = 0;
|
||||
int max = 0;
|
||||
int damage = 0;
|
||||
@@ -370,10 +373,9 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
// strip color information
|
||||
String locString = "modifier.tooltip." + EnumChatFormatting.getTextWithoutFormattingCodes(tipName);
|
||||
locString = locString.replace(" ", "");
|
||||
if (StatCollector.canTranslate(locString))
|
||||
tipName = tipName.replace(
|
||||
EnumChatFormatting.getTextWithoutFormattingCodes(tipName),
|
||||
StatCollector.translateToLocal(locString));
|
||||
if (StatCollector.canTranslate(locString)) tipName = tipName.replace(
|
||||
EnumChatFormatting.getTextWithoutFormattingCodes(tipName),
|
||||
StatCollector.translateToLocal(locString));
|
||||
if (!tipName.equals("")) list.add(tipName);
|
||||
} else displayToolTips = false;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package tconstruct.library.armor;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import tconstruct.library.modifier.*;
|
||||
|
||||
public abstract class ArmorMod extends ItemModifier {
|
||||
|
||||
protected final EnumSet<ArmorPart> armorTypes;
|
||||
|
||||
public ArmorMod(int effect, String dataKey, EnumSet<ArmorPart> armorTypes, ItemStack[] items) {
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package tconstruct.library.armor;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class ArmorModTypeFilter extends ArmorMod {
|
||||
|
||||
public final List<Integer> increase;
|
||||
|
||||
public ArmorModTypeFilter(
|
||||
int effect, String dataKey, EnumSet<ArmorPart> armorTypes, ItemStack[] items, int[] values) {
|
||||
public ArmorModTypeFilter(int effect, String dataKey, EnumSet<ArmorPart> armorTypes, ItemStack[] items,
|
||||
int[] values) {
|
||||
super(effect, dataKey, armorTypes, items);
|
||||
assert items.length == values.length
|
||||
: "Itemstacks and their values for armor modifiers must be the same length";
|
||||
@@ -18,13 +20,10 @@ public abstract class ArmorModTypeFilter extends ArmorMod {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the inputs match the stored items Note: Filters types,
|
||||
* doesn't care about amount
|
||||
* Checks to see if the inputs match the stored items Note: Filters types, doesn't care about amount
|
||||
*
|
||||
* @param input
|
||||
* The ItemStacks to compare against
|
||||
* @param tool
|
||||
* Item to modify, used for restrictions
|
||||
* @param input The ItemStacks to compare against
|
||||
* @param tool Item to modify, used for restrictions
|
||||
* @return Whether the recipe matches the input
|
||||
*/
|
||||
@Override
|
||||
@@ -79,15 +78,12 @@ public abstract class ArmorModTypeFilter extends ArmorMod {
|
||||
/**
|
||||
* Adds a new itemstack to the list for increases
|
||||
*
|
||||
* @param stack
|
||||
* ItemStack to compare against
|
||||
* @param amount
|
||||
* Amount to increase
|
||||
* @param stack ItemStack to compare against
|
||||
* @param amount Amount to increase
|
||||
*/
|
||||
public void addStackToMatchList(ItemStack stack, int amount) {
|
||||
if (stack == null)
|
||||
throw new NullPointerException(
|
||||
"ItemStack added to " + this.getClass().getSimpleName() + " cannot be null.");
|
||||
if (stack == null) throw new NullPointerException(
|
||||
"ItemStack added to " + this.getClass().getSimpleName() + " cannot be null.");
|
||||
stacks.add(stack);
|
||||
increase.add(amount);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package tconstruct.library.armor;
|
||||
|
||||
public enum ArmorPart {
|
||||
|
||||
Head(0),
|
||||
Chest(1),
|
||||
Legs(2),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package tconstruct.library.armor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.command.IEntitySelector;
|
||||
import net.minecraft.dispenser.*;
|
||||
@@ -10,9 +11,9 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.*;
|
||||
|
||||
final class BehaviorDispenseArmorCopy extends BehaviorDefaultDispenseItem {
|
||||
|
||||
/**
|
||||
* Dispense the specified stack, play the dispense sound and spawn
|
||||
* particles.
|
||||
* Dispense the specified stack, play the dispense sound and spawn particles.
|
||||
*/
|
||||
@Override
|
||||
protected ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) {
|
||||
@@ -21,10 +22,10 @@ final class BehaviorDispenseArmorCopy extends BehaviorDefaultDispenseItem {
|
||||
int j = par1IBlockSource.getYInt() + enumfacing.getFrontOffsetY();
|
||||
int k = par1IBlockSource.getZInt() + enumfacing.getFrontOffsetZ();
|
||||
AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(i, j, k, i + 1, j + 1, k + 1);
|
||||
List<EntityLivingBase> list = par1IBlockSource
|
||||
.getWorld()
|
||||
.selectEntitiesWithinAABB(
|
||||
EntityLivingBase.class, axisalignedbb, new IEntitySelector.ArmoredMob(par2ItemStack));
|
||||
List<EntityLivingBase> list = par1IBlockSource.getWorld().selectEntitiesWithinAABB(
|
||||
EntityLivingBase.class,
|
||||
axisalignedbb,
|
||||
new IEntitySelector.ArmoredMob(par2ItemStack));
|
||||
|
||||
if (list.size() > 0) {
|
||||
EntityLivingBase entitylivingbase = list.get(0);
|
||||
|
||||
@@ -38,8 +38,10 @@ public class FluidRenderProperties {
|
||||
}
|
||||
|
||||
public enum Applications {
|
||||
|
||||
TABLE(0.9375F, 1F, 0.0625F, 0.9375F, 0.062F, 0.9375F),
|
||||
BASIN(0.25F, 0.95F, 0.0625F, 0.9375F, 0.0625F, 0.9375F);
|
||||
|
||||
public float minHeight, maxHeight, minX, maxX, minZ, maxZ;
|
||||
|
||||
Applications(float minHeight, float maxHeight, float minX, float maxX, float minZ, float maxZ) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package tconstruct.library.client;
|
||||
|
||||
public class GuiElement {
|
||||
|
||||
public final int buttonIconX;
|
||||
public final int buttonIconY;
|
||||
public final String domain;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package tconstruct.library.client;
|
||||
|
||||
public class StencilGuiElement extends GuiElement {
|
||||
|
||||
public final int stencilIndex;
|
||||
|
||||
public StencilGuiElement(int buttonIconX, int buttonIconY, int stencilIndex, String domain, String texture) {
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
package tconstruct.library.client;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import mantle.lib.client.MantleClientRegistry;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.crafting.ModifyBuilder;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public class TConstructClientRegistry {
|
||||
|
||||
public static ArrayList<StencilGuiElement> stencilButtons = new ArrayList<>();
|
||||
public static ArrayList<StencilGuiElement> stencilButtons2 = new ArrayList<>();
|
||||
public static ArrayList<ToolGuiElement> toolButtons = new ArrayList<>(20);
|
||||
@@ -16,8 +20,8 @@ public class TConstructClientRegistry {
|
||||
public static Map<String, ItemStack> manualIcons = new HashMap<>();
|
||||
public static ItemStack defaultStack = new ItemStack(Items.iron_ingot);
|
||||
|
||||
public static void addMaterialRenderMapping(
|
||||
int materialID, String domain, String renderName, boolean useDefaultFolder) {
|
||||
public static void addMaterialRenderMapping(int materialID, String domain, String renderName,
|
||||
boolean useDefaultFolder) {
|
||||
for (ToolCore tool : TConstructRegistry.getToolMapping()) {
|
||||
String[] toolIcons = new String[tool.getPartAmount() + 1];
|
||||
for (int i = 0; i < tool.getPartAmount() + 1; i++) {
|
||||
@@ -30,8 +34,8 @@ public class TConstructClientRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
public static void addAlternateMaterialRenderMapping(
|
||||
ToolCore tool, int materialID, String domain, String renderName, boolean useDefaultFolder) {
|
||||
public static void addAlternateMaterialRenderMapping(ToolCore tool, int materialID, String domain,
|
||||
String renderName, boolean useDefaultFolder) {
|
||||
String[] toolIcons = new String[tool.getPartAmount() + 1];
|
||||
for (int i = 0; i < tool.getPartAmount() + 1; i++) {
|
||||
String icon = domain + ":";
|
||||
@@ -42,16 +46,16 @@ public class TConstructClientRegistry {
|
||||
tool.registerAlternatePartPaths(materialID, toolIcons);
|
||||
}
|
||||
|
||||
public static void addEffectRenderMapping(
|
||||
ToolCore tool, int materialID, String domain, String renderName, boolean useDefaultFolder) {
|
||||
public static void addEffectRenderMapping(ToolCore tool, int materialID, String domain, String renderName,
|
||||
boolean useDefaultFolder) {
|
||||
String icon = domain + ":";
|
||||
if (useDefaultFolder) icon += tool.getDefaultFolder() + "/";
|
||||
icon += renderName + tool.getEffectSuffix();
|
||||
tool.registerEffectPath(materialID, icon);
|
||||
}
|
||||
|
||||
public static void addEffectRenderMapping(
|
||||
int materialID, String domain, String renderName, boolean useDefaultFolder) {
|
||||
public static void addEffectRenderMapping(int materialID, String domain, String renderName,
|
||||
boolean useDefaultFolder) {
|
||||
for (ToolCore tool : TConstructRegistry.getToolMapping()) {
|
||||
String icon = domain + ":";
|
||||
if (useDefaultFolder) icon += tool.getDefaultFolder() + "/";
|
||||
@@ -60,8 +64,8 @@ public class TConstructClientRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
public static void addSingleEffectRenderMapping(
|
||||
ToolCore tool, int materialID, String domain, String renderName, boolean useDefaultFolder) {
|
||||
public static void addSingleEffectRenderMapping(ToolCore tool, int materialID, String domain, String renderName,
|
||||
boolean useDefaultFolder) {
|
||||
String icon = domain + ":";
|
||||
if (useDefaultFolder) icon += tool.getDefaultFolder() + "/";
|
||||
icon += renderName + tool.getEffectSuffix();
|
||||
@@ -72,25 +76,27 @@ public class TConstructClientRegistry {
|
||||
registerManualModifier(name, output, topinput, null);
|
||||
}
|
||||
|
||||
public static void registerManualModifier(
|
||||
String name, ItemStack output, ItemStack topinput, ItemStack bottominput) {
|
||||
public static void registerManualModifier(String name, ItemStack output, ItemStack topinput,
|
||||
ItemStack bottominput) {
|
||||
ItemStack[] recipe = new ItemStack[3];
|
||||
recipe[0] = ModifyBuilder.instance.modifyItem(output, new ItemStack[] {topinput, bottominput
|
||||
}); // ToolBuilder.instance.buildTool(output, topinput, bottominput, "");
|
||||
recipe[0] = ModifyBuilder.instance.modifyItem(output, new ItemStack[] { topinput, bottominput }); // ToolBuilder.instance.buildTool(output,
|
||||
// topinput,
|
||||
// bottominput,
|
||||
// "");
|
||||
recipe[1] = topinput;
|
||||
recipe[2] = bottominput;
|
||||
MantleClientRegistry.recipeIcons.put(name, recipe);
|
||||
}
|
||||
|
||||
public static void registerManualModifier(
|
||||
String name, ItemStack output, ItemStack input1, ItemStack input2, ItemStack input3) {
|
||||
public static void registerManualModifier(String name, ItemStack output, ItemStack input1, ItemStack input2,
|
||||
ItemStack input3) {
|
||||
registerManualModifier(name, output, input1, input2, input3, null);
|
||||
}
|
||||
|
||||
public static void registerManualModifier(
|
||||
String name, ItemStack output, ItemStack input1, ItemStack input2, ItemStack input3, ItemStack input4) {
|
||||
public static void registerManualModifier(String name, ItemStack output, ItemStack input1, ItemStack input2,
|
||||
ItemStack input3, ItemStack input4) {
|
||||
ItemStack[] recipe = new ItemStack[5];
|
||||
recipe[0] = ModifyBuilder.instance.modifyItem(output, new ItemStack[] {input1, input2, input3, input4});
|
||||
recipe[0] = ModifyBuilder.instance.modifyItem(output, new ItemStack[] { input1, input2, input3, input4 });
|
||||
recipe[1] = input1;
|
||||
recipe[2] = input2;
|
||||
recipe[3] = input3;
|
||||
@@ -128,16 +134,8 @@ public class TConstructClientRegistry {
|
||||
toolButtons.add(element);
|
||||
}
|
||||
|
||||
public static void addToolButton(
|
||||
int slotType,
|
||||
int xButton,
|
||||
int yButton,
|
||||
int[] xIcons,
|
||||
int[] yIcons,
|
||||
String title,
|
||||
String body,
|
||||
String domain,
|
||||
String texture) {
|
||||
public static void addToolButton(int slotType, int xButton, int yButton, int[] xIcons, int[] yIcons, String title,
|
||||
String body, String domain, String texture) {
|
||||
toolButtons.add(new ToolGuiElement(slotType, xButton, yButton, xIcons, yIcons, title, body, domain, texture));
|
||||
}
|
||||
|
||||
@@ -145,18 +143,10 @@ public class TConstructClientRegistry {
|
||||
tierTwoButtons.add(element);
|
||||
}
|
||||
|
||||
public static void addTierTwoButton(
|
||||
int slotType,
|
||||
int xButton,
|
||||
int yButton,
|
||||
int[] xIcons,
|
||||
int[] yIcons,
|
||||
String title,
|
||||
String body,
|
||||
String domain,
|
||||
String texture) {
|
||||
tierTwoButtons.add(
|
||||
new ToolGuiElement(slotType, xButton, yButton, xIcons, yIcons, title, body, domain, texture));
|
||||
public static void addTierTwoButton(int slotType, int xButton, int yButton, int[] xIcons, int[] yIcons,
|
||||
String title, String body, String domain, String texture) {
|
||||
tierTwoButtons
|
||||
.add(new ToolGuiElement(slotType, xButton, yButton, xIcons, yIcons, title, body, domain, texture));
|
||||
}
|
||||
|
||||
public static ArrayList<ToolGuiElement> getToolButtons() {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package tconstruct.library.client;
|
||||
|
||||
public class ToolGuiElement extends GuiElement {
|
||||
|
||||
public final int slotType;
|
||||
public final int[] iconsX;
|
||||
public final int[] iconsY;
|
||||
|
||||
@@ -3,5 +3,6 @@ package tconstruct.library.component;
|
||||
import java.util.List;
|
||||
|
||||
public interface IComponentHolder {
|
||||
|
||||
List<LogicComponent> getComponents();
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class LogicComponent {
|
||||
|
||||
protected World world;
|
||||
|
||||
public void setWorld(World world) {
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package tconstruct.library.component;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraftforge.fluids.*;
|
||||
|
||||
import tconstruct.library.crafting.Smeltery;
|
||||
|
||||
public class MultiFluidTank extends LogicComponent implements IFluidTank {
|
||||
|
||||
public ArrayList<FluidStack> fluidlist = new ArrayList<>();
|
||||
protected int maxLiquid;
|
||||
protected int currentLiquid;
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
package tconstruct.library.component;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import mantle.blocks.iface.*;
|
||||
import mantle.world.*;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
|
||||
public class TankLayerScan extends LogicComponent {
|
||||
|
||||
protected TileEntity master;
|
||||
protected IMasterLogic imaster;
|
||||
protected Block[] scanBlocks;
|
||||
@@ -28,10 +32,16 @@ public class TankLayerScan extends LogicComponent {
|
||||
protected CoordTuple returnStone;
|
||||
|
||||
private static final boolean debug = System.getenv("DBG_MANTLE_TankLayerScan") != null;
|
||||
private static final int MAX_LAYER_RECURSION_DEPTH =
|
||||
System.getProperty("os.arch").equals("amd64")
|
||||
? 4000
|
||||
: 2000; // Recursion causes overflows on 32-bit, so reduce if not 64-bit
|
||||
private static final int MAX_LAYER_RECURSION_DEPTH = System.getProperty("os.arch").equals("amd64") ? 4000 : 2000; // Recursion
|
||||
// causes
|
||||
// overflows
|
||||
// on
|
||||
// 32-bit,
|
||||
// so
|
||||
// reduce
|
||||
// if
|
||||
// not
|
||||
// 64-bit
|
||||
|
||||
public TankLayerScan(TileEntity te, Block... ids) {
|
||||
assert te instanceof IMasterLogic : "TileEntity must be an instance of IMasterLogic";
|
||||
@@ -39,14 +49,16 @@ public class TankLayerScan extends LogicComponent {
|
||||
imaster = (IMasterLogic) te;
|
||||
scanBlocks = ids;
|
||||
masterCoord = new CoordTuple(te.xCoord, te.yCoord, te.zCoord);
|
||||
validAirCoords.add(new int[] {1, 0});
|
||||
validAirCoords.add(new int[] {-1, 0});
|
||||
validAirCoords.add(new int[] {0, 1});
|
||||
validAirCoords.add(new int[] {0, -1});
|
||||
validAirCoords.add(new int[] { 1, 0 });
|
||||
validAirCoords.add(new int[] { -1, 0 });
|
||||
validAirCoords.add(new int[] { 0, 1 });
|
||||
validAirCoords.add(new int[] { 0, -1 });
|
||||
if (debug) {
|
||||
TConstruct.logger.info("In debug mode: " + this);
|
||||
TConstruct.logger.info("Using recursion size " + MAX_LAYER_RECURSION_DEPTH + " on JVM arch "
|
||||
+ System.getProperty("os.arch"));
|
||||
TConstruct.logger.info(
|
||||
"Using recursion size " + MAX_LAYER_RECURSION_DEPTH
|
||||
+ " on JVM arch "
|
||||
+ System.getProperty("os.arch"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,12 +74,14 @@ public class TankLayerScan extends LogicComponent {
|
||||
case 2: // +z
|
||||
case 3: // -z
|
||||
if (checkAir(master.xCoord, master.yCoord, master.zCoord - 1)
|
||||
&& checkAir(master.xCoord, master.yCoord, master.zCoord + 1)) validAir = true;
|
||||
&& checkAir(master.xCoord, master.yCoord, master.zCoord + 1))
|
||||
validAir = true;
|
||||
break;
|
||||
case 4: // +x
|
||||
case 5: // -x
|
||||
if (checkAir(master.xCoord - 1, master.yCoord, master.zCoord)
|
||||
&& checkAir(master.xCoord + 1, master.yCoord, master.zCoord)) validAir = true;
|
||||
&& checkAir(master.xCoord + 1, master.yCoord, master.zCoord))
|
||||
validAir = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -434,19 +448,19 @@ public class TankLayerScan extends LogicComponent {
|
||||
super.writeToNBT(tags);
|
||||
NBTTagList layerAir = new NBTTagList();
|
||||
for (CoordTuple coord : layerAirCoords) {
|
||||
layerAir.appendTag(new NBTTagIntArray(new int[] {coord.x, coord.y, coord.z}));
|
||||
layerAir.appendTag(new NBTTagIntArray(new int[] { coord.x, coord.y, coord.z }));
|
||||
}
|
||||
tags.setTag("AirLayer", layerAir);
|
||||
|
||||
NBTTagList blocks = new NBTTagList();
|
||||
for (CoordTuple coord : blockCoords) {
|
||||
blocks.appendTag(new NBTTagIntArray(new int[] {coord.x, coord.y, coord.z}));
|
||||
blocks.appendTag(new NBTTagIntArray(new int[] { coord.x, coord.y, coord.z }));
|
||||
}
|
||||
tags.setTag("Blocks", blocks);
|
||||
|
||||
NBTTagList air = new NBTTagList();
|
||||
for (CoordTuple coord : airCoords) {
|
||||
air.appendTag(new NBTTagIntArray(new int[] {coord.x, coord.y, coord.z}));
|
||||
air.appendTag(new NBTTagIntArray(new int[] { coord.x, coord.y, coord.z }));
|
||||
}
|
||||
tags.setTag("Air", air);
|
||||
tags.setInteger("structureTop", structureTop);
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package tconstruct.library.crafting;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class AlloyMix {
|
||||
|
||||
public final FluidStack result;
|
||||
public final List<FluidStack> mixers;
|
||||
|
||||
@@ -13,8 +15,7 @@ public class AlloyMix {
|
||||
}
|
||||
|
||||
/*
|
||||
* public boolean matches(List liquids) { ArrayList list = new
|
||||
* ArrayList(mixers); return false; }
|
||||
* public boolean matches(List liquids) { ArrayList list = new ArrayList(mixers); return false; }
|
||||
*/
|
||||
|
||||
public FluidStack mix(ArrayList<FluidStack> liquids) {
|
||||
|
||||
@@ -3,9 +3,11 @@ package tconstruct.library.crafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import tconstruct.library.client.FluidRenderProperties;
|
||||
|
||||
public class CastingRecipe {
|
||||
|
||||
public ItemStack output;
|
||||
public FluidStack castingMetal;
|
||||
public ItemStack cast;
|
||||
@@ -14,14 +16,8 @@ public class CastingRecipe {
|
||||
public FluidRenderProperties fluidRenderProperties;
|
||||
public boolean ignoreNBT;
|
||||
|
||||
public CastingRecipe(
|
||||
ItemStack replacement,
|
||||
FluidStack metal,
|
||||
ItemStack cast,
|
||||
boolean consume,
|
||||
int delay,
|
||||
FluidRenderProperties props,
|
||||
boolean ignoreNBT) {
|
||||
public CastingRecipe(ItemStack replacement, FluidStack metal, ItemStack cast, boolean consume, int delay,
|
||||
FluidRenderProperties props, boolean ignoreNBT) {
|
||||
castingMetal = metal;
|
||||
this.cast = cast;
|
||||
output = replacement;
|
||||
@@ -31,20 +27,14 @@ public class CastingRecipe {
|
||||
this.ignoreNBT = ignoreNBT;
|
||||
}
|
||||
|
||||
public CastingRecipe(
|
||||
ItemStack replacement,
|
||||
FluidStack metal,
|
||||
ItemStack cast,
|
||||
boolean consume,
|
||||
int delay,
|
||||
public CastingRecipe(ItemStack replacement, FluidStack metal, ItemStack cast, boolean consume, int delay,
|
||||
FluidRenderProperties props) {
|
||||
this(replacement, metal, cast, consume, delay, props, false);
|
||||
}
|
||||
|
||||
public boolean matches(FluidStack metal, ItemStack inputCast) {
|
||||
if (castingMetal.isFluidEqual(metal)) {
|
||||
if (cast != null
|
||||
&& cast.getItemDamage() == OreDictionary.WILDCARD_VALUE
|
||||
if (cast != null && cast.getItemDamage() == OreDictionary.WILDCARD_VALUE
|
||||
&& inputCast.getItem() == cast.getItem()) {
|
||||
return true;
|
||||
} else if (!ignoreNBT && ItemStack.areItemStacksEqual(cast, inputCast)) {
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
package tconstruct.library.crafting;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class Detailing {
|
||||
|
||||
public List<DetailInput> detailing = new ArrayList<>();
|
||||
|
||||
public void addDetailing(Object input, int inputMeta, Object output, int outputMeta, ToolCore tool) {
|
||||
@@ -73,6 +76,7 @@ public class Detailing {
|
||||
}
|
||||
|
||||
public static class DetailInput {
|
||||
|
||||
public ItemStack input;
|
||||
public int inputMeta;
|
||||
public ItemStack output;
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package tconstruct.library.crafting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.*;
|
||||
|
||||
public class DryingRackRecipes {
|
||||
|
||||
public static ArrayList<DryingRecipe> recipes = new ArrayList<>();
|
||||
|
||||
public static void addDryingRecipe(Object input, int time, Object output) {
|
||||
@@ -41,6 +43,7 @@ public class DryingRackRecipes {
|
||||
}
|
||||
|
||||
public static class DryingRecipe {
|
||||
|
||||
public final int time;
|
||||
public final ItemStack input;
|
||||
public final ItemStack result;
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package tconstruct.library.crafting;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
public class FluidType {
|
||||
|
||||
public final Block renderBlock;
|
||||
public final int renderMeta;
|
||||
public final int baseTemperature;
|
||||
@@ -25,8 +27,8 @@ public class FluidType {
|
||||
fluidTypes.put(name, type);
|
||||
}
|
||||
|
||||
public static void registerFluidType(
|
||||
String name, Block block, int meta, int baseTemperature, Fluid fluid, boolean isToolpart) {
|
||||
public static void registerFluidType(String name, Block block, int meta, int baseTemperature, Fluid fluid,
|
||||
boolean isToolpart) {
|
||||
FluidType type = new FluidType(block, meta, baseTemperature, fluid, isToolpart);
|
||||
registerFluidType(name, type);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package tconstruct.library.crafting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import tconstruct.library.client.FluidRenderProperties;
|
||||
|
||||
/* Melting becomes hardened */
|
||||
public class LiquidCasting {
|
||||
|
||||
// public static LiquidCasting instance = new LiquidCasting();
|
||||
private final ArrayList<CastingRecipe> casts = new ArrayList<>();
|
||||
|
||||
@@ -20,26 +23,14 @@ public class LiquidCasting {
|
||||
/**
|
||||
* Adds a casting recipe
|
||||
*
|
||||
* @param output
|
||||
* Result of the cast
|
||||
* @param metal
|
||||
* Liquid to be used in casting. This also decides how much metal
|
||||
* is consumed
|
||||
* @param cast
|
||||
* The empty item to cast with. ex Ingot Cast
|
||||
* @param consume
|
||||
* Whether the item should be consumed while casting
|
||||
* @param delay
|
||||
* Time to cast in ticks
|
||||
* @param props
|
||||
* The rendering properties for the casting fluid (may be null)
|
||||
* @param output Result of the cast
|
||||
* @param metal Liquid to be used in casting. This also decides how much metal is consumed
|
||||
* @param cast The empty item to cast with. ex Ingot Cast
|
||||
* @param consume Whether the item should be consumed while casting
|
||||
* @param delay Time to cast in ticks
|
||||
* @param props The rendering properties for the casting fluid (may be null)
|
||||
*/
|
||||
public void addCastingRecipe(
|
||||
ItemStack output,
|
||||
FluidStack metal,
|
||||
ItemStack cast,
|
||||
boolean consume,
|
||||
int delay,
|
||||
public void addCastingRecipe(ItemStack output, FluidStack metal, ItemStack cast, boolean consume, int delay,
|
||||
FluidRenderProperties props) {
|
||||
CastingRecipe cr = new CastingRecipe(output, metal, cast, consume, delay, props);
|
||||
if (!contains(cr)) casts.add(cr);
|
||||
@@ -48,17 +39,11 @@ public class LiquidCasting {
|
||||
/**
|
||||
* Adds a casting recipe
|
||||
*
|
||||
* @param output
|
||||
* Result of the cast
|
||||
* @param metal
|
||||
* Liquid to be used in casting. This also decides how much metal
|
||||
* is consumed
|
||||
* @param cast
|
||||
* The empty item to cast with. ex Ingot Cast
|
||||
* @param consume
|
||||
* Whether the item should be consumed while casting
|
||||
* @param delay
|
||||
* Time to cast in ticks
|
||||
* @param output Result of the cast
|
||||
* @param metal Liquid to be used in casting. This also decides how much metal is consumed
|
||||
* @param cast The empty item to cast with. ex Ingot Cast
|
||||
* @param consume Whether the item should be consumed while casting
|
||||
* @param delay Time to cast in ticks
|
||||
*/
|
||||
public void addCastingRecipe(ItemStack output, FluidStack metal, ItemStack cast, boolean consume, int delay) {
|
||||
addCastingRecipe(output, metal, cast, consume, delay, null);
|
||||
@@ -67,69 +52,47 @@ public class LiquidCasting {
|
||||
/**
|
||||
* Adds a casting recipe. Does not consume the cast
|
||||
*
|
||||
* @param output
|
||||
* Result of the cast
|
||||
* @param metal
|
||||
* Liquid to be used in casting. This also decides how much metal
|
||||
* is consumed
|
||||
* @param cast
|
||||
* The empty item to cast with. ex Ingot Cast
|
||||
* @param delay
|
||||
* Time to cast in ticks
|
||||
* @param props
|
||||
* The rendering properties for the casting fluid (may be null)
|
||||
* @param output Result of the cast
|
||||
* @param metal Liquid to be used in casting. This also decides how much metal is consumed
|
||||
* @param cast The empty item to cast with. ex Ingot Cast
|
||||
* @param delay Time to cast in ticks
|
||||
* @param props The rendering properties for the casting fluid (may be null)
|
||||
*/
|
||||
public void addCastingRecipe(
|
||||
ItemStack output, FluidStack metal, ItemStack cast, int delay, FluidRenderProperties props) {
|
||||
public void addCastingRecipe(ItemStack output, FluidStack metal, ItemStack cast, int delay,
|
||||
FluidRenderProperties props) {
|
||||
addCastingRecipe(output, metal, cast, false, delay, props);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a casting recipe. Does not consume the cast
|
||||
*
|
||||
* @param output
|
||||
* Result of the cast
|
||||
* @param metal
|
||||
* Liquid to be used in casting. This also decides how much metal
|
||||
* is consumed
|
||||
* @param cast
|
||||
* The empty item to cast with. ex Ingot Cast
|
||||
* @param delay
|
||||
* Time to cast in ticks
|
||||
* @param output Result of the cast
|
||||
* @param metal Liquid to be used in casting. This also decides how much metal is consumed
|
||||
* @param cast The empty item to cast with. ex Ingot Cast
|
||||
* @param delay Time to cast in ticks
|
||||
*/
|
||||
public void addCastingRecipe(ItemStack output, FluidStack metal, ItemStack cast, int delay) {
|
||||
addCastingRecipe(output, metal, cast, false, delay, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a casting recipe. Does not consume the cast or have an item to cast
|
||||
* against
|
||||
* Adds a casting recipe. Does not consume the cast or have an item to cast against
|
||||
*
|
||||
* @param output
|
||||
* Result of the cast
|
||||
* @param metal
|
||||
* Liquid to be used in casting. This also decides how much metal
|
||||
* is consumed
|
||||
* @param delay
|
||||
* Time to cast in ticks
|
||||
* @param props
|
||||
* The rendering properties for the casting fluid (may be null)
|
||||
* @param output Result of the cast
|
||||
* @param metal Liquid to be used in casting. This also decides how much metal is consumed
|
||||
* @param delay Time to cast in ticks
|
||||
* @param props The rendering properties for the casting fluid (may be null)
|
||||
*/
|
||||
public void addCastingRecipe(ItemStack output, FluidStack metal, int delay, FluidRenderProperties props) {
|
||||
addCastingRecipe(output, metal, null, false, delay, props);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a casting recipe. Does not consume the cast or have an item to cast
|
||||
* against
|
||||
* Adds a casting recipe. Does not consume the cast or have an item to cast against
|
||||
*
|
||||
* @param output
|
||||
* Result of the cast
|
||||
* @param metal
|
||||
* Liquid to be used in casting. This also decides how much metal
|
||||
* is consumed
|
||||
* @param delay
|
||||
* Time to cast in ticks
|
||||
* @param output Result of the cast
|
||||
* @param metal Liquid to be used in casting. This also decides how much metal is consumed
|
||||
* @param delay Time to cast in ticks
|
||||
*/
|
||||
public void addCastingRecipe(ItemStack output, FluidStack metal, int delay) {
|
||||
addCastingRecipe(output, metal, null, false, delay, null);
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package tconstruct.library.crafting;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import tconstruct.library.event.ModifyEvent;
|
||||
import tconstruct.library.modifier.*;
|
||||
|
||||
public class ModifyBuilder {
|
||||
|
||||
public static ModifyBuilder instance = new ModifyBuilder();
|
||||
public List<ItemModifier> itemModifiers = new ArrayList<>();
|
||||
|
||||
@@ -27,10 +30,8 @@ public class ModifyBuilder {
|
||||
mod.modify(modifiers, copy);
|
||||
|
||||
// we do not allow negative modifiers >:(
|
||||
if (copy.getTagCompound()
|
||||
.getCompoundTag(item.getBaseTagName())
|
||||
.getInteger("Modifiers")
|
||||
< 0) return null;
|
||||
if (copy.getTagCompound().getCompoundTag(item.getBaseTagName()).getInteger("Modifiers") < 0)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (built) return copy;
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
package tconstruct.library.crafting;
|
||||
|
||||
/** How to build tool parts? With patterns! */
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.event.PartBuilderEvent;
|
||||
import tconstruct.library.tools.CustomMaterial;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
|
||||
public class PatternBuilder {
|
||||
|
||||
public static PatternBuilder instance = new PatternBuilder();
|
||||
// Map items to their parts with a hashmap
|
||||
public List<ItemKey> materials = new ArrayList<>();
|
||||
@@ -30,8 +33,8 @@ public class PatternBuilder {
|
||||
materials.add(new ItemKey(shard.getItem(), shard.getItemDamage(), 1, key));
|
||||
}
|
||||
|
||||
public void registerFullMaterial(
|
||||
ItemStack material, int value, String key, ItemStack shard, ItemStack rod, int materialID) {
|
||||
public void registerFullMaterial(ItemStack material, int value, String key, ItemStack shard, ItemStack rod,
|
||||
int materialID) {
|
||||
materials.add(new ItemKey(material.getItem(), material.getItemDamage(), value, key));
|
||||
materials.add(new ItemKey(shard.getItem(), shard.getItemDamage(), 1, key));
|
||||
materialSets.put(key, new MaterialSet(shard, rod, materialID));
|
||||
@@ -63,31 +66,23 @@ public class PatternBuilder {
|
||||
int totalMaterial = key.value * material.stackSize;
|
||||
|
||||
if (totalMaterial < patternValue) // Not enough material
|
||||
return null;
|
||||
return null;
|
||||
else if (patternValue == key.value) // Material only
|
||||
return new ItemStack[] {toolPart, null};
|
||||
return new ItemStack[] { toolPart, null };
|
||||
else {
|
||||
if (patternValue % 2 == 1 && mat.shard != null) {
|
||||
return new ItemStack[] {toolPart, mat.shard.copy()}; // Material
|
||||
return new ItemStack[] { toolPart, mat.shard.copy() }; // Material
|
||||
// +
|
||||
// shard
|
||||
} else return new ItemStack[] {toolPart, null};
|
||||
} else return new ItemStack[] { toolPart, null };
|
||||
}
|
||||
/*
|
||||
* if ( patternValue < totalMaterial ) { if (otherPattern !=
|
||||
* null) { int otherValue =
|
||||
* ((IPattern)otherPattern.getItem()
|
||||
* ).getPatternCost(otherPattern.getItemDamage()); if
|
||||
* (patternValue + otherValue <= key.value) { ItemStack
|
||||
* otherPart = getMatchingPattern(otherPattern, mat); return
|
||||
* new ItemStack[] { toolPart, otherPart }; //Material +
|
||||
* Material } } }
|
||||
*
|
||||
* else if ( patternValue == key.value ) return new
|
||||
* ItemStack[] { new ItemStack(toolPart, 1, mat.materialID),
|
||||
* null }; //Material only
|
||||
*
|
||||
* else return null; //Not a valid match
|
||||
* if ( patternValue < totalMaterial ) { if (otherPattern != null) { int otherValue =
|
||||
* ((IPattern)otherPattern.getItem() ).getPatternCost(otherPattern.getItemDamage()); if
|
||||
* (patternValue + otherValue <= key.value) { ItemStack otherPart = getMatchingPattern(otherPattern,
|
||||
* mat); return new ItemStack[] { toolPart, otherPart }; //Material + Material } } } else if (
|
||||
* patternValue == key.value ) return new ItemStack[] { new ItemStack(toolPart, 1, mat.materialID),
|
||||
* null }; //Material only else return null; //Not a valid match
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -150,6 +145,7 @@ public class PatternBuilder {
|
||||
// Small data classes. I would prefer the struct from C#, but we do what we
|
||||
// can.
|
||||
public static class ItemKey {
|
||||
|
||||
public final Item item;
|
||||
public final int damage;
|
||||
public final int value;
|
||||
@@ -164,6 +160,7 @@ public class PatternBuilder {
|
||||
}
|
||||
|
||||
public static class MaterialSet {
|
||||
|
||||
public final ItemStack shard;
|
||||
public final ItemStack rod;
|
||||
public final int materialID;
|
||||
@@ -184,27 +181,22 @@ public class PatternBuilder {
|
||||
registerMaterial(new ItemStack(material, 1, Short.MAX_VALUE), value, key);
|
||||
}
|
||||
|
||||
public void registerFullMaterial(
|
||||
Block material, int value, String key, ItemStack shard, ItemStack rod, int materialID) {
|
||||
public void registerFullMaterial(Block material, int value, String key, ItemStack shard, ItemStack rod,
|
||||
int materialID) {
|
||||
registerFullMaterial(new ItemStack(material, 1, Short.MAX_VALUE), value, key, shard, rod, materialID);
|
||||
}
|
||||
|
||||
public void registerFullMaterial(
|
||||
Item material, int value, String key, ItemStack shard, ItemStack rod, int materialID) {
|
||||
public void registerFullMaterial(Item material, int value, String key, ItemStack shard, ItemStack rod,
|
||||
int materialID) {
|
||||
registerFullMaterial(new ItemStack(material, 1, Short.MAX_VALUE), value, key, shard, rod, materialID);
|
||||
}
|
||||
|
||||
/*
|
||||
* public void registerFullMaterial (Block material, int value, String key,
|
||||
* int materialID) { registerFullMaterial(new ItemStack(material, 1,
|
||||
* Short.MAX_VALUE), value, key, new ItemStack(TContent.toolShard, 1,
|
||||
* materialID), new ItemStack(TContent.toolRod, 1, materialID), materialID);
|
||||
* }
|
||||
*
|
||||
* public void registerFullMaterial (Item material, int value, String key,
|
||||
* int materialID) { registerFullMaterial(new ItemStack(material, 1,
|
||||
* Short.MAX_VALUE), value, key, new ItemStack(TContent.toolShard, 1,
|
||||
* materialID), new ItemStack(TContent.toolRod, 1, materialID), materialID);
|
||||
* }
|
||||
* public void registerFullMaterial (Block material, int value, String key, int materialID) {
|
||||
* registerFullMaterial(new ItemStack(material, 1, Short.MAX_VALUE), value, key, new ItemStack(TContent.toolShard,
|
||||
* 1, materialID), new ItemStack(TContent.toolRod, 1, materialID), materialID); } public void registerFullMaterial
|
||||
* (Item material, int value, String key, int materialID) { registerFullMaterial(new ItemStack(material, 1,
|
||||
* Short.MAX_VALUE), value, key, new ItemStack(TContent.toolShard, 1, materialID), new ItemStack(TContent.toolRod,
|
||||
* 1, materialID), materialID); }
|
||||
*/
|
||||
}
|
||||
@@ -1,19 +1,25 @@
|
||||
package tconstruct.library.crafting;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public class ShapelessToolRecipe extends ShapelessRecipes {
|
||||
|
||||
static {
|
||||
RecipeSorter.register(
|
||||
TConstruct.modID + ":" + "toolrecipe", ShapelessToolRecipe.class, RecipeSorter.Category.SHAPELESS, "");
|
||||
TConstruct.modID + ":" + "toolrecipe",
|
||||
ShapelessToolRecipe.class,
|
||||
RecipeSorter.Category.SHAPELESS,
|
||||
"");
|
||||
}
|
||||
|
||||
public ShapelessToolRecipe(ItemStack par1ItemStack, List par2List) {
|
||||
@@ -40,7 +46,8 @@ public class ShapelessToolRecipe extends ShapelessRecipes {
|
||||
|
||||
flag = true;
|
||||
} else if ((itemstack1.getItemDamage() == Short.MAX_VALUE
|
||||
|| itemstack.getItemDamage() == itemstack1.getItemDamage())) flag = true;
|
||||
|| itemstack.getItemDamage() == itemstack1.getItemDamage()))
|
||||
flag = true;
|
||||
|
||||
arraylist.remove(itemstack1);
|
||||
break;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package tconstruct.library.crafting;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import mantle.utils.ItemMetaWrapper;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraftforge.fluids.*;
|
||||
@@ -9,6 +11,7 @@ import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
/** Melting and hacking, churn and burn */
|
||||
public class Smeltery {
|
||||
|
||||
public static Smeltery instance = new Smeltery();
|
||||
|
||||
private final Map<ItemMetaWrapper, FluidStack> smeltingList = new HashMap<>();
|
||||
@@ -19,12 +22,13 @@ public class Smeltery {
|
||||
|
||||
/**
|
||||
* Add a new fluid as a valid Smeltery fuel.
|
||||
* @param fluid The fluid.
|
||||
* @param power The temperature of the fluid. This also influences the melting speed. Lava is 1000.
|
||||
*
|
||||
* @param fluid The fluid.
|
||||
* @param power The temperature of the fluid. This also influences the melting speed. Lava is 1000.
|
||||
* @param duration How long one "portion" of liquid fuels the smeltery. Lava is 10.
|
||||
*/
|
||||
public static void addSmelteryFuel(Fluid fluid, int power, int duration) {
|
||||
instance.smelteryFuels.put(fluid, new Integer[] {power, duration});
|
||||
instance.smelteryFuels.put(fluid, new Integer[] { power, duration });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,13 +55,13 @@ public class Smeltery {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds mappings between an itemstack and an output liquid Example:
|
||||
* Smeltery.addMelting(Block.oreIron, 0, 600, new
|
||||
* Adds mappings between an itemstack and an output liquid Example: Smeltery.addMelting(Block.oreIron, 0, 600, new
|
||||
* FluidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue * 2, 0));
|
||||
*
|
||||
* @param stack The itemstack to liquify. Must hold a block.
|
||||
* @param temperature How hot the block should be before liquifying. Max temp in the Smeltery is 800, other structures may vary
|
||||
* @param output The result of the process in liquid form
|
||||
* @param stack The itemstack to liquify. Must hold a block.
|
||||
* @param temperature How hot the block should be before liquifying. Max temp in the Smeltery is 800, other
|
||||
* structures may vary
|
||||
* @param output The result of the process in liquid form
|
||||
*/
|
||||
public static void addMelting(ItemStack stack, int temperature, FluidStack output) {
|
||||
if (stack.getItem() instanceof ItemBlock)
|
||||
@@ -66,30 +70,29 @@ public class Smeltery {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds mappings between a block and its liquid Example:
|
||||
* Smeltery.addMelting(Block.oreIron, 0, 600, new
|
||||
* Adds mappings between a block and its liquid Example: Smeltery.addMelting(Block.oreIron, 0, 600, new
|
||||
* FluidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue * 2, 0));
|
||||
*
|
||||
* @param block The block to liquify and render
|
||||
* @param metadata The metadata of the block to liquify and render
|
||||
* @param temperature How hot the block should be before liquifying. Max temp in the Smeltery is 800, other structures may vary
|
||||
* @param output The result of the process in liquid form
|
||||
* @param block The block to liquify and render
|
||||
* @param metadata The metadata of the block to liquify and render
|
||||
* @param temperature How hot the block should be before liquifying. Max temp in the Smeltery is 800, other
|
||||
* structures may vary
|
||||
* @param output The result of the process in liquid form
|
||||
*/
|
||||
public static void addMelting(Block block, int metadata, int temperature, FluidStack output) {
|
||||
addMelting(new ItemStack(block, 1, metadata), block, metadata, temperature, output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds mappings between an input and its liquid. Renders with the given
|
||||
* input's block ID and metadata Example: Smeltery.addMelting(Block.oreIron,
|
||||
* 0, 600, new FluidStack(liquidMetalStill.blockID,
|
||||
* TConstruct.ingotLiquidValue * 2, 0));
|
||||
* Adds mappings between an input and its liquid. Renders with the given input's block ID and metadata Example:
|
||||
* Smeltery.addMelting(Block.oreIron, 0, 600, new FluidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue *
|
||||
* 2, 0));
|
||||
*
|
||||
* @param input The item to liquify
|
||||
* @param block The block to render
|
||||
* @param metadata The metadata of the block to render
|
||||
* @param input The item to liquify
|
||||
* @param block The block to render
|
||||
* @param metadata The metadata of the block to render
|
||||
* @param temperature How hot the block should be before liquifying
|
||||
* @param liquid The result of the process
|
||||
* @param liquid The result of the process
|
||||
*/
|
||||
public static void addMelting(ItemStack input, Block block, int metadata, int temperature, FluidStack liquid) {
|
||||
ItemMetaWrapper in = new ItemMetaWrapper(input);
|
||||
@@ -99,10 +102,8 @@ public class Smeltery {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an alloy mixing recipe. Example: Smeltery.addAlloyMixing(new
|
||||
* FluidStack(bronzeID, 2, 0), new FluidStack(copperID, 3, 0), new
|
||||
* FluidStack(tinID, 1, 0)); The example mixes 3 copper with 1 tin to make 2
|
||||
* bronze
|
||||
* Adds an alloy mixing recipe. Example: Smeltery.addAlloyMixing(new FluidStack(bronzeID, 2, 0), new
|
||||
* FluidStack(copperID, 3, 0), new FluidStack(tinID, 1, 0)); The example mixes 3 copper with 1 tin to make 2 bronze
|
||||
*
|
||||
* @param result The output of the combination of mixers. The quantity is used for amount of a successful mix
|
||||
* @param mixers the liquids to be mixed. Quantities are used as ratios
|
||||
@@ -196,29 +197,27 @@ public class Smeltery {
|
||||
*
|
||||
* @author samtrion
|
||||
*
|
||||
* @param type Type of Fluid
|
||||
* @param input The item to liquify
|
||||
* @param temperatureDifference Difference between FluidType BaseTemperature
|
||||
* @param fluidAmount Amount of Fluid
|
||||
* @param type Type of Fluid
|
||||
* @param input The item to liquify
|
||||
* @param temperatureDifference Difference between FluidType BaseTemperature
|
||||
* @param fluidAmount Amount of Fluid
|
||||
*/
|
||||
public static void addMelting(FluidType type, ItemStack input, int temperatureDifference, int fluidAmount) {
|
||||
int temp = type.baseTemperature + temperatureDifference;
|
||||
if (temp <= 20) temp = type.baseTemperature;
|
||||
|
||||
if (input.getItem() instanceof ItemBlock)
|
||||
addMelting(
|
||||
input,
|
||||
((ItemBlock) input.getItem()).field_150939_a,
|
||||
input.getItemDamage(),
|
||||
type.baseTemperature + temperatureDifference,
|
||||
new FluidStack(type.fluid, fluidAmount));
|
||||
else
|
||||
addMelting(
|
||||
input,
|
||||
type.renderBlock,
|
||||
type.renderMeta,
|
||||
type.baseTemperature + temperatureDifference,
|
||||
new FluidStack(type.fluid, fluidAmount));
|
||||
if (input.getItem() instanceof ItemBlock) addMelting(
|
||||
input,
|
||||
((ItemBlock) input.getItem()).field_150939_a,
|
||||
input.getItemDamage(),
|
||||
type.baseTemperature + temperatureDifference,
|
||||
new FluidStack(type.fluid, fluidAmount));
|
||||
else addMelting(
|
||||
input,
|
||||
type.renderBlock,
|
||||
type.renderMeta,
|
||||
type.baseTemperature + temperatureDifference,
|
||||
new FluidStack(type.fluid, fluidAmount));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,13 +225,13 @@ public class Smeltery {
|
||||
*
|
||||
* @author samtrion
|
||||
*
|
||||
* @param oreName oreDictionary name e.g. oreIron
|
||||
* @param type Type of Fluid
|
||||
* @param oreName oreDictionary name e.g. oreIron
|
||||
* @param type Type of Fluid
|
||||
* @param temperatureDifference Difference between FluidType BaseTemperature
|
||||
* @param fluidAmount Amount of Fluid
|
||||
* @param fluidAmount Amount of Fluid
|
||||
*/
|
||||
public static void addDictionaryMelting(
|
||||
String oreName, FluidType type, int temperatureDifference, int fluidAmount) {
|
||||
public static void addDictionaryMelting(String oreName, FluidType type, int temperatureDifference,
|
||||
int fluidAmount) {
|
||||
for (ItemStack is : OreDictionary.getOres(oreName)) addMelting(type, is, temperatureDifference, fluidAmount);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,25 @@
|
||||
package tconstruct.library.crafting;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class StencilBuilder {
|
||||
|
||||
public static StencilBuilder instance = new StencilBuilder();
|
||||
|
||||
public List<ItemStack> blanks =
|
||||
new LinkedList<>(); // i wish ItemStack would support equals so i could use a Set here...
|
||||
public List<ItemStack> blanks = new LinkedList<>(); // i wish ItemStack would support equals so i could use a Set
|
||||
// here...
|
||||
public Map<Integer, ItemStack> stencils = new TreeMap<>();
|
||||
|
||||
/**
|
||||
* Returns whether the given ItemStack is a blank pattern and therefore usable for stencil crafting.
|
||||
*/
|
||||
public static boolean isBlank(ItemStack stack) {
|
||||
for (ItemStack blank : instance.blanks)
|
||||
if (OreDictionary.itemMatches(stack, blank, false)) // this has nothing to do with the oredictionary.
|
||||
for (ItemStack blank : instance.blanks) if (OreDictionary.itemMatches(stack, blank, false)) // this has nothing
|
||||
// to do with the
|
||||
// oredictionary.
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -31,9 +34,10 @@ public class StencilBuilder {
|
||||
}
|
||||
|
||||
public static void registerStencil(int id, ItemStack pattern) {
|
||||
if (instance.stencils.containsKey(id))
|
||||
throw new IllegalArgumentException("[TCon API] Stencil ID " + id + " is already occupied by "
|
||||
+ instance.stencils.get(id).getDisplayName());
|
||||
if (instance.stencils.containsKey(id)) throw new IllegalArgumentException(
|
||||
"[TCon API] Stencil ID " + id
|
||||
+ " is already occupied by "
|
||||
+ instance.stencils.get(id).getDisplayName());
|
||||
|
||||
instance.stencils.put(id, pattern);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
package tconstruct.library.crafting;
|
||||
|
||||
/** Once upon a time, too many tools to count. Let's put them together automatically */
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.event.*;
|
||||
import tconstruct.library.modifier.ItemModifier;
|
||||
import tconstruct.library.tools.*;
|
||||
import tconstruct.library.util.IToolPart;
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
|
||||
public class ToolBuilder {
|
||||
|
||||
public static ToolBuilder instance = new ToolBuilder();
|
||||
|
||||
public HashMap<String, ToolRecipe> recipeList = new HashMap<>();
|
||||
@@ -73,10 +76,10 @@ public class ToolBuilder {
|
||||
|
||||
public ToolCore getMatchingRecipe(Item head, Item handle, Item accessory, Item extra) {
|
||||
for (ToolRecipe recipe : combos) {
|
||||
if (recipe.validHead(head)
|
||||
&& recipe.validHandle(handle)
|
||||
if (recipe.validHead(head) && recipe.validHandle(handle)
|
||||
&& recipe.validAccessory(accessory)
|
||||
&& recipe.validExtra(extra)) return recipe.getType();
|
||||
&& recipe.validExtra(extra))
|
||||
return recipe.getType();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -95,14 +98,16 @@ public class ToolBuilder {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public ItemStack buildTool(
|
||||
ItemStack headStack, ItemStack handleStack, ItemStack accessoryStack, ItemStack extraStack, String name) {
|
||||
/*if (headStack != null && headStack.getItem() instanceof ToolCore)
|
||||
return modifyTool(headStack, new ItemStack[] { handleStack, accessoryStack, extraStack }, name);*/
|
||||
public ItemStack buildTool(ItemStack headStack, ItemStack handleStack, ItemStack accessoryStack,
|
||||
ItemStack extraStack, String name) {
|
||||
/*
|
||||
* if (headStack != null && headStack.getItem() instanceof ToolCore) return modifyTool(headStack, new
|
||||
* ItemStack[] { handleStack, accessoryStack, extraStack }, name);
|
||||
*/
|
||||
|
||||
if (headStack == null
|
||||
|| handleStack == null) // Nothing to build without these. All tools need at least two parts!
|
||||
return null;
|
||||
if (headStack == null || handleStack == null) // Nothing to build without these. All tools need at least two
|
||||
// parts!
|
||||
return null;
|
||||
if (name == null) name = "";
|
||||
|
||||
// fire the ToolBuild event to get the correct items
|
||||
@@ -140,7 +145,10 @@ public class ToolBuilder {
|
||||
if (extra == -1) return null;
|
||||
|
||||
item = getMatchingRecipe(
|
||||
headStack.getItem(), handleStack.getItem(), accessoryStack.getItem(), extraStack.getItem());
|
||||
headStack.getItem(),
|
||||
handleStack.getItem(),
|
||||
accessoryStack.getItem(),
|
||||
extraStack.getItem());
|
||||
} else {
|
||||
item = getMatchingRecipe(headStack.getItem(), handleStack.getItem(), accessoryStack.getItem(), null);
|
||||
}
|
||||
@@ -263,7 +271,9 @@ public class ToolBuilder {
|
||||
}
|
||||
|
||||
ToolCraftEvent.NormalTool event = new ToolCraftEvent.NormalTool(
|
||||
item, compound, new ToolMaterial[] {headMat, handleMat, accessoryMat, extraMat});
|
||||
item,
|
||||
compound,
|
||||
new ToolMaterial[] { headMat, handleMat, accessoryMat, extraMat });
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
if (event.getResult() == Result.DEFAULT) {
|
||||
@@ -277,46 +287,19 @@ public class ToolBuilder {
|
||||
return tool;
|
||||
}
|
||||
|
||||
/*@Deprecated
|
||||
public ItemStack modifyTool (ItemStack input, ItemStack topSlot, ItemStack bottomSlot, ItemStack extraStack, String name)
|
||||
{
|
||||
if (extraStack != null)
|
||||
return null;
|
||||
/*
|
||||
* @Deprecated public ItemStack modifyTool (ItemStack input, ItemStack topSlot, ItemStack bottomSlot, ItemStack
|
||||
* extraStack, String name) { if (extraStack != null) return null; ItemStack tool = input.copy(); NBTTagCompound
|
||||
* tags = tool.getTagCompound().getCompoundTag("InfiTool"); tags.removeTag("Built"); if (topSlot == null &&
|
||||
* bottomSlot == null) return tool; boolean built = false; for (ToolMod mod : toolMods) { ItemStack[] slots = new
|
||||
* ItemStack[] { topSlot, bottomSlot }; if (mod.matches(slots, tool)) { built = true; mod.addMatchingEffect(tool);
|
||||
* mod.modify(slots, tool); } } tags = tool.getTagCompound(); if (name != null && !name.equals("") &&
|
||||
* !tags.hasKey("display")) { tags.setCompoundTag("display", new NBTTagCompound());
|
||||
* tags.getCompoundTag("display").setString("Name", "\u00A7f" + name); } if (built) return tool; else return null; }
|
||||
*/
|
||||
|
||||
ItemStack tool = input.copy();
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
tags.removeTag("Built");
|
||||
|
||||
if (topSlot == null && bottomSlot == null)
|
||||
return tool;
|
||||
|
||||
boolean built = false;
|
||||
for (ToolMod mod : toolMods)
|
||||
{
|
||||
ItemStack[] slots = new ItemStack[] { topSlot, bottomSlot };
|
||||
if (mod.matches(slots, tool))
|
||||
{
|
||||
built = true;
|
||||
mod.addMatchingEffect(tool);
|
||||
mod.modify(slots, tool);
|
||||
}
|
||||
}
|
||||
|
||||
tags = tool.getTagCompound();
|
||||
if (name != null && !name.equals("") && !tags.hasKey("display"))
|
||||
{
|
||||
tags.setCompoundTag("display", new NBTTagCompound());
|
||||
tags.getCompoundTag("display").setString("Name", "\u00A7f" + name);
|
||||
}
|
||||
|
||||
if (built)
|
||||
return tool;
|
||||
else
|
||||
return null;
|
||||
}*/
|
||||
|
||||
int buildReinforced(
|
||||
ToolMaterial headMat, ToolMaterial handleMat, ToolMaterial accessoryMat, ToolMaterial extraMat) {
|
||||
int buildReinforced(ToolMaterial headMat, ToolMaterial handleMat, ToolMaterial accessoryMat,
|
||||
ToolMaterial extraMat) {
|
||||
int reinforced = 0;
|
||||
|
||||
int dHead = headMat.reinforced();
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package tconstruct.library.crafting;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
@@ -11,6 +13,7 @@ import tconstruct.library.tools.ToolCore;
|
||||
*/
|
||||
|
||||
public class ToolRecipe {
|
||||
|
||||
protected LinkedList<Item> headList = new LinkedList<>();
|
||||
protected LinkedList<Item> handleList = new LinkedList<>();
|
||||
protected LinkedList<Item> accessoryList = new LinkedList<>();
|
||||
@@ -19,8 +22,7 @@ public class ToolRecipe {
|
||||
protected Item toolRod = TConstructRegistry.getItem("toolRod");
|
||||
|
||||
/*
|
||||
* public ToolRecipe(Item head, ToolCore tool) { this(head,
|
||||
* TContent.toolRod, null, null, tool); }
|
||||
* public ToolRecipe(Item head, ToolCore tool) { this(head, TContent.toolRod, null, null, tool); }
|
||||
*/
|
||||
|
||||
public ToolRecipe(Item head, Item handle, ToolCore tool) {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package tconstruct.library.entity;
|
||||
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
@@ -18,6 +16,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.play.server.S2BPacketChangeGameState;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import tconstruct.library.ActiveToolMod;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
@@ -25,9 +24,13 @@ import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.library.weaponry.AmmoItem;
|
||||
import tconstruct.util.Reference;
|
||||
import tconstruct.weaponry.entity.ArrowEntity;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
// have to base this on EntityArrow, otherwise minecraft does derp things because everything is handled based on class.
|
||||
public abstract class ProjectileBase extends EntityArrow implements IEntityAdditionalSpawnData {
|
||||
|
||||
public static final String woodSound = Reference.resource("woodHit");
|
||||
public static final String stoneSound = Reference.resource("stoneHit");
|
||||
|
||||
@@ -72,23 +75,14 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
returnStack = stack;
|
||||
|
||||
/*
|
||||
// fix upward default angle
|
||||
motionY = -MathHelper.sin((rotationPitch / 180F) * 3.141593F - 0.2f);
|
||||
setArrowHeading(motionX, motionY, motionZ, speed, 0.0f);
|
||||
|
||||
// set better position and move it a tad so we don't hit ourselves.
|
||||
this.setPosition(player.posX, player.posY + player.getEyeHeight(), player.posZ);
|
||||
*/
|
||||
* // fix upward default angle motionY = -MathHelper.sin((rotationPitch / 180F) * 3.141593F - 0.2f);
|
||||
* setArrowHeading(motionX, motionY, motionZ, speed, 0.0f); // set better position and move it a tad so we don't
|
||||
* hit ourselves. this.setPosition(player.posX, player.posY + player.getEyeHeight(), player.posZ);
|
||||
*/
|
||||
/*
|
||||
double l = Math.sqrt(motionX*motionX + motionY*motionY + motionZ*motionZ);
|
||||
double vx = motionX/l;
|
||||
double vy = motionY/l;
|
||||
double vz = motionZ/l;
|
||||
|
||||
posX += vx*1.5f;
|
||||
posY += vy*1.5f;
|
||||
posZ += vz*1.5f;
|
||||
*/
|
||||
* double l = Math.sqrt(motionX*motionX + motionY*motionY + motionZ*motionZ); double vx = motionX/l; double vy =
|
||||
* motionY/l; double vz = motionZ/l; posX += vx*1.5f; posY += vy*1.5f; posZ += vz*1.5f;
|
||||
*/
|
||||
|
||||
// init();
|
||||
}
|
||||
@@ -119,8 +113,7 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
}
|
||||
|
||||
protected void doLivingHit(EntityLivingBase entityHit) {
|
||||
float knockback =
|
||||
returnStack.getTagCompound().getCompoundTag("InfiTool").getFloat("Knockback");
|
||||
float knockback = returnStack.getTagCompound().getCompoundTag("InfiTool").getFloat("Knockback");
|
||||
if (shootingEntity instanceof EntityLivingBase)
|
||||
knockback += EnchantmentHelper.getKnockbackModifier((EntityLivingBase) shootingEntity, entityHit);
|
||||
|
||||
@@ -144,12 +137,11 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
EnchantmentHelper.func_151385_b((EntityLivingBase) this.shootingEntity, entityHit);
|
||||
}
|
||||
|
||||
if (this.shootingEntity != null
|
||||
&& entityHit != this.shootingEntity
|
||||
if (this.shootingEntity != null && entityHit != this.shootingEntity
|
||||
&& entityHit instanceof EntityPlayer
|
||||
&& this.shootingEntity instanceof EntityPlayerMP) {
|
||||
((EntityPlayerMP) this.shootingEntity)
|
||||
.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F));
|
||||
((EntityPlayerMP) this.shootingEntity).playerNetServerHandler
|
||||
.sendPacket(new S2BPacketChangeGameState(6, 0.0F));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,9 +154,8 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
this.motionX = movingobjectposition.hitVec.xCoord - this.posX;
|
||||
this.motionY = movingobjectposition.hitVec.yCoord - this.posY;
|
||||
this.motionZ = movingobjectposition.hitVec.zCoord - this.posZ;
|
||||
double speed = getStuckDepth()
|
||||
* MathHelper.sqrt_double(
|
||||
this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
|
||||
double speed = getStuckDepth() * MathHelper
|
||||
.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
|
||||
this.posX -= this.motionX / speed * 0.05000000074505806D;
|
||||
this.posY -= this.motionY / speed * 0.05000000074505806D;
|
||||
this.posZ -= this.motionZ / speed * 0.05000000074505806D;
|
||||
@@ -178,14 +169,18 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
|
||||
if (this.field_145790_g.getMaterial() != Material.air) {
|
||||
this.field_145790_g.onEntityCollidedWithBlock(
|
||||
this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f, this);
|
||||
this.worldObj,
|
||||
this.field_145791_d,
|
||||
this.field_145792_e,
|
||||
this.field_145789_f,
|
||||
this);
|
||||
}
|
||||
}
|
||||
|
||||
public void onHitEntity(MovingObjectPosition movingobjectposition) {
|
||||
NBTTagCompound tags = returnStack.getTagCompound().getCompoundTag("InfiTool");
|
||||
float speed = MathHelper.sqrt_double(
|
||||
this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
|
||||
float speed = MathHelper
|
||||
.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
|
||||
|
||||
// absolute distance travelled minus the current tick
|
||||
float distance = speed * (this.ticksInAir - 1);
|
||||
@@ -213,8 +208,8 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
|
||||
float baseAttack = tags.getInteger("BaseAttack");
|
||||
float totalAttack = tags.getInteger("Attack");
|
||||
float damage = speed
|
||||
* baseAttack; // todo: potentially change this back to MathHelper.ceiling_float_int to get 1/2 heart
|
||||
float damage = speed * baseAttack; // todo: potentially change this back to MathHelper.ceiling_float_int to get
|
||||
// 1/2 heart
|
||||
// steps back
|
||||
|
||||
// add quartz damage
|
||||
@@ -232,7 +227,7 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
// basically we pass the base damage to all modifiers and take the highest one
|
||||
int baseDamage = 0;
|
||||
if (shotByPlayer) // prevent crashes with other things reflecting/shooting them
|
||||
for (ActiveToolMod toolmod : TConstructRegistry.activeModifiers) {
|
||||
for (ActiveToolMod toolmod : TConstructRegistry.activeModifiers) {
|
||||
int dmg = toolmod.baseAttackDamage(
|
||||
baseDamage,
|
||||
(int) damage,
|
||||
@@ -257,7 +252,8 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
// enchantments might add too
|
||||
if (shootingEntity != null && movingobjectposition.entityHit instanceof EntityLivingBase)
|
||||
bonusDamage += EnchantmentHelper.getEnchantmentModifierLiving(
|
||||
(EntityLivingBase) this.shootingEntity, (EntityLivingBase) movingobjectposition.entityHit);
|
||||
(EntityLivingBase) this.shootingEntity,
|
||||
(EntityLivingBase) movingobjectposition.entityHit);
|
||||
damage += bonusDamage;
|
||||
|
||||
// ensure we still have damage
|
||||
@@ -265,18 +261,17 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
|
||||
// the regular tool modifier damage stuff
|
||||
int modDamage = 0;
|
||||
if (shotByPlayer)
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers) {
|
||||
modDamage += mod.attackDamage(
|
||||
modDamage,
|
||||
(int) damage,
|
||||
ammo,
|
||||
returnStack.getTagCompound(),
|
||||
tags,
|
||||
returnStack,
|
||||
(EntityPlayer) this.shootingEntity,
|
||||
movingobjectposition.entityHit);
|
||||
}
|
||||
if (shotByPlayer) for (ActiveToolMod mod : TConstructRegistry.activeModifiers) {
|
||||
modDamage += mod.attackDamage(
|
||||
modDamage,
|
||||
(int) damage,
|
||||
ammo,
|
||||
returnStack.getTagCompound(),
|
||||
tags,
|
||||
returnStack,
|
||||
(EntityPlayer) this.shootingEntity,
|
||||
movingobjectposition.entityHit);
|
||||
}
|
||||
damage += modDamage;
|
||||
|
||||
// calculate critical damaaage
|
||||
@@ -356,8 +351,8 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
// If we don't have our rotation set correctly, infer it from our motion direction
|
||||
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
|
||||
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||
this.prevRotationYaw =
|
||||
this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
|
||||
this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D
|
||||
/ Math.PI);
|
||||
this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(this.motionY, f) * 180.0D / Math.PI);
|
||||
}
|
||||
|
||||
@@ -365,9 +360,15 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
Block block = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
|
||||
if (block.getMaterial() != Material.air) {
|
||||
block.setBlockBoundsBasedOnState(
|
||||
this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
|
||||
this.worldObj,
|
||||
this.field_145791_d,
|
||||
this.field_145792_e,
|
||||
this.field_145789_f);
|
||||
AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(
|
||||
this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
|
||||
this.worldObj,
|
||||
this.field_145791_d,
|
||||
this.field_145792_e,
|
||||
this.field_145789_f);
|
||||
|
||||
// we are stuck in a block. yay.
|
||||
if (axisalignedbb != null
|
||||
@@ -408,31 +409,27 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
|
||||
// do a raytrace from old to new position
|
||||
Vec3 curPos = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
|
||||
Vec3 newPos =
|
||||
Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
Vec3 newPos = Vec3
|
||||
.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(curPos, newPos, false, true, false);
|
||||
|
||||
// raytrace messes with the positions. get new ones!
|
||||
curPos = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
|
||||
|
||||
// if we hit something, the collision point is our new position
|
||||
if (movingobjectposition != null)
|
||||
newPos = Vec3.createVectorHelper(
|
||||
movingobjectposition.hitVec.xCoord,
|
||||
movingobjectposition.hitVec.yCoord,
|
||||
movingobjectposition.hitVec.zCoord);
|
||||
else
|
||||
newPos = Vec3.createVectorHelper(
|
||||
this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
if (movingobjectposition != null) newPos = Vec3.createVectorHelper(
|
||||
movingobjectposition.hitVec.xCoord,
|
||||
movingobjectposition.hitVec.yCoord,
|
||||
movingobjectposition.hitVec.zCoord);
|
||||
else newPos = Vec3
|
||||
.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
|
||||
if (!defused) {
|
||||
// Check all the entities we on our way
|
||||
Entity entity = null;
|
||||
List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(
|
||||
this,
|
||||
this.boundingBox
|
||||
.addCoord(this.motionX, this.motionY, this.motionZ)
|
||||
.expand(1.0D, 1.0D, 1.0D));
|
||||
this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
|
||||
double distance = 0.0D;
|
||||
float f1;
|
||||
|
||||
@@ -465,9 +462,8 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit;
|
||||
|
||||
// can we attack said player?
|
||||
if (entityplayer.capabilities.disableDamage
|
||||
|| this.shootingEntity instanceof EntityPlayer
|
||||
&& !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer))
|
||||
if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer
|
||||
&& !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer))
|
||||
movingobjectposition = null;
|
||||
|
||||
// this check should probably done inside of the loop for accuracy..
|
||||
@@ -590,7 +586,9 @@ public abstract class ProjectileBase extends EntityArrow implements IEntityAddit
|
||||
|
||||
if (flag) {
|
||||
this.playSound(
|
||||
"random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
"random.pop",
|
||||
0.2F,
|
||||
((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
player.onItemPickup(this, 1);
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package tconstruct.library.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import tconstruct.library.modifier.IModifyable;
|
||||
import tconstruct.library.modifier.ItemModifier;
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
@Cancelable
|
||||
public class ModifyEvent extends Event {
|
||||
|
||||
public final ItemModifier modifier;
|
||||
public final IModifyable item;
|
||||
public final ItemStack itemStack;
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
package tconstruct.library.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/* This event fires after all of the other construction. The resulting nbttag is added to the tool
|
||||
* Note: The tag is the base tag. toolTag.getCompoundTag("InfiTool") will have all of the tool's data.
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
/*
|
||||
* This event fires after all of the other construction. The resulting nbttag is added to the tool Note: The tag is the
|
||||
* base tag. toolTag.getCompoundTag("InfiTool") will have all of the tool's data.
|
||||
*/
|
||||
|
||||
public class PartBuilderEvent extends Event {
|
||||
|
||||
public final ItemStack material;
|
||||
public final ItemStack pattern;
|
||||
public final ItemStack otherPattern;
|
||||
@@ -21,6 +24,7 @@ public class PartBuilderEvent extends Event {
|
||||
|
||||
@HasResult
|
||||
public static class NormalPart extends PartBuilderEvent {
|
||||
|
||||
public NormalPart(ItemStack material, ItemStack pattern, ItemStack otherPattern) {
|
||||
super(material, pattern, otherPattern);
|
||||
}
|
||||
@@ -28,8 +32,8 @@ public class PartBuilderEvent extends Event {
|
||||
/**
|
||||
* Fires before other processing is done
|
||||
*
|
||||
* Result is significant: DEFAULT: Allows part to be crafted normally
|
||||
* ALLOW: Uses resultStack instead DENY: Stops part crafting altogether
|
||||
* Result is significant: DEFAULT: Allows part to be crafted normally ALLOW: Uses resultStack instead DENY:
|
||||
* Stops part crafting altogether
|
||||
*/
|
||||
public void overrideResult(ItemStack[] result) {
|
||||
resultStacks = result;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package tconstruct.library.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import tconstruct.library.crafting.CastingRecipe;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
/**
|
||||
* Fires when somebody tries to pour a liquid into a metal cast.
|
||||
@@ -10,6 +11,7 @@ import tconstruct.library.crafting.CastingRecipe;
|
||||
* Set result to DENY to prevent casting.
|
||||
*/
|
||||
public abstract class SmelteryCastEvent extends Event {
|
||||
|
||||
public final CastingRecipe recipe;
|
||||
public final FluidStack fluid;
|
||||
|
||||
@@ -19,12 +21,14 @@ public abstract class SmelteryCastEvent extends Event {
|
||||
}
|
||||
|
||||
public static class CastingTable extends SmelteryCastEvent {
|
||||
|
||||
public CastingTable(CastingRecipe recipe, FluidStack fluid) {
|
||||
super(recipe, fluid);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CastingBasin extends SmelteryCastEvent {
|
||||
|
||||
public CastingBasin(CastingRecipe recipe, FluidStack fluid) {
|
||||
super(recipe, fluid);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package tconstruct.library.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import tconstruct.library.crafting.CastingRecipe;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
/**
|
||||
* Fired when an item is cast in the casting table.
|
||||
* If consumeCast is set to true, the cast will be destroyed.
|
||||
* Fired when an item is cast in the casting table. If consumeCast is set to true, the cast will be destroyed.
|
||||
*/
|
||||
public abstract class SmelteryCastedEvent extends Event {
|
||||
|
||||
public final CastingRecipe recipe;
|
||||
public ItemStack output;
|
||||
public boolean consumeCast;
|
||||
@@ -20,12 +21,14 @@ public abstract class SmelteryCastedEvent extends Event {
|
||||
}
|
||||
|
||||
public static class CastingTable extends SmelteryCastedEvent {
|
||||
|
||||
public CastingTable(CastingRecipe recipe, ItemStack output) {
|
||||
super(recipe, output);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CastingBasin extends SmelteryCastedEvent {
|
||||
|
||||
public CastingBasin(CastingRecipe recipe, ItemStack output) {
|
||||
super(recipe, output);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package tconstruct.library.event;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SmelteryEvent extends Event {
|
||||
|
||||
@@ -20,13 +22,14 @@ public class SmelteryEvent extends Event {
|
||||
|
||||
@Cancelable
|
||||
public static class ItemInsertedIntoCasting extends SmelteryEvent {
|
||||
|
||||
/** Item that will be inserted into the casting block */
|
||||
public ItemStack item;
|
||||
|
||||
public EntityPlayer player;
|
||||
|
||||
public ItemInsertedIntoCasting(
|
||||
InventoryLogic component, int x, int y, int z, ItemStack item, EntityPlayer player) {
|
||||
public ItemInsertedIntoCasting(InventoryLogic component, int x, int y, int z, ItemStack item,
|
||||
EntityPlayer player) {
|
||||
super(component, x, y, z);
|
||||
this.item = item;
|
||||
this.player = player;
|
||||
@@ -34,13 +37,14 @@ public class SmelteryEvent extends Event {
|
||||
}
|
||||
|
||||
public static class ItemRemovedFromCasting extends SmelteryEvent {
|
||||
|
||||
/** Item that will be returned to the player */
|
||||
public ItemStack item;
|
||||
|
||||
public EntityPlayer player;
|
||||
|
||||
public ItemRemovedFromCasting(
|
||||
InventoryLogic component, int x, int y, int z, ItemStack item, EntityPlayer player) {
|
||||
public ItemRemovedFromCasting(InventoryLogic component, int x, int y, int z, ItemStack item,
|
||||
EntityPlayer player) {
|
||||
super(component, x, y, z);
|
||||
this.item = item;
|
||||
this.player = player;
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
package tconstruct.library.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
/**
|
||||
* Called when the ToolBuilder tries to piece together the Parts of a tool.
|
||||
*
|
||||
*/
|
||||
public class ToolBuildEvent extends Event {
|
||||
|
||||
public ItemStack headStack;
|
||||
public ItemStack handleStack;
|
||||
public ItemStack accessoryStack;
|
||||
public ItemStack extraStack;
|
||||
public String name; // to allow shenanigans
|
||||
|
||||
public ToolBuildEvent(
|
||||
ItemStack headStack, ItemStack handleStack, ItemStack accessoryStack, ItemStack extraStack, String name) {
|
||||
public ToolBuildEvent(ItemStack headStack, ItemStack handleStack, ItemStack accessoryStack, ItemStack extraStack,
|
||||
String name) {
|
||||
this.headStack = headStack;
|
||||
this.handleStack = handleStack;
|
||||
this.accessoryStack = accessoryStack;
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
package tconstruct.library.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.tools.*;
|
||||
|
||||
/* This event fires after all of the other construction. The resulting nbttag is added to the tool
|
||||
* Note: The tag is the base tag. toolTag.getCompoundTag("InfiTool") will have all of the tool's data.
|
||||
import tconstruct.library.tools.*;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
/*
|
||||
* This event fires after all of the other construction. The resulting nbttag is added to the tool Note: The tag is the
|
||||
* base tag. toolTag.getCompoundTag("InfiTool") will have all of the tool's data.
|
||||
*/
|
||||
|
||||
public class ToolCraftEvent extends Event {
|
||||
|
||||
public final ToolCore tool;
|
||||
public final NBTTagCompound toolTag;
|
||||
public final ToolMaterial[] materials;
|
||||
@@ -23,6 +26,7 @@ public class ToolCraftEvent extends Event {
|
||||
|
||||
@HasResult
|
||||
public static class NormalTool extends ToolCraftEvent {
|
||||
|
||||
public NormalTool(ToolCore tool, NBTTagCompound toolTag, ToolMaterial[] materials) {
|
||||
super(tool, toolTag, materials);
|
||||
}
|
||||
@@ -30,8 +34,8 @@ public class ToolCraftEvent extends Event {
|
||||
/**
|
||||
* Fires just before the tool is put together
|
||||
*
|
||||
* Result is significant: DEFAULT: Allows tool to be crafted normally
|
||||
* ALLOW: Uses resultStack instead DENY: Stops tool crafting altogether
|
||||
* Result is significant: DEFAULT: Allows tool to be crafted normally ALLOW: Uses resultStack instead DENY:
|
||||
* Stops tool crafting altogether
|
||||
*/
|
||||
public void overrideResult(ItemStack result) {
|
||||
resultStack = result;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package tconstruct.library.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
public class ToolCraftedEvent extends Event {
|
||||
|
||||
public IInventory inventory;
|
||||
|
||||
@@ -3,9 +3,11 @@ package tconstruct.library.modifier;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import tconstruct.library.armor.*;
|
||||
|
||||
public class ActiveArmorMod {
|
||||
|
||||
/* Ticks for every armor piece on client and server */
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack, ArmorCore armor, ArmorPart type) {}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package tconstruct.library.modifier;
|
||||
|
||||
public interface IModifyable {
|
||||
|
||||
/**
|
||||
* @return The base tag to modify. Ex: InfiTool
|
||||
*/
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
package tconstruct.library.modifier;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public abstract class ItemModifier {
|
||||
|
||||
public final String key;
|
||||
public final List<ItemStack> stacks;
|
||||
public final int effectIndex;
|
||||
public static Random random = new Random();
|
||||
|
||||
/** Default constructor
|
||||
/**
|
||||
* Default constructor
|
||||
*
|
||||
* @param recipe Items to compare against when checking the modifier
|
||||
* @param effect Render index for sprite layering
|
||||
* @param recipe Items to compare against when checking the modifier
|
||||
* @param effect Render index for sprite layering
|
||||
* @param dataKey NBT string to put on the item
|
||||
*/
|
||||
public ItemModifier(ItemStack[] recipe, int effect, String dataKey) {
|
||||
@@ -22,11 +25,11 @@ public abstract class ItemModifier {
|
||||
key = dataKey;
|
||||
}
|
||||
|
||||
/** Checks to see if the inputs match the stored items
|
||||
* Note: Works like ShapelessRecipes
|
||||
/**
|
||||
* Checks to see if the inputs match the stored items Note: Works like ShapelessRecipes
|
||||
*
|
||||
* @param recipe The ItemStacks to compare against
|
||||
* @param input Item to modify, used for restrictions
|
||||
* @param input Item to modify, used for restrictions
|
||||
* @return Whether the recipe matches the input
|
||||
*/
|
||||
public boolean matches(ItemStack[] recipe, ItemStack input) {
|
||||
@@ -66,7 +69,7 @@ public abstract class ItemModifier {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param input Tool to compare against
|
||||
* @param input Tool to compare against
|
||||
* @param recipe Items to modify with
|
||||
* @return Whether the tool can be modified
|
||||
*/
|
||||
@@ -75,10 +78,11 @@ public abstract class ItemModifier {
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
}
|
||||
|
||||
/** Modifies the tool. Adds nbttags, changes existing ones, ticks down modification counter, etc
|
||||
/**
|
||||
* Modifies the tool. Adds nbttags, changes existing ones, ticks down modification counter, etc
|
||||
*
|
||||
* @param recipe ItemStacks to pull info from
|
||||
* @param input The tool to modify
|
||||
* @param input The tool to modify
|
||||
*/
|
||||
public abstract void modify(ItemStack[] recipe, ItemStack input);
|
||||
|
||||
@@ -181,8 +185,8 @@ public abstract class ItemModifier {
|
||||
return ItemStack.areItemStackTagsEqual(stack1, stack2);
|
||||
}
|
||||
|
||||
public static NBTTagCompound getAttributeTag(
|
||||
String attributeType, String modifierName, double amount, boolean flat, UUID uuid) {
|
||||
public static NBTTagCompound getAttributeTag(String attributeType, String modifierName, double amount, boolean flat,
|
||||
UUID uuid) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setString("AttributeName", attributeType);
|
||||
tag.setString("Name", modifierName);
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
|
||||
public abstract class AOEHarvestTool extends HarvestTool {
|
||||
|
||||
public int breakRadius;
|
||||
public int breakDepth;
|
||||
|
||||
@@ -58,15 +59,14 @@ public abstract class AOEHarvestTool extends HarvestTool {
|
||||
break;
|
||||
}
|
||||
|
||||
for (int xPos = x - xRange; xPos <= x + xRange; xPos++)
|
||||
for (int yPos = y - yRange; yPos <= y + yRange; yPos++)
|
||||
for (int zPos = z - zRange; zPos <= z + zRange; zPos++) {
|
||||
// don't break the originally already broken block, duh
|
||||
if (xPos == x && yPos == y && zPos == z) continue;
|
||||
for (int xPos = x - xRange; xPos <= x + xRange; xPos++) for (int yPos = y - yRange; yPos <= y + yRange; yPos++)
|
||||
for (int zPos = z - zRange; zPos <= z + zRange; zPos++) {
|
||||
// don't break the originally already broken block, duh
|
||||
if (xPos == x && yPos == y && zPos == z) continue;
|
||||
|
||||
if (!super.onBlockStartBreak(stack, xPos, yPos, zPos, player))
|
||||
breakExtraBlock(player.worldObj, xPos, yPos, zPos, sideHit, player, x, y, z);
|
||||
}
|
||||
if (!super.onBlockStartBreak(stack, xPos, yPos, zPos, player))
|
||||
breakExtraBlock(player.worldObj, xPos, yPos, zPos, sideHit, player, x, y, z);
|
||||
}
|
||||
|
||||
return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package tconstruct.library.tools;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -27,18 +25,23 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.event.entity.player.UseHoeEvent;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.ActiveToolMod;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.util.PiercingEntityDamage;
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
|
||||
public class AbilityHelper {
|
||||
|
||||
public static Random random = new Random();
|
||||
public static boolean necroticUHS;
|
||||
|
||||
/* Normal interactions */
|
||||
public static boolean onBlockChanged(
|
||||
ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase player, Random random) {
|
||||
public static boolean onBlockChanged(ItemStack stack, World world, Block block, int x, int y, int z,
|
||||
EntityLivingBase player, Random random) {
|
||||
if (!stack.hasTagCompound()) return false;
|
||||
|
||||
int reinforced = 0;
|
||||
@@ -58,8 +61,8 @@ public class AbilityHelper {
|
||||
return onLeftClickEntity(stack, player, entity, tool, 0);
|
||||
}
|
||||
|
||||
public static boolean onLeftClickEntity(
|
||||
ItemStack stack, EntityLivingBase player, Entity entity, ToolCore tool, int baseDamage) {
|
||||
public static boolean onLeftClickEntity(ItemStack stack, EntityLivingBase player, Entity entity, ToolCore tool,
|
||||
int baseDamage) {
|
||||
if (entity != null && player != null && entity.canAttackWithItem() && stack.hasTagCompound()) {
|
||||
if (!entity.hitByEntity(player)) // can't attack this entity
|
||||
{
|
||||
@@ -83,8 +86,7 @@ public class AbilityHelper {
|
||||
}
|
||||
|
||||
if (damage > 0 || enchantDamage > 0) {
|
||||
boolean criticalHit = player.fallDistance > 0.0F
|
||||
&& !player.onGround
|
||||
boolean criticalHit = player.fallDistance > 0.0F && !player.onGround
|
||||
&& !player.isOnLadder()
|
||||
&& !player.isInWater()
|
||||
&& !player.isPotionActive(Potion.blindness)
|
||||
@@ -116,14 +118,12 @@ public class AbilityHelper {
|
||||
int armorValue = Math.min(20, ((EntityLivingBase) entity).getTotalArmorValue());
|
||||
damage = (int) (damage / (1 - (0.04 * armorValue)));
|
||||
|
||||
if (player instanceof EntityPlayer)
|
||||
causedDamage =
|
||||
entity.attackEntityFrom(causePlayerPiercingDamage((EntityPlayer) player), damage);
|
||||
if (player instanceof EntityPlayer) causedDamage = entity
|
||||
.attackEntityFrom(causePlayerPiercingDamage((EntityPlayer) player), damage);
|
||||
else causedDamage = entity.attackEntityFrom(causePiercingDamage(player), damage);
|
||||
} else {
|
||||
if (player instanceof EntityPlayer)
|
||||
causedDamage = entity.attackEntityFrom(
|
||||
DamageSource.causePlayerDamage((EntityPlayer) player), damage);
|
||||
if (player instanceof EntityPlayer) causedDamage = entity
|
||||
.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) player), damage);
|
||||
else causedDamage = entity.attackEntityFrom(DamageSource.causeMobDamage(player), damage);
|
||||
}
|
||||
|
||||
@@ -132,10 +132,8 @@ public class AbilityHelper {
|
||||
|
||||
// damageTool(stack, 1, player, false);
|
||||
tool.onEntityDamaged(player.worldObj, player, entity);
|
||||
if (!necroticUHS
|
||||
|| (entity instanceof IMob
|
||||
&& entity instanceof EntityLivingBase
|
||||
&& ((EntityLivingBase) entity).getHealth() <= 0)) {
|
||||
if (!necroticUHS || (entity instanceof IMob && entity instanceof EntityLivingBase
|
||||
&& ((EntityLivingBase) entity).getHealth() <= 0)) {
|
||||
if (isAlive) {
|
||||
int drain = toolTags.getInteger("Necrotic") * 2;
|
||||
if (drain > 0) player.heal(random.nextInt(drain + 1));
|
||||
@@ -198,15 +196,22 @@ public class AbilityHelper {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int calcDamage(
|
||||
Entity user, Entity entity, ItemStack stack, ToolCore tool, NBTTagCompound toolTags, int baseDamage) {
|
||||
public static int calcDamage(Entity user, Entity entity, ItemStack stack, ToolCore tool, NBTTagCompound toolTags,
|
||||
int baseDamage) {
|
||||
EntityLivingBase living = user instanceof EntityLivingBase ? (EntityLivingBase) user : null;
|
||||
|
||||
int damage = toolTags.getInteger("Attack") + baseDamage;
|
||||
int earlyModDamage = 0;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers) {
|
||||
earlyModDamage = mod.baseAttackDamage(
|
||||
earlyModDamage, damage, tool, stack.getTagCompound(), toolTags, stack, living, entity);
|
||||
earlyModDamage,
|
||||
damage,
|
||||
tool,
|
||||
stack.getTagCompound(),
|
||||
toolTags,
|
||||
stack,
|
||||
living,
|
||||
entity);
|
||||
}
|
||||
damage += earlyModDamage;
|
||||
|
||||
@@ -232,16 +237,16 @@ public class AbilityHelper {
|
||||
|
||||
int modDamage = 0;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers) {
|
||||
modDamage =
|
||||
mod.attackDamage(modDamage, damage, tool, stack.getTagCompound(), toolTags, stack, living, entity);
|
||||
modDamage = mod
|
||||
.attackDamage(modDamage, damage, tool, stack.getTagCompound(), toolTags, stack, living, entity);
|
||||
}
|
||||
damage += modDamage;
|
||||
|
||||
return damage;
|
||||
}
|
||||
|
||||
public static float calcKnockback(
|
||||
Entity user, Entity entity, ItemStack stack, ToolCore tool, NBTTagCompound toolTags, int baseDamage) {
|
||||
public static float calcKnockback(Entity user, Entity entity, ItemStack stack, ToolCore tool,
|
||||
NBTTagCompound toolTags, int baseDamage) {
|
||||
if (user == null) return 0;
|
||||
float knockback = 0;
|
||||
|
||||
@@ -308,17 +313,15 @@ public class AbilityHelper {
|
||||
List<EntityWolf> var6 = player.worldObj.getEntitiesWithinAABB(
|
||||
EntityWolf.class,
|
||||
AxisAlignedBB.getBoundingBox(
|
||||
player.posX,
|
||||
player.posY,
|
||||
player.posZ,
|
||||
player.posX + 1.0D,
|
||||
player.posY + 1.0D,
|
||||
player.posZ + 1.0D)
|
||||
.expand(16.0D, 4.0D, 16.0D));
|
||||
player.posX,
|
||||
player.posY,
|
||||
player.posZ,
|
||||
player.posX + 1.0D,
|
||||
player.posY + 1.0D,
|
||||
player.posZ + 1.0D).expand(16.0D, 4.0D, 16.0D));
|
||||
|
||||
for (EntityWolf var5 : var6) {
|
||||
if (var5.isTamed()
|
||||
&& var5.getEntityToAttack() == null
|
||||
if (var5.isTamed() && var5.getEntityToAttack() == null
|
||||
&& player.getDisplayName().equals(var5.func_152113_b())
|
||||
&& (!par2 || !var5.isSitting())) {
|
||||
var5.setSitting(false);
|
||||
@@ -340,8 +343,8 @@ public class AbilityHelper {
|
||||
damageTool(stack, -dam, tags, entity, ignoreCharge);
|
||||
}
|
||||
|
||||
public static void damageTool(
|
||||
ItemStack stack, int dam, NBTTagCompound tags, EntityLivingBase entity, boolean ignoreCharge) {
|
||||
public static void damageTool(ItemStack stack, int dam, NBTTagCompound tags, EntityLivingBase entity,
|
||||
boolean ignoreCharge) {
|
||||
if (entity instanceof EntityPlayer && ((EntityPlayer) entity).capabilities.isCreativeMode || tags == null)
|
||||
return;
|
||||
|
||||
@@ -383,7 +386,7 @@ public class AbilityHelper {
|
||||
int toolDamage = (damage * 100 / maxDamage) + 1;
|
||||
int stackDamage = stack.getItemDamage();
|
||||
// if (toolDamage != stackDamage) {
|
||||
// // stack.setItemDamage((damage * 100 / maxDamage) + 1);
|
||||
// // stack.setItemDamage((damage * 100 / maxDamage) + 1);
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -480,8 +483,9 @@ public class AbilityHelper {
|
||||
tags.setInteger("Energy", max - missing);
|
||||
}
|
||||
|
||||
private static final boolean equalityOverrideLoaded =
|
||||
Loader.isModLoaded("CoFHCore"); // Mods should be loaded far enough before this is ever initialized
|
||||
private static final boolean equalityOverrideLoaded = Loader.isModLoaded("CoFHCore"); // Mods should be loaded far
|
||||
// enough before this is ever
|
||||
// initialized
|
||||
|
||||
public static void breakTool(ItemStack stack, NBTTagCompound tags, Entity entity) {
|
||||
tags.getCompoundTag("InfiTool").setBoolean("Broken", true);
|
||||
@@ -508,8 +512,8 @@ public class AbilityHelper {
|
||||
living.motionZ *= boost;
|
||||
}
|
||||
|
||||
public static boolean hoeGround(
|
||||
ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, Random random) {
|
||||
public static boolean hoeGround(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side,
|
||||
Random random) {
|
||||
if (!player.canPlayerEdit(x, y, z, side, stack)) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -525,8 +529,7 @@ public class AbilityHelper {
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
if (side != 0
|
||||
&& world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z)
|
||||
if (side != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z)
|
||||
&& (block == Blocks.grass || block == Blocks.dirt)) {
|
||||
Block block1 = Blocks.farmland;
|
||||
world.playSoundEffect(
|
||||
@@ -550,8 +553,12 @@ public class AbilityHelper {
|
||||
|
||||
public static void spawnItemAtEntity(Entity entity, ItemStack stack, int delay) {
|
||||
if (!entity.worldObj.isRemote) {
|
||||
EntityItem entityitem =
|
||||
new EntityItem(entity.worldObj, entity.posX + 0.5D, entity.posY + 0.5D, entity.posZ + 0.5D, stack);
|
||||
EntityItem entityitem = new EntityItem(
|
||||
entity.worldObj,
|
||||
entity.posX + 0.5D,
|
||||
entity.posY + 0.5D,
|
||||
entity.posZ + 0.5D,
|
||||
stack);
|
||||
entityitem.delayBeforeCanPickup = delay;
|
||||
entity.worldObj.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
@@ -560,13 +567,18 @@ public class AbilityHelper {
|
||||
public static void spawnItemAtPlayer(EntityPlayer player, ItemStack stack) {
|
||||
if (!player.worldObj.isRemote) {
|
||||
// try to put it into the players inventory
|
||||
if (player instanceof FakePlayer
|
||||
|| !player.inventory.addItemStackToInventory(
|
||||
stack)) // note that the addItemStackToInventory is not called for fake players
|
||||
if (player instanceof FakePlayer || !player.inventory.addItemStackToInventory(stack)) // note that the
|
||||
// addItemStackToInventory
|
||||
// is not called for
|
||||
// fake players
|
||||
{
|
||||
// drop the rest as an entity
|
||||
EntityItem entityitem = new EntityItem(
|
||||
player.worldObj, player.posX + 0.5D, player.posY + 0.5D, player.posZ + 0.5D, stack);
|
||||
player.worldObj,
|
||||
player.posX + 0.5D,
|
||||
player.posY + 0.5D,
|
||||
player.posZ + 0.5D,
|
||||
stack);
|
||||
player.worldObj.spawnEntityInWorld(entityitem);
|
||||
if (!(player instanceof FakePlayer)) entityitem.onCollideWithPlayer(player);
|
||||
}
|
||||
@@ -624,8 +636,8 @@ public class AbilityHelper {
|
||||
return addItemStackToWorld(world, f, f1, f2, itemstack, false);
|
||||
}
|
||||
|
||||
public static EntityItem addItemStackToWorld(
|
||||
World world, float f, float f1, float f2, ItemStack itemstack, boolean flag) {
|
||||
public static EntityItem addItemStackToWorld(World world, float f, float f1, float f2, ItemStack itemstack,
|
||||
boolean flag) {
|
||||
EntityItem entityitem;
|
||||
if (flag) {
|
||||
entityitem = new EntityItem(world, f, f1, f2, itemstack);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package tconstruct.library.tools;
|
||||
|
||||
public class ArrowMaterial {
|
||||
|
||||
public final float mass;
|
||||
public final float breakChance;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package tconstruct.library.tools;
|
||||
|
||||
public class BowMaterial {
|
||||
|
||||
public final int drawspeed;
|
||||
public final float flightSpeedMax;
|
||||
|
||||
|
||||
@@ -3,19 +3,13 @@ package tconstruct.library.tools;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class BowstringMaterial extends CustomMaterial {
|
||||
|
||||
public final float durabilityModifier;
|
||||
public final float drawspeedModifier;
|
||||
public final float flightSpeedModifier;
|
||||
|
||||
public BowstringMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
ItemStack input,
|
||||
ItemStack craftingItem,
|
||||
float durability,
|
||||
float drawspeed,
|
||||
float flightspeed,
|
||||
int color) {
|
||||
public BowstringMaterial(int materialID, int value, ItemStack input, ItemStack craftingItem, float durability,
|
||||
float drawspeed, float flightspeed, int color) {
|
||||
super(materialID, value, input, craftingItem, color);
|
||||
this.durabilityModifier = durability;
|
||||
this.drawspeedModifier = drawspeed;
|
||||
@@ -23,14 +17,8 @@ public class BowstringMaterial extends CustomMaterial {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public BowstringMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
ItemStack input,
|
||||
ItemStack craftingItem,
|
||||
float durability,
|
||||
float drawspeed,
|
||||
float flightspeed) {
|
||||
public BowstringMaterial(int materialID, int value, ItemStack input, ItemStack craftingItem, float durability,
|
||||
float drawspeed, float flightspeed) {
|
||||
super(materialID, value, input, craftingItem);
|
||||
this.durabilityModifier = durability;
|
||||
this.drawspeedModifier = drawspeed;
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package tconstruct.library.tools;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public abstract class CustomMaterial {
|
||||
|
||||
public final int materialID;
|
||||
public final int value;
|
||||
public final ItemStack input;
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
/* Base class for harvest tools with each head having a different purpose */
|
||||
|
||||
public abstract class DualHarvestTool extends HarvestTool {
|
||||
|
||||
public DualHarvestTool(int baseDamage) {
|
||||
super(baseDamage);
|
||||
}
|
||||
@@ -66,7 +67,7 @@ public abstract class DualHarvestTool extends HarvestTool {
|
||||
|
||||
@Override
|
||||
public String[] getTraits() {
|
||||
return new String[] {"harvest", "dualharvest"};
|
||||
return new String[] { "harvest", "dualharvest" };
|
||||
}
|
||||
|
||||
protected abstract Material[] getEffectiveSecondaryMaterials();
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
package tconstruct.library.tools;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.util.TextureHelper;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class DualMaterialToolPart extends DynamicToolPart {
|
||||
|
||||
public IIcon defaultIcon2;
|
||||
public IIcon[] icons2;
|
||||
|
||||
@@ -69,12 +72,16 @@ public class DualMaterialToolPart extends DynamicToolPart {
|
||||
|
||||
// register icon for each material that has one
|
||||
if (!PHConstruct.minimalTextures)
|
||||
for (Map.Entry<Integer, tconstruct.library.tools.ToolMaterial> entry :
|
||||
TConstructRegistry.toolMaterials.entrySet()) {
|
||||
String tex = modTexPrefix + ":" + folder
|
||||
+ entry.getValue().materialName.toLowerCase() + texture + "_2";
|
||||
if (TextureHelper.itemTextureExists(tex)) this.icons2[entry.getKey()] = iconRegister.registerIcon(tex);
|
||||
}
|
||||
for (Map.Entry<Integer, tconstruct.library.tools.ToolMaterial> entry : TConstructRegistry.toolMaterials
|
||||
.entrySet()) {
|
||||
String tex = modTexPrefix + ":"
|
||||
+ folder
|
||||
+ entry.getValue().materialName.toLowerCase()
|
||||
+ texture
|
||||
+ "_2";
|
||||
if (TextureHelper.itemTextureExists(tex))
|
||||
this.icons2[entry.getKey()] = iconRegister.registerIcon(tex);
|
||||
}
|
||||
|
||||
this.defaultIcon2 = iconRegister.registerIcon(modTexPrefix + ":" + folder + texture + "_2");
|
||||
}
|
||||
@@ -98,8 +105,7 @@ public class DualMaterialToolPart extends DynamicToolPart {
|
||||
int matId = getMaterialID2(stack);
|
||||
if (matId > icons2.length || matId < 0) return super.getColorFromItemStack(stack, renderpass);
|
||||
|
||||
if (icons[matId] == null)
|
||||
return TConstructRegistry.getMaterial(matId).primaryColor();
|
||||
if (icons[matId] == null) return TConstructRegistry.getMaterial(matId).primaryColor();
|
||||
|
||||
return super.getColorFromItemStack(stack, renderpass);
|
||||
}
|
||||
|
||||
@@ -1,23 +1,27 @@
|
||||
package tconstruct.library.tools;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import mantle.items.abstracts.CraftingItem;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.util.IToolPart;
|
||||
import tconstruct.library.util.TextureHelper;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class DynamicToolPart extends CraftingItem implements IToolPart {
|
||||
|
||||
public String partName;
|
||||
public String texture;
|
||||
public IIcon defaultIcon;
|
||||
@@ -37,8 +41,8 @@ public class DynamicToolPart extends CraftingItem implements IToolPart {
|
||||
this(texture, name, domain, null);
|
||||
}
|
||||
|
||||
public DynamicToolPart(
|
||||
String texture, String name, String domain, Class<? extends CustomMaterial> customMaterialClass) {
|
||||
public DynamicToolPart(String texture, String name, String domain,
|
||||
Class<? extends CustomMaterial> customMaterialClass) {
|
||||
super(null, null, "parts/", domain, TConstructRegistry.partTab);
|
||||
this.setUnlocalizedName("tconstruct." + name);
|
||||
this.partName = name;
|
||||
@@ -75,8 +79,8 @@ public class DynamicToolPart extends CraftingItem implements IToolPart {
|
||||
: toolmat.localizationString; // :(
|
||||
matName = toolmat.prefixName();
|
||||
} else {
|
||||
CustomMaterial customMaterial =
|
||||
TConstructRegistry.getCustomMaterial(getMaterialID(stack), customMaterialClass);
|
||||
CustomMaterial customMaterial = TConstructRegistry
|
||||
.getCustomMaterial(getMaterialID(stack), customMaterialClass);
|
||||
if (customMaterial == null) return super.getItemStackDisplayName(stack);
|
||||
|
||||
if (customMaterial.input != null) {
|
||||
@@ -114,10 +118,10 @@ public class DynamicToolPart extends CraftingItem implements IToolPart {
|
||||
tconstruct.library.tools.ToolMaterial toolmat = TConstructRegistry.getMaterial(getMaterialID(stack));
|
||||
material = toolmat.materialName;
|
||||
} else {
|
||||
CustomMaterial customMaterial =
|
||||
TConstructRegistry.getCustomMaterial(getMaterialID(stack), customMaterialClass);
|
||||
material =
|
||||
customMaterial.input != null ? customMaterial.input.getUnlocalizedName() : customMaterial.oredict;
|
||||
CustomMaterial customMaterial = TConstructRegistry
|
||||
.getCustomMaterial(getMaterialID(stack), customMaterialClass);
|
||||
material = customMaterial.input != null ? customMaterial.input.getUnlocalizedName()
|
||||
: customMaterial.oredict;
|
||||
}
|
||||
|
||||
return "toolpart." + partName + "." + material;
|
||||
@@ -145,12 +149,15 @@ public class DynamicToolPart extends CraftingItem implements IToolPart {
|
||||
|
||||
// register icon for each material that has one
|
||||
if (!PHConstruct.minimalTextures)
|
||||
for (Map.Entry<Integer, tconstruct.library.tools.ToolMaterial> entry :
|
||||
TConstructRegistry.toolMaterials.entrySet()) {
|
||||
String tex = modTexPrefix + ":" + folder
|
||||
+ entry.getValue().materialName.toLowerCase() + texture;
|
||||
if (TextureHelper.itemTextureExists(tex)) this.icons[entry.getKey()] = iconRegister.registerIcon(tex);
|
||||
}
|
||||
for (Map.Entry<Integer, tconstruct.library.tools.ToolMaterial> entry : TConstructRegistry.toolMaterials
|
||||
.entrySet()) {
|
||||
String tex = modTexPrefix + ":"
|
||||
+ folder
|
||||
+ entry.getValue().materialName.toLowerCase()
|
||||
+ texture;
|
||||
if (TextureHelper.itemTextureExists(tex))
|
||||
this.icons[entry.getKey()] = iconRegister.registerIcon(tex);
|
||||
}
|
||||
|
||||
// default texture
|
||||
this.defaultIcon = iconRegister.registerIcon(modTexPrefix + ":" + folder + texture);
|
||||
@@ -171,8 +178,7 @@ public class DynamicToolPart extends CraftingItem implements IToolPart {
|
||||
if (matId > icons.length) return super.getColorFromItemStack(stack, renderpass);
|
||||
|
||||
if (matId >= 0 && icons[matId] == null) {
|
||||
if (customMaterialClass == null)
|
||||
return TConstructRegistry.getMaterial(getMaterialID(stack)).primaryColor();
|
||||
if (customMaterialClass == null) return TConstructRegistry.getMaterial(getMaterialID(stack)).primaryColor();
|
||||
else return TConstructRegistry.getCustomMaterial(getMaterialID(stack), customMaterialClass).color;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,19 +3,13 @@ package tconstruct.library.tools;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class FletchingMaterial extends CustomMaterial {
|
||||
|
||||
public final float accuracy;
|
||||
public final float breakChance;
|
||||
public final float durabilityModifier;
|
||||
|
||||
public FletchingMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
ItemStack input,
|
||||
ItemStack craftingItem,
|
||||
float accuracy,
|
||||
float breakChance,
|
||||
float duribalityModifier,
|
||||
int color) {
|
||||
public FletchingMaterial(int materialID, int value, ItemStack input, ItemStack craftingItem, float accuracy,
|
||||
float breakChance, float duribalityModifier, int color) {
|
||||
super(materialID, value, input, craftingItem, color);
|
||||
this.accuracy = accuracy;
|
||||
this.breakChance = breakChance;
|
||||
@@ -23,26 +17,13 @@ public class FletchingMaterial extends CustomMaterial {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public FletchingMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
ItemStack input,
|
||||
ItemStack craftingItem,
|
||||
float accuracy,
|
||||
float breakChance,
|
||||
float mass) {
|
||||
public FletchingMaterial(int materialID, int value, ItemStack input, ItemStack craftingItem, float accuracy,
|
||||
float breakChance, float mass) {
|
||||
this(materialID, value, input, craftingItem, accuracy, 0.01f, 1f, 0xffffffff);
|
||||
}
|
||||
|
||||
public FletchingMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
String oredict,
|
||||
ItemStack craftingItem,
|
||||
float accuracy,
|
||||
float breakChance,
|
||||
float duribalityModifier,
|
||||
int color) {
|
||||
public FletchingMaterial(int materialID, int value, String oredict, ItemStack craftingItem, float accuracy,
|
||||
float breakChance, float duribalityModifier, int color) {
|
||||
super(materialID, value, oredict, craftingItem, color);
|
||||
this.accuracy = accuracy;
|
||||
this.breakChance = breakChance;
|
||||
@@ -50,14 +31,8 @@ public class FletchingMaterial extends CustomMaterial {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public FletchingMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
String oredict,
|
||||
ItemStack craftingItem,
|
||||
float accuracy,
|
||||
float breakChance,
|
||||
float mass) {
|
||||
public FletchingMaterial(int materialID, int value, String oredict, ItemStack craftingItem, float accuracy,
|
||||
float breakChance, float mass) {
|
||||
this(materialID, value, oredict, craftingItem, accuracy, 0.01f, 1f, 0xffffffff);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
package tconstruct.library.tools;
|
||||
|
||||
import mantle.blocks.BlockUtils;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class FletchlingLeafMaterial extends FletchingMaterial {
|
||||
public FletchlingLeafMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
String oredict,
|
||||
ItemStack craftingItem,
|
||||
float accuracy,
|
||||
float breakChance,
|
||||
float durabilityModifier) {
|
||||
|
||||
public FletchlingLeafMaterial(int materialID, int value, String oredict, ItemStack craftingItem, float accuracy,
|
||||
float breakChance, float durabilityModifier) {
|
||||
super(materialID, value, oredict, craftingItem, accuracy, breakChance, durabilityModifier, 0x5ece46);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package tconstruct.library.tools;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -17,12 +18,14 @@ import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
|
||||
/* Base class for tools that should be harvesting blocks */
|
||||
|
||||
public abstract class HarvestTool extends ToolCore {
|
||||
|
||||
public HarvestTool(int baseDamage) {
|
||||
super(baseDamage);
|
||||
}
|
||||
@@ -84,7 +87,7 @@ public abstract class HarvestTool extends ToolCore {
|
||||
|
||||
@Override
|
||||
public String[] getTraits() {
|
||||
return new String[] {"harvest"};
|
||||
return new String[] { "harvest" };
|
||||
}
|
||||
|
||||
protected abstract Material[] getEffectiveMaterials();
|
||||
@@ -115,19 +118,11 @@ public abstract class HarvestTool extends ToolCore {
|
||||
|
||||
// Right-click
|
||||
@Override
|
||||
public boolean onItemUse(
|
||||
ItemStack stack,
|
||||
EntityPlayer player,
|
||||
World world,
|
||||
int x,
|
||||
int y,
|
||||
int z,
|
||||
int side,
|
||||
float clickX,
|
||||
float clickY,
|
||||
float clickZ) {
|
||||
/*if (world.isRemote)
|
||||
return true;*/
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side,
|
||||
float clickX, float clickY, float clickZ) {
|
||||
/*
|
||||
* if (world.isRemote) return true;
|
||||
*/
|
||||
|
||||
boolean used = false;
|
||||
int hotbarSlot = player.inventory.currentItem;
|
||||
@@ -165,8 +160,8 @@ public abstract class HarvestTool extends ToolCore {
|
||||
break;
|
||||
}
|
||||
|
||||
AxisAlignedBB blockBounds =
|
||||
AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX + 1, posY + 1, posZ + 1);
|
||||
AxisAlignedBB blockBounds = AxisAlignedBB
|
||||
.getBoundingBox(posX, posY, posZ, posX + 1, posY + 1, posZ + 1);
|
||||
AxisAlignedBB playerBounds = player.boundingBox;
|
||||
|
||||
if (item instanceof ItemBlock) {
|
||||
@@ -201,18 +196,15 @@ public abstract class HarvestTool extends ToolCore {
|
||||
}
|
||||
|
||||
/*
|
||||
if (used) //Update client
|
||||
{
|
||||
Packet103SetSlot packet = new Packet103SetSlot(player.openContainer.windowId, itemSlot, nearbyStack);
|
||||
((EntityPlayerMP)player).playerNetServerHandler.sendPacketToPlayer(packet);
|
||||
}
|
||||
*/
|
||||
* if (used) //Update client { Packet103SetSlot packet = new Packet103SetSlot(player.openContainer.windowId,
|
||||
* itemSlot, nearbyStack); ((EntityPlayerMP)player).playerNetServerHandler.sendPacketToPlayer(packet); }
|
||||
*/
|
||||
|
||||
return used;
|
||||
}
|
||||
|
||||
public void breakExtraBlock(
|
||||
World world, int x, int y, int z, int sidehit, EntityPlayer playerEntity, int refX, int refY, int refZ) {
|
||||
public void breakExtraBlock(World world, int x, int y, int z, int sidehit, EntityPlayer playerEntity, int refX,
|
||||
int refY, int refZ) {
|
||||
// prevent calling that stuff for air blocks, could lead to unexpected behaviour since it fires events
|
||||
if (world.isAirBlock(x, y, z)) return;
|
||||
|
||||
@@ -236,8 +228,8 @@ public abstract class HarvestTool extends ToolCore {
|
||||
if (!ForgeHooks.canHarvestBlock(block, player, meta) || refStrength / strength > 10f) return;
|
||||
|
||||
// send the blockbreak event
|
||||
BlockEvent.BreakEvent event =
|
||||
ForgeHooks.onBlockBreakEvent(world, player.theItemInWorldManager.getGameType(), player, x, y, z);
|
||||
BlockEvent.BreakEvent event = ForgeHooks
|
||||
.onBlockBreakEvent(world, player.theItemInWorldManager.getGameType(), player, x, y, z);
|
||||
if (event.isCanceled()) return;
|
||||
|
||||
if (player.capabilities.isCreativeMode) {
|
||||
@@ -265,8 +257,8 @@ public abstract class HarvestTool extends ToolCore {
|
||||
// ItemInWorldManager.removeBlock
|
||||
block.onBlockHarvested(world, x, y, z, meta, player);
|
||||
|
||||
if (block.removedByPlayer(
|
||||
world, player, x, y, z, true)) // boolean is if block can be harvested, checked above
|
||||
if (block.removedByPlayer(world, player, x, y, z, true)) // boolean is if block can be harvested, checked
|
||||
// above
|
||||
{
|
||||
block.onBlockDestroyedByPlayer(world, x, y, z, meta);
|
||||
block.harvestBlock(world, player, x, y, z, meta);
|
||||
@@ -300,11 +292,8 @@ public abstract class HarvestTool extends ToolCore {
|
||||
}
|
||||
|
||||
// send an update to the server, so we get an update back
|
||||
if (PHConstruct.extraBlockUpdates)
|
||||
Minecraft.getMinecraft()
|
||||
.getNetHandler()
|
||||
.addToSendQueue(new C07PacketPlayerDigging(
|
||||
2, x, y, z, Minecraft.getMinecraft().objectMouseOver.sideHit));
|
||||
if (PHConstruct.extraBlockUpdates) Minecraft.getMinecraft().getNetHandler().addToSendQueue(
|
||||
new C07PacketPlayerDigging(2, x, y, z, Minecraft.getMinecraft().objectMouseOver.sideHit));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,7 @@
|
||||
package tconstruct.library.tools;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import cofh.core.item.IEqualityOverrideItem;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.*;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
@@ -14,6 +11,7 @@ import net.minecraft.item.*;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import tconstruct.library.*;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import tconstruct.library.modifier.*;
|
||||
@@ -22,35 +20,33 @@ import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.tools.entity.FancyEntityItem;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import cofh.core.item.IEqualityOverrideItem;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.*;
|
||||
|
||||
/**
|
||||
* NBTTags Main tag - InfiTool
|
||||
*
|
||||
* @see ToolBuilder
|
||||
*
|
||||
* Required: Head: Base and render tag, above the handle Handle: Base and
|
||||
* render tag, bottom layer
|
||||
* Required: Head: Base and render tag, above the handle Handle: Base and render tag, bottom layer
|
||||
*
|
||||
* Damage: Replacement for metadata MaxDamage: ItemStacks only read
|
||||
* setMaxDamage() Broken: Represents whether the tool is broken (boolean)
|
||||
* Attack: How much damage a mob will take MiningSpeed: The speed at which
|
||||
* a tool mines
|
||||
* Damage: Replacement for metadata MaxDamage: ItemStacks only read setMaxDamage() Broken: Represents whether the
|
||||
* tool is broken (boolean) Attack: How much damage a mob will take MiningSpeed: The speed at which a tool mines
|
||||
*
|
||||
* Others: Accessory: Base and tag, above head. Sword guards, binding, etc
|
||||
* Effects: Render tag, top layer. Fancy effects like moss or diamond edge.
|
||||
* Render order: Handle > Head > Accessory > Effect1 > Effect2 > Effect3 >
|
||||
* etc Unbreaking: Reinforced in-game, 10% chance to not use durability per
|
||||
* level Stonebound: Mines faster as the tool takes damage, but has less
|
||||
* attack Spiny: Opposite of stonebound
|
||||
* Others: Accessory: Base and tag, above head. Sword guards, binding, etc Effects: Render tag, top layer. Fancy
|
||||
* effects like moss or diamond edge. Render order: Handle > Head > Accessory > Effect1 > Effect2 > Effect3 > etc
|
||||
* Unbreaking: Reinforced in-game, 10% chance to not use durability per level Stonebound: Mines faster as the tool
|
||||
* takes damage, but has less attack Spiny: Opposite of stonebound
|
||||
*
|
||||
* Modifiers have their own tags.
|
||||
* Modifiers have their own tags.
|
||||
* @see ItemModifier
|
||||
*/
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(modid = "CoFHAPI|energy", iface = "cofh.api.energy.IEnergyContainerItem"),
|
||||
@Optional.Interface(modid = "CoFHCore", iface = "cofh.core.item.IEqualityOverrideItem")
|
||||
})
|
||||
@Optional.InterfaceList({ @Optional.Interface(modid = "CoFHAPI|energy", iface = "cofh.api.energy.IEnergyContainerItem"),
|
||||
@Optional.Interface(modid = "CoFHCore", iface = "cofh.core.item.IEqualityOverrideItem") })
|
||||
public abstract class ToolCore extends Item implements IEnergyContainerItem, IEqualityOverrideItem, IModifyable {
|
||||
|
||||
protected Random random = new Random();
|
||||
protected int damageVsEntity;
|
||||
public static IIcon blankSprite;
|
||||
@@ -79,8 +75,8 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem, IEq
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines crafting behavior with regards to durability 0: None 1: Adds
|
||||
* handle modifier 2: Averages part with the rest of the tool (head)
|
||||
* Determines crafting behavior with regards to durability 0: None 1: Adds handle modifier 2: Averages part with the
|
||||
* rest of the tool (head)
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
@@ -155,8 +151,7 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem, IEq
|
||||
public abstract String getDefaultFolder();
|
||||
|
||||
/**
|
||||
* Returns the COMPLETE resource path.
|
||||
* Example: tinker:broadsword
|
||||
* Returns the COMPLETE resource path. Example: tinker:broadsword
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -192,16 +187,12 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem, IEq
|
||||
emptyIcon = iconRegister.registerIcon("tinker:blankface");
|
||||
}
|
||||
|
||||
protected void addIcons(
|
||||
HashMap<Integer, String> textures,
|
||||
HashMap<Integer, IIcon> icons,
|
||||
IIconRegister iconRegister,
|
||||
String standard,
|
||||
boolean defaultOnly) {
|
||||
protected void addIcons(HashMap<Integer, String> textures, HashMap<Integer, IIcon> icons,
|
||||
IIconRegister iconRegister, String standard, boolean defaultOnly) {
|
||||
icons.clear();
|
||||
|
||||
if (!defaultOnly) // compatibility mode: no specific textures
|
||||
for (Map.Entry<Integer, String> entry : textures.entrySet()) {
|
||||
for (Map.Entry<Integer, String> entry : textures.entrySet()) {
|
||||
if (TextureHelper.itemTextureExists(entry.getValue()))
|
||||
icons.put(entry.getKey(), iconRegister.registerIcon(entry.getValue()));
|
||||
}
|
||||
@@ -316,13 +307,12 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem, IEq
|
||||
if (!tipName.equals("")) {
|
||||
// let's see if we can translate it somehow
|
||||
// strip color information
|
||||
String locString =
|
||||
"modifier.tooltip." + EnumChatFormatting.getTextWithoutFormattingCodes(tipName);
|
||||
String locString = "modifier.tooltip."
|
||||
+ EnumChatFormatting.getTextWithoutFormattingCodes(tipName);
|
||||
locString = locString.replace(" ", "");
|
||||
if (StatCollector.canTranslate(locString))
|
||||
tipName = tipName.replace(
|
||||
EnumChatFormatting.getTextWithoutFormattingCodes(tipName),
|
||||
StatCollector.translateToLocal(locString));
|
||||
if (StatCollector.canTranslate(locString)) tipName = tipName.replace(
|
||||
EnumChatFormatting.getTextWithoutFormattingCodes(tipName),
|
||||
StatCollector.translateToLocal(locString));
|
||||
|
||||
list.add(tipName);
|
||||
}
|
||||
@@ -332,8 +322,10 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem, IEq
|
||||
}
|
||||
list.add("");
|
||||
int attack = (int) (tags.getCompoundTag("InfiTool").getInteger("Attack") * this.getDamageModifier());
|
||||
list.add("\u00A79+" + attack + " "
|
||||
+ StatCollector.translateToLocalFormatted("attribute.name.generic.attackDamage"));
|
||||
list.add(
|
||||
"\u00A79+" + attack
|
||||
+ " "
|
||||
+ StatCollector.translateToLocalFormatted("attribute.name.generic.attackDamage"));
|
||||
}
|
||||
|
||||
public static String getStyleForType(int type) {
|
||||
@@ -433,8 +425,8 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem, IEq
|
||||
|
||||
@Override
|
||||
public void getSubItems(Item id, CreativeTabs tab, List list) {
|
||||
for (Map.Entry<Integer, tconstruct.library.tools.ToolMaterial> integerToolMaterialEntry :
|
||||
TConstructRegistry.toolMaterials.entrySet()) {
|
||||
for (Map.Entry<Integer, tconstruct.library.tools.ToolMaterial> integerToolMaterialEntry : TConstructRegistry.toolMaterials
|
||||
.entrySet()) {
|
||||
tconstruct.library.tools.ToolMaterial material = integerToolMaterialEntry.getValue();
|
||||
buildTool(integerToolMaterialEntry.getKey(), ToolBuilder.defaultToolName(material, this), list);
|
||||
}
|
||||
@@ -497,8 +489,8 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem, IEq
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed(
|
||||
ItemStack itemstack, World world, Block block, int x, int y, int z, EntityLivingBase player) {
|
||||
public boolean onBlockDestroyed(ItemStack itemstack, World world, Block block, int x, int y, int z,
|
||||
EntityLivingBase player) {
|
||||
if (!itemstack.hasTagCompound()) return false;
|
||||
|
||||
// callbacks!
|
||||
@@ -567,8 +559,7 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem, IEq
|
||||
case 0:
|
||||
return getCorrectColor(stack, renderPass, tags, "Handle", handleIcons);
|
||||
case 1:
|
||||
return tags.getBoolean("Broken")
|
||||
? getCorrectColor(stack, renderPass, tags, "Head", brokenIcons)
|
||||
return tags.getBoolean("Broken") ? getCorrectColor(stack, renderPass, tags, "Head", brokenIcons)
|
||||
: getCorrectColor(stack, renderPass, tags, "Head", headIcons);
|
||||
case 2:
|
||||
return getCorrectColor(stack, renderPass, tags, "Accessory", accessoryIcons);
|
||||
@@ -580,8 +571,8 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem, IEq
|
||||
return super.getColorFromItemStack(stack, renderPass);
|
||||
}
|
||||
|
||||
protected int getCorrectColor(
|
||||
ItemStack stack, int renderPass, NBTTagCompound tags, String key, Map<Integer, IIcon> map) {
|
||||
protected int getCorrectColor(ItemStack stack, int renderPass, NBTTagCompound tags, String key,
|
||||
Map<Integer, IIcon> map) {
|
||||
// custom coloring
|
||||
if (tags.hasKey(key + "Color")) return tags.getInteger(key + "Color");
|
||||
|
||||
@@ -740,9 +731,8 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem, IEq
|
||||
NBTTagCompound tags = container.getTagCompound();
|
||||
if (tags == null || !tags.hasKey("Energy")) return 0;
|
||||
int energy = tags.getInteger("Energy");
|
||||
int energyReceived = tags.hasKey("EnergyReceiveRate")
|
||||
? tags.getInteger("EnergyReceiveRate")
|
||||
: this.maxReceive; // backup value
|
||||
int energyReceived = tags.hasKey("EnergyReceiveRate") ? tags.getInteger("EnergyReceiveRate") : this.maxReceive; // backup
|
||||
// value
|
||||
int maxEnergy = tags.hasKey("EnergyMax") ? tags.getInteger("EnergyMax") : this.capacity; // backup value
|
||||
|
||||
// calculate how much we can receive
|
||||
@@ -764,8 +754,7 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem, IEq
|
||||
return 0;
|
||||
}
|
||||
int energy = tags.getInteger("Energy");
|
||||
int energyExtracted = tags.hasKey("EnergyExtractionRate")
|
||||
? tags.getInteger("EnergyExtractionRate")
|
||||
int energyExtracted = tags.hasKey("EnergyExtractionRate") ? tags.getInteger("EnergyExtractionRate")
|
||||
: this.maxExtract; // backup value
|
||||
|
||||
// calculate how much we can extract
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.util.StatCollector;
|
||||
* Dynamic substitute for an enum. It carries a lot of information
|
||||
*/
|
||||
public class ToolMaterial {
|
||||
|
||||
public final String materialName;
|
||||
public final int harvestLevel;
|
||||
public final int durability;
|
||||
@@ -26,61 +27,25 @@ public class ToolMaterial {
|
||||
public String ability;
|
||||
|
||||
@Deprecated
|
||||
public ToolMaterial(
|
||||
String name,
|
||||
String displayName,
|
||||
int level,
|
||||
int durability,
|
||||
int speed,
|
||||
int damage,
|
||||
float handle,
|
||||
int reinforced,
|
||||
float stonebound,
|
||||
String style,
|
||||
String ability) {
|
||||
public ToolMaterial(String name, String displayName, int level, int durability, int speed, int damage, float handle,
|
||||
int reinforced, float stonebound, String style, String ability) {
|
||||
this(name, level, durability, speed, damage, handle, reinforced, stonebound, style, 0xFFFFFF);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ToolMaterial(
|
||||
String name,
|
||||
int level,
|
||||
int durability,
|
||||
int speed,
|
||||
int damage,
|
||||
float handle,
|
||||
int reinforced,
|
||||
float stonebound,
|
||||
String style,
|
||||
String ability) {
|
||||
public ToolMaterial(String name, int level, int durability, int speed, int damage, float handle, int reinforced,
|
||||
float stonebound, String style, String ability) {
|
||||
this(name, level, durability, speed, damage, handle, reinforced, stonebound, style, 0xFFFFFF);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ToolMaterial(
|
||||
String name,
|
||||
int level,
|
||||
int durability,
|
||||
int speed,
|
||||
int damage,
|
||||
float handle,
|
||||
int reinforced,
|
||||
float stonebound,
|
||||
String style) {
|
||||
public ToolMaterial(String name, int level, int durability, int speed, int damage, float handle, int reinforced,
|
||||
float stonebound, String style) {
|
||||
this(name, level, durability, speed, damage, handle, reinforced, stonebound, style, 0xFFFFFF);
|
||||
}
|
||||
|
||||
public ToolMaterial(
|
||||
String name,
|
||||
int level,
|
||||
int durability,
|
||||
int speed,
|
||||
int damage,
|
||||
float handle,
|
||||
int reinforced,
|
||||
float stonebound,
|
||||
String style,
|
||||
int primaryColor) {
|
||||
public ToolMaterial(String name, int level, int durability, int speed, int damage, float handle, int reinforced,
|
||||
float stonebound, String style, int primaryColor) {
|
||||
this(
|
||||
name,
|
||||
"material." + name.toLowerCase().replaceAll(" ", ""),
|
||||
@@ -95,18 +60,8 @@ public class ToolMaterial {
|
||||
primaryColor);
|
||||
}
|
||||
|
||||
public ToolMaterial(
|
||||
String name,
|
||||
String localizationString,
|
||||
int level,
|
||||
int durability,
|
||||
int speed,
|
||||
int damage,
|
||||
float handle,
|
||||
int reinforced,
|
||||
float stonebound,
|
||||
String style,
|
||||
int primaryColor) {
|
||||
public ToolMaterial(String name, String localizationString, int level, int durability, int speed, int damage,
|
||||
float handle, int reinforced, float stonebound, String style, int primaryColor) {
|
||||
this.materialName = name;
|
||||
this.harvestLevel = level;
|
||||
this.durability = durability;
|
||||
@@ -176,8 +131,8 @@ public class ToolMaterial {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ability of the tool to display.
|
||||
* ONLY USE THIS FOR DISPLAY PURPOSES. It is not data you can rely on. Use the material-ids for that.
|
||||
* Returns the ability of the tool to display. ONLY USE THIS FOR DISPLAY PURPOSES. It is not data you can rely on.
|
||||
* Use the material-ids for that.
|
||||
*/
|
||||
public String ability() {
|
||||
if (StatCollector.canTranslate(String.format("%s.ability", localizationString)))
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package tconstruct.library.tools;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.*;
|
||||
import mods.battlegear2.api.PlayerEventChild;
|
||||
import mods.battlegear2.api.weapons.IBattlegearWeapon;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
@@ -12,13 +11,15 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.*;
|
||||
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon"),
|
||||
@Optional.Interface(modid = "ZeldaItemAPI", iface = "zeldaswordskills.api.item.ISword"),
|
||||
@Optional.Interface(modid = "DynamicSkillsAPI", iface = "dynamicswordskills.api.ISword")
|
||||
})
|
||||
@Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon"),
|
||||
@Optional.Interface(modid = "ZeldaItemAPI", iface = "zeldaswordskills.api.item.ISword"),
|
||||
@Optional.Interface(modid = "DynamicSkillsAPI", iface = "dynamicswordskills.api.ISword") })
|
||||
public abstract class Weapon extends ToolCore
|
||||
implements IBattlegearWeapon, zeldaswordskills.api.item.ISword, dynamicswordskills.api.ISword {
|
||||
|
||||
@@ -49,8 +50,7 @@ public abstract class Weapon extends ToolCore
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the action that specifies what animation to play when the items
|
||||
* is being used
|
||||
* returns the action that specifies what animation to play when the items is being used
|
||||
*/
|
||||
@Override
|
||||
public EnumAction getItemUseAction(ItemStack par1ItemStack) {
|
||||
@@ -66,8 +66,7 @@ public abstract class Weapon extends ToolCore
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever this item is equipped and the right mouse button is
|
||||
* pressed. Args: itemStack, world, entityPlayer
|
||||
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
|
||||
*/
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
@@ -76,17 +75,8 @@ public abstract class Weapon extends ToolCore
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(
|
||||
ItemStack stack,
|
||||
EntityPlayer player,
|
||||
World world,
|
||||
int x,
|
||||
int y,
|
||||
int z,
|
||||
int side,
|
||||
float clickX,
|
||||
float clickY,
|
||||
float clickZ) {
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side,
|
||||
float clickX, float clickY, float clickZ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -121,10 +111,10 @@ public abstract class Weapon extends ToolCore
|
||||
|
||||
@Override
|
||||
public String[] getTraits() {
|
||||
return new String[] {"weapon", "melee"};
|
||||
return new String[] { "weapon", "melee" };
|
||||
}
|
||||
|
||||
public static Material[] web = new Material[] {Material.web, Material.cloth, Material.coral, Material.cake};
|
||||
public static Material[] web = new Material[] { Material.web, Material.cloth, Material.coral, Material.cake };
|
||||
public static Material[] none = new Material[0];
|
||||
|
||||
/*---- Battlegear Support START ----*/
|
||||
@@ -143,8 +133,8 @@ public abstract class Weapon extends ToolCore
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean offhandAttackEntity(
|
||||
PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
|
||||
public boolean offhandAttackEntity(PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem,
|
||||
ItemStack offhandItem) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -171,9 +161,8 @@ public abstract class Weapon extends ToolCore
|
||||
public boolean allowOffhand(ItemStack mainhand, ItemStack offhand) {
|
||||
if (offhand == null) return true;
|
||||
|
||||
return (mainhand != null
|
||||
&& mainhand.getItem() != TinkerTools.cleaver
|
||||
&& mainhand.getItem() != TinkerTools.battleaxe)
|
||||
return (mainhand != null && mainhand.getItem() != TinkerTools.cleaver
|
||||
&& mainhand.getItem() != TinkerTools.battleaxe)
|
||||
&& (offhand.getItem() != TinkerTools.cleaver && offhand.getItem() != TinkerTools.battleaxe);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,12 @@ import net.minecraft.dispenser.IPosition;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import tconstruct.library.entity.ProjectileBase;
|
||||
import tconstruct.library.weaponry.IAmmo;
|
||||
|
||||
public abstract class BehaviorProjectileBaseDispense extends BehaviorDefaultDispenseItem {
|
||||
|
||||
/**
|
||||
* Dispense the specified stack, play the dispense sound and spawn particles.
|
||||
*/
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package tconstruct.library.util;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
/**
|
||||
* Lookup for the name of each harvest level. Use this clientside only for display purposes.
|
||||
*/
|
||||
public final class HarvestLevels {
|
||||
|
||||
private HarvestLevels() {} // non-instantiable
|
||||
|
||||
public static final Map<Integer, String> harvestLevelNames = new HashMap<>();
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package tconstruct.library.util;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import tconstruct.library.crafting.PatternBuilder.MaterialSet;
|
||||
|
||||
public interface IPattern {
|
||||
|
||||
int getPatternCost(ItemStack pattern);
|
||||
|
||||
ItemStack getPatternOutput(ItemStack pattern, ItemStack input, MaterialSet set);
|
||||
|
||||
@@ -3,11 +3,11 @@ package tconstruct.library.util;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IToolPart {
|
||||
|
||||
/**
|
||||
* Parts to build tools from. ex: Pickaxe Head
|
||||
*
|
||||
* @param stack
|
||||
* This item
|
||||
* @param stack This item
|
||||
* @return Proper material ID. -1 for invalid
|
||||
*/
|
||||
int getMaterialID(ItemStack stack);
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.EntityDamageSourceIndirect;
|
||||
|
||||
public class PiercingArrowDamage extends EntityDamageSourceIndirect {
|
||||
|
||||
public PiercingArrowDamage(String p_i1568_1_, Entity p_i1568_2_, Entity p_i1568_3_) {
|
||||
super(p_i1568_1_, p_i1568_2_, p_i1568_3_);
|
||||
this.setProjectile();
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.EntityDamageSource;
|
||||
|
||||
public class PiercingEntityDamage extends EntityDamageSource {
|
||||
|
||||
public PiercingEntityDamage(String str, Entity entity) {
|
||||
super(str, entity);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package tconstruct.library.util;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
// Stolen from CofHLib RegistryUtil
|
||||
public final class TextureHelper {
|
||||
|
||||
private TextureHelper() {}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
package tconstruct.library.weaponry;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import mods.battlegear2.api.PlayerEventChild;
|
||||
import mods.battlegear2.api.weapons.IBattlegearWeapon;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon")
|
||||
})
|
||||
@Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon") })
|
||||
public abstract class AmmoItem extends ToolCore implements IBattlegearWeapon, IAmmo {
|
||||
|
||||
public AmmoItem(int baseDamage, String name) {
|
||||
super(baseDamage);
|
||||
this.setCreativeTab(TConstructRegistry.weaponryTab);
|
||||
@@ -161,8 +163,8 @@ public abstract class AmmoItem extends ToolCore implements IBattlegearWeapon, IA
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean offhandAttackEntity(
|
||||
PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
|
||||
public boolean offhandAttackEntity(PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem,
|
||||
ItemStack offhandItem) {
|
||||
event.cancelParent = false;
|
||||
event.swingOffhand = false;
|
||||
event.shouldAttack = false;
|
||||
@@ -193,9 +195,8 @@ public abstract class AmmoItem extends ToolCore implements IBattlegearWeapon, IA
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean allowOffhand(ItemStack mainhand, ItemStack offhand) {
|
||||
if (offhand == null) return true;
|
||||
return (mainhand != null
|
||||
&& mainhand.getItem() != TinkerTools.cleaver
|
||||
&& mainhand.getItem() != TinkerTools.battleaxe)
|
||||
return (mainhand != null && mainhand.getItem() != TinkerTools.cleaver
|
||||
&& mainhand.getItem() != TinkerTools.battleaxe)
|
||||
&& (offhand.getItem() != TinkerTools.cleaver && offhand.getItem() != TinkerTools.battleaxe);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,28 @@
|
||||
package tconstruct.library.weaponry;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import mods.battlegear2.api.PlayerEventChild;
|
||||
import mods.battlegear2.api.weapons.IBattlegearWeapon;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.weaponry.client.CrosshairType;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon")
|
||||
})
|
||||
@Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon") })
|
||||
/**
|
||||
* Throwing weapons that utilize the ammo system on themselves.
|
||||
* Throwing knifes etc.
|
||||
* Throwing weapons that utilize the ammo system on themselves. Throwing knifes etc.
|
||||
*/
|
||||
public abstract class AmmoWeapon extends AmmoItem implements IBattlegearWeapon, IAccuracy, IWindup {
|
||||
|
||||
public AmmoWeapon(int baseDamage, String name) {
|
||||
super(baseDamage, name);
|
||||
}
|
||||
@@ -43,22 +44,14 @@ public abstract class AmmoWeapon extends AmmoItem implements IBattlegearWeapon,
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(
|
||||
ItemStack stack,
|
||||
EntityPlayer player,
|
||||
World world,
|
||||
int x,
|
||||
int y,
|
||||
int z,
|
||||
int side,
|
||||
float clickX,
|
||||
float clickY,
|
||||
float clickZ) {
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side,
|
||||
float clickX, float clickY, float clickZ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* How long it takes to "ready" the weapon. To reach the point, where holding the right mouse button any longer doesn't have an impact.
|
||||
* How long it takes to "ready" the weapon. To reach the point, where holding the right mouse button any longer
|
||||
* doesn't have an impact.
|
||||
*/
|
||||
@Override
|
||||
public int getWindupTime(ItemStack itemStack) {
|
||||
@@ -105,7 +98,7 @@ public abstract class AmmoWeapon extends AmmoItem implements IBattlegearWeapon,
|
||||
|
||||
@Override
|
||||
public String[] getTraits() {
|
||||
return new String[] {"weapon", "thrown", "ammo", "windup"};
|
||||
return new String[] { "weapon", "thrown", "ammo", "windup" };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -129,10 +122,11 @@ public abstract class AmmoWeapon extends AmmoItem implements IBattlegearWeapon,
|
||||
if (!player.capabilities.isCreativeMode) this.consumeAmmo(1, stack);
|
||||
}
|
||||
|
||||
protected abstract Entity createProjectile(
|
||||
ItemStack reference, World world, EntityPlayer player, float accuracy, int time);
|
||||
protected abstract Entity createProjectile(ItemStack reference, World world, EntityPlayer player, float accuracy,
|
||||
int time);
|
||||
|
||||
/** used for displaying the damage, return the value used for pseed in createProjectile/ProjectileBase constructor
|
||||
/**
|
||||
* used for displaying the damage, return the value used for pseed in createProjectile/ProjectileBase constructor
|
||||
*/
|
||||
public abstract float getProjectileSpeed();
|
||||
|
||||
@@ -167,8 +161,8 @@ public abstract class AmmoWeapon extends AmmoItem implements IBattlegearWeapon,
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean offhandAttackEntity(
|
||||
PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
|
||||
public boolean offhandAttackEntity(PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem,
|
||||
ItemStack offhandItem) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -195,9 +189,8 @@ public abstract class AmmoWeapon extends AmmoItem implements IBattlegearWeapon,
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean allowOffhand(ItemStack mainhand, ItemStack offhand) {
|
||||
if (offhand == null) return true;
|
||||
return (mainhand != null
|
||||
&& mainhand.getItem() != TinkerTools.cleaver
|
||||
&& mainhand.getItem() != TinkerTools.battleaxe)
|
||||
return (mainhand != null && mainhand.getItem() != TinkerTools.cleaver
|
||||
&& mainhand.getItem() != TinkerTools.battleaxe)
|
||||
&& (offhand.getItem() != TinkerTools.cleaver && offhand.getItem() != TinkerTools.battleaxe);
|
||||
}
|
||||
}
|
||||
@@ -2,36 +2,31 @@ package tconstruct.library.weaponry;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import tconstruct.library.tools.CustomMaterial;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
|
||||
public class ArrowShaftMaterial extends CustomMaterial {
|
||||
|
||||
public final float durabilityModifier; // like the durability modifier of handles, but for arrows!
|
||||
public final float fragility; // 1.0 = breaks 100%, 0.0 = never breaks
|
||||
public final float weight; // baseline: 1.0 = default, smaller = lighter, higher = heavier
|
||||
|
||||
public ArrowShaftMaterial(
|
||||
int materialID,
|
||||
int value,
|
||||
ItemStack input,
|
||||
ItemStack craftingItem,
|
||||
float durabilityModifier,
|
||||
float weight,
|
||||
float fragility,
|
||||
int color) {
|
||||
public ArrowShaftMaterial(int materialID, int value, ItemStack input, ItemStack craftingItem,
|
||||
float durabilityModifier, float weight, float fragility, int color) {
|
||||
super(materialID, value, input, craftingItem, color);
|
||||
this.durabilityModifier = durabilityModifier;
|
||||
this.fragility = fragility;
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public static ArrowShaftMaterial createMaterial(
|
||||
int id, Item input, float durabilityModifier, float weight, float fragility, int color) {
|
||||
public static ArrowShaftMaterial createMaterial(int id, Item input, float durabilityModifier, float weight,
|
||||
float fragility, int color) {
|
||||
return createMaterial(id, input, 0, durabilityModifier, weight, fragility, color);
|
||||
}
|
||||
|
||||
public static ArrowShaftMaterial createMaterial(
|
||||
int id, Item input, int inputMeta, float durabilityModifier, float weight, float fragility, int color) {
|
||||
public static ArrowShaftMaterial createMaterial(int id, Item input, int inputMeta, float durabilityModifier,
|
||||
float weight, float fragility, int color) {
|
||||
return new ArrowShaftMaterial(
|
||||
id,
|
||||
2,
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package tconstruct.library.weaponry;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import java.util.List;
|
||||
|
||||
import mods.battlegear2.api.core.InventoryPlayerBattle;
|
||||
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -12,14 +13,17 @@ import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import tconstruct.library.tools.BowstringMaterial;
|
||||
import tconstruct.library.tools.CustomMaterial;
|
||||
import tconstruct.weaponry.ammo.ArrowAmmo;
|
||||
import tconstruct.weaponry.entity.ArrowEntity;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
public abstract class BowBaseAmmo extends ProjectileWeapon {
|
||||
|
||||
public BowBaseAmmo(int baseDamage, String name) {
|
||||
super(baseDamage, name);
|
||||
}
|
||||
@@ -108,8 +112,8 @@ public abstract class BowBaseAmmo extends ProjectileWeapon {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Entity createProjectile(
|
||||
ItemStack arrows, World world, EntityPlayer player, float speed, float accuracy, float windup) {
|
||||
protected Entity createProjectile(ItemStack arrows, World world, EntityPlayer player, float speed, float accuracy,
|
||||
float windup) {
|
||||
EntityArrow arrow;
|
||||
|
||||
if (arrows.getItem() == Items.arrow) {
|
||||
@@ -129,8 +133,8 @@ public abstract class BowBaseAmmo extends ProjectileWeapon {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playFiringSound(
|
||||
World world, EntityPlayer player, ItemStack weapon, ItemStack ammo, float speed, float accuracy) {
|
||||
public void playFiringSound(World world, EntityPlayer player, ItemStack weapon, ItemStack ammo, float speed,
|
||||
float accuracy) {
|
||||
world.playSoundAtEntity(player, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + speed * 0.5F);
|
||||
}
|
||||
|
||||
@@ -144,8 +148,8 @@ public abstract class BowBaseAmmo extends ProjectileWeapon {
|
||||
ItemStack accessoryStack = getPartAmount() > 2 ? new ItemStack(getAccessoryItem(), 1, id) : null;
|
||||
ItemStack extraStack = getPartAmount() > 3 ? new ItemStack(getExtraItem(), 1, id) : null;
|
||||
|
||||
ItemStack tool = ToolBuilder.instance.buildTool(
|
||||
new ItemStack(getHeadItem(), 1, id), handleStack, accessoryStack, extraStack, "");
|
||||
ItemStack tool = ToolBuilder.instance
|
||||
.buildTool(new ItemStack(getHeadItem(), 1, id), handleStack, accessoryStack, extraStack, "");
|
||||
if (tool != null) {
|
||||
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
|
||||
list.add(tool);
|
||||
@@ -167,6 +171,6 @@ public abstract class BowBaseAmmo extends ProjectileWeapon {
|
||||
|
||||
@Override
|
||||
public String[] getTraits() {
|
||||
return new String[] {"weapon", "bow", "windup"};
|
||||
return new String[] { "weapon", "bow", "windup" };
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package tconstruct.library.weaponry;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IAccuracy {
|
||||
|
||||
float minAccuracy(ItemStack itemStack);
|
||||
|
||||
float maxAccuracy(ItemStack itemStack);
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public interface IAmmo {
|
||||
|
||||
/**
|
||||
* Returns the current ammo amount of the item.
|
||||
*/
|
||||
@@ -16,12 +17,14 @@ public interface IAmmo {
|
||||
|
||||
/**
|
||||
* Returns the maximum amount of ammo the item can have
|
||||
*
|
||||
* @param tags InfiTool tag compound of the item
|
||||
*/
|
||||
int getMaxAmmo(NBTTagCompound tags);
|
||||
|
||||
/**
|
||||
* Adds the given amount of ammo cache. Will not go over max-ammo.
|
||||
*
|
||||
* @param count How much to add
|
||||
* @param stack The itemstack to add the ammo to. Has to have the proper NBT.
|
||||
* @return The amount of ammo that couldn't be added.
|
||||
@@ -30,6 +33,7 @@ public interface IAmmo {
|
||||
|
||||
/**
|
||||
* Removes the given amount fro the ammo cache. Will not go below zero.
|
||||
*
|
||||
* @param count How much to remove
|
||||
* @param stack The itemstack to add the ammo to. Has to have the proper NBT.
|
||||
* @return The amount of ammo that couldn't be removed. If you try to remove 5, but only 3 are left, it'll return 2.
|
||||
@@ -38,6 +42,7 @@ public interface IAmmo {
|
||||
|
||||
/**
|
||||
* Sets the Ammo amount to that absolute value. Behaviour for values below 0 or above the max ammo is undefined.
|
||||
*
|
||||
* @param count How much
|
||||
* @param stack The itemstack to set the ammo for. Has to have proper NBT.
|
||||
*/
|
||||
|
||||
@@ -2,13 +2,15 @@ package tconstruct.library.weaponry;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import tconstruct.weaponry.client.CrosshairType;
|
||||
|
||||
/**
|
||||
* This class has a windup time, meaning it takes some time to reach full potency.
|
||||
* Windup progress is visualized with a special crosshair.
|
||||
* This class has a windup time, meaning it takes some time to reach full potency. Windup progress is visualized with a
|
||||
* special crosshair.
|
||||
*/
|
||||
public interface IWindup {
|
||||
|
||||
int getWindupTime(ItemStack itemStack); // how long it takes to fully wind up
|
||||
|
||||
float getWindupProgress(ItemStack itemStack, EntityPlayer player); // how far we've winded up, 0.0-1.0
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package tconstruct.library.weaponry;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mods.battlegear2.api.PlayerEventChild;
|
||||
import mods.battlegear2.api.weapons.IBattlegearWeapon;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -21,6 +20,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.ArrowLooseEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
|
||||
import tconstruct.client.TProxyClient;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
@@ -29,15 +29,17 @@ import tconstruct.library.util.TextureHelper;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import tconstruct.weaponry.client.CrosshairType;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon")
|
||||
})
|
||||
@Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon") })
|
||||
/**
|
||||
* Weapons that utilize ammo that uses the ammo system to shoot projectiles.
|
||||
* Bows,...
|
||||
* Weapons that utilize ammo that uses the ammo system to shoot projectiles. Bows,...
|
||||
*/
|
||||
public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWeapon, IAccuracy, IWindup {
|
||||
|
||||
public ProjectileWeapon(int baseDamage, String name) {
|
||||
super(baseDamage);
|
||||
|
||||
@@ -61,6 +63,7 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
|
||||
/**
|
||||
* Searches the player for ammo to use
|
||||
*
|
||||
* @param player the player
|
||||
* @return the itemstack found to be ammo
|
||||
*/
|
||||
@@ -68,15 +71,16 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
|
||||
/**
|
||||
* Creates the projectile to be fired.
|
||||
* @param ammo The ammo used
|
||||
* @param world world.
|
||||
* @param player player.
|
||||
* @param speed the speed calculated for the projectile
|
||||
*
|
||||
* @param ammo The ammo used
|
||||
* @param world world.
|
||||
* @param player player.
|
||||
* @param speed the speed calculated for the projectile
|
||||
* @param accuracy the accuracy calculated for the projectile
|
||||
* @return A banana.
|
||||
*/
|
||||
protected abstract Entity createProjectile(
|
||||
ItemStack ammo, World world, EntityPlayer player, float speed, float accuracy, float windup);
|
||||
protected abstract Entity createProjectile(ItemStack ammo, World world, EntityPlayer player, float speed,
|
||||
float accuracy, float windup);
|
||||
|
||||
/* Accuracy */
|
||||
public abstract float minAccuracy(ItemStack itemStack);
|
||||
@@ -143,9 +147,9 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
if (getWindupTime(stack) == 0.0f) return stack;
|
||||
|
||||
// broken tool?
|
||||
if (stack.hasTagCompound()
|
||||
&& stack.getTagCompound().hasKey(getBaseTagName())
|
||||
&& stack.getTagCompound().getCompoundTag(getBaseTagName()).getBoolean("Broken")) return stack;
|
||||
if (stack.hasTagCompound() && stack.getTagCompound().hasKey(getBaseTagName())
|
||||
&& stack.getTagCompound().getCompoundTag(getBaseTagName()).getBoolean("Broken"))
|
||||
return stack;
|
||||
|
||||
// only if ammo is present
|
||||
if (searchForAmmo(player, stack) != null) player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
||||
@@ -204,8 +208,8 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
if (!world.isRemote) world.spawnEntityInWorld(projectile);
|
||||
}
|
||||
|
||||
public abstract void playFiringSound(
|
||||
World world, EntityPlayer player, ItemStack weapon, ItemStack ammo, float speed, float accuracy);
|
||||
public abstract void playFiringSound(World world, EntityPlayer player, ItemStack weapon, ItemStack ammo,
|
||||
float speed, float accuracy);
|
||||
|
||||
public HashMap<Integer, IIcon[]> animationHeadIcons = new HashMap<>();
|
||||
public HashMap<Integer, IIcon[]> animationHandleIcons = new HashMap<>();
|
||||
@@ -214,11 +218,7 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
public HashMap<Integer, IIcon[]> animationEffectIcons = new HashMap<>();
|
||||
|
||||
/**
|
||||
* return true if the current renderpass should use animations.
|
||||
* 0 == handle
|
||||
* 1 == head
|
||||
* 2 == accessory
|
||||
* 3 == extra
|
||||
* return true if the current renderpass should use animations. 0 == handle 1 == head 2 == accessory 3 == extra
|
||||
*/
|
||||
protected boolean animateLayer(int renderPass) {
|
||||
return false;
|
||||
@@ -238,11 +238,10 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
String effect = "Effect" + (1 + renderPass - getPartAmount());
|
||||
if (tags.hasKey(effect)) {
|
||||
int index = tags.getInteger(effect);
|
||||
if (animationEffectIcons.get(index) != null)
|
||||
return getCorrectAnimationIcon(
|
||||
animationEffectIcons,
|
||||
index,
|
||||
getWindupProgress(usingItem, getMaxItemUseDuration(usingItem) - useRemaining));
|
||||
if (animationEffectIcons.get(index) != null) return getCorrectAnimationIcon(
|
||||
animationEffectIcons,
|
||||
index,
|
||||
getWindupProgress(usingItem, getMaxItemUseDuration(usingItem) - useRemaining));
|
||||
else
|
||||
// non-animated
|
||||
return effectIcons.get(index);
|
||||
@@ -354,11 +353,8 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
animationEffectIcons.put(-1, anims);
|
||||
}
|
||||
|
||||
private void addAnimationIcons(
|
||||
HashMap<Integer, String> textures,
|
||||
HashMap<Integer, IIcon[]> icons,
|
||||
IIconRegister iconRegister,
|
||||
String standard) {
|
||||
private void addAnimationIcons(HashMap<Integer, String> textures, HashMap<Integer, IIcon[]> icons,
|
||||
IIconRegister iconRegister, String standard) {
|
||||
icons.clear();
|
||||
|
||||
// we use the standard to determine how many animations there are
|
||||
@@ -428,12 +424,7 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
if (currentAmmo.getItem() == TinkerWeaponry.arrowAmmo || currentAmmo.getItem() == TinkerWeaponry.boltAmmo)
|
||||
damage = Math.max(
|
||||
0,
|
||||
damage
|
||||
- currentAmmo
|
||||
.getTagCompound()
|
||||
.getCompoundTag("InfiTool")
|
||||
.getInteger("Attack")
|
||||
/ 2f);
|
||||
damage - currentAmmo.getTagCompound().getCompoundTag("InfiTool").getInteger("Attack") / 2f);
|
||||
|
||||
damage *= ((AmmoItem) currentAmmo.getItem()).getDamageModifier();
|
||||
|
||||
@@ -447,8 +438,9 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
|
||||
list.remove(list.size() - 1); // remove last item (the damage of the bow itself)
|
||||
list.add(currentAmmo.getDisplayName());
|
||||
list.add(StatCollector.translateToLocal("attribute.name.ammo.maxAttackDamage") + ": "
|
||||
+ TProxyClient.df.format(damage));
|
||||
list.add(
|
||||
StatCollector.translateToLocal("attribute.name.ammo.maxAttackDamage") + ": "
|
||||
+ TProxyClient.df.format(damage));
|
||||
}
|
||||
|
||||
/*---- Battlegear Support START ----*/
|
||||
@@ -467,8 +459,8 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean offhandAttackEntity(
|
||||
PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
|
||||
public boolean offhandAttackEntity(PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem,
|
||||
ItemStack offhandItem) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -494,9 +486,8 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean allowOffhand(ItemStack mainhand, ItemStack offhand) {
|
||||
if (offhand == null) return true;
|
||||
return (mainhand != null
|
||||
&& mainhand.getItem() != TinkerTools.cleaver
|
||||
&& mainhand.getItem() != TinkerTools.battleaxe)
|
||||
return (mainhand != null && mainhand.getItem() != TinkerTools.cleaver
|
||||
&& mainhand.getItem() != TinkerTools.battleaxe)
|
||||
&& (offhand.getItem() != TinkerTools.cleaver && offhand.getItem() != TinkerTools.battleaxe);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user