Skip to content

Commit

Permalink
First merging of weaponry into tinkers
Browse files Browse the repository at this point in the history
  • Loading branch information
bonii-xx committed Oct 5, 2014
1 parent 6e1ea0e commit 73b25d1
Show file tree
Hide file tree
Showing 191 changed files with 5,325 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.properties
@@ -1,5 +1,5 @@
minecraft_version=1.7.10
forge_version=10.13.0.1208
forge_version=10.13.1.1217
mantle_version=0.3.1.jenkins176
CCLIB_version=1.1.1.95
NEI_version=1.0.2.15
Expand Down
Binary file added item_texture_backup.zip
Binary file not shown.
18 changes: 18 additions & 0 deletions resources/assets/tinker/sounds.json
Expand Up @@ -16,5 +16,23 @@
"sounds": [
"launcher_clank"
]
},
"woodHit": {
"category": "block",
"sounds": [
"woodHit1",
"woodHit2",
"woodHit3",
"woodHit4",
"woodHit5"
]
},
"stoneHit": {
"category": "block",
"sounds": [
"stoneHit1",
"stoneHit2",
"stoneHit3"
]
}
}
Binary file added resources/assets/tinker/textures/gui/Crosshair.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/assets/tinker/textures/gui/Crosshair2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/assets/tinker/textures/gui/Crosshair3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/assets/tinker/textures/gui/Crosshair4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/assets/tinker/textures/gui/icons.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/assets/tinker/textures/items/arrow/_arrow_fletching.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/assets/tinker/textures/items/arrow/_arrow_head.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/assets/tinker/textures/items/arrow/_arrow_shaft.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/assets/tinker/textures/items/arrow/alumite_arrow_head.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified resources/assets/tinker/textures/items/arrow/ardite_arrow_head.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/assets/tinker/textures/items/arrow/blaze_arrow_effect.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified resources/assets/tinker/textures/items/arrow/bone_arrow_head.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/assets/tinker/textures/items/arrow/bone_arrow_shaft.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/assets/tinker/textures/items/arrow/bronze_arrow_head.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified resources/assets/tinker/textures/items/arrow/cactus_arrow_head.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified resources/assets/tinker/textures/items/arrow/cobalt_arrow_head.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Binary file modified resources/assets/tinker/textures/items/arrow/copper_arrow_head.png
Diff not rendered.
Binary file modified resources/assets/tinker/textures/items/arrow/flint_arrow_head.png
Diff not rendered.
Binary file modified resources/assets/tinker/textures/items/arrow/flux_arrow_effect.png
Binary file modified resources/assets/tinker/textures/items/arrow/ice_arrow_effect.png
Binary file modified resources/assets/tinker/textures/items/arrow/iron_arrow_head.png
Diff not rendered.
Binary file modified resources/assets/tinker/textures/items/arrow/lava_arrow_effect.png
Diff not rendered.
Binary file modified resources/assets/tinker/textures/items/arrow/moss_arrow_effect.png
Diff not rendered.
Diff not rendered.
Binary file modified resources/assets/tinker/textures/items/arrow/paper_arrow_head.png
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file modified resources/assets/tinker/textures/items/arrow/silk_arrow_effect.png
Binary file modified resources/assets/tinker/textures/items/arrow/slime_arrow_head.png
Diff not rendered.
Binary file modified resources/assets/tinker/textures/items/arrow/smite_arrow_effect.png
Binary file modified resources/assets/tinker/textures/items/arrow/steel_arrow_head.png
Diff not rendered.
Binary file modified resources/assets/tinker/textures/items/arrow/stone_arrow_head.png
Diff not rendered.
Diff not rendered.
Binary file modified resources/assets/tinker/textures/items/arrow/wood_arrow_head.png
Binary file modified resources/assets/tinker/textures/items/arrow/wood_arrow_shaft.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified resources/assets/tinker/textures/items/shortbow/_bowstring.png
Binary file modified resources/assets/tinker/textures/items/shortbow/_bowstring_1.png
Binary file modified resources/assets/tinker/textures/items/shortbow/_bowstring_2.png
Binary file modified resources/assets/tinker/textures/items/shortbow/_bowstring_3.png
317 changes: 317 additions & 0 deletions src/main/java/tconstruct/weaponry/TinkerWeaponry.java

Large diffs are not rendered by default.

114 changes: 114 additions & 0 deletions src/main/java/tconstruct/weaponry/WeaponryClientProxy.java
@@ -0,0 +1,114 @@
package boni.tinkersweaponry;

import boni.tinkersweaponry.client.AmmoSlotHandler;
import boni.tinkersweaponry.client.CrosshairHandler;
import boni.tinkersweaponry.client.RenderEventHandler;
import boni.tinkersweaponry.client.entityrenderer.ArrowEntityRenderer;
import boni.tinkersweaponry.client.entityrenderer.JavelinEntityRenderer;
import boni.tinkersweaponry.client.entityrenderer.ProjectileBaseRenderer;
import boni.tinkersweaponry.client.entityrenderer.ShurikenEntityRenderer;
import boni.tinkersweaponry.client.renderer.*;
import boni.tinkersweaponry.entity.*;
import boni.tinkersweaponry.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;

public class WeaponryClientProxy extends WeaponryCommonProxy {
public static AmmoItemRenderer renderer;

@Override
public void init() {
super.init();

MinecraftForge.EVENT_BUS.register(new CrosshairHandler());
MinecraftForge.EVENT_BUS.register(new AmmoSlotHandler());
MinecraftForge.EVENT_BUS.register(new RenderEventHandler());

registerRenderers();
registerEntityRendering();
registerMaterialRendering();

buttons();
}

private void registerRenderers()
{
renderer = new AmmoItemRenderer();
MinecraftForgeClient.registerItemRenderer(TinkerWeaponry.throwArrow, renderer);
MinecraftForgeClient.registerItemRenderer(TinkerWeaponry.shuriken, renderer);
MinecraftForgeClient.registerItemRenderer(TinkerWeaponry.throwingknife, new ThrowingKnifeRenderer());
MinecraftForgeClient.registerItemRenderer(TinkerWeaponry.javelin, new JavelinRenderer());

MinecraftForgeClient.registerItemRenderer(TinkerWeaponry.shortbow, new BowRenderer());
MinecraftForgeClient.registerItemRenderer(TinkerWeaponry.longbow, new BowRenderer());
MinecraftForgeClient.registerItemRenderer(TinkerWeaponry.crossbow, new CrossbowRenderer());

MinecraftForgeClient.registerItemRenderer(TinkerWeaponry.arrowAmmo, renderer);
MinecraftForgeClient.registerItemRenderer(TinkerWeaponry.boltAmmo, renderer);
}

private void registerEntityRendering()
{
ProjectileBaseRenderer defaultRenderer = new ProjectileBaseRenderer<ProjectileBase>();
RenderingRegistry.registerEntityRenderingHandler(ShurikenEntity.class, new ShurikenEntityRenderer());
RenderingRegistry.registerEntityRenderingHandler(ThrowingKnifeEntity.class, defaultRenderer);
RenderingRegistry.registerEntityRenderingHandler(JavelinEntity.class, new JavelinEntityRenderer());
RenderingRegistry.registerEntityRenderingHandler(ArrowEntity.class, new ArrowEntityRenderer());
RenderingRegistry.registerEntityRenderingHandler(BoltEntity.class, new ArrowEntityRenderer(0.6f));
}

private void registerMaterialRendering()
{
ToolCore arrow = TinkerWeaponry.arrowAmmo;
String pre = Reference.resource(arrow.getDefaultFolder()) + "/";

String[] shaft = {"wood", "bone", "blaze", "reed"};
String[] fletching = { "feather", "leaf", "slime", "blueslime" };

// we register different textures for the different parts per index
for(int i = 0; i < 4; 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});
}

// for bolts too
pre = Reference.resource(TinkerWeaponry.boltAmmo.getDefaultFolder()) + "/";
for(int i = 0; i < 4; i++) {
String acctex = pre + fletching[i] + TinkerWeaponry.boltAmmo.getIconSuffix(3);
TinkerWeaponry.boltAmmo.registerAlternatePartPaths(i, new String[]{null, null, null, acctex});
}

// todo: do properly when moving stuff into tinkers code
arrow.headStrings.clear();
arrow.headStrings.put(TinkerTools.MaterialID.PigIron, Reference.resource(arrow.getDefaultFolder() + "/pigiron" + arrow.getIconSuffix(0)));

/*
TConstructClientRegistry.addAlternateMaterialRenderMapping(TinkerWeaponry.shuriken, 2, Reference.RESOURCE, "iron", true);
TConstructClientRegistry.addAlternateMaterialRenderMapping(TinkerWeaponry.throwingknife, 2, Reference.RESOURCE, "iron", true);
String[] fletching = { "feather", "leaf", "slime", "blueslime" };
for (int arrowIter = 0; arrowIter < fletching.length; arrowIter++)
{
TConstructClientRegistry.addAlternateMaterialRenderMapping(TinkerWeaponry.throwArrow, arrowIter, "tinker", fletching[arrowIter], true);
}
*/
}

private void buttons()
{
int base = StencilBuilder.getIndex(new ItemStack(TinkerWeaponry.woodPattern, 0, 0));
TConstructClientRegistry.addStencilButton2(0, 4, base + 0, Reference.RESOURCE, "textures/gui/icons.png"); // shuriken
TConstructClientRegistry.addStencilButton2(1, 4, base + 1, Reference.RESOURCE, "textures/gui/icons.png"); // crossbow limb
TConstructClientRegistry.addStencilButton2(2, 4, base + 2, Reference.RESOURCE, "textures/gui/icons.png"); // crossbow body
TConstructClientRegistry.addStencilButton2(3, 4, base + 3, Reference.RESOURCE, "textures/gui/icons.png"); // bow limb
//TConstructClientRegistry.addStencilButton2(4, 4, index, Reference.RESOURCE, "textures/gui/icons.png"); // bolt
}
}
14 changes: 14 additions & 0 deletions src/main/java/tconstruct/weaponry/WeaponryCommonProxy.java
@@ -0,0 +1,14 @@
package boni.tinkersweaponry;

import boni.tinkersweaponry.entity.*;
import cpw.mods.fml.common.registry.EntityRegistry;

public class WeaponryCommonProxy {
public void init() {
EntityRegistry.registerModEntity(ShurikenEntity.class, "Shuriken", 0, TinkerWeaponry.instance, 32, 5, true);
EntityRegistry.registerModEntity(ThrowingKnifeEntity.class, "ThrowingKnife", 1, TinkerWeaponry.instance, 32, 5, true);
EntityRegistry.registerModEntity(JavelinEntity.class, "Javelin", 2, TinkerWeaponry.instance, 32, 5, true);
EntityRegistry.registerModEntity(ArrowEntity.class, "Arrow", 3, TinkerWeaponry.instance, 32, 5, true);
EntityRegistry.registerModEntity(BoltEntity.class, "Bolt", 4, TinkerWeaponry.instance, 32, 5, true);
}
}
189 changes: 189 additions & 0 deletions src/main/java/tconstruct/weaponry/WeaponryHandler.java
@@ -0,0 +1,189 @@
package boni.tinkersweaponry;

import boni.tinkersweaponry.ammo.ArrowAmmo;
import boni.tinkersweaponry.ammo.BoltAmmo;
import boni.tinkersweaponry.items.DualMaterialToolPart;
import boni.tinkersweaponry.library.weaponry.ArrowShaftMaterial;
import boni.tinkersweaponry.library.weaponry.BowBaseAmmo;
import boni.tinkersweaponry.library.weaponry.ProjectileWeapon;
import boni.tinkersweaponry.library.weaponry.IAmmo;
import boni.tinkersweaponry.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.*;

public class WeaponryHandler {
// Provides ammo-items with the necessary NBT
@SubscribeEvent
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)
{
// 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 it functions at the durability modifier
// the fletching defines the accuracy of the bow, adds a bit of durability and also breakchance

// Shortbows work better with lighter arrows
// 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);

// todo: fix leaf fletching
if(fletching == null)
fletching = (FletchingMaterial) TConstructRegistry.getCustomMaterial(tags.getInteger("Accessory"), FletchlingLeafMaterial.class);

int durability = (int)((float)head.durability() * shaft.durabilityModifier); // todo: fletching durability
float weight = arrow.mass + shaft.weight/2f;
float accuracy = fletching.accuracy;
float breakChance = shaft.fragility + fletching.breakChance;

tags.setInteger("TotalDurability", durability);
tags.setFloat("Mass", weight);
tags.setFloat("BreakChance", breakChance);
tags.setFloat("Accuracy", accuracy);
}
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

// the materials
ToolMaterial headMat = TConstructRegistry.getMaterial(tags.getInteger("Head"));
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);

// todo: fix leaf fletching
if(fletching == null)
fletching = (FletchingMaterial) TConstructRegistry.getCustomMaterial(tags.getInteger("Accessory"), FletchlingLeafMaterial.class);

int durability = (int)((float)headMat.durability() * coreMat.handleDurability()); // todo: fletching durability
float weight = head.mass + core.mass;
float accuracy = fletching.accuracy;
float breakChance = fletching.breakChance;

tags.setInteger("TotalDurability", durability);
tags.setFloat("Mass", weight);
tags.setFloat("BreakChance", breakChance);
tags.setFloat("Accuracy", accuracy);
}

// now that durability has been handled...
// fill the ammo full and at the same time provide the missing NBT tag
IAmmo ammoItem = (IAmmo) event.tool;
tags.setInteger("Ammo", ammoItem.getMaxAmmo(tags));
}

@SubscribeEvent
public void onProjectileWeaponCrafted(ToolCraftEvent.NormalTool event)
{
if(!(event.tool instanceof ProjectileWeapon))
return;

NBTTagCompound tags = event.toolTag.getCompoundTag("InfiTool");

int drawSpeed = 0;
float flightSpeed = 0;

BowMaterial top;
BowMaterial bottom;
BowstringMaterial string;

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);

drawSpeed = (int) ((top.drawspeed + bottom.drawspeed) / 2f * string.drawspeedModifier);
flightSpeed = (top.flightSpeedMax + bottom.flightSpeedMax)/2 * string.flightSpeedModifier;
}
else if(event.tool instanceof Crossbow)
{
top = TConstructRegistry.getBowMaterial(tags.getInteger("Head"));
string = (BowstringMaterial) TConstructRegistry.getCustomMaterial(tags.getInteger("Accessory"), BowstringMaterial.class);

drawSpeed = (int) ((float)top.drawspeed * string.drawspeedModifier);
flightSpeed = (top.flightSpeedMax * string.flightSpeedModifier);
}
else
return;

// enchanted fabric
/*
if (tags.getInteger("Handle") == 1) {
int modifiers = tags.getInteger("Modifiers");
modifiers += 1;
tags.setInteger("Modifiers", modifiers);
}*/

tags.setInteger("DrawSpeed", drawSpeed);
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;

// are we building an arrow?
CustomMaterial mat = TConstructRegistry.getCustomMaterial(event.handleStack, ArrowShaftMaterial.class);
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);

// it's an arrow!
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;

if(event.headStack.getItem() != TinkerWeaponry.partBolt)
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));

// update the part positions xX
event.headStack = bolt1;
event.handleStack = bolt2;
event.accessoryStack = fletching;
}
}

0 comments on commit 73b25d1

Please sign in to comment.