Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
tallgrass now uses the new plant system
  • Loading branch information
Konlii committed Mar 6, 2019
1 parent bf143ca commit 0de57b5
Show file tree
Hide file tree
Showing 120 changed files with 979 additions and 755 deletions.
10 changes: 4 additions & 6 deletions src/main/java/net/dries007/tfc/api/types/Plant.java
Expand Up @@ -15,10 +15,7 @@
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.registries.IForgeRegistryEntry;

import net.dries007.tfc.objects.blocks.plants.BlockCreepingPlantTFC;
import net.dries007.tfc.objects.blocks.plants.BlockDoublePlantTFC;
import net.dries007.tfc.objects.blocks.plants.BlockLilyPadTFC;
import net.dries007.tfc.objects.blocks.plants.BlockPlantTFC;
import net.dries007.tfc.objects.blocks.plants.*;

public class Plant extends IForgeRegistryEntry.Impl<Plant>
{
Expand Down Expand Up @@ -106,8 +103,9 @@ public enum PlantType
CREEPINGPLANT(BlockCreepingPlantTFC::new),
LILYPAD(BlockLilyPadTFC::new),
DESERTPLANT(BlockPlantTFC::new),
STACKPLANT(BlockPlantTFC::new),
CACTUS(BlockPlantTFC::new);
CACTUS(BlockCactusTFC::new),
SHORTGRASS(BlockShortGrassTFC::new),
TALLGRASS(BlockTallGrassTFC::new);

public static Block create(Plant plant, PlantType type)
{
Expand Down
16 changes: 0 additions & 16 deletions src/main/java/net/dries007/tfc/client/ClientRegisterEvents.java
Expand Up @@ -225,14 +225,6 @@ public static void registerColorHandlerBlocks(ColorHandlerEvent.Block event)
worldIn != null && pos != null ? BiomeColorHelper.getFoliageColorAtPos(worldIn, pos) : ColorizerFoliage.getFoliageColorBasic(),
BlocksTFC.getAllLeafBlocks().toArray(new Block[0]));

blockcolors.registerBlockColorHandler((state, worldIn, pos, tintIndex) ->
worldIn != null && pos != null ? BiomeColorHelper.getGrassColorAtPos(worldIn, pos) : ColorizerGrass.getGrassColor(0.5D, 1.0D),
BlocksTFC.TALL_GRASS);

blockcolors.registerBlockColorHandler((state, worldIn, pos, tintIndex) ->
worldIn != null && pos != null ? BiomeColorHelper.getGrassColorAtPos(worldIn, pos) : ColorizerGrass.getGrassColor(0.5D, 1.0D),
BlocksTFC.DOUBLE_TALL_GRASS);

blockcolors.registerBlockColorHandler((state, worldIn, pos, tintIndex) ->
worldIn != null && pos != null ? BiomeColorHelper.getFoliageColorAtPos(worldIn, pos) : ColorizerFoliage.getFoliageColorBasic(),
BlocksTFC.getAllPlantBlocks().toArray(new Block[0]));
Expand Down Expand Up @@ -260,14 +252,6 @@ public static void registerColorHandlerItems(ColorHandlerEvent.Item event)
itemColors.registerItemColorHandler((stack, tintIndex) -> tintIndex == 1 ? EnumDyeColor.byDyeDamage(stack.getItemDamage()).getColorValue() : 0xFFFFFF,
ItemsTFC.CERAMICS_UNFIRED_VESSEL_GLAZED, ItemsTFC.CERAMICS_FIRED_VESSEL_GLAZED);

itemColors.registerItemColorHandler((stack, tintIndex) ->
event.getBlockColors().colorMultiplier(((ItemBlock) stack.getItem()).getBlock().getStateFromMeta(stack.getMetadata()), null, null, tintIndex),
BlocksTFC.TALL_GRASS);

itemColors.registerItemColorHandler((stack, tintIndex) ->
event.getBlockColors().colorMultiplier(((ItemBlock) stack.getItem()).getBlock().getStateFromMeta(stack.getMetadata()), null, null, tintIndex),
BlocksTFC.DOUBLE_TALL_GRASS);

itemColors.registerItemColorHandler((stack, tintIndex) ->
event.getBlockColors().colorMultiplier(((ItemBlock) stack.getItem()).getBlock().getStateFromMeta(stack.getMetadata()), null, null, tintIndex),
BlocksTFC.getAllPlantBlocks().toArray(new BlockPlantTFC[0]));
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/net/dries007/tfc/objects/blocks/BlocksTFC.java
Expand Up @@ -106,11 +106,6 @@ public final class BlocksTFC
public static final BlockIngotPile INGOT_PILE = null;
public static final BlockTorchTFC TORCH = null;

@GameRegistry.ObjectHolder("plants/tallgrass")
public static final BlockTallGrassTFC TALL_GRASS = null;
@GameRegistry.ObjectHolder("plants/double_grass")
public static final BlockDoubleTallGrassTFC DOUBLE_TALL_GRASS = null;

// All these are for use in model registration. Do not use for block lookups.
// Use the static get methods in the classes instead.
private static ImmutableList<ItemBlock> allNormalItemBlocks;
Expand Down Expand Up @@ -248,9 +243,6 @@ public static void registerBlocks(RegistryEvent.Register<Block> event)

normalItemBlocks.add(new ItemBlock(register(r, "thatch", new BlockThatch(Material.PLANTS), CT_DECORATIONS)));

normalItemBlocks.add(new ItemBlock(register(r, "plants/tallgrass", new BlockTallGrassTFC(), CT_DECORATIONS)));
normalItemBlocks.add(new ItemBlock(register(r, "plants/double_grass", new BlockDoubleTallGrassTFC(), CT_DECORATIONS)));

register(r, "firepit", new BlockFirePit()); // No item or creative tab.

{
Expand Down Expand Up @@ -423,6 +415,14 @@ else if (plant.getPlantType() == Plant.PlantType.CACTUS)
{
b.add(register(r, "plants/" + plant.getRegistryName().getPath(), new BlockCactusTFC(plant, Plant.PlantType.CACTUS), CT_DECORATIONS));
}
else if (plant.getPlantType() == Plant.PlantType.SHORTGRASS)
{
b.add(register(r, "plants/" + plant.getRegistryName().getPath(), new BlockShortGrassTFC(plant, Plant.PlantType.SHORTGRASS), CT_DECORATIONS));
}
else if (plant.getPlantType() == Plant.PlantType.TALLGRASS)
{
b.add(register(r, "plants/" + plant.getRegistryName().getPath(), new BlockTallGrassTFC(plant, Plant.PlantType.TALLGRASS), CT_DECORATIONS));
}
}
allPlantBlocks = b.build();
for (BlockPlantTFC blockPlant : allPlantBlocks)
Expand Down
Expand Up @@ -131,6 +131,12 @@ public IBlockState getStateFromMeta(int meta)
return this.getDefaultState().withProperty(AGE, meta).withProperty(GROWTHSTAGE, CalenderTFC.getMonthOfYear().id());
}

@Override
public boolean isReplaceable(IBlockAccess worldIn, BlockPos pos)
{
return false;
}

@Override
public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random random)
{
Expand Down
Expand Up @@ -146,7 +146,7 @@ public int getMetaFromState(IBlockState state)
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
return state.withProperty(TIME, state.getValue(TIME)).withProperty(AGE, state.getValue(AGE)).withProperty(GROWTHSTAGE, state.getValue(GROWTHSTAGE)).withProperty(PART, getPlantPart(worldIn, pos));
return state.withProperty(TIME, state.getValue(TIME)).withProperty(AGE, state.getValue(AGE)).withProperty(GROWTHSTAGE, CalenderTFC.getMonthOfYear().id()).withProperty(PART, getPlantPart(worldIn, pos));
}

@Override
Expand Down Expand Up @@ -204,13 +204,13 @@ public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random ra

if (rand.nextFloat() < getGrowthRate(worldIn, pos) && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(worldIn, pos, state, true))
{
if (j == 15)
if (j == 0)
{
shrink(worldIn, rand, pos, state);
}
else
{
worldIn.setBlockState(pos, state.withProperty(AGE, j + 1).withProperty(GROWTHSTAGE, state.getValue(GROWTHSTAGE)).withProperty(PART, state.getValue(PART)));
worldIn.setBlockState(pos, state.withProperty(AGE, j - 1).withProperty(GROWTHSTAGE, state.getValue(GROWTHSTAGE)).withProperty(PART, state.getValue(PART)));
}
net.minecraftforge.common.ForgeHooks.onCropsGrowPost(worldIn, pos, state, worldIn.getBlockState(pos));
}
Expand Down

0 comments on commit 0de57b5

Please sign in to comment.