Skip to content
Permalink
Browse files

Replaced all usages of objects.Metal with api.types.Metal. Added flui…

…ds for each metal for future compatibility - unfinished. Note: somebody should look at fluids: BlockFluidFinite does weird things when placed. Should probably be replaced with BlockFluidClassic everywhere for compatibility reasons.
  • Loading branch information...
alcatrazEscapee committed Aug 19, 2018
1 parent 4b81ee8 commit 1fbbb0ea4aeef804c56e943892f1b3aa494f9ac5
Showing with 391 additions and 450 deletions.
  1. +1 −3 src/main/java/net/dries007/tfc/TerraFirmaCraft.java
  2. +18 −8 src/main/java/net/dries007/tfc/api/types/Metal.java
  3. +0 −103 src/main/java/net/dries007/tfc/api/types/MetalEnum.java
  4. +13 −4 src/main/java/net/dries007/tfc/api/types/Ore.java
  5. +11 −5 src/main/java/net/dries007/tfc/api/types/TFCRegistries.java
  6. +2 −2 src/main/java/net/dries007/tfc/client/render/TESRIngotPile.java
  7. +23 −11 src/main/java/net/dries007/tfc/objects/MetalType.java
  8. +10 −9 src/main/java/net/dries007/tfc/objects/blocks/BlocksTFC.java
  9. +8 −7 src/main/java/net/dries007/tfc/objects/blocks/metal/BlockAnvilTFC.java
  10. +2 −2 src/main/java/net/dries007/tfc/objects/blocks/metal/BlockIngotPile.java
  11. +8 −7 src/main/java/net/dries007/tfc/objects/blocks/metal/BlockSheet.java
  12. +63 −58 src/main/java/net/dries007/tfc/objects/fluids/FluidsTFC.java
  13. +22 −26 src/main/java/net/dries007/tfc/objects/items/ItemsTFC.java
  14. +16 −9 src/main/java/net/dries007/tfc/objects/items/ceramics/ItemFilledMold.java
  15. +2 −2 src/main/java/net/dries007/tfc/objects/items/ceramics/ItemPottery.java
  16. +2 −2 src/main/java/net/dries007/tfc/objects/items/ceramics/ItemUnfiredPottery.java
  17. +2 −2 src/main/java/net/dries007/tfc/objects/items/metal/ItemAnvil.java
  18. +2 −2 src/main/java/net/dries007/tfc/objects/items/metal/ItemIngot.java
  19. +2 −2 src/main/java/net/dries007/tfc/objects/items/metal/ItemLamp.java
  20. +16 −10 src/main/java/net/dries007/tfc/objects/items/metal/ItemMetal.java
  21. +2 −2 src/main/java/net/dries007/tfc/objects/items/metal/ItemMetalArmor.java
  22. +2 −2 src/main/java/net/dries007/tfc/objects/items/metal/ItemMetalTool.java
  23. +4 −4 src/main/java/net/dries007/tfc/objects/items/metal/ItemOreTFC.java
  24. +2 −2 src/main/java/net/dries007/tfc/objects/items/metal/ItemSheet.java
  25. +4 −4 src/main/java/net/dries007/tfc/objects/items/metal/ItemSmallOre.java
  26. +6 −6 src/main/java/net/dries007/tfc/objects/te/TEIngotPile.java
  27. +2 −2 src/main/java/net/dries007/tfc/objects/te/TEPitKiln.java
  28. +114 −29 src/main/java/net/dries007/tfc/types/DefaultMetals.java
  29. +0 −98 src/main/java/net/dries007/tfc/types/DefaultOres.java
  30. +5 −0 src/main/java/net/dries007/tfc/util/Helpers.java
  31. +5 −5 src/main/java/net/dries007/tfc/util/IFireable.java
  32. +4 −4 src/main/java/net/dries007/tfc/util/IMetalObject.java
  33. +18 −18 src/main/java/net/dries007/tfc/util/OreDictionaryHelper.java
@@ -26,7 +26,6 @@
import net.dries007.tfc.cmd.StripWorldCommand;
import net.dries007.tfc.cmd.TreeGenCommand;
import net.dries007.tfc.objects.entity.EntitiesTFC;
import net.dries007.tfc.objects.fluids.FluidsTFC;
import net.dries007.tfc.objects.items.ItemsTFC;
import net.dries007.tfc.util.OreDictionaryHelper;
import net.dries007.tfc.util.OreSpawnData;
@@ -104,11 +103,10 @@ public void preInit(FMLPreInitializationEvent event)
CalenderTFC.reload();

EntitiesTFC.preInit();
FluidsTFC.preInit();

OreSpawnData.preInit(event.getModConfigurationDirectory());
CapabilityItemSize.preInit();
CapabilityItemHeat.preInit();

MinecraftForge.EVENT_BUS.register(new CommonEventHandler());

if (event.getSide().isClient()) ClientEvents.preInit();
@@ -32,35 +32,39 @@ public static Metal get(String name)
return values().stream().filter(x -> x.name().equals(name)).findFirst().orElse(null);
}

public final boolean usable;
public final Tier tier;
public final double specificHeat;
public final int meltTemp;
public final Item.ToolMaterial toolMetal;
public final boolean usable;
public final int color;

private final ResourceLocation name;

public Metal(ResourceLocation name, Tier tier, double sh, int melt)
public Metal(ResourceLocation name, Tier tier, double sh, int melt, int color)
{
this(name, tier, true, sh, melt, null);
this(name, tier, true, sh, melt, color, null);
}

public Metal(ResourceLocation name, Tier tier, double sh, int melt, Item.ToolMaterial toolMetal)
public Metal(ResourceLocation name, Tier tier, double sh, int melt, int color, Item.ToolMaterial toolMetal)
{
this(name, tier, true, sh, melt, toolMetal);
this(name, tier, true, sh, melt, color, toolMetal);
}

public Metal(ResourceLocation name, Tier tier, boolean usable, double sh, int melt)
public Metal(ResourceLocation name, Tier tier, boolean usable, double sh, int melt, int color)
{
this(name, tier, usable, sh, melt, null);
this(name, tier, usable, sh, melt, color, null);
}

public Metal(ResourceLocation name, Tier tier, boolean usable, double sh, int melt, Item.ToolMaterial toolMetal)
public Metal(ResourceLocation name, Tier tier, boolean usable, double sh, int melt, int color, Item.ToolMaterial toolMetal)
{
this.usable = usable;
this.tier = tier;
this.specificHeat = sh;
this.meltTemp = melt;
this.toolMetal = toolMetal;
this.color = color;

this.name = name;
setRegistryName(name);
}
@@ -70,6 +74,12 @@ public String name()
return name.getPath();
}

@Nullable
public Item.ToolMaterial getToolMetal()
{
return toolMetal;
}

public enum Tier
{
TIER_I,

This file was deleted.

@@ -34,15 +34,24 @@ public static Ore get(String name)
private final ResourceLocation name;

public final boolean graded;
public final MetalEnum metal;
public final Metal metal;

public Ore(ResourceLocation name, @Nullable MetalEnum metal)
public Ore(ResourceLocation name, @Nonnull ResourceLocation metalLoc)
{
this.graded = (metal != null);
this.metal = metal;
this.name = name;
setRegistryName(name);

this.metal = TFCRegistries.getMetals().getValue(metalLoc);
this.graded = metal != null;
}

public Ore(ResourceLocation name)
{
this.name = name;
setRegistryName(name);

this.metal = null;
this.graded = false;
}

@Nonnull
@@ -6,7 +6,7 @@

package net.dries007.tfc.api.types;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

import net.minecraft.block.Block;
@@ -30,12 +30,12 @@
static final String MOD_ID = "tfc"; // This is here to avoid a import statement.

private static final ResourceLocation ROCK_TYPE = new ResourceLocation(MOD_ID, "rock_type");
private static final ResourceLocation METAL = new ResourceLocation(MOD_ID, "metal");
private static final ResourceLocation ROCK = new ResourceLocation(MOD_ID, "rock");
private static final ResourceLocation ORE = new ResourceLocation(MOD_ID, "ore");
private static final ResourceLocation TREE = new ResourceLocation(MOD_ID, "tree");
private static final ResourceLocation METAL = new ResourceLocation(MOD_ID, "metal");

private static final Map<ResourceLocation, IForgeRegistry<?>> preBlockRegistries = new HashMap<>();
private static final Map<ResourceLocation, IForgeRegistry<?>> preBlockRegistries = new LinkedHashMap<>();

private static IForgeRegistry<RockCategory> rockCategoryRegistry;
private static IForgeRegistry<Rock> rockRegistry;
@@ -47,10 +47,10 @@
public static void onNewRegistryEvent(RegistryEvent.NewRegistry event)
{
rockCategoryRegistry = newRegistry(ROCK_TYPE, RockCategory.class, true);
metalRegistry = newRegistry(METAL, Metal.class, true);
rockRegistry = newRegistry(ROCK, Rock.class, true);
oreRegistry = newRegistry(ORE, Ore.class, true);
treeRegistry = newRegistry(TREE, Tree.class, true);
metalRegistry = newRegistry(METAL, Metal.class, true);
}

/**
@@ -59,7 +59,13 @@ public static void onNewRegistryEvent(RegistryEvent.NewRegistry event)
@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void onRegisterBlock(RegistryEvent.Register<Block> event)
{
preBlockRegistries.forEach((e, r) -> MinecraftForge.EVENT_BUS.post(new TFCRegistries.RegisterPreBlock<>(e, r)));
// This needs to be done in a specific order
MinecraftForge.EVENT_BUS.post(new TFCRegistries.RegisterPreBlock<>(ROCK_TYPE, rockCategoryRegistry)); // Before Rock
MinecraftForge.EVENT_BUS.post(new TFCRegistries.RegisterPreBlock<>(METAL, metalRegistry)); // Before Ore

MinecraftForge.EVENT_BUS.post(new TFCRegistries.RegisterPreBlock<>(ROCK, rockRegistry));
MinecraftForge.EVENT_BUS.post(new TFCRegistries.RegisterPreBlock<>(ORE, oreRegistry));
MinecraftForge.EVENT_BUS.post(new TFCRegistries.RegisterPreBlock<>(TREE, treeRegistry));
}

static IForgeRegistry<Rock> getRocks()
@@ -11,7 +11,7 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import net.dries007.tfc.api.types.MetalEnum;
import net.dries007.tfc.api.types.Metal;
import net.dries007.tfc.client.model.ModelIngotPile;
import net.dries007.tfc.objects.te.TEIngotPile;

@@ -33,7 +33,7 @@ public void render(TEIngotPile te, double x, double y, double z, float partialTi
{
GlStateManager.color(1, 1, 1, 1);

MetalEnum metal = te.getMetal();
Metal metal = te.getMetal();
int count = te.getCount();
this.bindTexture(new ResourceLocation(MOD_ID, "textures/blocks/metal/" + metal.name() + ".png"));
GlStateManager.pushMatrix();
@@ -10,7 +10,7 @@

import net.minecraft.item.Item;

import net.dries007.tfc.api.types.MetalEnum;
import net.dries007.tfc.api.types.Metal;
import net.dries007.tfc.objects.items.metal.*;

public enum MetalType
@@ -67,24 +67,22 @@
public final boolean toolItem;
public final int smeltAmount;
public final boolean hasMold;
/**
* Internal use only.
*/
public final BiFunction<MetalEnum, MetalType, Item> supplier;

MetalType(boolean toolItem, int smeltAmount, BiFunction<MetalEnum, MetalType, Item> supplier, boolean hasMold)
public static Item create(Metal metal, MetalType type)
{
return type.supplier.apply(metal, type);
}

public final BiFunction<Metal, MetalType, Item> supplier;

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

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

MetalType(boolean toolItem, int smeltAmount, boolean hasMold)
{
this(toolItem, smeltAmount, ItemMetal::new, hasMold);
@@ -94,4 +92,18 @@
{
this(toolItem, smeltAmount, false);
}

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

public boolean hasType(Metal metal)
{
if (supplier == null)
return false;
if (!metal.usable)
return this == MetalType.INGOT || this == MetalType.UNSHAPED;
return !this.toolItem || metal.getToolMetal() != null;
}
}

0 comments on commit 1fbbb0e

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