Skip to content
Permalink
Browse files

Add more pumpkin + melon assets. Change vanilla pumpkin and melon mod…

…els to use item textures to fit in with TFC crops. Add wild crop world gen.
  • Loading branch information...
alcatrazEscapee committed Jun 12, 2019
1 parent 870a0ba commit e54082b43926f6873a2f5eebcd1b388aeb7a60a8
@@ -9,7 +9,6 @@
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;

import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
@@ -170,7 +169,4 @@ public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, Bloc
{
return CROPS_AABB[state.getValue(getStageProperty())];
}


protected abstract PropertyInteger getStageProperty();
}
@@ -10,6 +10,7 @@
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;

import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
@@ -158,4 +159,10 @@ public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos
drops.add(foodDrop);
}
}

@Override
public PropertyInteger getStageProperty()
{
return STAGE_8;
}
}
@@ -8,6 +8,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
@@ -17,6 +18,7 @@
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -45,6 +47,11 @@ public static BlockCropTFC get(ICrop crop)
return MAP.get(crop);
}

public static Set<ICrop> getCrops()
{
return MAP.keySet();
}

protected final ICrop crop;

BlockCropTFC(ICrop crop)
@@ -122,4 +129,6 @@ public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World wo
{
return new ItemStack(ItemSeedsTFC.get(crop));
}

public abstract PropertyInteger getStageProperty();
}
@@ -8,7 +8,6 @@
import java.util.Random;
import javax.annotation.ParametersAreNonnullByDefault;

import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World;
@@ -23,15 +22,15 @@
import net.dries007.tfc.world.classic.ClimateTFC;
import net.dries007.tfc.world.classic.chunkdata.ChunkDataTFC;
import net.dries007.tfc.world.classic.worldgen.WorldGenPlantTFC;
import net.dries007.tfc.world.classic.worldgen.WorldGenPumpkinTFC;
import net.dries007.tfc.world.classic.worldgen.WorldGenSandTFC;
import net.dries007.tfc.world.classic.worldgen.WorldGenWildCrops;

@ParametersAreNonnullByDefault
public class BiomeDecoratorTFC extends BiomeDecorator
{
private final int lilyPadPerChunk;
private final int waterPlantsPerChunk;
private final WorldGenPumpkinTFC pumpkinGen;
private final WorldGenWildCrops wildCropsGen;

private final WorldGenPlantTFC plantGen;
private int standardCount = 0;
@@ -69,7 +68,7 @@ public BiomeDecoratorTFC(int lilyPadPerChunk, int waterPlantsPerChunk)
plantGen = new WorldGenPlantTFC();

sandGen = new WorldGenSandTFC(7);
pumpkinGen = new WorldGenPumpkinTFC(Blocks.PUMPKIN); // todo: replace block? pumpkins and melons are technically crops
wildCropsGen = new WorldGenWildCrops();

for (Plant plant : TFCRegistries.PLANTS.getValuesCollection())
{
@@ -144,7 +143,7 @@ public void decorate(final World world, final Random rng, final Biome biome, fin
MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Pre(world, rng, forgeChunkPos));

ChunkDataTFC data = ChunkDataTFC.get(world, chunkPos);
if (data == null || !data.isInitialized()) return;
if (!data.isInitialized()) return;

final float avgTemperature = ClimateTFC.getAverageBiomeTemp(world, chunkPos);
final float rainfall = ChunkDataTFC.getRainfall(world, chunkPos);
@@ -159,9 +158,9 @@ public void decorate(final World world, final Random rng, final Biome biome, fin
// TerraFirmaCraft.getLog().info("decorate {} ({}) {} {}", chunkPos, biome.getBiomeName(), lilyPadPerChunk, waterPlantsPerChunk);
// todo: crops

if (TerrainGen.decorate(world, rng, forgeChunkPos, DecorateBiomeEvent.Decorate.EventType.PUMPKIN) && rng.nextInt(300) == 0)
if (rng.nextInt(80) == 0)
{
pumpkinGen.generate(world, rng, world.getHeight(chunkPos.add(rng.nextInt(16) + 8, 0, rng.nextInt(16) + 8)));
wildCropsGen.generate(world, rng, world.getHeight(chunkPos.add(rng.nextInt(16) + 8, 0, rng.nextInt(16) + 8)));
}

if (TerrainGen.decorate(world, rng, forgeChunkPos, DecorateBiomeEvent.Decorate.EventType.SHROOM))

This file was deleted.

@@ -0,0 +1,69 @@
/*
* Work under Copyright. Licensed under the EUPL.
* See the project README.md and LICENSE.txt for more information.
*/

package net.dries007.tfc.world.classic.worldgen;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import javax.annotation.ParametersAreNonnullByDefault;

import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;

import net.dries007.tfc.TerraFirmaCraft;
import net.dries007.tfc.api.types.ICrop;
import net.dries007.tfc.objects.blocks.BlocksTFC;
import net.dries007.tfc.objects.blocks.crops.BlockCropTFC;
import net.dries007.tfc.world.classic.ClimateTFC;
import net.dries007.tfc.world.classic.chunkdata.ChunkDataTFC;

@ParametersAreNonnullByDefault
public class WorldGenWildCrops extends WorldGenerator
{
private final List<ICrop> crops;

public WorldGenWildCrops()
{
this.crops = new ArrayList<>(BlockCropTFC.getCrops());
if (crops.size() == 0)
{
TerraFirmaCraft.getLog().warn("There are no wild crops registered to world gen!");
}
}

@Override
public boolean generate(World world, Random rng, BlockPos start)
{
if (crops.size() <= 0)
{
return false;
}

ICrop crop = crops.get(rng.nextInt(crops.size()));
BlockCropTFC cropBlock = BlockCropTFC.get(crop);

float temperature = ClimateTFC.getAverageBiomeTemp(world, start);
float rainfall = ChunkDataTFC.getRainfall(world, start);
if (crop.isValidConditions(temperature, rainfall))
{
for (int i = 0; i < 14 + rng.nextInt(5); ++i)
{
BlockPos pos = start.add(rng.nextInt(8) - rng.nextInt(8), rng.nextInt(4) - rng.nextInt(4), rng.nextInt(8) - rng.nextInt(8));
if (world.isAirBlock(pos) || cropBlock.canPlaceBlockAt(world, pos))
{
if (BlocksTFC.isSoil(world.getBlockState(pos.add(0, -1, 0))))
{
int growth = 2 + rng.nextInt(crop.getMaxStage() - 2);
world.setBlockState(pos, cropBlock.getDefaultState().withProperty(cropBlock.getStageProperty(), growth), 2);
}

}
}
}
return true;
}
}
@@ -0,0 +1,6 @@
{
"parent": "item/handheld",
"textures": {
"layer0": "tfc:items/food/melon"
}
}
@@ -0,0 +1,6 @@
{
"parent": "item/handheld",
"textures": {
"layer0": "tfc:items/food/pumpkin"
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit e54082b

Please sign in to comment.
You can’t perform that action at this time.