heaps of misc changes

This commit is contained in:
Ellpeck 2020-01-24 17:05:41 +01:00
parent 3077a0869a
commit 3ff0aed4ad
90 changed files with 728 additions and 516 deletions

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,17 +2,125 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{
"type": "minecraft:alternatives",
"children": [
{
"type": "minecraft:item",
"conditions": [
{
"condition": "minecraft:alternative",
"terms": [
{
"condition": "minecraft:match_tool",
"predicate": {
"item": "minecraft:shears"
}
},
{
"condition": "minecraft:match_tool",
"predicate": {
"enchantments": [
{
"enchantment": "minecraft:silk_touch",
"levels": {
"min": 1
}
}
]
}
}
]
}
],
"name": "naturesaura:ancient_leaves"
},
{
"type": "minecraft:item",
"conditions": [
{
"condition": "minecraft:survives_explosion"
},
{
"condition": "minecraft:table_bonus",
"enchantment": "minecraft:fortune",
"chances": [
0.05,
0.0625,
0.083333336,
0.1
]
}
],
"name": "naturesaura:ancient_sapling"
}
]
}
]
},
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "naturesaura:ancient_leaves"
"conditions": [
{
"condition": "minecraft:table_bonus",
"enchantment": "minecraft:fortune",
"chances": [
0.02,
0.022222223,
0.025,
0.033333335,
0.1
]
}
],
"functions": [
{
"function": "minecraft:set_count",
"count": {
"min": 1.0,
"max": 2.0,
"type": "minecraft:uniform"
}
},
{
"function": "minecraft:explosion_decay"
}
],
"name": "minecraft:stick"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
"condition": "minecraft:inverted",
"term": {
"condition": "minecraft:alternative",
"terms": [
{
"condition": "minecraft:match_tool",
"predicate": {
"item": "minecraft:shears"
}
},
{
"condition": "minecraft:match_tool",
"predicate": {
"enchantments": [
{
"enchantment": "minecraft:silk_touch",
"levels": {
"min": 1
}
}
]
}
}
]
}
}
]
}

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{
@ -12,7 +11,17 @@
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
"condition": "minecraft:match_tool",
"predicate": {
"enchantments": [
{
"enchantment": "minecraft:silk_touch",
"levels": {
"min": 1
}
}
]
}
}
]
}

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,17 +2,29 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "naturesaura:golden_leaves"
"conditions": [
{
"condition": "minecraft:survives_explosion"
},
{
"condition": "minecraft:block_state_property",
"block": "naturesaura:golden_leaves",
"properties": {
"stage": "3"
}
}
],
"name": "naturesaura:gold_leaf"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
"condition": "minecraft:random_chance",
"chance": 0.75
}
]
}

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -2,7 +2,6 @@
"type": "minecraft:block",
"pools": [
{
"name": "main",
"rolls": 1,
"entries": [
{

View file

@ -6,153 +6,211 @@ import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.api.recipes.WeightedOre;
import de.ellpeck.naturesaura.chunk.effect.OreSpawnEffect;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityType;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.Tag;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.registries.ForgeRegistries;
import java.util.Collections;
import java.util.List;
// TODO configs
//@Config(modid = NaturesAura.MOD_ID, category = "")
public final class ModConfig {
public static General general = new General();
public static Features enabledFeatures = new Features();
public static Client client = new Client();
public static ModConfig instance;
public ForgeConfigSpec.ConfigValue<List<? extends String>> additionalBotanistPickaxeConversions;
public ForgeConfigSpec.ConfigValue<List<? extends String>> additionalFlowers;
public ForgeConfigSpec.ConfigValue<List<? extends String>> auraTypeOverrides;
public ForgeConfigSpec.ConfigValue<List<? extends String>> additionalOres;
public ForgeConfigSpec.ConfigValue<List<? extends String>> oreExceptions;
public ForgeConfigSpec.ConfigValue<List<? extends String>> additionalProjectiles;
public ForgeConfigSpec.ConfigValue<Integer> fieldCreatorRange;
public ForgeConfigSpec.ConfigValue<Double> auraToRFRatio;
public static class General {
public ForgeConfigSpec.ConfigValue<Boolean> rfConverter;
public ForgeConfigSpec.ConfigValue<Boolean> chunkLoader;
public ForgeConfigSpec.ConfigValue<Boolean> grassDieEffect;
public ForgeConfigSpec.ConfigValue<Boolean> plantBoostEffect;
public ForgeConfigSpec.ConfigValue<Boolean> cacheRechargeEffect;
public ForgeConfigSpec.ConfigValue<Boolean> explosionEffect;
public ForgeConfigSpec.ConfigValue<Boolean> breathlessEffect;
public ForgeConfigSpec.ConfigValue<Boolean> animalEffect;
public ForgeConfigSpec.ConfigValue<Boolean> oreEffect;
//@Comment("Additional conversion recipes for the Botanist's Pickaxe right click function. Each entry needs to be formatted as modid:input_block[prop1=value1,...]->modid:output_block[prop1=value1,...] where block state properties are optional")
public String[] additionalBotanistPickaxeConversions = new String[0];
public ForgeConfigSpec.ConfigValue<Double> particleAmount;
public ForgeConfigSpec.ConfigValue<Boolean> respectVanillaParticleSettings;
public ForgeConfigSpec.ConfigValue<Double> excessParticleAmount;
public ForgeConfigSpec.ConfigValue<Integer> auraBarLocation;
public ForgeConfigSpec.ConfigValue<Boolean> debugText;
public ForgeConfigSpec.ConfigValue<Boolean> debugWorld;
//@Comment("Additional blocks that several mechanics identify as flowers. Each entry needs to be formatted as modid:block[prop1=value1,...] where block state properties are optional")
public String[] additionalFlowers = new String[0];
public ModConfig(ForgeConfigSpec.Builder builder) {
builder.push("general");
this.additionalBotanistPickaxeConversions = builder
.comment("Additional conversion recipes for the Botanist's Pickaxe right click function. Each entry needs to be formatted as modid:input_block[prop1=value1,...]->modid:output_block[prop1=value1,...] where block state properties are optional")
.translation("config." + NaturesAura.MOD_ID + ".additionalBotanistPickaxeConversions")
.defineList("additionalBotanistPickaxeConversions", Collections.emptyList(), s -> true);
this.additionalFlowers = builder
.comment("Additional blocks that several mechanics identify as flowers. Each entry needs to be formatted as modid:block[prop1=value1,...] where block state properties are optional")
.translation("config." + NaturesAura.MOD_ID + ".additionalFlowers")
.defineList("additionalFlowers", Collections.emptyList(), s -> true);
this.auraTypeOverrides = builder
.comment("Additional dimensions that map to Aura types that should be present in them. This is useful if you have a modpack with custom dimensions that should have Aura act similarly to an existing dimension in them. Each entry needs to be formatted as dimension_name->aura_type, where aura_type can be any of naturesaura:overworld, naturesaura:nether and naturesaura:end.")
.translation("config." + NaturesAura.MOD_ID + ".auraTypeOverrides")
.defineList("auraTypeOverrides", Collections.emptyList(), s -> true);
this.additionalOres = builder
.comment("Additional blocks that are recognized as generatable ores for the passive ore generation effect. Each entry needs to be formatted as oredictEntry:oreWeight:dimension where a higher weight makes the ore more likely to spawn with 5000 being the weight of coal, the default ore with the highest weight, and dimension being any of overworld and nether")
.translation("config." + NaturesAura.MOD_ID + ".additionalOres")
.defineList("additionalOres", Collections.emptyList(), s -> true);
this.oreExceptions = builder
.comment("Blocks that are exempt from being recognized as generatable ores for the passive ore generation effect. Each entry needs to be formatted as modid:block[prop1=value1,...] where block state properties are optional")
.translation("config." + NaturesAura.MOD_ID + ".oreExceptions")
.defineList("oreExceptions", Collections.emptyList(), s -> true);
this.additionalProjectiles = builder
.comment("Additional projectile types that are allowed to be consumed by the projectile generator. Each entry needs to be formatted as entity_registry_name->aura_amount")
.translation("config." + NaturesAura.MOD_ID + ".additionalProjectiles")
.defineList("additionalProjectiles", Collections.emptyList(), s -> true);
this.fieldCreatorRange = builder
.comment("The amount of blocks that can be between two Aura Field Creators for them to be connectable and work together")
.translation("config." + NaturesAura.MOD_ID + ".fieldCreatorRange")
.define("fieldCreatorRange", 10);
this.auraToRFRatio = builder
.comment("The Aura to RF ratio used by the RF converter, read as aura*ratio = rf")
.translation("config." + NaturesAura.MOD_ID + ".auraToRFRatio")
.define("auraToRFRatio", 0.05);
builder.pop();
//@Comment("Additional dimensions that map to Aura types that should be present in them. This is useful if you have a modpack with custom dimensions that should have Aura act similarly to an existing dimension in them. Each entry needs to be formatted as dimension_name->aura_type, where aura_type can be any of naturesaura:overworld, naturesaura:nether and naturesaura:end.")
public String[] auraTypeOverrides = new String[0];
builder.push("features");
this.rfConverter = builder
.comment("If the RF converter block should be enabled")
.translation("config." + NaturesAura.MOD_ID + ".rfConverter")
.define("rfConverter", true);
this.chunkLoader = builder
.comment("If the chunk loader block should be enabled")
.translation("config." + NaturesAura.MOD_ID + ".chunkLoader")
.define("chunkLoader", true);
this.grassDieEffect = builder
.comment("If the Aura Imbalance effect of grass and trees dying in the area if the Aura levels are too low should occur")
.translation("config." + NaturesAura.MOD_ID + ".grassDieEffect")
.define("grassDieEffect", true);
this.plantBoostEffect = builder
.comment("If the Aura Imbalance effect of plant growth being boosted if the Aura levels are high enough should occur")
.translation("config." + NaturesAura.MOD_ID + ".plantBoostEffect")
.define("plantBoostEffect", true);
this.cacheRechargeEffect = builder
.comment("If the Aura Imbalance effect of aura containers in players' inventories being filled if the Aura levels are high enough should occur")
.translation("config." + NaturesAura.MOD_ID + ".cacheRechargeEffect")
.define("cacheRechargeEffect", true);
this.explosionEffect = builder
.comment("If the Aura Imbalance effect of explosions happening randomly if Aura levels are too low should occur")
.translation("config." + NaturesAura.MOD_ID + ".explosionEffect")
.define("explosionEffect", true);
this.breathlessEffect = builder
.comment("If the Aura Imbalance effect of breathlessness if Aura levels are too low should occur")
.translation("config." + NaturesAura.MOD_ID + ".breathlessEffect")
.define("breathlessEffect", true);
this.animalEffect = builder
.comment("If the Aura Imbalance effect of farm animals being affected in positive ways if Aura levels are too high should occur")
.translation("config." + NaturesAura.MOD_ID + ".animalEffect")
.define("animalEffect", true);
this.oreEffect = builder
.comment("If the Aura Imbalance effect of ores spawning in the area if Aura levels are too high should occur")
.translation("config." + NaturesAura.MOD_ID + ".oreEffect")
.define("oreEffect", true);
builder.pop();
//@Comment("Additional blocks that are recognized as generatable ores for the passive ore generation effect. Each entry needs to be formatted as oredictEntry:oreWeight:dimension where a higher weight makes the ore more likely to spawn with 5000 being the weight of coal, the default ore with the highest weight, and dimension being any of overworld and nether")
public String[] additionalOres = new String[0];
//@Comment("Blocks that are exempt from being recognized as generatable ores for the passive ore generation effect. Each entry needs to be formatted as modid:block[prop1=value1,...] where block state properties are optional")
public String[] oreExceptions = new String[0];
//@Comment("Additional projectile types that are allowed to be consumed by the projectile generator. Each entry needs to be formatted as entity_registry_name->aura_amount")
public String[] additionalProjectiles = new String[0];
//@Comment("The amount of blocks that can be between two Aura Field Creators for them to be connectable and work together")
public int fieldCreatorRange = 10;
//@Comment("The Aura to RF ratio used by the RF converter, read as aura*ratio = rf")
public float auraToRFRatio = 0.05F;
builder.push("client");
this.particleAmount = builder
.comment("The percentage of particles that should be displayed, where 1 is 100% and 0 is 0%")
.translation("config." + NaturesAura.MOD_ID + ".particleAmount")
.defineInRange("particleAmount", 1D, 0, 1);
this.respectVanillaParticleSettings = builder
.comment("If particle spawning should respect the particle setting in Minecraft's video settings screen")
.translation("config." + NaturesAura.MOD_ID + ".respectVanillaParticleSettings")
.define("respectVanillaParticleSettings", false);
this.excessParticleAmount = builder
.comment("The percentage of particles that should spawn when there is an excess amount of Aura in the environment, where 1 is 100% and 0 is 0%")
.translation("config." + NaturesAura.MOD_ID + ".excessParticleAmount")
.define("excessParticleAmount", 1D);
this.auraBarLocation = builder
.comment("The location of the aura bar, where 0 is top left, 1 is top right, 2 is bottom left and 3 is bottom right")
.translation("config." + NaturesAura.MOD_ID + ".auraBarLocation")
.defineInRange("auraBarLocation", 0, 0, 3);
this.debugText = builder
.comment("If debug information about Aura around the player should be displayed in the F3 debug menu if the player is in creative mode")
.translation("config." + NaturesAura.MOD_ID + ".debugText")
.define("debugText", true);
this.debugWorld = builder
.comment("If, when the F3 debug menu is open and the player is in creative mode, every Aura spot should be highlighted in the world for debug purposes")
.translation("config." + NaturesAura.MOD_ID + ".debugWorld")
.define("debugWorld", false);
builder.pop();
}
public static class Features {
//@Comment("If using Dragon's Breath in a Brewing Stand should not cause a glass bottle to appear")
public boolean removeDragonBreathContainerItem = true;
//@Comment("If the RF converter block should be enabled")
public boolean rfConverter = true;
//@Comment("If the chunk loader block should be enabled")
public boolean chunkLoader = true;
//@Comment("If the Aura Imbalance effect of grass and trees dying in the area if the Aura levels are too low should occur")
public boolean grassDieEffect = true;
//@Comment("If the Aura Imbalance effect of plant growth being boosted if the Aura levels are high enough should occur")
public boolean plantBoostEffect = true;
//@Comment("If the Aura Imbalance effect of aura containers in players' inventories being filled if the Aura levels are high enough should occur")
public boolean cacheRechargeEffect = true;
//@Comment("If the Aura Imbalance effect of explosions happening randomly if Aura levels are too low should occur")
public boolean explosionEffect = true;
//@Comment("If the Aura Imbalance effect of breathlessness if Aura levels are too low should occur")
public boolean breathlessEffect = true;
//@Comment("If the Aura Imbalance effect of farm animals being affected in positive ways if Aura levels are too high should occur")
public boolean animalEffect = true;
//@Comment("If the Aura Imbalance effect of ores spawning in the area if Aura levels are too high should occur")
public boolean oreEffect = true;
}
public static class Client {
//@Comment("The percentage of particles that should be displayed, where 1 is 100% and 0 is 0%")
//@RangeDouble(min = 0, max = 1)
public double particleAmount = 1;
//@Comment("If particle spawning should respect the particle setting in Minecraft's video settings screen")
public boolean respectVanillaParticleSettings = true;
//@Comment("The percentage of particles that should spawn when there is an excess amount of Aura in the environment, where 1 is 100% and 0 is 0%")
public double excessParticleAmount = 1;
//@Comment("The location of the aura bar, where 0 is top left, 1 is top right, 2 is bottom left and 3 is bottom right")
//@Config.RangeInt(min = 0, max = 3)
public int auraBarLocation = 0;
//@Comment("If debug information about Aura around the player should be displayed in the F3 debug menu if the player is in creative mode")
public boolean debugText = true;
//@Comment("If, when the F3 debug menu is open and the player is in creative mode, every Aura spot should be highlighted in the world for debug purposes")
public boolean debugWorld = true;
}
public static void initOrReload(boolean reload) {
if (!reload) {
try {
for (String s : general.additionalBotanistPickaxeConversions) {
String[] split = s.split("->");
NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.put(
Helper.getStateFromString(split[0]),
Helper.getStateFromString(split[1]));
}
} catch (Exception e) {
NaturesAura.LOGGER.warn("Error parsing additionalBotanistPickaxeConversions", e);
public void apply() {
try {
for (String s : this.additionalBotanistPickaxeConversions.get()) {
String[] split = s.split("->");
NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.put(
Helper.getStateFromString(split[0]),
Helper.getStateFromString(split[1]));
}
} catch (Exception e) {
NaturesAura.LOGGER.warn("Error parsing additionalBotanistPickaxeConversions", e);
}
try {
for (String s : general.additionalFlowers)
NaturesAuraAPI.FLOWERS.add(Helper.getStateFromString(s));
} catch (Exception e) {
NaturesAura.LOGGER.warn("Error parsing additionalFlowers", e);
}
try {
for (String s : this.additionalFlowers.get())
NaturesAuraAPI.FLOWERS.add(Helper.getStateFromString(s));
} catch (Exception e) {
NaturesAura.LOGGER.warn("Error parsing additionalFlowers", e);
}
try {
for (String s : general.auraTypeOverrides) {
String[] split = s.split("->");
IAuraType type = NaturesAuraAPI.AURA_TYPES.get(new ResourceLocation(split[1]));
if (type instanceof BasicAuraType)
((BasicAuraType) type).addDimensionType(DimensionType.byName(new ResourceLocation(split[0])));
}
} catch (Exception e) {
NaturesAura.LOGGER.warn("Error parsing auraTypeOverrides", e);
try {
for (String s : this.auraTypeOverrides.get()) {
String[] split = s.split("->");
IAuraType type = NaturesAuraAPI.AURA_TYPES.get(new ResourceLocation(split[1]));
if (type instanceof BasicAuraType)
((BasicAuraType) type).addDimensionType(DimensionType.byName(new ResourceLocation(split[0])));
}
} catch (Exception e) {
NaturesAura.LOGGER.warn("Error parsing auraTypeOverrides", e);
}
try {
for (String s : general.additionalOres) {
String[] split = s.split(":");
Tag<Block> tag = BlockTags.getCollection().get(new ResourceLocation(split[0]));
WeightedOre ore = new WeightedOre(tag, Integer.parseInt(split[1]));
String dimension = split[2];
if ("nether".equalsIgnoreCase(dimension))
NaturesAuraAPI.NETHER_ORES.add(ore);
else
NaturesAuraAPI.OVERWORLD_ORES.add(ore);
}
} catch (Exception e) {
NaturesAura.LOGGER.warn("Error parsing additionalOres", e);
try {
for (String s : this.additionalOres.get()) {
String[] split = s.split(":");
Tag<Block> tag = BlockTags.getCollection().get(new ResourceLocation(split[0]));
WeightedOre ore = new WeightedOre(tag, Integer.parseInt(split[1]));
String dimension = split[2];
if ("nether".equalsIgnoreCase(dimension))
NaturesAuraAPI.NETHER_ORES.add(ore);
else
NaturesAuraAPI.OVERWORLD_ORES.add(ore);
}
} catch (Exception e) {
NaturesAura.LOGGER.warn("Error parsing additionalOres", e);
}
try {
for (String s : general.oreExceptions)
OreSpawnEffect.SPAWN_EXCEPTIONS.add(Helper.getStateFromString(s));
} catch (Exception e) {
NaturesAura.LOGGER.warn("Error parsing oreExceptions", e);
}
try {
for (String s : this.oreExceptions.get())
OreSpawnEffect.SPAWN_EXCEPTIONS.add(Helper.getStateFromString(s));
} catch (Exception e) {
NaturesAura.LOGGER.warn("Error parsing oreExceptions", e);
}
try {
for (String s : general.additionalProjectiles) {
String[] split = s.split("->");
ResourceLocation name = new ResourceLocation(split[0]);
int amount = Integer.parseInt(split[1]);
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(name, amount);
}
} catch (Exception e) {
NaturesAura.LOGGER.warn("Error parsing additionalProjectiles", e);
try {
for (String s : this.additionalProjectiles.get()) {
String[] split = s.split("->");
ResourceLocation name = new ResourceLocation(split[0]);
EntityType type = ForgeRegistries.ENTITIES.getValue(name);
int amount = Integer.parseInt(split[1]);
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(type, amount);
}
} catch (Exception e) {
NaturesAura.LOGGER.warn("Error parsing additionalProjectiles", e);
}
}
}

View file

@ -7,10 +7,8 @@ import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
import de.ellpeck.naturesaura.api.misc.IWorldData;
import de.ellpeck.naturesaura.blocks.ModBlocks;
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.chunk.effect.DrainSpotEffects;
import de.ellpeck.naturesaura.compat.Compat;
import de.ellpeck.naturesaura.entities.ModEntities;
import de.ellpeck.naturesaura.events.CommonEvents;
import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.packet.PacketHandler;
@ -23,14 +21,14 @@ import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.ForgeRegistries;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -47,9 +45,11 @@ public final class NaturesAura {
public NaturesAura() {
instance = this;
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();
eventBus.addListener(this::setup);
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
ModConfig.instance = new ModConfig(builder);
ModLoadingContext.get().registerConfig(net.minecraftforge.fml.config.ModConfig.Type.COMMON, builder.build());
}
public static IProxy proxy = DistExecutor.runForDist(() -> ClientProxy::new, () -> ServerProxy::new);
@ -66,12 +66,14 @@ public final class NaturesAura {
}
public void setup(FMLCommonSetupEvent event) {
ModConfig.instance.apply();
this.preInit(event);
this.init(event);
this.postInit(event);
}
public void preInit(FMLCommonSetupEvent event) {
private void preInit(FMLCommonSetupEvent event) {
NaturesAuraAPI.setInstance(new InternalHooks());
Helper.registerCap(IAuraContainer.class);
Helper.registerCap(IAuraRecharge.class);
@ -91,8 +93,7 @@ public final class NaturesAura {
proxy.preInit(event);
}
public void init(FMLCommonSetupEvent event) {
ModConfig.initOrReload(false);
private void init(FMLCommonSetupEvent event) {
ModRecipes.init();
ModRegistry.init();
DrainSpotEffects.init();
@ -100,13 +101,9 @@ public final class NaturesAura {
proxy.init(event);
}
public void postInit(FMLCommonSetupEvent event) {
private void postInit(FMLCommonSetupEvent event) {
Compat.postInit();
proxy.postInit(event);
if (ModConfig.enabledFeatures.removeDragonBreathContainerItem) {
// TODO Items.DRAGON_BREATH.setContainerItem(null);
}
}
public void serverStarting(FMLServerStartingEvent event) {

View file

@ -15,6 +15,7 @@ import de.ellpeck.naturesaura.api.multiblock.Matcher;
import de.ellpeck.naturesaura.api.recipes.*;
import net.minecraft.block.BlockState;
import net.minecraft.block.FlowerBlock;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Tuple;
@ -129,7 +130,7 @@ public final class NaturesAuraAPI {
* A map of all of the entities' registry names to the amounts of aura they
* each generate in the projectile generator
*/
public static final Map<ResourceLocation, Integer> PROJECTILE_GENERATIONS = new HashMap<>();
public static final Map<EntityType, Integer> PROJECTILE_GENERATIONS = new HashMap<>();
/**
* The capability for any item or block that stores Aura in the form of an

View file

@ -5,6 +5,7 @@ import de.ellpeck.naturesaura.blocks.tiles.TileEntityAncientLeaves;
import de.ellpeck.naturesaura.reg.*;
import net.minecraft.block.BlockState;
import net.minecraft.block.LeavesBlock;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.material.MaterialColor;
import net.minecraft.client.renderer.color.IBlockColor;
@ -23,7 +24,7 @@ public class BlockAncientLeaves extends LeavesBlock implements
IModItem, IModelProvider, IColorProvidingBlock, IColorProvidingItem {
public BlockAncientLeaves() {
super(ModBlocks.prop(Material.LEAVES, MaterialColor.PINK));
super(ModBlocks.prop(Material.LEAVES, MaterialColor.PINK).hardnessAndResistance(0.2F).tickRandomly().sound(SoundType.PLANT));
ModRegistry.add(this);
ModRegistry.add(new ModTileType<>(TileEntityAncientLeaves::new, this));
}
@ -39,6 +40,11 @@ public class BlockAncientLeaves extends LeavesBlock implements
return new TileEntityAncientLeaves();
}
@Override
public boolean hasTileEntity(BlockState state) {
return true;
}
@Override
@OnlyIn(Dist.CLIENT)
public IBlockColor getBlockColor() {

View file

@ -4,6 +4,7 @@ import de.ellpeck.naturesaura.reg.IModItem;
import de.ellpeck.naturesaura.reg.IModelProvider;
import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraft.block.LogBlock;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.material.MaterialColor;
@ -12,7 +13,7 @@ public class BlockAncientLog extends LogBlock implements IModItem, IModelProvide
private final String baseName;
public BlockAncientLog(String baseName) {
super(MaterialColor.PURPLE, ModBlocks.prop(Material.WOOD));
super(MaterialColor.PURPLE, ModBlocks.prop(Material.WOOD).hardnessAndResistance(2.0F).sound(SoundType.WOOD));
this.baseName = baseName;
ModRegistry.add(this);
}

View file

@ -1,5 +1,6 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.gen.WorldGenAncientTree;
import de.ellpeck.naturesaura.reg.IModItem;
import de.ellpeck.naturesaura.reg.IModelProvider;
import de.ellpeck.naturesaura.reg.ModRegistry;
@ -11,6 +12,7 @@ import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.IFeatureConfig;
import net.minecraftforge.event.ForgeEventFactory;
import java.util.Random;
@ -64,8 +66,7 @@ public class BlockAncientSapling extends BushBlock implements IGrowable, IModIte
if (state.get(SaplingBlock.STAGE) == 0) {
world.setBlockState(pos, state.cycle(SaplingBlock.STAGE), 4);
} else if (ForgeEventFactory.saplingGrowTree(world, rand, pos)) {
// TODO generate tree
//new WorldGenAncientTree(true).generate(world, rand, pos);
new WorldGenAncientTree(true).place(world, world.getChunkProvider().getChunkGenerator(), rand, pos, IFeatureConfig.NO_FEATURE_CONFIG);
}
}
}

View file

@ -13,6 +13,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.IFluidState;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.shapes.ISelectionContext;
@ -21,11 +22,14 @@ import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraft.world.gen.Heightmap;
import net.minecraft.world.storage.loot.LootContext;
import net.minecraft.world.storage.loot.LootParameters;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import javax.annotation.Nullable;
import java.util.List;
public class BlockEndFlower extends BushBlock implements IModItem, IModelProvider {
@ -101,4 +105,12 @@ public class BlockEndFlower extends BushBlock implements IModItem, IModelProvide
super.harvestBlock(worldIn, player, pos, state, te, stack);
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
TileEntity tile = builder.get(LootParameters.BLOCK_ENTITY);
if (tile instanceof TileEntityEndFlower && ((TileEntityEndFlower) tile).isDrainMode)
return NonNullList.create();
return super.getDrops(state, builder);
}
}

View file

@ -14,6 +14,7 @@ import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
@ -34,6 +35,7 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.AnvilUpdateEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.network.NetworkHooks;
import javax.annotation.Nullable;
import java.lang.ref.WeakReference;
@ -108,7 +110,7 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider
TileEntityEnderCrate crate = (TileEntityEnderCrate) tile;
if (crate.canOpen()) {
crate.drainAura(10000);
// TODO playerIn.openGui(NaturesAura.MOD_ID, 0, worldIn, pos.getX(), pos.getY(), pos.getZ());
NetworkHooks.openGui((ServerPlayerEntity) player, crate, pos);
}
}
}

View file

@ -4,12 +4,15 @@ import de.ellpeck.naturesaura.reg.IColorProvidingBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.RedstoneWireBlock;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.EnumProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.state.properties.RedstoneSide;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.Direction;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
@ -17,26 +20,21 @@ import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import javax.annotation.Nullable;
public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock {
public static final EnumProperty<AttachPos> NORTH = EnumProperty.create("north", AttachPos.class);
public static final EnumProperty<AttachPos> EAST = EnumProperty.create("east", AttachPos.class);
public static final EnumProperty<AttachPos> SOUTH = EnumProperty.create("south", AttachPos.class);
public static final EnumProperty<AttachPos> WEST = EnumProperty.create("west", AttachPos.class);
public static final EnumProperty<RedstoneSide> NORTH = BlockStateProperties.REDSTONE_NORTH;
public static final EnumProperty<RedstoneSide> EAST = BlockStateProperties.REDSTONE_EAST;
public static final EnumProperty<RedstoneSide> SOUTH = BlockStateProperties.REDSTONE_SOUTH;
public static final EnumProperty<RedstoneSide> WEST = BlockStateProperties.REDSTONE_WEST;
protected static final VoxelShape[] SHAPES = new VoxelShape[]{Block.makeCuboidShape(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D), Block.makeCuboidShape(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D), Block.makeCuboidShape(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D), Block.makeCuboidShape(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D), Block.makeCuboidShape(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D), Block.makeCuboidShape(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 16.0D), Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D), Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 13.0D, 1.0D, 16.0D), Block.makeCuboidShape(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D), Block.makeCuboidShape(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 16.0D), Block.makeCuboidShape(0.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D), Block.makeCuboidShape(0.0D, 0.0D, 3.0D, 16.0D, 1.0D, 16.0D), Block.makeCuboidShape(3.0D, 0.0D, 0.0D, 16.0D, 1.0D, 13.0D), Block.makeCuboidShape(3.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D), Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 13.0D), Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D)};
public BlockGoldPowder() {
super("gold_powder", ModBlocks.prop(Blocks.REDSTONE_WIRE));
this.setDefaultState(this.getDefaultState()
.with(NORTH, AttachPos.NONE)
.with(EAST, AttachPos.NONE)
.with(SOUTH, AttachPos.NONE)
.with(WEST, AttachPos.NONE));
this.setDefaultState(this.stateContainer.getBaseState().with(NORTH, RedstoneSide.NONE).with(EAST, RedstoneSide.NONE).with(SOUTH, RedstoneSide.NONE).with(WEST, RedstoneSide.NONE));
}
@Override
@ -56,10 +54,10 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock {
private static int getShapeIndex(BlockState state) {
int i = 0;
boolean n = state.get(NORTH) != AttachPos.NONE;
boolean e = state.get(EAST) != AttachPos.NONE;
boolean s = state.get(SOUTH) != AttachPos.NONE;
boolean w = state.get(WEST) != AttachPos.NONE;
boolean n = state.get(NORTH) != RedstoneSide.NONE;
boolean e = state.get(EAST) != RedstoneSide.NONE;
boolean s = state.get(SOUTH) != RedstoneSide.NONE;
boolean w = state.get(WEST) != RedstoneSide.NONE;
if (n || s && !n && !e && !w) {
i |= 1 << Direction.NORTH.getHorizontalIndex();
@ -76,49 +74,44 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock {
return i;
}
// TODO weird gold powder thing
/*
@Override
public BlockState getActualState(BlockState state, IWorld worldIn, BlockPos pos) {
state = state.with(WEST, this.getAttachPosition(worldIn, pos, Direction.WEST));
state = state.with(EAST, this.getAttachPosition(worldIn, pos, Direction.EAST));
state = state.with(NORTH, this.getAttachPosition(worldIn, pos, Direction.NORTH));
state = state.with(SOUTH, this.getAttachPosition(worldIn, pos, Direction.SOUTH));
return state;
public BlockState getStateForPlacement(BlockItemUseContext context) {
IBlockReader iblockreader = context.getWorld();
BlockPos blockpos = context.getPos();
return this.getDefaultState().with(WEST, this.getSide(iblockreader, blockpos, Direction.WEST)).with(EAST, this.getSide(iblockreader, blockpos, Direction.EAST)).with(NORTH, this.getSide(iblockreader, blockpos, Direction.NORTH)).with(SOUTH, this.getSide(iblockreader, blockpos, Direction.SOUTH));
}
private AttachPos getAttachPosition(IWorld worldIn, BlockPos pos, Direction direction) {
BlockPos dirPos = pos.offset(direction);
BlockState state = worldIn.getBlockState(pos.offset(direction));
if (!this.canConnectTo(worldIn.getBlockState(dirPos), direction, worldIn, dirPos)
&& (state.isNormalCube(worldIn, pos.offset(direction)) || !this.canConnectUpwardsTo(worldIn, dirPos.down()))) {
BlockState iblockstate1 = worldIn.getBlockState(pos.up());
if (!iblockstate1.isNormalCube(worldIn, pos.up())) {
*//*boolean flag = worldIn.getBlockState(dirPos).isSideSolid(worldIn, dirPos, Direction.UP)
|| worldIn.getBlockState(dirPos).getBlock() == Blocks.GLOWSTONE;
if (flag && this.canConnectUpwardsTo(worldIn, dirPos.up())) {
if (state.isBlockNormalCube()) {
return AttachPos.UP;
}
return AttachPos.SIDE;
}*//*
return AttachPos.SIDE;
}
return AttachPos.NONE;
@Override
public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) {
if (facing == Direction.DOWN) {
return stateIn;
} else {
return AttachPos.SIDE;
return facing == Direction.UP ? stateIn.with(WEST, this.getSide(worldIn, currentPos, Direction.WEST)).with(EAST, this.getSide(worldIn, currentPos, Direction.EAST)).with(NORTH, this.getSide(worldIn, currentPos, Direction.NORTH)).with(SOUTH, this.getSide(worldIn, currentPos, Direction.SOUTH)) : stateIn.with(RedstoneWireBlock.FACING_PROPERTY_MAP.get(facing), this.getSide(worldIn, currentPos, facing));
}
}*/
@Override
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return VoxelShapes.empty();
}
@Override
public boolean isFireSource(BlockState state, IBlockReader world, BlockPos pos, Direction side) {
return false;
private RedstoneSide getSide(IBlockReader worldIn, BlockPos pos, Direction face) {
BlockPos blockpos = pos.offset(face);
BlockState blockstate = worldIn.getBlockState(blockpos);
BlockPos blockpos1 = pos.up();
BlockState blockstate1 = worldIn.getBlockState(blockpos1);
if (!blockstate1.isNormalCube(worldIn, blockpos1)) {
boolean flag = blockstate.func_224755_d(worldIn, blockpos, Direction.UP) || blockstate.getBlock() == Blocks.HOPPER;
if (flag && this.canConnectTo(worldIn.getBlockState(blockpos.up()))) {
if (blockstate.func_224756_o(worldIn, blockpos)) {
return RedstoneSide.UP;
}
return RedstoneSide.SIDE;
}
}
return !this.canConnectTo(blockstate) && (blockstate.isNormalCube(worldIn, blockpos) || !this.canConnectTo(worldIn.getBlockState(blockpos.down()))) ? RedstoneSide.NONE : RedstoneSide.SIDE;
}
protected boolean canConnectTo(BlockState blockState) {
Block block = blockState.getBlock();
return block == this;
}
@Override
@ -128,13 +121,101 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock {
return blockstate.func_224755_d(worldIn, blockpos, Direction.UP) || blockstate.getBlock() == Blocks.HOPPER;
}
private boolean canConnectUpwardsTo(IWorld worldIn, BlockPos pos) {
return this.canConnectTo(worldIn.getBlockState(pos), null, worldIn, pos);
@Override
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return VoxelShapes.empty();
}
private boolean canConnectTo(BlockState blockState, @Nullable Direction side, IWorld world, BlockPos pos) {
Block block = blockState.getBlock();
return block == this;
@Override
public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) {
if (oldState.getBlock() != state.getBlock() && !worldIn.isRemote) {
for (Direction direction : Direction.Plane.VERTICAL) {
worldIn.notifyNeighborsOfStateChange(pos.offset(direction), this);
}
for (Direction direction1 : Direction.Plane.HORIZONTAL) {
this.notifyWireNeighborsOfStateChange(worldIn, pos.offset(direction1));
}
for (Direction direction2 : Direction.Plane.HORIZONTAL) {
BlockPos blockpos = pos.offset(direction2);
if (worldIn.getBlockState(blockpos).isNormalCube(worldIn, blockpos)) {
this.notifyWireNeighborsOfStateChange(worldIn, blockpos.up());
} else {
this.notifyWireNeighborsOfStateChange(worldIn, blockpos.down());
}
}
}
}
@Override
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
if (!isMoving && state.getBlock() != newState.getBlock()) {
super.onReplaced(state, worldIn, pos, newState, isMoving);
if (!worldIn.isRemote) {
for (Direction direction : Direction.values()) {
worldIn.notifyNeighborsOfStateChange(pos.offset(direction), this);
}
for (Direction direction1 : Direction.Plane.HORIZONTAL) {
this.notifyWireNeighborsOfStateChange(worldIn, pos.offset(direction1));
}
for (Direction direction2 : Direction.Plane.HORIZONTAL) {
BlockPos blockpos = pos.offset(direction2);
if (worldIn.getBlockState(blockpos).isNormalCube(worldIn, blockpos)) {
this.notifyWireNeighborsOfStateChange(worldIn, blockpos.up());
} else {
this.notifyWireNeighborsOfStateChange(worldIn, blockpos.down());
}
}
}
}
}
@Override
public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
if (!worldIn.isRemote) {
if (!state.isValidPosition(worldIn, pos)) {
spawnDrops(state, worldIn, pos);
worldIn.removeBlock(pos, false);
}
}
}
@Override
public void updateDiagonalNeighbors(BlockState state, IWorld worldIn, BlockPos pos, int flags) {
try (BlockPos.PooledMutableBlockPos pool = BlockPos.PooledMutableBlockPos.retain()) {
for (Direction direction : Direction.Plane.HORIZONTAL) {
RedstoneSide redstoneside = state.get(RedstoneWireBlock.FACING_PROPERTY_MAP.get(direction));
if (redstoneside != RedstoneSide.NONE && worldIn.getBlockState(pool.setPos(pos).move(direction)).getBlock() != this) {
pool.move(Direction.DOWN);
BlockState blockstate = worldIn.getBlockState(pool);
if (blockstate.getBlock() != Blocks.OBSERVER) {
BlockPos blockpos = pool.offset(direction.getOpposite());
BlockState blockstate1 = blockstate.updatePostPlacement(direction.getOpposite(), worldIn.getBlockState(blockpos), worldIn, pool, blockpos);
replaceBlock(blockstate, blockstate1, worldIn, pool, flags);
}
pool.setPos(pos).move(direction).move(Direction.UP);
BlockState blockstate3 = worldIn.getBlockState(pool);
if (blockstate3.getBlock() != Blocks.OBSERVER) {
BlockPos blockpos1 = pool.offset(direction.getOpposite());
BlockState blockstate2 = blockstate3.updatePostPlacement(direction.getOpposite(), worldIn.getBlockState(blockpos1), worldIn, pool, blockpos1);
replaceBlock(blockstate3, blockstate2, worldIn, pool, flags);
}
}
}
}
}
private void notifyWireNeighborsOfStateChange(World worldIn, BlockPos pos) {
if (worldIn.getBlockState(pos).getBlock() == this) {
worldIn.notifyNeighborsOfStateChange(pos, this);
for (Direction direction : Direction.values()) {
worldIn.notifyNeighborsOfStateChange(pos.offset(direction), this);
}
}
}
@Override
@ -142,25 +223,4 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock {
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.CUTOUT;
}
private enum AttachPos implements IStringSerializable {
UP("up"),
SIDE("side"),
NONE("none");
private final String name;
AttachPos(String name) {
this.name = name;
}
public String toString() {
return this.getName();
}
@Override
public String getName() {
return this.name;
}
}
}

View file

@ -6,6 +6,7 @@ import de.ellpeck.naturesaura.reg.*;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.LeavesBlock;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.material.MaterialColor;
import net.minecraft.client.renderer.color.IBlockColor;
@ -24,11 +25,11 @@ import java.util.Random;
public class BlockGoldenLeaves extends LeavesBlock implements
IModItem, IModelProvider, IColorProvidingBlock, IColorProvidingItem {
private static final int HIGHEST_STAGE = 3;
private static final IntegerProperty STAGE = IntegerProperty.create("stage", 0, HIGHEST_STAGE);
public static final int HIGHEST_STAGE = 3;
public static final IntegerProperty STAGE = IntegerProperty.create("stage", 0, HIGHEST_STAGE);
public BlockGoldenLeaves() {
super(ModBlocks.prop(Material.LEAVES, MaterialColor.GOLD));
super(ModBlocks.prop(Material.LEAVES, MaterialColor.GOLD).hardnessAndResistance(0.2F).tickRandomly().sound(SoundType.PLANT));
ModRegistry.add(this);
}
@ -49,15 +50,6 @@ public class BlockGoldenLeaves extends LeavesBlock implements
0xF2FF00, 0.5F + rand.nextFloat(), 50, 0F, false, true);
}
/* Replaced by json loot tables
@Override
public List<ItemStack> onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) {
NonNullList<ItemStack> drops = NonNullList.create();
this.getDrops(drops, world, pos, world.getBlockState(pos), fortune);
return drops;
}
*/
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
@ -84,20 +76,6 @@ public class BlockGoldenLeaves extends LeavesBlock implements
return (stack, tintIndex) -> 0xF2FF00;
}
/* Replaced by json loot tables
@Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, BlockState state, int fortune) {
Random rand = world instanceof World ? ((World) world).rand : RANDOM;
if (state.getValue(STAGE) < HIGHEST_STAGE) {
if (rand.nextFloat() >= 0.75F) {
drops.add(new ItemStack(ModItems.GOLD_FIBER));
}
} else if (rand.nextFloat() >= 0.25F) {
drops.add(new ItemStack(ModItems.GOLD_LEAF));
}
}
*/
@Override
public void randomTick(BlockState state, World worldIn, BlockPos pos, Random random) {
super.randomTick(state, worldIn, pos, random);
@ -115,6 +93,11 @@ public class BlockGoldenLeaves extends LeavesBlock implements
}
}
@Override
public boolean ticksRandomly(BlockState state) {
return true;
}
public static boolean convert(World world, BlockPos pos) {
BlockState state = world.getBlockState(pos);
if ((state.getBlock().isFoliage(state, world, pos) || state.getBlock() instanceof LeavesBlock) && !(state.getBlock() instanceof BlockAncientLeaves || state.getBlock() instanceof BlockGoldenLeaves)) {

View file

@ -12,7 +12,6 @@ import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.Tuple;
@ -24,7 +23,6 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.ProjectileImpactEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.registries.ForgeRegistries;
public class BlockProjectileGenerator extends BlockContainerImpl implements ITESRProvider {
public BlockProjectileGenerator() {
@ -51,8 +49,7 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
TileEntityProjectileGenerator generator = (TileEntityProjectileGenerator) tile;
if (generator.nextSide != blockRay.getFace())
return;
ResourceLocation name = ForgeRegistries.ENTITIES.getKey(entity.getType());
Integer amount = NaturesAuraAPI.PROJECTILE_GENERATIONS.get(name);
Integer amount = NaturesAuraAPI.PROJECTILE_GENERATIONS.get(entity.getType());
if (amount == null || amount <= 0)
return;

View file

@ -86,7 +86,7 @@ public final class Multiblocks {
'L', ModBlocks.ANCIENT_LOG,
'0', ModBlocks.AUTO_CRAFTER,
' ', Matcher.wildcard());
public static final IMultiblock RF_CONVERTER = ModConfig.enabledFeatures.rfConverter ? NaturesAuraAPI.instance().createMultiblock(
public static final IMultiblock RF_CONVERTER = ModConfig.instance.rfConverter.get() ? NaturesAuraAPI.instance().createMultiblock(
new ResourceLocation(NaturesAura.MOD_ID, "rf_converter"),
new String[][]{
{" ", " ", " ", " R ", " ", " ", " "},

View file

@ -4,15 +4,25 @@ import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.misc.IWorldData;
import de.ellpeck.naturesaura.blocks.BlockEnderCrate;
import de.ellpeck.naturesaura.gui.ContainerEnderCrate;
import de.ellpeck.naturesaura.gui.ModContainers;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.items.IItemHandlerModifiable;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class TileEntityEnderCrate extends TileEntityImpl {
public class TileEntityEnderCrate extends TileEntityImpl implements INamedContainerProvider {
private final IItemHandlerModifiable wrappedEnderStorage = new IItemHandlerModifiable() {
@Override
@ -127,4 +137,15 @@ public class TileEntityEnderCrate extends TileEntityImpl {
IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, amount);
}
}
@Override
public ITextComponent getDisplayName() {
return new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".ender_crate", TextFormatting.ITALIC + this.name + TextFormatting.RESET);
}
@Nullable
@Override
public Container createMenu(int window, PlayerInventory inv, PlayerEntity player) {
return new ContainerEnderCrate(ModContainers.ENDER_CRATE, window, player, this.getItemHandler(null));
}
}

View file

@ -167,7 +167,7 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickableT
}
public boolean isCloseEnough(BlockPos pos) {
int range = ModConfig.general.fieldCreatorRange + 1;
int range = ModConfig.instance.fieldCreatorRange.get() + 1;
return this.pos.distanceSq(pos) <= range * range;
}

View file

@ -78,7 +78,7 @@ public class TileEntityRFConverter extends TileEntityImpl implements ITickableTi
if (aura <= IAuraChunk.DEFAULT_AURA)
return;
int amountToGen = Math.min(Math.min(10000, aura / 1000), emptyPart);
int amountToUse = MathHelper.ceil(amountToGen / ModConfig.general.auraToRFRatio);
int amountToUse = MathHelper.ceil(amountToGen / ModConfig.instance.auraToRFRatio.get());
this.storage.setEnergy(this.storage.getEnergyStored() + amountToGen);
BlockPos pos = IAuraChunk.getHighestSpot(this.world, this.pos, 45, this.pos);

View file

@ -145,7 +145,7 @@ public class AnimalEffect implements IDrainSpotEffect {
@Override
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) {
return ModConfig.enabledFeatures.animalEffect;
return ModConfig.instance.animalEffect.get();
}
@Override

View file

@ -68,7 +68,7 @@ public class BreathlessEffect implements IDrainSpotEffect {
@Override
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) {
return ModConfig.enabledFeatures.breathlessEffect;
return ModConfig.instance.breathlessEffect.get();
}
@Override

View file

@ -70,7 +70,7 @@ public class CacheRechargeEffect implements IDrainSpotEffect {
@Override
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) {
return ModConfig.enabledFeatures.cacheRechargeEffect;
return ModConfig.instance.cacheRechargeEffect.get();
}
@Override

View file

@ -72,7 +72,7 @@ public class ExplosionEffect implements IDrainSpotEffect {
@Override
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) {
return ModConfig.enabledFeatures.explosionEffect;
return ModConfig.instance.explosionEffect.get();
}
@Override

View file

@ -81,7 +81,7 @@ public class GrassDieEffect implements IDrainSpotEffect {
@Override
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) {
return ModConfig.enabledFeatures.grassDieEffect && type.isSimilar(NaturesAuraAPI.TYPE_OVERWORLD);
return ModConfig.instance.grassDieEffect.get() && type.isSimilar(NaturesAuraAPI.TYPE_OVERWORLD);
}
@Override

View file

@ -130,7 +130,7 @@ public class OreSpawnEffect implements IDrainSpotEffect {
@Override
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) {
return ModConfig.enabledFeatures.oreEffect &&
return ModConfig.instance.oreEffect.get() &&
(type.isSimilar(NaturesAuraAPI.TYPE_OVERWORLD) || type.isSimilar(NaturesAuraAPI.TYPE_NETHER));
}

View file

@ -87,7 +87,7 @@ public class PlantBoostEffect implements IDrainSpotEffect {
@Override
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) {
return ModConfig.enabledFeatures.plantBoostEffect && type.isSimilar(NaturesAuraAPI.TYPE_OVERWORLD);
return ModConfig.instance.plantBoostEffect.get() && type.isSimilar(NaturesAuraAPI.TYPE_OVERWORLD);
}
@Override

View file

@ -2,7 +2,6 @@ package de.ellpeck.naturesaura.compat;
import de.ellpeck.naturesaura.compat.crafttweaker.CraftTweakerCompat;
import de.ellpeck.naturesaura.compat.patchouli.PatchouliCompat;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.ModList;
public final class Compat {

View file

@ -30,8 +30,8 @@ public final class PatchouliCompat {
private static final ResourceLocation BOOK = new ResourceLocation(NaturesAura.MOD_ID, "book");
public static void preInit() {
PatchouliAPI.instance.setConfigFlag(NaturesAura.MOD_ID + ":rf_converter", ModConfig.enabledFeatures.rfConverter);
PatchouliAPI.instance.setConfigFlag(NaturesAura.MOD_ID + ":chunk_loader", ModConfig.enabledFeatures.chunkLoader);
PatchouliAPI.instance.setConfigFlag(NaturesAura.MOD_ID + ":rf_converter", ModConfig.instance.rfConverter.get());
PatchouliAPI.instance.setConfigFlag(NaturesAura.MOD_ID + ":chunk_loader", ModConfig.instance.chunkLoader.get());
}
public static void preInitClient() {

View file

@ -77,7 +77,7 @@ public class ClientEvents {
@SubscribeEvent
public void onDebugRender(RenderGameOverlayEvent.Text event) {
Minecraft mc = Minecraft.getInstance();
if (mc.gameSettings.showDebugInfo && ModConfig.client.debugText) {
if (mc.gameSettings.showDebugInfo && ModConfig.instance.debugText.get()) {
String prefix = TextFormatting.GREEN + "[" + NaturesAura.MOD_NAME + "]" + TextFormatting.RESET + " ";
List<String> left = event.getLeft();
left.add("");
@ -127,7 +127,7 @@ public class ClientEvents {
if (!mc.isGamePaused()) {
if (mc.world.getGameTime() % 20 == 0) {
int amount = MathHelper.floor(190 * ModConfig.client.excessParticleAmount);
int amount = MathHelper.floor(190 * ModConfig.instance.excessParticleAmount.get());
for (int i = 0; i < amount; i++) {
int x = MathHelper.floor(mc.player.posX) + mc.world.rand.nextInt(64) - 32;
int z = MathHelper.floor(mc.player.posZ) + mc.world.rand.nextInt(64) - 32;
@ -220,7 +220,7 @@ public class ClientEvents {
-mc.player.prevPosY - (mc.player.posY - mc.player.prevPosY) * partial - (double) MathHelper.lerp(partial, this.previousHeight, this.height),
-mc.player.prevPosZ - (mc.player.posZ - mc.player.prevPosZ) * partial);
if (mc.gameSettings.showDebugInfo && mc.player.isCreative() && ModConfig.client.debugWorld) {
if (mc.gameSettings.showDebugInfo && mc.player.isCreative() && ModConfig.instance.debugWorld.get()) {
Map<BlockPos, Integer> spots = new HashMap<>();
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_DEPTH_TEST);
@ -331,7 +331,7 @@ public class ClientEvents {
GlStateManager.pushMatrix();
mc.getTextureManager().bindTexture(OVERLAYS);
int conf = ModConfig.client.auraBarLocation;
int conf = ModConfig.instance.auraBarLocation.get();
if (!mc.gameSettings.showDebugInfo && (conf != 2 || !(mc.currentScreen instanceof ChatScreen))) {
GlStateManager.color3f(83 / 255F, 160 / 255F, 8 / 255F);

View file

@ -6,12 +6,8 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.chunk.AuraChunk;
import de.ellpeck.naturesaura.chunk.AuraChunkProvider;
import de.ellpeck.naturesaura.misc.BlockLootProvider;
import de.ellpeck.naturesaura.misc.BlockTagProvider;
import de.ellpeck.naturesaura.misc.ItemTagProvider;
import de.ellpeck.naturesaura.misc.WorldData;
import de.ellpeck.naturesaura.packet.PacketHandler;
import net.minecraft.data.DataGenerator;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
@ -23,7 +19,6 @@ import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.world.ChunkWatchEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@ -90,13 +85,4 @@ public class CommonEvents {
PacketHandler.sendTo(event.getPlayer(), auraChunk.makePacket());
}
}
// TODO config
/* @SubscribeEvent
public void onConfigChanged(OnConfigChangedEvent event) {
if (NaturesAura.MOD_ID.equals(event.getModID())) {
ConfigManager.sync(NaturesAura.MOD_ID, Config.Type.INSTANCE);
ModConfig.initOrReload(true);
}
}*/
}

View file

@ -1,24 +1,25 @@
/* TODO World gen
package de.ellpeck.naturesaura.gen;
import de.ellpeck.naturesaura.blocks.ModBlocks;
import net.minecraft.block.*;
import net.minecraft.block.BlockLog.EnumAxis;
import net.minecraft.block.material.Material;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.LogBlock;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.world.World;
import net.minecraft.world.gen.IWorldGenerationReader;
import net.minecraft.world.gen.feature.AbstractTreeFeature;
import net.minecraft.world.gen.feature.NoFeatureConfig;
import java.util.Random;
import java.util.Set;
public class WorldGenAncientTree extends AbstractTreeFeature {
public class WorldGenAncientTree extends AbstractTreeFeature<NoFeatureConfig> {
public WorldGenAncientTree(boolean notify) {
super(notify);
super(NoFeatureConfig::deserialize, notify);
}
@Override
@ -35,12 +36,12 @@ public class WorldGenAncientTree extends AbstractTreeFeature {
float z = (float) Math.cos(angle) * length;
BlockPos goal = pos.add(x, 0, z);
while (!world.getBlockState(goal).isFullBlock()) {
while (!world.hasBlockState(goal, state -> state.getMaterial().isReplaceable())) {
goal = goal.down();
if (goal.distanceSq(pos) >= 10 * 10)
break;
}
this.makeBranch(world, pos.up(rand.nextInt(1)), goal, ModBlocks.ANCIENT_BARK.getDefaultState(), false);
this.makeBranch(changedBlocks, world, pos.up(rand.nextInt(1)), goal, ModBlocks.ANCIENT_BARK.getDefaultState(), false);
}
//Trunk
@ -48,15 +49,14 @@ public class WorldGenAncientTree extends AbstractTreeFeature {
for (int z = 0; z <= 1; z++) {
for (int i = height - (x + z) * (rand.nextInt(2) + 2); i >= 0; i--) {
BlockPos goal = pos.add(x, i, z);
if (this.isReplaceable(world, goal)) {
this.setBlockAndNotifyAdequately(world, goal,
ModBlocks.ANCIENT_LOG.getDefaultState().withProperty(LogBlock.LOG_AXIS, EnumAxis.Y));
if (func_214587_a(world, goal)) {
this.setBlockState(world, goal, ModBlocks.ANCIENT_LOG.getDefaultState().with(LogBlock.AXIS, Axis.Y));
changedBlocks.add(goal);
}
}
}
}
this.makeLeaves(world, trunkTop.up(rand.nextInt(2) - 1),
ModBlocks.ANCIENT_LEAVES.getDefaultState().withProperty(LeavesBlock.CHECK_DECAY, false), rand.nextInt(2) + 3, rand);
this.makeLeaves(changedBlocks, world, trunkTop.up(rand.nextInt(2) - 1), ModBlocks.ANCIENT_LEAVES.getDefaultState(), rand.nextInt(2) + 3, rand);
//Branches
int branchAmount = rand.nextInt(3) + 4;
@ -67,25 +67,14 @@ public class WorldGenAncientTree extends AbstractTreeFeature {
float z = (float) Math.cos(angle) * length;
BlockPos goal = trunkTop.add(x, rand.nextInt(3) + 1, z);
this.makeBranch(world, trunkTop, goal, ModBlocks.ANCIENT_LOG.getDefaultState(), true);
this.makeLeaves(world, goal,
ModBlocks.ANCIENT_LEAVES.getDefaultState().withProperty(LeavesBlock.CHECK_DECAY, false), rand.nextInt(2) + 2, rand);
this.makeBranch(changedBlocks, world, trunkTop, goal, ModBlocks.ANCIENT_LOG.getDefaultState(), true);
this.makeLeaves(changedBlocks, world, goal, ModBlocks.ANCIENT_LEAVES.getDefaultState(), rand.nextInt(2) + 2, rand);
}
return true;
}
@Override
protected boolean canGrowInto(Block blockType) {
if (super.canGrowInto(blockType)) {
return true;
} else {
Material material = blockType.getDefaultState().getMaterial();
return material == Material.VINE || material == Material.PLANTS;
}
}
private void makeBranch(World world, BlockPos first, BlockPos second, BlockState state, boolean hasAxis) {
private void makeBranch(Set changedBlocks, IWorldGenerationReader world, BlockPos first, BlockPos second, BlockState state, boolean hasAxis) {
BlockPos pos = second.add(-first.getX(), -first.getY(), -first.getZ());
int length = this.getHighestCoord(pos);
float stepX = (float) pos.getX() / (float) length;
@ -94,27 +83,32 @@ public class WorldGenAncientTree extends AbstractTreeFeature {
for (int i = 0; i <= length; i++) {
BlockPos goal = first.add((0.5F + i * stepX), (0.5F + i * stepY), (0.5F + i * stepZ));
if (this.isReplaceable(world, goal)) {
if (func_214587_a(world, goal)) {
if (hasAxis) {
EnumAxis axis = this.getLogAxis(first, goal);
this.setBlockAndNotifyAdequately(world, goal, state.withProperty(LogBlock.LOG_AXIS, axis));
Axis axis = this.getLogAxis(first, goal);
this.setBlockState(world, goal, state.with(LogBlock.AXIS, axis));
} else {
this.setBlockAndNotifyAdequately(world, goal, state);
this.setBlockState(world, goal, state);
}
changedBlocks.add(goal);
}
}
}
private void makeLeaves(World world, BlockPos pos, BlockState state, int radius, Random rand) {
private void makeLeaves(Set changedBlocks, IWorldGenerationReader world, BlockPos pos, BlockState state, int radius, Random rand) {
for (int x = -radius; x <= radius; x++) {
for (int y = -radius; y <= radius; y++) {
for (int z = -radius; z <= radius; z++) {
BlockPos goal = pos.add(x, y, z);
if (pos.distanceSq(goal) <= radius * radius + rand.nextInt(3) - 1) {
if (this.isReplaceable(world, goal)) {
Block block = world.getBlockState(goal).getBlock();
if (!(block instanceof LogBlock) && block != Blocks.DIRT && block != Blocks.GRASS)
this.setBlockAndNotifyAdequately(world, goal, state);
if (isAirOrLeaves(world, goal)) {
if (world.hasBlockState(goal, st -> {
Block block = st.getBlock();
return !(block instanceof LogBlock) && block != Blocks.DIRT && block != Blocks.GRASS;
})) {
this.setBlockState(world, goal, state);
changedBlocks.add(goal);
}
}
}
}
@ -126,18 +120,18 @@ public class WorldGenAncientTree extends AbstractTreeFeature {
return Math.max(MathHelper.abs(pos.getX()), Math.max(MathHelper.abs(pos.getY()), MathHelper.abs(pos.getZ())));
}
private EnumAxis getLogAxis(BlockPos pos, BlockPos goal) {
EnumAxis axis = EnumAxis.Y;
private Axis getLogAxis(BlockPos pos, BlockPos goal) {
Axis axis = Axis.Y;
int x = Math.abs(goal.getX() - pos.getX());
int y = Math.abs(goal.getZ() - pos.getZ());
int highest = Math.max(x, y);
if (highest > 0) {
if (x == highest) {
axis = EnumAxis.X;
axis = Axis.X;
} else if (y == highest) {
axis = EnumAxis.Z;
axis = Axis.Z;
}
}
return axis;
}
}*/
}

View file

@ -10,7 +10,7 @@ import net.minecraftforge.items.SlotItemHandler;
public class ContainerEnderCrate extends Container {
public ContainerEnderCrate(ContainerType<?> type, int id, PlayerEntity player, IItemHandler handler) {
public ContainerEnderCrate(ContainerType<ContainerEnderCrate> type, int id, PlayerEntity player, IItemHandler handler) {
super(type, id);
int i = (3 - 4) * 18;
for (int j = 0; j < 3; ++j)

View file

@ -1,30 +1,22 @@
package de.ellpeck.naturesaura.gui;
import com.mojang.blaze3d.platform.GlStateManager;
import de.ellpeck.naturesaura.NaturesAura;
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.items.IItemHandler;
@OnlyIn(Dist.CLIENT)
public class GuiEnderCrate extends ContainerScreen {
public class GuiEnderCrate extends ContainerScreen<ContainerEnderCrate> {
private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("textures/gui/container/generic_54.png");
private final PlayerEntity player;
private final String nameKey;
private final String name;
public GuiEnderCrate(ContainerType<?> type, int id, PlayerEntity player, IItemHandler handler, String nameKey, String name) {
super(new ContainerEnderCrate(type, id, player, handler), player.inventory, new StringTextComponent(""));
this.player = player;
this.nameKey = nameKey;
this.name = name;
public GuiEnderCrate(ContainerEnderCrate container, PlayerInventory inv, ITextComponent title) {
super(container, inv, title);
this.player = inv.player;
this.ySize = 114 + 3 * 18;
}
@ -37,8 +29,7 @@ public class GuiEnderCrate extends ContainerScreen {
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
String display = I18n.format("info." + NaturesAura.MOD_ID + "." + this.nameKey, TextFormatting.ITALIC + this.name + TextFormatting.RESET);
this.font.drawString(display, 8, 6, 4210752);
this.font.drawString(this.title.getFormattedText(), 8, 6, 4210752);
this.font.drawString(this.player.inventory.getDisplayName().getFormattedText(), 8, this.ySize - 96 + 2, 4210752);
}

View file

@ -1,66 +0,0 @@
/* TODO gui handler
package de.ellpeck.naturesaura.gui;
import de.ellpeck.naturesaura.api.misc.IWorldData;
import de.ellpeck.naturesaura.blocks.BlockEnderCrate;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityEnderCrate;
import de.ellpeck.naturesaura.items.ModItems;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.IGuiHandler;
import javax.annotation.Nullable;
public class GuiHandler implements IGuiHandler {
public GuiHandler() {
//NetworkRegistry.registerGuiHandler(NaturesAura.MOD_ID, this);
}
@Nullable
@Override
public Object getServerGuiElement(int id, PlayerEntity player, World world, int x, int y, int z) {
if (id == 0) {
TileEntity tile = world.getTileEntity(new BlockPos(x, y, z));
if (tile instanceof TileEntityEnderCrate) {
TileEntityEnderCrate crate = (TileEntityEnderCrate) tile;
if (crate.canOpen())
return new ContainerEnderCrate(player, crate.getItemHandler(null));
}
} else if (id == 1) {
ItemStack stack = player.getHeldItemMainhand();
if (stack.getItem() == ModItems.ENDER_ACCESS) {
String name = BlockEnderCrate.getEnderName(stack);
if (name != null && !name.isEmpty())
return new ContainerEnderCrate(player, IWorldData.getOverworldData(world).getEnderStorage(name));
}
}
return null;
}
@Nullable
@Override
public Object getClientGuiElement(int id, PlayerEntity player, World world, int x, int y, int z) {
if (id == 0) {
TileEntity tile = world.getTileEntity(new BlockPos(x, y, z));
if (tile instanceof TileEntityEnderCrate) {
TileEntityEnderCrate crate = (TileEntityEnderCrate) tile;
if (crate.canOpen())
return new GuiEnderCrate(player, crate.getItemHandler(null), "ender_crate", crate.name);
}
} else if (id == 1) {
ItemStack stack = player.getHeldItemMainhand();
if (stack.getItem() == ModItems.ENDER_ACCESS) {
String name = BlockEnderCrate.getEnderName(stack);
if (name != null && !name.isEmpty())
return new GuiEnderCrate(player, IWorldData.getOverworldData(world).getEnderStorage(name), "ender_access", name);
}
}
return null;
}
}
*/

View file

@ -0,0 +1,10 @@
package de.ellpeck.naturesaura.gui;
import net.minecraft.inventory.container.ContainerType;
@SuppressWarnings("FieldNamingConvention")
public final class ModContainers {
public static ContainerType<ContainerEnderCrate> ENDER_CRATE;
public static ContainerType<ContainerEnderCrate> ENDER_ACCESS;
}

View file

@ -3,17 +3,28 @@ package de.ellpeck.naturesaura.items;
import com.google.common.base.Strings;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.misc.IWorldData;
import de.ellpeck.naturesaura.blocks.BlockEnderCrate;
import de.ellpeck.naturesaura.gui.ContainerEnderCrate;
import de.ellpeck.naturesaura.gui.ModContainers;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.network.NetworkHooks;
import net.minecraftforge.items.IItemHandler;
import javax.annotation.Nullable;
import java.util.List;
@ -28,15 +39,28 @@ public class EnderAccess extends ItemImpl {
if (handIn != Hand.MAIN_HAND)
return new ActionResult<>(ActionResultType.PASS, playerIn.getHeldItem(handIn));
ItemStack stack = playerIn.getHeldItemMainhand();
if (!Strings.isNullOrEmpty(BlockEnderCrate.getEnderName(stack))) {
if (!worldIn.isRemote && NaturesAuraAPI.instance().extractAuraFromPlayer(playerIn, 10000, false))
// TODO playerIn.openGui(NaturesAura.MOD_ID, 1, worldIn, (int) playerIn.posX, (int) playerIn.posY, (int) playerIn.posZ);
String name = BlockEnderCrate.getEnderName(stack);
if (!Strings.isNullOrEmpty(name)) {
if (!worldIn.isRemote && NaturesAuraAPI.instance().extractAuraFromPlayer(playerIn, 10000, false)) {
NetworkHooks.openGui((ServerPlayerEntity) playerIn, new INamedContainerProvider() {
@Override
public ITextComponent getDisplayName() {
return new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".ender_access", TextFormatting.ITALIC + name + TextFormatting.RESET);
}
@Nullable
@Override
public Container createMenu(int windowId, PlayerInventory inv, PlayerEntity player) {
IItemHandler handler = IWorldData.getOverworldData(inv.player.world).getEnderStorage(name);
return new ContainerEnderCrate(ModContainers.ENDER_ACCESS, windowId, player, handler);
}
}, buffer -> buffer.writeString(name));
}
return new ActionResult<>(ActionResultType.SUCCESS, stack);
}
return new ActionResult<>(ActionResultType.FAIL, stack);
}
@Override
@OnlyIn(Dist.CLIENT)
public void addInformation(ItemStack stack, @Nullable World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {

View file

@ -36,7 +36,7 @@ public class Hoe extends HoeItem implements IModItem, IModelProvider {
Random random = world.getRandom();
BlockPos pos = context.getPos();
if (random.nextInt(5) == 0) {
seed = new ItemStack(Items.WHEAT_SEEDS); // TODO Change this to spawn random seed dropped by tall grass
seed = new ItemStack(Items.WHEAT_SEEDS);
} else if (random.nextInt(10) == 0) {
int rand = random.nextInt(3);
if (rand == 0) {

View file

@ -2,21 +2,21 @@ package de.ellpeck.naturesaura.misc;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import de.ellpeck.naturesaura.blocks.BlockGoldenLeaves;
import de.ellpeck.naturesaura.blocks.ModBlocks;
import de.ellpeck.naturesaura.blocks.Slab;
import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.reg.IModItem;
import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.SlabBlock;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.DirectoryCache;
import net.minecraft.data.IDataProvider;
import net.minecraft.state.properties.SlabType;
import net.minecraft.data.loot.BlockLootTables;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.storage.loot.*;
import net.minecraft.world.storage.loot.conditions.BlockStateProperty;
import net.minecraft.world.storage.loot.conditions.SurvivesExplosion;
import net.minecraft.world.storage.loot.functions.ExplosionDecay;
import net.minecraft.world.storage.loot.functions.SetCount;
import net.minecraft.world.storage.loot.conditions.RandomChance;
import javax.annotation.Nonnull;
import java.io.IOException;
@ -38,11 +38,16 @@ public class BlockLootProvider implements IDataProvider {
continue;
Block block = (Block) item;
if (block instanceof Slab) {
this.lootFunctions.put(block, BlockLootProvider::genSlab);
this.lootFunctions.put(block, LootTableHooks::genSlab);
} else {
this.lootFunctions.put(block, BlockLootProvider::genRegular);
this.lootFunctions.put(block, LootTableHooks::genRegular);
}
}
this.lootFunctions.put(ModBlocks.ANCIENT_LEAVES, b -> LootTableHooks.genLeaves(b, ModBlocks.ANCIENT_SAPLING));
this.lootFunctions.put(ModBlocks.DECAYED_LEAVES, LootTableHooks::genSilkOnly);
this.lootFunctions.put(ModBlocks.GOLDEN_LEAVES, b -> LootTable.builder().addLootPool(LootPool.builder().rolls(ConstantRange.of(1)).addEntry(LootTableHooks.survivesExplosion(b, ItemLootEntry.builder(ModItems.GOLD_LEAF)).acceptCondition(BlockStateProperty.builder(b).with(BlockGoldenLeaves.STAGE, BlockGoldenLeaves.HIGHEST_STAGE))).acceptCondition(RandomChance.builder(0.75F))));
}
@Override
@ -56,22 +61,8 @@ public class BlockLootProvider implements IDataProvider {
}
}
private static Path getPath(Path root, ResourceLocation id) {
return root.resolve("data/" + id.getNamespace() + "/loot_tables/blocks/" + id.getPath() + ".json");
}
private static LootTable.Builder genSlab(Block b) {
LootEntry.Builder<?> entry = ItemLootEntry.builder(b)
.acceptFunction(SetCount.func_215932_a(ConstantRange.of(2)).acceptCondition(BlockStateProperty.builder(b).with(SlabBlock.TYPE, SlabType.DOUBLE)))
.acceptFunction(ExplosionDecay.func_215863_b());
return LootTable.builder().addLootPool(LootPool.builder().name("main").rolls(ConstantRange.of(1)).addEntry(entry));
}
private static LootTable.Builder genRegular(Block b) {
LootEntry.Builder<?> entry = ItemLootEntry.builder(b);
LootPool.Builder pool = LootPool.builder().name("main").rolls(ConstantRange.of(1)).addEntry(entry)
.acceptCondition(SurvivesExplosion.builder());
return LootTable.builder().addLootPool(pool);
private static Path getPath(Path root, ResourceLocation res) {
return root.resolve("data/" + res.getNamespace() + "/loot_tables/blocks/" + res.getPath() + ".json");
}
@Nonnull
@ -79,4 +70,27 @@ public class BlockLootProvider implements IDataProvider {
public String getName() {
return "Nature's Aura Loot";
}
// What a mess
private static class LootTableHooks extends BlockLootTables {
public static LootTable.Builder genLeaves(Block block, Block drop) {
return func_218540_a(block, drop, 0.05F, 0.0625F, 0.083333336F, 0.1F);
}
public static LootTable.Builder genSlab(Block block) {
return func_218513_d(block);
}
public static LootTable.Builder genRegular(Block block) {
return func_218546_a(block);
}
public static LootTable.Builder genSilkOnly(Block block) {
return func_218561_b(block);
}
public static <T> T survivesExplosion(Block block, ILootConditionConsumer<T> then) {
return func_218560_a(block, then);
}
}
}

View file

@ -9,6 +9,7 @@ import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.settings.ParticleStatus;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@ -29,14 +30,14 @@ public final class ParticleHandler {
public static void spawnParticle(Supplier<Particle> particle, double x, double y, double z) {
if (Minecraft.getInstance().player.getDistanceSq(x, y, z) <= range * range) {
Minecraft mc = Minecraft.getInstance();
if (ModConfig.client.respectVanillaParticleSettings) {
int setting = mc.gameSettings.particles.func_216832_b();
if (setting != 0 &&
(setting != 1 || mc.world.rand.nextInt(3) != 0) &&
(setting != 2 || mc.world.rand.nextInt(10) != 0))
if (ModConfig.instance.respectVanillaParticleSettings.get()) {
ParticleStatus setting = mc.gameSettings.particles;
if (setting != ParticleStatus.ALL &&
(setting != ParticleStatus.DECREASED || mc.world.rand.nextInt(3) != 0) &&
(setting != ParticleStatus.MINIMAL || mc.world.rand.nextInt(10) != 0))
return;
}
double setting = ModConfig.client.particleAmount;
double setting = ModConfig.instance.particleAmount.get();
if (setting < 1 && mc.world.rand.nextDouble() > setting)
return;

View file

@ -2,6 +2,8 @@ package de.ellpeck.naturesaura.proxy;
import de.ellpeck.naturesaura.compat.Compat;
import de.ellpeck.naturesaura.events.ClientEvents;
import de.ellpeck.naturesaura.gui.GuiEnderCrate;
import de.ellpeck.naturesaura.gui.ModContainers;
import de.ellpeck.naturesaura.particles.ParticleHandler;
import de.ellpeck.naturesaura.particles.ParticleMagic;
import de.ellpeck.naturesaura.reg.IColorProvidingBlock;
@ -11,6 +13,7 @@ import de.ellpeck.naturesaura.renderers.PlayerLayerTrinkets;
import de.ellpeck.naturesaura.renderers.SupporterFancyHandler;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScreenManager;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.client.renderer.color.ItemColors;
import net.minecraft.client.renderer.entity.PlayerRenderer;
@ -33,6 +36,8 @@ public class ClientProxy implements IProxy {
public void preInit(FMLCommonSetupEvent event) {
MinecraftForge.EVENT_BUS.register(new ClientEvents());
Compat.preInitClient();
ScreenManager.registerFactory(ModContainers.ENDER_CRATE, GuiEnderCrate::new);
ScreenManager.registerFactory(ModContainers.ENDER_ACCESS, GuiEnderCrate::new);
}
@Override

View file

@ -18,6 +18,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.FlowerBlock;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.passive.SheepEntity;
import net.minecraft.item.DyeColor;
import net.minecraft.item.Item;
@ -323,14 +324,16 @@ public final class ModRecipes {
NaturesAuraAPI.NETHER_ORES.add(new WeightedOre("oreCobalt", 50));
NaturesAuraAPI.NETHER_ORES.add(new WeightedOre("oreArdite", 50));*/
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(new ResourceLocation("egg"), 2500);
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(new ResourceLocation("snowball"), 3500);
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(new ResourceLocation("small_fireball"), 15000);
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(new ResourceLocation("ender_pearl"), 30000);
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(new ResourceLocation("xp_bottle"), 75000);
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(new ResourceLocation("arrow"), 10000);
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(new ResourceLocation("shulker_bullet"), 250000);
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(new ResourceLocation("llama_spit"), 80000);
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(EntityType.EGG, 2500);
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(EntityType.SNOWBALL, 3500);
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(EntityType.SMALL_FIREBALL, 15000);
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(EntityType.ENDER_PEARL, 30000);
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(EntityType.EXPERIENCE_BOTTLE, 75000);
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(EntityType.ARROW, 10000);
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(EntityType.SPECTRAL_ARROW, 15000);
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(EntityType.SHULKER_BULLET, 250000);
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(EntityType.LLAMA_SPIT, 80000);
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(EntityType.TRIDENT, 3000000);
}
private static void spawner(String name, String entity, int aura, int time, Ingredient... ings) {

View file

@ -3,13 +3,17 @@ package de.ellpeck.naturesaura.reg;
import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.ModConfig;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.misc.IWorldData;
import de.ellpeck.naturesaura.blocks.*;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityEnderCrate;
import de.ellpeck.naturesaura.entities.EntityEffectInhibitor;
import de.ellpeck.naturesaura.entities.EntityMoverMinecart;
import de.ellpeck.naturesaura.entities.ModEntities;
import de.ellpeck.naturesaura.entities.render.RenderEffectInhibitor;
import de.ellpeck.naturesaura.entities.render.RenderMoverMinecart;
import de.ellpeck.naturesaura.gui.ContainerEnderCrate;
import de.ellpeck.naturesaura.gui.ModContainers;
import de.ellpeck.naturesaura.items.*;
import de.ellpeck.naturesaura.items.tools.*;
import de.ellpeck.naturesaura.misc.BlockLootProvider;
@ -24,15 +28,19 @@ import net.minecraft.data.DataGenerator;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.potion.Effect;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.common.extensions.IForgeContainerType;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent;
import net.minecraftforge.items.IItemHandler;
import java.util.HashSet;
import java.util.Set;
@ -101,9 +109,9 @@ public final class ModRegistry {
new BlockDimensionRail("end", DimensionType.THE_END, DimensionType.OVERWORLD)
);
if (ModConfig.enabledFeatures.rfConverter)
if (ModConfig.instance.rfConverter.get())
event.getRegistry().register(new BlockRFConverter());
if (ModConfig.enabledFeatures.chunkLoader)
if (ModConfig.instance.chunkLoader.get())
event.getRegistry().register(new BlockChunkLoader());
Helper.populateObjectHolders(ModBlocks.class, event.getRegistry());
@ -121,11 +129,11 @@ public final class ModRegistry {
Item temp;
event.getRegistry().registerAll(
new Pickaxe("infused_iron_pickaxe", NAItemTier.INFUSED, 8, 3.2F),
new Axe("infused_iron_axe", NAItemTier.INFUSED, 8.25F, 3.2F),
new Shovel("infused_iron_shovel", NAItemTier.INFUSED, 8.25F, 3.2F),
new Hoe("infused_iron_hoe", NAItemTier.INFUSED, 3.2F),
new Sword("infused_iron_sword", NAItemTier.INFUSED, 3, 3), // TODO dmg and speed values need to be changed
new Pickaxe("infused_iron_pickaxe", NAItemTier.INFUSED, 1, -2.8F),
new Axe("infused_iron_axe", NAItemTier.INFUSED, 6.0F, -3.1F),
new Shovel("infused_iron_shovel", NAItemTier.INFUSED, 1.5F, -3.0F),
new Hoe("infused_iron_hoe", NAItemTier.INFUSED, -1.0F),
new Sword("infused_iron_sword", NAItemTier.INFUSED, 3, -2.4F),
new Armor("infused_iron_helmet", NAArmorMaterial.INFUSED, EquipmentSlotType.HEAD),
new Armor("infused_iron_chest", NAArmorMaterial.INFUSED, EquipmentSlotType.CHEST),
new Armor("infused_iron_pants", NAArmorMaterial.INFUSED, EquipmentSlotType.LEGS),
@ -182,6 +190,23 @@ public final class ModRegistry {
Helper.populateObjectHolders(ModPotions.class, event.getRegistry());
}
@SubscribeEvent
public static void registerContainers(RegistryEvent.Register<ContainerType<?>> event) {
event.getRegistry().registerAll(
IForgeContainerType.create((windowId, inv, data) -> {
TileEntity tile = inv.player.world.getTileEntity(data.readBlockPos());
if (tile instanceof TileEntityEnderCrate)
return new ContainerEnderCrate(ModContainers.ENDER_CRATE, windowId, inv.player, ((TileEntityEnderCrate) tile).getItemHandler(null));
return null;
}).setRegistryName("ender_crate"),
IForgeContainerType.create((windowId, inv, data) -> {
IItemHandler handler = IWorldData.getOverworldData(inv.player.world).getEnderStorage(data.readString());
return new ContainerEnderCrate(ModContainers.ENDER_ACCESS, windowId, inv.player, handler);
}).setRegistryName("ender_access")
);
Helper.populateObjectHolders(ModContainers.class, event.getRegistry());
}
@SubscribeEvent
public static void registerEntities(RegistryEvent.Register<EntityType<?>> event) {
event.getRegistry().registerAll(

View file

@ -1,6 +1,5 @@
package de.ellpeck.naturesaura.reg;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.items.ModItems;
import net.minecraft.item.IItemTier;
import net.minecraft.item.crafting.Ingredient;
@ -9,7 +8,7 @@ import net.minecraft.util.LazyLoadBase;
import java.util.function.Supplier;
public enum NAItemTier implements IItemTier {
INFUSED(3, 300, 6.25F, 2.25F, 16, () -> Ingredient.fromItems(ModItems.INFUSED_IRON));
INFUSED(2, 250, 6.0F, 2.0F, 14, () -> Ingredient.fromItems(ModItems.INFUSED_IRON));
private final int harvestLevel;
private final int maxUses;
@ -27,26 +26,32 @@ public enum NAItemTier implements IItemTier {
this.repairMaterial = new LazyLoadBase<>(repairMaterialIn);
}
@Override
public int getMaxUses() {
return this.maxUses;
}
@Override
public float getEfficiency() {
return this.efficiency;
}
@Override
public float getAttackDamage() {
return this.attackDamage;
}
@Override
public int getHarvestLevel() {
return this.harvestLevel;
}
@Override
public int getEnchantability() {
return this.enchantability;
}
@Override
public Ingredient getRepairMaterial() {
return this.repairMaterial.getValue();
}

View file

@ -66,7 +66,7 @@
"item.naturesaura.ancient_stick": "Ancient Wood Rod",
"item.naturesaura.aura_cache": "Aura Cache",
"item.naturesaura.color_changer": "Bucket of Infinite Color",
"item.naturesaura.book": "Book of Natural Aura",
"item.naturesaura.book.name": "Book of Natural Aura",
"item.naturesaura.shockwave_creator": "Amulet of Wrath",
"item.naturesaura.multiblock_maker": "Multiblock Maker",
"item.naturesaura.aura_bottle.naturesaura:overworld": "Bottled Sunlight",