Added Treasure Chests

This commit is contained in:
Ellpeck 2015-07-10 13:08:20 +02:00
parent 5d963805d8
commit 551ecf0501
14 changed files with 426 additions and 26 deletions

View file

@ -26,6 +26,7 @@ import ellpeck.actuallyadditions.ore.InitOreDict;
import ellpeck.actuallyadditions.proxy.IProxy;
import ellpeck.actuallyadditions.recipe.FuelHandler;
import ellpeck.actuallyadditions.recipe.HairyBallHandler;
import ellpeck.actuallyadditions.recipe.TreasureChestHandler;
import ellpeck.actuallyadditions.tile.TileEntityBase;
import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.Util;
@ -80,6 +81,7 @@ public class ActuallyAdditions{
CrusherCrafting.init();
ItemCrafting.initMashedFoodRecipes();
HairyBallHandler.init();
TreasureChestHandler.init();
proxy.postInit();
ModUtil.LOGGER.info("PostInitialization Finished.");

View file

@ -25,10 +25,10 @@ public abstract class BlockContainerBase extends BlockContainer{
if(tile instanceof TileEntityInventoryBase){
TileEntityInventoryBase tileEntity = (TileEntityInventoryBase)tile;
if(tileEntity.getSizeInventory() > 0){
Random rand = new Random();
for(int i = 0; i < tileEntity.getSizeInventory(); i++){
ItemStack itemStack = tileEntity.getStackInSlot(i);
if(itemStack != null && itemStack.stackSize > 0){
Random rand = new Random();
float dX = rand.nextFloat()*0.8F+0.1F;
float dY = rand.nextFloat()*0.8F+0.1F;
float dZ = rand.nextFloat()*0.8F+0.1F;

View file

@ -0,0 +1,165 @@
package ellpeck.actuallyadditions.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.recipe.TreasureChestHandler;
import ellpeck.actuallyadditions.util.BlockUtil;
import ellpeck.actuallyadditions.util.INameableItem;
import ellpeck.actuallyadditions.util.ModUtil;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.WeightedRandom;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import java.util.List;
import java.util.Random;
public class BlockTreasureChest extends Block implements INameableItem{
private IIcon topIcon;
private IIcon onIcon;
private IIcon frontIcon;
public BlockTreasureChest(){
super(Material.wood);
this.setHarvestLevel("axe", 0);
this.setHardness(2.0F);
this.setResistance(10.0F);
this.setStepSound(soundTypeWood);
this.setTickRandomly(true);
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){
int rotation = MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
if (rotation == 0) world.setBlockMetadataWithNotify(x, y, z, 0, 2);
if (rotation == 1) world.setBlockMetadataWithNotify(x, y, z, 3, 2);
if (rotation == 2) world.setBlockMetadataWithNotify(x, y, z, 1, 2);
if (rotation == 3) world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
@Override
public Item getItemDropped(int par1, Random rand, int par3){
return null;
}
@Override
public IIcon getIcon(int side, int meta){
if(side == 1) return this.topIcon;
if(side == 3) return this.frontIcon;
return this.blockIcon;
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){
int meta = world.getBlockMetadata(x, y, z);
if(side == 1) return this.topIcon;
if(side == meta+2 && meta <= 3) return this.frontIcon;
else if(side == meta-2 && meta > 3) return this.onIcon;
return this.blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName());
this.topIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "Top");
this.onIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "On");
this.frontIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "Front");
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
if(!world.isRemote){
world.playSoundAtEntity(player, "random.chestopen", 0.2F, new Random().nextFloat()*0.1F+0.9F);
this.dropItems(world, x, y, z);
world.setBlockToAir(x, y, z);
}
return true;
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int par6){
this.dropItems(world, x, y, z);
super.breakBlock(world, x, y, z, block, par6);
}
private void dropItems(World world, int x, int y, int z){
Random rand = new Random();
for(int i = 0; i < MathHelper.getRandomIntegerInRange(rand, 3, 6); i++){
TreasureChestHandler.Return theReturn = (TreasureChestHandler.Return)WeightedRandom.getRandomItem(rand, TreasureChestHandler.returns);
ItemStack itemStack = theReturn.returnItem.copy();
itemStack.stackSize = MathHelper.getRandomIntegerInRange(rand, theReturn.minAmount, theReturn.maxAmount);
float dX = rand.nextFloat()*0.8F+0.1F;
float dY = rand.nextFloat()*0.8F+0.1F;
float dZ = rand.nextFloat()*0.8F+0.1F;
EntityItem entityItem = new EntityItem(world, x+dX, y+dY, z+dZ, itemStack.copy());
if(itemStack.hasTagCompound()) entityItem.getEntityItem().setTagCompound((NBTTagCompound)itemStack.getTagCompound().copy());
float factor = 0.05F;
entityItem.motionX = rand.nextGaussian()*factor;
entityItem.motionY = rand.nextGaussian()*factor+0.2F;
entityItem.motionZ = rand.nextGaussian()*factor;
world.spawnEntityInWorld(entityItem);
itemStack.stackSize = 0;
}
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand){
//TODO Bubble Particles if in water
}
@Override
public String getName(){
return "blockTreasureChest";
}
public static class TheItemBlock extends ItemBlock{
private Block theBlock;
public TheItemBlock(Block block){
super(block);
this.theBlock = block;
this.setHasSubtypes(false);
this.setMaxDamage(0);
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.epic;
}
@Override
public String getUnlocalizedName(ItemStack stack){
return this.getUnlocalizedName();
}
@Override
@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
BlockUtil.addInformation(theBlock, list, 1, "");
}
@Override
public int getMetadata(int damage){
return damage;
}
}
}

View file

@ -78,6 +78,8 @@ public class InitBlocks{
public static Block blockColoredLampOn;
public static Block blockLampPowerer;
public static Block blockTreasureChest;
public static void init(){
ModUtil.LOGGER.info("Initializing Blocks...");
@ -101,6 +103,9 @@ public class InitBlocks{
blockLampPowerer = new BlockLampPowerer();
BlockUtil.register(blockLampPowerer, BlockLampPowerer.TheItemBlock.class);
blockTreasureChest = new BlockTreasureChest();
BlockUtil.register(blockTreasureChest, BlockTreasureChest.TheItemBlock.class);
blockEnergizer = new BlockEnergizer(true);
BlockUtil.register(blockEnergizer, BlockEnergizer.TheItemBlock.class);

View file

@ -4,6 +4,7 @@ import cpw.mods.fml.common.event.FMLInterModComms;
import ellpeck.actuallyadditions.items.ItemCoffee;
import ellpeck.actuallyadditions.recipe.CrusherRecipeManualRegistry;
import ellpeck.actuallyadditions.recipe.HairyBallHandler;
import ellpeck.actuallyadditions.recipe.TreasureChestHandler;
import ellpeck.actuallyadditions.util.ModUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -63,6 +64,22 @@ public class InterModCommunications{
else ModUtil.LOGGER.log(Level.ERROR, "Ball Of Hair Recipe that was sent from Mod " + message.getSender() + " could not be registered: It's missing an Output or a Chance!");
}
}
if(message.key.equalsIgnoreCase("registerTreasureChestRecipe")){
NBTTagCompound compound = message.getNBTValue();
if(compound != null){
ItemStack output = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("output"));
int chance = compound.getInteger("chance");
int minAmount = compound.getInteger("minAmount");
int maxAmount = compound.getInteger("maxAmount");
if(output != null && chance > 0 && minAmount > 0 && maxAmount >= minAmount){
TreasureChestHandler.addReturn(output, chance, minAmount, maxAmount);
ModUtil.LOGGER.info("Treasure Chest Recipe that was sent from Mod "+message.getSender()+" has been registered successfully: "+output.toString()+", Chance: "+chance+", Min Amount: "+minAmount+", Max Amount: "+maxAmount);
}
else ModUtil.LOGGER.log(Level.ERROR, "Treasure Chest Recipe that was sent from Mod " + message.getSender() + " could not be registered: It's missing an Output, a Chance or minimum and maximum Amounts!");
}
}
}
}

View file

@ -31,6 +31,7 @@ public enum ConfigBoolValues{
DO_CANOLA_GEN("Canola Gen", ConfigCategories.WORLD_GEN, true, "If Canola should generate in the World"),
DO_FLAX_GEN("Flax Gen", ConfigCategories.WORLD_GEN, true, "If Flax should generate in the World"),
DO_COFFEE_GEN("Coffee Gen", ConfigCategories.WORLD_GEN, true, "If Coffee should generate in the World"),
DO_TREASURE_CHEST_GEN("Treasure Chest Gen", ConfigCategories.WORLD_GEN, true, "If Treasure Chests should generate in the World"),
PREVENT_OIL_OVERRIDE("Oil Fluid Override", ConfigCategories.FLUIDS, false, "If not registering Oil Fluids from Actually Additions if other Oil is already registered should be prevented"+ConfigurationHandler.ISSUES_WARNING),
PREVENT_CANOLA_OVERRIDE("Canola Oil Fluid Override", ConfigCategories.FLUIDS, false, "If not registering Canola Oil Fluids from Actually Additions if other Canola Oil is already registered should be prevented"+ConfigurationHandler.ISSUES_WARNING),

View file

@ -54,6 +54,9 @@ public enum ConfigIntValues{
CANOLA_AMOUNT("Canola Amount", ConfigCategories.WORLD_GEN, 10, 1, 50, "The Chance of Canola generating"),
FLAX_AMOUNT("Flax Amount", ConfigCategories.WORLD_GEN, 8, 1, 50, "The Chance of Flax generating"),
COFFEE_AMOUNT("Coffee Amount", ConfigCategories.WORLD_GEN, 6, 1, 50, "The Chance of Coffee generating"),
RICE_CHANCE("Rice Chance", ConfigCategories.WORLD_GEN, 50, 1, 3000, "The 1 in X chance for Rice to generate"),
NORMAL_PLANT_CHANCE("Plant Chance", ConfigCategories.WORLD_GEN, 400, 1, 3000, "The 1 in X chance for Flax, Coffee and Canola to generate"),
TREASURE_CHEST_CHANCE("Treasure Chest Chance", ConfigCategories.WORLD_GEN, 300, 1, 3000, "The 1 in X chance for a Treasure Chest to generate in a Deep Ocean"),
GRINDER_ENERGY_USED("Energy Use: Crusher", ConfigCategories.MACHINE_VALUES, 40, 1, 500, "The Amount of Energy used by the Crusher per Tick"),
GRINDER_DOUBLE_ENERGY_USED("Energy Use: Double Crusher", ConfigCategories.MACHINE_VALUES, 60, 1, 500, "The Amount of Energy used by the Double Crusher per Tick"),

View file

@ -2,6 +2,7 @@ package ellpeck.actuallyadditions.event;
import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.Util;
import net.minecraftforge.common.MinecraftForge;
public class InitEvents{
@ -14,8 +15,8 @@ public class InitEvents{
Util.registerEvent(new PickupEvent());
Util.registerEvent(new TooltipEvent());
Util.registerEvent(new EntityLivingEvent());
Util.registerEvent(new WorldDecorationEvent());
Util.registerEvent(new BucketFillEvent());
MinecraftForge.TERRAIN_GEN_BUS.register(new WorldDecorationEvent());
}
}

View file

@ -1,5 +1,6 @@
package ellpeck.actuallyadditions.event;
import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import ellpeck.actuallyadditions.blocks.InitBlocks;
import ellpeck.actuallyadditions.blocks.metalists.TheWildPlants;
@ -8,6 +9,7 @@ import ellpeck.actuallyadditions.config.values.ConfigIntValues;
import ellpeck.actuallyadditions.util.WorldUtil;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.event.terraingen.DecorateBiomeEvent;
import java.util.ArrayList;
@ -16,10 +18,52 @@ import java.util.Random;
public class WorldDecorationEvent{
@SubscribeEvent
public void onWorldDecoration(DecorateBiomeEvent event){
public void onWorldDecoration(DecorateBiomeEvent.Decorate event){
if((event.getResult() == Event.Result.ALLOW || event.getResult() == Event.Result.DEFAULT)){
this.generateRice(event);
this.genPlantNormally(InitBlocks.blockWildPlant, TheWildPlants.CANOLA.ordinal(), ConfigIntValues.CANOLA_AMOUNT.getValue(), ConfigBoolValues.DO_CANOLA_GEN.isEnabled(), Material.grass, event);
this.genPlantNormally(InitBlocks.blockWildPlant, TheWildPlants.FLAX.ordinal(), ConfigIntValues.FLAX_AMOUNT.getValue(), ConfigBoolValues.DO_FLAX_GEN.isEnabled(), Material.grass, event);
this.genPlantNormally(InitBlocks.blockWildPlant, TheWildPlants.COFFEE.ordinal(), ConfigIntValues.COFFEE_AMOUNT.getValue(), ConfigBoolValues.DO_COFFEE_GEN.isEnabled(), Material.grass, event);
//Generate Treasure Chests
if(ConfigBoolValues.DO_TREASURE_CHEST_GEN.isEnabled()){
if(new Random().nextInt(ConfigIntValues.TREASURE_CHEST_CHANCE.getValue()) == 0){
int genX = event.chunkX+event.rand.nextInt(16)+8;
int genZ = event.chunkZ+event.rand.nextInt(16)+8;
int genY = event.world.getTopSolidOrLiquidBlock(genX, genZ);
if(event.world.getBiomeGenForCoords(genX, genZ) == BiomeGenBase.deepOcean){
if(event.world.getBlock(genX, genY, genZ).getMaterial() == Material.water){
if(event.world.getBlock(genX, genY-1, genZ).getMaterial().isSolid()){
event.world.setBlock(genX, genY, genZ, InitBlocks.blockTreasureChest, 0, 2);
}
}
}
}
}
}
}
private void genPlantNormally(Block plant, int meta, int amount, boolean doIt, Material blockBelow, DecorateBiomeEvent event){
if(doIt){
for(int i = 0; i < amount; i++){
if(new Random().nextInt(ConfigIntValues.NORMAL_PLANT_CHANCE.getValue()) == 0){
int genX = event.chunkX+event.rand.nextInt(16)+8;
int genZ = event.chunkZ+event.rand.nextInt(16)+8;
int genY = event.world.getTopSolidOrLiquidBlock(genX, genZ)-1;
if(event.world.getBlock(genX, genY, genZ).getMaterial() == blockBelow){
event.world.setBlock(genX, genY+1, genZ, plant, meta, 2);
}
}
}
}
}
private void generateRice(DecorateBiomeEvent event){
if(ConfigBoolValues.DO_RICE_GEN.isEnabled()){
for(int i = 0; i < ConfigIntValues.RICE_AMOUNT.getValue(); i++){
if(new Random().nextInt(10) == 0){
if(new Random().nextInt(ConfigIntValues.RICE_CHANCE.getValue()) == 0){
int genX = event.chunkX+event.rand.nextInt(16)+8;
int genZ = event.chunkZ+event.rand.nextInt(16)+8;
int genY = event.world.getTopSolidOrLiquidBlock(genX, genZ);
@ -36,26 +80,5 @@ public class WorldDecorationEvent{
}
}
}
this.genPlantNormally(InitBlocks.blockWildPlant, TheWildPlants.CANOLA.ordinal(), ConfigIntValues.CANOLA_AMOUNT.getValue(), ConfigBoolValues.DO_CANOLA_GEN.isEnabled(), Material.grass, event);
this.genPlantNormally(InitBlocks.blockWildPlant, TheWildPlants.FLAX.ordinal(), ConfigIntValues.FLAX_AMOUNT.getValue(), ConfigBoolValues.DO_FLAX_GEN.isEnabled(), Material.grass, event);
this.genPlantNormally(InitBlocks.blockWildPlant, TheWildPlants.COFFEE.ordinal(), ConfigIntValues.COFFEE_AMOUNT.getValue(), ConfigBoolValues.DO_COFFEE_GEN.isEnabled(), Material.grass, event);
}
public void genPlantNormally(Block plant, int meta, int amount, boolean doIt, Material blockBelow, DecorateBiomeEvent event){
if(doIt){
for(int i = 0; i < amount; i++){
if(new Random().nextInt(100) == 0){
int genX = event.chunkX+event.rand.nextInt(16)+8;
int genZ = event.chunkZ+event.rand.nextInt(16)+8;
int genY = event.world.getTopSolidOrLiquidBlock(genX, genZ)-1;
if(event.world.getBlock(genX, genY, genZ).getMaterial() == blockBelow){
event.world.setBlock(genX, genY+1, genZ, plant, meta, 2);
}
}
}
}
}
}

View file

@ -118,7 +118,7 @@ public class HairyBallRecipeHandler extends TemplateRecipeHandler{
if(recipe.result != null){
int secondChance = recipe.chance;
String secondString = secondChance + "%";
GuiDraw.drawString(secondString, 65+32, 48, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
GuiDraw.drawString(secondString, 65+32, 45, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
}
}

View file

@ -26,6 +26,10 @@ public class NEIActuallyAdditionsConfig implements IConfigureNEI{
API.registerRecipeHandler(ballRecipeHandler);
API.registerUsageHandler(ballRecipeHandler);
TreasureChestRecipeHandler treasureRecipeHandler = new TreasureChestRecipeHandler();
API.registerRecipeHandler(treasureRecipeHandler);
API.registerUsageHandler(treasureRecipeHandler);
CompostRecipeHandler compostRecipeHandler = new CompostRecipeHandler();
API.registerRecipeHandler(compostRecipeHandler);
API.registerUsageHandler(compostRecipeHandler);

View file

@ -0,0 +1,134 @@
package ellpeck.actuallyadditions.nei;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.RecipeInfo;
import codechicken.nei.recipe.TemplateRecipeHandler;
import ellpeck.actuallyadditions.recipe.TreasureChestHandler;
import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.StringUtil;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.util.ArrayList;
import java.util.Collections;
public class TreasureChestRecipeHandler extends TemplateRecipeHandler{
public static final String NAME = "actuallyadditions.treasureChest";
public TreasureChestRecipeHandler(){
super();
RecipeInfo.setGuiOffset(this.getGuiClass(), 0, 0);
}
public class CachedTreasure extends CachedRecipe{
public PositionedStack result;
public PositionedStack input;
public int chance;
public int minAmount;
public int maxAmount;
public CachedTreasure(ItemStack input, ItemStack result, int chance, int minAmount, int maxAmount){
this.result = new PositionedStack(result, 67+32, 19);
this.chance = chance;
this.input = new PositionedStack(input, 5+32, 19);
this.minAmount = minAmount;
this.maxAmount = maxAmount;
}
@Override
public PositionedStack getIngredient(){
return input;
}
@Override
public PositionedStack getResult(){
return result;
}
}
@Override
public int recipiesPerPage(){
return 2;
}
@Override
public Class<? extends GuiContainer> getGuiClass(){
return null;
}
@Override
public String getRecipeName(){
return StatCollector.translateToLocal("container.nei." + NAME + ".name");
}
@Override
public void loadTransferRects(){
transferRects.add(new RecipeTransferRect(new Rectangle(31+32, 18, 22, 16), NAME));
}
@Override
public void loadCraftingRecipes(String outputId, Object... results){
if(outputId.equals(NAME) && getClass() == TreasureChestRecipeHandler.class){
ArrayList<TreasureChestHandler.Return> recipes = TreasureChestHandler.returns;
for(TreasureChestHandler.Return recipe : recipes){
arecipes.add(new CachedTreasure(recipe.input, recipe.returnItem, recipe.itemWeight, recipe.minAmount, recipe.maxAmount));
}
}
else super.loadCraftingRecipes(outputId, results);
}
@Override
public void loadCraftingRecipes(ItemStack result){
ArrayList<TreasureChestHandler.Return> recipes = TreasureChestHandler.returns;
for(TreasureChestHandler.Return recipe : recipes){
if(NEIServerUtils.areStacksSameType(recipe.returnItem, result)) arecipes.add(new CachedTreasure(recipe.input, recipe.returnItem, recipe.itemWeight, recipe.minAmount, recipe.maxAmount));
}
}
@Override
public void loadUsageRecipes(ItemStack ingredient){
ArrayList<TreasureChestHandler.Return> recipes = TreasureChestHandler.returns;
for(TreasureChestHandler.Return recipe : recipes){
if(NEIServerUtils.areStacksSameTypeCrafting(recipe.input, ingredient)){
CachedTreasure theRecipe = new CachedTreasure(recipe.input, recipe.returnItem, recipe.itemWeight, recipe.minAmount, recipe.maxAmount);
theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.input), ingredient);
arecipes.add(theRecipe);
}
}
}
@Override
public String getGuiTexture(){
return ModUtil.MOD_ID_LOWER + ":textures/gui/guiNEITreasure.png";
}
@Override
public void drawBackground(int recipeIndex){
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GuiDraw.changeTexture(getGuiTexture());
GuiDraw.drawTexturedModalRect(32, 0, 0, 0, 96, 60);
}
@Override
public void drawExtras(int rec){
CachedTreasure recipe = (CachedTreasure)this.arecipes.get(rec);
if(recipe.result != null){
int secondChance = recipe.chance;
String secondString = secondChance + "%";
//TODO
GuiDraw.drawString(recipe.minAmount + "-" + recipe.maxAmount + " Items at " + secondString, 65+10, 45, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
}
}
@Override
public String getOverlayIdentifier(){
return NAME;
}
}

View file

@ -0,0 +1,45 @@
package ellpeck.actuallyadditions.recipe;
import ellpeck.actuallyadditions.blocks.InitBlocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.WeightedRandom;
import java.util.ArrayList;
public class TreasureChestHandler{
public static ArrayList<Return> returns = new ArrayList<Return>();
public static void init(){
addReturn(new ItemStack(Items.diamond), 5, 1, 2);
addReturn(new ItemStack(Items.iron_ingot), 30, 1, 5);
addReturn(new ItemStack(Items.gold_nugget), 60, 1, 8);
addReturn(new ItemStack(Items.gold_ingot), 35, 1, 3);
addReturn(new ItemStack(Items.ender_pearl), 10, 1, 2);
addReturn(new ItemStack(Items.emerald), 3, 1, 1);
addReturn(new ItemStack(Items.experience_bottle), 5, 3, 6);
}
public static void addReturn(ItemStack stack, int chance, int minAmount, int maxAmount){
returns.add(new Return(stack, chance, minAmount, maxAmount));
}
public static class Return extends WeightedRandom.Item{
public ItemStack returnItem;
public ItemStack input;
public int minAmount;
public int maxAmount;
public Return(ItemStack returnItem, int chance, int minAmount, int maxAmount){
super(chance);
this.returnItem = returnItem;
this.input = new ItemStack(InitBlocks.blockTreasureChest);
this.minAmount = minAmount;
this.maxAmount = maxAmount;
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB