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 config options for enabling/disabling specific double drops
+ Added automatic zip backup of flatfile database & config files + Added automatic zip backup of flatfile database & config files
+ Added config options to enable/disable specific skills for PVP & PVE + 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 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 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 = 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 some bypass nodes defaulting true for Ops
= Fixed bug with trying to use Chimera Wing while standing on a half-block = 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 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 the mcMMO motd to link to the new website rather than the wiki
! Changed bleeding ticks damage to 1 from 2 ! Changed bleeding ticks damage to 1 from 2
! Changed Mining to ignore blocks when the pick is enchanted with Silk Touch ! 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 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 skill commands to only display what you have permissions for
! Changed mcMMO to use a new storage system for player placed blocks ! 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 some unused permission nodes
- Removed a few config options in favor of permissions nodes (Hunger Bonus, Armor/Tool Repair, Instant Wheat Regrowth) - 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 - 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> customMiningBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customWoodcuttingBlocks = 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<ItemStack> customItems = new ArrayList<ItemStack>();
public List<CustomBlock> customBlocks = new ArrayList<CustomBlock>(); public List<CustomBlock> customBlocks = new ArrayList<CustomBlock>();
@ -95,6 +99,19 @@ public class CustomBlocksConfig extends ModConfigLoader{
block = new CustomBlock(itemDrop, xp, data, id); block = new CustomBlock(itemDrop, xp, data, id);
blockItem = new ItemStack(id, 1, (short) 0, data); 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); blockList.add(blockItem);
customItems.add(blockItem); customItems.add(blockItem);
customBlocks.add(block); 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 (Config.getInstance().getWoodcuttingRequiresTool() && ItemChecks.isAxe(inhand)) {
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) { if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
event.setInstaBreak(true); event.setInstaBreak(true);

View File

@ -16,12 +16,14 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.mods.CustomBlock;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent; import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.spout.SpoutSounds; import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.util.BlockChecks; import com.gmail.nossr50.util.BlockChecks;
import com.gmail.nossr50.util.Combat; import com.gmail.nossr50.util.Combat;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ModChecks;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Skills; import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users; import com.gmail.nossr50.util.Users;
@ -89,7 +91,33 @@ public class WoodCutting {
for (Block x : toBeFelled) { for (Block x : toBeFelled) {
if (Misc.blockBreakSimulate(x, player, true)) { 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(); Tree tree = (Tree) x.getState().getData();
TreeSpecies species = tree.getSpecies(); TreeSpecies species = tree.getSpecies();
@ -181,6 +209,9 @@ public class WoodCutting {
if (type.equals(Material.LOG) || type.equals(Material.LEAVES)) { if (type.equals(Material.LOG) || type.equals(Material.LEAVES)) {
toBeFelled.add(currentBlock); 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 xPositive = currentBlock.getRelative(1, 0, 0);
Block xNegative = 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) { private static boolean isTooAggressive(Block currentBlock, Block newBlock) {
Material currentType = currentBlock.getType(); 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; return true;
} }
else { else {
@ -250,8 +281,19 @@ public class WoodCutting {
if ((skillLevel > MAX_SKILL_LEVEL || random.nextInt(1000) <= skillLevel) && Permissions.getInstance().woodcuttingDoubleDrops(player)) { if ((skillLevel > MAX_SKILL_LEVEL || random.nextInt(1000) <= skillLevel) && Permissions.getInstance().woodcuttingDoubleDrops(player)) {
Config configInstance = Config.getInstance(); Config configInstance = Config.getInstance();
ItemStack item = new ItemStack(mat, 1, (short) 0, type); ItemStack item;
Location location = block.getLocation(); 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 */ /* Drop the block */
switch (species) { switch (species) {
@ -300,6 +342,10 @@ public class WoodCutting {
return; return;
} }
if (Config.getInstance().getBlockModsEnabled() && ModChecks.isCustomLogBlock(block)) {
xp = ModChecks.getCustomBlock(block).getXpGain();
}
else {
switch (species) { switch (species) {
case GENERIC: case GENERIC:
xp += Config.getInstance().getWoodcuttingXPOak(); xp += Config.getInstance().getWoodcuttingXPOak();
@ -320,6 +366,7 @@ public class WoodCutting {
default: default:
break; break;
} }
}
WoodCutting.woodCuttingProcCheck(player, block); WoodCutting.woodCuttingProcCheck(player, block);
PP.addXP(player, SkillType.WOODCUTTING, xp); PP.addXP(player, SkillType.WOODCUTTING, xp);
@ -348,7 +395,7 @@ public class WoodCutting {
private static int durabilityLossCalulate(ArrayList<Block> toBeFelled) { private static int durabilityLossCalulate(ArrayList<Block> toBeFelled) {
int durabilityLoss = 0; int durabilityLoss = 0;
for (Block x : toBeFelled) { 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 = durabilityLoss + Config.getInstance().getAbilityToolDamage(); durabilityLoss = durabilityLoss + Config.getInstance().getAbilityToolDamage();
} }

View File

@ -118,9 +118,14 @@ public class BlockChecks {
return true; return true;
default: default:
if (customBlocksEnabled && ModChecks.isCustomOreBlock(block)) {
return true;
}
else {
return false; return false;
} }
} }
}
/** /**
* Check if a block can be made mossy. * Check if a block can be made mossy.

View File

@ -78,4 +78,49 @@ public class ModChecks {
return null; 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 ID: 999
Data_Value: 0 Data_Value: 0
XP_Gain: 99 XP_Gain: 99
Is_Ore: true
Drop_Item: false Drop_Item: false
Drop_Item_ID: 999 Drop_Item_ID: 999
Drop_Item_Data_Value: 0 Drop_Item_Data_Value: 0
@ -51,6 +52,7 @@ Mining:
ID: 999 ID: 999
Data_Value: 0 Data_Value: 0
XP_Gain: 99 XP_Gain: 99
Is_Ore: true
Drop_Item: false Drop_Item: false
Drop_Item_ID: 999 Drop_Item_ID: 999
Drop_Item_Data_Value: 0 Drop_Item_Data_Value: 0
@ -63,6 +65,7 @@ Woodcutting:
ID: 999 ID: 999
Data_Value: 0 Data_Value: 0
XP_Gain: 99 XP_Gain: 99
Is_Log: true
Drop_Item: false Drop_Item: false
Drop_Item_ID: 999 Drop_Item_ID: 999
Drop_Item_Data_Value: 0 Drop_Item_Data_Value: 0
@ -70,6 +73,7 @@ Woodcutting:
ID: 999 ID: 999
Data_Value: 0 Data_Value: 0
XP_Gain: 99 XP_Gain: 99
Is_Log: true
Drop_Item: false Drop_Item: false
Drop_Item_ID: 999 Drop_Item_ID: 999
Drop_Item_Data_Value: 0 Drop_Item_Data_Value: 0