Make weaponry book available!

This commit is contained in:
Bernhard Bonigl committed 2014-10-30 12:31:54 +01:00
1 parent 6cd7b497e8
commit 5a03a15ec4
5 files changed
+32 -3

No files matched your search

@@ -27,6 +27,7 @@ public class TPlayerStats implements IExtendedEntityProperties, IPlayerExtendedI
public boolean beginnerManual;
public boolean materialManual;
public boolean smelteryManual;
public boolean weaponryManual;
public boolean battlesignBonus;
// death-penality
@@ -61,6 +62,7 @@ public class TPlayerStats implements IExtendedEntityProperties, IPlayerExtendedI
tTag.setBoolean("beginnerManual", this.beginnerManual);
tTag.setBoolean("materialManual", this.materialManual);
tTag.setBoolean("smelteryManual", this.smelteryManual);
tTag.setBoolean("weaponryManual", this.weaponryManual);
tTag.setBoolean("battlesignBonus", this.battlesignBonus);
tTag.setInteger("derpLevel", this.derpLevel);
compound.setTag(PROP_NAME, tTag);
@@ -76,6 +78,7 @@ public class TPlayerStats implements IExtendedEntityProperties, IPlayerExtendedI
this.beginnerManual = properties.getBoolean("beginnerManual");
this.materialManual = properties.getBoolean("materialManual");
this.smelteryManual = properties.getBoolean("smelteryManual");
this.weaponryManual = properties.getBoolean("weaponryManual");
this.battlesignBonus = properties.getBoolean("battlesignBonus");
this.derpLevel = properties.getInteger("derpLevel");
}
@@ -95,6 +98,7 @@ public class TPlayerStats implements IExtendedEntityProperties, IPlayerExtendedI
this.beginnerManual = stats.beginnerManual;
this.materialManual = stats.materialManual;
this.smelteryManual = stats.smelteryManual;
this.weaponryManual = stats.weaponryManual;
this.battlesignBonus = stats.battlesignBonus;
this.derpLevel = stats.derpLevel;
@@ -612,7 +612,9 @@ public class TinkerTools
GameRegistry.addShapelessRecipe(new ItemStack(TinkerTools.manualBook, 2, 1), new ItemStack(TinkerTools.manualBook, 1, 1), Items.book);
GameRegistry.addShapelessRecipe(new ItemStack(TinkerTools.manualBook, 1, 2), new ItemStack(TinkerTools.manualBook, 1, 1));
GameRegistry.addShapelessRecipe(new ItemStack(TinkerTools.manualBook, 2, 2), new ItemStack(TinkerTools.manualBook, 1, 2), Items.book);
GameRegistry.addShapelessRecipe(new ItemStack(TinkerTools.manualBook, 1, 3), new ItemStack(TinkerTools.manualBook, 1, 2));
GameRegistry.addShapelessRecipe(new ItemStack(TinkerTools.manualBook, 2, 4), new ItemStack(TinkerTools.manualBook, 1, 4), Items.book);
GameRegistry.addShapelessRecipe(new ItemStack(TinkerTools.manualBook, 1, 4), new ItemStack(TinkerTools.manualBook, 1, 2));
GameRegistry.addShapelessRecipe(new ItemStack(TinkerTools.manualBook, 1, 3), new ItemStack(TinkerTools.manualBook, 1, 4));
// alternative Vanilla Book Recipe
GameRegistry.addShapelessRecipe(new ItemStack(Items.book), Items.paper, Items.paper, Items.paper, Items.string, TinkerTools.blankPattern, TinkerTools.blankPattern);
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(Items.name_tag), "P~ ", "~O ", " ~", '~', Items.string, 'P', Items.paper, 'O', "slimeball"));
@@ -1,6 +1,7 @@
package tconstruct.weaponry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
@@ -111,7 +112,9 @@ public class TinkerWeaponry {
public void postInit(FMLPostInitializationEvent event)
{
// this handler takes care that ammo weapons get ammo.
MinecraftForge.EVENT_BUS.register(new WeaponryHandler());
WeaponryHandler weaponryHandler = new WeaponryHandler();
MinecraftForge.EVENT_BUS.register(weaponryHandler);
FMLCommonHandler.instance().bus().register(weaponryHandler);
proxy.init();
}
@@ -1,5 +1,8 @@
package tconstruct.weaponry;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import tconstruct.armor.player.TPlayerStats;
import tconstruct.tools.TinkerTools;
import tconstruct.weaponry.ammo.ArrowAmmo;
import tconstruct.weaponry.ammo.BoltAmmo;
import tconstruct.library.tools.DualMaterialToolPart;
@@ -21,6 +24,24 @@ import tconstruct.weaponry.weapons.LongBow;
import tconstruct.weaponry.weapons.ShortBow;
public class WeaponryHandler {
@SubscribeEvent
public void onCrafting (PlayerEvent.ItemCraftedEvent event)
{
Item item = event.crafting.getItem();
if (!event.player.worldObj.isRemote)
{
if (item == Item.getItemFromBlock(TinkerTools.toolStationWood))
{
TPlayerStats stats = TPlayerStats.get(event.player);
if (!stats.weaponryManual)
{
stats.weaponryManual = true;
AbilityHelper.spawnItemAtPlayer(event.player, new ItemStack(TinkerTools.manualBook, 1, 4));
}
}
}
}
// Provides ammo-items with the necessary NBT
@SubscribeEvent
public void onAmmoCrafted(ToolCraftEvent.NormalTool event)