mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 11:59:14 +00:00
Fix JABBA-related issues with crafting station slots (#54)
* Fix shift-merging tools voiding items fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/11392> * Change 0-sized ItemStacks into null stacks in crafting station attached slots Fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/10425> * Update buildscript * spotlessApply
This commit is contained in:
1 parent
18bfeaff32
commit
39be06c23b
571 files changed
+25959
-28223
No files matched your search
@@ -5,9 +5,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
import tconstruct.library.crafting.PatternBuilder;
|
||||
import tconstruct.library.tools.DualMaterialToolPart;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import tconstruct.library.util.IToolPart;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.util.Reference;
|
||||
@@ -15,7 +13,8 @@ import tconstruct.util.Reference;
|
||||
public class AlternateBoltRecipe implements IRecipe {
|
||||
static {
|
||||
// register the recipe with the recipesorter
|
||||
RecipeSorter.register(Reference.MOD_ID + ":part", AlternateBoltRecipe.class, RecipeSorter.Category.SHAPELESS, "");
|
||||
RecipeSorter.register(
|
||||
Reference.MOD_ID + ":part", AlternateBoltRecipe.class, RecipeSorter.Category.SHAPELESS, "");
|
||||
}
|
||||
|
||||
private ItemStack outputPart;
|
||||
@@ -26,40 +25,33 @@ public class AlternateBoltRecipe implements IRecipe {
|
||||
ItemStack rod = null;
|
||||
ItemStack head = null;
|
||||
|
||||
for(int i = 0; i < inventoryCrafting.getSizeInventory(); i++)
|
||||
{
|
||||
for (int i = 0; i < inventoryCrafting.getSizeInventory(); i++) {
|
||||
ItemStack slot = inventoryCrafting.getStackInSlot(i);
|
||||
// empty slot
|
||||
if(slot == null)
|
||||
continue;
|
||||
if (slot == null) continue;
|
||||
|
||||
// is it the tool?
|
||||
if(slot.getItem() == TinkerWeaponry.arrowhead) {
|
||||
if (slot.getItem() == TinkerWeaponry.arrowhead) {
|
||||
// only one arrowhead
|
||||
if(head != null)
|
||||
return false;
|
||||
if (head != null) return false;
|
||||
|
||||
head = slot;
|
||||
}
|
||||
else if(slot.getItem() == TinkerTools.toolRod) {
|
||||
} else if (slot.getItem() == TinkerTools.toolRod) {
|
||||
// only one rod
|
||||
if(rod != null)
|
||||
return false;
|
||||
if (rod != null) return false;
|
||||
|
||||
rod = slot;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// unknown object
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(rod == null || head == null)
|
||||
return false;
|
||||
if (rod == null || head == null) return false;
|
||||
|
||||
// craft the bolt
|
||||
int mat1 = ((IToolPart)rod.getItem()).getMaterialID(rod);
|
||||
int mat2 = ((IToolPart)head.getItem()).getMaterialID(head);
|
||||
int mat1 = ((IToolPart) rod.getItem()).getMaterialID(rod);
|
||||
int mat2 = ((IToolPart) head.getItem()).getMaterialID(head);
|
||||
|
||||
outputPart = DualMaterialToolPart.createDualMaterial(TinkerWeaponry.partBolt, mat1, mat2);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package tconstruct.weaponry;
|
||||
|
||||
import static tconstruct.tools.TinkerTools.MaterialID;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
@@ -7,6 +8,8 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import mantle.pulsar.pulse.Handler;
|
||||
import mantle.pulsar.pulse.Pulse;
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
@@ -15,25 +18,28 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.crafting.*;
|
||||
import tconstruct.library.entity.ProjectileBase;
|
||||
import tconstruct.library.tools.DualMaterialToolPart;
|
||||
import tconstruct.library.tools.DynamicToolPart;
|
||||
import tconstruct.library.tools.FletchlingLeafMaterial;
|
||||
import tconstruct.library.util.BehaviorProjectileBaseDispense;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import tconstruct.library.util.IToolPart;
|
||||
import tconstruct.library.weaponry.AmmoItem;
|
||||
import tconstruct.library.weaponry.AmmoWeapon;
|
||||
import tconstruct.library.weaponry.ArrowShaftMaterial;
|
||||
import tconstruct.library.weaponry.ProjectileWeapon;
|
||||
import tconstruct.modifiers.tools.ModAmmoRestock;
|
||||
import tconstruct.modifiers.tools.ModAttack;
|
||||
import tconstruct.modifiers.tools.ModWindup;
|
||||
import tconstruct.modifiers.tools.ModAmmoRestock;
|
||||
import tconstruct.smeltery.TinkerSmeltery;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.tools.items.Bowstring;
|
||||
@@ -42,28 +48,23 @@ import tconstruct.tools.items.Pattern;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
import tconstruct.weaponry.ammo.ArrowAmmo;
|
||||
import tconstruct.weaponry.ammo.BoltAmmo;
|
||||
import tconstruct.library.tools.DualMaterialToolPart;
|
||||
import tconstruct.weaponry.entity.*;
|
||||
import tconstruct.weaponry.items.Boneana;
|
||||
import tconstruct.weaponry.items.GlassArrows;
|
||||
import tconstruct.weaponry.items.WeaponryPattern;
|
||||
import tconstruct.weaponry.items.WeaponryPatternClay;
|
||||
import tconstruct.library.weaponry.AmmoItem;
|
||||
import tconstruct.library.weaponry.AmmoWeapon;
|
||||
import tconstruct.library.weaponry.ArrowShaftMaterial;
|
||||
import tconstruct.library.weaponry.ProjectileWeapon;
|
||||
import tconstruct.weaponry.weapons.*;
|
||||
import tconstruct.world.TinkerWorld;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import static tconstruct.tools.TinkerTools.MaterialID;
|
||||
|
||||
@GameRegistry.ObjectHolder(TConstruct.modID)
|
||||
@Pulse(id = "Tinkers' Weaponry", description = "The main core of the mod! All of the tools, the tables, and the patterns are here.", pulsesRequired="Tinkers' Tools")
|
||||
@Pulse(
|
||||
id = "Tinkers' Weaponry",
|
||||
description = "The main core of the mod! All of the tools, the tables, and the patterns are here.",
|
||||
pulsesRequired = "Tinkers' Tools")
|
||||
public class TinkerWeaponry {
|
||||
@SidedProxy(clientSide = "tconstruct.weaponry.WeaponryClientProxy", serverSide = "tconstruct.weaponry.WeaponryCommonProxy")
|
||||
@SidedProxy(
|
||||
clientSide = "tconstruct.weaponry.WeaponryClientProxy",
|
||||
serverSide = "tconstruct.weaponry.WeaponryCommonProxy")
|
||||
public static WeaponryCommonProxy proxy;
|
||||
|
||||
// Throwing Weapons
|
||||
@@ -96,7 +97,6 @@ public class TinkerWeaponry {
|
||||
public static Pattern metalPattern;
|
||||
public static Pattern clayPattern;
|
||||
|
||||
|
||||
// legendary weapons?
|
||||
public static GlassArrows glassArrows;
|
||||
public static Boneana boneana;
|
||||
@@ -105,20 +105,17 @@ public class TinkerWeaponry {
|
||||
public static ModAttack modAttack;
|
||||
public static Random random = new Random();
|
||||
|
||||
|
||||
public static Item[] patternOutputs;
|
||||
|
||||
@Handler
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
registerItems();
|
||||
registerLegendaries();
|
||||
registerMaterials();
|
||||
}
|
||||
|
||||
@Handler
|
||||
public void init(FMLInitializationEvent event)
|
||||
{
|
||||
public void init(FMLInitializationEvent event) {
|
||||
addPartRecipies();
|
||||
addWeaponRecipies();
|
||||
setupCreativeTab();
|
||||
@@ -126,10 +123,16 @@ public class TinkerWeaponry {
|
||||
// Modifiers
|
||||
ItemStack redstoneItem = new ItemStack(Items.redstone);
|
||||
ItemStack redstoneBlock = new ItemStack(Blocks.redstone_block);
|
||||
ModifyBuilder.registerModifier(new ModWindup(2, new ItemStack[] { redstoneItem, redstoneBlock }, new int[] { 1, 9 }));
|
||||
ModifyBuilder.registerModifier(
|
||||
new ModWindup(2, new ItemStack[] {redstoneItem, redstoneBlock}, new int[] {1, 9}));
|
||||
ModifyBuilder.registerModifier(new ModAmmoRestock());
|
||||
|
||||
modAttack = new ModAttack("Quartz", 11, new ItemStack[] { new ItemStack(Items.quartz), new ItemStack(Blocks.quartz_block, 1, Short.MAX_VALUE) }, new int[] { 1, 4 }, true);
|
||||
modAttack = new ModAttack(
|
||||
"Quartz",
|
||||
11,
|
||||
new ItemStack[] {new ItemStack(Items.quartz), new ItemStack(Blocks.quartz_block, 1, Short.MAX_VALUE)},
|
||||
new int[] {1, 4},
|
||||
true);
|
||||
ModifyBuilder.registerModifier(modAttack);
|
||||
|
||||
TConstructRegistry.registerActiveToolMod(new WeaponryActiveToolMod());
|
||||
@@ -138,35 +141,30 @@ public class TinkerWeaponry {
|
||||
}
|
||||
|
||||
@Handler
|
||||
public void postInit(FMLPostInitializationEvent event)
|
||||
{
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
// this handler takes care that ammo weapons get ammo.
|
||||
WeaponryHandler weaponryHandler = new WeaponryHandler();
|
||||
MinecraftForge.EVENT_BUS.register(weaponryHandler);
|
||||
FMLCommonHandler.instance().bus().register(weaponryHandler);
|
||||
|
||||
|
||||
// "vanilla" bolt:
|
||||
// iron-tipped wood-shaft with feather fletching
|
||||
ItemStack headStack = DualMaterialToolPart.createDualMaterial(boltAmmo.getHeadItem(), TinkerTools.MaterialID.Wood, TinkerTools.MaterialID.Iron);
|
||||
ItemStack headStack = DualMaterialToolPart.createDualMaterial(
|
||||
boltAmmo.getHeadItem(), TinkerTools.MaterialID.Wood, TinkerTools.MaterialID.Iron);
|
||||
ItemStack handleStack = new ItemStack(boltAmmo.getAccessoryItem(), 1, 0); // feather fletchling
|
||||
|
||||
ItemStack tool = ToolBuilder.instance.buildTool(headStack, handleStack, null, null, "");
|
||||
if (tool != null)
|
||||
{
|
||||
if (tool != null) {
|
||||
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
|
||||
creativeBolt = tool;
|
||||
}
|
||||
else
|
||||
TConstruct.logger.error("Couldn't build basic Tinker Bolt for creative crossbow shootnig");
|
||||
} else TConstruct.logger.error("Couldn't build basic Tinker Bolt for creative crossbow shootnig");
|
||||
|
||||
proxy.init();
|
||||
|
||||
registerBoltCasting();
|
||||
}
|
||||
|
||||
private void registerItems()
|
||||
{
|
||||
private void registerItems() {
|
||||
// create tool part
|
||||
TinkerTools.bowstring = bowstring = new Bowstring().setUnlocalizedName("tconstruct.Bowstring");
|
||||
TinkerTools.arrowhead = arrowhead = new DynamicToolPart("_arrowhead", "ArrowHead");
|
||||
@@ -194,7 +192,6 @@ public class TinkerWeaponry {
|
||||
metalPattern = new WeaponryPattern("cast_", "MetalPattern");
|
||||
clayPattern = new WeaponryPatternClay("clay_cast_", "ClayPattern");
|
||||
|
||||
|
||||
// register tool parts
|
||||
GameRegistry.registerItem(bowstring, "bowstring"); // 1.8 todo: rename properly?
|
||||
GameRegistry.registerItem(arrowhead, "arrowhead");
|
||||
@@ -219,11 +216,9 @@ public class TinkerWeaponry {
|
||||
GameRegistry.registerItem(woodPattern, "Pattern");
|
||||
GameRegistry.registerItem(metalPattern, "Cast");
|
||||
GameRegistry.registerItem(clayPattern, "Clay Cast");
|
||||
|
||||
}
|
||||
|
||||
private void addPartRecipies()
|
||||
{
|
||||
private void addPartRecipies() {
|
||||
StencilBuilder.registerStencil(21, TinkerTools.woodPattern, 25); // arrow head
|
||||
StencilBuilder.registerStencil(22, TinkerTools.woodPattern, 24); // fletchling
|
||||
StencilBuilder.registerStencil(23, TinkerTools.woodPattern, 23); // bowstring
|
||||
@@ -236,38 +231,47 @@ public class TinkerWeaponry {
|
||||
PatternBuilder.instance.addToolPattern(woodPattern);
|
||||
|
||||
// todo: integrate into tcon
|
||||
int[] nonMetals = { 0, 1, 3, 4, 5, 6, 7, 8, 9, 17 };
|
||||
int[] liquidDamage = new int[] { 2, 13, 10, 11, 12, 14, 15, 6, 16, 18 };
|
||||
patternOutputs = new Item[] { partShuriken, partCrossbowLimb, partCrossbowBody, partBowLimb };
|
||||
|
||||
int[] nonMetals = {0, 1, 3, 4, 5, 6, 7, 8, 9, 17};
|
||||
int[] liquidDamage = new int[] {2, 13, 10, 11, 12, 14, 15, 6, 16, 18};
|
||||
patternOutputs = new Item[] {partShuriken, partCrossbowLimb, partCrossbowBody, partBowLimb};
|
||||
|
||||
// register part crafting
|
||||
if (PHConstruct.craftMetalTools)
|
||||
{
|
||||
if (PHConstruct.craftMetalTools) {
|
||||
for (int m = 0; m < patternOutputs.length; m++)
|
||||
for (int i = 0; i < 18; i++)
|
||||
TConstructRegistry.addPartMapping(woodPattern, m, i, new ItemStack(patternOutputs[m], 1, i));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
for (int m = 0; m < patternOutputs.length; m++)
|
||||
for (int nonMetal : nonMetals)
|
||||
TConstructRegistry.addPartMapping(woodPattern, m, nonMetal, new ItemStack(patternOutputs[m], 1, nonMetal));
|
||||
TConstructRegistry.addPartMapping(
|
||||
woodPattern, m, nonMetal, new ItemStack(patternOutputs[m], 1, nonMetal));
|
||||
}
|
||||
|
||||
// arrowhead is still integrated in tinkertools.. bla n stuff
|
||||
for (int nonMetal : nonMetals)
|
||||
TConstructRegistry.addPartMapping(TinkerTools.woodPattern, 25, nonMetal, new ItemStack(arrowhead, 1, nonMetal));
|
||||
TConstructRegistry.addPartMapping(
|
||||
TinkerTools.woodPattern, 25, nonMetal, new ItemStack(arrowhead, 1, nonMetal));
|
||||
|
||||
// register part casting
|
||||
if(TConstruct.pulsar.isPulseLoaded("Tinkers' Smeltery")) {
|
||||
if (TConstruct.pulsar.isPulseLoaded("Tinkers' Smeltery")) {
|
||||
LiquidCasting tableCasting = TConstructRegistry.getTableCasting();
|
||||
for (int i = 0; i < patternOutputs.length; i++) {
|
||||
ItemStack cast = new ItemStack(metalPattern, 1, i);
|
||||
ItemStack clay_cast = new ItemStack(clayPattern, 1, i);
|
||||
|
||||
tableCasting.addCastingRecipe(cast, new FluidStack(TinkerSmeltery.moltenAlubrassFluid, TConstruct.ingotLiquidValue), new ItemStack(patternOutputs[i], 1, Short.MAX_VALUE), false, 50);
|
||||
if (!PHConstruct.removeGoldCastRecipes)
|
||||
tableCasting.addCastingRecipe(cast, new FluidStack(TinkerSmeltery.moltenGoldFluid, TConstruct.ingotLiquidValue * 2), new ItemStack(patternOutputs[i], 1, Short.MAX_VALUE), false, 50);
|
||||
|
||||
tableCasting.addCastingRecipe(
|
||||
cast,
|
||||
new FluidStack(TinkerSmeltery.moltenAlubrassFluid, TConstruct.ingotLiquidValue),
|
||||
new ItemStack(patternOutputs[i], 1, Short.MAX_VALUE),
|
||||
false,
|
||||
50);
|
||||
if (!PHConstruct.removeGoldCastRecipes)
|
||||
tableCasting.addCastingRecipe(
|
||||
cast,
|
||||
new FluidStack(TinkerSmeltery.moltenGoldFluid, TConstruct.ingotLiquidValue * 2),
|
||||
new ItemStack(patternOutputs[i], 1, Short.MAX_VALUE),
|
||||
false,
|
||||
50);
|
||||
|
||||
for (int iterTwo = 0; iterTwo < TinkerSmeltery.liquids.length; iterTwo++) {
|
||||
Fluid fs = TinkerSmeltery.liquids[iterTwo].getFluid();
|
||||
@@ -281,14 +285,25 @@ public class TinkerWeaponry {
|
||||
|
||||
ItemStack cast = new ItemStack(TinkerSmeltery.metalPattern, 1, 25);
|
||||
ItemStack clay_cast = new ItemStack(TinkerSmeltery.clayPattern, 1, 25);
|
||||
|
||||
tableCasting.addCastingRecipe(cast, new FluidStack(TinkerSmeltery.moltenAlubrassFluid, TConstruct.ingotLiquidValue), new ItemStack(arrowhead, 1, Short.MAX_VALUE), false, 50);
|
||||
|
||||
tableCasting.addCastingRecipe(
|
||||
cast,
|
||||
new FluidStack(TinkerSmeltery.moltenAlubrassFluid, TConstruct.ingotLiquidValue),
|
||||
new ItemStack(arrowhead, 1, Short.MAX_VALUE),
|
||||
false,
|
||||
50);
|
||||
if (!PHConstruct.removeGoldCastRecipes)
|
||||
tableCasting.addCastingRecipe(cast, new FluidStack(TinkerSmeltery.moltenGoldFluid, TConstruct.ingotLiquidValue * 2), new ItemStack(arrowhead, 1, Short.MAX_VALUE), false, 50);
|
||||
tableCasting.addCastingRecipe(
|
||||
cast,
|
||||
new FluidStack(TinkerSmeltery.moltenGoldFluid, TConstruct.ingotLiquidValue * 2),
|
||||
new ItemStack(arrowhead, 1, Short.MAX_VALUE),
|
||||
false,
|
||||
50);
|
||||
|
||||
for (int iterTwo = 0; iterTwo < TinkerSmeltery.liquids.length; iterTwo++) {
|
||||
Fluid fs = TinkerSmeltery.liquids[iterTwo].getFluid();
|
||||
int fluidAmount = ((IPattern) TinkerSmeltery.metalPattern).getPatternCost(cast) * TConstruct.ingotLiquidValue / 2;
|
||||
int fluidAmount =
|
||||
((IPattern) TinkerSmeltery.metalPattern).getPatternCost(cast) * TConstruct.ingotLiquidValue / 2;
|
||||
ItemStack metalCast = new ItemStack(arrowhead, 1, liquidDamage[iterTwo]);
|
||||
tableCasting.addCastingRecipe(metalCast, new FluidStack(fs, fluidAmount), cast, 50);
|
||||
tableCasting.addCastingRecipe(metalCast, new FluidStack(fs, fluidAmount), clay_cast, true, 50);
|
||||
@@ -297,11 +312,9 @@ public class TinkerWeaponry {
|
||||
|
||||
// Stone parts
|
||||
FluidType stone = FluidType.getFluidType("Stone");
|
||||
for (int sc = 0; sc < patternOutputs.length; sc++)
|
||||
{
|
||||
if (patternOutputs[sc] != null)
|
||||
{
|
||||
ItemStack item = new ItemStack(patternOutputs[sc], 1, 1);
|
||||
for (int sc = 0; sc < patternOutputs.length; sc++) {
|
||||
if (patternOutputs[sc] != null) {
|
||||
ItemStack item = new ItemStack(patternOutputs[sc], 1, 1);
|
||||
int amount = (8 * woodPattern.getPatternCost(new ItemStack(woodPattern, 1, sc))) / 2;
|
||||
Smeltery.addMelting(stone, item, 1, amount);
|
||||
}
|
||||
@@ -309,8 +322,7 @@ public class TinkerWeaponry {
|
||||
}
|
||||
}
|
||||
|
||||
private void registerLegendaries()
|
||||
{
|
||||
private void registerLegendaries() {
|
||||
glassArrows = new GlassArrows();
|
||||
boneana = new Boneana();
|
||||
|
||||
@@ -318,125 +330,180 @@ public class TinkerWeaponry {
|
||||
GameRegistry.registerItem(boneana, "Boneana");
|
||||
}
|
||||
|
||||
private void registerMaterials()
|
||||
{
|
||||
private void registerMaterials() {
|
||||
// Bow Materials: Material ID, durability, drawspeed, arrow speed
|
||||
// speed 3.0 == exactly the vanilla bow if 2 parts of speed 3 are used
|
||||
// Wooden stuff is flexible, therefore good. Reference.
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Wood, 18, 3.0f); // Wood
|
||||
// other organic materials also are good
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Cactus, 20, 3.4f); // Cactus
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Bone, 38, 3.0f); // Bone
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Slime, 28, 4.2f); // Slime
|
||||
TConstructRegistry.addBowMaterial(MaterialID.BlueSlime, 21, 4.0f); // Blue Slime
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Paper, 10, 1.1f); // Paper
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Cactus, 20, 3.4f); // Cactus
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Bone, 38, 3.0f); // Bone
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Slime, 28, 4.2f); // Slime
|
||||
TConstructRegistry.addBowMaterial(MaterialID.BlueSlime, 21, 4.0f); // Blue Slime
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Paper, 10, 1.1f); // Paper
|
||||
// Metal stuff has a lot of POW, but takes LONG to wind up since it's so hard
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Iron, 54, 5.2f); // Iron
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Steel, 60, 5.5f); // Steel
|
||||
TConstructRegistry.addBowMaterial(MaterialID.PigIron, 42, 5.2f); // Pig Iron - it's meat!
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Ardite, 55, 4.9f); // Ardite
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Cobalt, 45, 5.3f); // Cobalt
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Manyullyn, 50, 5.0f); // Manyullyn
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Copper, 40, 4.9f); // Copper
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Bronze, 45, 5.1f); // Bronze
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Alumite, 45, 5.0f); // Alumite - a bit stone-ish since it has obsidian
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Iron, 54, 5.2f); // Iron
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Steel, 60, 5.5f); // Steel
|
||||
TConstructRegistry.addBowMaterial(MaterialID.PigIron, 42, 5.2f); // Pig Iron - it's meat!
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Ardite, 55, 4.9f); // Ardite
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Cobalt, 45, 5.3f); // Cobalt
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Manyullyn, 50, 5.0f); // Manyullyn
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Copper, 40, 4.9f); // Copper
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Bronze, 45, 5.1f); // Bronze
|
||||
TConstructRegistry.addBowMaterial(
|
||||
MaterialID.Alumite, 45, 5.0f); // Alumite - a bit stone-ish since it has obsidian
|
||||
// Stone doesn't bend. takes forever, has no pow. WHY WOULD YOU DO THAT
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Stone, 90, 1.0f); // Stone
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Flint, 90, 1.0f); // Flint
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Obsidian, 109, 1.0f); // Obsidian
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Stone, 90, 1.0f); // Stone
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Flint, 90, 1.0f); // Flint
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Obsidian, 109, 1.0f); // Obsidian
|
||||
TConstructRegistry.addBowMaterial(MaterialID.Netherrack, 80, 1.0f); // Netherrack
|
||||
|
||||
// Arrow Head Materials: Material ID, mass, fragility
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Wood, 0.69F, 0.5F); //Wood
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Stone, 2.05F, 1.0F); //Stone
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Iron, 3.3F, 0.8F); //Iron
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Flint, 1.325F, 1.0F); //Flint
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Cactus, 0.76F, 1.0F); //Cactus
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Bone, 1.69F, 1.0F); //Bone
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Obsidian, 2.4F, 1.0F); //Obsidian
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Netherrack, 1.5F, 1.3F); //Netherrack
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Slime, 0.22F, 0.0F); //Slime
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Paper, 0.69F, 10.0F); //Paper
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Cobalt, 3.0F, 2.0f); //Cobalt
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Ardite, 1.25F, 2.0f); //Ardite
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Manyullyn, 2.25F, 1.0F); //Manyullyn
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Copper, 2.7F, 1.1F); //Copper
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Bronze, 3.2F, 1.2f); //Bronze
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Alumite, 1.1F, 0.7f); //Alumite
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Steel, 3.6F, 0.9f); //Steel
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.BlueSlime, 0.22F, 0.0F); //Blue Slime
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.PigIron, 3.0F, 0.5F); //Pigiron
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Wood, 0.69F, 0.5F); // Wood
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Stone, 2.05F, 1.0F); // Stone
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Iron, 3.3F, 0.8F); // Iron
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Flint, 1.325F, 1.0F); // Flint
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Cactus, 0.76F, 1.0F); // Cactus
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Bone, 1.69F, 1.0F); // Bone
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Obsidian, 2.4F, 1.0F); // Obsidian
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Netherrack, 1.5F, 1.3F); // Netherrack
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Slime, 0.22F, 0.0F); // Slime
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Paper, 0.69F, 10.0F); // Paper
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Cobalt, 3.0F, 2.0f); // Cobalt
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Ardite, 1.25F, 2.0f); // Ardite
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Manyullyn, 2.25F, 1.0F); // Manyullyn
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Copper, 2.7F, 1.1F); // Copper
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Bronze, 3.2F, 1.2f); // Bronze
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Alumite, 1.1F, 0.7f); // Alumite
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.Steel, 3.6F, 0.9f); // Steel
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.BlueSlime, 0.22F, 0.0F); // Blue Slime
|
||||
TConstructRegistry.addArrowMaterial(MaterialID.PigIron, 3.0F, 0.5F); // Pigiron
|
||||
|
||||
// Arrow Shaft Materials: Material ID, crafting item, durability-medifier, mass, fragility
|
||||
TConstructRegistry.addCustomMaterial(ArrowShaftMaterial.createMaterial(0, Items.stick, 1.0f, 1.0f, 0.15f, 0x866526)); // wood: reference material, 10% break chance
|
||||
TConstructRegistry.addCustomMaterial(ArrowShaftMaterial.createMaterial(1, Items.bone, 0.95f, 1.8f, 0.02f, 0xede6bf)); // bone: heavier, but durable
|
||||
TConstructRegistry.addCustomMaterial(ArrowShaftMaterial.createMaterial(2, Items.reeds, 1.5f, 0.5f, 0.66f, 0xc7ff87)); // reed: light, but less durable
|
||||
TConstructRegistry.addCustomMaterial(ArrowShaftMaterial.createMaterial(3, Items.blaze_rod, 1.2f, 0.9f, 0.08f, 0xfff32d)); // blaze: tad lighter, tad more durable, fieryyyy
|
||||
TConstructRegistry.addCustomMaterial(ArrowShaftMaterial.createMaterial(
|
||||
0, Items.stick, 1.0f, 1.0f, 0.15f, 0x866526)); // wood: reference material, 10% break chance
|
||||
TConstructRegistry.addCustomMaterial(ArrowShaftMaterial.createMaterial(
|
||||
1, Items.bone, 0.95f, 1.8f, 0.02f, 0xede6bf)); // bone: heavier, but durable
|
||||
TConstructRegistry.addCustomMaterial(ArrowShaftMaterial.createMaterial(
|
||||
2, Items.reeds, 1.5f, 0.5f, 0.66f, 0xc7ff87)); // reed: light, but less durable
|
||||
TConstructRegistry.addCustomMaterial(ArrowShaftMaterial.createMaterial(
|
||||
3, Items.blaze_rod, 1.2f, 0.9f, 0.08f, 0xfff32d)); // blaze: tad lighter, tad more durable, fieryyyy
|
||||
// also add the tool rod variants, same stats
|
||||
TConstructRegistry.addCustomMaterial(ArrowShaftMaterial.createMaterial(0, TinkerTools.toolRod, MaterialID.Wood, 1.0f, 1.0f, 0.15f, 0x866526)); // wood: reference material, 10% break chance
|
||||
TConstructRegistry.addCustomMaterial(ArrowShaftMaterial.createMaterial(1, TinkerTools.toolRod, MaterialID.Bone, 0.95f, 1.8f, 0.02f, 0xede6bf)); // bone: heavier, but durable
|
||||
TConstructRegistry.addCustomMaterial(ArrowShaftMaterial.createMaterial(
|
||||
0,
|
||||
TinkerTools.toolRod,
|
||||
MaterialID.Wood,
|
||||
1.0f,
|
||||
1.0f,
|
||||
0.15f,
|
||||
0x866526)); // wood: reference material, 10% break chance
|
||||
TConstructRegistry.addCustomMaterial(ArrowShaftMaterial.createMaterial(
|
||||
1, TinkerTools.toolRod, MaterialID.Bone, 0.95f, 1.8f, 0.02f, 0xede6bf)); // bone: heavier, but durable
|
||||
|
||||
// Arrow Fletching Materials
|
||||
TConstructRegistry.addFletchingMaterial(0, 2, new ItemStack(Items.feather), new ItemStack(TinkerWeaponry.fletching, 1, 0), 95F, 0.05F, 1.0f, 0xffffff); // Feather
|
||||
TConstructRegistry.addCustomMaterial(new FletchlingLeafMaterial(1, 2, "treeLeaves", new ItemStack(TinkerWeaponry.fletching, 1, 1), 75F, 0F, 2.5f)); // all vanilla and oredicted leaves. and all leaves in general.
|
||||
TConstructRegistry.addFletchingMaterial(2, 2, new ItemStack(TinkerTools.materials, 1, 1), new ItemStack(TinkerWeaponry.fletching, 1, 2), 100F, 0.005F, 0.8f, 0x82c873); // Slime
|
||||
TConstructRegistry.addFletchingMaterial(3, 2, new ItemStack(TinkerTools.materials, 1, 17), new ItemStack(TinkerWeaponry.fletching, 1, 3), 100F, 0.005F, 0.8f, 0x74c8c7); // BlueSlime
|
||||
TConstructRegistry.addFletchingMaterial(4, 2, new ItemStack(TinkerWorld.slimeLeaves, 1, 0), new ItemStack(TinkerWeaponry.fletching, 1, 4), 98F, 0.02F, 1.4F, 0x74e8c7); // Slime leaves
|
||||
TConstructRegistry.addFletchingMaterial(
|
||||
0,
|
||||
2,
|
||||
new ItemStack(Items.feather),
|
||||
new ItemStack(TinkerWeaponry.fletching, 1, 0),
|
||||
95F,
|
||||
0.05F,
|
||||
1.0f,
|
||||
0xffffff); // Feather
|
||||
TConstructRegistry.addCustomMaterial(new FletchlingLeafMaterial(
|
||||
1,
|
||||
2,
|
||||
"treeLeaves",
|
||||
new ItemStack(TinkerWeaponry.fletching, 1, 1),
|
||||
75F,
|
||||
0F,
|
||||
2.5f)); // all vanilla and oredicted leaves. and all leaves in general.
|
||||
TConstructRegistry.addFletchingMaterial(
|
||||
2,
|
||||
2,
|
||||
new ItemStack(TinkerTools.materials, 1, 1),
|
||||
new ItemStack(TinkerWeaponry.fletching, 1, 2),
|
||||
100F,
|
||||
0.005F,
|
||||
0.8f,
|
||||
0x82c873); // Slime
|
||||
TConstructRegistry.addFletchingMaterial(
|
||||
3,
|
||||
2,
|
||||
new ItemStack(TinkerTools.materials, 1, 17),
|
||||
new ItemStack(TinkerWeaponry.fletching, 1, 3),
|
||||
100F,
|
||||
0.005F,
|
||||
0.8f,
|
||||
0x74c8c7); // BlueSlime
|
||||
TConstructRegistry.addFletchingMaterial(
|
||||
4,
|
||||
2,
|
||||
new ItemStack(TinkerWorld.slimeLeaves, 1, 0),
|
||||
new ItemStack(TinkerWeaponry.fletching, 1, 4),
|
||||
98F,
|
||||
0.02F,
|
||||
1.4F,
|
||||
0x74e8c7); // Slime leaves
|
||||
|
||||
// Bowstring Materials
|
||||
TConstructRegistry.addBowstringMaterial(0, 2, new ItemStack(Items.string), new ItemStack(TinkerWeaponry.bowstring, 1, 0), 1F, 1F, 1f, 0xeeeeee); // String
|
||||
TConstructRegistry.addBowstringMaterial(
|
||||
0,
|
||||
2,
|
||||
new ItemStack(Items.string),
|
||||
new ItemStack(TinkerWeaponry.bowstring, 1, 0),
|
||||
1F,
|
||||
1F,
|
||||
1f,
|
||||
0xeeeeee); // String
|
||||
}
|
||||
|
||||
private void addWeaponRecipies()
|
||||
{
|
||||
private void addWeaponRecipies() {
|
||||
TConstructRegistry.addToolRecipe(shuriken, partShuriken, partShuriken, partShuriken, partShuriken);
|
||||
TConstructRegistry.addToolRecipe(throwingknife, TinkerTools.knifeBlade, TinkerTools.toolRod);
|
||||
TConstructRegistry.addToolRecipe(javelin, arrowhead, TinkerTools.toughRod, TinkerTools.toughRod);
|
||||
|
||||
TConstructRegistry.addToolRecipe(shortbow, partBowLimb, bowstring, partBowLimb);
|
||||
TConstructRegistry.addToolRecipe(longbow, partBowLimb, bowstring, partBowLimb, TinkerTools.largePlate);
|
||||
TConstructRegistry.addToolRecipe(crossbow, partCrossbowLimb, partCrossbowBody, bowstring, TinkerTools.toughBinding);
|
||||
TConstructRegistry.addToolRecipe(
|
||||
crossbow, partCrossbowLimb, partCrossbowBody, bowstring, TinkerTools.toughBinding);
|
||||
|
||||
TConstructRegistry.addToolRecipe(arrowAmmo, arrowhead, partArrowShaft, fletching);
|
||||
TConstructRegistry.addToolRecipe(boltAmmo, partBolt, partBolt, fletching);
|
||||
}
|
||||
|
||||
private void registerBoltCasting()
|
||||
{
|
||||
if(PHConstruct.alternativeBoltRecipe)
|
||||
GameRegistry.addRecipe(new AlternateBoltRecipe());
|
||||
private void registerBoltCasting() {
|
||||
if (PHConstruct.alternativeBoltRecipe) GameRegistry.addRecipe(new AlternateBoltRecipe());
|
||||
|
||||
LiquidCasting tb = TConstructRegistry.getTableCasting();
|
||||
|
||||
// any fluid that is a toolpart material can be used
|
||||
for(Map.Entry<String, FluidType> entry : FluidType.fluidTypes.entrySet()) {
|
||||
for (Map.Entry<String, FluidType> entry : FluidType.fluidTypes.entrySet()) {
|
||||
// is tool material?
|
||||
if(!entry.getValue().isToolpart)
|
||||
continue;
|
||||
if (!entry.getValue().isToolpart) continue;
|
||||
|
||||
// get a casting recipe for it D:
|
||||
FluidStack liquid = new FluidStack(entry.getValue().fluid, TConstruct.ingotLiquidValue);
|
||||
CastingRecipe recipe = tb.getCastingRecipe(liquid, new ItemStack(TinkerSmeltery.metalPattern, 1, 2)); // pickaxe
|
||||
CastingRecipe recipe =
|
||||
tb.getCastingRecipe(liquid, new ItemStack(TinkerSmeltery.metalPattern, 1, 2)); // pickaxe
|
||||
// no recipe found
|
||||
if(recipe == null)
|
||||
continue;
|
||||
if (recipe == null) continue;
|
||||
|
||||
// material id for the pickaxe head == material id for the fluid! such hack. wow.
|
||||
int matID = recipe.getResult().getItemDamage();
|
||||
|
||||
// register our casting stuff
|
||||
for(Integer id : TConstructRegistry.toolMaterials.keySet()) {
|
||||
for (Integer id : TConstructRegistry.toolMaterials.keySet()) {
|
||||
ItemStack rod = new ItemStack(TinkerTools.toolRod, 1, id);
|
||||
if(((IToolPart)TinkerTools.toolRod).getMaterialID(rod) == -1)
|
||||
continue;
|
||||
if (((IToolPart) TinkerTools.toolRod).getMaterialID(rod) == -1) continue;
|
||||
|
||||
tb.addCastingRecipe(DualMaterialToolPart.createDualMaterial(partBolt, id, matID), liquid, rod, true, 150);
|
||||
tb.addCastingRecipe(
|
||||
DualMaterialToolPart.createDualMaterial(partBolt, id, matID), liquid, rod, true, 150);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setupCreativeTab()
|
||||
{
|
||||
private void setupCreativeTab() {
|
||||
ItemStack tool = new ItemStack(TinkerWeaponry.longbow, 1, 0);
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
|
||||
@@ -10,29 +10,23 @@ public class WeaponryActiveToolMod extends ActiveToolMod {
|
||||
@Override
|
||||
public boolean damageTool(ItemStack stack, int damage, EntityLivingBase entity) {
|
||||
// does not proc on tool 'healing'
|
||||
if(stack.getItem() == TinkerWeaponry.javelin && stack.hasTagCompound() && damage > 0) {
|
||||
if (stack.getItem() == TinkerWeaponry.javelin && stack.hasTagCompound() && damage > 0) {
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
IAmmo ammo =(IAmmo)stack.getItem();
|
||||
if(tags.getInteger("Damage") == 0)
|
||||
{
|
||||
IAmmo ammo = (IAmmo) stack.getItem();
|
||||
if (tags.getInteger("Damage") == 0) {
|
||||
int rem = ammo.consumeAmmo(1, stack);
|
||||
if(rem > 0)
|
||||
return true;
|
||||
}
|
||||
else if(ammo.getAmmoCount(stack) > 0)
|
||||
{
|
||||
if (rem > 0) return true;
|
||||
} else if (ammo.getAmmoCount(stack) > 0) {
|
||||
int d = tags.getInteger("Damage") + damage;
|
||||
int max = tags.getInteger("TotalDurability");
|
||||
if(d > max)
|
||||
{
|
||||
if (d > max) {
|
||||
tags.setInteger("Damage", 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// all other ammo items can't be damaged
|
||||
else if(stack.getItem() instanceof IAmmo)
|
||||
return true;
|
||||
else if (stack.getItem() instanceof IAmmo) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
package tconstruct.weaponry;
|
||||
|
||||
import static tconstruct.weaponry.TinkerWeaponry.*;
|
||||
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import mantle.lib.client.MantleClientRegistry;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import tconstruct.client.AmmoItemRenderer;
|
||||
import tconstruct.library.client.TConstructClientRegistry;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import tconstruct.library.entity.ProjectileBase;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.util.Reference;
|
||||
import tconstruct.weaponry.client.AmmoSlotHandler;
|
||||
import tconstruct.weaponry.client.CrosshairHandler;
|
||||
import tconstruct.weaponry.client.RenderEventHandler;
|
||||
@@ -14,17 +24,6 @@ import tconstruct.weaponry.client.entity.ProjectileBaseRenderer;
|
||||
import tconstruct.weaponry.client.entity.ShurikenEntityRenderer;
|
||||
import tconstruct.weaponry.client.item.*;
|
||||
import tconstruct.weaponry.entity.*;
|
||||
import tconstruct.util.Reference;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import tconstruct.library.client.TConstructClientRegistry;
|
||||
import tconstruct.library.crafting.StencilBuilder;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
|
||||
import static tconstruct.weaponry.TinkerWeaponry.*;
|
||||
|
||||
public class WeaponryClientProxy extends WeaponryCommonProxy {
|
||||
public static AmmoItemRenderer renderer;
|
||||
@@ -45,8 +44,7 @@ public class WeaponryClientProxy extends WeaponryCommonProxy {
|
||||
registerManualIcons();
|
||||
}
|
||||
|
||||
private void registerRenderers()
|
||||
{
|
||||
private void registerRenderers() {
|
||||
renderer = new AmmoItemRenderer();
|
||||
MinecraftForgeClient.registerItemRenderer(TinkerWeaponry.shuriken, renderer);
|
||||
MinecraftForgeClient.registerItemRenderer(TinkerWeaponry.throwingknife, new ThrowingKnifeRenderer());
|
||||
@@ -59,11 +57,10 @@ public class WeaponryClientProxy extends WeaponryCommonProxy {
|
||||
MinecraftForgeClient.registerItemRenderer(TinkerWeaponry.arrowAmmo, renderer);
|
||||
MinecraftForgeClient.registerItemRenderer(TinkerWeaponry.boltAmmo, renderer);
|
||||
|
||||
//MinecraftForgeClient.registerItemRenderer(TinkerWeaponry.boneana, );
|
||||
// MinecraftForgeClient.registerItemRenderer(TinkerWeaponry.boneana, );
|
||||
}
|
||||
|
||||
private void registerEntityRendering()
|
||||
{
|
||||
private void registerEntityRendering() {
|
||||
ProjectileBaseRenderer defaultRenderer = new ProjectileBaseRenderer<ProjectileBase>();
|
||||
RenderingRegistry.registerEntityRenderingHandler(ShurikenEntity.class, new ShurikenEntityRenderer());
|
||||
RenderingRegistry.registerEntityRenderingHandler(ThrowingKnifeEntity.class, defaultRenderer);
|
||||
@@ -72,47 +69,44 @@ public class WeaponryClientProxy extends WeaponryCommonProxy {
|
||||
RenderingRegistry.registerEntityRenderingHandler(BoltEntity.class, new ArrowEntityRenderer(0.8f));
|
||||
}
|
||||
|
||||
private void registerMaterialRendering()
|
||||
{
|
||||
private void registerMaterialRendering() {
|
||||
ToolCore arrow = TinkerWeaponry.arrowAmmo;
|
||||
String pre = Reference.resource(arrow.getDefaultFolder()) + "/";
|
||||
|
||||
String[] shaft = {"wood", "bone", "reed", "blaze", null};
|
||||
String[] fletching = { "feather", "leaf", "slime", "blueslime", "slimeleaf" };
|
||||
String[] fletching = {"feather", "leaf", "slime", "blueslime", "slimeleaf"};
|
||||
|
||||
// we register different textures for the different parts per index
|
||||
for(int i = 0; i < 5; i++) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
String handletex = pre + shaft[i] + arrow.getIconSuffix(2);
|
||||
String acctex = pre + fletching[i] + arrow.getIconSuffix(3);
|
||||
arrow.registerAlternatePartPaths(i, new String[]{null, null, handletex, acctex});
|
||||
TinkerWeaponry.boltAmmo.registerAlternatePartPaths(i, new String[]{null, null, null, acctex});
|
||||
arrow.registerAlternatePartPaths(i, new String[] {null, null, handletex, acctex});
|
||||
TinkerWeaponry.boltAmmo.registerAlternatePartPaths(i, new String[] {null, null, null, acctex});
|
||||
}
|
||||
|
||||
// for bolts too
|
||||
pre = Reference.resource(TinkerWeaponry.boltAmmo.getDefaultFolder()) + "/";
|
||||
for(int i = 0; i < 5; i++) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
String acctex = pre + fletching[i] + TinkerWeaponry.boltAmmo.getIconSuffix(3);
|
||||
TinkerWeaponry.boltAmmo.registerAlternatePartPaths(i, new String[]{null, null, null, acctex});
|
||||
TinkerWeaponry.boltAmmo.registerAlternatePartPaths(i, new String[] {null, null, null, acctex});
|
||||
}
|
||||
|
||||
|
||||
// bowstring
|
||||
String[] bowstringTypes = { "string", "magicfabric", "flamestring" };
|
||||
for (int bowIter = 0; bowIter < bowstringTypes.length; bowIter++)
|
||||
{
|
||||
TConstructClientRegistry.addAlternateMaterialRenderMapping(TinkerWeaponry.shortbow, bowIter, Reference.RESOURCE, bowstringTypes[bowIter], true);
|
||||
String[] bowstringTypes = {"string", "magicfabric", "flamestring"};
|
||||
for (int bowIter = 0; bowIter < bowstringTypes.length; bowIter++) {
|
||||
TConstructClientRegistry.addAlternateMaterialRenderMapping(
|
||||
TinkerWeaponry.shortbow, bowIter, Reference.RESOURCE, bowstringTypes[bowIter], true);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttons()
|
||||
{
|
||||
private void buttons() {
|
||||
final String tex = "textures/gui/icons.png";
|
||||
|
||||
// Stencil Table
|
||||
TConstructClientRegistry.addStencilButton2(11, 3, 21, Reference.RESOURCE, tex); // arrow head
|
||||
TConstructClientRegistry.addStencilButton2(12, 3, 22, Reference.RESOURCE, tex); // fletchling
|
||||
TConstructClientRegistry.addStencilButton2(0,0, -1, null, null);
|
||||
TConstructClientRegistry.addStencilButton2(0,0, -1, null, null);
|
||||
TConstructClientRegistry.addStencilButton2(0, 0, -1, null, null);
|
||||
TConstructClientRegistry.addStencilButton2(0, 0, -1, null, null);
|
||||
|
||||
TConstructClientRegistry.addStencilButton2(3, 4, 27, Reference.RESOURCE, tex); // bow limb
|
||||
TConstructClientRegistry.addStencilButton2(10, 3, 23, Reference.RESOURCE, tex); // bowstring
|
||||
@@ -120,59 +114,93 @@ public class WeaponryClientProxy extends WeaponryCommonProxy {
|
||||
TConstructClientRegistry.addStencilButton2(2, 4, 26, Reference.RESOURCE, tex); // crossbow body
|
||||
|
||||
TConstructClientRegistry.addStencilButton2(0, 4, 24, Reference.RESOURCE, tex); // shuriken
|
||||
//TConstructClientRegistry.addStencilButton2(4, 4, index, Reference.RESOURCE, "textures/gui/icons.png"); // bolt
|
||||
|
||||
// TConstructClientRegistry.addStencilButton2(4, 4, index, Reference.RESOURCE, "textures/gui/icons.png"); //
|
||||
// bolt
|
||||
|
||||
// Tool Station
|
||||
ToolCore[] tools = {shortbow, arrowAmmo, throwingknife, javelin};
|
||||
int[][] icons = {
|
||||
new int[] {3, 9, 1}, // shortbow
|
||||
new int[] {7, 10, 1}, // arrow
|
||||
new int[] {2, 1, 5}, // throwingknife
|
||||
new int[] {1, 2, 5} // javelin
|
||||
new int[] {3, 9, 1}, // shortbow
|
||||
new int[] {7, 10, 1}, // arrow
|
||||
new int[] {2, 1, 5}, // throwingknife
|
||||
new int[] {1, 2, 5} // javelin
|
||||
};
|
||||
int[][] coords = {
|
||||
new int[] { 3, 10, 3, 13 }, new int[] { 4, 3, 4, 13 }, // shortbow
|
||||
new int[] { 11, 0, 12, 13 }, new int[] { 3, 3, 3, 13 }, // arrow
|
||||
new int[] { 7, 0, 13, 13 }, new int[] { 2, 3, 13, 13 }, // throwingknife
|
||||
new int[] { 11, 8, 8, 13 }, new int[] { 3, 3, 3, 13 } // javelin
|
||||
new int[] {3, 10, 3, 13}, new int[] {4, 3, 4, 13}, // shortbow
|
||||
new int[] {11, 0, 12, 13}, new int[] {3, 3, 3, 13}, // arrow
|
||||
new int[] {7, 0, 13, 13}, new int[] {2, 3, 13, 13}, // throwingknife
|
||||
new int[] {11, 8, 8, 13}, new int[] {3, 3, 3, 13} // javelin
|
||||
};
|
||||
|
||||
for (int i = 0; i < tools.length; i++)
|
||||
{
|
||||
String locString = String.format("gui.toolstation.%s.desc", tools[i].getToolName().toLowerCase());
|
||||
TConstructClientRegistry.addToolButton(icons[i][0], icons[i][1], icons[i][2], coords[i*2], coords[i*2+1], tools[i].getLocalizedToolName(), locString, Reference.RESOURCE, tex);
|
||||
for (int i = 0; i < tools.length; i++) {
|
||||
String locString = String.format(
|
||||
"gui.toolstation.%s.desc", tools[i].getToolName().toLowerCase());
|
||||
TConstructClientRegistry.addToolButton(
|
||||
icons[i][0],
|
||||
icons[i][1],
|
||||
icons[i][2],
|
||||
coords[i * 2],
|
||||
coords[i * 2 + 1],
|
||||
tools[i].getLocalizedToolName(),
|
||||
locString,
|
||||
Reference.RESOURCE,
|
||||
tex);
|
||||
}
|
||||
|
||||
// Tool Forge
|
||||
tools = new ToolCore[] {longbow, crossbow, boltAmmo, shuriken};
|
||||
icons = new int[][] {
|
||||
new int[] {8, 11, 1}, // longbow
|
||||
new int[] {9, 12, 1}, // crossbow
|
||||
new int[] {2, 13, 1}, // bolt
|
||||
new int[] {4, 0, 5} // shuriken
|
||||
new int[] {8, 11, 1}, // longbow
|
||||
new int[] {9, 12, 1}, // crossbow
|
||||
new int[] {2, 13, 1}, // bolt
|
||||
new int[] {4, 0, 5} // shuriken
|
||||
};
|
||||
coords = new int[][] {
|
||||
new int[] { 3, 10, 3, 9 }, new int[] { 4, 3, 4, 2 }, // longbow
|
||||
new int[] { 1, 2, 10, 9 }, new int[] { 4, 4, 3, 3 }, // crossbow
|
||||
new int[] { 4, 12, 13, 13 }, new int[] { 4, 3, 13, 13 }, // bolt
|
||||
new int[] { 0, 0, 0, 0 }, new int[] { 4, 4, 4, 4 } // shuriken
|
||||
new int[] {3, 10, 3, 9}, new int[] {4, 3, 4, 2}, // longbow
|
||||
new int[] {1, 2, 10, 9}, new int[] {4, 4, 3, 3}, // crossbow
|
||||
new int[] {4, 12, 13, 13}, new int[] {4, 3, 13, 13}, // bolt
|
||||
new int[] {0, 0, 0, 0}, new int[] {4, 4, 4, 4} // shuriken
|
||||
};
|
||||
|
||||
for (int i = 0; i < tools.length; i++)
|
||||
{
|
||||
String locString = String.format("gui.toolstation.%s.desc", tools[i].getToolName().toLowerCase());
|
||||
TConstructClientRegistry.addTierTwoButton(icons[i][0], icons[i][1], icons[i][2], coords[i*2], coords[i*2+1], tools[i].getLocalizedToolName(), locString, Reference.RESOURCE, tex);
|
||||
for (int i = 0; i < tools.length; i++) {
|
||||
String locString = String.format(
|
||||
"gui.toolstation.%s.desc", tools[i].getToolName().toLowerCase());
|
||||
TConstructClientRegistry.addTierTwoButton(
|
||||
icons[i][0],
|
||||
icons[i][1],
|
||||
icons[i][2],
|
||||
coords[i * 2],
|
||||
coords[i * 2 + 1],
|
||||
tools[i].getLocalizedToolName(),
|
||||
locString,
|
||||
Reference.RESOURCE,
|
||||
tex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Manual Stuff */
|
||||
public void registerManualIcons ()
|
||||
{
|
||||
MantleClientRegistry.registerManualIcon("throwingknifeIcon", ToolBuilder.instance.buildTool(new ItemStack(TinkerTools.knifeBlade, 1, TinkerTools.MaterialID.Iron), new ItemStack(TinkerTools.toolRod, 1, 11), null, ""));
|
||||
MantleClientRegistry.registerManualIcon("shortbowIcon", ToolBuilder.instance.buildTool(new ItemStack(TinkerWeaponry.partBowLimb, 1, TinkerTools.MaterialID.Wood), new ItemStack(TinkerWeaponry.bowstring, 1, 0), new ItemStack(TinkerWeaponry.partBowLimb, 1, TinkerTools.MaterialID.Wood), ""));
|
||||
MantleClientRegistry.registerManualIcon("arrowIcon", ToolBuilder.instance.buildTool(new ItemStack(TinkerWeaponry.arrowhead, 1, TinkerTools.MaterialID.Flint), new ItemStack(Items.stick), new ItemStack(TinkerWeaponry.fletching, 1, 0), ""));
|
||||
public void registerManualIcons() {
|
||||
MantleClientRegistry.registerManualIcon(
|
||||
"throwingknifeIcon",
|
||||
ToolBuilder.instance.buildTool(
|
||||
new ItemStack(TinkerTools.knifeBlade, 1, TinkerTools.MaterialID.Iron),
|
||||
new ItemStack(TinkerTools.toolRod, 1, 11),
|
||||
null,
|
||||
""));
|
||||
MantleClientRegistry.registerManualIcon(
|
||||
"shortbowIcon",
|
||||
ToolBuilder.instance.buildTool(
|
||||
new ItemStack(TinkerWeaponry.partBowLimb, 1, TinkerTools.MaterialID.Wood),
|
||||
new ItemStack(TinkerWeaponry.bowstring, 1, 0),
|
||||
new ItemStack(TinkerWeaponry.partBowLimb, 1, TinkerTools.MaterialID.Wood),
|
||||
""));
|
||||
MantleClientRegistry.registerManualIcon(
|
||||
"arrowIcon",
|
||||
ToolBuilder.instance.buildTool(
|
||||
new ItemStack(TinkerWeaponry.arrowhead, 1, TinkerTools.MaterialID.Flint),
|
||||
new ItemStack(Items.stick),
|
||||
new ItemStack(TinkerWeaponry.fletching, 1, 0),
|
||||
""));
|
||||
|
||||
MantleClientRegistry.registerManualIcon("weaponrybook", new ItemStack(TinkerTools.manualBook, 1, 4));
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package tconstruct.weaponry;
|
||||
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.weaponry.entity.*;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
|
||||
public class WeaponryCommonProxy {
|
||||
public void init() {
|
||||
EntityRegistry.registerModEntity(ShurikenEntity.class, "Shuriken", 20, TConstruct.instance, 32, 5, true);
|
||||
EntityRegistry.registerModEntity(ThrowingKnifeEntity.class, "ThrowingKnife", 21, TConstruct.instance, 32, 5, true);
|
||||
EntityRegistry.registerModEntity(
|
||||
ThrowingKnifeEntity.class, "ThrowingKnife", 21, TConstruct.instance, 32, 5, true);
|
||||
EntityRegistry.registerModEntity(JavelinEntity.class, "Javelin", 22, TConstruct.instance, 32, 5, true);
|
||||
EntityRegistry.registerModEntity(ArrowEntity.class, "Arrow", 23, TConstruct.instance, 32, 5, true);
|
||||
EntityRegistry.registerModEntity(BoltEntity.class, "Bolt", 24, TConstruct.instance, 32, 5, true);
|
||||
|
||||
@@ -2,58 +2,53 @@ package tconstruct.weaponry;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import tconstruct.armor.player.TPlayerStats;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.crafting.PatternBuilder;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import tconstruct.library.entity.ProjectileBase;
|
||||
import tconstruct.library.event.PartBuilderEvent;
|
||||
import tconstruct.library.event.SmelteryCastEvent;
|
||||
import tconstruct.library.event.ToolBuildEvent;
|
||||
import tconstruct.library.event.ToolCraftEvent;
|
||||
import tconstruct.library.tools.*;
|
||||
import tconstruct.library.tools.DualMaterialToolPart;
|
||||
import tconstruct.library.util.IToolPart;
|
||||
import tconstruct.library.weaponry.ArrowShaftMaterial;
|
||||
import tconstruct.library.weaponry.BowBaseAmmo;
|
||||
import tconstruct.library.weaponry.IAmmo;
|
||||
import tconstruct.library.weaponry.ProjectileWeapon;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
import tconstruct.weaponry.ammo.ArrowAmmo;
|
||||
import tconstruct.weaponry.ammo.BoltAmmo;
|
||||
import tconstruct.library.tools.DualMaterialToolPart;
|
||||
import tconstruct.library.weaponry.ArrowShaftMaterial;
|
||||
import tconstruct.library.weaponry.BowBaseAmmo;
|
||||
import tconstruct.library.weaponry.ProjectileWeapon;
|
||||
import tconstruct.library.weaponry.IAmmo;
|
||||
import tconstruct.weaponry.weapons.Crossbow;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import tconstruct.library.event.ToolBuildEvent;
|
||||
import tconstruct.library.event.ToolCraftEvent;
|
||||
import tconstruct.library.tools.*;
|
||||
import tconstruct.weaponry.weapons.LongBow;
|
||||
import tconstruct.weaponry.weapons.ShortBow;
|
||||
|
||||
public class WeaponryHandler {
|
||||
@SubscribeEvent
|
||||
public void onCrafting (PlayerEvent.ItemCraftedEvent event)
|
||||
{
|
||||
public void onCrafting(PlayerEvent.ItemCraftedEvent event) {
|
||||
Item item = event.crafting.getItem();
|
||||
if (!event.player.worldObj.isRemote)
|
||||
{
|
||||
if (item == Item.getItemFromBlock(TinkerTools.toolStationWood))
|
||||
{
|
||||
if (!PHConstruct.beginnerBook)
|
||||
{
|
||||
if (!event.player.worldObj.isRemote) {
|
||||
if (item == Item.getItemFromBlock(TinkerTools.toolStationWood)) {
|
||||
if (!PHConstruct.beginnerBook) {
|
||||
return;
|
||||
}
|
||||
|
||||
TPlayerStats stats = TPlayerStats.get(event.player);
|
||||
if (!stats.weaponryManual)
|
||||
{
|
||||
if (!stats.weaponryManual) {
|
||||
stats.weaponryManual = true;
|
||||
AbilityHelper.spawnItemAtPlayer(event.player, new ItemStack(TinkerTools.manualBook, 1, 4));
|
||||
}
|
||||
@@ -63,44 +58,46 @@ public class WeaponryHandler {
|
||||
|
||||
// Provides ammo-items with the necessary NBT
|
||||
@SubscribeEvent
|
||||
public void onAmmoCrafted(ToolCraftEvent.NormalTool event)
|
||||
{
|
||||
if(!(event.tool instanceof IAmmo))
|
||||
return;
|
||||
public void onAmmoCrafted(ToolCraftEvent.NormalTool event) {
|
||||
if (!(event.tool instanceof IAmmo)) return;
|
||||
|
||||
NBTTagCompound tags = event.toolTag.getCompoundTag("InfiTool");
|
||||
|
||||
// calculate its stats
|
||||
if(event.tool instanceof ArrowAmmo)
|
||||
{
|
||||
if (event.tool instanceof ArrowAmmo) {
|
||||
// arrows work like this:
|
||||
// the head is responsible for the damage, but also adds weight
|
||||
// the shaft defines how fragile the arrow is, and also adds to the weight a bit. But mostly the fragility.
|
||||
// the fletching defines the accuracy of the arrow and adds a bit breakchance. Mostly there for the durability modifier because availability
|
||||
// the fletching defines the accuracy of the arrow and adds a bit breakchance. Mostly there for the
|
||||
// durability modifier because availability
|
||||
|
||||
// Shortbows work better with lighter arrows
|
||||
// while Longbows require a bit heavier arrows, the lighter the arrow the more impact the accuracy has otherwise
|
||||
// while Longbows require a bit heavier arrows, the lighter the arrow the more impact the accuracy has
|
||||
// otherwise
|
||||
|
||||
// summa sumarum: heavier arrows fall faster (less range) but accuracy has less impact
|
||||
|
||||
// the materials
|
||||
ToolMaterial head = TConstructRegistry.getMaterial(tags.getInteger("Head"));
|
||||
ArrowMaterial arrow = TConstructRegistry.getArrowMaterial(tags.getInteger("Head"));
|
||||
ArrowShaftMaterial shaft = (ArrowShaftMaterial) TConstructRegistry.getCustomMaterial(tags.getInteger("Handle"), ArrowShaftMaterial.class);
|
||||
FletchingMaterial fletching = (FletchingMaterial) TConstructRegistry.getCustomMaterial(tags.getInteger("Accessory"), FletchingMaterial.class);
|
||||
ArrowShaftMaterial shaft = (ArrowShaftMaterial)
|
||||
TConstructRegistry.getCustomMaterial(tags.getInteger("Handle"), ArrowShaftMaterial.class);
|
||||
FletchingMaterial fletching = (FletchingMaterial)
|
||||
TConstructRegistry.getCustomMaterial(tags.getInteger("Accessory"), FletchingMaterial.class);
|
||||
|
||||
// todo: fix leaf fletching
|
||||
if(fletching == null)
|
||||
fletching = (FletchingMaterial) TConstructRegistry.getCustomMaterial(tags.getInteger("Accessory"), FletchlingLeafMaterial.class);
|
||||
if (fletching == null)
|
||||
fletching = (FletchingMaterial) TConstructRegistry.getCustomMaterial(
|
||||
tags.getInteger("Accessory"), FletchlingLeafMaterial.class);
|
||||
|
||||
// invalid materials
|
||||
if(arrow == null || shaft == null || fletching == null)
|
||||
{
|
||||
if (arrow == null || shaft == null || fletching == null) {
|
||||
event.setResult(Event.Result.DENY);
|
||||
return;
|
||||
}
|
||||
|
||||
int durability = (int)((float)head.durability() * shaft.durabilityModifier * fletching.durabilityModifier);
|
||||
int durability =
|
||||
(int) ((float) head.durability() * shaft.durabilityModifier * fletching.durabilityModifier);
|
||||
float weight = arrow.mass + shaft.weight;
|
||||
float accuracy = fletching.accuracy;
|
||||
float breakChance = shaft.fragility * arrow.breakChance + fletching.breakChance;
|
||||
@@ -108,16 +105,13 @@ public class WeaponryHandler {
|
||||
setAmmoData(tags, durability, weight, breakChance, accuracy, head.shoddy(), head.reinforced());
|
||||
|
||||
// Blaze shafts give fiery
|
||||
if(tags.getInteger("Handle") == 3)
|
||||
{
|
||||
if (tags.getInteger("Handle") == 3) {
|
||||
tags.setInteger("Fiery", 5);
|
||||
}
|
||||
// arrows get only 2 modifiers (so one less) by default
|
||||
int mods = Math.max(0, tags.getInteger("Modifiers")-1);
|
||||
int mods = Math.max(0, tags.getInteger("Modifiers") - 1);
|
||||
tags.setInteger("Modifiers", mods);
|
||||
}
|
||||
else if(event.tool instanceof BoltAmmo)
|
||||
{
|
||||
} else if (event.tool instanceof BoltAmmo) {
|
||||
// bolts work like ammos, but have more weight as they have 2 main materials
|
||||
// Crossbows work better with heavier bolts
|
||||
|
||||
@@ -126,29 +120,31 @@ public class WeaponryHandler {
|
||||
ToolMaterial coreMat = TConstructRegistry.getMaterial(tags.getInteger("Handle"));
|
||||
ArrowMaterial head = TConstructRegistry.getArrowMaterial(tags.getInteger("Head"));
|
||||
ArrowMaterial core = TConstructRegistry.getArrowMaterial(tags.getInteger("Handle"));
|
||||
FletchingMaterial fletching = (FletchingMaterial) TConstructRegistry.getCustomMaterial(tags.getInteger("Accessory"), FletchingMaterial.class);
|
||||
FletchingMaterial fletching = (FletchingMaterial)
|
||||
TConstructRegistry.getCustomMaterial(tags.getInteger("Accessory"), FletchingMaterial.class);
|
||||
|
||||
// todo: fix leaf fletching
|
||||
if(fletching == null)
|
||||
fletching = (FletchingMaterial) TConstructRegistry.getCustomMaterial(tags.getInteger("Accessory"), FletchlingLeafMaterial.class);
|
||||
if (fletching == null)
|
||||
fletching = (FletchingMaterial) TConstructRegistry.getCustomMaterial(
|
||||
tags.getInteger("Accessory"), FletchlingLeafMaterial.class);
|
||||
|
||||
// invalid materials
|
||||
if(head == null || core == null || fletching == null)
|
||||
{
|
||||
if (head == null || core == null || fletching == null) {
|
||||
event.setResult(Event.Result.DENY);
|
||||
return;
|
||||
}
|
||||
|
||||
int durability = (int)((float)headMat.durability() * coreMat.handleDurability() * fletching.durabilityModifier);
|
||||
float weight = head.mass + core.mass*1.5f;
|
||||
float accuracy = (100f + fletching.accuracy)/2f;
|
||||
float breakChance = (fletching.breakChance*2 + 0.15f * core.breakChance) * head.breakChance/2f;
|
||||
float shoddy = (headMat.shoddy() + coreMat.shoddy())/2f;
|
||||
int durability =
|
||||
(int) ((float) headMat.durability() * coreMat.handleDurability() * fletching.durabilityModifier);
|
||||
float weight = head.mass + core.mass * 1.5f;
|
||||
float accuracy = (100f + fletching.accuracy) / 2f;
|
||||
float breakChance = (fletching.breakChance * 2 + 0.15f * core.breakChance) * head.breakChance / 2f;
|
||||
float shoddy = (headMat.shoddy() + coreMat.shoddy()) / 2f;
|
||||
int reinforced = Math.max(headMat.reinforced(), coreMat.reinforced());
|
||||
|
||||
setAmmoData(tags, durability, weight, breakChance, accuracy, shoddy, reinforced);
|
||||
|
||||
int mods = Math.max(0, tags.getInteger("Modifiers")-1);
|
||||
int mods = Math.max(0, tags.getInteger("Modifiers") - 1);
|
||||
tags.setInteger("Modifiers", mods);
|
||||
}
|
||||
|
||||
@@ -159,13 +155,11 @@ public class WeaponryHandler {
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onProjectileWeaponCrafted(ToolCraftEvent.NormalTool event)
|
||||
{
|
||||
if(!(event.tool instanceof ProjectileWeapon))
|
||||
return;
|
||||
public void onProjectileWeaponCrafted(ToolCraftEvent.NormalTool event) {
|
||||
if (!(event.tool instanceof ProjectileWeapon)) return;
|
||||
|
||||
NBTTagCompound tags = event.toolTag.getCompoundTag("InfiTool");
|
||||
ProjectileWeapon weapon = (ProjectileWeapon)event.tool;
|
||||
ProjectileWeapon weapon = (ProjectileWeapon) event.tool;
|
||||
|
||||
int drawSpeed = 0;
|
||||
float flightSpeed = 0;
|
||||
@@ -176,61 +170,58 @@ public class WeaponryHandler {
|
||||
|
||||
boolean enchanted = false;
|
||||
|
||||
if(event.tool instanceof BowBaseAmmo) {
|
||||
if (event.tool instanceof BowBaseAmmo) {
|
||||
top = TConstructRegistry.getBowMaterial(tags.getInteger("Head"));
|
||||
bottom = TConstructRegistry.getBowMaterial(tags.getInteger("Accessory"));
|
||||
string = (BowstringMaterial) TConstructRegistry.getCustomMaterial(tags.getInteger("Handle"), BowstringMaterial.class);
|
||||
string = (BowstringMaterial)
|
||||
TConstructRegistry.getCustomMaterial(tags.getInteger("Handle"), BowstringMaterial.class);
|
||||
|
||||
// some materials seem to be incompatible
|
||||
if(top == null || bottom == null || string == null)
|
||||
{
|
||||
if (top == null || bottom == null || string == null) {
|
||||
event.setResult(Event.Result.DENY);
|
||||
return;
|
||||
}
|
||||
|
||||
drawSpeed = (int) ((top.drawspeed + bottom.drawspeed) / 2f * string.drawspeedModifier);
|
||||
flightSpeed = (top.flightSpeedMax + bottom.flightSpeedMax)/2 * string.flightSpeedModifier;
|
||||
flightSpeed = (top.flightSpeedMax + bottom.flightSpeedMax) / 2 * string.flightSpeedModifier;
|
||||
|
||||
// SHORT bows have a SHORTER windup because they're SHORT. hahahaha.... get it?
|
||||
if(event.tool instanceof ShortBow) {
|
||||
if (event.tool instanceof ShortBow) {
|
||||
drawSpeed *= 0.9;
|
||||
}
|
||||
// longbows have LONGER drawspeed. LOGIC!
|
||||
if(event.tool instanceof LongBow) {
|
||||
if (event.tool instanceof LongBow) {
|
||||
drawSpeed *= 1.8f;
|
||||
flightSpeed *= 1.5f;
|
||||
}
|
||||
|
||||
// enchanted bowstring
|
||||
enchanted = tags.getInteger("Handle") == 1;
|
||||
}
|
||||
else if(event.tool instanceof Crossbow)
|
||||
{
|
||||
} else if (event.tool instanceof Crossbow) {
|
||||
top = TConstructRegistry.getBowMaterial(tags.getInteger("Head"));
|
||||
string = (BowstringMaterial) TConstructRegistry.getCustomMaterial(tags.getInteger("Accessory"), BowstringMaterial.class);
|
||||
string = (BowstringMaterial)
|
||||
TConstructRegistry.getCustomMaterial(tags.getInteger("Accessory"), BowstringMaterial.class);
|
||||
|
||||
// some materials seem to be incompatible
|
||||
if(top == null || string == null)
|
||||
{
|
||||
if (top == null || string == null) {
|
||||
event.setResult(Event.Result.DENY);
|
||||
return;
|
||||
}
|
||||
|
||||
drawSpeed = (int) ((float)top.drawspeed * string.drawspeedModifier);
|
||||
drawSpeed = (int) ((float) top.drawspeed * string.drawspeedModifier);
|
||||
flightSpeed = (top.flightSpeedMax * string.flightSpeedModifier);
|
||||
|
||||
// crossbows are more efficient the higher the base drawspeed is. So the higher the drawspeed, the more bonus you get
|
||||
// crossbows are more efficient the higher the base drawspeed is. So the higher the drawspeed, the more
|
||||
// bonus you get
|
||||
drawSpeed *= 2.5f;
|
||||
drawSpeed -= drawSpeed*0.25f;
|
||||
drawSpeed -= drawSpeed * 0.25f;
|
||||
|
||||
// crossbows are stronk
|
||||
flightSpeed *= 1.5;
|
||||
|
||||
// enchanted bowstring
|
||||
enchanted = tags.getInteger("Accessory") == 1;
|
||||
}
|
||||
else
|
||||
return;
|
||||
} else return;
|
||||
|
||||
// enchanted fabric
|
||||
if (enchanted) {
|
||||
@@ -244,47 +235,41 @@ public class WeaponryHandler {
|
||||
tags.setFloat("FlightSpeed", flightSpeed);
|
||||
}
|
||||
|
||||
|
||||
// arrows use custom materials. But we don't allow the creation of those items
|
||||
// we therefore replace the items with their toolpart counterparts here
|
||||
@SubscribeEvent
|
||||
public void buildArrow(ToolBuildEvent event)
|
||||
{
|
||||
if(event.headStack == null || event.handleStack == null || event.accessoryStack == null)
|
||||
return;
|
||||
public void buildArrow(ToolBuildEvent event) {
|
||||
if (event.headStack == null || event.handleStack == null || event.accessoryStack == null) return;
|
||||
|
||||
// are we building an arrow?
|
||||
CustomMaterial mat = TConstructRegistry.getCustomMaterial(event.handleStack, ArrowShaftMaterial.class);
|
||||
if(mat == null)
|
||||
return;
|
||||
if (mat == null) return;
|
||||
Item extra = event.extraStack != null ? event.extraStack.getItem() : null;
|
||||
ToolCore tool = ToolBuilder.instance.getMatchingRecipe(event.headStack.getItem(), mat.craftingItem.getItem(), event.accessoryStack.getItem(), extra);
|
||||
ToolCore tool = ToolBuilder.instance.getMatchingRecipe(
|
||||
event.headStack.getItem(), mat.craftingItem.getItem(), event.accessoryStack.getItem(), extra);
|
||||
|
||||
// it's an arrow!
|
||||
if(tool == TinkerWeaponry.arrowAmmo)
|
||||
event.handleStack = mat.craftingItem.copy();
|
||||
if (tool == TinkerWeaponry.arrowAmmo) event.handleStack = mat.craftingItem.copy();
|
||||
}
|
||||
|
||||
// bolts require special treatment because of their dual-material cores
|
||||
@SubscribeEvent
|
||||
public void buildBolt(ToolBuildEvent event)
|
||||
{
|
||||
if(event.headStack == null || event.handleStack == null)
|
||||
return;
|
||||
public void buildBolt(ToolBuildEvent event) {
|
||||
if (event.headStack == null || event.handleStack == null) return;
|
||||
|
||||
if(event.headStack.getItem() != TinkerWeaponry.partBolt)
|
||||
return;
|
||||
if (event.headStack.getItem() != TinkerWeaponry.partBolt) return;
|
||||
|
||||
// is the bolt already split into 2 items?
|
||||
if(event.accessoryStack != null && event.headStack.getItem() == TinkerWeaponry.partBolt && event.handleStack.getItem() == TinkerWeaponry.partBolt && event.accessoryStack.getItem() == TinkerWeaponry.fletching)
|
||||
return;
|
||||
if (event.accessoryStack != null
|
||||
&& event.headStack.getItem() == TinkerWeaponry.partBolt
|
||||
&& event.handleStack.getItem() == TinkerWeaponry.partBolt
|
||||
&& event.accessoryStack.getItem() == TinkerWeaponry.fletching) return;
|
||||
|
||||
// split the bolt into its two parts
|
||||
ItemStack bolt1 = event.headStack.copy();
|
||||
ItemStack bolt2 = event.headStack;
|
||||
ItemStack fletching = event.handleStack;
|
||||
|
||||
|
||||
// set the correct material on the 2nd part
|
||||
DualMaterialToolPart dualPart = (DualMaterialToolPart) bolt2.getItem();
|
||||
bolt1.setItemDamage(dualPart.getMaterialID2(bolt1));
|
||||
@@ -295,8 +280,14 @@ public class WeaponryHandler {
|
||||
event.accessoryStack = fletching;
|
||||
}
|
||||
|
||||
private void setAmmoData(NBTTagCompound tags, int durability, float weight, float breakChance, float accuracy, float shoddy, int reinforced)
|
||||
{
|
||||
private void setAmmoData(
|
||||
NBTTagCompound tags,
|
||||
int durability,
|
||||
float weight,
|
||||
float breakChance,
|
||||
float accuracy,
|
||||
float shoddy,
|
||||
int reinforced) {
|
||||
tags.setInteger("TotalDurability", durability);
|
||||
tags.setInteger("BaseDurability", durability);
|
||||
tags.setFloat("Mass", weight);
|
||||
@@ -307,80 +298,79 @@ public class WeaponryHandler {
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void weaponryPartCrafted(PartBuilderEvent.NormalPart event)
|
||||
{
|
||||
if(event.pattern == null)
|
||||
return;
|
||||
public void weaponryPartCrafted(PartBuilderEvent.NormalPart event) {
|
||||
if (event.pattern == null) return;
|
||||
|
||||
// weaponry part
|
||||
if(event.pattern.getItem() == TinkerWeaponry.woodPattern) {
|
||||
if (event.pattern.getItem() == TinkerWeaponry.woodPattern) {
|
||||
// crossbow or bow limb
|
||||
if (event.pattern.getItemDamage() == 1 || event.pattern.getItemDamage() == 3) {
|
||||
// only allow crafting if the material has bow stats
|
||||
PatternBuilder.ItemKey key = PatternBuilder.instance.getItemKey(event.material);
|
||||
if(key == null)
|
||||
return;
|
||||
PatternBuilder.ItemKey key = PatternBuilder.instance.getItemKey(event.material);
|
||||
if (key == null) return;
|
||||
|
||||
PatternBuilder.MaterialSet ms = PatternBuilder.instance.materialSets.get(key.key);
|
||||
if(ms == null)
|
||||
return;
|
||||
if (ms == null) return;
|
||||
|
||||
if(TConstructRegistry.getBowMaterial(ms.materialID) == null)
|
||||
event.setResult(Event.Result.DENY);
|
||||
if (TConstructRegistry.getBowMaterial(ms.materialID) == null) event.setResult(Event.Result.DENY);
|
||||
}
|
||||
}
|
||||
// arrow stats, still in tool
|
||||
if(event.pattern.getItem() == TinkerTools.woodPattern && event.pattern.getItemDamage() == 25) {
|
||||
if (event.pattern.getItem() == TinkerTools.woodPattern && event.pattern.getItemDamage() == 25) {
|
||||
// only allow crafting if the material has bow stats
|
||||
PatternBuilder.ItemKey key = PatternBuilder.instance.getItemKey(event.material);
|
||||
if(key == null)
|
||||
return;
|
||||
PatternBuilder.ItemKey key = PatternBuilder.instance.getItemKey(event.material);
|
||||
if (key == null) return;
|
||||
|
||||
PatternBuilder.MaterialSet ms = PatternBuilder.instance.materialSets.get(key.key);
|
||||
if(ms == null)
|
||||
return;
|
||||
if (ms == null) return;
|
||||
|
||||
if(TConstructRegistry.getArrowMaterial(ms.materialID) == null)
|
||||
event.setResult(Event.Result.DENY);
|
||||
if (TConstructRegistry.getArrowMaterial(ms.materialID) == null) event.setResult(Event.Result.DENY);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void weaponryPartCast(SmelteryCastEvent.CastingTable event) {
|
||||
if (event.recipe == null || event.recipe.output == null)
|
||||
return;
|
||||
if (event.recipe == null || event.recipe.output == null) return;
|
||||
|
||||
if (!(event.recipe.output.getItem() instanceof IToolPart))
|
||||
return;
|
||||
if (!(event.recipe.output.getItem() instanceof IToolPart)) return;
|
||||
|
||||
// get material for the output
|
||||
int mat = ((IToolPart) event.recipe.output.getItem()).getMaterialID(event.recipe.output);
|
||||
|
||||
// arrowhead
|
||||
if (event.recipe.output.getItem() == TinkerWeaponry.arrowhead)
|
||||
if (TConstructRegistry.getArrowMaterial(mat) == null)
|
||||
event.setResult(Event.Result.DENY);
|
||||
if (TConstructRegistry.getArrowMaterial(mat) == null) event.setResult(Event.Result.DENY);
|
||||
// crossbow/bowlimb
|
||||
if (event.recipe.output.getItem() == TinkerWeaponry.partBowLimb || event.recipe.output.getItem() == TinkerWeaponry.partCrossbowLimb)
|
||||
if (TConstructRegistry.getBowMaterial(mat) == null)
|
||||
event.setResult(Event.Result.DENY);
|
||||
if (event.recipe.output.getItem() == TinkerWeaponry.partBowLimb
|
||||
|| event.recipe.output.getItem() == TinkerWeaponry.partCrossbowLimb)
|
||||
if (TConstructRegistry.getBowMaterial(mat) == null) event.setResult(Event.Result.DENY);
|
||||
}
|
||||
|
||||
// high priority because we want to do these checks on unmodified stacks
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public void boneanaParts(ToolBuildEvent event) {
|
||||
if(event.headStack == null || event.handleStack == null || event.accessoryStack != null || event.extraStack != null)
|
||||
return;
|
||||
if (event.headStack == null
|
||||
|| event.handleStack == null
|
||||
|| event.accessoryStack != null
|
||||
|| event.extraStack != null) return;
|
||||
|
||||
// golden carrot + bone
|
||||
if(event.headStack.getItem() == Items.golden_carrot && event.handleStack.getItem() == Items.bone)
|
||||
{
|
||||
if (event.headStack.getItem() == Items.golden_carrot && event.handleStack.getItem() == Items.bone) {
|
||||
// golden carrot must be named banana
|
||||
if(!event.headStack.hasTagCompound() || !event.headStack.getTagCompound().hasKey("display") ||
|
||||
!event.headStack.getTagCompound().getCompoundTag("display").hasKey("Name") ||
|
||||
!event.headStack.getTagCompound().getCompoundTag("display").getString("Name").toLowerCase().equals("banana"))
|
||||
return;
|
||||
event.name = '\u2400' + "Bonæna"; // the \u2400 is a non-printable unicode character so you can't just type it
|
||||
if (!event.headStack.hasTagCompound()
|
||||
|| !event.headStack.getTagCompound().hasKey("display")
|
||||
|| !event.headStack
|
||||
.getTagCompound()
|
||||
.getCompoundTag("display")
|
||||
.hasKey("Name")
|
||||
|| !event.headStack
|
||||
.getTagCompound()
|
||||
.getCompoundTag("display")
|
||||
.getString("Name")
|
||||
.toLowerCase()
|
||||
.equals("banana")) return;
|
||||
event.name =
|
||||
'\u2400' + "Bonæna"; // the \u2400 is a non-printable unicode character so you can't just type it
|
||||
event.headStack = new ItemStack(TinkerTools.swordBlade, 1, TinkerTools.MaterialID.Bone);
|
||||
event.handleStack = new ItemStack(TinkerTools.toolRod, 1, TinkerTools.MaterialID.Bone);
|
||||
event.accessoryStack = new ItemStack(TinkerTools.wideGuard, 1, TinkerTools.MaterialID.Bone);
|
||||
@@ -390,8 +380,7 @@ public class WeaponryHandler {
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public void boneanaBuilding(ToolCraftEvent.NormalTool event) {
|
||||
// is it a boneana?
|
||||
if("\u00A7f\u2400Bonæna".equals(event.toolTag.getCompoundTag("display").getString("Name")))
|
||||
{
|
||||
if ("\u00A7f\u2400Bonæna".equals(event.toolTag.getCompoundTag("display").getString("Name"))) {
|
||||
// set correct name
|
||||
event.toolTag.getCompoundTag("display").setString("Name", EnumChatFormatting.YELLOW + "Bonæna");
|
||||
// lore!
|
||||
@@ -422,9 +411,9 @@ public class WeaponryHandler {
|
||||
public void entityJoin(EntityJoinWorldEvent event) {
|
||||
// This prevents invalid projectiles to be created
|
||||
// This can happen because of ID remaps.
|
||||
if(event.entity instanceof ProjectileBase) {
|
||||
if (event.entity instanceof ProjectileBase) {
|
||||
ProjectileBase projectile = (ProjectileBase) event.entity;
|
||||
if(projectile.returnStack == null || !(projectile.returnStack.getItem() instanceof ToolCore))
|
||||
if (projectile.returnStack == null || !(projectile.returnStack.getItem() instanceof ToolCore))
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
package tconstruct.weaponry.ammo;
|
||||
|
||||
import net.minecraft.util.StatCollector;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.ArrowMaterial;
|
||||
import tconstruct.library.tools.CustomMaterial;
|
||||
import tconstruct.library.tools.FletchingMaterial;
|
||||
import tconstruct.library.tools.FletchlingLeafMaterial;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import tconstruct.library.weaponry.AmmoItem;
|
||||
import java.util.List;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import tconstruct.library.tools.CustomMaterial;
|
||||
import tconstruct.library.tools.FletchingMaterial;
|
||||
import tconstruct.library.tools.FletchlingLeafMaterial;
|
||||
import tconstruct.library.weaponry.AmmoItem;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
|
||||
import java.util.List;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
|
||||
public class ArrowAmmo extends AmmoItem {
|
||||
public static ItemStack vanillaArrow;
|
||||
@@ -25,10 +23,8 @@ public class ArrowAmmo extends AmmoItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
public String getIconSuffix(int partType) {
|
||||
switch (partType) {
|
||||
case 0:
|
||||
return "_arrow_head";
|
||||
case 1:
|
||||
@@ -43,33 +39,28 @@ public class ArrowAmmo extends AmmoItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
public String getEffectSuffix() {
|
||||
return "_arrow_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
public String getDefaultFolder() {
|
||||
return "arrow";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPartPaths (int index, String[] location)
|
||||
{
|
||||
public void registerPartPaths(int index, String[] location) {
|
||||
headStrings.put(index, location[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAlternatePartPaths (int index, String[] location)
|
||||
{
|
||||
public void registerAlternatePartPaths(int index, String[] location) {
|
||||
handleStrings.put(index, location[2]);
|
||||
accessoryStrings.put(index, location[3]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
public Item getHeadItem() {
|
||||
return TinkerWeaponry.arrowhead;
|
||||
}
|
||||
|
||||
@@ -79,8 +70,7 @@ public class ArrowAmmo extends AmmoItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
public Item getAccessoryItem() {
|
||||
return TinkerWeaponry.fletching;
|
||||
}
|
||||
|
||||
@@ -91,23 +81,20 @@ public class ArrowAmmo extends AmmoItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTraits ()
|
||||
{
|
||||
return new String[] { "ammo", "projectile", "weapon" };
|
||||
public String[] getTraits() {
|
||||
return new String[] {"ammo", "projectile", "weapon"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildTool (int id, String name, List list)
|
||||
{
|
||||
if(TConstructRegistry.getArrowMaterial(id) == null)
|
||||
return;
|
||||
public void buildTool(int id, String name, List list) {
|
||||
if (TConstructRegistry.getArrowMaterial(id) == null) return;
|
||||
|
||||
ItemStack handleStack = new ItemStack(getHandleItem(), 1, 0); // wooden shaft
|
||||
ItemStack accessoryStack = new ItemStack(getAccessoryItem(), 1, 0); // feather fletchling
|
||||
|
||||
ItemStack tool = ToolBuilder.instance.buildTool(new ItemStack(getHeadItem(), 1, id), handleStack, accessoryStack, null, "");
|
||||
if (tool != null)
|
||||
{
|
||||
ItemStack tool = ToolBuilder.instance.buildTool(
|
||||
new ItemStack(getHeadItem(), 1, id), handleStack, accessoryStack, null, "");
|
||||
if (tool != null) {
|
||||
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
|
||||
list.add(tool);
|
||||
}
|
||||
@@ -123,25 +110,19 @@ public class ArrowAmmo extends AmmoItem {
|
||||
ItemStack accessoryStack = new ItemStack(getAccessoryItem(), 1, 0); // feather fletchling
|
||||
|
||||
ItemStack tool = ToolBuilder.instance.buildTool(headStack, handleStack, accessoryStack, null, "");
|
||||
if (tool != null)
|
||||
{
|
||||
if (tool != null) {
|
||||
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
|
||||
vanillaArrow = tool;
|
||||
}
|
||||
else
|
||||
TConstruct.logger.error("Couldn't build vanilla equivalent of Tinker Arrow");
|
||||
} else TConstruct.logger.error("Couldn't build vanilla equivalent of Tinker Arrow");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDefaultColor(int renderPass, int materialID) {
|
||||
if(renderPass != 2)
|
||||
return super.getDefaultColor(renderPass, materialID);
|
||||
if (renderPass != 2) return super.getDefaultColor(renderPass, materialID);
|
||||
|
||||
CustomMaterial mat = TConstructRegistry.getCustomMaterial(materialID, FletchingMaterial.class);
|
||||
if(mat == null)
|
||||
TConstructRegistry.getCustomMaterial(materialID, FletchlingLeafMaterial.class);
|
||||
if(mat == null)
|
||||
return 0xffffff;
|
||||
if (mat == null) TConstructRegistry.getCustomMaterial(materialID, FletchlingLeafMaterial.class);
|
||||
if (mat == null) return 0xffffff;
|
||||
|
||||
return mat.color;
|
||||
}
|
||||
@@ -150,10 +131,9 @@ public class ArrowAmmo extends AmmoItem {
|
||||
@Override
|
||||
public String getAbilityNameForType(int type, int part) {
|
||||
// blaze shaft?
|
||||
if(part == 1 && type == 3)
|
||||
return "\u00a76" + StatCollector.translateToLocal("modifier.tool.blaze");
|
||||
if(part >= 1) // only head has ability otherwise
|
||||
return "";
|
||||
if (part == 1 && type == 3) return "\u00a76" + StatCollector.translateToLocal("modifier.tool.blaze");
|
||||
if (part >= 1) // only head has ability otherwise
|
||||
return "";
|
||||
return super.getAbilityNameForType(type, part);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,17 @@
|
||||
package tconstruct.weaponry.ammo;
|
||||
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.CustomMaterial;
|
||||
import tconstruct.library.tools.FletchingMaterial;
|
||||
import tconstruct.library.tools.FletchlingLeafMaterial;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import tconstruct.library.tools.DualMaterialToolPart;
|
||||
import tconstruct.library.weaponry.AmmoItem;
|
||||
import java.util.List;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
|
||||
import java.util.List;
|
||||
import tconstruct.library.tools.CustomMaterial;
|
||||
import tconstruct.library.tools.DualMaterialToolPart;
|
||||
import tconstruct.library.tools.FletchingMaterial;
|
||||
import tconstruct.library.tools.FletchlingLeafMaterial;
|
||||
import tconstruct.library.weaponry.AmmoItem;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
|
||||
public class BoltAmmo extends AmmoItem {
|
||||
public BoltAmmo() {
|
||||
@@ -21,8 +20,7 @@ public class BoltAmmo extends AmmoItem {
|
||||
|
||||
@Override
|
||||
public String getIconSuffix(int partType) {
|
||||
switch (partType)
|
||||
{
|
||||
switch (partType) {
|
||||
case 0:
|
||||
return "_bolt_head";
|
||||
case 1:
|
||||
@@ -47,15 +45,13 @@ public class BoltAmmo extends AmmoItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPartPaths (int index, String[] location)
|
||||
{
|
||||
public void registerPartPaths(int index, String[] location) {
|
||||
headStrings.put(index, location[0]);
|
||||
handleStrings.put(index, location[2]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAlternatePartPaths (int index, String[] location)
|
||||
{
|
||||
public void registerAlternatePartPaths(int index, String[] location) {
|
||||
accessoryStrings.put(index, location[3]);
|
||||
}
|
||||
|
||||
@@ -75,25 +71,22 @@ public class BoltAmmo extends AmmoItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTraits ()
|
||||
{
|
||||
return new String[] { "ammo", "projectile", "weapon" };
|
||||
public String[] getTraits() {
|
||||
return new String[] {"ammo", "projectile", "weapon"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildTool (int id, String name, List list)
|
||||
{
|
||||
if(TConstructRegistry.getArrowMaterial(id) == null)
|
||||
return;
|
||||
public void buildTool(int id, String name, List list) {
|
||||
if (TConstructRegistry.getArrowMaterial(id) == null) return;
|
||||
|
||||
// dual material head: we use wooden shafts
|
||||
ItemStack headStack = DualMaterialToolPart.createDualMaterial(getHeadItem(), id, TinkerTools.MaterialID.Iron); // material shaft
|
||||
ItemStack headStack = DualMaterialToolPart.createDualMaterial(
|
||||
getHeadItem(), id, TinkerTools.MaterialID.Iron); // material shaft
|
||||
ItemStack handleStack = new ItemStack(getAccessoryItem(), 1, 0); // feather Fletchling
|
||||
//ItemStack accessoryStack = new ItemStack(getAccessoryItem(), 1, 0); // feather fletchling
|
||||
// ItemStack accessoryStack = new ItemStack(getAccessoryItem(), 1, 0); // feather fletchling
|
||||
|
||||
ItemStack tool = ToolBuilder.instance.buildTool(headStack, handleStack, null, null, "");
|
||||
if (tool != null)
|
||||
{
|
||||
if (tool != null) {
|
||||
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
|
||||
list.add(tool);
|
||||
}
|
||||
@@ -101,14 +94,11 @@ public class BoltAmmo extends AmmoItem {
|
||||
|
||||
@Override
|
||||
protected int getDefaultColor(int renderPass, int materialID) {
|
||||
if(renderPass != 2)
|
||||
return super.getDefaultColor(renderPass, materialID);
|
||||
if (renderPass != 2) return super.getDefaultColor(renderPass, materialID);
|
||||
|
||||
CustomMaterial mat = TConstructRegistry.getCustomMaterial(materialID, FletchingMaterial.class);
|
||||
if(mat == null)
|
||||
mat = TConstructRegistry.getCustomMaterial(materialID, FletchlingLeafMaterial.class);
|
||||
if(mat == null)
|
||||
return 0xffffff;
|
||||
if (mat == null) mat = TConstructRegistry.getCustomMaterial(materialID, FletchlingLeafMaterial.class);
|
||||
if (mat == null) return 0xffffff;
|
||||
|
||||
return mat.color;
|
||||
}
|
||||
@@ -116,8 +106,8 @@ public class BoltAmmo extends AmmoItem {
|
||||
// fix tooltip custom materials
|
||||
@Override
|
||||
public String getAbilityNameForType(int type, int part) {
|
||||
if(part >= 2) // only head and handle have ability
|
||||
return "";
|
||||
if (part >= 2) // only head and handle have ability
|
||||
return "";
|
||||
return super.getAbilityNameForType(type, part);
|
||||
}
|
||||
}
|
||||
@@ -1,57 +1,50 @@
|
||||
package tconstruct.weaponry.client;
|
||||
|
||||
import tconstruct.library.weaponry.ProjectileWeapon;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import tconstruct.library.weaponry.ProjectileWeapon;
|
||||
|
||||
public class AmmoSlotHandler {
|
||||
@SubscribeEvent
|
||||
public void onRenderOverlay(RenderGameOverlayEvent.Pre event)
|
||||
{
|
||||
if(event.type != RenderGameOverlayEvent.ElementType.HOTBAR)
|
||||
return;
|
||||
public void onRenderOverlay(RenderGameOverlayEvent.Pre event) {
|
||||
if (event.type != RenderGameOverlayEvent.ElementType.HOTBAR) return;
|
||||
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
ItemStack equipped = player.getCurrentEquippedItem();
|
||||
|
||||
if(equipped == null || equipped.getItem() == null)
|
||||
return;
|
||||
if(!(equipped.getItem() instanceof ProjectileWeapon))
|
||||
return;
|
||||
if (equipped == null || equipped.getItem() == null) return;
|
||||
if (!(equipped.getItem() instanceof ProjectileWeapon)) return;
|
||||
|
||||
// find ammo
|
||||
// todo: cache this somehow?
|
||||
ItemStack ammo = ((ProjectileWeapon) equipped.getItem()).searchForAmmo(player, equipped);
|
||||
if(ammo == null)
|
||||
return;
|
||||
if (ammo == null) return;
|
||||
|
||||
// check if it's in the inventory
|
||||
int slot = -1;
|
||||
for(int i = 0; i < 9; i++)
|
||||
if(player.inventory.mainInventory[i] == ammo)
|
||||
{
|
||||
for (int i = 0; i < 9; i++)
|
||||
if (player.inventory.mainInventory[i] == ammo) {
|
||||
slot = i;
|
||||
break;
|
||||
}
|
||||
|
||||
// not in the hotbar
|
||||
if(slot == -1)
|
||||
return;
|
||||
if (slot == -1) return;
|
||||
|
||||
int x = event.resolution.getScaledWidth() / 2 - 90 + slot * 20 + 2;
|
||||
int z = event.resolution.getScaledHeight() - 16 - 3;
|
||||
|
||||
int col = 0;
|
||||
col |= 120 << 16; // red
|
||||
col |= 150 << 8; // green
|
||||
col |= 200 << 0; // blue
|
||||
col |= 150 << 8; // green
|
||||
col |= 200 << 0; // blue
|
||||
col |= 200 << 24; // alpha
|
||||
|
||||
// render a cool underlay thing
|
||||
Gui.drawRect(x,z, x+16, z+16, col);
|
||||
Gui.drawRect(x, z, x + 16, z + 16, col);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +1,36 @@
|
||||
package tconstruct.weaponry.client;
|
||||
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import tconstruct.util.Reference;
|
||||
import tconstruct.library.weaponry.IWindup;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import tconstruct.library.weaponry.IWindup;
|
||||
import tconstruct.util.Reference;
|
||||
|
||||
public class CrosshairHandler {
|
||||
private static Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
private static ResourceLocation crossHairSquare = new ResourceLocation(Reference.RESOURCE, "textures/gui/Crosshair.png");
|
||||
private static ResourceLocation crossHairTip = new ResourceLocation(Reference.RESOURCE, "textures/gui/Crosshair2.png");
|
||||
private static ResourceLocation crossHairWeird = new ResourceLocation(Reference.RESOURCE, "textures/gui/Crosshair3.png");
|
||||
private static ResourceLocation crossHairSpike = new ResourceLocation(Reference.RESOURCE, "textures/gui/Crosshair4.png");
|
||||
private static ResourceLocation crossHairSquare =
|
||||
new ResourceLocation(Reference.RESOURCE, "textures/gui/Crosshair.png");
|
||||
private static ResourceLocation crossHairTip =
|
||||
new ResourceLocation(Reference.RESOURCE, "textures/gui/Crosshair2.png");
|
||||
private static ResourceLocation crossHairWeird =
|
||||
new ResourceLocation(Reference.RESOURCE, "textures/gui/Crosshair3.png");
|
||||
private static ResourceLocation crossHairSpike =
|
||||
new ResourceLocation(Reference.RESOURCE, "textures/gui/Crosshair4.png");
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRenderOverlay(RenderGameOverlayEvent.Pre event)
|
||||
{
|
||||
if(event.type != RenderGameOverlayEvent.ElementType.CROSSHAIRS)
|
||||
return;
|
||||
public void onRenderOverlay(RenderGameOverlayEvent.Pre event) {
|
||||
if (event.type != RenderGameOverlayEvent.ElementType.CROSSHAIRS) return;
|
||||
|
||||
ItemStack equipped = mc.thePlayer.getCurrentEquippedItem();
|
||||
if(equipped == null || equipped.getItem() == null)
|
||||
return;
|
||||
if(!(equipped.getItem() instanceof IWindup))
|
||||
return;
|
||||
if (equipped == null || equipped.getItem() == null) return;
|
||||
if (!(equipped.getItem() instanceof IWindup)) return;
|
||||
|
||||
IWindup weapon = (IWindup) equipped.getItem();
|
||||
|
||||
@@ -39,13 +39,24 @@ public class CrosshairHandler {
|
||||
|
||||
int type = 0;
|
||||
ResourceLocation tex;
|
||||
switch (weapon.getCrosshairType())
|
||||
{
|
||||
case SQUARE: tex = crossHairSquare; break;
|
||||
case TIP: tex = crossHairTip; break;
|
||||
case WEIRD: tex = crossHairWeird; type = 1; break;
|
||||
case SPIKE: tex = crossHairSpike; type = 1; break;
|
||||
default: tex = crossHairSquare; type = 0;
|
||||
switch (weapon.getCrosshairType()) {
|
||||
case SQUARE:
|
||||
tex = crossHairSquare;
|
||||
break;
|
||||
case TIP:
|
||||
tex = crossHairTip;
|
||||
break;
|
||||
case WEIRD:
|
||||
tex = crossHairWeird;
|
||||
type = 1;
|
||||
break;
|
||||
case SPIKE:
|
||||
tex = crossHairSpike;
|
||||
type = 1;
|
||||
break;
|
||||
default:
|
||||
tex = crossHairSquare;
|
||||
type = 0;
|
||||
}
|
||||
|
||||
mc.getTextureManager().bindTexture(tex);
|
||||
@@ -55,7 +66,7 @@ public class CrosshairHandler {
|
||||
float spread = ((1.0f - weapon.getWindupProgress(equipped, mc.thePlayer)) * 25f);
|
||||
|
||||
// 4 square crosshair
|
||||
if(type == 0) {
|
||||
if (type == 0) {
|
||||
drawCrosshairPart(width / 2f - spread, height / 2f - spread, 0);
|
||||
drawCrosshairPart(width / 2f + spread, height / 2f - spread, 1);
|
||||
drawCrosshairPart(width / 2f - spread, height / 2f + spread, 2);
|
||||
@@ -63,10 +74,10 @@ public class CrosshairHandler {
|
||||
}
|
||||
// 4 triangle crosshair
|
||||
else {
|
||||
drawAlternateCrosshairPart(width/2f, height/2f - spread, 0);
|
||||
drawAlternateCrosshairPart(width/2f - spread, height/2f, 1);
|
||||
drawAlternateCrosshairPart(width/2f + spread, height/2f, 2);
|
||||
drawAlternateCrosshairPart(width/2f, height/2f + spread, 3);
|
||||
drawAlternateCrosshairPart(width / 2f, height / 2f - spread, 0);
|
||||
drawAlternateCrosshairPart(width / 2f - spread, height / 2f, 1);
|
||||
drawAlternateCrosshairPart(width / 2f + spread, height / 2f, 2);
|
||||
drawAlternateCrosshairPart(width / 2f, height / 2f + spread, 3);
|
||||
}
|
||||
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
@@ -78,10 +89,9 @@ public class CrosshairHandler {
|
||||
mc.getTextureManager().bindTexture(Gui.icons);
|
||||
}
|
||||
|
||||
private void drawCrosshairPart(float width, float height, int part)
|
||||
{
|
||||
double w = (double)width;
|
||||
double h = (double)height;
|
||||
private void drawCrosshairPart(float width, float height, int part) {
|
||||
double w = (double) width;
|
||||
double h = (double) height;
|
||||
|
||||
double s = 4;
|
||||
double z = -90;
|
||||
@@ -89,9 +99,8 @@ public class CrosshairHandler {
|
||||
double u1 = 0;
|
||||
double v1 = 0;
|
||||
|
||||
switch(part)
|
||||
{
|
||||
// top left
|
||||
switch (part) {
|
||||
// top left
|
||||
case 0:
|
||||
w -= s;
|
||||
h -= s;
|
||||
@@ -119,17 +128,16 @@ public class CrosshairHandler {
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV(w - s, h - s, z, u1, v1);
|
||||
tessellator.addVertexWithUV(w - s, h + s, z, u1, v2);
|
||||
tessellator.addVertexWithUV(w + s, h + s, z, u2, v2);
|
||||
tessellator.addVertexWithUV(w + s, h - s, z, u2, v1);
|
||||
tessellator.addVertexWithUV(w - s, h - s, z, u1, v1);
|
||||
tessellator.addVertexWithUV(w - s, h + s, z, u1, v2);
|
||||
tessellator.addVertexWithUV(w + s, h + s, z, u2, v2);
|
||||
tessellator.addVertexWithUV(w + s, h - s, z, u2, v1);
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
private void drawAlternateCrosshairPart(float width, float height, int part)
|
||||
{
|
||||
double w = (double)width;
|
||||
double h = (double)height;
|
||||
private void drawAlternateCrosshairPart(float width, float height, int part) {
|
||||
double w = (double) width;
|
||||
double h = (double) height;
|
||||
|
||||
final double s = 8d;
|
||||
final double z = -90;
|
||||
@@ -137,25 +145,25 @@ public class CrosshairHandler {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawing(GL11.GL_TRIANGLES); // 4
|
||||
// top part
|
||||
if(part == 0) {
|
||||
if (part == 0) {
|
||||
tessellator.addVertexWithUV(w - s, h - s, z, 0, 0);
|
||||
tessellator.addVertexWithUV(w, h, z, 0.5, 0.5);
|
||||
tessellator.addVertexWithUV(w + s, h - s, z, 1, 0);
|
||||
}
|
||||
// left part
|
||||
else if(part == 1) {
|
||||
else if (part == 1) {
|
||||
tessellator.addVertexWithUV(w - s, h - s, z, 0, 0);
|
||||
tessellator.addVertexWithUV(w - s, h + s, z, 0, 1);
|
||||
tessellator.addVertexWithUV(w, h, z, 0.5, 0.5);
|
||||
}
|
||||
// right part
|
||||
else if(part == 2) {
|
||||
else if (part == 2) {
|
||||
tessellator.addVertexWithUV(w, h, z, 0.5, 0.5);
|
||||
tessellator.addVertexWithUV(w + s, h + s, z, 1, 1);
|
||||
tessellator.addVertexWithUV(w + s, h - s, z, 1, 0);
|
||||
}
|
||||
// bottom part
|
||||
else if(part == 3) {
|
||||
else if (part == 3) {
|
||||
tessellator.addVertexWithUV(w, h, z, 0.5, 0.5);
|
||||
tessellator.addVertexWithUV(w - s, h + s, z, 0, 1);
|
||||
tessellator.addVertexWithUV(w + s, h + s, z, 1, 1);
|
||||
|
||||
@@ -1,41 +1,36 @@
|
||||
package tconstruct.weaponry.client;
|
||||
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import tconstruct.library.weaponry.BowBaseAmmo;
|
||||
import tconstruct.library.weaponry.IWindup;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.event.FOVUpdateEvent;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
import tconstruct.library.weaponry.BowBaseAmmo;
|
||||
import tconstruct.library.weaponry.IWindup;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
|
||||
public class RenderEventHandler {
|
||||
@SubscribeEvent
|
||||
public void onAimZoom(FOVUpdateEvent event)
|
||||
{
|
||||
if(!event.entity.isUsingItem())
|
||||
return;
|
||||
public void onAimZoom(FOVUpdateEvent event) {
|
||||
if (!event.entity.isUsingItem()) return;
|
||||
|
||||
if(!(event.entity.getItemInUse().getItem() instanceof IWindup))
|
||||
return;
|
||||
if (!(event.entity.getItemInUse().getItem() instanceof IWindup)) return;
|
||||
|
||||
ItemStack weapon = event.entity.getItemInUse();
|
||||
IWindup item = (IWindup) weapon.getItem();
|
||||
|
||||
if(item.zoomOnWindup(weapon))
|
||||
event.newfov = event.fov / (event.fov + (item.getZoom(weapon)-1.0f) * item.getWindupProgress(weapon, event.entity));
|
||||
if (item.zoomOnWindup(weapon))
|
||||
event.newfov = event.fov
|
||||
/ (event.fov + (item.getZoom(weapon) - 1.0f) * item.getWindupProgress(weapon, event.entity));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRenderPlayer(RenderPlayerEvent.Pre event)
|
||||
{
|
||||
if(event.entityPlayer.getCurrentEquippedItem() != null && event.entityPlayer.getCurrentEquippedItem().getItem() == TinkerWeaponry.javelin) {
|
||||
public void onRenderPlayer(RenderPlayerEvent.Pre event) {
|
||||
if (event.entityPlayer.getCurrentEquippedItem() != null
|
||||
&& event.entityPlayer.getCurrentEquippedItem().getItem() == TinkerWeaponry.javelin) {}
|
||||
|
||||
}
|
||||
if (event.entityPlayer.getItemInUse() == null) return;
|
||||
|
||||
if(event.entityPlayer.getItemInUse() == null)
|
||||
return;
|
||||
|
||||
if(event.entityPlayer.getItemInUse().getItem() instanceof BowBaseAmmo) {
|
||||
if (event.entityPlayer.getItemInUse().getItem() instanceof BowBaseAmmo) {
|
||||
event.renderer.modelBipedMain.aimedBow = true;
|
||||
event.renderer.modelArmor.aimedBow = true;
|
||||
event.renderer.modelArmorChestplate.aimedBow = true;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package tconstruct.weaponry.client.entity;
|
||||
|
||||
import tconstruct.weaponry.entity.ArrowEntity;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import tconstruct.weaponry.entity.ArrowEntity;
|
||||
|
||||
public class ArrowEntityRenderer extends ProjectileBaseRenderer<ArrowEntity> {
|
||||
private int count = 0;
|
||||
@@ -34,8 +34,7 @@ public class ArrowEntityRenderer extends ProjectileBaseRenderer<ArrowEntity> {
|
||||
GL11.glRotatef(-entity.rotationPitch, 1f, 0f, 0f);
|
||||
|
||||
// rotate it so it's "upright"
|
||||
if(count == 0)
|
||||
GL11.glRotatef(90, 0f, 0f, 1f);
|
||||
if (count == 0) GL11.glRotatef(90, 0f, 0f, 1f);
|
||||
|
||||
GL11.glRotatef(45, 0f, 0f, 1f);
|
||||
|
||||
@@ -46,6 +45,6 @@ public class ArrowEntityRenderer extends ProjectileBaseRenderer<ArrowEntity> {
|
||||
GL11.glRotatef(-45, 0f, 0f, 1f);
|
||||
|
||||
// thinner arrows
|
||||
toolCoreRenderer.setDepth(1/64f);
|
||||
toolCoreRenderer.setDepth(1 / 64f);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
package tconstruct.weaponry.client.entity;
|
||||
|
||||
import tconstruct.weaponry.entity.JavelinEntity;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import tconstruct.weaponry.entity.JavelinEntity;
|
||||
|
||||
public class JavelinEntityRenderer extends ProjectileBaseRenderer<JavelinEntity> {
|
||||
@Override
|
||||
public void customRendering(JavelinEntity entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) {
|
||||
public void customRendering(
|
||||
JavelinEntity entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) {
|
||||
|
||||
// rotate it into the direction we threw it
|
||||
GL11.glRotatef(entity.rotationYaw, 0f, 1f, 0f);
|
||||
@@ -24,6 +25,6 @@ public class JavelinEntityRenderer extends ProjectileBaseRenderer<JavelinEntity>
|
||||
// rotate the projectile it so it faces upwards (because the graphic itself is rotated by 45°)
|
||||
GL11.glRotatef(45, 0f, 0f, 1f);
|
||||
|
||||
toolCoreRenderer.setDepth(1/16f);
|
||||
toolCoreRenderer.setDepth(1 / 16f);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package tconstruct.weaponry.client.entity;
|
||||
|
||||
import tconstruct.client.FlexibleToolRenderer;
|
||||
import tconstruct.library.entity.ProjectileBase;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -10,14 +8,22 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import tconstruct.client.FlexibleToolRenderer;
|
||||
import tconstruct.library.entity.ProjectileBase;
|
||||
|
||||
public class ProjectileBaseRenderer<T extends ProjectileBase> extends Render {
|
||||
protected static FlexibleToolRenderer toolCoreRenderer = new FlexibleToolRenderer();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void doRender(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) {
|
||||
doRender((T)p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_);
|
||||
public void doRender(
|
||||
Entity p_76986_1_,
|
||||
double p_76986_2_,
|
||||
double p_76986_4_,
|
||||
double p_76986_6_,
|
||||
float p_76986_8_,
|
||||
float p_76986_9_) {
|
||||
doRender((T) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_);
|
||||
}
|
||||
|
||||
public void doRender(T entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) {
|
||||
@@ -27,7 +33,7 @@ public class ProjectileBaseRenderer<T extends ProjectileBase> extends Render {
|
||||
// So remember to read this from the rendering call up to this line
|
||||
|
||||
// can be overwritten in customRendering
|
||||
toolCoreRenderer.setDepth(1/32f);
|
||||
toolCoreRenderer.setDepth(1 / 32f);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
@@ -40,15 +46,13 @@ public class ProjectileBaseRenderer<T extends ProjectileBase> extends Render {
|
||||
customRendering(entity, x, y, z, p_76986_8_, p_76986_9_);
|
||||
|
||||
// arrow shake
|
||||
float f11 = (float)entity.arrowShake - p_76986_9_;
|
||||
if (f11 > 0.0F)
|
||||
{
|
||||
float f11 = (float) entity.arrowShake - p_76986_9_;
|
||||
if (f11 > 0.0F) {
|
||||
float f12 = -MathHelper.sin(f11 * 3.0F) * f11;
|
||||
GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
if(renderManager == null || renderManager.renderEngine == null)
|
||||
return;
|
||||
if (renderManager == null || renderManager.renderEngine == null) return;
|
||||
|
||||
// draw correct texture. not some weird block fragments.
|
||||
renderManager.renderEngine.bindTexture(TextureMap.locationItemsTexture);
|
||||
@@ -61,8 +65,7 @@ public class ProjectileBaseRenderer<T extends ProjectileBase> extends Render {
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void customRendering(T entity, double x, double y, double z, float p_76986_8_, float p_76986_9_)
|
||||
{
|
||||
public void customRendering(T entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) {
|
||||
// flip it, flop it, pop it, pull it, push it, rotate it, translate it, TECHNOLOGY
|
||||
|
||||
// rotate it into the direction we threw it
|
||||
@@ -80,13 +83,12 @@ public class ProjectileBaseRenderer<T extends ProjectileBase> extends Render {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture (Entity par1Entity)
|
||||
{
|
||||
protected ResourceLocation getEntityTexture(Entity par1Entity) {
|
||||
return this.func_110796_a((ProjectileBase) par1Entity);
|
||||
}
|
||||
|
||||
protected ResourceLocation func_110796_a (ProjectileBase par1ArrowEntity)
|
||||
{
|
||||
return this.renderManager.renderEngine.getResourceLocation(par1ArrowEntity.getEntityItem().getItemSpriteNumber());
|
||||
protected ResourceLocation func_110796_a(ProjectileBase par1ArrowEntity) {
|
||||
return this.renderManager.renderEngine.getResourceLocation(
|
||||
par1ArrowEntity.getEntityItem().getItemSpriteNumber());
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
package tconstruct.weaponry.client.entity;
|
||||
|
||||
import tconstruct.weaponry.entity.ShurikenEntity;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import tconstruct.weaponry.entity.ShurikenEntity;
|
||||
|
||||
public class ShurikenEntityRenderer extends ProjectileBaseRenderer<ShurikenEntity> {
|
||||
|
||||
@Override
|
||||
public void customRendering(ShurikenEntity entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) {
|
||||
public void customRendering(
|
||||
ShurikenEntity entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) {
|
||||
// make it smaller
|
||||
GL11.glScalef(0.6F, 0.6F, 0.6F);
|
||||
|
||||
@@ -23,8 +24,7 @@ public class ShurikenEntityRenderer extends ProjectileBaseRenderer<ShurikenEntit
|
||||
// shurikens spin around their center a lot. *spin*
|
||||
GL11.glRotatef(entity.spin, 0f, 0f, 1f);
|
||||
|
||||
|
||||
// also make it a bit thicker
|
||||
toolCoreRenderer.setDepth(1/20f);
|
||||
toolCoreRenderer.setDepth(1 / 20f);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,5 @@
|
||||
package tconstruct.weaponry.client.item;
|
||||
|
||||
import tconstruct.client.FlexibleToolRenderer;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import tconstruct.weaponry.ammo.ArrowAmmo;
|
||||
import tconstruct.weaponry.entity.ArrowEntity;
|
||||
import tconstruct.library.weaponry.ProjectileWeapon;
|
||||
import tconstruct.library.weaponry.IWindup;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
@@ -13,7 +7,12 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import tconstruct.weaponry.entity.BoltEntity;
|
||||
import tconstruct.client.FlexibleToolRenderer;
|
||||
import tconstruct.library.weaponry.IWindup;
|
||||
import tconstruct.library.weaponry.ProjectileWeapon;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import tconstruct.weaponry.ammo.ArrowAmmo;
|
||||
import tconstruct.weaponry.entity.ArrowEntity;
|
||||
|
||||
public class BowRenderer extends FlexibleToolRenderer {
|
||||
private static final ArrowEntity dummy = new ArrowEntity(null);
|
||||
@@ -25,41 +24,35 @@ public class BowRenderer extends FlexibleToolRenderer {
|
||||
GL11.glTranslatef(0.5f, 0.5f, 0);
|
||||
GL11.glScalef(0.5f, 0.5f, 0.5f);
|
||||
|
||||
if(type == ItemRenderType.EQUIPPED)
|
||||
{
|
||||
//GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
|
||||
if (type == ItemRenderType.EQUIPPED) {
|
||||
// GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
|
||||
GL11.glTranslatef(0.2F, -0.4F, 0.2f);
|
||||
GL11.glRotatef(-20.0F, 0.0F, 1.0F, 0.0F);
|
||||
//GL11.glScalef(f1, -f1, f1);
|
||||
//GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
|
||||
// GL11.glScalef(f1, -f1, f1);
|
||||
// GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
// windup animation
|
||||
if(type == ItemRenderType.EQUIPPED_FIRST_PERSON && player.isUsingItem())
|
||||
{
|
||||
if (type == ItemRenderType.EQUIPPED_FIRST_PERSON && player.isUsingItem()) {
|
||||
float progress = ((IWindup) item.getItem()).getWindupProgress(item, player);
|
||||
|
||||
//GL11.glScalef(1.2f, 1.2f, 1.2f);
|
||||
//float progress = ((IWindup) item.getItem()).getWindupProgress(item, Minecraft.getMinecraft().thePlayer);;
|
||||
// GL11.glScalef(1.2f, 1.2f, 1.2f);
|
||||
// float progress = ((IWindup) item.getItem()).getWindupProgress(item, Minecraft.getMinecraft().thePlayer);;
|
||||
GL11.glRotatef(-18.0F, 0.0F, 0.0F, 1.0F); // tilts the bow forward a bit
|
||||
GL11.glRotatef(-6.0F, 0.0F, 1.0F, 0.0F); // rotates the bow so it faces more forward
|
||||
GL11.glRotatef(8.0F, 1.0F, 0.0F, 0.0F); // rotates the bow forward
|
||||
GL11.glTranslatef(-0.9F, 0.2F, -1.0F);
|
||||
|
||||
|
||||
// this does the "zoom closer to the bow" thing
|
||||
GL11.glTranslatef(progress * -0.1f, progress * -0.125f, 0.0F);
|
||||
|
||||
|
||||
|
||||
// we're crazy, so.. render the arrow =D
|
||||
ItemStack ammo = ((ProjectileWeapon) item.getItem()).searchForAmmo(player, item); // we know it's a projectile weapon, it's a bow!
|
||||
if(ammo != null) {
|
||||
if(ammo.getItem() == Items.arrow)
|
||||
dummy.returnStack = ArrowAmmo.vanillaArrow;
|
||||
else
|
||||
dummy.returnStack = ammo;
|
||||
ItemStack ammo = ((ProjectileWeapon) item.getItem())
|
||||
.searchForAmmo(player, item); // we know it's a projectile weapon, it's a bow!
|
||||
if (ammo != null) {
|
||||
if (ammo.getItem() == Items.arrow) dummy.returnStack = ArrowAmmo.vanillaArrow;
|
||||
else dummy.returnStack = ammo;
|
||||
Render renderer = RenderManager.instance.getEntityClassRenderObject(ArrowEntity.class);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
@@ -79,16 +72,14 @@ public class BowRenderer extends FlexibleToolRenderer {
|
||||
renderer.doRender(dummy, 0, 0, 0, 0, 0);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
else if(type == ItemRenderType.EQUIPPED && player.isUsingItem())
|
||||
{
|
||||
} else if (type == ItemRenderType.EQUIPPED && player.isUsingItem()) {
|
||||
// we're crazy, so.. render the arrow =D
|
||||
ItemStack ammo = ((ProjectileWeapon) item.getItem()).searchForAmmo(player, item); // we know it's a projectile weapon, it's a bow!
|
||||
if(ammo != null) {
|
||||
if(ammo.getItem() == Items.arrow || !(ammo.getItem() instanceof ArrowAmmo))
|
||||
ItemStack ammo = ((ProjectileWeapon) item.getItem())
|
||||
.searchForAmmo(player, item); // we know it's a projectile weapon, it's a bow!
|
||||
if (ammo != null) {
|
||||
if (ammo.getItem() == Items.arrow || !(ammo.getItem() instanceof ArrowAmmo))
|
||||
dummy.returnStack = ArrowAmmo.vanillaArrow;
|
||||
else
|
||||
dummy.returnStack = ammo;
|
||||
else dummy.returnStack = ammo;
|
||||
Render renderer = RenderManager.instance.getEntityClassRenderObject(ArrowEntity.class);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
@@ -110,11 +101,8 @@ public class BowRenderer extends FlexibleToolRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(item.getItem() == TinkerWeaponry.longbow)
|
||||
GL11.glScalef(2.3f, 2.3f, 1.0f);
|
||||
else if(item.getItem() == TinkerWeaponry.shortbow)
|
||||
GL11.glScalef(1.7f, 1.7f, 1.0f);
|
||||
if (item.getItem() == TinkerWeaponry.longbow) GL11.glScalef(2.3f, 2.3f, 1.0f);
|
||||
else if (item.getItem() == TinkerWeaponry.shortbow) GL11.glScalef(1.7f, 1.7f, 1.0f);
|
||||
|
||||
GL11.glTranslatef(-0.5f, -0.5f, 0f);
|
||||
}
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
package tconstruct.weaponry.client.item;
|
||||
|
||||
import tconstruct.client.FlexibleToolRenderer;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import tconstruct.weaponry.ammo.BoltAmmo;
|
||||
import tconstruct.weaponry.entity.ArrowEntity;
|
||||
import tconstruct.weaponry.entity.BoltEntity;
|
||||
import tconstruct.weaponry.weapons.Crossbow;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import tconstruct.client.FlexibleToolRenderer;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import tconstruct.weaponry.ammo.BoltAmmo;
|
||||
import tconstruct.weaponry.entity.BoltEntity;
|
||||
import tconstruct.weaponry.weapons.Crossbow;
|
||||
|
||||
public class CrossbowRenderer extends FlexibleToolRenderer {
|
||||
private static final BoltEntity dummy = new BoltEntity(null);
|
||||
@@ -19,44 +18,41 @@ public class CrossbowRenderer extends FlexibleToolRenderer {
|
||||
@Override
|
||||
protected void specialAnimation(ItemRenderType type, ItemStack item) {
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
Crossbow crossbow = (Crossbow)item.getItem();
|
||||
Crossbow crossbow = (Crossbow) item.getItem();
|
||||
|
||||
GL11.glTranslatef(0.5f, 0.5f, 0);
|
||||
GL11.glScalef(0.5f, 0.5f, 0.5f);
|
||||
|
||||
GL11.glScalef(1.5f, 1.5f, 1.5f);
|
||||
|
||||
if(type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
|
||||
if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
|
||||
// we're crazy, so.. render the arrow =D
|
||||
ItemStack ammo = crossbow.getLoadedAmmo(item);
|
||||
|
||||
if(crossbow.isLoaded(item))
|
||||
{
|
||||
if (crossbow.isLoaded(item)) {
|
||||
GL11.glTranslatef(0.0f, 0.0f, -0.3f);
|
||||
GL11.glRotatef(80f, 1f, 0f, 0f);
|
||||
GL11.glRotatef(15f, 0f, 1f, 0f);
|
||||
GL11.glRotatef(-20, 0, 0, 1);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
GL11.glScalef(1.1f, 1.1f, 1.1f);
|
||||
GL11.glTranslatef(0.1f, 0f, 0f);
|
||||
GL11.glRotatef(50f, 1f, 0f, 0f);
|
||||
}
|
||||
|
||||
if(ammo != null && ammo.hasTagCompound()) {
|
||||
//float progress = crossbow.getWindupProgress(item, player);
|
||||
if (ammo != null && ammo.hasTagCompound()) {
|
||||
// float progress = crossbow.getWindupProgress(item, player);
|
||||
float progress = 1f;
|
||||
dummy.returnStack = ammo;
|
||||
if(!(ammo.getItem() instanceof BoltAmmo))
|
||||
dummy.returnStack = TinkerWeaponry.creativeBolt;
|
||||
if (!(ammo.getItem() instanceof BoltAmmo)) dummy.returnStack = TinkerWeaponry.creativeBolt;
|
||||
|
||||
Render renderer = RenderManager.instance.getEntityClassRenderObject(BoltEntity.class);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
// adjust position
|
||||
//GL11.glScalef(2, 2, 2); // bigger
|
||||
// GL11.glScalef(2, 2, 2); // bigger
|
||||
GL11.glRotatef(95, 0, 1, 0); // rotate it into the same direction as the bow
|
||||
//GL11.glRotatef(15, 0, 1, 0); // rotate it a bit more so it's not directly inside the bow
|
||||
// GL11.glRotatef(15, 0, 1, 0); // rotate it a bit more so it's not directly inside the bow
|
||||
GL11.glRotatef(-45, 1, 0, 0); // sprite is rotated by 45° in the graphics, correct that
|
||||
GL11.glTranslatef(0.05f, 0, 0); // same as the not-inside-bow-rotation
|
||||
|
||||
@@ -71,9 +67,7 @@ public class CrossbowRenderer extends FlexibleToolRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(type == ItemRenderType.EQUIPPED)
|
||||
{
|
||||
if (type == ItemRenderType.EQUIPPED) {
|
||||
GL11.glTranslatef(0.25f, 0, 0);
|
||||
GL11.glRotatef(45.0F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package tconstruct.weaponry.client.item;
|
||||
|
||||
import tconstruct.client.AmmoItemRenderer;
|
||||
import tconstruct.library.weaponry.IWindup;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import tconstruct.client.AmmoItemRenderer;
|
||||
import tconstruct.library.weaponry.IWindup;
|
||||
|
||||
public class JavelinRenderer extends AmmoItemRenderer {
|
||||
|
||||
@@ -13,16 +13,15 @@ public class JavelinRenderer extends AmmoItemRenderer {
|
||||
GL11.glTranslatef(0.5f, 0.5f, 0);
|
||||
GL11.glScalef(0.5f, 0.5f, 0.5f);
|
||||
|
||||
float progress = ((IWindup)item.getItem()).getWindupProgress(item, Minecraft.getMinecraft().thePlayer); // 0.5 while not winding
|
||||
float progress = ((IWindup) item.getItem())
|
||||
.getWindupProgress(item, Minecraft.getMinecraft().thePlayer); // 0.5 while not winding
|
||||
|
||||
if(type == ItemRenderType.EQUIPPED)
|
||||
GL11.glRotatef(90, 0, 0, 1);
|
||||
if (type == ItemRenderType.EQUIPPED) GL11.glRotatef(90, 0, 0, 1);
|
||||
|
||||
GL11.glRotatef(-45, 0, 0, 1);
|
||||
GL11.glScalef(1.5F, 2F, 1.5F);
|
||||
|
||||
if(type == ItemRenderType.EQUIPPED_FIRST_PERSON)
|
||||
GL11.glTranslatef(0, progress * 0.4f, 0);
|
||||
if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) GL11.glTranslatef(0, progress * 0.4f, 0);
|
||||
GL11.glRotatef(45, 0, 0, 1);
|
||||
|
||||
GL11.glTranslatef(-0.5f, -0.5f, 0f);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package tconstruct.weaponry.client.item;
|
||||
|
||||
import tconstruct.client.AmmoItemRenderer;
|
||||
import tconstruct.library.weaponry.IWindup;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||
@@ -9,6 +7,8 @@ import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import tconstruct.client.AmmoItemRenderer;
|
||||
import tconstruct.library.weaponry.IWindup;
|
||||
|
||||
public class ThrowingKnifeRenderer extends AmmoItemRenderer {
|
||||
private static Minecraft mc = Minecraft.getMinecraft();
|
||||
@@ -18,15 +18,15 @@ public class ThrowingKnifeRenderer extends AmmoItemRenderer {
|
||||
GL11.glTranslatef(0.5f, 0.5f, 0);
|
||||
GL11.glScalef(0.5f, 0.5f, 0.5f);
|
||||
|
||||
float progress = ((IWindup)item.getItem()).getWindupProgress(item, mc.thePlayer);
|
||||
float progress = ((IWindup) item.getItem()).getWindupProgress(item, mc.thePlayer);
|
||||
|
||||
if(type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
|
||||
if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(2.5f, 2.5f, 2.5f);
|
||||
// rotate it, otherwise it's drawn over our item :(
|
||||
GL11.glTranslatef(0.5f, -0.6f, 0f);
|
||||
//GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
|
||||
//GL11.glRotatef(-85.0F, 0.0F, 0.0F, 1.0F);
|
||||
// GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
|
||||
// GL11.glRotatef(-85.0F, 0.0F, 0.0F, 1.0F);
|
||||
|
||||
GL11.glRotatef(-25.0F, 0.0F, 0.0F, 1.0F);
|
||||
|
||||
@@ -41,22 +41,21 @@ public class ThrowingKnifeRenderer extends AmmoItemRenderer {
|
||||
mc.getTextureManager().bindTexture(TextureMap.locationItemsTexture);
|
||||
|
||||
// rotate it aroooound
|
||||
//GL11.glRotatef(-180, 0, 0, 1);
|
||||
//GL11.glTranslatef(0.5f, -0.6f, 0f);
|
||||
//GL11.glRotatef(-25.0F, 0.0F, 0.0F, 1.0F);
|
||||
// GL11.glRotatef(-180, 0, 0, 1);
|
||||
// GL11.glTranslatef(0.5f, -0.6f, 0f);
|
||||
// GL11.glRotatef(-25.0F, 0.0F, 0.0F, 1.0F);
|
||||
|
||||
GL11.glTranslatef(1.3f, 0.4f, -0.2f);
|
||||
|
||||
//GL11.glTranslatef(-0.5f, 0.6f, 0f);
|
||||
//GL11.glTranslatef(0.f, 1f, 0f);
|
||||
//GL11.glTranslatef(progress * -1.5f, 0.0f, 0f);
|
||||
// GL11.glTranslatef(-0.5f, 0.6f, 0f);
|
||||
// GL11.glTranslatef(0.f, 1f, 0f);
|
||||
// GL11.glTranslatef(progress * -1.5f, 0.0f, 0f);
|
||||
GL11.glTranslatef(0.0f, -1.85f, 0f);
|
||||
GL11.glRotatef(progress * 35.0F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glTranslatef(0.0f, 1.85f, 0f);
|
||||
GL11.glRotatef(progress * -15.0F, 0.0F, 0.0F, 1.0F);
|
||||
//GL11.glTranslatef(-0.f, -1f, 0f);
|
||||
//GL11.glTranslatef(0.5f, -0.6f, 0f);
|
||||
|
||||
// GL11.glTranslatef(-0.f, -1f, 0f);
|
||||
// GL11.glTranslatef(0.5f, -0.6f, 0f);
|
||||
|
||||
GL11.glScalef(1.5f, 1.5f, 1.5f);
|
||||
|
||||
@@ -65,9 +64,7 @@ public class ThrowingKnifeRenderer extends AmmoItemRenderer {
|
||||
GL11.glRotatef(-25.0F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
if(type == ItemRenderType.EQUIPPED)
|
||||
GL11.glRotatef(-180, 0, 0, 1);
|
||||
|
||||
if (type == ItemRenderType.EQUIPPED) GL11.glRotatef(-180, 0, 0, 1);
|
||||
|
||||
GL11.glTranslatef(-0.5f, -0.5f, 0f);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package tconstruct.weaponry.entity;
|
||||
|
||||
import tconstruct.library.entity.ProjectileBase;
|
||||
import tconstruct.library.util.PiercingArrowDamage;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -10,7 +8,9 @@ import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.entity.ProjectileBase;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.library.util.PiercingArrowDamage;
|
||||
|
||||
public class ArrowEntity extends ProjectileBase {
|
||||
public ArrowEntity(World world) {
|
||||
@@ -33,17 +33,18 @@ public class ArrowEntity extends ProjectileBase {
|
||||
@Override
|
||||
protected double getSlowdown() {
|
||||
// we could use the fletchling material for the slowdown, hm
|
||||
// note: not done because fletchlings also balance amount you get now. Rather use slowdown for different projectile types
|
||||
// note: not done because fletchlings also balance amount you get now. Rather use slowdown for different
|
||||
// projectile types
|
||||
return super.getSlowdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double getGravity() {
|
||||
if(returnStack == null || !returnStack.hasTagCompound())
|
||||
return super.getGravity();
|
||||
if (returnStack == null || !returnStack.hasTagCompound()) return super.getGravity();
|
||||
|
||||
float mass = returnStack.getTagCompound().getCompoundTag("InfiTool").getFloat("Mass");
|
||||
mass /= 36f; // why 36? simple because it's roughly 0.05 with flint head and wooden arrow shaft! Yes, that's the only reason.
|
||||
mass /= 36f; // why 36? simple because it's roughly 0.05 with flint head and wooden arrow shaft! Yes, that's the
|
||||
// only reason.
|
||||
return mass;
|
||||
}
|
||||
|
||||
@@ -51,15 +52,13 @@ public class ArrowEntity extends ProjectileBase {
|
||||
public void onHitBlock(MovingObjectPosition movingobjectposition) {
|
||||
super.onHitBlock(movingobjectposition);
|
||||
|
||||
if(defused)
|
||||
return;
|
||||
if (defused) return;
|
||||
|
||||
if(returnStack == null || !returnStack.hasTagCompound())
|
||||
return;
|
||||
if (returnStack == null || !returnStack.hasTagCompound()) return;
|
||||
|
||||
// we might break! oh noez!
|
||||
float chance = returnStack.getTagCompound().getCompoundTag("InfiTool").getFloat("BreakChance");
|
||||
if(chance > TConstruct.random.nextFloat()) {
|
||||
if (chance > TConstruct.random.nextFloat()) {
|
||||
this.setDead();
|
||||
this.playSound("random.break", 1.0F, 1.5F / (this.rand.nextFloat() * 0.2F + 0.9F));
|
||||
}
|
||||
@@ -77,42 +76,40 @@ public class ArrowEntity extends ProjectileBase {
|
||||
|
||||
// returns true if it was successful
|
||||
@Override
|
||||
public boolean dealDamage(float damage, ToolCore ammo, NBTTagCompound tags, Entity entityHit)
|
||||
{
|
||||
public boolean dealDamage(float damage, ToolCore ammo, NBTTagCompound tags, Entity entityHit) {
|
||||
boolean dealtDamage = false;
|
||||
|
||||
//Minecraft.getMinecraft().thePlayer.sendChatMessage("Damage/Weight: " + damage + " - " + tags.getFloat("Mass"));
|
||||
// Minecraft.getMinecraft().thePlayer.sendChatMessage("Damage/Weight: " + damage + " - " +
|
||||
// tags.getFloat("Mass"));
|
||||
|
||||
// we take the weight, and shift the damage done towards armor piercing, the more weight the arrow/bolt has!
|
||||
float shift = (tags.getFloat("Mass") - 0.7f)*armorPenetrationModifier();
|
||||
float shift = (tags.getFloat("Mass") - 0.7f) * armorPenetrationModifier();
|
||||
|
||||
if(shift < 0)
|
||||
shift = 0;
|
||||
if(shift > damage)
|
||||
shift = damage;
|
||||
if (shift < 0) shift = 0;
|
||||
if (shift > damage) shift = damage;
|
||||
|
||||
damage -= shift;
|
||||
|
||||
// deal regular damage
|
||||
if(damage > 0)
|
||||
dealtDamage = super.dealDamage(damage, ammo, tags, entityHit);
|
||||
if (damage > 0) dealtDamage = super.dealDamage(damage, ammo, tags, entityHit);
|
||||
|
||||
// deal armor piercing damage
|
||||
if(shift > 0) {
|
||||
if (shift > 0) {
|
||||
DamageSource damagesource;
|
||||
if (this.shootingEntity == null)
|
||||
damagesource = new PiercingArrowDamage("arrow", this, this);
|
||||
else
|
||||
damagesource = new PiercingArrowDamage("arrow", this, this.shootingEntity);
|
||||
if (this.shootingEntity == null) damagesource = new PiercingArrowDamage("arrow", this, this);
|
||||
else damagesource = new PiercingArrowDamage("arrow", this, this.shootingEntity);
|
||||
|
||||
//Minecraft.getMinecraft().thePlayer.sendChatMessage("Piercing Damage: " + shift);
|
||||
// Minecraft.getMinecraft().thePlayer.sendChatMessage("Piercing Damage: " + shift);
|
||||
|
||||
// piercing damage does not affect wether the entity was hit (return value), since it should go through always
|
||||
// piercing damage does not affect wether the entity was hit (return value), since it should go through
|
||||
// always
|
||||
entityHit.attackEntityFrom(damagesource, shift);
|
||||
}
|
||||
|
||||
return dealtDamage;
|
||||
}
|
||||
|
||||
protected float armorPenetrationModifier() { return 1.0f; }
|
||||
protected float armorPenetrationModifier() {
|
||||
return 1.0f;
|
||||
}
|
||||
}
|
||||
@@ -22,8 +22,7 @@ public class BoltEntity extends ArrowEntity {
|
||||
|
||||
@Override
|
||||
protected void updateInAir() {
|
||||
if(this.ticksInAir > 1)
|
||||
this.setIsCritical(true);
|
||||
if (this.ticksInAir > 1) this.setIsCritical(true);
|
||||
|
||||
super.updateInAir();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package tconstruct.weaponry.entity;
|
||||
|
||||
import tconstruct.library.entity.ProjectileBase;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.entity.ProjectileBase;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
|
||||
public class JavelinEntity extends ProjectileBase {
|
||||
public int roll = 0;
|
||||
@@ -25,8 +25,7 @@ public class JavelinEntity extends ProjectileBase {
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
// you turn me right round baby
|
||||
if(this.ticksInGround == 0)
|
||||
roll = (roll + 13) % 360;
|
||||
if (this.ticksInGround == 0) roll = (roll + 13) % 360;
|
||||
|
||||
super.onUpdate();
|
||||
}
|
||||
@@ -39,7 +38,9 @@ public class JavelinEntity extends ProjectileBase {
|
||||
roll = TinkerWeaponry.random.nextInt(360);
|
||||
}
|
||||
|
||||
protected double getGravity() { return 0.07; }
|
||||
protected double getGravity() {
|
||||
return 0.07;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double getStuckDepth() {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package tconstruct.weaponry.entity;
|
||||
|
||||
import tconstruct.library.entity.ProjectileBase;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.entity.ProjectileBase;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
|
||||
public class ShurikenEntity extends ProjectileBase {
|
||||
public int spin = 0;
|
||||
@@ -32,8 +32,7 @@ public class ShurikenEntity extends ProjectileBase {
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
// you turn me right round baby
|
||||
if(this.ticksInGround == 0)
|
||||
spin = (spin + 33) % 360;
|
||||
if (this.ticksInGround == 0) spin = (spin + 33) % 360;
|
||||
|
||||
super.onUpdate();
|
||||
}
|
||||
@@ -43,13 +42,14 @@ public class ShurikenEntity extends ProjectileBase {
|
||||
super.readSpawnData(data);
|
||||
|
||||
// this is only relevant clientside only, so we don't actually have it on the server
|
||||
//rollAngle = (TinkerWeaponry.random.nextInt(3)-1)*45 + TinkerWeaponry.random.nextInt(30)-15;
|
||||
// rollAngle = (TinkerWeaponry.random.nextInt(3)-1)*45 + TinkerWeaponry.random.nextInt(30)-15;
|
||||
spin = TinkerWeaponry.random.nextInt(360);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double getGravity() {
|
||||
return (this.ticksExisted/8) * 0.018d; // integer division. so the first 20 ticks it will have no gravity at all.
|
||||
return (this.ticksExisted / 8)
|
||||
* 0.018d; // integer division. so the first 20 ticks it will have no gravity at all.
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package tconstruct.weaponry.entity;
|
||||
|
||||
import tconstruct.library.entity.ProjectileBase;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.entity.ProjectileBase;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
|
||||
public class ThrowingKnifeEntity extends ProjectileBase {
|
||||
public ThrowingKnifeEntity(World world) {
|
||||
|
||||
@@ -2,17 +2,15 @@ package tconstruct.weaponry.items;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
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 tconstruct.items.tools.Broadsword;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.util.Reference;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Boneana extends Broadsword {
|
||||
private IIcon brokenIcon;
|
||||
|
||||
@@ -25,11 +23,9 @@ public class Boneana extends Broadsword {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(ItemStack stack, int renderPass) {
|
||||
if(!stack.hasTagCompound() || !stack.getTagCompound().hasKey("InfiTool"))
|
||||
return emptyIcon;
|
||||
if (!stack.hasTagCompound() || !stack.getTagCompound().hasKey("InfiTool")) return emptyIcon;
|
||||
|
||||
if(stack.getTagCompound().getCompoundTag("InfiTool").getBoolean("Broken"))
|
||||
return brokenIcon;
|
||||
if (stack.getTagCompound().getCompoundTag("InfiTool").getBoolean("Broken")) return brokenIcon;
|
||||
return itemIcon;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +1,17 @@
|
||||
package tconstruct.weaponry.items;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import tconstruct.library.client.TConstructClientRegistry;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import tconstruct.util.Reference;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import tconstruct.weaponry.ammo.ArrowAmmo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GlassArrows extends ArrowAmmo {
|
||||
public GlassArrows() {
|
||||
super();
|
||||
@@ -35,13 +29,11 @@ public class GlassArrows extends ArrowAmmo {
|
||||
ItemStack handleStack = new ItemStack(getHandleItem(), 1, 0); // wooden shaft
|
||||
ItemStack accessoryStack = new ItemStack(getAccessoryItem(), 1, 0); // feather fletchling
|
||||
|
||||
ItemStack tool = ToolBuilder.instance.buildTool(headStack, handleStack, accessoryStack, null, this.getLocalizedToolName());
|
||||
if (tool != null)
|
||||
{
|
||||
ItemStack tool = ToolBuilder.instance.buildTool(
|
||||
headStack, handleStack, accessoryStack, null, this.getLocalizedToolName());
|
||||
if (tool != null) {
|
||||
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
|
||||
}
|
||||
else
|
||||
return;
|
||||
} else return;
|
||||
|
||||
// now turn it into legendary glass arrows!
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
package tconstruct.weaponry.items;
|
||||
|
||||
import tconstruct.util.Reference;
|
||||
import java.util.List;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.tools.items.Pattern;
|
||||
|
||||
import java.util.List;
|
||||
import tconstruct.util.Reference;
|
||||
|
||||
public class WeaponryPattern extends Pattern {
|
||||
private static final String[] patternName = new String[] { "shuriken", "crossbowlimb", "crossbowbody", "bowlimb" };
|
||||
private static final String[] patternName = new String[] {"shuriken", "crossbowlimb", "crossbowbody", "bowlimb"};
|
||||
|
||||
public WeaponryPattern(String patternType, String name) {
|
||||
super(patternName, getPatternNames(patternName, patternType), "patterns/");
|
||||
@@ -17,19 +16,15 @@ public class WeaponryPattern extends Pattern {
|
||||
this.setUnlocalizedName(Reference.prefix(name));
|
||||
}
|
||||
|
||||
public static String[] getPatternNames (String[] patternName, String partType)
|
||||
{
|
||||
public static String[] getPatternNames(String[] patternName, String partType) {
|
||||
String[] names = new String[patternName.length];
|
||||
for (int i = 0; i < patternName.length; i++)
|
||||
names[i] = partType + patternName[i];
|
||||
for (int i = 0; i < patternName.length; i++) names[i] = partType + patternName[i];
|
||||
return names;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems (Item b, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int i = 0; i < patternName.length; i++)
|
||||
{
|
||||
public void getSubItems(Item b, CreativeTabs tab, List list) {
|
||||
for (int i = 0; i < patternName.length; i++) {
|
||||
// if (i != 23)
|
||||
list.add(new ItemStack(b, 1, i));
|
||||
}
|
||||
@@ -37,12 +32,15 @@ public class WeaponryPattern extends Pattern {
|
||||
|
||||
@Override
|
||||
public int getPatternCost(ItemStack pattern) {
|
||||
switch(pattern.getItemDamage())
|
||||
{
|
||||
case 0: return 1; // shuriken
|
||||
case 1: return 8; // crossbow limb
|
||||
case 2: return 10; // crossbow body
|
||||
case 3: return 3; // bowlimb
|
||||
switch (pattern.getItemDamage()) {
|
||||
case 0:
|
||||
return 1; // shuriken
|
||||
case 1:
|
||||
return 8; // crossbow limb
|
||||
case 2:
|
||||
return 10; // crossbow body
|
||||
case 3:
|
||||
return 3; // bowlimb
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
package tconstruct.weaponry.items;
|
||||
|
||||
import tconstruct.util.Reference;
|
||||
import java.util.List;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.tools.items.Pattern;
|
||||
|
||||
import java.util.List;
|
||||
import tconstruct.util.Reference;
|
||||
|
||||
public class WeaponryPatternClay extends Pattern {
|
||||
private static final String[] patternName = new String[] { "", "", "", "bowlimb" };
|
||||
private static final String[] patternName = new String[] {"", "", "", "bowlimb"};
|
||||
|
||||
public WeaponryPatternClay(String patternType, String name) {
|
||||
super(patternName, getPatternNames(patternName, patternType), "patterns/");
|
||||
@@ -17,37 +16,33 @@ public class WeaponryPatternClay extends Pattern {
|
||||
this.setUnlocalizedName(Reference.prefix(name));
|
||||
}
|
||||
|
||||
public static String[] getPatternNames (String[] patternName, String partType)
|
||||
{
|
||||
public static String[] getPatternNames(String[] patternName, String partType) {
|
||||
String[] names = new String[patternName.length];
|
||||
for (int i = 0; i < patternName.length; i++)
|
||||
if (!(patternName[i].equals("")))
|
||||
names[i] = partType + patternName[i];
|
||||
else
|
||||
names[i] = "";
|
||||
if (!(patternName[i].equals(""))) names[i] = partType + patternName[i];
|
||||
else names[i] = "";
|
||||
return names;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems (Item b, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int i = 0; i < patternName.length; i++)
|
||||
{
|
||||
public void getSubItems(Item b, CreativeTabs tab, List list) {
|
||||
for (int i = 0; i < patternName.length; i++) {
|
||||
// if (i != 23)
|
||||
if (!(patternName[i].equals("")))
|
||||
list.add(new ItemStack(b, 1, i));
|
||||
if (!(patternName[i].equals(""))) list.add(new ItemStack(b, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getPatternCost(ItemStack pattern) {
|
||||
switch(pattern.getItemDamage())
|
||||
{
|
||||
case 0: return 1; // shuriken
|
||||
case 1: return 8; // crossbow limb
|
||||
case 2: return 10; // crossbow body
|
||||
case 3: return 3; // bowlimb
|
||||
switch (pattern.getItemDamage()) {
|
||||
case 0:
|
||||
return 1; // shuriken
|
||||
case 1:
|
||||
return 8; // crossbow limb
|
||||
case 2:
|
||||
return 10; // crossbow body
|
||||
case 3:
|
||||
return 3; // bowlimb
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,8 @@
|
||||
package tconstruct.weaponry.weapons;
|
||||
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.init.Items;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import tconstruct.weaponry.ammo.BoltAmmo;
|
||||
import tconstruct.weaponry.entity.BoltEntity;
|
||||
import tconstruct.library.weaponry.AmmoItem;
|
||||
import tconstruct.library.weaponry.ProjectileWeapon;
|
||||
import tconstruct.util.Reference;
|
||||
import tconstruct.library.weaponry.IAmmo;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import java.util.List;
|
||||
import mods.battlegear2.api.core.InventoryPlayerBattle;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
@@ -20,13 +11,17 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.library.weaponry.AmmoItem;
|
||||
import tconstruct.library.weaponry.IAmmo;
|
||||
import tconstruct.library.weaponry.ProjectileWeapon;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import mods.battlegear2.api.core.InventoryPlayerBattle;
|
||||
|
||||
import java.util.List;
|
||||
import tconstruct.util.Reference;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import tconstruct.weaponry.ammo.BoltAmmo;
|
||||
import tconstruct.weaponry.entity.BoltEntity;
|
||||
|
||||
public class Crossbow extends ProjectileWeapon {
|
||||
public Crossbow() {
|
||||
@@ -34,29 +29,25 @@ public class Crossbow extends ProjectileWeapon {
|
||||
this.setMaxDamage(100);
|
||||
}
|
||||
|
||||
public boolean isLoaded(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack.hasTagCompound())
|
||||
public boolean isLoaded(ItemStack itemStack) {
|
||||
if (itemStack.hasTagCompound())
|
||||
return isLoaded(itemStack.getTagCompound().getCompoundTag("InfiTool"));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isLoaded(NBTTagCompound tags)
|
||||
{
|
||||
public boolean isLoaded(NBTTagCompound tags) {
|
||||
return tags.getBoolean("Loaded");
|
||||
}
|
||||
|
||||
public ItemStack getLoadedAmmo(ItemStack itemStack)
|
||||
{
|
||||
public ItemStack getLoadedAmmo(ItemStack itemStack) {
|
||||
NBTTagCompound tags = itemStack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if(!isLoaded(tags))
|
||||
return null;
|
||||
if (!isLoaded(tags)) return null;
|
||||
|
||||
ItemStack ammo = ItemStack.loadItemStackFromNBT(tags.getCompoundTag("LoadedItem"));
|
||||
|
||||
// prevent crashes from remapping corruptions..
|
||||
if(ammo != null && ammo.getItem() != null && ammo.getItem() != TinkerWeaponry.boltAmmo) {
|
||||
if (ammo != null && ammo.getItem() != null && ammo.getItem() != TinkerWeaponry.boltAmmo) {
|
||||
tags.removeTag("LoadedItem");
|
||||
ammo = null;
|
||||
}
|
||||
@@ -74,13 +65,10 @@ public class Crossbow extends ProjectileWeapon {
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
|
||||
// unload on shift-rightclick
|
||||
if(player.isSneaking())
|
||||
if(unload(stack, player, tags))
|
||||
return stack;
|
||||
if (player.isSneaking()) if (unload(stack, player, tags)) return stack;
|
||||
|
||||
// loaded
|
||||
if(tags.getBoolean("Loaded"))
|
||||
fire(stack, world, player);
|
||||
if (tags.getBoolean("Loaded")) fire(stack, world, player);
|
||||
|
||||
// reload (automatically after firing)
|
||||
initiateReload(stack, player, tags);
|
||||
@@ -92,23 +80,18 @@ public class Crossbow extends ProjectileWeapon {
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) {
|
||||
super.onUpdate(stack, world, entity, par4, par5);
|
||||
|
||||
if(!stack.hasTagCompound())
|
||||
return;
|
||||
if (!stack.hasTagCompound()) return;
|
||||
|
||||
if(!(entity instanceof EntityPlayer))
|
||||
return;
|
||||
if (!(entity instanceof EntityPlayer)) return;
|
||||
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
if(player.inventory.getCurrentItem() != stack)
|
||||
return;
|
||||
if (player.inventory.getCurrentItem() != stack) return;
|
||||
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if(tags.hasKey("Reloading"))
|
||||
{
|
||||
if (tags.hasKey("Reloading")) {
|
||||
int timeLeft = tags.getInteger("Reloading");
|
||||
timeLeft--;
|
||||
if(timeLeft > 0)
|
||||
tags.setInteger("Reloading", timeLeft);
|
||||
if (timeLeft > 0) tags.setInteger("Reloading", timeLeft);
|
||||
else {
|
||||
tags.removeTag("Reloading");
|
||||
reload(stack, player, world, tags);
|
||||
@@ -121,58 +104,49 @@ public class Crossbow extends ProjectileWeapon {
|
||||
NBTTagCompound tags = itemStack.getTagCompound().getCompoundTag("InfiTool");
|
||||
|
||||
// loaded, full accuracy
|
||||
if(tags.getBoolean("Loaded"))
|
||||
return 1.0f;
|
||||
if (tags.getBoolean("Loaded")) return 1.0f;
|
||||
// not loaded, but reloading -> progress
|
||||
else if(tags.hasKey("Reloading"))
|
||||
return 1.0f - ((float)tags.getInteger("Reloading"))/((float)getWindupTime(itemStack));
|
||||
else if (tags.hasKey("Reloading"))
|
||||
return 1.0f - ((float) tags.getInteger("Reloading")) / ((float) getWindupTime(itemStack));
|
||||
// not loaded and not reloading -> no accuracy!
|
||||
else
|
||||
return 0.0f;
|
||||
else return 0.0f;
|
||||
}
|
||||
|
||||
public void initiateReload(ItemStack stack, EntityPlayer player, NBTTagCompound tags) {
|
||||
if(tags.getBoolean("Broken"))
|
||||
return;
|
||||
if (tags.getBoolean("Broken")) return;
|
||||
|
||||
// has ammo?
|
||||
if(searchForAmmo(player, stack) != null)
|
||||
if(!tags.hasKey("Reloading"))
|
||||
if (searchForAmmo(player, stack) != null)
|
||||
if (!tags.hasKey("Reloading"))
|
||||
// start reloading
|
||||
tags.setInteger("Reloading", getWindupTime(stack));
|
||||
}
|
||||
|
||||
// called after the reloading is done. Does the actual loading
|
||||
public boolean reload(ItemStack weapon, EntityPlayer player, World world, NBTTagCompound tags)
|
||||
{
|
||||
public boolean reload(ItemStack weapon, EntityPlayer player, World world, NBTTagCompound tags) {
|
||||
ItemStack ammo = searchForAmmo(player, weapon);
|
||||
// no ammo present
|
||||
if(ammo == null)
|
||||
return false;
|
||||
if (ammo == null) return false;
|
||||
|
||||
// already loaded
|
||||
if(tags.getBoolean("Loaded"))
|
||||
return false;
|
||||
if (tags.getBoolean("Loaded")) return false;
|
||||
|
||||
ItemStack copy = ammo.copy();
|
||||
copy.getTagCompound().getCompoundTag("InfiTool").setInteger("Ammo", 1);
|
||||
|
||||
|
||||
// load ammo into nbt
|
||||
NBTTagCompound ammotag = new NBTTagCompound();
|
||||
copy.writeToNBT(ammotag);
|
||||
//ammotag.getCompoundTag("tag"; // set ammo count to 1
|
||||
// ammotag.getCompoundTag("tag"; // set ammo count to 1
|
||||
tags.setTag("LoadedItem", ammotag);
|
||||
tags.setBoolean("Loaded", true);
|
||||
|
||||
// remove loaded item
|
||||
if(ammo.getItem() instanceof IAmmo)
|
||||
((IAmmo) ammo.getItem()).consumeAmmo(1, ammo);
|
||||
if (ammo.getItem() instanceof IAmmo) ((IAmmo) ammo.getItem()).consumeAmmo(1, ammo);
|
||||
else {
|
||||
if(Loader.isModLoaded("battlegear2")) {
|
||||
((InventoryPlayerBattle)player.inventory).consumeInventoryItem(ammo.getItem());
|
||||
}
|
||||
else {
|
||||
if (Loader.isModLoaded("battlegear2")) {
|
||||
((InventoryPlayerBattle) player.inventory).consumeInventoryItem(ammo.getItem());
|
||||
} else {
|
||||
player.inventory.consumeInventoryItem(ammo.getItem());
|
||||
}
|
||||
}
|
||||
@@ -183,19 +157,16 @@ public class Crossbow extends ProjectileWeapon {
|
||||
}
|
||||
|
||||
// stops reloading, or unloads the ammo if it has been loaded
|
||||
public boolean unload(ItemStack weapon, EntityPlayer player, NBTTagCompound tags)
|
||||
{
|
||||
public boolean unload(ItemStack weapon, EntityPlayer player, NBTTagCompound tags) {
|
||||
// is reloading?
|
||||
if(tags.hasKey("Reloading"))
|
||||
{
|
||||
if (tags.hasKey("Reloading")) {
|
||||
// stop it
|
||||
tags.removeTag("Reloading");
|
||||
return true;
|
||||
}
|
||||
|
||||
// loaded?
|
||||
if(tags.getBoolean("Loaded"))
|
||||
{
|
||||
if (tags.getBoolean("Loaded")) {
|
||||
// unload
|
||||
ItemStack loadedItem = ItemStack.loadItemStackFromNBT(tags.getCompoundTag("LoadedItem"));
|
||||
AmmoItem ammo = (AmmoItem) loadedItem.getItem();
|
||||
@@ -214,12 +185,10 @@ public class Crossbow extends ProjectileWeapon {
|
||||
}
|
||||
|
||||
// called if loaded to SHOOOOOOOT
|
||||
public void fire(ItemStack weapon, World world, EntityPlayer player)
|
||||
{
|
||||
public void fire(ItemStack weapon, World world, EntityPlayer player) {
|
||||
NBTTagCompound tags = weapon.getTagCompound().getCompoundTag("InfiTool");
|
||||
// not loaded
|
||||
if(!tags.getBoolean("Loaded"))
|
||||
return;
|
||||
if (!tags.getBoolean("Loaded")) return;
|
||||
|
||||
// get ammo
|
||||
ItemStack ammo = ItemStack.loadItemStackFromNBT(tags.getCompoundTag("LoadedItem"));
|
||||
@@ -229,37 +198,34 @@ public class Crossbow extends ProjectileWeapon {
|
||||
tags.removeTag("LoadedItem");
|
||||
|
||||
// safety
|
||||
if(ammo == null)
|
||||
return;
|
||||
if (ammo == null) return;
|
||||
|
||||
float projectileSpeed = getProjectileSpeed(weapon);
|
||||
float windup = getWindupTime(weapon); // max windup time
|
||||
float accuracy = getAccuracy(weapon, (int)windup);
|
||||
float accuracy = getAccuracy(weapon, (int) windup);
|
||||
|
||||
Entity projectile = createProjectile(ammo, world, player, projectileSpeed, accuracy, 1.0f);
|
||||
|
||||
int reinforced = 0;
|
||||
|
||||
if (tags.hasKey("Unbreaking"))
|
||||
reinforced = tags.getInteger("Unbreaking");
|
||||
if (tags.hasKey("Unbreaking")) reinforced = tags.getInteger("Unbreaking");
|
||||
|
||||
if (random.nextInt(10) < 10 - reinforced)
|
||||
AbilityHelper.damageTool(weapon, 1, player, false);
|
||||
if (random.nextInt(10) < 10 - reinforced) AbilityHelper.damageTool(weapon, 1, player, false);
|
||||
|
||||
playFiringSound(world, player, weapon, ammo, projectileSpeed, accuracy);
|
||||
|
||||
// thwock
|
||||
if (!world.isRemote)
|
||||
world.spawnEntityInWorld(projectile);
|
||||
if (!world.isRemote) world.spawnEntityInWorld(projectile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack searchForAmmo(EntityPlayer player, ItemStack weapon) {
|
||||
// arrow priority: hotbar > inventory, tinker arrows > regular arrows
|
||||
if(Loader.isModLoaded("battlegear2")){
|
||||
if (Loader.isModLoaded("battlegear2")) {
|
||||
ItemStack offhand = ((InventoryPlayerBattle) player.inventory).getCurrentOffhandWeapon();
|
||||
if(offhand != null && (offhand.getItem() instanceof BoltAmmo) && ((IAmmo) offhand.getItem()).getAmmoCount(offhand) > 0)
|
||||
{
|
||||
if (offhand != null
|
||||
&& (offhand.getItem() instanceof BoltAmmo)
|
||||
&& ((IAmmo) offhand.getItem()).getAmmoCount(offhand) > 0) {
|
||||
return offhand;
|
||||
}
|
||||
}
|
||||
@@ -267,27 +233,24 @@ public class Crossbow extends ProjectileWeapon {
|
||||
ItemStack[] inventory = player.inventory.mainInventory;
|
||||
|
||||
// check hotbar for tinker arrows
|
||||
for(int i = 0; i < inventory.length; i++)
|
||||
{
|
||||
for (int i = 0; i < inventory.length; i++) {
|
||||
ItemStack stack = inventory[i];
|
||||
if(stack == null)
|
||||
continue;
|
||||
if(!(stack.getItem() instanceof BoltAmmo))
|
||||
continue;
|
||||
if(((IAmmo) stack.getItem()).getAmmoCount(stack) <= 0)
|
||||
continue;
|
||||
if (stack == null) continue;
|
||||
if (!(stack.getItem() instanceof BoltAmmo)) continue;
|
||||
if (((IAmmo) stack.getItem()).getAmmoCount(stack) <= 0) continue;
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
if(player.capabilities.isCreativeMode && TinkerWeaponry.creativeBolt != null)
|
||||
if (player.capabilities.isCreativeMode && TinkerWeaponry.creativeBolt != null)
|
||||
return TinkerWeaponry.creativeBolt.copy();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Entity createProjectile(ItemStack ammo, World world, EntityPlayer player, float speed, float accuracy, float windup) {
|
||||
protected Entity createProjectile(
|
||||
ItemStack ammo, World world, EntityPlayer player, float speed, float accuracy, float windup) {
|
||||
EntityArrow arrow;
|
||||
|
||||
ItemStack reference = ammo.copy();
|
||||
@@ -295,8 +258,7 @@ public class Crossbow extends ProjectileWeapon {
|
||||
reference.getTagCompound().getCompoundTag("InfiTool").setInteger("Ammo", 1);
|
||||
arrow = new BoltEntity(world, player, speed, accuracy, reference);
|
||||
|
||||
if(player.capabilities.isCreativeMode)
|
||||
arrow.canBePickedUp = 2;
|
||||
if (player.capabilities.isCreativeMode) arrow.canBePickedUp = 2;
|
||||
|
||||
return arrow;
|
||||
}
|
||||
@@ -316,38 +278,33 @@ public class Crossbow 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, 0.5F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int renderPass) {
|
||||
if(!animateLayer(renderPass) && renderPass < getPartAmount())
|
||||
return super.getIcon(stack, renderPass);
|
||||
if (!animateLayer(renderPass) && renderPass < getPartAmount()) return super.getIcon(stack, renderPass);
|
||||
|
||||
if(!stack.hasTagCompound())
|
||||
return super.getIcon(stack, renderPass);
|
||||
if (!stack.hasTagCompound()) return super.getIcon(stack, renderPass);
|
||||
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if(tags == null || renderPass > 10)
|
||||
return super.getIcon(stack, renderPass);
|
||||
if (tags == null || renderPass > 10) return super.getIcon(stack, renderPass);
|
||||
|
||||
float progress;
|
||||
|
||||
if(tags.getBoolean("Loaded"))
|
||||
progress = 1;
|
||||
else if(!tags.hasKey("Reloading"))
|
||||
return super.getIcon(stack, renderPass);
|
||||
else
|
||||
progress = getWindupProgress(stack, getWindupTime(stack) - tags.getInteger("Reloading"));
|
||||
if (tags.getBoolean("Loaded")) progress = 1;
|
||||
else if (!tags.hasKey("Reloading")) return super.getIcon(stack, renderPass);
|
||||
else progress = getWindupProgress(stack, getWindupTime(stack) - tags.getInteger("Reloading"));
|
||||
|
||||
// are we drawing an effect?
|
||||
if(renderPass >= getPartAmount()) {
|
||||
if (renderPass >= getPartAmount()) {
|
||||
// is the effect animated?
|
||||
String effect = "Effect" + (1 + renderPass - getPartAmount());
|
||||
if(tags.hasKey(effect)) {
|
||||
if (tags.hasKey(effect)) {
|
||||
int index = tags.getInteger(effect);
|
||||
if(animationEffectIcons.get(index) != null)
|
||||
if (animationEffectIcons.get(index) != null)
|
||||
return getCorrectAnimationIcon(animationEffectIcons, index, progress);
|
||||
else
|
||||
// non-animated
|
||||
@@ -357,22 +314,23 @@ public class Crossbow extends ProjectileWeapon {
|
||||
}
|
||||
|
||||
// get the correct icon
|
||||
switch (renderPass)
|
||||
{
|
||||
case 0: return getCorrectAnimationIcon(animationHandleIcons, tags.getInteger("RenderHandle"), progress);
|
||||
case 1: return getCorrectAnimationIcon(animationHeadIcons, tags.getInteger("RenderHead"), progress);
|
||||
case 2: return getCorrectAnimationIcon(animationAccessoryIcons, tags.getInteger("RenderAccessory"), progress);
|
||||
case 3: return getCorrectAnimationIcon(animationExtraIcons, tags.getInteger("RenderExtra"), progress);
|
||||
switch (renderPass) {
|
||||
case 0:
|
||||
return getCorrectAnimationIcon(animationHandleIcons, tags.getInteger("RenderHandle"), progress);
|
||||
case 1:
|
||||
return getCorrectAnimationIcon(animationHeadIcons, tags.getInteger("RenderHead"), progress);
|
||||
case 2:
|
||||
return getCorrectAnimationIcon(animationAccessoryIcons, tags.getInteger("RenderAccessory"), progress);
|
||||
case 3:
|
||||
return getCorrectAnimationIcon(animationExtraIcons, tags.getInteger("RenderExtra"), progress);
|
||||
}
|
||||
|
||||
return emptyIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
public String getIconSuffix(int partType) {
|
||||
switch (partType) {
|
||||
case 0:
|
||||
return "_crossbow_bow"; // head
|
||||
case 1:
|
||||
@@ -389,14 +347,12 @@ public class Crossbow extends ProjectileWeapon {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
public String getEffectSuffix() {
|
||||
return "_crossbow_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
public String getDefaultFolder() {
|
||||
return "crossbow";
|
||||
}
|
||||
|
||||
@@ -411,20 +367,17 @@ public class Crossbow extends ProjectileWeapon {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
public Item getHeadItem() {
|
||||
return TinkerWeaponry.partCrossbowLimb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHandleItem ()
|
||||
{
|
||||
public Item getHandleItem() {
|
||||
return TinkerWeaponry.partCrossbowBody;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
public Item getAccessoryItem() {
|
||||
return TinkerWeaponry.bowstring;
|
||||
}
|
||||
|
||||
@@ -438,13 +391,10 @@ public class Crossbow extends ProjectileWeapon {
|
||||
return new String[] {"weapon", "bow", "windup"};
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void buildTool (int id, String name, List list)
|
||||
{
|
||||
public void buildTool(int id, String name, List list) {
|
||||
// does the material have a bow material?
|
||||
if(TConstructRegistry.getBowMaterial(id) == null)
|
||||
return;
|
||||
if (TConstructRegistry.getBowMaterial(id) == null) return;
|
||||
|
||||
// all creative bows use regular bowstring
|
||||
ItemStack headStack = new ItemStack(getHeadItem(), 1, id);
|
||||
@@ -453,8 +403,7 @@ public class Crossbow extends ProjectileWeapon {
|
||||
ItemStack extraStack = getPartAmount() > 3 ? new ItemStack(getExtraItem(), 1, id) : null;
|
||||
|
||||
ItemStack tool = ToolBuilder.instance.buildTool(headStack, handleStack, accessoryStack, extraStack, "");
|
||||
if (tool != null)
|
||||
{
|
||||
if (tool != null) {
|
||||
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
|
||||
list.add(tool);
|
||||
}
|
||||
@@ -462,17 +411,18 @@ public class Crossbow extends ProjectileWeapon {
|
||||
|
||||
@Override
|
||||
public int getColorFromItemStack(ItemStack stack, int renderPass) {
|
||||
if(renderPass != 2 || !stack.hasTagCompound())
|
||||
return super.getColorFromItemStack(stack, renderPass);
|
||||
if (renderPass != 2 || !stack.hasTagCompound()) return super.getColorFromItemStack(stack, renderPass);
|
||||
|
||||
// bowstring: custom material -> custom coloring
|
||||
// todo: move this into the custom material itself
|
||||
int mat = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Accessory");
|
||||
switch(mat)
|
||||
{
|
||||
case 0: return 0xffffffff; // string = white
|
||||
case 1: return 0xffccccff; // macig string = light blue
|
||||
case 2: return 0xffffcccc; // flamestring = light red
|
||||
switch (mat) {
|
||||
case 0:
|
||||
return 0xffffffff; // string = white
|
||||
case 1:
|
||||
return 0xffccccff; // macig string = light blue
|
||||
case 2:
|
||||
return 0xffffcccc; // flamestring = light red
|
||||
}
|
||||
return super.getColorFromItemStack(stack, renderPass);
|
||||
}
|
||||
|
||||
@@ -2,10 +2,6 @@ package tconstruct.weaponry.weapons;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import tconstruct.weaponry.client.CrosshairType;
|
||||
import tconstruct.weaponry.entity.JavelinEntity;
|
||||
import tconstruct.library.weaponry.AmmoWeapon;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -13,7 +9,11 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.library.weaponry.AmmoWeapon;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import tconstruct.weaponry.client.CrosshairType;
|
||||
import tconstruct.weaponry.entity.JavelinEntity;
|
||||
|
||||
public class Javelin extends AmmoWeapon {
|
||||
public Javelin() {
|
||||
@@ -21,26 +21,21 @@ public class Javelin extends AmmoWeapon {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLeftClickEntity (ItemStack stack, EntityPlayer player, Entity entity)
|
||||
{
|
||||
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
|
||||
// javelin is the only throwing/ammo weapon that hurts on leftclicking
|
||||
return AbilityHelper.onLeftClickEntity(stack, player, entity, this, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWindupProgress(ItemStack itemStack, EntityPlayer player) {
|
||||
if(!itemStack.hasTagCompound())
|
||||
return super.getWindupProgress(itemStack, player);
|
||||
if (!itemStack.hasTagCompound()) return super.getWindupProgress(itemStack, player);
|
||||
|
||||
if(!itemStack.getTagCompound().getCompoundTag("InfiTool").hasKey("Throwing"))
|
||||
return 0.5f;
|
||||
if (!itemStack.getTagCompound().getCompoundTag("InfiTool").hasKey("Throwing")) return 0.5f;
|
||||
|
||||
float timeleft = itemStack.getTagCompound().getCompoundTag("InfiTool").getInteger("Throwing");
|
||||
float threshold = getWindupTime(itemStack)/5;
|
||||
if(timeleft < threshold)
|
||||
return (threshold-timeleft)/threshold;
|
||||
else
|
||||
return 0.5f - 0.25f * ((float)getWindupTime(itemStack)-timeleft)/threshold;
|
||||
float threshold = getWindupTime(itemStack) / 5;
|
||||
if (timeleft < threshold) return (threshold - timeleft) / threshold;
|
||||
else return 0.5f - 0.25f * ((float) getWindupTime(itemStack) - timeleft) / threshold;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,12 +43,10 @@ public class Javelin extends AmmoWeapon {
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
|
||||
// already throwing
|
||||
if(tags.hasKey("Throwing"))
|
||||
return stack;
|
||||
if (tags.hasKey("Throwing")) return stack;
|
||||
|
||||
// has ammo?
|
||||
if(this.getAmmoCount(stack) <= 0)
|
||||
return stack;
|
||||
if (this.getAmmoCount(stack) <= 0) return stack;
|
||||
|
||||
// start throwing
|
||||
tags.setInteger("Throwing", getWindupTime(stack));
|
||||
@@ -65,21 +58,17 @@ public class Javelin extends AmmoWeapon {
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) {
|
||||
super.onUpdate(stack, world, entity, par4, par5);
|
||||
|
||||
if(!stack.hasTagCompound())
|
||||
return;
|
||||
if (!stack.hasTagCompound()) return;
|
||||
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if(!tags.hasKey("Throwing"))
|
||||
return;
|
||||
if (!tags.hasKey("Throwing")) return;
|
||||
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
if(player.inventory.getCurrentItem() != stack)
|
||||
return;
|
||||
if (player.inventory.getCurrentItem() != stack) return;
|
||||
|
||||
int timeLeft = tags.getInteger("Throwing");
|
||||
timeLeft--;
|
||||
if(timeLeft > 0)
|
||||
tags.setInteger("Throwing", timeLeft);
|
||||
if (timeLeft > 0) tags.setInteger("Throwing", timeLeft);
|
||||
else {
|
||||
onPlayerStoppedUsing(stack, world, player, 0);
|
||||
tags.removeTag("Throwing");
|
||||
@@ -118,8 +107,7 @@ public class Javelin extends AmmoWeapon {
|
||||
|
||||
@Override
|
||||
public String getIconSuffix(int partType) {
|
||||
switch (partType)
|
||||
{
|
||||
switch (partType) {
|
||||
case 0:
|
||||
return "_javelin_head";
|
||||
case 1:
|
||||
@@ -188,5 +176,7 @@ public class Javelin extends AmmoWeapon {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public CrosshairType getCrosshairType() { return CrosshairType.WEIRD; }
|
||||
public CrosshairType getCrosshairType() {
|
||||
return CrosshairType.WEIRD;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
package tconstruct.weaponry.weapons;
|
||||
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import tconstruct.weaponry.ammo.ArrowAmmo;
|
||||
import tconstruct.library.weaponry.BowBaseAmmo;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.weaponry.BowBaseAmmo;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import tconstruct.weaponry.ammo.ArrowAmmo;
|
||||
|
||||
public class LongBow extends BowBaseAmmo {
|
||||
public LongBow() {
|
||||
@@ -32,28 +32,25 @@ public class LongBow extends BowBaseAmmo {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Entity createProjectile(ItemStack arrows, World world, EntityPlayer player, float speed, float accuracy, float windup) {
|
||||
if(arrows.getItem() instanceof ArrowAmmo)
|
||||
{
|
||||
protected Entity createProjectile(
|
||||
ItemStack arrows, World world, EntityPlayer player, float speed, float accuracy, float windup) {
|
||||
if (arrows.getItem() instanceof ArrowAmmo) {
|
||||
// modify accuraccy of the arrow depending on its accuraccy and weight
|
||||
NBTTagCompound tags = arrows.getTagCompound().getCompoundTag("InfiTool");
|
||||
float matAccuracy = tags.getFloat("Accuracy");
|
||||
float weight = tags.getFloat("Mass");
|
||||
|
||||
// we need heavier arrows because we have POW. therefore we increase the weight penality on accuracy
|
||||
accuracy += ((100f-matAccuracy)/10f)/Math.max(1f, weight-1f);
|
||||
if(accuracy < 0)
|
||||
accuracy = 0;
|
||||
accuracy += ((100f - matAccuracy) / 10f) / Math.max(1f, weight - 1f);
|
||||
if (accuracy < 0) accuracy = 0;
|
||||
}
|
||||
|
||||
return super.createProjectile(arrows, world, player, speed, accuracy, windup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
public String getIconSuffix(int partType) {
|
||||
switch (partType) {
|
||||
case 0:
|
||||
return "_bow_top";
|
||||
case 1:
|
||||
@@ -70,14 +67,12 @@ public class LongBow extends BowBaseAmmo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
public String getEffectSuffix() {
|
||||
return "_bow_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
public String getDefaultFolder() {
|
||||
return "longbow";
|
||||
}
|
||||
|
||||
@@ -92,20 +87,17 @@ public class LongBow extends BowBaseAmmo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
public Item getHeadItem() {
|
||||
return TinkerWeaponry.partBowLimb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHandleItem ()
|
||||
{
|
||||
public Item getHandleItem() {
|
||||
return TinkerWeaponry.bowstring;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
public Item getAccessoryItem() {
|
||||
return TinkerWeaponry.partBowLimb;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,15 +3,15 @@ package tconstruct.weaponry.weapons;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import tconstruct.weaponry.ammo.ArrowAmmo;
|
||||
import tconstruct.library.weaponry.BowBaseAmmo;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.weaponry.BowBaseAmmo;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import tconstruct.weaponry.ammo.ArrowAmmo;
|
||||
|
||||
public class ShortBow extends BowBaseAmmo {
|
||||
public ShortBow() {
|
||||
@@ -29,28 +29,25 @@ public class ShortBow extends BowBaseAmmo {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Entity createProjectile(ItemStack arrows, World world, EntityPlayer player, float speed, float accuracy, float windup) {
|
||||
if(arrows.getItem() instanceof ArrowAmmo)
|
||||
{
|
||||
protected Entity createProjectile(
|
||||
ItemStack arrows, World world, EntityPlayer player, float speed, float accuracy, float windup) {
|
||||
if (arrows.getItem() instanceof ArrowAmmo) {
|
||||
// modify accuraccy of the arrow depending on its accuraccy and weight
|
||||
NBTTagCompound tags = arrows.getTagCompound().getCompoundTag("InfiTool");
|
||||
float matAccuracy = tags.getFloat("Accuracy");
|
||||
float weight = tags.getFloat("Mass");
|
||||
|
||||
// weight influences the accuracy too, but only a little bit.
|
||||
accuracy += ((100f-matAccuracy)/10f)/(weight);
|
||||
if(accuracy < 0)
|
||||
accuracy = 0;
|
||||
accuracy += ((100f - matAccuracy) / 10f) / (weight);
|
||||
if (accuracy < 0) accuracy = 0;
|
||||
}
|
||||
|
||||
return super.createProjectile(arrows, world, player, speed, accuracy, windup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
public String getIconSuffix(int partType) {
|
||||
switch (partType) {
|
||||
case 0:
|
||||
return "_bow_top";
|
||||
case 1:
|
||||
@@ -65,14 +62,12 @@ public class ShortBow extends BowBaseAmmo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
public String getEffectSuffix() {
|
||||
return "_bow_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
public String getDefaultFolder() {
|
||||
return "shortbow";
|
||||
}
|
||||
|
||||
@@ -87,35 +82,29 @@ public class ShortBow extends BowBaseAmmo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
public Item getHeadItem() {
|
||||
return TinkerWeaponry.partBowLimb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHandleItem ()
|
||||
{
|
||||
public Item getHandleItem() {
|
||||
return TinkerWeaponry.bowstring;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
public Item getAccessoryItem() {
|
||||
return TinkerWeaponry.partBowLimb;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5)
|
||||
{
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) {
|
||||
// shortbows are smaller and more mobile than longbows
|
||||
super.onUpdate(stack, world, entity, par4, par5);
|
||||
if (entity instanceof EntityPlayerSP)
|
||||
{
|
||||
if (entity instanceof EntityPlayerSP) {
|
||||
EntityPlayerSP player = (EntityPlayerSP) entity;
|
||||
ItemStack usingItem = player.getItemInUse();
|
||||
if (usingItem != null && usingItem.getItem() == this)
|
||||
{
|
||||
if (usingItem != null && usingItem.getItem() == this) {
|
||||
player.movementInput.moveForward *= 1.5F;
|
||||
player.movementInput.moveStrafe *= 1.5F;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
package tconstruct.weaponry.weapons;
|
||||
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import tconstruct.weaponry.client.CrosshairType;
|
||||
import tconstruct.client.IconFlipped;
|
||||
import tconstruct.weaponry.entity.ShurikenEntity;
|
||||
import tconstruct.library.weaponry.AmmoWeapon;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -15,9 +12,11 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import tconstruct.client.IconFlipped;
|
||||
import tconstruct.library.weaponry.AmmoWeapon;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import tconstruct.weaponry.client.CrosshairType;
|
||||
import tconstruct.weaponry.entity.ShurikenEntity;
|
||||
|
||||
public class Shuriken extends AmmoWeapon {
|
||||
|
||||
@@ -52,8 +51,7 @@ public class Shuriken extends AmmoWeapon {
|
||||
|
||||
@Override
|
||||
public String getIconSuffix(int partType) {
|
||||
switch (partType)
|
||||
{
|
||||
switch (partType) {
|
||||
case 0:
|
||||
return "_shuriken";
|
||||
case 1:
|
||||
@@ -116,8 +114,7 @@ public class Shuriken extends AmmoWeapon {
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
if(getAmmoCount(stack) <= 0)
|
||||
return stack;
|
||||
if (getAmmoCount(stack) <= 0) return stack;
|
||||
|
||||
launchProjectile(stack, world, player, 1);
|
||||
|
||||
@@ -160,8 +157,7 @@ public class Shuriken extends AmmoWeapon {
|
||||
// now we flip all the different part icons, so we only need 1 graphic for 4 different orientations \o/
|
||||
// handle first: flip x
|
||||
Iterator<Map.Entry<Integer, IIcon>> iter = handleIcons.entrySet().iterator();
|
||||
while(iter.hasNext())
|
||||
{
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry<Integer, IIcon> entry = iter.next();
|
||||
entry.setValue(new IconFlipped(entry.getValue(), true, false));
|
||||
// the entry object should reference the direct object in the map, no further updating needed
|
||||
@@ -169,16 +165,14 @@ public class Shuriken extends AmmoWeapon {
|
||||
|
||||
// accessory: flip y
|
||||
iter = accessoryIcons.entrySet().iterator();
|
||||
while(iter.hasNext())
|
||||
{
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry<Integer, IIcon> entry = iter.next();
|
||||
entry.setValue(new IconFlipped(entry.getValue(), false, true));
|
||||
}
|
||||
|
||||
// extra: flip x and y
|
||||
iter = extraIcons.entrySet().iterator();
|
||||
while(iter.hasNext())
|
||||
{
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry<Integer, IIcon> entry = iter.next();
|
||||
entry.setValue(new IconFlipped(entry.getValue(), true, true));
|
||||
}
|
||||
@@ -189,6 +183,4 @@ public class Shuriken extends AmmoWeapon {
|
||||
public CrosshairType getCrosshairType() {
|
||||
return CrosshairType.TIP;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
package tconstruct.weaponry.weapons;
|
||||
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import tconstruct.library.entity.ProjectileBase;
|
||||
import tconstruct.weaponry.client.CrosshairType;
|
||||
import tconstruct.weaponry.entity.ThrowingKnifeEntity;
|
||||
import tconstruct.library.weaponry.AmmoWeapon;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.entity.ProjectileBase;
|
||||
import tconstruct.library.weaponry.AmmoWeapon;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.weaponry.client.CrosshairType;
|
||||
import tconstruct.weaponry.entity.ThrowingKnifeEntity;
|
||||
|
||||
public class ThrowingKnife extends AmmoWeapon {
|
||||
public ThrowingKnife() {
|
||||
@@ -26,8 +26,7 @@ public class ThrowingKnife extends AmmoWeapon {
|
||||
|
||||
@Override
|
||||
public String getIconSuffix(int partType) {
|
||||
switch (partType)
|
||||
{
|
||||
switch (partType) {
|
||||
case 0:
|
||||
return "_knife_blade";
|
||||
case 1:
|
||||
@@ -60,7 +59,9 @@ public class ThrowingKnife extends AmmoWeapon {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWindupTime(ItemStack itemStack) { return 15; } // 1 1/2 seconds
|
||||
public int getWindupTime(ItemStack itemStack) {
|
||||
return 15;
|
||||
} // 1 1/2 seconds
|
||||
|
||||
@Override
|
||||
public float getMinWindupProgress(ItemStack itemStack) {
|
||||
@@ -81,8 +82,7 @@ public class ThrowingKnife extends AmmoWeapon {
|
||||
protected Entity createProjectile(ItemStack reference, World world, EntityPlayer player, float accuracy, int time) {
|
||||
ProjectileBase knife = new ThrowingKnifeEntity(world, player, getProjectileSpeed(), accuracy, reference);
|
||||
// if you aim long enough, it's a crit!
|
||||
if(time >= this.getWindupTime(reference)*1.5f)
|
||||
knife.setIsCritical(true);
|
||||
if (time >= this.getWindupTime(reference) * 1.5f) knife.setIsCritical(true);
|
||||
|
||||
return knife;
|
||||
}
|
||||
@@ -100,16 +100,13 @@ public class ThrowingKnife extends AmmoWeapon {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5)
|
||||
{
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) {
|
||||
// aiming with throwing knives slows down much less than with a bow
|
||||
super.onUpdate(stack, world, entity, par4, par5);
|
||||
if (entity instanceof EntityPlayerSP)
|
||||
{
|
||||
if (entity instanceof EntityPlayerSP) {
|
||||
EntityPlayerSP player = (EntityPlayerSP) entity;
|
||||
ItemStack usingItem = player.getItemInUse();
|
||||
if (usingItem != null && usingItem.getItem() == this)
|
||||
{
|
||||
if (usingItem != null && usingItem.getItem() == this) {
|
||||
player.movementInput.moveForward *= 3.0F;
|
||||
player.movementInput.moveStrafe *= 3.0F;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user