Added alfalfa based foods and recipes

This commit is contained in:
Sollace 2018-09-26 20:53:35 +02:00
parent 55b050a992
commit e8aaafbb75
10 changed files with 108 additions and 6 deletions

View file

@ -20,7 +20,9 @@ import net.minecraft.init.Enchantments;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemDoor;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemSeedFood;
import net.minecraft.item.ItemSoup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.item.crafting.IRecipe;
@ -77,10 +79,18 @@ public class UItems {
public static final ItemOfHolding bag_of_holding = new ItemOfHolding(Unicopia.MODID, "bag_of_holding");
public static final Item alfalfa_seeds = new ItemSeeds(UBlocks.alfalfa, Blocks.FARMLAND)
public static final Item alfalfa_seeds = new ItemSeedFood(1, 4, UBlocks.alfalfa, Blocks.FARMLAND)
.setTranslationKey("alfalfa_seeds")
.setRegistryName(Unicopia.MODID, "alfalfa_seeds");
public static final Item alfalfa_leaves = new ItemFood(1, 3, false)
.setTranslationKey("alfalfa_leaves")
.setRegistryName(Unicopia.MODID, "alfalfa_leaves");
public static final Item cereal = new ItemSoup(15)
.setTranslationKey("cereal")
.setRegistryName(Unicopia.MODID, "cereal");
static void registerItems(IForgeRegistry<Item> registry) {
RegistryLockSpinner.unlock(Item.REGISTRY);
@ -88,10 +98,12 @@ public class UItems {
RegistryLockSpinner.lock(Item.REGISTRY);
registry.registerAll(cloud_spawner, dew_drop, cloud_matter, cloud_block,
cloud_stairs, cloud_slab, mist_door, anvil,
bag_of_holding, spell, curse,
alfalfa_seeds);
alfalfa_seeds, alfalfa_leaves, cereal);
if (UClient.isClientSide()) {
registerAllVariants(apple, apple.getVariants());
@ -107,6 +119,8 @@ public class UItems {
registerAllVariants(spell, "gem");
registerAllVariants(curse, "corrupted_gem");
registerAllVariants(alfalfa_seeds, "alfalfa_seeds");
registerAllVariants(alfalfa_leaves, "alfalfa_leaves");
registerAllVariants(cereal, "cereal");
}
registerFuels();

View file

@ -1,6 +1,7 @@
package com.minelittlepony.unicopia;
import net.minecraft.block.Block;
import net.minecraft.block.BlockCrops;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Blocks;
import net.minecraft.item.EnumAction;
@ -154,7 +155,9 @@ public class Unicopia {
@SubscribeEvent
public static void onBlockHarvested(BlockEvent.HarvestDropsEvent event) {
if (event.getState().getBlock() == Blocks.STONE) {
Block block = event.getState().getBlock();
if (block == Blocks.STONE) {
int fortuneFactor = 1 + event.getFortuneLevel() * 15;
if (event.getWorld().rand.nextInt(500 / fortuneFactor) == 0) {
@ -166,6 +169,14 @@ public class Unicopia {
}
}
}
} else if (block instanceof BlockCrops) {
int fortuneFactor = 1 + event.getFortuneLevel() * 15;
if (event.getWorld().rand.nextInt(500 / fortuneFactor) == 0) {
for (int i = 0; i < 1 + event.getFortuneLevel(); i++) {
event.getDrops().add(new ItemStack(UItems.alfalfa_seeds, 1));
}
}
}
}

View file

@ -12,7 +12,9 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
@ -139,6 +141,25 @@ public class BlockAlfalfa extends BlockCrops {
return super.getItemDropped(state, rand, fortune);
}
@Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
Random rand = world instanceof World ? ((World)world).rand : RANDOM;
Item item = getItemDropped(state, rand, fortune);
if (item != Items.AIR) {
drops.add(new ItemStack(item, getFullAge(world, pos), damageDropped(state)));
if (isMaxAge(state)) {
drops.add(new ItemStack(UItems.alfalfa_leaves, rand.nextInt(10)));
}
}
}
@Override
public int quantityDropped(IBlockState state, int fortune, Random random) {
return 1;
}
@Override
public boolean canBlockStay(World world, BlockPos pos, IBlockState state) {
return getHalf(state) != Half.BOTTOM || super.canBlockStay(world, pos, state);
@ -198,8 +219,6 @@ public class BlockAlfalfa extends BlockCrops {
@Override
public boolean canGrow(World world, BlockPos pos, IBlockState state, boolean isClient) {
Half half = getHalf(state);
if (half == Half.MIDDLE || (half == Half.TOP && world.getBlockState(pos.down()).getBlock() == this)) {

View file

@ -45,6 +45,9 @@ item.apple.rotten.name=Rotten Apple
item.apple.zap.name=Zap Apple
item.apple.zap_cooked.name=Cooked Zap Apple
item.alfalfa_leaves.name=Alfalfa
item.alfalfa_seeds.name=Grain
entity.racing_cloud.name=Bucking Bronco
entity.construction_cloud.name=Construction Cloud
entity.cloud.name=Cloud

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "unicopia:items/alfalfa_leaves"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "unicopia:items/cereal"
}
}

View file

@ -0,0 +1,21 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"###",
" # ",
"###"
],
"key": {
"#": [
{
"item": "unicopia:cloud_block",
"data": 0
}
]
},
"result": {
"item": "unicopia:anvil",
"data": 0,
"count": 1
}
}

View file

@ -0,0 +1,22 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{
"item": "minecraft:bowl"
},
{
"item": "unicopia:alfalfa_seeds"
},
{
"item": "unicopia:alfalfa_leaves"
},
{
"item": "minecraft:milk_bucket"
}
],
"result": {
"item": "unicopia:cereal",
"data": 0,
"count": 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 B