updating the anvil method

This commit is contained in:
Mohammad-Ali Minaie
2017-03-26 02:38:47 -04:00
parent 2df60f9bc3
commit a8235c01d1
7 changed files with 64 additions and 33 deletions

View File

@@ -3,9 +3,11 @@ To-Dos
*** Priority *** *** Priority ***
- [ ] OreDict Stuff - [ ] OreDict Stuff
- [ ] Use Primal Brick instead of clay brick - [x] Can't remove fuel from Bloomery
- [ ] Iron Plate Recipe - [ ] Crafting Recipe for Iron Ingot to Iron Ball
- [ ] Bucket Crafting - [ ] Block To Read Temperature
- [ ] Bellows Moves Faster
*** 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

View File

@@ -83,6 +83,7 @@ public class Anvil extends CustomContainerFacing {
ItemStack pItem = player.inventory.getCurrentItem(); ItemStack pItem = player.inventory.getCurrentItem();
TileAnvil tile = (TileAnvil) world.getTileEntity(pos); TileAnvil tile = (TileAnvil) world.getTileEntity(pos);
if (tile != null) { if (tile != null) {
//System.out.println("Tile is not null");
if ((player.inventory.getCurrentItem().getItem().equals(PrimalItems.STONE_GALLAGHER)) || (player.inventory.getCurrentItem().getItem() == ModItems.forgehammer)) { if ((player.inventory.getCurrentItem().getItem().equals(PrimalItems.STONE_GALLAGHER)) || (player.inventory.getCurrentItem().getItem() == ModItems.forgehammer)) {
@@ -203,22 +204,15 @@ public class Anvil extends CustomContainerFacing {
if ((pItem.getItem() != PrimalItems.STONE_GALLAGHER) || (pItem.getItem() != ModItems.forgehammer)) { if ((pItem.getItem() != PrimalItems.STONE_GALLAGHER) || (pItem.getItem() != ModItems.forgehammer)) {
if (pItem.getItem().equals(ModItems.stonetongs)) {
if ((pItem.getTagCompound().getInteger("type") == 6) || (pItem.getTagCompound().getInteger("type") == 7) ||
(pItem.getTagCompound().getInteger("type") == 8) ||
(pItem.getTagCompound().getInteger("type") == 9) ||
(pItem.getTagCompound().getInteger("type") == 10) ||
(pItem.getTagCompound().getInteger("type") == 11) ||
(pItem.getTagCompound().getInteger("type") == 0)) {
if (state.getValue(FACING) == EnumFacing.NORTH) { if (state.getValue(FACING) == EnumFacing.NORTH) {
int counter = 0; int counter = 0;
for (int z = 0; z < 5; z++) { for (int z = 0; z < 5; z++) {
for (int x = 0; x < 5; x++) { for (int x = 0; x < 5; x++) {
if (hitx >= this.getNormalMin(x) && hitx <= this.getNormalMax(x)) { if (hitx >= this.getNormalMin(x) && hitx <= this.getNormalMax(x)) {
if (hitz >= this.getNormalMin(z) && hitz <= this.getNormalMax(z)) { if (hitz >= this.getNormalMin(z) && hitz <= this.getNormalMax(z)) {
doWork(pItem, counter, tile, world, pos, player); doWork(pItem, counter, tile, world, pos, player);
//System.out.println("Doing work"); return true;
} }
} }
counter++; counter++;
@@ -231,9 +225,8 @@ public class Anvil extends CustomContainerFacing {
for (int x = 0; x < 5; x++) { for (int x = 0; x < 5; x++) {
if (hitx >= this.getReverseMin(x) && hitx <= this.getReverseMax(x)) { if (hitx >= this.getReverseMin(x) && hitx <= this.getReverseMax(x)) {
if (hitz >= this.getReverseMin(z) && hitz <= this.getReverseMax(z)) { if (hitz >= this.getReverseMin(z) && hitz <= this.getReverseMax(z)) {
doWork(pItem, counter, tile, world, pos, player); doWork(pItem, counter, tile, world, pos, player);
return true;
} }
} }
counter++; counter++;
@@ -246,9 +239,8 @@ public class Anvil extends CustomContainerFacing {
for (int z = 0; z < 5; z++) { for (int z = 0; z < 5; z++) {
if (hitx >= this.getNormalMin(x) && hitx <= this.getNormalMax(x)) { if (hitx >= this.getNormalMin(x) && hitx <= this.getNormalMax(x)) {
if (hitz >= this.getReverseMin(z) && hitz <= this.getReverseMax(z)) { if (hitz >= this.getReverseMin(z) && hitz <= this.getReverseMax(z)) {
doWork(pItem, counter, tile, world, pos, player); doWork(pItem, counter, tile, world, pos, player);
return true;
} }
} }
counter++; counter++;
@@ -261,17 +253,16 @@ public class Anvil extends CustomContainerFacing {
for (int z = 0; z < 5; z++) { for (int z = 0; z < 5; z++) {
if (hitx >= this.getReverseMin(x) && hitx <= this.getReverseMax(x)) { if (hitx >= this.getReverseMin(x) && hitx <= this.getReverseMax(x)) {
if (hitz >= this.getNormalMin(z) && hitz <= this.getNormalMax(z)) { if (hitz >= this.getNormalMin(z) && hitz <= this.getNormalMax(z)) {
doWork(pItem, counter, tile, world, pos, player); doWork(pItem, counter, tile, world, pos, player);
return true;
} }
} }
counter++; counter++;
} }
} }
} }
}
}
} }
} }
return false; return false;
@@ -280,8 +271,16 @@ public class Anvil extends CustomContainerFacing {
} }
private boolean doWork(ItemStack pItem, Integer counter, TileAnvil tile, World world, BlockPos pos, EntityPlayer player) { private boolean doWork(ItemStack pItem, Integer counter, TileAnvil tile, World world, BlockPos pos, EntityPlayer player) {
if (pItem.getItem().equals(ModItems.stonetongs)) { if (pItem.getItem().equals(ModItems.stonetongs)) {
//System.out.println("Level 1"); if ((pItem.getTagCompound().getInteger("type") == 6) ||
(pItem.getTagCompound().getInteger("type") == 7) ||
(pItem.getTagCompound().getInteger("type") == 8) ||
(pItem.getTagCompound().getInteger("type") == 9) ||
(pItem.getTagCompound().getInteger("type") == 10) ||
(pItem.getTagCompound().getInteger("type") == 11) ||
(pItem.getTagCompound().getInteger("type") == 0)) {
//System.out.println("Level 1");
if (!tile.getSlotStack(counter).isEmpty()) { if (!tile.getSlotStack(counter).isEmpty()) {
if (pItem.getTagCompound().getInteger("type") == 0) { if (pItem.getTagCompound().getInteger("type") == 0) {
@@ -294,6 +293,7 @@ public class Anvil extends CustomContainerFacing {
pItem.getTagCompound().setInteger("type", 7); pItem.getTagCompound().setInteger("type", 7);
tile.setSlotStack(counter, ItemStack.EMPTY); tile.setSlotStack(counter, ItemStack.EMPTY);
//System.out.println(counter); //System.out.println(counter);
//System.out.println(counter);
return true; return true;
} }
@@ -301,17 +301,20 @@ public class Anvil extends CustomContainerFacing {
} }
if (tile.getSlotStack(counter).isEmpty()) { if (tile.getSlotStack(counter).isEmpty()) {
//System.out.println("Activating"); System.out.println("Activating");
if (pItem.getTagCompound().getInteger("type") == 6) { if (pItem.getTagCompound().getInteger("type") == 6) {
System.out.println("Tongs meta = 6");
tile.setSlotStack((counter), new ItemStack(ModItems.ironingotballhot, 1)); tile.setSlotStack((counter), new ItemStack(ModItems.ironingotballhot, 1));
pItem.getTagCompound().setInteger("type", 0); pItem.getTagCompound().setInteger("type", 0);
return true; //return true;
} }
if (pItem.getTagCompound().getInteger("type") == 7) { if (pItem.getTagCompound().getInteger("type") == 7) {
System.out.println("Tongs meta = 7");
tile.setSlotStack((counter), new ItemStack(ModItems.ironchunkhot, 1)); tile.setSlotStack((counter), new ItemStack(ModItems.ironchunkhot, 1));
pItem.getTagCompound().setInteger("type", 0); pItem.getTagCompound().setInteger("type", 0);
//System.out.println(counter); System.out.println(counter);
return true; System.out.println(tile.getSlotStack(counter));
//return true;
} }
if (pItem.getTagCompound().getInteger("type") == 8) { if (pItem.getTagCompound().getInteger("type") == 8) {
ItemStack tempStack = new ItemStack(ModItems.pickaxehead, 1); ItemStack tempStack = new ItemStack(ModItems.pickaxehead, 1);
@@ -379,6 +382,9 @@ public class Anvil extends CustomContainerFacing {
} }
} }
} }
}
//System.out.println("1" + pItem); //System.out.println("1" + pItem);
@@ -448,7 +454,9 @@ public class Anvil extends CustomContainerFacing {
} }
if (pItem.getItem().equals(Items.DIAMOND)) { if (pItem.getItem().equals(Items.DIAMOND)) {
System.out.println("It Is Diamond");
if (tile.getSlotStack(counter).isEmpty()) { if (tile.getSlotStack(counter).isEmpty()) {
System.out.println("Slot is empty");
tile.setSlotStack(counter, new ItemStack(pItem.getItem(), 1)); tile.setSlotStack(counter, new ItemStack(pItem.getItem(), 1));
pItem.shrink(1); pItem.shrink(1);
return true; return true;
@@ -534,7 +542,9 @@ public class Anvil extends CustomContainerFacing {
@Override @Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{ {
worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing()),2); if(!worldIn.isRemote) {
worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing()), 2);
}
} }
@Override @Override

View File

@@ -23,6 +23,7 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import nmd.primal.forgecraft.CommonUtils;
import nmd.primal.forgecraft.ModInfo; import nmd.primal.forgecraft.ModInfo;
import nmd.primal.forgecraft.tiles.TileBloomery; import nmd.primal.forgecraft.tiles.TileBloomery;
@@ -63,7 +64,9 @@ public class Bloomery extends CustomContainerFacing implements ITileEntityProvid
ItemStack tileItem = tile.getSlotStack(0); ItemStack tileItem = tile.getSlotStack(0);
ItemStack tileItem1 = tile.getSlotStack(1); ItemStack tileItem1 = tile.getSlotStack(1);
if(pItem.isEmpty()) { if(pItem.isEmpty()) {
/*if (player.isSneaking()) {
if (player.isSneaking()) {
if (!tileItem.isEmpty()) { if (!tileItem.isEmpty()) {
CommonUtils.spawnItemEntity(world, player, tile.getSlotStack(0)); CommonUtils.spawnItemEntity(world, player, tile.getSlotStack(0));
tile.setSlotStack(0, ItemStack.EMPTY); tile.setSlotStack(0, ItemStack.EMPTY);
@@ -71,7 +74,7 @@ public class Bloomery extends CustomContainerFacing implements ITileEntityProvid
tile.updateBlock(); tile.updateBlock();
return true; return true;
} }
}*/ }
if(!player.isSneaking()){ if(!player.isSneaking()){
if(world.getBlockState(pos).getValue(ACTIVE) == true){ if(world.getBlockState(pos).getValue(ACTIVE) == true){
Integer tempInt = tile.getHeat(); Integer tempInt = tile.getHeat();
@@ -200,7 +203,10 @@ public class Bloomery extends CustomContainerFacing implements ITileEntityProvid
@Override @Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{ {
worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing()).withProperty(ACTIVE, Boolean.valueOf(false)).withProperty(COVERED, Boolean.valueOf(false)), 2); if(!worldIn.isRemote){
worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing()).withProperty(ACTIVE, Boolean.valueOf(false)).withProperty(COVERED, Boolean.valueOf(false)), 2);
}
} }
@Override @Override

View File

@@ -345,7 +345,9 @@ public class Forge extends CustomContainerFacing implements ITileEntityProvider/
@Override @Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{ {
worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing()).withProperty(ACTIVE, Boolean.valueOf(false)), 2); if(!worldIn.isRemote) {
worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing()).withProperty(ACTIVE, Boolean.valueOf(false)), 2);
}
} }
@Override @Override

View File

@@ -90,7 +90,7 @@ public class ModBlocks {
{ {
if(!world.isRemote){ if(!world.isRemote){
Item pItem = player.getHeldItem(hand).getItem(); Item pItem = player.getHeldItem(hand).getItem();
BlockPos belowPos = new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ()); BlockPos belowPos = pos.down();
//System.out.println("Activating"); //System.out.println("Activating");
if (pItem.equals(PrimalItems.STONE_GALLAGHER) && world.getBlockState(belowPos).getBlock().equals(Blocks.STONE)) { if (pItem.equals(PrimalItems.STONE_GALLAGHER) && world.getBlockState(belowPos).getBlock().equals(Blocks.STONE)) {
player.swingArm(hand); player.swingArm(hand);

View File

@@ -175,6 +175,17 @@ public class ModCrafting {
1.0f 1.0f
); );
// Converts a Vanilla Ingot into ForgeCraft Ingot Ball
ForgeCrafting.addRecipe(
Items.IRON_INGOT,
new ItemStack(ModItems.ironingotballhot, 1),
800,
200,
500,
1.0f,
1.0f
);
//Makes a Hot Iron Chunk //Makes a Hot Iron Chunk
ForgeCrafting.addRecipe( ForgeCrafting.addRecipe(
Item.getItemFromBlock(ModBlocks.ironchunk), Item.getItemFromBlock(ModBlocks.ironchunk),

View File

@@ -311,7 +311,7 @@ public class ItemStoneTongs extends Item {
else return EnumActionResult.FAIL; else return EnumActionResult.FAIL;
//System.out.println(itemstack.getTagCompound().getInteger("type")); //System.out.println(itemstack.getTagCompound().getInteger("type"));
} }
//System.out.println(player.getHeldItem(hand).getTagCompound().getInteger("type")); System.out.println(player.getHeldItem(hand).getTagCompound().getInteger("type"));
return EnumActionResult.FAIL; return EnumActionResult.FAIL;
} }
@@ -321,7 +321,7 @@ public class ItemStoneTongs extends Item {
public void addInformation(ItemStack item, EntityPlayer player, List<String> tooltip, boolean advanced) public void addInformation(ItemStack item, EntityPlayer player, List<String> tooltip, boolean advanced)
{ {
tooltip.add(ChatFormatting.BLUE + "NBT: " + item.getSubCompound("tags")); tooltip.add(ChatFormatting.BLUE + "NBT: " + item.getSubCompound("tags"));
//tooltip.add(ChatFormatting.RED + "Consumes sticks"); tooltip.add(ChatFormatting.RED + "NBT: " + item.getTagCompound().getInteger("type"));
} }
} }