Initial commit of BM 1.8
This commit is contained in:
parent
d99eadbea7
commit
c5681dc831
713 changed files with 6502 additions and 27334 deletions
|
@ -1,83 +0,0 @@
|
|||
package WayofTime.alchemicalWizardry.common.harvest;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class AgriCraftCropHarvestHandler implements IHarvestHandler
|
||||
{
|
||||
public Block harvestBlock;
|
||||
public Method isMature;
|
||||
public Method harvest;
|
||||
|
||||
public AgriCraftCropHarvestHandler()
|
||||
{
|
||||
this.harvestBlock = getBlockForString("AgriCraft:crops");
|
||||
if(this.harvestBlock != null)
|
||||
{
|
||||
try {
|
||||
Class clazz = Class.forName("com.InfinityRaider.AgriCraft.blocks.BlockCrop");
|
||||
if(clazz != null)
|
||||
{
|
||||
isMature = clazz.getMethod("isMature", World.class, int.class, int.class, int.class);
|
||||
harvest = clazz.getMethod("harvest", World.class, int.class, int.class, int.class);
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchMethodException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (SecurityException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isHarvesterValid()
|
||||
{
|
||||
return harvestBlock != null && isMature != null && harvest != null;
|
||||
}
|
||||
|
||||
public static Block getBlockForString(String str)
|
||||
{
|
||||
String[] parts = str.split(":");
|
||||
String modId = parts[0];
|
||||
String name = parts[1];
|
||||
return GameRegistry.findBlock(modId, name);
|
||||
}
|
||||
|
||||
public boolean canHandleBlock(Block block)
|
||||
{
|
||||
return block == harvestBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean harvestAndPlant(World world, int xCoord, int yCoord, int zCoord, Block block, int meta)
|
||||
{
|
||||
if (!this.canHandleBlock(block))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
return (Boolean)(isMature.invoke(block, world, xCoord, yCoord, zCoord)) && (Boolean)(harvest.invoke(block, world, xCoord, yCoord, zCoord));
|
||||
} catch (IllegalAccessException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IllegalArgumentException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -3,12 +3,13 @@ package WayofTime.alchemicalWizardry.common.harvest;
|
|||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockCrops;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler;
|
||||
|
@ -22,10 +23,6 @@ public class BloodMagicHarvestHandler implements IHarvestHandler
|
|||
|
||||
public int getHarvestMeta(Block block)
|
||||
{
|
||||
if(block instanceof BlockCrops)
|
||||
{
|
||||
|
||||
}
|
||||
if (block == Blocks.wheat)
|
||||
{
|
||||
return 7;
|
||||
|
@ -46,9 +43,9 @@ public class BloodMagicHarvestHandler implements IHarvestHandler
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean harvestAndPlant(World world, int xCoord, int yCoord, int zCoord, Block block, int meta)
|
||||
public boolean harvestAndPlant(World world, BlockPos pos, Block block, IBlockState state)
|
||||
{
|
||||
if (!this.canHandleBlock(block) || meta != this.getHarvestMeta(block))
|
||||
if (!this.canHandleBlock(block) || block.getMetaFromState(state) != this.getHarvestMeta(block))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -62,7 +59,7 @@ public class BloodMagicHarvestHandler implements IHarvestHandler
|
|||
|
||||
int fortune = 0;
|
||||
|
||||
List<ItemStack> list = block.getDrops(world, xCoord, yCoord, zCoord, meta, fortune);
|
||||
List<ItemStack> list = block.getDrops(world, pos, state, fortune);
|
||||
boolean foundAndRemovedSeed = false;
|
||||
|
||||
for (ItemStack stack : list)
|
||||
|
@ -92,16 +89,15 @@ public class BloodMagicHarvestHandler implements IHarvestHandler
|
|||
|
||||
if (foundAndRemovedSeed)
|
||||
{
|
||||
int plantMeta = seed.getPlantMetadata(world, xCoord, yCoord, zCoord);
|
||||
Block plantBlock = seed.getPlant(world, xCoord, yCoord, zCoord);
|
||||
IBlockState plantState = seed.getPlant(world, pos);
|
||||
|
||||
world.func_147480_a(xCoord, yCoord, zCoord, false);
|
||||
world.destroyBlock(pos, false);
|
||||
|
||||
world.setBlock(xCoord, yCoord, zCoord, plantBlock, plantMeta, 3);
|
||||
world.setBlockState(pos, plantState, 3);
|
||||
|
||||
for (ItemStack stack : list)
|
||||
{
|
||||
EntityItem itemEnt = new EntityItem(world, xCoord, yCoord, zCoord, stack);
|
||||
EntityItem itemEnt = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, stack);
|
||||
|
||||
world.spawnEntityInWorld(itemEnt);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package WayofTime.alchemicalWizardry.common.harvest;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler;
|
||||
|
||||
public class CactusReedHarvestHandler implements IHarvestHandler
|
||||
{
|
||||
|
@ -13,19 +15,19 @@ public class CactusReedHarvestHandler implements IHarvestHandler
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean harvestAndPlant(World world, int xCoord, int yCoord, int zCoord, Block block, int meta)
|
||||
public boolean harvestAndPlant(World world, BlockPos pos, Block block, IBlockState state)
|
||||
{
|
||||
if (!this.canHandleBlock(block))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (world.getBlock(xCoord, yCoord - 1, zCoord) != block || world.getBlock(xCoord, yCoord - 2, zCoord) != block)
|
||||
if (world.getBlockState(pos.offsetDown(1)).getBlock() != block || world.getBlockState(pos.offsetDown(2)).getBlock() != block)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
world.func_147480_a(xCoord, yCoord, zCoord, true);
|
||||
world.destroyBlock(pos, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
package WayofTime.alchemicalWizardry.common.harvest;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler;
|
||||
|
||||
public class GenericItemStackHarvestHandler implements IHarvestHandler
|
||||
{
|
||||
|
||||
public Block harvestBlock;
|
||||
public int harvestMeta;
|
||||
public ItemStack harvestItem;
|
||||
|
@ -30,15 +31,15 @@ public class GenericItemStackHarvestHandler implements IHarvestHandler
|
|||
return block == harvestBlock;
|
||||
}
|
||||
|
||||
public int getHarvestMeta(Block block)
|
||||
public int getHarvestMeta()
|
||||
{
|
||||
return harvestMeta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean harvestAndPlant(World world, int xCoord, int yCoord, int zCoord, Block block, int meta)
|
||||
public boolean harvestAndPlant(World world, BlockPos pos, Block block, IBlockState state)
|
||||
{
|
||||
if (!this.canHandleBlock(block) || meta != this.getHarvestMeta(block))
|
||||
if (!this.canHandleBlock(block) || block.getMetaFromState(state) != this.getHarvestMeta())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -47,14 +48,14 @@ public class GenericItemStackHarvestHandler implements IHarvestHandler
|
|||
|
||||
if (seed == null)
|
||||
{
|
||||
world.func_147480_a(xCoord, yCoord, zCoord, true);
|
||||
world.destroyBlock(pos, true);
|
||||
|
||||
return true;
|
||||
} else
|
||||
{
|
||||
int fortune = 0;
|
||||
|
||||
List<ItemStack> list = block.getDrops(world, xCoord, yCoord, zCoord, meta, fortune);
|
||||
List<ItemStack> list = block.getDrops(world, pos, state, fortune);
|
||||
boolean foundAndRemovedSeed = false;
|
||||
|
||||
for (ItemStack stack : list)
|
||||
|
@ -85,16 +86,15 @@ public class GenericItemStackHarvestHandler implements IHarvestHandler
|
|||
|
||||
if (foundAndRemovedSeed)
|
||||
{
|
||||
int plantMeta = seed.getPlantMetadata(world, xCoord, yCoord, zCoord);
|
||||
Block plantBlock = seed.getPlant(world, xCoord, yCoord, zCoord);
|
||||
IBlockState plantState = seed.getPlant(world, pos);
|
||||
|
||||
world.func_147480_a(xCoord, yCoord, zCoord, false);
|
||||
world.destroyBlock(pos, false);
|
||||
|
||||
world.setBlock(xCoord, yCoord, zCoord, plantBlock, plantMeta, 3);
|
||||
world.setBlockState(pos, plantState, 3);
|
||||
|
||||
for (ItemStack stack : list)
|
||||
{
|
||||
EntityItem itemEnt = new EntityItem(world, xCoord, yCoord, zCoord, stack);
|
||||
EntityItem itemEnt = new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), stack);
|
||||
|
||||
world.spawnEntityInWorld(itemEnt);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package WayofTime.alchemicalWizardry.common.harvest;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class GenericPamSeedlessFruitHarvestHandler implements IHarvestHandler
|
||||
{
|
||||
|
@ -45,22 +47,22 @@ public class GenericPamSeedlessFruitHarvestHandler implements IHarvestHandler
|
|||
return block == harvestBlock;
|
||||
}
|
||||
|
||||
public int getHarvestMeta(Block block)
|
||||
public int getHarvestMeta()
|
||||
{
|
||||
return harvestMeta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean harvestAndPlant(World world, int xCoord, int yCoord, int zCoord, Block block, int meta)
|
||||
public boolean harvestAndPlant(World world, BlockPos pos, Block block, IBlockState state)
|
||||
{
|
||||
if (!this.canHandleBlock(block) || meta != this.getHarvestMeta(block))
|
||||
if (!this.canHandleBlock(block) || block.getMetaFromState(state) != this.getHarvestMeta())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
world.func_147480_a(xCoord, yCoord, zCoord, true);
|
||||
world.destroyBlock(pos, true);
|
||||
|
||||
world.setBlock(xCoord, yCoord, zCoord, harvestBlock, resetMeta, 3);
|
||||
world.setBlockState(pos, harvestBlock.getStateFromMeta(resetMeta), 3);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
package WayofTime.alchemicalWizardry.common.harvest;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
|
||||
import java.util.List;
|
||||
import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class GenericSeededHarvestHandler implements IHarvestHandler
|
||||
{
|
||||
|
@ -57,15 +59,15 @@ public class GenericSeededHarvestHandler implements IHarvestHandler
|
|||
return block == harvestBlock;
|
||||
}
|
||||
|
||||
public int getHarvestMeta(Block block)
|
||||
public int getHarvestMeta()
|
||||
{
|
||||
return harvestMeta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean harvestAndPlant(World world, int xCoord, int yCoord, int zCoord, Block block, int meta)
|
||||
public boolean harvestAndPlant(World world, BlockPos pos, Block block, IBlockState state)
|
||||
{
|
||||
if (!this.canHandleBlock(block) || meta != this.getHarvestMeta(block))
|
||||
if (!this.canHandleBlock(block) || block.getMetaFromState(state) != this.getHarvestMeta())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -74,14 +76,14 @@ public class GenericSeededHarvestHandler implements IHarvestHandler
|
|||
|
||||
if (seed == null)
|
||||
{
|
||||
world.func_147480_a(xCoord, yCoord, zCoord, true);
|
||||
world.destroyBlock(pos, true);
|
||||
|
||||
return true;
|
||||
} else
|
||||
{
|
||||
int fortune = 0;
|
||||
|
||||
List<ItemStack> list = block.getDrops(world, xCoord, yCoord, zCoord, meta, fortune);
|
||||
List<ItemStack> list = block.getDrops(world, pos, state, fortune);
|
||||
boolean foundAndRemovedSeed = false;
|
||||
|
||||
for (ItemStack stack : list)
|
||||
|
@ -111,16 +113,15 @@ public class GenericSeededHarvestHandler implements IHarvestHandler
|
|||
|
||||
if (foundAndRemovedSeed)
|
||||
{
|
||||
int plantMeta = seed.getPlantMetadata(world, xCoord, yCoord, zCoord);
|
||||
Block plantBlock = seed.getPlant(world, xCoord, yCoord, zCoord);
|
||||
IBlockState plantState = seed.getPlant(world, pos);
|
||||
|
||||
world.func_147480_a(xCoord, yCoord, zCoord, false);
|
||||
world.destroyBlock(pos, false);
|
||||
|
||||
world.setBlock(xCoord, yCoord, zCoord, plantBlock, plantMeta, 3);
|
||||
world.setBlockState(pos, plantState, 3);
|
||||
|
||||
for (ItemStack stack : list)
|
||||
{
|
||||
EntityItem itemEnt = new EntityItem(world, xCoord, yCoord, zCoord, stack);
|
||||
EntityItem itemEnt = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, stack);
|
||||
|
||||
world.spawnEntityInWorld(itemEnt);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package WayofTime.alchemicalWizardry.common.harvest;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler;
|
||||
|
||||
public class GourdHarvestHandler implements IHarvestHandler
|
||||
{
|
||||
|
@ -13,13 +15,13 @@ public class GourdHarvestHandler implements IHarvestHandler
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean harvestAndPlant(World world, int xCoord, int yCoord, int zCoord, Block block, int meta)
|
||||
public boolean harvestAndPlant(World world, BlockPos pos, Block block, IBlockState state)
|
||||
{
|
||||
if (!this.canHandleBlock(block))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
world.func_147480_a(xCoord, yCoord, zCoord, true);
|
||||
world.destroyBlock(pos, true);
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue