From 6ecc76786555e2aaa7b1e9f5c65b9619a9d93239 Mon Sep 17 00:00:00 2001 From: Jordan Byrne Date: Thu, 22 Feb 2018 15:46:32 +1000 Subject: + Added a debug item for linking blocks. % More project clean-up. % Made fish trap 2x slower. $ Fixed issue with fish trap name. $ Fixed .08 issue getting powder barrels. --- .../core/item/tool/misc/ConnectedBlockFinder.java | 150 +++++++++++++++++++++ .../core/item/tool/staballoy/StaballoyPickaxe.java | 4 +- .../core/item/tool/staballoy/StaballoySpade.java | 4 +- 3 files changed, 154 insertions(+), 4 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/item/tool/misc/ConnectedBlockFinder.java (limited to 'src/Java/gtPlusPlus/core/item/tool') diff --git a/src/Java/gtPlusPlus/core/item/tool/misc/ConnectedBlockFinder.java b/src/Java/gtPlusPlus/core/item/tool/misc/ConnectedBlockFinder.java new file mode 100644 index 0000000000..f0cc8c7344 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/tool/misc/ConnectedBlockFinder.java @@ -0,0 +1,150 @@ +package gtPlusPlus.core.item.tool.misc; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.BaseItemWithDamageValue; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +public class ConnectedBlockFinder extends BaseItemWithDamageValue{ + + public ConnectedBlockFinder() { + super("item.test.connector"); + this.setTextureName("stick"); + this.setMaxStackSize(1); + this.setMaxDamage(10000); + setCreativeTab(AddToCreativeTab.tabTools); + GameRegistry.registerItem(this, getUnlocalizedName()); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add(EnumChatFormatting.GRAY+"Finds connected blocks, turns them to Glass once found."); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid(final ItemStack itemStack){ + return false; + } + + @Override + public boolean getShareTag(){ + return true; + } + + @Override + public boolean hasContainerItem(final ItemStack itemStack){ + return true; + } + @Override + public ItemStack getContainerItem(final ItemStack itemStack){ + return itemStack; + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(final ItemStack par1ItemStack){ + return EnumRarity.uncommon; + } + + @Override + public boolean hasEffect(final ItemStack par1ItemStack){ + return false; + } + + + @Override + public boolean onItemUse( + ItemStack stack, EntityPlayer player, World world, + int x, int y, int z, int side, + float hitX, float hitY, float hitZ) { + + BlockPos mStartPoint = new BlockPos(x,y,z); + + Block mBlockType = world.getBlock(x, y, z); + int mBlockMeta = mBlockType.getDamageValue(world, x, y, z); + + Set mTotalIndex = new HashSet(); + Set mFirstSearch = new HashSet(); + Set mSearch_A = new HashSet(); + Set mSearch_B = new HashSet(); + Set mSearch_C = new HashSet(); + + for (BlockPos b : mStartPoint.getSurroundingBlocks().values()) { + if (world.getBlock(b.xPos, b.yPos, b.zPos) == mBlockType) { + if (mBlockType.getDamageValue(world, b.xPos, b.yPos, b.zPos) == mBlockMeta) { + if (mFirstSearch.add(b)) { + if (mTotalIndex.add(b)) { + world.setBlock(b.xPos, b.yPos, b.zPos, Blocks.emerald_ore); + } + } + } + } + } + + for (BlockPos b : mFirstSearch) { + if (world.getBlock(b.xPos, b.yPos, b.zPos) == mBlockType) { + if (mBlockType.getDamageValue(world, b.xPos, b.yPos, b.zPos) == mBlockMeta) { + if (mSearch_A.add(b)) { + if (mTotalIndex.add(b)) { + world.setBlock(b.xPos, b.yPos, b.zPos, Blocks.emerald_ore); + } + } + } + } + } + + for (BlockPos b : mSearch_A) { + if (world.getBlock(b.xPos, b.yPos, b.zPos) == mBlockType) { + if (mBlockType.getDamageValue(world, b.xPos, b.yPos, b.zPos) == mBlockMeta) { + if (mSearch_B.add(b)) { + if (mTotalIndex.add(b)) { + world.setBlock(b.xPos, b.yPos, b.zPos, Blocks.emerald_ore); + } + } + } + } + } + + for (BlockPos b : mSearch_B) { + if (world.getBlock(b.xPos, b.yPos, b.zPos) == mBlockType) { + if (mBlockType.getDamageValue(world, b.xPos, b.yPos, b.zPos) == mBlockMeta) { + if (mSearch_C.add(b)) { + if (mTotalIndex.add(b)) { + world.setBlock(b.xPos, b.yPos, b.zPos, Blocks.emerald_ore); + } + } + } + } + } + + return super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ); + } + + @Override + public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { + // TODO Auto-generated method stub + return super.onItemRightClick(p_77659_1_, p_77659_2_, p_77659_3_); + } + + + + + + + +} diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java index 5ad027409b..138015b7cd 100644 --- a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java @@ -6,7 +6,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.UtilsMining; +import gtPlusPlus.core.util.minecraft.MiningUtils; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -101,7 +101,7 @@ public class StaballoyPickaxe extends ItemPickaxe{ if (!currentWorld.isRemote){ try { correctTool = currentBlock.getHarvestTool(0); - if (UtilsMining.getBlockType(currentBlock, currentWorld, xyz, this.miningLevel) || correctTool.equals("pickaxe") || correctTool.equals("null")){ + if (MiningUtils.getBlockType(currentBlock, currentWorld, xyz, this.miningLevel) || correctTool.equals("pickaxe") || correctTool.equals("null")){ //Utils.LOG_WARNING(correctTool); return true;} } catch (final NullPointerException e){ diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java index 50a2a48588..067a2ea9bd 100644 --- a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java @@ -6,7 +6,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.UtilsMining; +import gtPlusPlus.core.util.minecraft.MiningUtils; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -76,7 +76,7 @@ public class StaballoySpade extends ItemSpade{ //Utils.LOG_WARNING(correctTool); Logger.WARNING("Tool for Block: "+correctTool+" | Current block: "+currentBlock.getLocalizedName()); - if (UtilsMining.getBlockType(currentBlock, currentWorld, xyz, this.miningLevel) || correctTool.equals("shovel")){ + if (MiningUtils.getBlockType(currentBlock, currentWorld, xyz, this.miningLevel) || correctTool.equals("shovel")){ return true;} } catch (final NullPointerException e){ return false;} -- cgit