mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-25 02:04:44 +02:00
Added ability for custom blocks to drop a range of items. MOD BLOCK
FILES WILL NEED TO BE REDONE.
This commit is contained in:
@ -63,7 +63,8 @@ public class CustomBlocksConfig extends ModConfigLoader{
|
||||
boolean dropItem = config.getBoolean(skillType + "." + blockName + ".Drop_Item", false);
|
||||
int dropID = config.getInt(skillType + "." + blockName + ".Drop_Item_ID", 0);
|
||||
byte dropData = (byte) config.getInt(skillType + "." + blockName + ".Drop_Item_Data_Value", 0);
|
||||
int dropAmount = config.getInt(skillType + "." + blockName + ".Drop_Item_Amount", 1);
|
||||
int minimumDropAmount = config.getInt(skillType + "." + blockName + ".Min_Drop_Item_Amount", 1);
|
||||
int maxiumDropAmount = config.getInt(skillType + "." + blockName + ".Max_Drop_Item_Amount", 1);
|
||||
|
||||
if (id == 0) {
|
||||
plugin.getLogger().warning("Missing ID. This block will be skipped.");
|
||||
@ -80,13 +81,13 @@ public class CustomBlocksConfig extends ModConfigLoader{
|
||||
ItemStack blockItem;
|
||||
|
||||
if (dropItem) {
|
||||
itemDrop = new ItemStack(dropID, dropAmount, (short) 0, dropData);
|
||||
itemDrop = new ItemStack(dropID, 1, (short) 0, dropData);
|
||||
}
|
||||
else {
|
||||
itemDrop = new ItemStack(id, dropAmount, (short) 0, data);
|
||||
itemDrop = new ItemStack(id, 1, (short) 0, data);
|
||||
}
|
||||
|
||||
block = new CustomBlock(itemDrop, tier, xp, data, id);
|
||||
block = new CustomBlock(minimumDropAmount, maxiumDropAmount, itemDrop, tier, xp, data, id);
|
||||
blockItem = new ItemStack(id, 1, (short) 0, data);
|
||||
|
||||
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
|
||||
|
@ -8,13 +8,17 @@ public class CustomBlock {
|
||||
private int xpGain;
|
||||
private int tier;
|
||||
private ItemStack itemDrop;
|
||||
private int minimumDropAmount;
|
||||
private int maximumDropAmount;
|
||||
|
||||
public CustomBlock(ItemStack itemDrop, int tier, int xpGain, byte dataValue, int itemID) {
|
||||
public CustomBlock(int minimumDropAmount, int maximumDropAmount, ItemStack itemDrop, int tier, int xpGain, byte dataValue, int itemID) {
|
||||
this.itemID = itemID;
|
||||
this.dataValue = dataValue;
|
||||
this.xpGain = xpGain;
|
||||
this.tier = tier;
|
||||
this.itemDrop = itemDrop;
|
||||
this.minimumDropAmount = minimumDropAmount;
|
||||
this.maximumDropAmount = maximumDropAmount;
|
||||
}
|
||||
|
||||
public int getItemID() {
|
||||
@ -56,4 +60,20 @@ public class CustomBlock {
|
||||
public void setItemDrop(ItemStack itemDrop) {
|
||||
this.itemDrop = itemDrop;
|
||||
}
|
||||
|
||||
public int getMinimumDropAmount() {
|
||||
return minimumDropAmount;
|
||||
}
|
||||
|
||||
public void setMinimumDropAmount(int minimumDropAmount) {
|
||||
this.minimumDropAmount = minimumDropAmount;
|
||||
}
|
||||
|
||||
public int getMaximumDropAmount() {
|
||||
return maximumDropAmount;
|
||||
}
|
||||
|
||||
public void setMaximumDropAmount(int maximumDropAmount) {
|
||||
this.maximumDropAmount = maximumDropAmount;
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import com.gmail.nossr50.config.mods.CustomBlocksConfig;
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.GreenThumbTimer;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
@ -281,7 +282,19 @@ public class Herbalism {
|
||||
|
||||
default:
|
||||
if (customPlant) {
|
||||
Misc.dropItem(loc, is);
|
||||
CustomBlock customBlock = ModChecks.getCustomBlock(block);
|
||||
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
||||
int maximumDropAmount = customBlock.getMaximumDropAmount();
|
||||
|
||||
is = customBlock.getItemDrop();
|
||||
|
||||
if (minimumDropAmount != maximumDropAmount) {
|
||||
Misc.dropItems(loc, is, minimumDropAmount);
|
||||
Misc.randomDropItems(loc, is, 50, maximumDropAmount - minimumDropAmount);
|
||||
}
|
||||
else {
|
||||
Misc.dropItems(loc, is, minimumDropAmount);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ 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.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
@ -196,8 +197,19 @@ public class Mining {
|
||||
|
||||
default:
|
||||
if (ModChecks.isCustomMiningBlock(block)) {
|
||||
CustomBlock customBlock = ModChecks.getCustomBlock(block);
|
||||
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
||||
int maximumDropAmount = customBlock.getMaximumDropAmount();
|
||||
|
||||
item = ModChecks.getCustomBlock(block).getItemDrop();
|
||||
Misc.dropItem(loc, item);
|
||||
|
||||
if (minimumDropAmount != maximumDropAmount) {
|
||||
Misc.dropItems(loc, item, minimumDropAmount);
|
||||
Misc.randomDropItems(loc, item, 50, maximumDropAmount - minimumDropAmount);
|
||||
}
|
||||
else {
|
||||
Misc.dropItems(loc, item, minimumDropAmount);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -116,7 +116,18 @@ public class WoodCutting {
|
||||
x.setData((byte) 0x0);
|
||||
x.setType(Material.AIR);
|
||||
|
||||
Misc.dropItem(x.getLocation(), item);
|
||||
int minimumDropAmount = block.getMinimumDropAmount();
|
||||
int maximumDropAmount = block.getMaximumDropAmount();
|
||||
|
||||
item = block.getItemDrop();
|
||||
|
||||
if (minimumDropAmount != maximumDropAmount) {
|
||||
Misc.dropItems(x.getLocation(), item, minimumDropAmount);
|
||||
Misc.randomDropItems(x.getLocation(), item, 50, maximumDropAmount - minimumDropAmount);
|
||||
}
|
||||
else {
|
||||
Misc.dropItems(x.getLocation(), item, minimumDropAmount);
|
||||
}
|
||||
}
|
||||
else if (ModChecks.isCustomLeafBlock(x)) {
|
||||
CustomBlock block = ModChecks.getCustomBlock(x);
|
||||
@ -298,9 +309,20 @@ public class WoodCutting {
|
||||
Location location;
|
||||
|
||||
if (configInstance.getBlockModsEnabled() && ModChecks.isCustomLogBlock(block)) {
|
||||
item = ModChecks.getCustomBlock(block).getItemDrop();
|
||||
CustomBlock customBlock = ModChecks.getCustomBlock(block);
|
||||
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
||||
int maximumDropAmount = customBlock.getMaximumDropAmount();
|
||||
|
||||
item = customBlock.getItemDrop();
|
||||
location = block.getLocation();
|
||||
Misc.dropItem(location, item);
|
||||
|
||||
if (minimumDropAmount != maximumDropAmount) {
|
||||
Misc.dropItems(location, item, minimumDropAmount);
|
||||
Misc.randomDropItems(location, item, 50, maximumDropAmount - minimumDropAmount);
|
||||
}
|
||||
else {
|
||||
Misc.dropItems(location, item, minimumDropAmount);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
Reference in New Issue
Block a user