Skip to content
Permalink
Browse files

Update registry stuffs. (finally)

  • Loading branch information...
alcatrazEscapee committed Aug 25, 2018
1 parent a893640 commit 1d1260f19cae0d7225902dd555bfd77ea7a9c476
Showing with 339 additions and 594 deletions.
  1. +2 −2 src/main/java/net/dries007/tfc/api/capability/heat/CapabilityItemHeat.java
  2. +1 −1 src/main/java/net/dries007/tfc/api/capability/size/CapabilityItemSize.java
  3. +2 −4 src/main/java/net/dries007/tfc/api/registries/TFCRegistries.java
  4. +1 −0 src/main/java/net/dries007/tfc/api/registries/TFCRegistryNames.java
  5. +99 −20 src/main/java/net/dries007/tfc/api/types/Metal.java
  6. +13 −0 src/main/java/net/dries007/tfc/api/types/Ore.java
  7. +26 −10 src/main/java/net/dries007/tfc/api/types/Rock.java
  8. 0 src/main/java/net/dries007/tfc/api/types/TFCRegistries.java
  9. +3 −3 src/main/java/net/dries007/tfc/client/ClientRegisterEvents.java
  10. +2 −2 src/main/java/net/dries007/tfc/client/TFCGuiHandler.java
  11. +0 −6 src/main/java/net/dries007/tfc/client/gui/GuiContainerTFC.java
  12. +2 −2 src/main/java/net/dries007/tfc/client/gui/GuiLiquidTransfer.java
  13. +1 −1 src/main/java/net/dries007/tfc/client/render/TESRIngotPile.java
  14. +0 −109 src/main/java/net/dries007/tfc/objects/MetalType.java
  15. +0 −104 src/main/java/net/dries007/tfc/objects/RockType.java
  16. +9 −10 src/main/java/net/dries007/tfc/objects/blocks/BlockSlabTFC.java
  17. +4 −5 src/main/java/net/dries007/tfc/objects/blocks/BlockStairsTFC.java
  18. +9 −14 src/main/java/net/dries007/tfc/objects/blocks/BlocksTFC.java
  19. +2 −3 src/main/java/net/dries007/tfc/objects/blocks/metal/BlockAnvilTFC.java
  20. +8 −4 src/main/java/net/dries007/tfc/objects/blocks/metal/BlockIngotPile.java
  21. +3 −4 src/main/java/net/dries007/tfc/objects/blocks/metal/BlockSheet.java
  22. +3 −4 src/main/java/net/dries007/tfc/objects/blocks/stone/BlockFarmlandTFC.java
  23. +1 −2 src/main/java/net/dries007/tfc/objects/blocks/stone/BlockOreTFC.java
  24. +2 −3 src/main/java/net/dries007/tfc/objects/blocks/stone/BlockPathTFC.java
  25. +1 −2 src/main/java/net/dries007/tfc/objects/blocks/stone/BlockRockRaw.java
  26. +12 −13 src/main/java/net/dries007/tfc/objects/blocks/stone/BlockRockVariant.java
  27. +1 −2 src/main/java/net/dries007/tfc/objects/blocks/stone/BlockRockVariantConnected.java
  28. +1 −2 src/main/java/net/dries007/tfc/objects/blocks/stone/BlockRockVariantFallable.java
  29. +3 −4 src/main/java/net/dries007/tfc/objects/blocks/stone/BlockWallTFC.java
  30. +2 −3 src/main/java/net/dries007/tfc/objects/fluids/FluidMetal.java
  31. +3 −2 src/main/java/net/dries007/tfc/objects/fluids/FluidsTFC.java
  32. +8 −12 src/main/java/net/dries007/tfc/objects/items/ItemsTFC.java
  33. +9 −9 src/main/java/net/dries007/tfc/objects/items/ceramics/ItemMold.java
  34. +5 −5 src/main/java/net/dries007/tfc/objects/items/ceramics/ItemUnfiredMold.java
  35. +1 −2 src/main/java/net/dries007/tfc/objects/items/metal/ItemAnvil.java
  36. +1 −2 src/main/java/net/dries007/tfc/objects/items/metal/ItemIngot.java
  37. +1 −2 src/main/java/net/dries007/tfc/objects/items/metal/ItemLamp.java
  38. +6 −7 src/main/java/net/dries007/tfc/objects/items/metal/ItemMetal.java
  39. +1 −2 src/main/java/net/dries007/tfc/objects/items/metal/ItemMetalArmor.java
  40. +1 −2 src/main/java/net/dries007/tfc/objects/items/metal/ItemMetalTool.java
  41. +4 −5 src/main/java/net/dries007/tfc/objects/items/metal/ItemOreTFC.java
  42. +1 −2 src/main/java/net/dries007/tfc/objects/items/metal/ItemSheet.java
  43. +2 −2 src/main/java/net/dries007/tfc/objects/items/metal/ItemSmallOre.java
  44. +4 −4 src/main/java/net/dries007/tfc/objects/recipes/MetalToolRecipe.java
  45. +14 −14 src/main/java/net/dries007/tfc/objects/recipes/RecipeRegistryEvents.java
  46. +6 −6 src/main/java/net/dries007/tfc/objects/te/TEIngotPile.java
  47. +4 −4 src/main/java/net/dries007/tfc/types/DefaultMetals.java
  48. +0 −100 src/main/java/net/dries007/tfc/types/DefaultOres.java
  49. +2 −4 src/main/java/net/dries007/tfc/types/Registries.java
  50. +3 −16 src/main/java/net/dries007/tfc/util/Helpers.java
  51. +21 −22 src/main/java/net/dries007/tfc/util/OreDictionaryHelper.java
  52. +18 −19 src/main/java/net/dries007/tfc/world/classic/ChunkGenTFC.java
  53. +4 −4 src/main/java/net/dries007/tfc/world/classic/worldgen/WorldGenFissure.java
  54. +1 −2 src/main/java/net/dries007/tfc/world/classic/worldgen/WorldGenLargeRocks.java
  55. +2 −2 src/main/java/net/dries007/tfc/world/classic/worldgen/WorldGenOre.java
  56. +1 −1 src/main/java/net/dries007/tfc/world/classic/worldgen/WorldGenSandTFC.java
  57. +3 −3 src/main/java/net/dries007/tfc/world/classic/worldgen/WorldGenSoilPits.java
@@ -17,15 +17,15 @@
import net.minecraftforge.common.capabilities.*;

import net.dries007.tfc.ConfigTFC;
import net.dries007.tfc.Constants;
import net.dries007.tfc.api.util.TFCConstants;
import net.dries007.tfc.world.classic.CalenderTFC;

public class CapabilityItemHeat
{

public static final CapabilityItemHeat INSTANCE = new CapabilityItemHeat();

private static final ResourceLocation ID = new ResourceLocation(Constants.MOD_ID, "item_heat");
private static final ResourceLocation ID = new ResourceLocation(TFCConstants.MOD_ID, "item_heat");

@CapabilityInject(IItemHeat.class)
public static Capability<IItemHeat> ITEM_HEAT_CAPABILITY = null;
@@ -21,7 +21,7 @@
import net.minecraftforge.event.AttachCapabilitiesEvent;

import mcp.MethodsReturnNonnullByDefault;
import net.dries007.tfc.Constants;
import net.dries007.tfc.api.util.TFCConstants;

public class CapabilityItemSize
{
@@ -12,10 +12,7 @@
import net.minecraftforge.registries.IForgeRegistry;

import net.dries007.tfc.TerraFirmaCraft;
import net.dries007.tfc.api.types.Ore;
import net.dries007.tfc.api.types.Rock;
import net.dries007.tfc.api.types.RockCategory;
import net.dries007.tfc.api.types.Tree;
import net.dries007.tfc.api.types.*;

/**
* Get Registry instances for standard TFC objects here.
@@ -26,6 +23,7 @@
public static final IForgeRegistry<RockCategory> ROCK_CATEGORIES = GameRegistry.findRegistry(RockCategory.class);
public static final IForgeRegistry<Ore> ORES = GameRegistry.findRegistry(Ore.class);
public static final IForgeRegistry<Tree> TREES = GameRegistry.findRegistry(Tree.class);
public static final IForgeRegistry<Metal> METALS = GameRegistry.findRegistry(Metal.class);

static
{
@@ -18,4 +18,5 @@
public static final ResourceLocation ROCK = new ResourceLocation(MOD_ID, "rock");
public static final ResourceLocation ORE = new ResourceLocation(MOD_ID, "ore");
public static final ResourceLocation TREE = new ResourceLocation(MOD_ID, "tree");
public static final ResourceLocation METAL = new ResourceLocation(MOD_ID, "metal");
}
@@ -6,31 +6,24 @@

package net.dries007.tfc.api.types;

import java.util.Collection;
import java.util.Collections;
import java.util.function.BiFunction;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.registries.IForgeRegistryEntry;

import net.dries007.tfc.objects.items.metal.*;

/**
* todo: document API
*/
public class Metal extends IForgeRegistryEntry.Impl<Metal>
{
@Nonnull
public static Collection<Metal> values()
{
return Collections.unmodifiableCollection(TFCRegistries.getMetals().getValuesCollection());
}

@Nullable
public static Metal get(String name)
{
return values().stream().filter(x -> x.name().equals(name)).findFirst().orElse(null);
}
@GameRegistry.ObjectHolder("tfc:unknown")
public static final Metal UNKNOWN = null;

public final Tier tier;
public final float specificHeat;
@@ -39,7 +32,6 @@ public static Metal get(String name)
public final int color;

private final Item.ToolMaterial toolMetal;
private final ResourceLocation name;

/**
* This is a registry object that will create a number of things.
@@ -65,15 +57,9 @@ public Metal(@Nonnull ResourceLocation name, Tier tier, boolean usable, float sh

this.toolMetal = toolMetal;

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

public String name()
{
return name.getPath();
}

@Nullable
public Item.ToolMaterial getToolMetal()
{
@@ -94,4 +80,97 @@ public boolean isToolMetal()
TIER_V
}

public enum ItemType
{
UNSHAPED(false, 100, null), // Special case, because it's a pottery item
INGOT(false, 100, ItemIngot::new, true),
DOUBLE_INGOT(false, 200),
SCRAP(false, 100),
DUST(false, 100),
NUGGET(false, 10),
SHEET(false, 200, ItemSheet::new),
DOUBLE_SHEET(false, 400),
LAMP(false, 100, ItemLamp::new),

ANVIL(true, 1400, ItemAnvil::new),
TUYERE(true, 400),

PICK(true, 100, ItemMetalTool::new),
PICK_HEAD(true, 100, true),
SHOVEL(true, 100, ItemMetalTool::new),
SHOVEL_HEAD(true, 100, true),
AXE(true, 100, ItemMetalTool::new),
AXE_HEAD(true, 100, true),
HOE(true, 100, ItemMetalTool::new),
HOE_HEAD(true, 100, true),
CHISEL(true, 100, ItemMetalTool::new),
CHISEL_HEAD(true, 100, true),
SWORD(true, 200, ItemMetalTool::new),
SWORD_BLADE(true, 200, true),
MACE(true, 200, ItemMetalTool::new),
MACE_HEAD(true, 200, true),
SAW(true, 100, ItemMetalTool::new),
SAW_BLADE(true, 100, true),
JAVELIN(true, 100, ItemMetalTool::new), // todo: special class?
JAVELIN_HEAD(true, 100, true),
HAMMER(true, 100, ItemMetalTool::new),
HAMMER_HEAD(true, 100, true),
PROPICK(true, 100, ItemMetalTool::new),
PROPICK_HEAD(true, 100, true),
KNIFE(true, 100, ItemMetalTool::new),
KNIFE_BLADE(true, 100, true),
SCYTHE(true, 100, ItemMetalTool::new),
SCYTHE_BLADE(true, 100, true),

UNFINISHED_HELMET(true, 200),
HELMET(true, 400, ItemMetalArmor::new),
UNFINISHED_CHESTPLATE(true, 400),
CHESTPLATE(true, 800, ItemMetalArmor::new),
UNFINISHED_GREAVES(true, 400),
GREAVES(true, 600, ItemMetalArmor::new),
UNFINISHED_BOOTS(true, 200),
BOOTS(true, 200, ItemMetalArmor::new);

public static Item create(Metal metal, ItemType type)
{
return type.supplier.apply(metal, type);
}

public final boolean toolItem;
public final int smeltAmount;
public final boolean hasMold;
public final BiFunction<Metal, ItemType, Item> supplier;

ItemType(boolean toolItem, int smeltAmount, BiFunction<Metal, ItemType, Item> supplier, boolean hasMold)
{
this.toolItem = toolItem;
this.smeltAmount = smeltAmount;
this.supplier = supplier;
this.hasMold = hasMold;
}

ItemType(boolean toolItem, int smeltAmount, boolean hasMold)
{
this(toolItem, smeltAmount, ItemMetal::new, hasMold);
}

ItemType(boolean toolItem, int smeltAmount)
{
this(toolItem, smeltAmount, false);
}

ItemType(boolean toolItem, int smeltAmount, BiFunction<Metal, ItemType, Item> supplier)
{
this(toolItem, smeltAmount, supplier, false);
}

public boolean hasType(Metal metal)
{
if (supplier == null)
return false;
if (!metal.usable)
return this == ItemType.INGOT || this == ItemType.UNSHAPED;
return !this.toolItem || metal.getToolMetal() != null;
}
}
}
@@ -5,12 +5,15 @@

package net.dries007.tfc.api.types;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import net.minecraft.util.IStringSerializable;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.registries.IForgeRegistryEntry;

import net.dries007.tfc.api.registries.TFCRegistries;

/**
* todo: document API
*/
@@ -26,6 +29,16 @@ public Ore(ResourceLocation name, @Nullable Metal metal)
setRegistryName(name);
}

public Ore(ResourceLocation name, @Nonnull ResourceLocation metal)
{
this(name, TFCRegistries.METALS.getValue(metal));
}

public Ore(ResourceLocation name)
{
this(name, (Metal) null);
}

public boolean isGraded()
{
return graded;
@@ -5,13 +5,15 @@

package net.dries007.tfc.api.types;

import java.util.function.BiFunction;
import javax.annotation.Nonnull;

import net.minecraft.block.material.Material;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.registries.ForgeRegistry;
import net.minecraftforge.registries.IForgeRegistryEntry;

import net.dries007.tfc.api.registries.TFCRegistries;
import net.dries007.tfc.objects.blocks.stone.*;

import static net.dries007.tfc.api.types.Rock.FallingBlockType.*;

@@ -44,7 +46,7 @@ public RockCategory getRockCategory()

public enum Type
{
RAW(Material.ROCK, NO_FALL, false), // Todo: add collapsing when broken
RAW(Material.ROCK, NO_FALL, false, BlockRockRaw::new), // Todo: add collapsing when broken
SMOOTH(Material.ROCK, NO_FALL, false),
COBBLE(Material.ROCK, FALL_HORIZONTAL, false),
BRICKS(Material.ROCK, NO_FALL, false),
@@ -55,29 +57,43 @@ public RockCategory getRockCategory()
DRY_GRASS(Material.GRASS, FALL_HORIZONTAL, true),
CLAY(Material.GRASS, FALL_VERTICAL, false),
CLAY_GRASS(Material.GRASS, FALL_VERTICAL, true),
FARMLAND(Material.GROUND, FALL_VERTICAL, false),
PATH(Material.GROUND, FALL_VERTICAL, false);
FARMLAND(Material.GROUND, FALL_VERTICAL, false, BlockFarmlandTFC::new),
PATH(Material.GROUND, FALL_VERTICAL, false, BlockPathTFC::new);

public final Material material;
public final boolean isGrass;

private final FallingBlockType gravityType;
private final FallingBlockType gravType;
private final BiFunction<Type, Rock, BlockRockVariant> supplier;

Type(Material material, FallingBlockType gravityType, boolean isGrass)
Type(Material material, FallingBlockType gravType, boolean isGrass)
{
// If no fall + no grass, then normal. If it can fall, then eiether fallable or fallable + connected (since grass always falls)
this(material, gravType, isGrass, (gravType == NO_FALL && !isGrass) ? BlockRockVariant::new :
(isGrass ? BlockRockVariantConnected::new : BlockRockVariantFallable::new));
}

Type(Material material, FallingBlockType gravType, boolean isGrass, BiFunction<Type, Rock, BlockRockVariant> supplier)
{
this.material = material;
this.gravityType = gravityType;
this.gravType = gravType;
this.isGrass = isGrass;
this.supplier = supplier;
}

public boolean canFall()
{
return gravityType != NO_FALL;
return gravType != NO_FALL;
}

public boolean canFallHorizontal()
{
return gravityType == FALL_HORIZONTAL;
return gravType == FALL_HORIZONTAL;
}

public BlockRockVariant create(Rock rock)
{
return supplier.apply(this, rock);
}

public Type getNonGrassVersion()
@@ -109,7 +125,7 @@ public Type getGrassVersion(Type spreader)
}
}

protected enum FallingBlockType
public enum FallingBlockType
{
NO_FALL,
FALL_VERTICAL,
No changes.
@@ -30,12 +30,12 @@
import net.minecraftforge.fml.relauncher.SideOnly;

import net.dries007.tfc.api.types.Ore;
import net.dries007.tfc.api.types.Rock;
import net.dries007.tfc.client.render.TESRChestTFC;
import net.dries007.tfc.client.render.TESRIngotPile;
import net.dries007.tfc.client.render.TESRPitKiln;
import net.dries007.tfc.client.render.TESRWorldItem;
import net.dries007.tfc.objects.Gem;
import net.dries007.tfc.objects.RockType;
import net.dries007.tfc.objects.blocks.BlockSlabTFC;
import net.dries007.tfc.objects.blocks.BlocksTFC;
import net.dries007.tfc.objects.blocks.stone.BlockFarmlandTFC;
@@ -123,7 +123,7 @@ public static void registerModels(ModelRegistryEvent event)
ModelLoader.setCustomStateMapper(block.doubleSlab, new StateMap.Builder().ignore(BlockSlabTFC.VARIANT).build());
}

BlocksTFC.getAllBlockRockVariants().stream().filter(x -> x.type == RockType.FARMLAND).forEach(e ->
BlocksTFC.getAllBlockRockVariants().stream().filter(x -> x.type == Rock.Type.FARMLAND).forEach(e ->
ModelLoader.setCustomStateMapper(e, new StateMap.Builder().ignore(BlockFarmlandTFC.MOISTURE).build())
);

@@ -159,7 +159,7 @@ public static void registerColorHandlerBlocks(ColorHandlerEvent.Block event)
BlocksTFC.getAllBlockRockVariants().stream().filter(x -> x.type.isGrass).toArray(BlockRockVariant[]::new));

blockcolors.registerBlockColorHandler((state, worldIn, pos, tintIndex) -> BlockFarmlandTFC.TINT[state.getValue(BlockFarmlandTFC.MOISTURE)],
BlocksTFC.getAllBlockRockVariants().stream().filter(x -> x.type == RockType.FARMLAND).toArray(BlockRockVariant[]::new));
BlocksTFC.getAllBlockRockVariants().stream().filter(x -> x.type == Rock.Type.FARMLAND).toArray(BlockRockVariant[]::new));

blockcolors.registerBlockColorHandler((state, worldIn, pos, tintIndex) ->
worldIn != null && pos != null ? BiomeColorHelper.getGrassColorAtPos(worldIn, pos) : ColorizerGrass.getGrassColor(0.5D, 1.0D),
@@ -15,7 +15,7 @@
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.IGuiHandler;

import net.dries007.tfc.Constants;
import net.dries007.tfc.api.util.TFCConstants;
import net.dries007.tfc.client.gui.GuiContainerTFC;
import net.dries007.tfc.client.gui.GuiLiquidTransfer;
import net.dries007.tfc.objects.blocks.BlocksTFC;
@@ -35,7 +35,7 @@
public static final int SMALL_VESSEL_LIQUID = 2;
public static final int MOLD = 3;

private static final ResourceLocation SMALL_INVENTORY_BACKGROUND = new ResourceLocation(Constants.MOD_ID, "textures/gui/small_inventory.png");
private static final ResourceLocation SMALL_INVENTORY_BACKGROUND = new ResourceLocation(TFCConstants.MOD_ID, "textures/gui/small_inventory.png");

@Override
@Nullable
@@ -14,17 +14,11 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import net.dries007.tfc.api.util.TFCConstants;
import net.dries007.tfc.objects.blocks.BlocksTFC;

@SideOnly(Side.CLIENT)
public class GuiContainerTFC extends GuiContainer
{
private static final ResourceLocation BG_TEXTURE = new ResourceLocation(TFCConstants.MOD_ID, "textures/gui/log_pile.png");
private InventoryPlayer playerInv;
private final ResourceLocation background;
private final String translationKey;

protected InventoryPlayer playerInv;

public GuiContainerTFC(Container container, InventoryPlayer playerInv, ResourceLocation background, String titleKey)

0 comments on commit 1d1260f

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