mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
Updates to metadata, change to use block.getRelative in Woodcutting.java
This commit is contained in:
parent
058cc3aac9
commit
bb5d003430
@ -395,8 +395,8 @@ public class Combat {
|
||||
baseXP = 20 * LoadProperties.pvpxprewardmodifier;
|
||||
}
|
||||
}
|
||||
else if (!target.hasMetadata("fromMobSpawner")) {
|
||||
if (target instanceof Animals && !target.hasMetadata("summoned")) {
|
||||
else if (!target.hasMetadata("mcmmoFromMobSpawner")) {
|
||||
if (target instanceof Animals && !target.hasMetadata("mcmmoSummoned")) {
|
||||
baseXP = LoadProperties.animalXP;
|
||||
}
|
||||
else {
|
||||
|
@ -75,7 +75,7 @@ public class mcBlockListener implements Listener {
|
||||
}
|
||||
else {
|
||||
Block newLocation = block.getRelative(0, y+1, 0);
|
||||
newLocation.setMetadata("placedBlock", new FixedMetadataValue(plugin, true));
|
||||
newLocation.setMetadata("mcmmoPlacedBlock", new FixedMetadataValue(plugin, true));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -83,7 +83,7 @@ public class mcBlockListener implements Listener {
|
||||
|
||||
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
|
||||
if (BlockChecks.shouldBeWatched(mat)) {
|
||||
block.setMetadata("placedBlock", new FixedMetadataValue(plugin, true));
|
||||
block.setMetadata("mcmmoPlacedBlock", new FixedMetadataValue(plugin, true));
|
||||
}
|
||||
|
||||
if (id == LoadProperties.anvilID && LoadProperties.anvilmessages) {
|
||||
@ -176,7 +176,7 @@ public class mcBlockListener implements Listener {
|
||||
* EXCAVATION
|
||||
*/
|
||||
|
||||
if (Excavation.canBeGigaDrillBroken(mat) && mcPermissions.getInstance().excavation(player) && !block.hasMetadata("placedBlock")) {
|
||||
if (Excavation.canBeGigaDrillBroken(mat) && mcPermissions.getInstance().excavation(player) && !block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if (LoadProperties.excavationRequiresShovel && ItemChecks.isShovel(inhand)) {
|
||||
Excavation.excavationProcCheck(block, player);
|
||||
}
|
||||
@ -186,8 +186,8 @@ public class mcBlockListener implements Listener {
|
||||
}
|
||||
|
||||
//Remove metadata when broken
|
||||
if (block.hasMetadata("placedBlock") && BlockChecks.shouldBeWatched(mat)) {
|
||||
block.removeMetadata("placedBlock", plugin);
|
||||
if (block.hasMetadata("mcmmoPlacedBlock") && BlockChecks.shouldBeWatched(mat)) {
|
||||
block.removeMetadata("mcmmoPlacedBlock", plugin);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ public class mcEntityListener implements Listener {
|
||||
@EventHandler (priority = EventPriority.MONITOR)
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
if (event.getSpawnReason().equals(SpawnReason.SPAWNER) && !LoadProperties.xpGainsMobSpawners) {
|
||||
event.getEntity().setMetadata("fromMobSpawner", new FixedMetadataValue(plugin, true));
|
||||
event.getEntity().setMetadata("mcmmoFromMobSpawner", new FixedMetadataValue(plugin, true));
|
||||
}
|
||||
}
|
||||
|
||||
@ -287,7 +287,7 @@ public class mcEntityListener implements Listener {
|
||||
public void onEntityTame(EntityTameEvent event) {
|
||||
Player player = (Player) event.getOwner();
|
||||
|
||||
if (mcPermissions.getInstance().taming(player) && !event.getEntity().hasMetadata("summoned")) {
|
||||
if (mcPermissions.getInstance().taming(player) && !event.getEntity().hasMetadata("mcmmoSummoned")) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
EntityType type = event.getEntityType();
|
||||
int xp = 0;
|
||||
|
@ -48,7 +48,7 @@ public class BlastMining {
|
||||
blocksDropped.add(temp);
|
||||
Mining.miningDrops(temp);
|
||||
|
||||
if (!temp.hasMetadata("placedBlock")) {
|
||||
if (!temp.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if (extraDrops == 2) {
|
||||
blocksDropped.add(temp);
|
||||
Mining.miningDrops(temp);
|
||||
@ -160,7 +160,7 @@ public class BlastMining {
|
||||
}
|
||||
|
||||
for (Block block : xp) {
|
||||
if (!block.hasMetadata("placedBlock")) {
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
Mining.miningXP(player, block);
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ public class Excavation {
|
||||
public static void gigaDrillBreaker(Player player, Block block) {
|
||||
Skills.abilityDurabilityLoss(player.getItemInHand(), LoadProperties.abilityDurabilityLoss);
|
||||
|
||||
if (!block.hasMetadata("placedBlock")) {
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);
|
||||
Bukkit.getPluginManager().callEvent(armswing);
|
||||
|
||||
|
@ -135,7 +135,7 @@ public class Herbalism {
|
||||
Block b = block.getRelative(0, y, 0);
|
||||
if (b.getType().equals(Material.CACTUS)) {
|
||||
mat = Material.CACTUS;
|
||||
if (!b.hasMetadata("placedBlock")) {
|
||||
if (!b.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if(herbLevel > MAX_BONUS_LEVEL || (Math.random() * 1000 <= herbLevel)) {
|
||||
catciDrops++;
|
||||
}
|
||||
@ -154,7 +154,7 @@ public class Herbalism {
|
||||
break;
|
||||
|
||||
case MELON_BLOCK:
|
||||
if (!block.hasMetadata("placedBlock")) {
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
mat = Material.MELON;
|
||||
xp = LoadProperties.mmelon;
|
||||
}
|
||||
@ -169,7 +169,7 @@ public class Herbalism {
|
||||
|
||||
case PUMPKIN:
|
||||
case JACK_O_LANTERN:
|
||||
if (!block.hasMetadata("placedBlock")) {
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
mat = Material.getMaterial(id);
|
||||
xp = LoadProperties.mpumpkin;
|
||||
}
|
||||
@ -177,7 +177,7 @@ public class Herbalism {
|
||||
|
||||
case RED_ROSE:
|
||||
case YELLOW_FLOWER:
|
||||
if (!block.hasMetadata("placedBlock")) {
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
mat = Material.getMaterial(id);
|
||||
xp = LoadProperties.mflower;
|
||||
}
|
||||
@ -188,7 +188,7 @@ public class Herbalism {
|
||||
Block b = block.getRelative(0, y, 0);
|
||||
if (b.getType().equals(Material.SUGAR_CANE_BLOCK)) {
|
||||
mat = Material.SUGAR_CANE;
|
||||
if (!b.hasMetadata("placedBlock")) {
|
||||
if (!b.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if(herbLevel > MAX_BONUS_LEVEL || (Math.random() * 1000 <= herbLevel)) {
|
||||
caneDrops++;
|
||||
}
|
||||
@ -199,14 +199,14 @@ public class Herbalism {
|
||||
break;
|
||||
|
||||
case VINE:
|
||||
if (!block.hasMetadata("placedBlock")) {
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
mat = type;
|
||||
xp = LoadProperties.mvines;
|
||||
}
|
||||
break;
|
||||
|
||||
case WATER_LILY:
|
||||
if (!block.hasMetadata("placedBlock")) {
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
mat = type;
|
||||
xp = LoadProperties.mlilypad;
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ public class Mining
|
||||
* @param plugin mcMMO plugin instance
|
||||
*/
|
||||
public static void miningBlockCheck(Player player, Block block, mcMMO plugin) {
|
||||
if (block.hasMetadata("placedBlock")) {
|
||||
if (block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -251,7 +251,7 @@ public class Mining
|
||||
case NETHERRACK:
|
||||
case SANDSTONE:
|
||||
case STONE:
|
||||
if (!block.hasMetadata("placedBlock")) {
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,7 @@ public class Taming {
|
||||
}
|
||||
}
|
||||
LivingEntity entity = player.getWorld().spawnCreature(player.getLocation(), type);
|
||||
entity.setMetadata("summoned", new FixedMetadataValue(plugin, true));
|
||||
entity.setMetadata("mcmmoSummoned", new FixedMetadataValue(plugin, true));
|
||||
((Tameable) entity).setOwner(player);
|
||||
|
||||
player.setItemInHand(new ItemStack(summonItem, item.getAmount() - summonAmount));
|
||||
|
@ -3,7 +3,6 @@ package com.gmail.nossr50.skills;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -32,13 +31,12 @@ public class WoodCutting
|
||||
Player player = event.getPlayer();
|
||||
Block firstBlock = event.getBlock();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
World world = firstBlock.getWorld();
|
||||
|
||||
//Prepare array
|
||||
ArrayList<Block> toBeFelled = new ArrayList<Block>();
|
||||
|
||||
//NOTE: Tree Feller will cut upwards like how you actually fell trees
|
||||
processTreeFelling(firstBlock, world, toBeFelled, plugin);
|
||||
processTreeFelling(firstBlock, toBeFelled, plugin);
|
||||
removeBlocks(toBeFelled, player, PP, plugin);
|
||||
}
|
||||
|
||||
@ -97,7 +95,7 @@ public class WoodCutting
|
||||
break;
|
||||
}
|
||||
|
||||
if(!x.hasMetadata("placedBlock"))
|
||||
if(!x.hasMetadata("mcmmoPlacedBlock"))
|
||||
{
|
||||
WoodCutting.woodCuttingProcCheck(player, x);
|
||||
|
||||
@ -149,9 +147,8 @@ public class WoodCutting
|
||||
return block.getType() == Material.LOG || block.getType() == Material.LEAVES || block.getType() == Material.AIR;
|
||||
}
|
||||
|
||||
private static void processTreeFelling(Block currentBlock, World world, ArrayList<Block> toBeFelled, mcMMO plugin)
|
||||
private static void processTreeFelling(Block currentBlock, ArrayList<Block> toBeFelled, mcMMO plugin)
|
||||
{
|
||||
int x = currentBlock.getX(), y = currentBlock.getY(), z = currentBlock.getZ();
|
||||
|
||||
if(currentBlock.getType() == Material.LOG || currentBlock.getType() == Material.LEAVES)
|
||||
toBeFelled.add(currentBlock);
|
||||
@ -159,32 +156,32 @@ public class WoodCutting
|
||||
//These 2 are to make sure that Tree Feller isn't so aggressive
|
||||
boolean isAirOrLeaves = currentBlock.getType() == Material.LEAVES || currentBlock.getType() == Material.AIR;
|
||||
|
||||
Block xPositive = world.getBlockAt(x+1, y, z);
|
||||
Block xNegative = world.getBlockAt(x-1, y, z);
|
||||
Block zPositive = world.getBlockAt(x, y, z+1);
|
||||
Block zNegative = world.getBlockAt(x, y, z-1);
|
||||
Block xPositive = currentBlock.getRelative(1, 0, 0);
|
||||
Block xNegative = currentBlock.getRelative(-1, 0, 0);
|
||||
Block zPositive = currentBlock.getRelative(0, 0, 1);
|
||||
Block zNegative = currentBlock.getRelative(0, 0, -1);
|
||||
|
||||
if(!currentBlock.hasMetadata("placedBlock") &&
|
||||
if(!currentBlock.hasMetadata("mcmmoPlacedBlock") &&
|
||||
!isTooAgressive(isAirOrLeaves, xPositive) && treeFellerCompatible(xPositive) && !toBeFelled.contains(xPositive))
|
||||
processTreeFelling(xPositive, world, toBeFelled, plugin);
|
||||
if(!currentBlock.hasMetadata("placedBlock") &&
|
||||
processTreeFelling(xPositive, toBeFelled, plugin);
|
||||
if(!currentBlock.hasMetadata("mcmmoPlacedBlock") &&
|
||||
!isTooAgressive(isAirOrLeaves, xNegative) && treeFellerCompatible(xNegative) && !toBeFelled.contains(xNegative))
|
||||
processTreeFelling(xNegative, world, toBeFelled, plugin);
|
||||
if(!currentBlock.hasMetadata("placedBlock") &&
|
||||
processTreeFelling(xNegative, toBeFelled, plugin);
|
||||
if(!currentBlock.hasMetadata("mcmmoPlacedBlock") &&
|
||||
!isTooAgressive(isAirOrLeaves, zPositive) && treeFellerCompatible(zPositive) && !toBeFelled.contains(zPositive))
|
||||
processTreeFelling(zPositive, world, toBeFelled, plugin);
|
||||
if(!currentBlock.hasMetadata("placedBlock") &&
|
||||
processTreeFelling(zPositive, toBeFelled, plugin);
|
||||
if(!currentBlock.hasMetadata("mcmmoPlacedBlock") &&
|
||||
!isTooAgressive(isAirOrLeaves, zNegative) && treeFellerCompatible(zNegative) && !toBeFelled.contains(zNegative))
|
||||
processTreeFelling(zNegative, world, toBeFelled, plugin);
|
||||
processTreeFelling(zNegative, toBeFelled, plugin);
|
||||
|
||||
//Finally go Y+
|
||||
Block yPositive = world.getBlockAt(x, y+1, z);
|
||||
Block yPositive = currentBlock.getRelative(0, 1, 0);
|
||||
|
||||
if(treeFellerCompatible(yPositive))
|
||||
{
|
||||
if(!currentBlock.hasMetadata("placedBlock") && !toBeFelled.contains(yPositive))
|
||||
if(!currentBlock.hasMetadata("mcmmoPlacedBlock") && !toBeFelled.contains(yPositive))
|
||||
{
|
||||
processTreeFelling(yPositive, world, toBeFelled, plugin);
|
||||
processTreeFelling(yPositive, toBeFelled, plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user