player arm can swing

This commit is contained in:
Mohammad-Ali Minaie
2017-03-21 23:39:26 -04:00
parent 958633ff2a
commit 9c332d6b61
2 changed files with 118 additions and 104 deletions

View File

@@ -1,15 +1,16 @@
To-Dos To-Dos
*** Priority *** *** Priority ***
- [ ] Create the hoe Item - [ ] Sound Handler
- [ ] OreDict Stuff
- [ ] Create the Sword Model - [ ] Create the Sword Model
- [ ] Add randomInt to anvil - [ ] Sword Item
- [ ] Sword Json
*** Backlog *** *** Backlog ***
- [ ] Create a method which adds the types of NBT upgrades and creates a unique float instead of using magic numbers - [ ] Create a method which adds the types of NBT upgrades and creates a unique float instead of using magic numbers
- [ ] Add forgehammer to oreDict - [ ] Add forgehammer to oreDict
- [ ] Finish Toolhead Recipes
- [ ] WeaponHead recipes - [ ] WeaponHead recipes
- [ ] Casting Table - [ ] Casting Table
@@ -25,6 +26,9 @@ To-Dos
*** Completed *** *** Completed ***
- [x] Create the hoe Item
- [x] Finish Toolhead Recipes
- [x] Add randomInt to anvil
- [x] Create the axe Item - [x] Create the axe Item
- [x] Create the shovel Item - [x] Create the shovel Item
- [x] Create the axe Model - [x] Create the axe Model

View File

@@ -73,131 +73,140 @@ public class Anvil extends CustomContainerFacing {
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitx, float hity, float hitz) { public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitx, float hity, float hitz) {
if (world.isRemote) {
if (!player.isSwingInProgress) {
player.swingArm(hand);
}
}
/******************************************************************************
Crafting Anvil Recipes
*****************************************************************************/
if (!world.isRemote) { if (!world.isRemote) {
TileAnvil tile = (TileAnvil) world.getTileEntity(pos); if ((player.inventory.getCurrentItem().getItem().equals(PrimalItems.STONE_GALLAGHER)) || (player.inventory.getCurrentItem().getItem() == ModItems.forgehammer)) {
if (tile != null) { TileAnvil tile = (TileAnvil) world.getTileEntity(pos);
ItemStack pItem = player.inventory.getCurrentItem(); ItemStack pItem = player.inventory.getCurrentItem();
if (tile != null) {
/****************************************************************************** if ((pItem.getItem().equals(PrimalItems.STONE_GALLAGHER)) || (pItem.getItem() == ModItems.forgehammer)) {
Crafting Anvil Recipes
*****************************************************************************/
if ((pItem.getItem().equals(PrimalItems.STONE_GALLAGHER)) || (pItem.getItem() == ModItems.forgehammer)) {
String[] tempArray = new String[25];
for (int i = 0; i < 25; i++) {
tempArray[i] = tile.getSlotStack(i).getItem().getRegistryName().toString(); String[] tempArray = new String[25];
//System.out.println(i + " || " + tempArray[i] + " || " + tile.getSlotStack(i).getItem()); for (int i = 0; i < 25; i++) {
}
AnvilCrafting recipe = AnvilCrafting.getRecipe(tempArray); tempArray[i] = tile.getSlotStack(i).getItem().getRegistryName().toString();
//System.out.println(i + " || " + tempArray[i] + " || " + tile.getSlotStack(i).getItem());
if (recipe != null) {
if (pItem.getItem().equals(PrimalItems.STONE_GALLAGHER)) {
pItem.damageItem(15, player);
}
if (pItem.getItem().equals(ModItems.forgehammer)) {
pItem.damageItem(1, player);
} }
if (recipe.getOutput().getItem() instanceof ToolPart) { AnvilCrafting recipe = AnvilCrafting.getRecipe(tempArray);
if (!tile.getSlotStack(12).getItem().equals(recipe.getOutput().getItem())) { if (recipe != null) {
ItemStack tempStack = recipe.getOutput(); if (pItem.getItem().equals(PrimalItems.STONE_GALLAGHER)) {
tempStack.setTagCompound(new NBTTagCompound()); pItem.damageItem(15, player);
NBTTagCompound tags = new NBTTagCompound();
tempStack.getTagCompound().setTag("tags", tags);
tempStack.getSubCompound("tags").setBoolean("hot", false);
tempStack.getSubCompound("tags").setBoolean("emerald", false);
tempStack.getSubCompound("tags").setInteger("diamond", 0);
tempStack.getSubCompound("tags").setInteger("redstone", 0);
tempStack.getSubCompound("tags").setInteger("lapis", 0);
tempStack.getSubCompound("tags").setInteger("modifiers", 0);
CommonUtils.spawnItemEntityFromWorld(world, pos, tempStack);
} }
if (pItem.getItem().equals(ModItems.forgehammer)) {
if (tile.getSlotStack(12).getItem().equals(recipe.getOutput().getItem())) { pItem.damageItem(1, player);
}
world.playEvent(1031, pos, 0);
NBTTagCompound tempNBT = tile.getSlotStack(12).getSubCompound("tags"); if (world.rand.nextBoolean()) {
ItemStack outputStack = recipe.getOutput();
outputStack.setTagCompound(new NBTTagCompound());
outputStack.getTagCompound().setTag("tags", tempNBT);
outputStack.getSubCompound("tags").setBoolean("hot", false);
if (outputStack.getSubCompound("tags").getInteger("modifiers") < 3) { if (recipe.getOutput().getItem() instanceof ToolPart) {
//Upgrade emerald if (!tile.getSlotStack(12).getItem().equals(recipe.getOutput().getItem())) {
if (recipe.getUpgrade() == "emerald") { ItemStack tempStack = recipe.getOutput();
if (outputStack.getSubCompound("tags").getInteger("lapis") == 0) { tempStack.setTagCompound(new NBTTagCompound());
if (outputStack.getSubCompound("tags").getBoolean("emerald") == false) { NBTTagCompound tags = new NBTTagCompound();
outputStack.getSubCompound("tags").setInteger("emerald",
(outputStack.getSubCompound("tags").getInteger("emerald") + 1)); tempStack.getTagCompound().setTag("tags", tags);
tempStack.getSubCompound("tags").setBoolean("hot", false);
tempStack.getSubCompound("tags").setBoolean("emerald", false);
tempStack.getSubCompound("tags").setInteger("diamond", 0);
tempStack.getSubCompound("tags").setInteger("redstone", 0);
tempStack.getSubCompound("tags").setInteger("lapis", 0);
tempStack.getSubCompound("tags").setInteger("modifiers", 0);
CommonUtils.spawnItemEntityFromWorld(world, pos, tempStack);
}
if (tile.getSlotStack(12).getItem().equals(recipe.getOutput().getItem())) {
NBTTagCompound tempNBT = tile.getSlotStack(12).getSubCompound("tags");
ItemStack outputStack = recipe.getOutput();
outputStack.setTagCompound(new NBTTagCompound());
outputStack.getTagCompound().setTag("tags", tempNBT);
outputStack.getSubCompound("tags").setBoolean("hot", false);
if (outputStack.getSubCompound("tags").getInteger("modifiers") < 3) {
//Upgrade emerald
if (recipe.getUpgrade() == "emerald") {
if (outputStack.getSubCompound("tags").getInteger("lapis") == 0) {
if (outputStack.getSubCompound("tags").getBoolean("emerald") == false) {
outputStack.getSubCompound("tags").setInteger("emerald",
(outputStack.getSubCompound("tags").getInteger("emerald") + 1));
outputStack.getSubCompound("tags").setInteger("modifiers",
(outputStack.getSubCompound("tags").getInteger("modifiers") + 1));
}
}
}
//Upgrade diamond
if (recipe.getUpgrade() == "diamond") {
outputStack.getSubCompound("tags").setInteger("diamond",
(outputStack.getSubCompound("tags").getInteger("diamond") + 1));
outputStack.getSubCompound("tags").setInteger("modifiers", outputStack.getSubCompound("tags").setInteger("modifiers",
(outputStack.getSubCompound("tags").getInteger("modifiers") + 1)); (outputStack.getSubCompound("tags").getInteger("modifiers") + 1));
} }
//Upgrade redstone
if (recipe.getUpgrade() == "redstone") {
outputStack.getSubCompound("tags").setInteger("redstone",
(outputStack.getSubCompound("tags").getInteger("redstone") + 1));
outputStack.getSubCompound("tags").setInteger("modifiers",
(outputStack.getSubCompound("tags").getInteger("modifiers") + 1));
}
//Upgrade lapis
if (recipe.getUpgrade() == "lapis") {
if (outputStack.getSubCompound("tags").getBoolean("emerald") == false) {
outputStack.getSubCompound("tags").setInteger("lapis",
(outputStack.getSubCompound("tags").getInteger("lapis") + 1));
outputStack.getSubCompound("tags").setInteger("modifiers",
(outputStack.getSubCompound("tags").getInteger("modifiers") + 1));
}
}
} }
CommonUtils.spawnItemEntityFromWorld(world, pos, outputStack);
} }
//Upgrade diamond } else {
if (recipe.getUpgrade() == "diamond") { CommonUtils.spawnItemEntityFromWorld(world, pos, recipe.getOutput());
outputStack.getSubCompound("tags").setInteger("diamond",
(outputStack.getSubCompound("tags").getInteger("diamond") + 1));
outputStack.getSubCompound("tags").setInteger("modifiers",
(outputStack.getSubCompound("tags").getInteger("modifiers") + 1));
}
//Upgrade redstone
if (recipe.getUpgrade() == "redstone") {
outputStack.getSubCompound("tags").setInteger("redstone",
(outputStack.getSubCompound("tags").getInteger("redstone") + 1));
outputStack.getSubCompound("tags").setInteger("modifiers",
(outputStack.getSubCompound("tags").getInteger("modifiers") + 1));
}
//Upgrade lapis
if (recipe.getUpgrade() == "lapis") {
if (outputStack.getSubCompound("tags").getBoolean("emerald") == false) {
outputStack.getSubCompound("tags").setInteger("lapis",
(outputStack.getSubCompound("tags").getInteger("lapis") + 1));
outputStack.getSubCompound("tags").setInteger("modifiers",
(outputStack.getSubCompound("tags").getInteger("modifiers") + 1));
}
}
} }
CommonUtils.spawnItemEntityFromWorld(world, pos, outputStack); //world.playEvent(1031, pos, 0);
} for (int i = 0; i < tile.getSlotListSize(); i++) {
if (!tile.getSlotStack(i).isEmpty()) {
} else { tile.setSlotStack(i, ItemStack.EMPTY);
CommonUtils.spawnItemEntityFromWorld(world, pos, recipe.getOutput()); }
} }
return true;
/*
NBTTagCompound tempNBT = this.getSlotStack(i).getSubCompound("tags");
ItemStack outputStack = recipe.getOutput();
outputStack.getTagCompound().setTag("tags", tempNBT);
outputStack.getSubCompound("tags").setBoolean("hot", true);
this.setSlotStack(i, outputStack);
*/
world.playEvent(1031, pos, 0);
for (int i = 0; i < tile.getSlotListSize(); i++) {
if (!tile.getSlotStack(i).isEmpty()) {
tile.setSlotStack(i, ItemStack.EMPTY);
} }
} }
return true;
} }
} }
/*****************************************************************************
Adding and Removing Inventory With Tongs
*****************************************************************************/
/*****************************************************************************
Adding and Removing Inventory With Tongs
*****************************************************************************/
if ((pItem.getItem() != PrimalItems.STONE_GALLAGHER) || (pItem.getItem() != ModItems.forgehammer)) { if ((pItem.getItem() != PrimalItems.STONE_GALLAGHER) || (pItem.getItem() != ModItems.forgehammer)) {
@@ -262,10 +271,11 @@ public class Anvil extends CustomContainerFacing {
} }
} }
} }
return false; return false;
} }
} }
return false; return false;
} }