diff options
author | feildmaster <admin@feildmaster.com> | 2012-03-25 18:06:43 -0500 |
---|---|---|
committer | Warren Loo <evilseph@gmail.com> | 2012-03-25 19:46:55 -0400 |
commit | 80db22b643ca55f116474b3285a07d447ab188ee (patch) | |
tree | 9d14c2c7b913c7bd7506e17c262942e5153c25b7 /src/main/java/net | |
parent | c30e339af6dd7594cca7e0c1ca31f0ea34a0afa9 (diff) | |
download | craftbukkit-80db22b643ca55f116474b3285a07d447ab188ee.tar craftbukkit-80db22b643ca55f116474b3285a07d447ab188ee.tar.gz craftbukkit-80db22b643ca55f116474b3285a07d447ab188ee.tar.lz craftbukkit-80db22b643ca55f116474b3285a07d447ab188ee.tar.xz craftbukkit-80db22b643ca55f116474b3285a07d447ab188ee.zip |
Refactor code to be more efficient.
Diffstat (limited to 'src/main/java/net')
8 files changed, 16 insertions, 20 deletions
diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java index 43430951..3244351d 100644 --- a/src/main/java/net/minecraft/server/Block.java +++ b/src/main/java/net/minecraft/server/Block.java @@ -164,7 +164,7 @@ public class Block { public final Material material; public float frictionFactor; private String name; - public ArrayList<ItemStack> dropList = new ArrayList<ItemStack>(1); // CraftBukkit + public final ArrayList<ItemStack> dropList = new ArrayList<ItemStack>(1); // CraftBukkit protected Block(int i, Material material) { this.bR = true; @@ -362,7 +362,7 @@ public class Block { protected void a(World world, int i, int j, int k, ItemStack itemstack) { // CraftBukkit start - the logic of this function is moved into finishDrop - // This is such a hackish change it's rediculous. + // This is such a hackish change it's ridiculous. this.dropList.add(itemstack); } @@ -550,6 +550,7 @@ public class Block { this.dropList.clear(); } + // Blocks that have different drops in certain situations need to override this. IE: Sheers on BlockLeaves public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) { // CraftBukkit end if (this.h() && EnchantmentManager.hasSilkTouchEnchantment(entityhuman.inventory)) { @@ -563,7 +564,8 @@ public class Block { this.dropNaturally(world, i, j, k, l, 1.0F, i1); // CraftBukkit } - return this.dropList; // CraftBukkit + + return this.dropList; } protected boolean h() { diff --git a/src/main/java/net/minecraft/server/BlockDeadBush.java b/src/main/java/net/minecraft/server/BlockDeadBush.java index 60f53b88..fdb4573f 100644 --- a/src/main/java/net/minecraft/server/BlockDeadBush.java +++ b/src/main/java/net/minecraft/server/BlockDeadBush.java @@ -1,6 +1,5 @@ package net.minecraft.server; -import java.util.ArrayList; // CraftBukkit import java.util.Random; public class BlockDeadBush extends BlockFlower { @@ -38,13 +37,13 @@ public class BlockDeadBush extends BlockFlower { } // CraftBukkit start - Calculate drops - public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) { + public java.util.ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) { if (!world.isStatic && entityhuman.U() != null && entityhuman.U().id == Item.SHEARS.id) { this.a(world, i, j, k, new ItemStack(Block.DEAD_BUSH, 1, l)); - return this.dropList; } else { return super.calculateDrops(world, entityhuman, i, j, k, l); } + return this.dropList; } // CraftBukkit end } diff --git a/src/main/java/net/minecraft/server/BlockLeaves.java b/src/main/java/net/minecraft/server/BlockLeaves.java index 6345fafc..02b7ab12 100644 --- a/src/main/java/net/minecraft/server/BlockLeaves.java +++ b/src/main/java/net/minecraft/server/BlockLeaves.java @@ -1,6 +1,5 @@ package net.minecraft.server; -import java.util.ArrayList; // CraftBukkit import java.util.Random; import org.bukkit.event.block.LeavesDecayEvent; // CraftBukkit @@ -173,13 +172,13 @@ public class BlockLeaves extends BlockTransparant { } // CraftBukkit start - Calculate drops - public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) { + public java.util.ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) { if (!world.isStatic && entityhuman.U() != null && entityhuman.U().id == Item.SHEARS.id) { this.a(world, i, j, k, new ItemStack(Block.LEAVES.id, 1, l & 3)); - return this.dropList; } else { return super.calculateDrops(world, entityhuman, i, j, k, l); } + return this.dropList; } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/BlockLongGrass.java b/src/main/java/net/minecraft/server/BlockLongGrass.java index f98ae327..391407bf 100644 --- a/src/main/java/net/minecraft/server/BlockLongGrass.java +++ b/src/main/java/net/minecraft/server/BlockLongGrass.java @@ -1,6 +1,5 @@ package net.minecraft.server; -import java.util.ArrayList; // CraftBukkit import java.util.Random; public class BlockLongGrass extends BlockFlower { @@ -38,13 +37,13 @@ public class BlockLongGrass extends BlockFlower { } // CraftBukkit start - Calculate drops - public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) { + public java.util.ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) { if (!world.isStatic && entityhuman.U() != null && entityhuman.U().id == Item.SHEARS.id) { this.a(world, i, j, k, new ItemStack(Block.LONG_GRASS, 1, l)); - return this.dropList; } else { return super.calculateDrops(world, entityhuman, i, j, k, l); } + return this.dropList; } // CraftBukkit end } diff --git a/src/main/java/net/minecraft/server/BlockPistonExtension.java b/src/main/java/net/minecraft/server/BlockPistonExtension.java index 3ead3a4a..0cb2fa38 100644 --- a/src/main/java/net/minecraft/server/BlockPistonExtension.java +++ b/src/main/java/net/minecraft/server/BlockPistonExtension.java @@ -14,7 +14,7 @@ public class BlockPistonExtension extends Block { } // CraftBukkit start - Support getDrops() in BlockBreakEvent - public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int d) { + public java.util.ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int d) { super.calculateDrops(world, entityhuman, i, j, k, d); int l = world.getData(i, j, k) & 0x7; if (l > 5 || l < 0) return this.dropList; diff --git a/src/main/java/net/minecraft/server/BlockSnow.java b/src/main/java/net/minecraft/server/BlockSnow.java index ea63188a..24c52a35 100644 --- a/src/main/java/net/minecraft/server/BlockSnow.java +++ b/src/main/java/net/minecraft/server/BlockSnow.java @@ -1,6 +1,5 @@ package net.minecraft.server; -import java.util.ArrayList; // CraftBukkit import java.util.Random; import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -74,7 +73,7 @@ public class BlockSnow extends Block { } // CraftBukkit start - Calculate drops - public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) { + public java.util.ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) { this.a(world, i, j, k, new ItemStack(Item.SNOW_BALL.id, 1, 1)); return this.dropList; } diff --git a/src/main/java/net/minecraft/server/BlockTNT.java b/src/main/java/net/minecraft/server/BlockTNT.java index 3aaf8c6d..9a1f0398 100644 --- a/src/main/java/net/minecraft/server/BlockTNT.java +++ b/src/main/java/net/minecraft/server/BlockTNT.java @@ -1,6 +1,5 @@ package net.minecraft.server; -import java.util.ArrayList; // CraftBukkit import java.util.Random; public class BlockTNT extends Block { @@ -57,7 +56,7 @@ public class BlockTNT extends Block { } // CraftBukkit start - Calculate drops - public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) { + public java.util.ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) { if ((l & 1) == 0) { this.a(world, i, j, k, new ItemStack(Block.TNT.id, 1, 0)); } diff --git a/src/main/java/net/minecraft/server/BlockVine.java b/src/main/java/net/minecraft/server/BlockVine.java index 93d8876b..816d6734 100644 --- a/src/main/java/net/minecraft/server/BlockVine.java +++ b/src/main/java/net/minecraft/server/BlockVine.java @@ -1,6 +1,5 @@ package net.minecraft.server; -import java.util.ArrayList; // CraftBukkit import java.util.Random; public class BlockVine extends Block { @@ -298,13 +297,13 @@ public class BlockVine extends Block { } // CraftBukkit start - Calculate drops - public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) { + public java.util.ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) { if (!world.isStatic && entityhuman.U() != null && entityhuman.U().id == Item.SHEARS.id) { this.a(world, i, j, k, new ItemStack(Block.VINE, 1, 0)); - return this.dropList; } else { return super.calculateDrops(world, entityhuman, i, j, k, l); } + return this.dropList; } // CraftBukkit end } |