From 9543e46c0b90d1e087214020afd23e35180d5a03 Mon Sep 17 00:00:00 2001 From: DarkGuardsman Date: Mon, 23 Sep 2013 13:35:59 -0400 Subject: [PATCH] ChangesToPairClass --- src/dark/api/ProcessorRecipes.java | 4 +-- src/dark/core/common/RecipeLoader.java | 4 +-- src/dark/core/common/debug/BlockDebug.java | 25 +++++++++++++++++++ .../core/prefab/helpers/ItemWorldHelper.java | 13 +++++----- .../core/prefab/machine/BlockMachine.java | 17 +++++++++++-- .../core/registration/ModObjectRegistry.java | 4 +-- 6 files changed, 52 insertions(+), 15 deletions(-) diff --git a/src/dark/api/ProcessorRecipes.java b/src/dark/api/ProcessorRecipes.java index 874167e6..d697f717 100644 --- a/src/dark/api/ProcessorRecipes.java +++ b/src/dark/api/ProcessorRecipes.java @@ -222,9 +222,9 @@ public class ProcessorRecipes //Read chance output map Pair ree = mapChance.get(blockSet); - if (ree != null && random.nextFloat() >= ree.getValue()) + if (ree != null && random.nextFloat() >= ree.right()) { - return new ItemStack[] { convert(ree.getKey()) }; + return new ItemStack[] { convert(ree.left()) }; } //Start salvaging items diff --git a/src/dark/core/common/RecipeLoader.java b/src/dark/core/common/RecipeLoader.java index 390d478f..fb443418 100644 --- a/src/dark/core/common/RecipeLoader.java +++ b/src/dark/core/common/RecipeLoader.java @@ -118,8 +118,8 @@ public abstract class RecipeLoader public RecipeGrid(Object stack, Pair one, Pair two) { this(stack); - this.setRowOne(one.getKey(), one.getValue()); - this.setRowTwo(two.getKey(), two.getValue()); + this.setRowOne(one.left(), one.right()); + this.setRowTwo(two.left(), two.right()); this.hight = 2; this.width = 2; } diff --git a/src/dark/core/common/debug/BlockDebug.java b/src/dark/core/common/debug/BlockDebug.java index 1aa87972..7413db53 100644 --- a/src/dark/core/common/debug/BlockDebug.java +++ b/src/dark/core/common/debug/BlockDebug.java @@ -8,6 +8,7 @@ import com.builtbroken.common.Pair; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; @@ -123,6 +124,30 @@ public class BlockDebug extends BlockMachine } + @Override + public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) + { + return false; + } + + @Override + public boolean onSneakMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) + { + return false; + } + + @Override + public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) + { + return false; + } + + @Override + public boolean onSneakUseWrench(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) + { + return this.onUseWrench(world, x, y, z, entityPlayer, side, hitX, hitY, hitZ); + } + public static enum DebugBlocks { SOURCE("UnlimitedPower", TileEntityInfSupply.class, "infSource"), diff --git a/src/dark/core/prefab/helpers/ItemWorldHelper.java b/src/dark/core/prefab/helpers/ItemWorldHelper.java index 3bc9ef66..505c3cd5 100644 --- a/src/dark/core/prefab/helpers/ItemWorldHelper.java +++ b/src/dark/core/prefab/helpers/ItemWorldHelper.java @@ -21,7 +21,7 @@ public class ItemWorldHelper } /** Gets all EntityItems in an area and sorts them by a list of itemStacks - * + * * @param world - world being worked in * @param start - start point * @param end - end point @@ -37,12 +37,11 @@ public class ItemWorldHelper public static List filterEntityItemsList(List entityItems, List disiredItems) { List newItemList = new ArrayList(); - - for (EntityItem entityItem : entityItems) + for (ItemStack itemStack : disiredItems) { - for (ItemStack itemStack : disiredItems) + for (EntityItem entityItem : entityItems) { - if (entityItem.getEntityItem().itemID == itemStack.itemID && entityItem.getEntityItem().getItemDamage() == itemStack.getItemDamage() && !newItemList.contains(entityItem)) + if (entityItem.getEntityItem().isItemEqual(itemStack) && !newItemList.contains(entityItem)) { newItemList.add(entityItem); break; @@ -69,7 +68,7 @@ public class ItemWorldHelper } /** filter a list of itemStack to another list of itemStacks - * + * * @param totalItems - full list of items being filtered * @param desiredItems - list the of item that are being filtered too * @return a list of item from the original that are wanted */ @@ -92,7 +91,7 @@ public class ItemWorldHelper } /** grabs all the items that the block can drop then pass them onto dropBlockAsItem_do - * + * * @param world * @param x * @param y diff --git a/src/dark/core/prefab/machine/BlockMachine.java b/src/dark/core/prefab/machine/BlockMachine.java index f5444970..132c1bb9 100644 --- a/src/dark/core/prefab/machine/BlockMachine.java +++ b/src/dark/core/prefab/machine/BlockMachine.java @@ -6,6 +6,7 @@ import com.builtbroken.common.Pair; import net.minecraft.block.ITileEntityProvider; import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.world.World; @@ -17,13 +18,14 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import dark.api.parts.INetworkPart; import dark.core.common.DarkMain; +import dark.core.interfaces.IBlockActivated; import dark.core.prefab.IExtraInfo.IExtraBlockInfo; import dark.core.prefab.ModPrefab; import dark.core.registration.ModObjectRegistry.BlockBuildData; /** Basic TileEntity Container class designed to be used by generic machines. It is suggested that - * each mod using this create there own basic block extending this to reduce need to use build - * data per block. + * each mod using this create there own basic block extending this to reduce need to use build data + * per block. * * @author Darkguardsman */ public abstract class BlockMachine extends BlockTile implements IExtraBlockInfo @@ -120,4 +122,15 @@ public abstract class BlockMachine extends BlockTile implements IExtraBlockInfo } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) + { + TileEntity entity = world.getBlockTileEntity(x, y, z); + if (entity instanceof IBlockActivated && ((IBlockActivated) entity).onActivated(entityPlayer)) + { + return true; + } + return super.onBlockActivated(world, x, y, z, entityPlayer, side, hitX, hitY, hitZ); + } + } diff --git a/src/dark/core/registration/ModObjectRegistry.java b/src/dark/core/registration/ModObjectRegistry.java index fdac66bb..87d65410 100644 --- a/src/dark/core/registration/ModObjectRegistry.java +++ b/src/dark/core/registration/ModObjectRegistry.java @@ -190,7 +190,7 @@ public class ModObjectRegistry { for (Pair> par : data.tiles) { - GameRegistry.registerTileEntityWithAlternatives(par.getValue(), par.getKey(), "DM" + par.getKey()); + GameRegistry.registerTileEntityWithAlternatives(par.right(), par.left(), "DM" + par.left()); } } if (data.creativeTab != null) @@ -215,7 +215,7 @@ public class ModObjectRegistry ((IExtraBlockInfo) block).getTileEntities(block.blockID, tileListNew); for (Pair> par : tileListNew) { - GameRegistry.registerTileEntityWithAlternatives(par.getValue(), par.getKey(), "DM" + par.getKey()); + GameRegistry.registerTileEntityWithAlternatives(par.right(), par.left(), "DM" + par.left()); } } }