Skip to content
Permalink
Browse files

Added Tree registry for real. Removed Wood enum and replaced it with …

…Tree everywhere.

I'm sorry in advance for broken merges :(
  • Loading branch information...
alcatrazEscapee committed Jul 21, 2018
1 parent af55157 commit 2d6b3c503cbcc790be07a1ceccad895d858047da
Showing with 287 additions and 336 deletions.
  1. +2 −2 src/main/java/net/dries007/tfc/api/ITreeGenerator.java
  2. +27 −3 src/main/java/net/dries007/tfc/api/types/Tree.java
  3. +1 −1 src/main/java/net/dries007/tfc/client/ClientEvents.java
  4. +13 −11 src/main/java/net/dries007/tfc/client/render/TESRChestTFC.java
  5. +5 −5 src/main/java/net/dries007/tfc/cmd/TreeGenCommand.java
  6. +27 −0 src/main/java/net/dries007/tfc/objects/CustomRegistries.java
  7. +1 −0 src/main/java/net/dries007/tfc/objects/OreEnum.java
  8. +2 −0 src/main/java/net/dries007/tfc/objects/Rock.java
  9. +0 −92 src/main/java/net/dries007/tfc/objects/Wood.java
  10. +10 −9 src/main/java/net/dries007/tfc/objects/blocks/BlockSlabTFC.java
  11. +6 −5 src/main/java/net/dries007/tfc/objects/blocks/BlockStairsTFC.java
  12. +22 −21 src/main/java/net/dries007/tfc/objects/blocks/BlocksTFC.java
  13. +7 −6 src/main/java/net/dries007/tfc/objects/blocks/wood/BlockBookshelfTFC.java
  14. +7 −6 src/main/java/net/dries007/tfc/objects/blocks/wood/BlockButtonWoodTFC.java
  15. +9 −8 src/main/java/net/dries007/tfc/objects/blocks/wood/BlockChestTFC.java
  16. +7 −6 src/main/java/net/dries007/tfc/objects/blocks/wood/BlockDoorTFC.java
  17. +7 −6 src/main/java/net/dries007/tfc/objects/blocks/wood/BlockFenceGateTFC.java
  18. +7 −6 src/main/java/net/dries007/tfc/objects/blocks/wood/BlockFenceTFC.java
  19. +7 −6 src/main/java/net/dries007/tfc/objects/blocks/wood/BlockLeavesTFC.java
  20. +7 −6 src/main/java/net/dries007/tfc/objects/blocks/wood/BlockLogTFC.java
  21. +7 −6 src/main/java/net/dries007/tfc/objects/blocks/wood/BlockPlanksTFC.java
  22. +9 −7 src/main/java/net/dries007/tfc/objects/blocks/wood/BlockSaplingTFC.java
  23. +7 −6 src/main/java/net/dries007/tfc/objects/blocks/wood/BlockTrapDoorWoodTFC.java
  24. +7 −6 src/main/java/net/dries007/tfc/objects/blocks/wood/BlockWorkbenchTFC.java
  25. +3 −2 src/main/java/net/dries007/tfc/objects/items/ItemsTFC.java
  26. +6 −5 src/main/java/net/dries007/tfc/objects/items/wood/ItemDoorTFC.java
  27. +8 −7 src/main/java/net/dries007/tfc/objects/items/wood/ItemLumberTFC.java
  28. +5 −4 src/main/java/net/dries007/tfc/objects/te/TEChestTFC.java
  29. +8 −18 src/main/java/net/dries007/tfc/world/classic/ChunkGenTFC.java
  30. +19 −40 src/main/java/net/dries007/tfc/world/classic/chunkdata/ChunkDataTFC.java
  31. +4 −4 src/main/java/net/dries007/tfc/world/classic/genlayers/datalayers/tree/GenLayerTreeInit.java
  32. +2 −2 src/main/java/net/dries007/tfc/world/classic/genlayers/datalayers/tree/GenTreeLayer.java
  33. +8 −10 src/main/java/net/dries007/tfc/world/classic/worldgen/WorldGenTrees.java
  34. +2 −2 src/main/java/net/dries007/tfc/world/classic/worldgen/trees/TreeGenAcacia.java
  35. +2 −2 src/main/java/net/dries007/tfc/world/classic/worldgen/trees/TreeGenKapok.java
  36. +4 −4 src/main/java/net/dries007/tfc/world/classic/worldgen/trees/TreeGenNormal.java
  37. +2 −2 src/main/java/net/dries007/tfc/world/classic/worldgen/trees/TreeGenSequoia.java
  38. +3 −3 src/main/java/net/dries007/tfc/world/classic/worldgen/trees/TreeGenVariants.java
  39. +6 −6 src/main/java/net/dries007/tfc/world/classic/worldgen/trees/TreeGenWillow.java
  40. +1 −1 src/main/java/net/dries007/tfc/world/classic/worldgen/vein/VeinType.java
@@ -12,7 +12,7 @@
import net.minecraft.world.World;
import net.minecraft.world.gen.structure.template.TemplateManager;

import net.dries007.tfc.objects.Wood;
import net.dries007.tfc.api.types.Tree;

public interface ITreeGenerator
{
@@ -25,5 +25,5 @@
* @param tree The tree type to spawn
* @param rand A random to use in generation
*/
void generateTree(TemplateManager manager, World world, BlockPos pos, Wood tree, Random rand);
void generateTree(TemplateManager manager, World world, BlockPos pos, Tree tree, Random rand);
}
@@ -6,7 +6,14 @@

package net.dries007.tfc.api.types;

import java.util.Random;
import javax.annotation.Nonnull;

import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.gen.structure.template.TemplateManager;
import net.minecraftforge.registries.IForgeRegistryEntry;

import net.dries007.tfc.api.ITreeGenerator;
@@ -21,9 +28,13 @@
public final float minEVT;
public final float maxEVT;

// Used when growing a tree
public final ITreeGenerator gen;
/**
* The path part of the resource location, used for assigning block names
*/
public final String name;
public final int maxGrowthRadius;
// Used when growing a tree
private final ITreeGenerator gen;

/**
* This is a registry object that will create a number of things:
@@ -41,7 +52,7 @@
* @param maxEVT max EVT
* @param gen the generator that should be called to generate this tree, both during world gen and when growing from a sapling
*/
public Tree(ResourceLocation name, float minTemp, float maxTemp, float minRain, float maxRain, float minEVT, float maxEVT, int maxGrowthRadius, ITreeGenerator gen)
public Tree(@Nonnull ResourceLocation name, float minTemp, float maxTemp, float minRain, float maxRain, float minEVT, float maxEVT, int maxGrowthRadius, @Nonnull ITreeGenerator gen)
{
this.minTemp = minTemp;
this.maxTemp = maxTemp;
@@ -53,6 +64,19 @@ public Tree(ResourceLocation name, float minTemp, float maxTemp, float minRain,
this.gen = gen;
this.maxGrowthRadius = maxGrowthRadius;

this.name = name.getResourcePath().toLowerCase();
setRegistryName(name);
}

public void makeTree(TemplateManager manager, World world, BlockPos pos, Random rand)
{
this.gen.generateTree(manager, world, pos, this, rand);
}

public void makeTree(World world, BlockPos pos, Random rand)
{
if (world.isRemote) return;
final TemplateManager manager = ((WorldServer) world).getStructureTemplateManager();
this.gen.generateTree(manager, world, pos, this, rand);
}
}
@@ -109,7 +109,7 @@ public static void onRenderGameOverlayText(RenderGameOverlayEvent.Text event)
list.add(GRAY + "Rocks: " + WHITE + data.getRockLayer1(x, z).name + ", " + data.getRockLayer2(x, z).name + ", " + data.getRockLayer3(x, z).name);
list.add(GRAY + "EVT: " + WHITE + data.getEvtLayer(x, z).name);
list.add(GRAY + "Rainfall: " + WHITE + data.getRainfallLayer(x, z).name);
list.add(GRAY + "Trees: "+ WHITE + data.getTreeLayer1(x, z).name() + ", " + data.getTreeLayer2(x, z).name() + ", " + data.getTreeLayer3(x, z).name());
list.add(GRAY + "Trees: " + WHITE + data.getTree1().name + ", " + data.getTree2().name + ", " + data.getTree3().name);
list.add(GRAY + "Stability: " + WHITE + data.getStabilityLayer(x, z).name);
list.add(GRAY + "Drainage: " + WHITE + data.getDrainageLayer(x, z).name);
list.add(GRAY + "Sea level offset: " + WHITE + data.getSeaLevelOffset(x, z));
@@ -5,7 +5,8 @@

package net.dries007.tfc.client.render;

import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;

import net.minecraft.block.BlockChest;
import net.minecraft.client.model.ModelChest;
@@ -16,7 +17,8 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import net.dries007.tfc.objects.Wood;
import net.dries007.tfc.api.types.Tree;
import net.dries007.tfc.objects.CustomRegistries;
import net.dries007.tfc.objects.blocks.wood.BlockChestTFC;
import net.dries007.tfc.objects.te.TEChestTFC;

@@ -25,19 +27,19 @@
@SideOnly(Side.CLIENT)
public class TESRChestTFC extends TileEntitySpecialRenderer<TEChestTFC>
{
private static final EnumMap<Wood, ResourceLocation> SINGLE_TEXTURES = new EnumMap<>(Wood.class);
private static final EnumMap<Wood, ResourceLocation> DOUBLE_TEXTURES = new EnumMap<>(Wood.class);
private static final EnumMap<Wood, ResourceLocation> TRAP_SINGLE_TEXTURES = new EnumMap<>(Wood.class);
private static final EnumMap<Wood, ResourceLocation> TRAP_DOUBLE_TEXTURES = new EnumMap<>(Wood.class);
private static final Map<Tree, ResourceLocation> SINGLE_TEXTURES = new HashMap<>();
private static final Map<Tree, ResourceLocation> DOUBLE_TEXTURES = new HashMap<>();
private static final Map<Tree, ResourceLocation> TRAP_SINGLE_TEXTURES = new HashMap<>();
private static final Map<Tree, ResourceLocation> TRAP_DOUBLE_TEXTURES = new HashMap<>();

static
{
for (Wood wood : Wood.values())
for (Tree wood : CustomRegistries.getTrees())
{
SINGLE_TEXTURES.put(wood, new ResourceLocation(MOD_ID, "textures/entity/chests/chest/" + wood.name().toLowerCase() + ".png"));
DOUBLE_TEXTURES.put(wood, new ResourceLocation(MOD_ID, "textures/entity/chests/chest_double/" + wood.name().toLowerCase() + ".png"));
TRAP_SINGLE_TEXTURES.put(wood, new ResourceLocation(MOD_ID, "textures/entity/chests/chest_trap/" + wood.name().toLowerCase() + ".png"));
TRAP_DOUBLE_TEXTURES.put(wood, new ResourceLocation(MOD_ID, "textures/entity/chests/chest_trap_double/" + wood.name().toLowerCase() + ".png"));
SINGLE_TEXTURES.put(wood, new ResourceLocation(MOD_ID, "textures/entity/chests/chest/" + wood.name + ".png"));
DOUBLE_TEXTURES.put(wood, new ResourceLocation(MOD_ID, "textures/entity/chests/chest_double/" + wood.name + ".png"));
TRAP_SINGLE_TEXTURES.put(wood, new ResourceLocation(MOD_ID, "textures/entity/chests/chest_trap/" + wood.name + ".png"));
TRAP_DOUBLE_TEXTURES.put(wood, new ResourceLocation(MOD_ID, "textures/entity/chests/chest_trap_double/" + wood.name + ".png"));
}
}

@@ -19,8 +19,8 @@
import net.minecraft.world.gen.structure.template.TemplateManager;

import mcp.MethodsReturnNonnullByDefault;
import net.dries007.tfc.api.ITreeGenerator;
import net.dries007.tfc.objects.Wood;
import net.dries007.tfc.api.types.Tree;
import net.dries007.tfc.objects.CustomRegistries;

@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
@@ -45,16 +45,16 @@ public void execute(MinecraftServer server, ICommandSender sender, String[] args
if (args.length != 1)
throw new WrongUsageException("1 argument required.");

Wood tree = Wood.valueOf(args[0].toUpperCase());
Tree tree = CustomRegistries.getTree(args[0]);
if (tree == null) throw new WrongUsageException("Tree type " + args[0] + " not found");

if (sender.getCommandSenderEntity() == null) return;

final World world = sender.getEntityWorld();
final BlockPos center = new BlockPos(sender.getCommandSenderEntity());
final TemplateManager manager = ((WorldServer) world).getStructureTemplateManager();

ITreeGenerator gen = tree.getTreeGenerator();
gen.generateTree(manager, world, center, tree, world.rand);
tree.makeTree(manager, world, center, world.rand);

}
}
@@ -9,6 +9,8 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import net.minecraft.block.Block;
import net.minecraft.util.ResourceLocation;
@@ -39,11 +41,36 @@
private static IForgeRegistry<Ore> oreRegistry;
private static IForgeRegistry<Tree> treeRegistry;

@Nonnull
public static Collection<Tree> getTrees()
{
return Collections.unmodifiableCollection(treeRegistry.getValuesCollection());
}

@Nullable
public static Tree getTree(String name)
{
return treeRegistry.getValuesCollection().stream().filter(tree -> tree.name.equals(name)).findFirst().orElse(null);
}

@Nonnull
public static Collection<Rock> getRocks()
{
return Collections.unmodifiableCollection(rockRegistry.getValuesCollection());
}

@Nonnull
public static Collection<RockCategory> getRockCategories()
{
return Collections.unmodifiableCollection(rockCategoryRegistry.getValuesCollection());
}

@Nonnull
public static Collection<Ore> getOres()
{
return Collections.unmodifiableCollection(oreRegistry.getValuesCollection());
}

@SubscribeEvent
public static void onNewRegistryEvent(RegistryEvent.NewRegistry event)
{
@@ -7,6 +7,7 @@

import net.minecraft.util.IStringSerializable;

@Deprecated
public enum OreEnum
{
NATIVE_COPPER(Metal.COPPER),
@@ -15,6 +15,7 @@
import net.dries007.tfc.objects.blocks.stone.BlockRockVariant;
import net.dries007.tfc.objects.blocks.stone.BlockRockVariantConnected;

@Deprecated
public enum Rock
{
GRANITE(Category.IGNEOUS_INTRUSIVE),
@@ -46,6 +47,7 @@
this.category = category;
}

@Deprecated
public enum Category
{
SEDIMENTARY(ToolMaterialsTFC.SED),

This file was deleted.

0 comments on commit 2d6b3c5

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