aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-03-22 04:22:55 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-03-22 04:22:55 +1000
commit46590e0c7b1f874c368f9ac335b4333222723c1e (patch)
tree54be6b541abf674c86b6b57a03372ccadbffded2
parentb6ee1cacc50dec9ee65d30d8d62f0fbe1591bdc7 (diff)
downloadGT5-Unofficial-46590e0c7b1f874c368f9ac335b4333222723c1e.tar.gz
GT5-Unofficial-46590e0c7b1f874c368f9ac335b4333222723c1e.tar.bz2
GT5-Unofficial-46590e0c7b1f874c368f9ac335b4333222723c1e.zip
Added a Staballoy Treecapacitor style axe and a Staballoy TiCo. Hammer style Pickaxe.
Optimised the code to check block facement through raytracing. Something to refine later.
-rw-r--r--src/Java/miscutil/MiscUtils.java5
-rw-r--r--src/Java/miscutil/core/item/ModItems.java13
-rw-r--r--src/Java/miscutil/core/item/tool/staballoy/StaballoyAxe.java256
-rw-r--r--src/Java/miscutil/core/item/tool/staballoy/StaballoyPickaxe.java148
4 files changed, 415 insertions, 7 deletions
diff --git a/src/Java/miscutil/MiscUtils.java b/src/Java/miscutil/MiscUtils.java
index fa0f043675..1a26e1add9 100644
--- a/src/Java/miscutil/MiscUtils.java
+++ b/src/Java/miscutil/MiscUtils.java
@@ -17,13 +17,12 @@ import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
-import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
-@Mod(modid=CORE.MODID, name="Misc. Utils", version=CORE.VERSION, dependencies="required-after:gregtech; after:Thaumcraft;")
+@Mod(modid=CORE.MODID, name="Misc. Utils", version=CORE.VERSION, dependencies="required-after:gregtech;")
public class MiscUtils
implements ActionListener
{
@@ -46,7 +45,7 @@ implements ActionListener
proxy.registerTileEntities();
proxy.registerRenderThings();
proxy.preInit(event);
- FMLInterModComms.sendMessage("Waila", "register", "miscutil.core.waila.WailaCompat.load");
+ //FMLInterModComms.sendMessage("Waila", "register", "miscutil.core.waila.WailaCompat.load");
}
//Init
diff --git a/src/Java/miscutil/core/item/ModItems.java b/src/Java/miscutil/core/item/ModItems.java
index 814f0a10d6..f876a38fbd 100644
--- a/src/Java/miscutil/core/item/ModItems.java
+++ b/src/Java/miscutil/core/item/ModItems.java
@@ -5,8 +5,8 @@ import static miscutil.core.lib.CORE.LOAD_ALL_CONTENT;
import miscutil.core.creativetabs.AddToCreativeTab;
import miscutil.core.item.effects.RarityUncommon;
import miscutil.core.item.tool.staballoy.StaballoyPickaxe;
-import miscutil.core.lib.LoadedMods;
import miscutil.core.lib.CORE;
+import miscutil.core.lib.LoadedMods;
import miscutil.core.util.Utils;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
@@ -196,8 +196,12 @@ public final class ModItems {
if (LoadedMods.Thaumcraft|| LOAD_ALL_CONTENT){
Utils.LOG_INFO("Thaumcraft Found - Loading Resources.");
//Item Init
+ try {
itemPlateVoidMetal = new Item().setUnlocalizedName("itemPlateVoidMetal").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateVoidMetal");;
-
+ } catch (NullPointerException e){
+ e.getClass();
+ }
+
//Registry
GameRegistry.registerItem(itemPlateVoidMetal, "itemPlateVoidMetal");
@@ -210,8 +214,11 @@ public final class ModItems {
if (LoadedMods.Extra_Utils|| LOAD_ALL_CONTENT){
Utils.LOG_INFO("ExtraUtilities Found - Loading Resources.");
//Item Init
+ try {
itemPlateBedrockium = new Item().setUnlocalizedName("itemPlateBedrockium").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateBedrockium");;
-
+ } catch (NullPointerException e){
+ e.getClass();
+ }
//Registry
GameRegistry.registerItem(itemPlateBedrockium, "itemPlateBedrockium");
diff --git a/src/Java/miscutil/core/item/tool/staballoy/StaballoyAxe.java b/src/Java/miscutil/core/item/tool/staballoy/StaballoyAxe.java
new file mode 100644
index 0000000000..64ed49f80c
--- /dev/null
+++ b/src/Java/miscutil/core/item/tool/staballoy/StaballoyAxe.java
@@ -0,0 +1,256 @@
+package miscutil.core.item.tool.staballoy;
+
+import miscutil.core.lib.CORE;
+import net.minecraft.block.Block;
+import net.minecraft.block.BlockAir;
+import net.minecraft.block.BlockCocoa;
+import net.minecraft.block.BlockDirt;
+import net.minecraft.block.BlockDoublePlant;
+import net.minecraft.block.BlockFlower;
+import net.minecraft.block.BlockGrass;
+import net.minecraft.block.BlockHugeMushroom;
+import net.minecraft.block.BlockLeavesBase;
+import net.minecraft.block.BlockLog;
+import net.minecraft.block.BlockMushroom;
+import net.minecraft.block.BlockSand;
+import net.minecraft.block.BlockSnow;
+import net.minecraft.block.BlockSnowBlock;
+import net.minecraft.block.BlockTallGrass;
+import net.minecraft.block.BlockVine;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemAxe;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
+
+public class StaballoyAxe extends ItemAxe{
+ public String mat;
+
+ public StaballoyAxe(ToolMaterial material, String materialName) {
+ super(material);
+ mat=materialName;
+ setCreativeTab(CreativeTabs.tabTools);
+ setUnlocalizedName("lumberaxe"+mat);
+ setTextureName(CORE.MODID+":lumberaxe_"+mat);
+ }
+
+ // EXPLODE TREE
+ byte[] tre= new byte[32000];
+ byte unchecked=0;
+ byte needcheck=1;
+ byte ignore =2;
+ byte harvest =3;
+
+ private boolean setcheck(int x, int y, int z) {
+ if(x<0 || x>19 || z<0 || z>19 || y<0 || y>79) return false;
+ int o=x+z*20+y*400;
+ if (tre[o]==unchecked) tre[o]=needcheck;
+ return true;
+ }
+
+ public boolean canIgnore(Block bit){
+ if (bit instanceof BlockAir)return true;
+ if (bit instanceof BlockGrass)return true;
+ if (bit instanceof BlockSand)return true;
+ if (bit instanceof BlockDirt)return true;
+ if (bit instanceof BlockCocoa)return true;
+ if (bit instanceof BlockVine)return true;
+ if (bit instanceof BlockMushroom)return true;
+ if (bit instanceof BlockSnow)return true;
+ if (bit instanceof BlockSnowBlock)return true;
+ if (bit instanceof BlockFlower)return true;
+ if (bit instanceof BlockTallGrass)return true;
+ if (bit instanceof BlockDoublePlant)return true;
+
+ //LoonTools.log("Found uncuttable "+bit.getClass().getSimpleName());
+ return false;
+ }
+
+ private int check(World par1World, int x, int y, int z, int xo, int yo,int zo) {
+ int f=0;
+ int o=x+z*20+y*400;
+ if (tre[o]==needcheck){
+ tre[o]=ignore;
+ Block bit = par1World.getBlock(x+xo, y+yo, z+zo);
+ if ((bit instanceof BlockLog)||(bit instanceof BlockLeavesBase)||(bit instanceof BlockHugeMushroom)){
+ f=1;
+ tre[o]=harvest;
+ //if (bit instanceof BlockLog){
+ // LoonTools.log("^ Found log @ "+x+xo+" "+y+yo+" "+z+zo+" ");
+ //}
+ for(int xb=-1;xb<2;xb++)
+ for(int yb=-1;yb<2;yb++)
+ for(int zb=-1;zb<2;zb++)
+ if (!setcheck(x+xb,y+yb,z+zb))return 3;
+ }else{
+ if (!canIgnore(bit)) return 2;
+ }
+ }
+ return f;
+ }
+
+ public int checkTree(World par1World,int xo,int yo,int zo){
+ boolean f;
+ for (f=true;f==true;){
+ f=false;
+ for (int y=0;y<80;y++)
+ for(int z=0;z<20;z++)
+ for(int x=0;x<20;x++){
+ int r=check(par1World,x,y,z,xo,yo,zo);
+ if (r==3) return 3;
+ if (r==2) return 2;
+ if (r==1) f=true;
+ }
+
+ for (int y=79;y>=0;y--)
+ for(int z=19;z>=0;z--)
+ for(int x=19;x>=0;x--){
+ int r=check(par1World,x,y,z,xo,yo,zo);
+ if (r==2) return 3;
+ if (r==2) return 2;
+ if (r==1) f=true;
+ }
+ }
+ return 1;
+ }
+
+ private int check2(World par1World, int x, int y, int z, int xo, int yo,int zo) {
+ int f=0;
+ int o=x+z*20+y*400;
+ if (tre[o]==needcheck){
+ tre[o]=ignore;
+ Block bit = par1World.getBlock(x+xo, y+yo, z+zo);
+ if (bit instanceof BlockLog){
+ f=1;
+ tre[o]=harvest;
+ //if (bit instanceof BlockLog){
+ // LoonTools.log("^ Found log @ "+x+xo+" "+y+yo+" "+z+zo+" ");
+ //}
+ for(int xb=-1;xb<2;xb++)
+ for(int yb=-1;yb<2;yb++)
+ for(int zb=-1;zb<2;zb++)
+ if (!setcheck(x+xb,y+yb,z+zb))return 3;
+ }else if (bit instanceof BlockLeavesBase){
+ }else{
+ if (!canIgnore(bit)) return 2;
+ }
+ }
+ return f;
+ }
+
+ public int checkTree2(World par1World,int xo,int yo,int zo){
+ boolean f;
+ for (f=true;f==true;){
+ f=false;
+ for (int y=0;y<80;y++)
+ for(int z=0;z<20;z++)
+ for(int x=0;x<20;x++){
+ int r=check2(par1World,x,y,z,xo,yo,zo);
+ if (r==3) return 3;
+ if (r==2) return 2;
+ if (r==1) f=true;
+ }
+
+ for (int y=79;y>=0;y--)
+ for(int z=19;z>=0;z--)
+ for(int x=19;x>=0;x--){
+ int r=check2(par1World,x,y,z,xo,yo,zo);
+ if (r==2) return 3;
+ if (r==2) return 2;
+ if (r==1) f=true;
+ }
+ }
+ return 1;
+ }
+
+ public void exploadTree(World par1World,int xo,int yo,int zo, EntityPlayer plr){
+ for (int y=0;y<80;y++)
+ for(int z=0;z<20;z++)
+ for(int x=0;x<20;x++){
+ int o=x+z*20+y*400;
+ if (tre[o]==harvest){
+ Block bit = par1World.getBlock(x+xo, y+yo, z+zo);
+ int met = par1World.getBlockMetadata(x+xo, y+yo, z+zo);
+
+ if ((bit instanceof BlockLog)||(bit instanceof BlockLeavesBase)){
+ bit.harvestBlock(par1World, plr, x+xo, y+yo, z+zo,met);
+ par1World.setBlockToAir(x+xo, y+yo, z+zo);
+ }
+ }
+ }
+ }
+
+ private void breakMushroom(World wld, Block bit, EntityPlayer plr, boolean silk, int x, int y, int z, int met) {
+ if (silk){
+ ItemStack stk = null; //TODO
+ /*if (bit==Blocks.brown_mushroom_block) stk = new ItemStack(LoonToolItems.brown_mushroom_block,1,met);
+ else if (bit==Blocks.red_mushroom_block) stk = new ItemStack(LoonToolItems.red_mushroom_block,1,met);
+ else stk = new ItemStack(bit,1,met);*/
+ EntityItem entityitem = new EntityItem(wld, x+0.5, y+0.5, z+0.5, stk);
+ entityitem.delayBeforeCanPickup = 10;
+ wld.spawnEntityInWorld(entityitem);
+ }else{
+ bit.harvestBlock(wld, plr, x, y, z, met);
+ }
+ wld.setBlockToAir(x, y, z);
+ }
+
+ public void exploadMushroom(World par1World,int xo,int yo,int zo, EntityPlayer plr, boolean silk){
+ for (int y=0;y<80;y++)
+ for(int z=0;z<20;z++)
+ for(int x=0;x<20;x++){
+ int o=x+z*20+y*400;
+ if (tre[o]==harvest){
+ Block bit = par1World.getBlock(x+xo, y+yo, z+zo);
+ int met = par1World.getBlockMetadata(x+xo, y+yo, z+zo);
+ if (bit instanceof BlockHugeMushroom){
+ breakMushroom(par1World, bit, plr, silk, x+xo, y+yo, z+zo,met);
+ }else{
+ bit.harvestBlock(par1World, plr, x+xo, y+yo, z+zo,met);
+ par1World.setBlockToAir(x+xo, y+yo, z+zo);
+ }
+ }
+ }
+ }
+
+
+ @Override
+ public boolean onBlockDestroyed(ItemStack itm, World wld,Block blk, int x, int y,int z, EntityLivingBase plr) {
+ if (!wld.isRemote){
+ Block bit = wld.getBlock(x, y, z);
+ boolean silk=EnchantmentHelper.getSilkTouchModifier(plr);
+ if ((bit instanceof BlockHugeMushroom)){
+ for (int n=0;n<32000;n++) tre[n]=unchecked;
+ int met = wld.getBlockMetadata(x, y, z);
+ breakMushroom(wld, bit, (EntityPlayer) plr, silk, x, y, z,met);
+ wld.setBlockToAir(x,y,z);
+ tre[2210]=needcheck;
+ if (checkTree(wld,x-10,y-4,z-10)==1){
+ exploadMushroom(wld,x-10,y-4,z-10,(EntityPlayer) plr,silk);
+ }
+ }
+
+ if (bit instanceof BlockLog){
+ //LoonTools.log("cutting tree @ "+x+" "+y+" "+z+" ");
+ for (int n=0;n<32000;n++) tre[n]=unchecked;
+ int met = wld.getBlockMetadata(x, y, z);
+ bit.harvestBlock(wld, (EntityPlayer) plr, x, y, z,met);
+ wld.setBlockToAir(x,y,z);
+ tre[2210]=needcheck;
+ if (checkTree(wld,x-10,y-4,z-10)==1){
+ exploadTree(wld,x-10,y-4,z-10,(EntityPlayer) plr);
+ }else{
+ for (int n=0;n<32000;n++) tre[n]=unchecked;
+ tre[2210]=needcheck;
+ if (checkTree2(wld,x-10,y-4,z-10)==1){
+ exploadTree(wld,x-10,y-4,z-10,(EntityPlayer) plr);
+ }
+ }
+ }
+ }
+ return super.onBlockDestroyed(itm, wld, blk, x, y, z, plr);
+ }
+} \ No newline at end of file
diff --git a/src/Java/miscutil/core/item/tool/staballoy/StaballoyPickaxe.java b/src/Java/miscutil/core/item/tool/staballoy/StaballoyPickaxe.java
index 150279118f..d797ceb67f 100644
--- a/src/Java/miscutil/core/item/tool/staballoy/StaballoyPickaxe.java
+++ b/src/Java/miscutil/core/item/tool/staballoy/StaballoyPickaxe.java
@@ -1,14 +1,160 @@
package miscutil.core.item.tool.staballoy;
+import java.util.List;
+
import miscutil.core.lib.CORE;
+import miscutil.core.util.Utils;
+import net.minecraft.block.Block;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
import net.minecraft.item.ItemPickaxe;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.world.World;
public class StaballoyPickaxe extends ItemPickaxe{
+ private Boolean FACING_HORIZONTAL = true;
+ private String FACING = "north";
+ private EntityPlayer localPlayer;
+
+ /*
+ *
+ *
+ *
+ * Methods
+ *
+ *
+ *
+ */
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer aPlayer) {
+ localPlayer = aPlayer;
+ checkFacing(world);
+ return super.onItemRightClick(stack, world, aPlayer);
+ }
+
+
+
+ @Override
+ public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int X, int Y, int Z, EntityLivingBase entity) {
+ //super.onBlockDestroyed(stack, world, block, X, Y, Z, entity);
+
+ GetDestroyOrientation("FLAT, TOPDOWN OR BOTTOMUP", world, X, Y, Z);
+
+ return super.onBlockDestroyed(stack, world, block, X, Y, Z, entity);
+ }
+
+ private void GetDestroyOrientation(String FACING, World world, int X, int Y, int Z){
+ for(int i = -1; i < 2; i++) {
+ for(int j = -1; j < 2; j++) {
+ removeBlockAndDropAsItem(world, X + i, Y, Z + j, i, j);
+ }
+ }
+ }
+
+ //Should clear up blocks quicker if I chain it.
+ @SuppressWarnings("static-method")
+ private void removeBlockAndDropAsItem(World world, int X, int Y, int Z, int i, int j){
+ Block block = world.getBlock(X, Y, Z);
+ if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) != -1)){
+ block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0);
+ world.setBlockToAir(X, Y, Z);
+ }
+ }
+
+ private boolean checkFacing(World world){
+ if (!localPlayer.equals(null) || localPlayer != null || (!localPlayer.equals(null) && localPlayer != null)){
+ int direction = MathHelper.floor_double((double)((localPlayer.rotationYaw * 4F) / 360F) + 0.5D) & 3;
+ //Utils.LOG_INFO("Player - F: "+direction);
+ Utils.LOG_INFO("Player - getLookVec(): "+localPlayer.getLookVec().yCoord);
+
+ /*if (localPlayer.getLookVec().yCoord > 0){
+ localPlayer.getLookVec().yCoord;
+ }*/
+
+ MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, (EntityPlayer) localPlayer, false);
+ int sideHit = movingobjectposition.sideHit;
+ String playerStandingPosition;
+ if (movingobjectposition != null) {
+ System.out.println("Side Hit: "+movingobjectposition.sideHit);
+ }
+
+ if (sideHit == 0){
+ playerStandingPosition = "below";
+ }
+ else if (sideHit == 1){
+ playerStandingPosition = "above";
+ }
+ else if (sideHit == 2){
+ playerStandingPosition = "facingSouth";
+ }
+ else if (sideHit == 3){
+ playerStandingPosition = "facingNorth";
+ }
+ else if (sideHit == 4){
+ playerStandingPosition = "facingEast";
+ }
+ else if (sideHit == 5){
+ playerStandingPosition = "facingWest";
+ }
+
+ if (direction == 0){
+ FACING = "south";
+ }
+ else if (direction == 1){
+ FACING = "west";
+ }
+ else if (direction == 2){
+ FACING = "north";
+ }
+ else if (direction == 3){
+ FACING = "east";
+ }
+
+
+ }
+ return false;
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) {
+ String facing;
+ if (FACING_HORIZONTAL){
+ facing = "Horizontal";
+ }
+ else {
+ facing = "Vertical";
+ }
+ list.add("Mines a 3x3 area on the "+facing+" axis.");
+
+
+ super.addInformation(stack, aPlayer, list, bool);
+ }
+
+ @Override
+ public boolean onBlockStartBreak(ItemStack itemstack, int X, int Y, int Z, EntityPlayer aPlayer) {
+
+ localPlayer = aPlayer;
+
+ return super.onBlockStartBreak(itemstack, X, Y, Z, aPlayer);
+ }
+
public StaballoyPickaxe(String unlocalizedName, ToolMaterial material) {
super(material);
this.setUnlocalizedName(unlocalizedName);
- this.setTextureName(CORE.MODID + ":" + unlocalizedName);
+ this.setTextureName(CORE.MODID + ":" + unlocalizedName);
+ this.FACING_HORIZONTAL=true;
}
+ /*public boolean onBlockDestroyed(ItemStack stack, World w, int id, int x, int y, int z, EntityLiving entity){
+ super.onBlockDestroyed(stack, w, , x, y, z, entity);
+ Block block = this.
+
+ }*/
+
}