generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed resource gen code, implemented new systems.
- Loading branch information
Dragonoidzero
committed
Jun 9, 2021
1 parent
6d8ce8c
commit 81b8f33
Showing
18 changed files
with
370 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 24 additions & 1 deletion
25
src/main/java/azzy/fabric/incubus_core/datagen/Metadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/azzy/fabric/incubus_core/systems/DefaultMaterials.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package azzy.fabric.incubus_core.systems; | ||
|
||
import azzy.fabric.incubus_core.IncubusCoreCommon; | ||
import net.minecraft.recipe.Ingredient; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraft.util.registry.Registry; | ||
|
||
@SuppressWarnings("unused") | ||
public class DefaultMaterials { | ||
|
||
public static void init() {} | ||
|
||
//public static final Material MYRCIL = register("myrcil", new Material(475, 0.03, 0, 0, 27500)); | ||
public static final Material IRON = register("iron", new Material(1250, 9.5, 5.75, 8.5, 2048, 512, 85000, new Identifier("c", "iron_ingots"))); | ||
public static final Material COPPER = register("copper", new Material(700, 21.5, 17.5, 5.5, 256, 128, 15000, new Identifier("c", "copper_ingots"))); | ||
public static final Material GOLD = register("gold", new Material(600, 15, 13, 1.5, 256, 64, 22500, new Identifier("c", "gold_ingots"))); | ||
public static final Material DIAMOND = register("diamond", new Material(250, 52.75, 35, 2.5, 16384, 128, 137000, new Identifier("c", "diamonds"))); | ||
public static final Material AMETHYST = register("amethyst", new Material(850, 13.5, 36.75, 9.5, 4096, 256, 47000, new Identifier("c", "amethyst"))); | ||
//public static final Material HSLA_STEEL = register("hsla_steel", new Material(1600, 0.25, 1024, 2048, 150000)); | ||
//public static final Material UNOBTANIUM = register("unobtanium", new Material(Double.POSITIVE_INFINITY, 1, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY)); | ||
|
||
private static Material register(String id, Material material) { | ||
return Registry.register(RegistryRegistry.MATERIAL, new Identifier(IncubusCoreCommon.MODID), material); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
src/main/java/azzy/fabric/incubus_core/systems/HeatHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package azzy.fabric.incubus_core.systems; | ||
|
||
import net.minecraft.world.biome.Biome; | ||
|
||
public class HeatHelper { | ||
|
||
public static double exchangeHeat(HeatMaterial medium, double tempA, double tempB, double exchangeArea) { | ||
return medium.transfer * exchangeArea * (tempA - tempB); | ||
} | ||
|
||
public static double playerAmbientHeat(HeatMaterial medium, double playerTemp, Biome biome, boolean night, boolean rain, int height) { | ||
return -exchangeHeat(medium, playerTemp, translateBiomeHeat(biome, night, rain, height), 4.5); | ||
} | ||
|
||
public static double translateBiomeHeat(Biome biome, boolean night, boolean rain, int height) { | ||
double temp; | ||
if (biome.getCategory() == Biome.Category.NETHER) { | ||
temp = (biome.getTemperature() + 2) * 31.25; | ||
} else if (biome.getCategory() == Biome.Category.THEEND) { | ||
temp = (biome.getTemperature() - 1.5) * 31.25; | ||
} else { | ||
temp = biome.getTemperature() * 31.25; | ||
} | ||
if(night) { | ||
if(biome.getCategory() == Biome.Category.DESERT || biome.getCategory() == Biome.Category.MESA) { | ||
temp -= temp * 0.75; | ||
} else if(biome.getPrecipitation() == Biome.Precipitation.SNOW) { | ||
if(biome.getCategory() == Biome.Category.ICY && temp < 0) | ||
temp += temp * 1.25; | ||
else | ||
temp -= 20; | ||
|
||
} else { | ||
temp -= (biome.getPrecipitation() == Biome.Precipitation.NONE) ? 12 : 4; | ||
} | ||
} | ||
if(rain) { | ||
temp -= biome.getPrecipitation() == Biome.Precipitation.SNOW || biome.getPrecipitation() == Biome.Precipitation.RAIN && height >= 100 ? 10 : 3; | ||
} | ||
return temp; | ||
} | ||
|
||
public enum HeatMaterial { | ||
NULL(0.0), | ||
AIR(0.026), | ||
BRICK(0.6), | ||
STEEL(50.2), | ||
WATER(0.6), | ||
GENERIC_FLUID(0.35), | ||
DIAMOND(335.2), | ||
GRANITE(1.73), | ||
BEDROCK(400); | ||
|
||
private final double transfer; | ||
|
||
HeatMaterial(double transfer) { | ||
this.transfer = transfer / 419.0; | ||
} | ||
|
||
public static HeatMaterial nullableValueOf(String name){ | ||
try { | ||
return HeatMaterial.valueOf(name); | ||
} catch (Exception ignored){ | ||
return NULL; | ||
} | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/azzy/fabric/incubus_core/systems/HeatIo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package azzy.fabric.incubus_core.systems; | ||
|
||
/** | ||
* An object that can hold and optionally take and provide heat energy. | ||
*/ | ||
public interface HeatIo { | ||
|
||
/** | ||
* Get the amount of heat stored. | ||
*/ | ||
double getTemperature(); | ||
|
||
/** | ||
* Return false if this object does not support insertion at all, meaning that insertion will always return the passed amount, | ||
* and insert-only cables should not connect. | ||
*/ | ||
default boolean supportsTransfer() { | ||
return false; | ||
} | ||
|
||
/** | ||
* Insert heat into this inventory, and return the amount of leftover heat. | ||
* | ||
* <p>If simulation is {@link Simulation#SIMULATE}, the result of the operation must be returned, but the underlying state of the object must not change. | ||
* | ||
* @param amount The amount of heat to insert | ||
* @param simulation If {@link Simulation#SIMULATE}, do not mutate this object | ||
* @return the amount of heat that could not be inserted | ||
*/ | ||
default double heat(double amount, Simulation simulation) { | ||
return amount; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/azzy/fabric/incubus_core/systems/Material.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package azzy.fabric.incubus_core.systems; | ||
|
||
import azzy.fabric.incubus_core.util.TagSuperset; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.recipe.Ingredient; | ||
import net.minecraft.tag.ServerTagManagerHolder; | ||
import net.minecraft.tag.Tag; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraft.util.registry.DefaultedRegistry; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class Material { | ||
|
||
public final TagSuperset<Item> tags; | ||
public final double maxTemperature, heatConductivity; | ||
public final double electricalConductivity, resistance; | ||
public final long maxRads, maxNm; | ||
public final double maxPressure; | ||
|
||
public Material(double maxTemperature, double heatConductivity, double electricalConductivity, double resistance, long maxRads, long maxNm, double maxPressure, Identifier ... components) { | ||
this.tags = new TagSuperset<>(DefaultedRegistry.ITEM_KEY, components); | ||
this.maxTemperature = maxTemperature; | ||
this.heatConductivity = heatConductivity / 100; | ||
this.electricalConductivity = electricalConductivity / 100; | ||
this.resistance = resistance / 100; | ||
this.maxRads = maxRads; | ||
this.maxNm = maxNm; | ||
this.maxPressure = maxPressure; | ||
} | ||
} |
Oops, something went wrong.