Mod Support - Woodcutting now works. Still need to add # of drops from a

given block.
This commit is contained in:
GJ 2012-05-17 17:03:56 -04:00
parent 0afc0d59a4
commit d20c5e1773
7 changed files with 144 additions and 25 deletions

View File

@ -24,6 +24,7 @@ Version 1.3.07
+ Added config options for enabling/disabling specific double drops
+ Added automatic zip backup of flatfile database & config files
+ Added config options to enable/disable specific skills for PVP & PVE
= Fixed bug where Tree Feller was looking at the wrong blocks for determining how much to take down.
= Fixed bug where Green Terra consumed seeds even on Mossy Stone Brick
= Fixed bug where the client didn't reflect the Stone Brick to Mossy Stone Brick change
= Fixed bug where an arrow could bounce off entities on daze proc
@ -40,6 +41,7 @@ Version 1.3.07
= Fixed some bypass nodes defaulting true for Ops
= Fixed bug with trying to use Chimera Wing while standing on a half-block
= Fixed duplication bug when a placed block was mined after a server restart
= Fixed exploit where shooting yourself with an arrow gave Archery XP
! Changed the mcMMO motd to link to the new website rather than the wiki
! Changed bleeding ticks damage to 1 from 2
! Changed Mining to ignore blocks when the pick is enchanted with Silk Touch
@ -48,7 +50,6 @@ Version 1.3.07
! Changed the permission node for Blast Mining detonation to mcmmo.ability.blastmining.detonate (was mcmmo.skills.blastmining) for the sake of consistency
! Changed skill commands to only display what you have permissions for
! Changed mcMMO to use a new storage system for player placed blocks
- Removed the experience granted when an arrow strikes its shooter
- Removed some unused permission nodes
- Removed a few config options in favor of permissions nodes (Hunger Bonus, Armor/Tool Repair, Instant Wheat Regrowth)
- Removed level requirement for repairing string tools from the config file

View File

@ -27,6 +27,10 @@ public class CustomBlocksConfig extends ModConfigLoader{
public List<ItemStack> customMiningBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customWoodcuttingBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customOres = new ArrayList<ItemStack>();
public List<ItemStack> customLogs = new ArrayList<ItemStack>();
public List<ItemStack> customLeaves = new ArrayList<ItemStack>();
public List<ItemStack> customItems = new ArrayList<ItemStack>();
public List<CustomBlock> customBlocks = new ArrayList<CustomBlock>();
@ -95,6 +99,19 @@ public class CustomBlocksConfig extends ModConfigLoader{
block = new CustomBlock(itemDrop, xp, data, id);
blockItem = new ItemStack(id, 1, (short) 0, data);
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
customOres.add(blockItem);
}
else if (skillType.equals("Woodcutting")) {
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
customLogs.add(blockItem);
}
else {
customLeaves.add(blockItem);
block.setXpGain(0); //Leaves don't grant XP
}
}
blockList.add(blockItem);
customItems.add(blockItem);
customBlocks.add(block);

View File

@ -319,7 +319,7 @@ public class BlockListener implements Listener {
}
}
}
else if (PP.getSkillLevel(SkillType.WOODCUTTING) >= LEAF_BLOWER_LEVEL && mat.equals(Material.LEAVES)) {
else if (PP.getSkillLevel(SkillType.WOODCUTTING) >= LEAF_BLOWER_LEVEL && (mat.equals(Material.LEAVES) || (Config.getInstance().getBlockModsEnabled() && ModChecks.isCustomLeafBlock(block)))) {
if (Config.getInstance().getWoodcuttingRequiresTool() && ItemChecks.isAxe(inhand)) {
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
event.setInstaBreak(true);

View File

@ -16,12 +16,14 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.mods.CustomBlock;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.util.BlockChecks;
import com.gmail.nossr50.util.Combat;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ModChecks;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users;
@ -89,7 +91,33 @@ public class WoodCutting {
for (Block x : toBeFelled) {
if (Misc.blockBreakSimulate(x, player, true)) {
if (x.getType() == Material.LOG) {
if (Config.getInstance().getBlockModsEnabled()) {
CustomBlock block = ModChecks.getCustomBlock(x);
item = block.getItemDrop();
if (ModChecks.isCustomLogBlock(x)) {
if (!mcMMO.placeStore.isTrue(x)) {
WoodCutting.woodCuttingProcCheck(player, x);
xp = block.getXpGain();
}
/* Remove the block */
x.setData((byte) 0x0);
x.setType(Material.AIR);
Misc.mcDropItem(x.getLocation(), item);
}
else if (ModChecks.isCustomLeafBlock(x)) {
final int SAPLING_DROP_CHANCE = 10;
/* Remove the block */
x.setData((byte) 0x0);
x.setType(Material.AIR);
Misc.mcRandomDropItem(x.getLocation(), item, SAPLING_DROP_CHANCE);
}
}
else if (x.getType() == Material.LOG) {
Tree tree = (Tree) x.getState().getData();
TreeSpecies species = tree.getSpecies();
@ -174,13 +202,16 @@ public class WoodCutting {
private static void processTreeFelling(Block currentBlock, ArrayList<Block> toBeFelled) {
Material type = currentBlock.getType();
if(toBeFelled.size() >= Config.getInstance().getTreeFellerThreshold()) {
if (toBeFelled.size() >= Config.getInstance().getTreeFellerThreshold()) {
return;
}
if (type.equals(Material.LOG) || type.equals(Material.LEAVES)) {
toBeFelled.add(currentBlock);
}
else if (Config.getInstance().getBlockModsEnabled() && (ModChecks.isCustomLogBlock(currentBlock) || ModChecks.isCustomLeafBlock(currentBlock))) {
toBeFelled.add(currentBlock);
}
Block xPositive = currentBlock.getRelative(1, 0, 0);
Block xNegative = currentBlock.getRelative(-1, 0, 0);
@ -222,9 +253,9 @@ public class WoodCutting {
*/
private static boolean isTooAggressive(Block currentBlock, Block newBlock) {
Material currentType = currentBlock.getType();
Material newType = currentBlock.getType();
Material newType = newBlock.getType();
if ((currentType.equals(Material.LEAVES) || currentType.equals(Material.AIR)) && (newType.equals(Material.LEAVES) || newType.equals(Material.AIR))) {
if ((currentType.equals(Material.LEAVES) || currentType.equals(Material.AIR) || (Config.getInstance().getBlockModsEnabled() && ModChecks.isCustomLeafBlock(currentBlock))) && (newType.equals(Material.LEAVES) || newType.equals(Material.AIR) || (Config.getInstance().getBlockModsEnabled() && ModChecks.isCustomLeafBlock(currentBlock)))) {
return true;
}
else {
@ -250,8 +281,19 @@ public class WoodCutting {
if ((skillLevel > MAX_SKILL_LEVEL || random.nextInt(1000) <= skillLevel) && Permissions.getInstance().woodcuttingDoubleDrops(player)) {
Config configInstance = Config.getInstance();
ItemStack item = new ItemStack(mat, 1, (short) 0, type);
Location location = block.getLocation();
ItemStack item;
Location location;
if (configInstance.getBlockModsEnabled() && ModChecks.isCustomLogBlock(block)) {
item = ModChecks.getCustomBlock(block).getItemDrop();
location = block.getLocation();
Misc.mcDropItem(location, item);
return;
}
else {
item = new ItemStack(mat, 1, (short) 0, type);
location = block.getLocation();
}
/* Drop the block */
switch (species) {
@ -300,25 +342,30 @@ public class WoodCutting {
return;
}
switch (species) {
case GENERIC:
xp += Config.getInstance().getWoodcuttingXPOak();
break;
if (Config.getInstance().getBlockModsEnabled() && ModChecks.isCustomLogBlock(block)) {
xp = ModChecks.getCustomBlock(block).getXpGain();
}
else {
switch (species) {
case GENERIC:
xp += Config.getInstance().getWoodcuttingXPOak();
break;
case REDWOOD:
xp += Config.getInstance().getWoodcuttingXPSpruce();
break;
case REDWOOD:
xp += Config.getInstance().getWoodcuttingXPSpruce();
break;
case BIRCH:
xp += Config.getInstance().getWoodcuttingXPBirch();
break;
case BIRCH:
xp += Config.getInstance().getWoodcuttingXPBirch();
break;
case JUNGLE:
xp += Config.getInstance().getWoodcuttingXPJungle();
break;
case JUNGLE:
xp += Config.getInstance().getWoodcuttingXPJungle();
break;
default:
break;
default:
break;
}
}
WoodCutting.woodCuttingProcCheck(player, block);
@ -348,7 +395,7 @@ public class WoodCutting {
private static int durabilityLossCalulate(ArrayList<Block> toBeFelled) {
int durabilityLoss = 0;
for (Block x : toBeFelled) {
if (x.getType().equals(Material.LOG)) {
if (x.getType().equals(Material.LOG) || (Config.getInstance().getBlockModsEnabled() && ModChecks.isCustomLogBlock(x))) {
durabilityLoss++;
durabilityLoss = durabilityLoss + Config.getInstance().getAbilityToolDamage();
}

View File

@ -118,7 +118,12 @@ public class BlockChecks {
return true;
default:
return false;
if (customBlocksEnabled && ModChecks.isCustomOreBlock(block)) {
return true;
}
else {
return false;
}
}
}

View File

@ -78,4 +78,49 @@ public class ModChecks {
return null;
}
/**
* Check if a custom block is a leaf block.
*
* @param block The block to check
* @return true if the block represents leaves, false otherwise
*/
public static boolean isCustomLeafBlock(Block block) {
if (blocksInstance.customLeaves.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
return true;
}
else {
return false;
}
}
/**
* Check if a custom block is a log block.
*
* @param block The block to check
* @return true if the block represents a log, false otherwise
*/
public static boolean isCustomLogBlock(Block block) {
if (blocksInstance.customLogs.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
return true;
}
else {
return false;
}
}
/**
* Check if a custom block is an ore block.
*
* @param block The block to check
* @return true if the block represents an ore, false otherwise
*/
public static boolean isCustomOreBlock(Block block) {
if (blocksInstance.customOres.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
return true;
}
else {
return false;
}
}
}

View File

@ -44,6 +44,7 @@ Mining:
ID: 999
Data_Value: 0
XP_Gain: 99
Is_Ore: true
Drop_Item: false
Drop_Item_ID: 999
Drop_Item_Data_Value: 0
@ -51,6 +52,7 @@ Mining:
ID: 999
Data_Value: 0
XP_Gain: 99
Is_Ore: true
Drop_Item: false
Drop_Item_ID: 999
Drop_Item_Data_Value: 0
@ -63,6 +65,7 @@ Woodcutting:
ID: 999
Data_Value: 0
XP_Gain: 99
Is_Log: true
Drop_Item: false
Drop_Item_ID: 999
Drop_Item_Data_Value: 0
@ -70,6 +73,7 @@ Woodcutting:
ID: 999
Data_Value: 0
XP_Gain: 99
Is_Log: true
Drop_Item: false
Drop_Item_ID: 999
Drop_Item_Data_Value: 0