Skip to content

Commit

Permalink
moves drops into ores view
Browse files Browse the repository at this point in the history
  • Loading branch information
way2muchnoise committed Jan 21, 2016
1 parent cfc299a commit d37b055
Show file tree
Hide file tree
Showing 27 changed files with 170 additions and 357 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version_forge=11.15.0.1707
version_minecraft=1.8.9
version_major=0
version_minor=2
version_revis=0
version_revis=1
version_mappings=snapshot_20160101
version_jei=2.21+
version_thaumcraft=5.1.0
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@API(owner = "jeresources", apiVersion = "1.0", provides = "jeresources|API")
@API(owner = "jeresources", apiVersion = "@MAJOR@.@MINOR@.@REVIS@", provides = "jeresources|API")
package jeresources.api.distributions;

import net.minecraftforge.fml.common.API;
29 changes: 15 additions & 14 deletions src/main/java/jeresources/api/messages/ModifyOreMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,33 @@

import jeresources.api.messages.utils.MessageHelper;
import jeresources.api.messages.utils.MessageKeys;
import jeresources.api.utils.DropItem;
import jeresources.api.utils.Priority;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;

public class ModifyOreMessage extends ModifyMessage
{
private ItemStack ore;
private ItemStack[] addDrops = new ItemStack[0];
private ItemStack[] removeDrops = new ItemStack[0];
private DropItem[] addDrops = new DropItem[0];
private DropItem[] removeDrops = new DropItem[0];

public ModifyOreMessage(ItemStack ore, ItemStack... drops)
public ModifyOreMessage(ItemStack ore, DropItem... drops)
{
this(ore, true, drops);
}

public ModifyOreMessage(ItemStack ore, Priority priority, ItemStack... drops)
public ModifyOreMessage(ItemStack ore, Priority priority, DropItem... drops)
{
this(ore, true, priority, drops);
}

public ModifyOreMessage(ItemStack ore, boolean add, ItemStack... drops)
public ModifyOreMessage(ItemStack ore, boolean add, DropItem... drops)
{
this(ore, add, Priority.SECOND, drops);
}

public ModifyOreMessage(ItemStack ore, boolean add, Priority priority, ItemStack... drops)
public ModifyOreMessage(ItemStack ore, boolean add, Priority priority, DropItem... drops)
{
super(priority, add);
this.ore = ore;
Expand All @@ -37,12 +38,12 @@ public ModifyOreMessage(ItemStack ore, boolean add, Priority priority, ItemStack
this.removeDrops = drops;
}

public ModifyOreMessage(ItemStack ore, ItemStack[] removeDrops, ItemStack[] addDrops)
public ModifyOreMessage(ItemStack ore, DropItem[] removeDrops, DropItem[] addDrops)
{
this(ore, removeDrops, addDrops, Priority.SECOND, Priority.FIRST);
}

public ModifyOreMessage(ItemStack ore, ItemStack[] removeDrops, ItemStack[] addDrops, Priority removePriority, Priority addPriority)
public ModifyOreMessage(ItemStack ore, DropItem[] removeDrops, DropItem[] addDrops, Priority removePriority, Priority addPriority)
{
super(addPriority, removePriority);
this.ore = ore;
Expand All @@ -54,21 +55,21 @@ public ModifyOreMessage(NBTTagCompound tagCompound)
{
super(tagCompound);
this.ore = ItemStack.loadItemStackFromNBT(tagCompound.getCompoundTag(MessageKeys.stack));
this.addDrops = MessageHelper.getItemStacks(tagCompound, MessageKeys.addDrops);
this.removeDrops = MessageHelper.getItemStacks(tagCompound, MessageKeys.removeDrops);
this.addDrops = MessageHelper.getDropItems(tagCompound, MessageKeys.addDrops);
this.removeDrops = MessageHelper.getDropItems(tagCompound, MessageKeys.removeDrops);
}

public ItemStack getOre()
{
return ore;
}

public ItemStack[] getRemoveDrops()
public DropItem[] getRemoveDrops()
{
return removeDrops;
}

public ItemStack[] getAddDrops()
public DropItem[] getAddDrops()
{
return addDrops;
}
Expand All @@ -78,8 +79,8 @@ public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound);
tagCompound.setTag(MessageKeys.stack, ore.writeToNBT(new NBTTagCompound()));
tagCompound.setTag(MessageKeys.addDrops, MessageHelper.getItemStackList(addDrops));
tagCompound.setTag(MessageKeys.removeDrops, MessageHelper.getItemStackList(removeDrops));
tagCompound.setTag(MessageKeys.addDrops, MessageHelper.getDropItemList(addDrops));
tagCompound.setTag(MessageKeys.removeDrops, MessageHelper.getDropItemList(removeDrops));
return tagCompound;
}

Expand Down
29 changes: 15 additions & 14 deletions src/main/java/jeresources/api/messages/RegisterOreMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import jeresources.api.messages.utils.MessageHelper;
import jeresources.api.messages.utils.MessageKeys;
import jeresources.api.utils.ColorHelper;
import jeresources.api.utils.DropItem;
import jeresources.api.utils.Priority;
import jeresources.api.utils.restrictions.Restriction;
import net.minecraft.item.ItemStack;
Expand All @@ -12,58 +13,58 @@
public class RegisterOreMessage extends RegistryMessage
{
private ItemStack ore;
private ItemStack[] drops;
private DropItem[] drops;
private boolean needSilkTouch;
private DistributionBase distribution;
private int colour;
private Restriction restriction;

public RegisterOreMessage(ItemStack ore, DistributionBase distribution, ItemStack... drops)
public RegisterOreMessage(ItemStack ore, DistributionBase distribution, DropItem... drops)
{
this(ore, distribution, ColorHelper.BLACK, Restriction.OVERWORLD_LIKE, false, drops);
}

public RegisterOreMessage(ItemStack ore, DistributionBase distribution, boolean needSilkTouch, ItemStack... drops)
public RegisterOreMessage(ItemStack ore, DistributionBase distribution, boolean needSilkTouch, DropItem... drops)
{
this(ore, distribution, ColorHelper.BLACK, Restriction.OVERWORLD_LIKE, needSilkTouch, drops);
}

public RegisterOreMessage(ItemStack ore, DistributionBase distribution, int colour, ItemStack... drops)
public RegisterOreMessage(ItemStack ore, DistributionBase distribution, int colour, DropItem... drops)
{
this(ore, distribution, colour, Restriction.OVERWORLD_LIKE, false, drops);
}

public RegisterOreMessage(ItemStack ore, DistributionBase distribution, int colour, Restriction restriction, boolean needSilkTouch, ItemStack... drops)
public RegisterOreMessage(ItemStack ore, DistributionBase distribution, int colour, Restriction restriction, boolean needSilkTouch, DropItem... drops)
{
this(ore, distribution, colour, restriction, needSilkTouch, Priority.FIRST, drops);
}

public RegisterOreMessage(ItemStack ore, DistributionBase distribution, int colour, boolean needSilkTouch, Priority priority, ItemStack... drops)
public RegisterOreMessage(ItemStack ore, DistributionBase distribution, int colour, boolean needSilkTouch, Priority priority, DropItem... drops)
{
this(ore, distribution, colour, Restriction.OVERWORLD_LIKE, needSilkTouch, priority, drops);
}

public RegisterOreMessage(ItemStack ore, DistributionBase distribution, Restriction restriction, ItemStack... drops)
public RegisterOreMessage(ItemStack ore, DistributionBase distribution, Restriction restriction, DropItem... drops)
{
this(ore, distribution, ColorHelper.BLACK, restriction, false, drops);
}

public RegisterOreMessage(ItemStack ore, DistributionBase distribution, Restriction restriction, boolean needSilkTouch, ItemStack... drops)
public RegisterOreMessage(ItemStack ore, DistributionBase distribution, Restriction restriction, boolean needSilkTouch, DropItem... drops)
{
this(ore, distribution, ColorHelper.BLACK, restriction, needSilkTouch, drops);
}

public RegisterOreMessage(ItemStack ore, DistributionBase distribution, Restriction restriction, int colour, ItemStack... drops)
public RegisterOreMessage(ItemStack ore, DistributionBase distribution, Restriction restriction, int colour, DropItem... drops)
{
this(ore, distribution, colour, restriction, false, drops);
}

public RegisterOreMessage(ItemStack ore, DistributionBase distribution, Restriction restriction, int colour, boolean needSilkTouch, Priority priority, ItemStack... drops)
public RegisterOreMessage(ItemStack ore, DistributionBase distribution, Restriction restriction, int colour, boolean needSilkTouch, Priority priority, DropItem... drops)
{
this(ore, distribution, colour, restriction, needSilkTouch, priority, drops);
}

public RegisterOreMessage(ItemStack ore, DistributionBase distribution, int colour, Restriction restriction, boolean needSilkTouch, Priority priority, ItemStack... drops)
public RegisterOreMessage(ItemStack ore, DistributionBase distribution, int colour, Restriction restriction, boolean needSilkTouch, Priority priority, DropItem... drops)
{
super(priority, true);
this.ore = ore;
Expand All @@ -79,7 +80,7 @@ public RegisterOreMessage(NBTTagCompound tagCompound)
{
super(tagCompound);
this.ore = ItemStack.loadItemStackFromNBT(tagCompound.getCompoundTag(MessageKeys.stack));
this.drops = MessageHelper.getItemStacks(tagCompound, MessageKeys.addDrops);
this.drops = MessageHelper.getDropItems(tagCompound, MessageKeys.addDrops);
this.needSilkTouch = tagCompound.getBoolean(MessageKeys.silkTouch);
this.distribution = MessageHelper.getDistribution(tagCompound);
this.colour = tagCompound.hasKey(MessageKeys.colour) ? tagCompound.getInteger(MessageKeys.colour) : ColorHelper.BLACK;
Expand All @@ -106,7 +107,7 @@ public int getColour()
return colour;
}

public ItemStack[] getDrops()
public DropItem[] getDrops()
{
return drops;
}
Expand All @@ -121,7 +122,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound);
tagCompound.setTag(MessageKeys.stack, ore.writeToNBT(new NBTTagCompound()));
tagCompound.setTag(MessageKeys.addDrops, MessageHelper.getItemStackList(drops));
tagCompound.setTag(MessageKeys.addDrops, MessageHelper.getDropItemList(drops));
distribution.writeToNBT(tagCompound);
tagCompound.setBoolean(MessageKeys.silkTouch, needSilkTouch);
tagCompound.setInteger(MessageKeys.colour, colour);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/jeresources/api/messages/package-info.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@API(owner = "jeresources", apiVersion = "1.0", provides = "jeresources|API")
@API(owner = "jeresources", apiVersion = "@MAJOR@.@MINOR@.@REVIS@", provides = "jeresources|API")
package jeresources.api.messages;

import net.minecraftforge.fml.common.API;
2 changes: 1 addition & 1 deletion src/main/java/jeresources/api/package-info.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@API(owner = "jeresources", apiVersion = "1.0", provides = "jeresources|API")
@API(owner = "jeresources", apiVersion = "@MAJOR@.@MINOR@.@REVIS@", provides = "jeresources|API")
package jeresources.api;

import net.minecraftforge.fml.common.API;
10 changes: 10 additions & 0 deletions src/main/java/jeresources/api/utils/DropItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public class DropItem implements Comparable<DropItem>
public List<String> conditionals = new ArrayList<String>();
private float sortIndex;

public DropItem(ItemStack item)
{
this(item, item.stackSize);
}

public DropItem(ItemStack item, float chance)
{
this(item, 0, 1, chance);
Expand Down Expand Up @@ -112,6 +117,11 @@ private String formatChance()
return String.format("%2d", (int) chance);
}

public String chanceString()
{
return String.format("%.2G", chance);
}

public List<String> getTooltipText()
{
return conditionals;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/jeresources/api/utils/package-info.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@API(owner = "jeresources", apiVersion = "1.0", provides = "jeresources|API")
@API(owner = "jeresources", apiVersion = "@MAJOR@.@MINOR@.@REVIS@", provides = "jeresources|API")
package jeresources.api.utils;

import net.minecraftforge.fml.common.API;
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ protected void init(boolean initOres)

private void registerVanillaOreDrops()
{
registerOre(new RegisterOreMessage(new ItemStack(Blocks.clay), new DistributionUnderWater(0.0035F), new ItemStack(Items.clay_ball, 4)));
MessageRegistry.addMessage(new ModifyOreMessage(new ItemStack(Blocks.clay), Priority.FIRST, new ItemStack(Items.clay_ball, 4)));
MessageRegistry.addMessage(new ModifyOreMessage(new ItemStack(Blocks.coal_ore), Priority.FIRST, new ItemStack(Items.coal)));
MessageRegistry.addMessage(new ModifyOreMessage(new ItemStack(Blocks.diamond_ore), Priority.FIRST, new ItemStack(Items.diamond)));
MessageRegistry.addMessage(new ModifyOreMessage(new ItemStack(Blocks.lapis_ore), Priority.FIRST, new ItemStack(Items.dye, 4, 4)));
MessageRegistry.addMessage(new ModifyOreMessage(new ItemStack(Blocks.emerald_ore), Priority.FIRST, new ItemStack(Items.emerald)));
MessageRegistry.addMessage(new ModifyOreMessage(new ItemStack(Blocks.redstone_ore), Priority.FIRST, new ItemStack(Items.redstone, 4)));
MessageRegistry.addMessage(new ModifyOreMessage(new ItemStack(Blocks.quartz_ore), Priority.FIRST, new ItemStack(Items.quartz, 4)));
registerOre(new RegisterOreMessage(new ItemStack(Blocks.clay), new DistributionUnderWater(0.0035F), new DropItem(new ItemStack(Items.clay_ball, 4))));
MessageRegistry.addMessage(new ModifyOreMessage(new ItemStack(Blocks.clay), Priority.FIRST, new DropItem(new ItemStack(Items.clay_ball, 4))));
MessageRegistry.addMessage(new ModifyOreMessage(new ItemStack(Blocks.coal_ore), Priority.FIRST, new DropItem(new ItemStack(Items.coal))));
MessageRegistry.addMessage(new ModifyOreMessage(new ItemStack(Blocks.diamond_ore), Priority.FIRST, new DropItem(new ItemStack(Items.diamond))));
MessageRegistry.addMessage(new ModifyOreMessage(new ItemStack(Blocks.lapis_ore), Priority.FIRST, new DropItem(new ItemStack(Items.dye, 4, 4))));
MessageRegistry.addMessage(new ModifyOreMessage(new ItemStack(Blocks.emerald_ore), Priority.FIRST, new DropItem(new ItemStack(Items.emerald))));
MessageRegistry.addMessage(new ModifyOreMessage(new ItemStack(Blocks.redstone_ore), Priority.FIRST, new DropItem(new ItemStack(Items.redstone, 4))));
MessageRegistry.addMessage(new ModifyOreMessage(new ItemStack(Blocks.quartz_ore), Priority.FIRST, new DropItem(new ItemStack(Items.quartz, 4))));
}

private void registerVanillaMobs()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected void init(boolean initOres)
private void registerThaumcraftOres()
{
ItemStack amber = new ItemStack(GameRegistry.findBlock(ModList.Names.THAUMCRAFT, "ore_amber"));
ItemStack amberDrop = new ItemStack(GameRegistry.findItem(ModList.Names.THAUMCRAFT, "amber"));
DropItem amberDrop = new DropItem(new ItemStack(GameRegistry.findItem(ModList.Names.THAUMCRAFT, "amber")));
MessageRegistry.addMessage(new ModifyOreMessage(amber, Priority.FIRST, amberDrop));
if (Config.genCinnibar) genCinnabar();
if (Config.genAmber) genAmber();
Expand Down
Loading

0 comments on commit d37b055

Please sign in to comment.