Start migration
This commit is contained in:
parent
6630ce0cab
commit
47ed597358
491 changed files with 12045 additions and 11953 deletions
|
@ -5,7 +5,7 @@ import java.util.Map;
|
|||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
import net.minecraft.world.item.ItemConvertible;
|
||||
import ru.betterend.blocks.HydraluxPetalColoredBlock;
|
||||
import ru.betterend.blocks.complex.ColoredMaterial;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
@ -18,25 +18,24 @@ public class FlamboyantRefabricatedIntegration extends ModIntegration {
|
|||
|
||||
@Override
|
||||
public void register() {
|
||||
/*Class<?> fDyeColor = getClass("com.github.EltrutCo.flamboyant.items.FDyeColor");
|
||||
Object[] values = getStaticFieldValue(fDyeColor, "VALUES");
|
||||
|
||||
if (values == null) {
|
||||
return;
|
||||
}*/
|
||||
|
||||
/*
|
||||
* Class<?> fDyeColor =
|
||||
* getClass("com.github.EltrutCo.flamboyant.items.FDyeColor"); Object[] values =
|
||||
* getStaticFieldValue(fDyeColor, "VALUES");
|
||||
*
|
||||
* if (values == null) { return; }
|
||||
*/
|
||||
|
||||
Map<Integer, String> colors = Maps.newHashMap();
|
||||
Map<Integer, ItemConvertible> dyes = Maps.newHashMap();
|
||||
/*for (Object val: values) {
|
||||
Integer color = (Integer) getFieldValue(fDyeColor, "signColor", val);
|
||||
String name = (String) getFieldValue(fDyeColor, "name", val);
|
||||
if (color != null && name != null) {
|
||||
colors.put(color, name);
|
||||
System.out.println(name + " " + color + " " + new Color(color));
|
||||
dyes.put(color, getItem(name + "_dye"));
|
||||
}
|
||||
}*/
|
||||
|
||||
/*
|
||||
* for (Object val: values) { Integer color = (Integer) getFieldValue(fDyeColor,
|
||||
* "signColor", val); String name = (String) getFieldValue(fDyeColor, "name",
|
||||
* val); if (color != null && name != null) { colors.put(color, name);
|
||||
* System.out.println(name + " " + color + " " + new Color(color));
|
||||
* dyes.put(color, getItem(name + "_dye")); } }
|
||||
*/
|
||||
|
||||
addColor("fead1d", "amber", colors, dyes);
|
||||
addColor("bd9a5f", "beige", colors, dyes);
|
||||
addColor("edeada", "cream", colors, dyes);
|
||||
|
@ -53,15 +52,15 @@ public class FlamboyantRefabricatedIntegration extends ModIntegration {
|
|||
addColor("6bb1cf", "sky_blue", colors, dyes);
|
||||
addColor("6e8c9c", "slate_gray", colors, dyes);
|
||||
addColor("b02454", "violet", colors, dyes);
|
||||
|
||||
|
||||
new ColoredMaterial(HydraluxPetalColoredBlock::new, EndBlocks.HYDRALUX_PETAL_BLOCK, colors, dyes, true);
|
||||
}
|
||||
|
||||
|
||||
private void addColor(String hex, String name, Map<Integer, String> colors, Map<Integer, ItemConvertible> dyes) {
|
||||
int color = MHelper.color(hex);
|
||||
colors.put(color, name);
|
||||
dyes.put(color, getItem(name + "_dye"));
|
||||
|
||||
|
||||
System.out.println(name + " " + color + " " + new Color(color));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,16 +7,16 @@ import java.lang.reflect.Method;
|
|||
|
||||
import net.fabricmc.fabric.api.tag.TagRegistry;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tag.BlockTags;
|
||||
import net.minecraft.tag.ItemTags;
|
||||
import net.minecraft.tag.Tag;
|
||||
import net.minecraft.tag.Tag.Identified;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.tags.Tag.Identified;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.GenerationStep;
|
||||
|
@ -27,63 +27,65 @@ import ru.betterend.world.features.EndFeature;
|
|||
|
||||
public abstract class ModIntegration {
|
||||
private final String modID;
|
||||
|
||||
public void register() {}
|
||||
|
||||
public void addBiomes() {}
|
||||
|
||||
|
||||
public void register() {
|
||||
}
|
||||
|
||||
public void addBiomes() {
|
||||
}
|
||||
|
||||
public ModIntegration(String modID) {
|
||||
this.modID = modID;
|
||||
}
|
||||
|
||||
public Identifier getID(String name) {
|
||||
return new Identifier(modID, name);
|
||||
|
||||
public ResourceLocation getID(String name) {
|
||||
return new ResourceLocation(modID, name);
|
||||
}
|
||||
|
||||
|
||||
public Block getBlock(String name) {
|
||||
return Registry.BLOCK.get(getID(name));
|
||||
}
|
||||
|
||||
|
||||
public Item getItem(String name) {
|
||||
return Registry.ITEM.get(getID(name));
|
||||
}
|
||||
|
||||
public BlockState getDefaultState(String name) {
|
||||
return getBlock(name).getDefaultState();
|
||||
return getBlock(name).defaultBlockState();
|
||||
}
|
||||
|
||||
|
||||
public RegistryKey<Biome> getKey(String name) {
|
||||
return RegistryKey.of(Registry.BIOME_KEY, getID(name));
|
||||
}
|
||||
|
||||
|
||||
public boolean modIsInstalled() {
|
||||
return FabricLoader.getInstance().isModLoaded(modID);
|
||||
}
|
||||
|
||||
|
||||
public EndFeature getFeature(String featureID, String configuredFeatureID, GenerationStep.Feature featureStep) {
|
||||
Feature<?> feature = Registry.FEATURE.get(getID(featureID));
|
||||
ConfiguredFeature<?, ?> featureConfigured = BuiltinRegistries.CONFIGURED_FEATURE.get(getID(configuredFeatureID));
|
||||
ConfiguredFeature<?, ?> featureConfigured = BuiltinRegistries.CONFIGURED_FEATURE
|
||||
.get(getID(configuredFeatureID));
|
||||
return new EndFeature(feature, featureConfigured, featureStep);
|
||||
}
|
||||
|
||||
|
||||
public EndFeature getFeature(String name, GenerationStep.Feature featureStep) {
|
||||
return getFeature(name, name, featureStep);
|
||||
}
|
||||
|
||||
|
||||
public ConfiguredFeature<?, ?> getConfiguredFeature(String name) {
|
||||
return BuiltinRegistries.CONFIGURED_FEATURE.get(getID(name));
|
||||
}
|
||||
|
||||
|
||||
public Biome getBiome(String name) {
|
||||
return BuiltinRegistries.BIOME.get(getID(name));
|
||||
}
|
||||
|
||||
|
||||
public Class<?> getClass(String path) {
|
||||
Class<?> cl = null;
|
||||
try {
|
||||
cl = Class.forName(path);
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
} catch (ClassNotFoundException e) {
|
||||
BetterEnd.LOGGER.error(e.getMessage());
|
||||
if (BetterEnd.isDevEnvironment()) {
|
||||
e.printStackTrace();
|
||||
|
@ -91,7 +93,7 @@ public abstract class ModIntegration {
|
|||
}
|
||||
return cl;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Object> T getStaticFieldValue(Class<?> cl, String name) {
|
||||
if (cl != null) {
|
||||
|
@ -100,14 +102,13 @@ public abstract class ModIntegration {
|
|||
if (field != null) {
|
||||
return (T) field.get(null);
|
||||
}
|
||||
}
|
||||
catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
|
||||
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public Object getFieldValue(Class<?> cl, String name, Object classInstance) {
|
||||
if (cl != null) {
|
||||
try {
|
||||
|
@ -115,20 +116,18 @@ public abstract class ModIntegration {
|
|||
if (field != null) {
|
||||
return field.get(classInstance);
|
||||
}
|
||||
}
|
||||
catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
|
||||
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public Method getMethod(Class<?> cl, String functionName, Class<?>... args) {
|
||||
if (cl != null) {
|
||||
try {
|
||||
return cl.getMethod(functionName, args);
|
||||
}
|
||||
catch (NoSuchMethodException | SecurityException e) {
|
||||
} catch (NoSuchMethodException | SecurityException e) {
|
||||
BetterEnd.LOGGER.error(e.getMessage());
|
||||
if (BetterEnd.isDevEnvironment()) {
|
||||
e.printStackTrace();
|
||||
|
@ -137,13 +136,12 @@ public abstract class ModIntegration {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public Object executeMethod(Object instance, Method method, Object... args) {
|
||||
if (method != null) {
|
||||
try {
|
||||
return method.invoke(instance, args);
|
||||
}
|
||||
catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||
BetterEnd.LOGGER.error(e.getMessage());
|
||||
if (BetterEnd.isDevEnvironment()) {
|
||||
e.printStackTrace();
|
||||
|
@ -152,7 +150,7 @@ public abstract class ModIntegration {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public Object getAndExecuteStatic(Class<?> cl, String functionName, Object... args) {
|
||||
if (cl != null) {
|
||||
Class<?>[] classes = new Class<?>[args.length];
|
||||
|
@ -164,9 +162,10 @@ public abstract class ModIntegration {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Object> T getAndExecuteRuntime(Class<?> cl, Object instance, String functionName, Object... args) {
|
||||
public <T extends Object> T getAndExecuteRuntime(Class<?> cl, Object instance, String functionName,
|
||||
Object... args) {
|
||||
if (instance != null) {
|
||||
Class<?>[] classes = new Class<?>[args.length];
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
|
@ -177,15 +176,15 @@ public abstract class ModIntegration {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public Object newInstance(Class<?> cl, Object... args) {
|
||||
if (cl != null) {
|
||||
for (Constructor<?> constructor: cl.getConstructors()) {
|
||||
for (Constructor<?> constructor : cl.getConstructors()) {
|
||||
if (constructor.getParameterCount() == args.length) {
|
||||
try {
|
||||
return constructor.newInstance(args);
|
||||
}
|
||||
catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
|
||||
| InvocationTargetException e) {
|
||||
BetterEnd.LOGGER.error(e.getMessage());
|
||||
if (BetterEnd.isDevEnvironment()) {
|
||||
e.printStackTrace();
|
||||
|
@ -196,15 +195,15 @@ public abstract class ModIntegration {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public Tag.Identified<Item> getItemTag(String name) {
|
||||
Identifier id = getID(name);
|
||||
ResourceLocation id = getID(name);
|
||||
Tag<Item> tag = ItemTags.getTagGroup().getTag(id);
|
||||
return tag == null ? (Identified<Item>) TagRegistry.item(id) : (Identified<Item>) tag;
|
||||
}
|
||||
|
||||
|
||||
public Tag.Identified<Block> getBlockTag(String name) {
|
||||
Identifier id = getID(name);
|
||||
ResourceLocation id = getID(name);
|
||||
Tag<Block> tag = BlockTags.getTagGroup().getTag(id);
|
||||
return tag == null ? (Identified<Block>) TagRegistry.block(id) : (Identified<Block>) tag;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package ru.betterend.integration;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tag.Tag;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.tags.Tag;
|
||||
import ru.betterend.registry.EndItems;
|
||||
import ru.betterend.util.TagHelper;
|
||||
|
||||
|
@ -16,9 +16,10 @@ public class NourishIntegration extends ModIntegration {
|
|||
Tag.Identified<Item> fruit = getItemTag("fruit");
|
||||
Tag.Identified<Item> protein = getItemTag("protein");
|
||||
Tag.Identified<Item> sweets = getItemTag("sweets");
|
||||
|
||||
|
||||
TagHelper.addTag(fats, EndItems.END_FISH_RAW, EndItems.END_FISH_COOKED);
|
||||
TagHelper.addTag(fruit, EndItems.SHADOW_BERRY_RAW, EndItems.SHADOW_BERRY_COOKED, EndItems.BLOSSOM_BERRY, EndItems.SHADOW_BERRY_JELLY, EndItems.SWEET_BERRY_JELLY);
|
||||
TagHelper.addTag(fruit, EndItems.SHADOW_BERRY_RAW, EndItems.SHADOW_BERRY_COOKED, EndItems.BLOSSOM_BERRY,
|
||||
EndItems.SHADOW_BERRY_JELLY, EndItems.SWEET_BERRY_JELLY);
|
||||
TagHelper.addTag(protein, EndItems.END_FISH_RAW, EndItems.END_FISH_COOKED);
|
||||
TagHelper.addTag(sweets, EndItems.SHADOW_BERRY_JELLY, EndItems.SWEET_BERRY_JELLY);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ru.betterend.integration.byg;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import ru.betterend.blocks.basis.EndWallPlantBlock;
|
||||
import ru.betterend.blocks.basis.VineBlock;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
@ -8,8 +8,9 @@ import ru.betterend.registry.EndBlocks;
|
|||
public class BYGBlocks {
|
||||
public static final Block IVIS_MOSS = EndBlocks.registerBlock("ivis_moss", new EndWallPlantBlock());
|
||||
public static final Block NIGHTSHADE_MOSS = EndBlocks.registerBlock("nightshade_moss", new EndWallPlantBlock());
|
||||
|
||||
|
||||
public static final Block IVIS_VINE = EndBlocks.registerBlock("ivis_vine", new VineBlock());
|
||||
|
||||
public static void register() {}
|
||||
|
||||
public static void register() {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package ru.betterend.integration.byg;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.collection.WeightedList;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
@ -32,31 +32,31 @@ public class BYGIntegration extends ModIntegration {
|
|||
@Override
|
||||
public void addBiomes() {
|
||||
BYGBiomes.addBiomes();
|
||||
|
||||
|
||||
Class<?> biomeClass = this.getClass("corgiaoc.byg.common.world.biome.BYGEndBiome");
|
||||
List<Object> biomes = this.getStaticFieldValue(biomeClass, "BYG_END_BIOMES");
|
||||
|
||||
|
||||
if (biomes != null && biomeClass != null) {
|
||||
biomes.forEach((obj) -> {
|
||||
Biome biome = this.getAndExecuteRuntime(biomeClass, obj, "getBiome");
|
||||
if (biome != null) {
|
||||
Identifier biomeID = BuiltinRegistries.BIOME.getId(biome);
|
||||
ResourceLocation biomeID = BuiltinRegistries.BIOME.getId(biome);
|
||||
EndBiome endBiome = EndBiomes.getBiome(biomeID);
|
||||
Biome edge = this.getAndExecuteRuntime(biomeClass, obj, "getEdge");
|
||||
if (edge != null) {
|
||||
Identifier edgeID = BuiltinRegistries.BIOME.getId(edge);
|
||||
ResourceLocation edgeID = BuiltinRegistries.BIOME.getId(edge);
|
||||
EndBiomes.LAND_BIOMES.removeMutableBiome(edgeID);
|
||||
EndBiomes.VOID_BIOMES.removeMutableBiome(edgeID);
|
||||
EndBiome edgeBiome = EndBiomes.getBiome(edgeID);
|
||||
endBiome.setEdge(edgeBiome);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Boolean isVoid = this.getAndExecuteRuntime(biomeClass, obj, "isVoid");
|
||||
if (isVoid != null && isVoid.booleanValue()) {
|
||||
EndBiomes.LAND_BIOMES.removeMutableBiome(biomeID);
|
||||
EndBiomes.VOID_BIOMES.addBiomeMutable(endBiome);
|
||||
}
|
||||
WeightedList<Identifier> subBiomes = this.getAndExecuteRuntime(biomeClass, obj, "getHills");
|
||||
WeightedList<ResourceLocation> subBiomes = this.getAndExecuteRuntime(biomeClass, obj,
|
||||
"getHills");
|
||||
if (subBiomes != null) {
|
||||
subBiomes.stream().collect(Collectors.toList()).forEach((id) -> {
|
||||
EndBiome subBiome = EndBiomes.getBiome(id);
|
||||
|
|
|
@ -2,7 +2,7 @@ package ru.betterend.integration.byg.biomes;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.SpawnGroup;
|
||||
import net.minecraft.world.entity.SpawnGroup;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.BiomeEffects;
|
||||
|
@ -17,15 +17,15 @@ public class EterialGrove extends EndBiome {
|
|||
public EterialGrove() {
|
||||
super(makeDef());
|
||||
}
|
||||
|
||||
|
||||
private static BiomeDefinition makeDef() {
|
||||
Biome biome = Integrations.BYG.getBiome("ethereal_islands");
|
||||
BiomeEffects effects = biome.getEffects();
|
||||
|
||||
|
||||
BiomeDefinition def = new BiomeDefinition("eterial_grove")
|
||||
.setSurface(biome.getGenerationSettings().getSurfaceBuilder().get())
|
||||
.addFeature(BYGFeatures.BIG_ETHER_TREE);
|
||||
|
||||
|
||||
if (BetterEnd.isClient()) {
|
||||
SoundEvent loop = effects.getLoopSound().get();
|
||||
SoundEvent music = effects.getMusic().get().getSound();
|
||||
|
@ -33,14 +33,14 @@ public class EterialGrove extends EndBiome {
|
|||
SoundEvent mood = effects.getMoodSound().get().getSound();
|
||||
def.setLoop(loop).setMusic(music).setAdditions(additions).setMood(mood);
|
||||
}
|
||||
|
||||
for (SpawnGroup group: SpawnGroup.values()) {
|
||||
|
||||
for (SpawnGroup group : SpawnGroup.values()) {
|
||||
List<SpawnEntry> list = biome.getSpawnSettings().getSpawnEntry(group);
|
||||
list.forEach((entry) -> {
|
||||
def.addMobSpawn(entry);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@ package ru.betterend.integration.byg.biomes;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.SpawnGroup;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.world.entity.SpawnGroup;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.BiomeEffects;
|
||||
|
@ -20,25 +20,19 @@ public class NightshadeRedwoods extends EndBiome {
|
|||
public NightshadeRedwoods() {
|
||||
super(makeDef());
|
||||
}
|
||||
|
||||
|
||||
private static BiomeDefinition makeDef() {
|
||||
Biome biome = Integrations.BYG.getBiome("nightshade_forest");
|
||||
BiomeEffects effects = biome.getEffects();
|
||||
|
||||
BiomeDefinition def = new BiomeDefinition("nightshade_redwoods")
|
||||
.setFogColor(140, 108, 47)
|
||||
.setFogDensity(1.5F)
|
||||
.setWaterAndFogColor(55, 70, 186)
|
||||
.setFoliageColor(122, 17, 155)
|
||||
|
||||
BiomeDefinition def = new BiomeDefinition("nightshade_redwoods").setFogColor(140, 108, 47).setFogDensity(1.5F)
|
||||
.setWaterAndFogColor(55, 70, 186).setFoliageColor(122, 17, 155)
|
||||
.setParticles(ParticleTypes.REVERSE_PORTAL, 0.002F)
|
||||
.setSurface(biome.getGenerationSettings().getSurfaceBuilder().get())
|
||||
.setGrassColor(48, 13, 89)
|
||||
.setPlantsColor(200, 125, 9)
|
||||
.addFeature(EndFeatures.END_LAKE_RARE)
|
||||
.addFeature(BYGFeatures.NIGHTSHADE_REDWOOD_TREE)
|
||||
.addFeature(BYGFeatures.NIGHTSHADE_MOSS_WOOD)
|
||||
.setSurface(biome.getGenerationSettings().getSurfaceBuilder().get()).setGrassColor(48, 13, 89)
|
||||
.setPlantsColor(200, 125, 9).addFeature(EndFeatures.END_LAKE_RARE)
|
||||
.addFeature(BYGFeatures.NIGHTSHADE_REDWOOD_TREE).addFeature(BYGFeatures.NIGHTSHADE_MOSS_WOOD)
|
||||
.addFeature(BYGFeatures.NIGHTSHADE_MOSS);
|
||||
|
||||
|
||||
if (BetterEnd.isClient()) {
|
||||
SoundEvent loop = effects.getLoopSound().get();
|
||||
SoundEvent music = effects.getMusic().get().getSound();
|
||||
|
@ -51,14 +45,14 @@ public class NightshadeRedwoods extends EndBiome {
|
|||
def.addFeature(Feature.VEGETAL_DECORATION, feature.get());
|
||||
});
|
||||
});
|
||||
|
||||
for (SpawnGroup group: SpawnGroup.values()) {
|
||||
|
||||
for (SpawnGroup group : SpawnGroup.values()) {
|
||||
List<SpawnEntry> list = biome.getSpawnSettings().getSpawnEntry(group);
|
||||
list.forEach((entry) -> {
|
||||
def.addMobSpawn(entry);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,13 @@ package ru.betterend.integration.byg.biomes;
|
|||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.SpawnGroup;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.entity.SpawnGroup;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.BiomeEffects;
|
||||
import net.minecraft.world.biome.SpawnSettings.SpawnEntry;
|
||||
|
@ -27,23 +27,18 @@ public class OldBulbisGardens extends EndBiome {
|
|||
public OldBulbisGardens() {
|
||||
super(makeDef());
|
||||
}
|
||||
|
||||
|
||||
private static BiomeDefinition makeDef() {
|
||||
Biome biome = Integrations.BYG.getBiome("bulbis_gardens");
|
||||
BiomeEffects effects = biome.getEffects();
|
||||
|
||||
|
||||
Block ivis = Integrations.BYG.getBlock("ivis_phylium");
|
||||
Block origin = biome.getGenerationSettings().getSurfaceConfig().getTopMaterial().getBlock();
|
||||
BiomeDefinition def = new BiomeDefinition("old_bulbis_gardens")
|
||||
.setFogColor(215, 132, 207)
|
||||
.setFogDensity(1.8F)
|
||||
.setWaterAndFogColor(40, 0, 56)
|
||||
.setFoliageColor(122, 17, 155)
|
||||
.setParticles(ParticleTypes.REVERSE_PORTAL, 0.002F)
|
||||
.setSurface(ivis, origin)
|
||||
.addFeature(EndFeatures.END_LAKE_RARE)
|
||||
.addFeature(BYGFeatures.OLD_BULBIS_TREE);
|
||||
|
||||
BiomeDefinition def = new BiomeDefinition("old_bulbis_gardens").setFogColor(215, 132, 207).setFogDensity(1.8F)
|
||||
.setWaterAndFogColor(40, 0, 56).setFoliageColor(122, 17, 155)
|
||||
.setParticles(ParticleTypes.REVERSE_PORTAL, 0.002F).setSurface(ivis, origin)
|
||||
.addFeature(EndFeatures.END_LAKE_RARE).addFeature(BYGFeatures.OLD_BULBIS_TREE);
|
||||
|
||||
if (BetterEnd.isClient()) {
|
||||
SoundEvent loop = effects.getLoopSound().get();
|
||||
SoundEvent music = effects.getMusic().get().getSound();
|
||||
|
@ -51,25 +46,27 @@ public class OldBulbisGardens extends EndBiome {
|
|||
SoundEvent mood = effects.getMoodSound().get().getSound();
|
||||
def.setLoop(loop).setMusic(music).setAdditions(additions).setMood(mood);
|
||||
}
|
||||
|
||||
for (SpawnGroup group: SpawnGroup.values()) {
|
||||
|
||||
for (SpawnGroup group : SpawnGroup.values()) {
|
||||
List<SpawnEntry> list = biome.getSpawnSettings().getSpawnEntry(group);
|
||||
list.forEach((entry) -> {
|
||||
def.addMobSpawn(entry);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
List<List<Supplier<ConfiguredFeature<?, ?>>>> features = biome.getGenerationSettings().getFeatures();
|
||||
List<Supplier<ConfiguredFeature<?, ?>>> vegetal = features.get(Feature.VEGETAL_DECORATION.ordinal());
|
||||
if (vegetal.size() > 2) {
|
||||
Supplier<ConfiguredFeature<?, ?>> getter;
|
||||
// Trees (first two features)
|
||||
// I couldn't process them with conditions, so that's why they are hardcoded (paulevs)
|
||||
// I couldn't process them with conditions, so that's why they are hardcoded
|
||||
// (paulevs)
|
||||
for (int i = 0; i < 2; i++) {
|
||||
getter = vegetal.get(i);
|
||||
ConfiguredFeature<?, ?> feature = getter.get();
|
||||
Identifier id = BetterEnd.makeID("obg_feature_" + i);
|
||||
feature = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, feature.decorate(ConfiguredFeatures.Decorators.SQUARE_HEIGHTMAP).repeatRandomly(1));
|
||||
ResourceLocation id = BetterEnd.makeID("obg_feature_" + i);
|
||||
feature = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id,
|
||||
feature.decorate(ConfiguredFeatures.Decorators.SQUARE_HEIGHTMAP).repeatRandomly(1));
|
||||
def.addFeature(Feature.VEGETAL_DECORATION, feature);
|
||||
}
|
||||
// Grasses and other features
|
||||
|
@ -79,13 +76,11 @@ public class OldBulbisGardens extends EndBiome {
|
|||
def.addFeature(Feature.VEGETAL_DECORATION, feature);
|
||||
}
|
||||
}
|
||||
|
||||
def.addFeature(EndFeatures.PURPLE_POLYPORE)
|
||||
.addFeature(BYGFeatures.IVIS_MOSS_WOOD)
|
||||
.addFeature(BYGFeatures.IVIS_MOSS)
|
||||
.addFeature(BYGFeatures.IVIS_VINE)
|
||||
.addFeature(BYGFeatures.IVIS_SPROUT);
|
||||
|
||||
|
||||
def.addFeature(EndFeatures.PURPLE_POLYPORE).addFeature(BYGFeatures.IVIS_MOSS_WOOD)
|
||||
.addFeature(BYGFeatures.IVIS_MOSS).addFeature(BYGFeatures.IVIS_VINE)
|
||||
.addFeature(BYGFeatures.IVIS_SPROUT);
|
||||
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,10 @@ import java.util.Random;
|
|||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -21,22 +21,27 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
|
||||
public class BigEtherTreeFeature extends DefaultFeature {
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false;
|
||||
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
|
||||
return false;
|
||||
|
||||
BlockState log = Integrations.BYG.getDefaultState("ether_log");
|
||||
BlockState wood = Integrations.BYG.getDefaultState("ether_wood");
|
||||
//BlockState leaves = Integrations.BYG.getDefaultState("ether_leaves");
|
||||
Function<BlockPos, BlockState> splinePlacer = (bpos) -> { return log; };
|
||||
Function<BlockState, Boolean> replace = (state) -> {
|
||||
return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT) || state.getMaterial().isReplaceable();
|
||||
// BlockState leaves = Integrations.BYG.getDefaultState("ether_leaves");
|
||||
Function<BlockPos, BlockState> splinePlacer = (bpos) -> {
|
||||
return log;
|
||||
};
|
||||
|
||||
Function<BlockState, Boolean> replace = (state) -> {
|
||||
return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)
|
||||
|| state.getMaterial().isReplaceable();
|
||||
};
|
||||
|
||||
int height = MHelper.randRange(40, 60, random);
|
||||
List<Vector3f> trunk = SplineHelper.makeSpline(0, 0, 0, 0, height, 0, height / 4);
|
||||
SplineHelper.offsetParts(trunk, random, 2F, 0, 2F);
|
||||
SDF sdf = SplineHelper.buildSDF(trunk, 2.3F, 0.8F, splinePlacer);
|
||||
|
||||
|
||||
int count = height / 15;
|
||||
for (int i = 1; i < count; i++) {
|
||||
float splinePos = (float) i / (float) count;
|
||||
|
@ -46,21 +51,22 @@ public class BigEtherTreeFeature extends DefaultFeature {
|
|||
List<Vector3f> branch = SplineHelper.makeSpline(0, 0, 0, length, 0, 0, points < 2 ? 2 : points);
|
||||
SplineHelper.powerOffset(branch, length, 2F);
|
||||
int rotCount = MHelper.randRange(5, 7, random);
|
||||
//float startRad = MathHelper.lerp(splinePos, 2.3F, 0.8F) * 0.8F;
|
||||
// float startRad = Mth.lerp(splinePos, 2.3F, 0.8F) * 0.8F;
|
||||
Vector3f start = SplineHelper.getPos(trunk, splinePos * (trunk.size() - 1));
|
||||
for (int j = 0; j < rotCount; j++) {
|
||||
float angle = startAngle + (float) j / rotCount * MHelper.PI2;
|
||||
List<Vector3f> br = SplineHelper.copySpline(branch);
|
||||
SplineHelper.offsetParts(br, random, 0, 1, 1);
|
||||
SplineHelper.rotateSpline(br, angle);
|
||||
|
||||
|
||||
SplineHelper.offset(br, start);
|
||||
SplineHelper.fillSpline(br, world, wood, pos, replace);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sdf.setReplaceFunction((state) -> {
|
||||
return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT) || state.getMaterial().isReplaceable();
|
||||
return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)
|
||||
|| state.getMaterial().isReplaceable();
|
||||
}).addPostProcess((info) -> {
|
||||
if (info.getState().equals(log) && (!info.getStateUp().equals(log) || !info.getStateDown().equals(log))) {
|
||||
return wood;
|
||||
|
@ -70,8 +76,9 @@ public class BigEtherTreeFeature extends DefaultFeature {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
//private void makeLeavesSphere(StructureWorldAccess world, BlockPos pos, BlockState leaves, Function<BlockState, Boolean> ignore) {
|
||||
//
|
||||
//}
|
||||
|
||||
// private void makeLeavesSphere(StructureWorldAccess world, BlockPos pos,
|
||||
// BlockState leaves, Function<BlockState, Boolean> ignore) {
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@ import java.util.Random;
|
|||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.LeavesBlock;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -33,19 +33,25 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
|
||||
public class GreatNightshadeTreeFeature extends DefaultFeature {
|
||||
private static final List<Vector3f> BRANCH;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false;
|
||||
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
|
||||
return false;
|
||||
|
||||
BlockState log = Integrations.BYG.getDefaultState("nightshade_log");
|
||||
BlockState wood = Integrations.BYG.getDefaultState("nightshade_wood");
|
||||
BlockState leaves = Integrations.BYG.getDefaultState("nightshade_leaves").with(LeavesBlock.DISTANCE, 1);
|
||||
BlockState leaves_flower = Integrations.BYG.getDefaultState("flowering_nightshade_leaves").with(LeavesBlock.DISTANCE, 1);
|
||||
|
||||
Function<BlockPos, BlockState> splinePlacer = (bpos) -> { return log; };
|
||||
BlockState leaves_flower = Integrations.BYG.getDefaultState("flowering_nightshade_leaves")
|
||||
.with(LeavesBlock.DISTANCE, 1);
|
||||
|
||||
Function<BlockPos, BlockState> splinePlacer = (bpos) -> {
|
||||
return log;
|
||||
};
|
||||
Function<BlockState, Boolean> replace = (state) -> {
|
||||
return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT) || state.getMaterial().isReplaceable();
|
||||
return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)
|
||||
|| state.getMaterial().isReplaceable();
|
||||
};
|
||||
Function<PosInfo, BlockState> post = (info) -> {
|
||||
if (info.getState().equals(log) && (!info.getStateUp().equals(log) || !info.getStateDown().equals(log))) {
|
||||
|
@ -56,15 +62,15 @@ public class GreatNightshadeTreeFeature extends DefaultFeature {
|
|||
Function<BlockState, Boolean> ignore = (state) -> {
|
||||
return state.equals(log) || state.equals(wood);
|
||||
};
|
||||
|
||||
|
||||
int height = MHelper.randRange(40, 60, random);
|
||||
List<Vector3f> trunk = SplineHelper.makeSpline(0, 0, 0, 0, height, 0, height / 4);
|
||||
SplineHelper.offsetParts(trunk, random, 0.8F, 0, 0.8F);
|
||||
|
||||
|
||||
if (!SplineHelper.canGenerate(trunk, pos, world, replace)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int count = height >> 2;
|
||||
float start = trunk.size() / 3F;
|
||||
float delta = trunk.size() * 0.6F;
|
||||
|
@ -83,20 +89,21 @@ public class GreatNightshadeTreeFeature extends DefaultFeature {
|
|||
SplineHelper.fillSpline(branch, world, wood, pos, replace);
|
||||
}
|
||||
SplineHelper.fillSpline(trunk, world, log, pos, ignore);
|
||||
|
||||
|
||||
SDF sdf = SplineHelper.buildSDF(trunk, 2.3F, 0.8F, splinePlacer);
|
||||
SDF roots = new SDFSphere().setRadius(2F).setBlock(log);
|
||||
roots = new SDFFlatWave().setIntensity(2F).setRaysCount(MHelper.randRange(5, 7, random)).setAngle(random.nextFloat() * MHelper.PI2).setSource(roots);
|
||||
roots = new SDFFlatWave().setIntensity(2F).setRaysCount(MHelper.randRange(5, 7, random))
|
||||
.setAngle(random.nextFloat() * MHelper.PI2).setSource(roots);
|
||||
sdf = new SDFSmoothUnion().setRadius(2F).setSourceA(sdf).setSourceB(roots);
|
||||
sdf.setReplaceFunction(replace).addPostProcess(post).fillRecursive(world, pos);
|
||||
Vector3f last = SplineHelper.getPos(trunk, trunk.size() - 1.75F);
|
||||
for (int y = 0; y < 8; y++) {
|
||||
BlockPos p = pos.add(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5);
|
||||
BlockPos p = pos.offset(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5);
|
||||
BlocksHelper.setWithoutUpdate(world, p, y == 4 ? wood : log);
|
||||
}
|
||||
|
||||
|
||||
for (int y = 0; y < 16; y++) {
|
||||
BlockPos p = pos.add(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5);
|
||||
BlockPos p = pos.offset(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5);
|
||||
if (world.isAir(p)) {
|
||||
BlocksHelper.setWithoutUpdate(world, p, leaves);
|
||||
}
|
||||
|
@ -116,8 +123,8 @@ public class GreatNightshadeTreeFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Mutable mut = new Mutable();
|
||||
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
Function<PosInfo, BlockState> leavesPost1 = (info) -> {
|
||||
if (info.getState().equals(log) || info.getState().equals(wood)) {
|
||||
for (int x = -6; x < 7; x++) {
|
||||
|
@ -133,7 +140,7 @@ public class GreatNightshadeTreeFeature extends DefaultFeature {
|
|||
mut.setY(y + info.getPos().getY());
|
||||
BlockState state = info.getState(mut);
|
||||
if (state.getBlock() instanceof LeavesBlock) {
|
||||
int distance = state.get(LeavesBlock.DISTANCE);
|
||||
int distance = state.getValue(LeavesBlock.DISTANCE);
|
||||
if (d < distance) {
|
||||
info.setState(mut, state.with(LeavesBlock.DISTANCE, d));
|
||||
}
|
||||
|
@ -149,15 +156,15 @@ public class GreatNightshadeTreeFeature extends DefaultFeature {
|
|||
if (info.getState().getBlock() instanceof LeavesBlock) {
|
||||
int distance = info.getState().get(LeavesBlock.DISTANCE);
|
||||
if (distance > MHelper.randRange(2, 4, random)) {
|
||||
return Blocks.AIR.getDefaultState();
|
||||
return Blocks.AIR.defaultBlockState();
|
||||
}
|
||||
for (Direction d: BlocksHelper.DIRECTIONS) {
|
||||
for (Direction d : BlocksHelper.DIRECTIONS) {
|
||||
int airCount = 0;
|
||||
if (info.getState(d).isAir()) {
|
||||
airCount ++;
|
||||
airCount++;
|
||||
}
|
||||
if (airCount > 5) {
|
||||
return Blocks.AIR.getDefaultState();
|
||||
return Blocks.AIR.defaultBlockState();
|
||||
}
|
||||
}
|
||||
if (random.nextInt(8) == 0) {
|
||||
|
@ -166,19 +173,19 @@ public class GreatNightshadeTreeFeature extends DefaultFeature {
|
|||
}
|
||||
return info.getState();
|
||||
};
|
||||
|
||||
|
||||
SDF canopy = new SDFCappedCone().setRadius1(12F).setRadius2(1f).setHeight(height * 0.3F).setBlock(leaves);
|
||||
canopy = new SDFDisplacement().setFunction((vec) -> { return MHelper.randRange(-3F, 3F, random); }).setSource(canopy);
|
||||
canopy.addPostProcess(leavesPost1).addPostProcess(leavesPost2).fillRecursiveIgnore(world, pos.add(0, height * 0.75, 0), ignore);
|
||||
|
||||
canopy = new SDFDisplacement().setFunction((vec) -> {
|
||||
return MHelper.randRange(-3F, 3F, random);
|
||||
}).setSource(canopy);
|
||||
canopy.addPostProcess(leavesPost1).addPostProcess(leavesPost2).fillRecursiveIgnore(world,
|
||||
pos.offset(0, height * 0.75, 0), ignore);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
BRANCH = Lists.newArrayList(new Vector3f(0, 0, 0),
|
||||
new Vector3f(0.25F, 0.1F, 0),
|
||||
new Vector3f(0.40F, 0.2F, 0),
|
||||
new Vector3f(0.50F, 0.4F, 0),
|
||||
new Vector3f(0.55F, 0.6F, 0));
|
||||
BRANCH = Lists.newArrayList(new Vector3f(0, 0, 0), new Vector3f(0.25F, 0.1F, 0), new Vector3f(0.40F, 0.2F, 0),
|
||||
new Vector3f(0.50F, 0.4F, 0), new Vector3f(0.55F, 0.6F, 0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@ import java.util.Random;
|
|||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.LeavesBlock;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -33,19 +33,24 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
|
||||
public class NightshadeRedwoodTreeFeature extends DefaultFeature {
|
||||
private static final List<Vector3f> BRANCH;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false;
|
||||
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
|
||||
return false;
|
||||
|
||||
BlockState log = Integrations.BYG.getDefaultState("nightshade_log");
|
||||
BlockState wood = Integrations.BYG.getDefaultState("nightshade_wood");
|
||||
BlockState leaves = Integrations.BYG.getDefaultState("nightshade_leaves");
|
||||
BlockState leaves_flower = Integrations.BYG.getDefaultState("flowering_nightshade_leaves");
|
||||
|
||||
Function<BlockPos, BlockState> splinePlacer = (bpos) -> { return log; };
|
||||
|
||||
Function<BlockPos, BlockState> splinePlacer = (bpos) -> {
|
||||
return log;
|
||||
};
|
||||
Function<BlockState, Boolean> replace = (state) -> {
|
||||
return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT) || state.getMaterial().isReplaceable();
|
||||
return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)
|
||||
|| state.getMaterial().isReplaceable();
|
||||
};
|
||||
Function<PosInfo, BlockState> post = (info) -> {
|
||||
if (info.getState().equals(log) && (!info.getStateUp().equals(log) || !info.getStateDown().equals(log))) {
|
||||
|
@ -56,15 +61,15 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
|
|||
Function<BlockState, Boolean> ignore = (state) -> {
|
||||
return state.equals(log) || state.equals(wood);
|
||||
};
|
||||
|
||||
|
||||
int height = MHelper.randRange(40, 60, random);
|
||||
List<Vector3f> trunk = SplineHelper.makeSpline(0, 0, 0, 0, height, 0, height / 4);
|
||||
SplineHelper.offsetParts(trunk, random, 0.8F, 0, 0.8F);
|
||||
|
||||
|
||||
if (!SplineHelper.canGenerate(trunk, pos, world, replace)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int count = height >> 2;
|
||||
float start = trunk.size() / 3F;
|
||||
float delta = trunk.size() * 0.6F;
|
||||
|
@ -83,20 +88,21 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
|
|||
SplineHelper.offset(branch, offset);
|
||||
SplineHelper.fillSpline(branch, world, wood, pos, replace);
|
||||
}
|
||||
|
||||
|
||||
SDF sdf = SplineHelper.buildSDF(trunk, 2.3F, 0.8F, splinePlacer);
|
||||
SDF roots = new SDFSphere().setRadius(2F).setBlock(log);
|
||||
roots = new SDFFlatWave().setIntensity(2F).setRaysCount(MHelper.randRange(5, 7, random)).setAngle(random.nextFloat() * MHelper.PI2).setSource(roots);
|
||||
roots = new SDFFlatWave().setIntensity(2F).setRaysCount(MHelper.randRange(5, 7, random))
|
||||
.setAngle(random.nextFloat() * MHelper.PI2).setSource(roots);
|
||||
sdf = new SDFSmoothUnion().setRadius(2F).setSourceA(sdf).setSourceB(roots);
|
||||
sdf.setReplaceFunction(replace).addPostProcess(post).fillRecursive(world, pos);
|
||||
Vector3f last = SplineHelper.getPos(trunk, trunk.size() - 1.35F);
|
||||
for (int y = 0; y < 8; y++) {
|
||||
BlockPos p = pos.add(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5);
|
||||
BlockPos p = pos.offset(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5);
|
||||
BlocksHelper.setWithoutUpdate(world, p, y == 4 ? wood : log);
|
||||
}
|
||||
|
||||
|
||||
for (int y = 0; y < 16; y++) {
|
||||
BlockPos p = pos.add(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5);
|
||||
BlockPos p = pos.offset(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5);
|
||||
if (world.isAir(p)) {
|
||||
BlocksHelper.setWithoutUpdate(world, p, leaves);
|
||||
}
|
||||
|
@ -116,8 +122,8 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Mutable mut = new Mutable();
|
||||
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
Function<PosInfo, BlockState> leavesPost1 = (info) -> {
|
||||
if (info.getState().equals(log) || info.getState().equals(wood)) {
|
||||
for (int x = -6; x < 7; x++) {
|
||||
|
@ -133,7 +139,7 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
|
|||
mut.setY(y + info.getPos().getY());
|
||||
BlockState state = info.getState(mut);
|
||||
if (state.getBlock() instanceof LeavesBlock) {
|
||||
int distance = state.get(LeavesBlock.DISTANCE);
|
||||
int distance = state.getValue(LeavesBlock.DISTANCE);
|
||||
if (d < distance) {
|
||||
info.setState(mut, state.with(LeavesBlock.DISTANCE, d));
|
||||
}
|
||||
|
@ -149,15 +155,15 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
|
|||
if (info.getState().getBlock() instanceof LeavesBlock) {
|
||||
int distance = info.getState().get(LeavesBlock.DISTANCE);
|
||||
if (distance > MHelper.randRange(2, 4, random)) {
|
||||
return Blocks.AIR.getDefaultState();
|
||||
return Blocks.AIR.defaultBlockState();
|
||||
}
|
||||
for (Direction d: BlocksHelper.DIRECTIONS) {
|
||||
for (Direction d : BlocksHelper.DIRECTIONS) {
|
||||
int airCount = 0;
|
||||
if (info.getState(d).isAir()) {
|
||||
airCount ++;
|
||||
airCount++;
|
||||
}
|
||||
if (airCount > 5) {
|
||||
return Blocks.AIR.getDefaultState();
|
||||
return Blocks.AIR.defaultBlockState();
|
||||
}
|
||||
}
|
||||
if (random.nextInt(8) == 0) {
|
||||
|
@ -166,19 +172,19 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
|
|||
}
|
||||
return info.getState();
|
||||
};
|
||||
|
||||
|
||||
SDF canopy = new SDFCappedCone().setRadius1(12F).setRadius2(1f).setHeight(height * 0.3F).setBlock(leaves);
|
||||
canopy = new SDFDisplacement().setFunction((vec) -> { return MHelper.randRange(-3F, 3F, random); }).setSource(canopy);
|
||||
canopy.addPostProcess(leavesPost1).addPostProcess(leavesPost2).fillRecursiveIgnore(world, pos.add(0, height * 0.75, 0), ignore);
|
||||
|
||||
canopy = new SDFDisplacement().setFunction((vec) -> {
|
||||
return MHelper.randRange(-3F, 3F, random);
|
||||
}).setSource(canopy);
|
||||
canopy.addPostProcess(leavesPost1).addPostProcess(leavesPost2).fillRecursiveIgnore(world,
|
||||
pos.offset(0, height * 0.75, 0), ignore);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
BRANCH = Lists.newArrayList(new Vector3f(0, 0, 0),
|
||||
new Vector3f(0.25F, 0.1F, 0),
|
||||
new Vector3f(0.40F, 0.2F, 0),
|
||||
new Vector3f(0.50F, 0.4F, 0),
|
||||
new Vector3f(0.55F, 0.6F, 0));
|
||||
BRANCH = Lists.newArrayList(new Vector3f(0, 0, 0), new Vector3f(0.25F, 0.1F, 0), new Vector3f(0.40F, 0.2F, 0),
|
||||
new Vector3f(0.50F, 0.4F, 0), new Vector3f(0.55F, 0.6F, 0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,13 +6,13 @@ import java.util.function.Function;
|
|||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -34,30 +34,35 @@ public class OldBulbisTreeFeature extends DefaultFeature {
|
|||
private static final List<Vector3f> ROOT;
|
||||
private static final List<Vector3f> LEAF;
|
||||
private static final List<Vector3f> SIDE;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false;
|
||||
if (!world.getBlockState(pos.down(4)).getBlock().isIn(EndTags.GEN_TERRAIN)) return false;
|
||||
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
|
||||
return false;
|
||||
if (!world.getBlockState(pos.down(4)).getBlock().isIn(EndTags.GEN_TERRAIN))
|
||||
return false;
|
||||
|
||||
BlockState stem = Integrations.BYG.getDefaultState("bulbis_stem");
|
||||
BlockState wood = Integrations.BYG.getDefaultState("bulbis_wood");
|
||||
BlockState cap = Integrations.BYG.getDefaultState(random.nextBoolean() ? "bulbis_shell" : "purple_bulbis_shell");
|
||||
BlockState cap = Integrations.BYG
|
||||
.getDefaultState(random.nextBoolean() ? "bulbis_shell" : "purple_bulbis_shell");
|
||||
BlockState glow = Integrations.BYG.getDefaultState("purple_shroomlight");
|
||||
|
||||
|
||||
Function<BlockState, Boolean> replacement = (state) -> {
|
||||
if (state.equals(stem) || state.equals(wood) || state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)) {
|
||||
if (state.equals(stem) || state.equals(wood) || state.isIn(EndTags.END_GROUND)
|
||||
|| state.getMaterial().equals(Material.PLANT)) {
|
||||
return true;
|
||||
}
|
||||
return state.getMaterial().isReplaceable();
|
||||
};
|
||||
|
||||
|
||||
float size = MHelper.randRange(10, 20, random);
|
||||
float addSize = MHelper.randRange(1, 1.7F, random);
|
||||
float addRad = addSize * 0.5F + 0.5F;
|
||||
int count = (int) (size * 0.15F);
|
||||
size *= addSize;
|
||||
float var = MHelper.PI2 / (float) (count * 3);
|
||||
float var = MHelper.PI2 / (float) (count * 3);
|
||||
float start = MHelper.randRange(0, MHelper.PI2, random);
|
||||
SDF sdf = null;
|
||||
int x1 = ((pos.getX() >> 4) << 4) - 16;
|
||||
|
@ -70,53 +75,56 @@ public class OldBulbisTreeFeature extends DefaultFeature {
|
|||
SplineHelper.scale(spline, sizeXZ, sizeXZ * 1.5F + MHelper.randRange(0, size * 0.5F, random), sizeXZ);
|
||||
SplineHelper.offset(spline, new Vector3f(size * random.nextFloat() * 0.3F, 0, 0));
|
||||
SplineHelper.rotateSpline(spline, angle);
|
||||
SplineHelper.offsetParts(spline, random, 1F, 0, 1F);//1.3F 0.8F
|
||||
SplineHelper.offsetParts(spline, random, 1F, 0, 1F);// 1.3F 0.8F
|
||||
SDF branch = SplineHelper.buildSDF(spline, 2.3F * addRad, 1.3F * addRad, (bpos) -> {
|
||||
return stem;
|
||||
});
|
||||
|
||||
Vector3f vec = spline.get(spline.size() - 1);
|
||||
float radius = (size + MHelper.randRange(0, size * 0.5F, random)) * 0.35F;
|
||||
bigSphere(world, pos.add(vec.getX(), vec.getY(), vec.getZ()), radius, cap, glow, wood, replacement, random);
|
||||
bigSphere(world, pos.offset(vec.getX(), vec.getY(), vec.getZ()), radius, cap, glow, wood, replacement,
|
||||
random);
|
||||
vec = SplineHelper.getPos(spline, 0.3F);
|
||||
makeRoots(world, pos.add(vec.getX(), vec.getY(), vec.getZ()), size * 0.4F + 5, random, wood, replacement);
|
||||
makeRoots(world, pos.offset(vec.getX(), vec.getY(), vec.getZ()), size * 0.4F + 5, random, wood,
|
||||
replacement);
|
||||
|
||||
sdf = (sdf == null) ? branch : new SDFUnion().setSourceA(sdf).setSourceB(branch);
|
||||
}
|
||||
|
||||
|
||||
sdf.setReplaceFunction(replacement).addPostProcess((info) -> {
|
||||
if (info.getState().equals(stem) && (!info.getStateUp().equals(stem) || !info.getStateDown().equals(stem))) {
|
||||
if (info.getState().equals(stem)
|
||||
&& (!info.getStateUp().equals(stem) || !info.getStateDown().equals(stem))) {
|
||||
return wood;
|
||||
}
|
||||
return info.getState();
|
||||
}).fillArea(world, pos, limits);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void bigSphere(StructureWorldAccess world, BlockPos pos, float radius, BlockState cap, BlockState glow, BlockState wood, Function<BlockState, Boolean> replacement, Random random) {
|
||||
|
||||
private void bigSphere(StructureWorldAccess world, BlockPos pos, float radius, BlockState cap, BlockState glow,
|
||||
BlockState wood, Function<BlockState, Boolean> replacement, Random random) {
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
|
||||
SDF sphere = new SDFSphere().setRadius(radius).setBlock(cap);
|
||||
|
||||
|
||||
SDF sphereInner = new SDFSphere().setRadius(radius * 0.53F).setBlock(Blocks.AIR);
|
||||
sphereInner = new SDFDisplacement().setFunction((vec) -> {
|
||||
return (float) noise.eval(vec.getX() * 0.1, vec.getY() * 0.1, vec.getZ() * 0.1);
|
||||
}).setSource(sphereInner);
|
||||
|
||||
|
||||
SDF sphereGlow = new SDFSphere().setRadius(radius * 0.6F).setBlock(glow);
|
||||
sphereGlow = new SDFDisplacement().setFunction((vec) -> {
|
||||
return (float) noise.eval(vec.getX() * 0.1, vec.getY() * 0.1, vec.getZ() * 0.1) * 2F;
|
||||
}).setSource(sphereGlow);
|
||||
sphereGlow = new SDFSubtraction().setSourceA(sphereGlow).setSourceB(sphereInner);
|
||||
|
||||
|
||||
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sphereGlow);
|
||||
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sphereInner);
|
||||
|
||||
|
||||
float offsetY = radius * 1.7F;
|
||||
sphere = new SDFUnion().setSourceA(sphere).setSourceB(sphereGlow);
|
||||
sphere = new SDFTranslate().setTranslate(0, offsetY, 0).setSource(sphere);
|
||||
|
||||
|
||||
int leafCount = (int) (radius * 0.5F) + 2;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
float angle = (float) i / 4 * MHelper.PI2;
|
||||
|
@ -124,72 +132,54 @@ public class OldBulbisTreeFeature extends DefaultFeature {
|
|||
SplineHelper.rotateSpline(spline, angle);
|
||||
SplineHelper.scale(spline, radius * 1.4F);
|
||||
SplineHelper.fillSplineForce(spline, world, wood, pos, replacement);
|
||||
|
||||
|
||||
for (int j = 0; j < leafCount; j++) {
|
||||
float delta = ((float) j / (float) (leafCount - 1));
|
||||
float scale = (float) Math.sin(delta * Math.PI) * 0.8F + 0.2F;
|
||||
float index = MathHelper.lerp(delta, 1F, 3.9F);
|
||||
float index = Mth.lerp(delta, 1F, 3.9F);
|
||||
Vector3f point = SplineHelper.getPos(spline, index);
|
||||
|
||||
|
||||
List<Vector3f> side = SplineHelper.copySpline(SIDE);
|
||||
SplineHelper.rotateSpline(side, angle);
|
||||
SplineHelper.scale(side, scale * radius);
|
||||
BlockPos p = pos.add(point.getX() + 0.5F, point.getY() + 0.5F, point.getZ() + 0.5F);
|
||||
BlockPos p = pos.offset(point.getX() + 0.5F, point.getY() + 0.5F, point.getZ() + 0.5F);
|
||||
SplineHelper.fillSplineForce(side, world, wood, p, replacement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sphere.fillArea(world, pos, new Box(pos.up((int) offsetY)).expand(radius * 1.3F));
|
||||
}
|
||||
|
||||
private void makeRoots(StructureWorldAccess world, BlockPos pos, float radius, Random random, BlockState wood, Function<BlockState, Boolean> replacement) {
|
||||
|
||||
private void makeRoots(StructureWorldAccess world, BlockPos pos, float radius, Random random, BlockState wood,
|
||||
Function<BlockState, Boolean> replacement) {
|
||||
int count = (int) (radius * 1.5F);
|
||||
for (int i = 0; i < count; i++) {
|
||||
float angle = (float) i / (float) count * MHelper.PI2;
|
||||
float scale = radius * MHelper.randRange(0.85F, 1.15F, random);
|
||||
|
||||
|
||||
List<Vector3f> branch = SplineHelper.copySpline(ROOT);
|
||||
SplineHelper.rotateSpline(branch, angle);
|
||||
SplineHelper.scale(branch, scale);
|
||||
Vector3f last = branch.get(branch.size() - 1);
|
||||
if (world.getBlockState(pos.add(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) {
|
||||
if (world.getBlockState(pos.offset(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) {
|
||||
SplineHelper.fillSpline(branch, world, wood, pos, replacement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
SPLINE = Lists.newArrayList(
|
||||
new Vector3f(0.00F, 0.00F, 0.00F),
|
||||
new Vector3f(0.10F, 0.35F, 0.00F),
|
||||
new Vector3f(0.20F, 0.50F, 0.00F),
|
||||
new Vector3f(0.30F, 0.55F, 0.00F),
|
||||
new Vector3f(0.42F, 0.70F, 0.00F),
|
||||
new Vector3f(0.50F, 1.00F, 0.00F)
|
||||
);
|
||||
|
||||
ROOT = Lists.newArrayList(new Vector3f(0F, 1F, 0),
|
||||
new Vector3f(0.1F, 0.70F, 0),
|
||||
new Vector3f(0.3F, 0.30F, 0),
|
||||
new Vector3f(0.7F, 0.05F, 0),
|
||||
new Vector3f(0.8F, -0.20F, 0)
|
||||
);
|
||||
SPLINE = Lists.newArrayList(new Vector3f(0.00F, 0.00F, 0.00F), new Vector3f(0.10F, 0.35F, 0.00F),
|
||||
new Vector3f(0.20F, 0.50F, 0.00F), new Vector3f(0.30F, 0.55F, 0.00F), new Vector3f(0.42F, 0.70F, 0.00F),
|
||||
new Vector3f(0.50F, 1.00F, 0.00F));
|
||||
|
||||
ROOT = Lists.newArrayList(new Vector3f(0F, 1F, 0), new Vector3f(0.1F, 0.70F, 0), new Vector3f(0.3F, 0.30F, 0),
|
||||
new Vector3f(0.7F, 0.05F, 0), new Vector3f(0.8F, -0.20F, 0));
|
||||
SplineHelper.offset(ROOT, new Vector3f(0, -0.45F, 0));
|
||||
|
||||
LEAF = Lists.newArrayList(
|
||||
new Vector3f(0.00F, 0.0F, 0),
|
||||
new Vector3f(0.10F, 0.4F, 0),
|
||||
new Vector3f(0.40F, 0.8F, 0),
|
||||
new Vector3f(0.75F, 0.9F, 0),
|
||||
new Vector3f(1.00F, 0.8F, 0)
|
||||
);
|
||||
|
||||
SIDE = Lists.newArrayList(
|
||||
new Vector3f(0, -0.3F, -0.5F),
|
||||
new Vector3f(0, -0.1F, -0.3F),
|
||||
new Vector3f(0, 0.0F, 0.0F),
|
||||
new Vector3f(0, -0.1F, 0.3F),
|
||||
new Vector3f(0, -0.3F, 0.5F)
|
||||
);
|
||||
|
||||
LEAF = Lists.newArrayList(new Vector3f(0.00F, 0.0F, 0), new Vector3f(0.10F, 0.4F, 0),
|
||||
new Vector3f(0.40F, 0.8F, 0), new Vector3f(0.75F, 0.9F, 0), new Vector3f(1.00F, 0.8F, 0));
|
||||
|
||||
SIDE = Lists.newArrayList(new Vector3f(0, -0.3F, -0.5F), new Vector3f(0, -0.1F, -0.3F),
|
||||
new Vector3f(0, 0.0F, 0.0F), new Vector3f(0, -0.1F, 0.3F), new Vector3f(0, -0.3F, 0.5F));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import me.shedaniel.rei.gui.widget.Widget;
|
|||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import ru.betterend.recipe.builders.AlloyingRecipe;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.util.LangUtil;
|
||||
|
@ -27,7 +27,7 @@ import ru.betterend.util.LangUtil;
|
|||
public class REIAlloyingCategory implements TransferRecipeCategory<REIAlloyingDisplay> {
|
||||
|
||||
@Override
|
||||
public @NotNull Identifier getIdentifier() {
|
||||
public @NotNull ResourceLocation getIdentifier() {
|
||||
return AlloyingRecipe.ID;
|
||||
}
|
||||
|
||||
|
@ -35,12 +35,12 @@ public class REIAlloyingCategory implements TransferRecipeCategory<REIAlloyingDi
|
|||
public @NotNull String getCategoryName() {
|
||||
return LangUtil.translate(EndBlocks.END_STONE_SMELTER.getTranslationKey());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull EntryStack getLogo() {
|
||||
return REIPlugin.END_STONE_SMELTER;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull List<Widget> setupDisplay(REIAlloyingDisplay display, Rectangle bounds) {
|
||||
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10);
|
||||
|
@ -49,18 +49,26 @@ public class REIAlloyingCategory implements TransferRecipeCategory<REIAlloyingDi
|
|||
List<Widget> widgets = Lists.newArrayList();
|
||||
widgets.add(Widgets.createRecipeBase(bounds));
|
||||
widgets.add(Widgets.createResultSlotBackground(new Point(startPoint.x + 61, startPoint.y + 9)));
|
||||
widgets.add(Widgets.createBurningFire(new Point(startPoint.x - 9, startPoint.y + 20)).animationDurationMS(10000));
|
||||
widgets.add(Widgets.createLabel(new Point(bounds.x + bounds.width - 5, bounds.y + 5),
|
||||
new TranslatableText("category.rei.cooking.time&xp", df.format(display.getXp()), df.format(smeltTime / 20D))).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB));
|
||||
widgets.add(Widgets.createArrow(new Point(startPoint.x + 24, startPoint.y + 8)).animationDurationTicks(smeltTime));
|
||||
widgets.add(
|
||||
Widgets.createBurningFire(new Point(startPoint.x - 9, startPoint.y + 20)).animationDurationMS(10000));
|
||||
widgets.add(Widgets
|
||||
.createLabel(new Point(bounds.x + bounds.width - 5, bounds.y + 5), new TranslatableText(
|
||||
"category.rei.cooking.time&xp", df.format(display.getXp()), df.format(smeltTime / 20D)))
|
||||
.noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB));
|
||||
widgets.add(
|
||||
Widgets.createArrow(new Point(startPoint.x + 24, startPoint.y + 8)).animationDurationTicks(smeltTime));
|
||||
List<List<EntryStack>> inputEntries = display.getInputEntries();
|
||||
widgets.add(Widgets.createSlot(new Point(startPoint.x - 20, startPoint.y + 1)).entries(inputEntries.get(0)).markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(startPoint.x - 20, startPoint.y + 1)).entries(inputEntries.get(0))
|
||||
.markInput());
|
||||
if (inputEntries.size() > 1) {
|
||||
widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entries(inputEntries.get(1)).markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entries(inputEntries.get(1))
|
||||
.markInput());
|
||||
} else {
|
||||
widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entries(Lists.newArrayList()).markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entries(Lists.newArrayList())
|
||||
.markInput());
|
||||
}
|
||||
widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 9)).entries(display.getResultingEntries().get(0)).disableBackground().markOutput());
|
||||
widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 9))
|
||||
.entries(display.getResultingEntries().get(0)).disableBackground().markOutput());
|
||||
return widgets;
|
||||
}
|
||||
|
||||
|
@ -71,17 +79,19 @@ public class REIAlloyingCategory implements TransferRecipeCategory<REIAlloyingDi
|
|||
matrices.push();
|
||||
matrices.translate(0, 0, 400);
|
||||
if (redSlots.contains(0)) {
|
||||
DrawableHelper.fill(matrices, startPoint.x - 20, startPoint.y + 1, startPoint.x - 20 + 16, startPoint.y + 1 + 16, 1090453504);
|
||||
DrawableHelper.fill(matrices, startPoint.x + 1, startPoint.y + 1, startPoint.x + 1 + 16, startPoint.y + 1 + 16, 1090453504);
|
||||
DrawableHelper.fill(matrices, startPoint.x - 20, startPoint.y + 1, startPoint.x - 20 + 16,
|
||||
startPoint.y + 1 + 16, 1090453504);
|
||||
DrawableHelper.fill(matrices, startPoint.x + 1, startPoint.y + 1, startPoint.x + 1 + 16,
|
||||
startPoint.y + 1 + 16, 1090453504);
|
||||
}
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull RecipeEntry getSimpleRenderer(REIAlloyingDisplay recipe) {
|
||||
return SimpleRecipeEntry.from(recipe.getInputEntries(), recipe.getResultingEntries());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getDisplayHeight() {
|
||||
return 49;
|
||||
|
|
|
@ -10,26 +10,26 @@ import org.jetbrains.annotations.NotNull;
|
|||
import me.shedaniel.rei.api.EntryStack;
|
||||
import me.shedaniel.rei.api.TransferRecipeDisplay;
|
||||
import me.shedaniel.rei.server.ContainerInfo;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.recipe.BlastingRecipe;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.crafting.BlastingRecipe;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
||||
import ru.betterend.recipe.builders.AlloyingRecipe;
|
||||
|
||||
public class REIAlloyingDisplay implements TransferRecipeDisplay {
|
||||
|
||||
private static List<EntryStack> fuel;
|
||||
|
||||
|
||||
private Recipe<?> recipe;
|
||||
private List<List<EntryStack>> input;
|
||||
private List<EntryStack> output;
|
||||
private float xp;
|
||||
private double smeltTime;
|
||||
|
||||
|
||||
public REIAlloyingDisplay(AlloyingRecipe recipe) {
|
||||
this.recipe = recipe;
|
||||
this.input = EntryStack.ofIngredients(recipe.getPreviewInputs());
|
||||
|
@ -37,7 +37,7 @@ public class REIAlloyingDisplay implements TransferRecipeDisplay {
|
|||
this.xp = recipe.getExperience();
|
||||
this.smeltTime = recipe.getSmeltTime();
|
||||
}
|
||||
|
||||
|
||||
public REIAlloyingDisplay(BlastingRecipe recipe) {
|
||||
this.recipe = recipe;
|
||||
this.input = EntryStack.ofIngredients(recipe.getPreviewInputs());
|
||||
|
@ -45,44 +45,44 @@ public class REIAlloyingDisplay implements TransferRecipeDisplay {
|
|||
this.xp = recipe.getExperience();
|
||||
this.smeltTime = recipe.getCookTime();
|
||||
}
|
||||
|
||||
|
||||
public static List<EntryStack> getFuel() {
|
||||
return fuel;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull Optional<Identifier> getRecipeLocation() {
|
||||
public @NotNull Optional<ResourceLocation> getRecipeLocation() {
|
||||
return Optional.ofNullable(recipe).map(Recipe::getId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull List<List<EntryStack>> getInputEntries() {
|
||||
return this.input;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull List<List<EntryStack>> getResultingEntries() {
|
||||
return Collections.singletonList(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Identifier getRecipeCategory() {
|
||||
public @NotNull ResourceLocation getRecipeCategory() {
|
||||
return AlloyingRecipe.ID;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull List<List<EntryStack>> getRequiredEntries() {
|
||||
return this.input;
|
||||
}
|
||||
|
||||
|
||||
public float getXp() {
|
||||
return this.xp;
|
||||
}
|
||||
|
||||
|
||||
public double getSmeltTime() {
|
||||
return this.smeltTime;
|
||||
}
|
||||
|
||||
|
||||
public Optional<Recipe<?>> getOptionalRecipe() {
|
||||
return Optional.ofNullable(recipe);
|
||||
}
|
||||
|
@ -98,14 +98,17 @@ public class REIAlloyingDisplay implements TransferRecipeDisplay {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<ScreenHandler> containerInfo, ScreenHandler container) {
|
||||
public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<ScreenHandler> containerInfo,
|
||||
ScreenHandler container) {
|
||||
return this.input;
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
fuel = EndStoneSmelterBlockEntity.availableFuels().keySet().stream()
|
||||
.map(Item::getDefaultStack).map(EntryStack::create)
|
||||
.map(e -> e.setting(EntryStack.Settings.TOOLTIP_APPEND_EXTRA, stack -> Collections.singletonList(new TranslatableText("category.rei.smelting.fuel")
|
||||
.formatted(Formatting.YELLOW)))).collect(Collectors.toList());
|
||||
fuel = EndStoneSmelterBlockEntity.availableFuels().keySet().stream().map(Item::getDefaultStack)
|
||||
.map(EntryStack::create)
|
||||
.map(e -> e.setting(EntryStack.Properties.TOOLTIP_APPEND_EXTRA,
|
||||
stack -> Collections.singletonList(
|
||||
new TranslatableText("category.rei.smelting.fuel").formatted(Formatting.YELLOW))))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,15 +20,15 @@ import me.shedaniel.rei.gui.widget.Widget;
|
|||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class REIAlloyingFuelCategory implements RecipeCategory<REIAlloyingFuelDisplay> {
|
||||
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.##");
|
||||
|
||||
@Override
|
||||
public @NotNull Identifier getIdentifier() {
|
||||
public @NotNull ResourceLocation getIdentifier() {
|
||||
return REIPlugin.ALLOYING_FUEL;
|
||||
}
|
||||
|
||||
|
@ -53,16 +53,21 @@ public class REIAlloyingFuelCategory implements RecipeCategory<REIAlloyingFuelDi
|
|||
String burnTime = DECIMAL_FORMAT.format(recipeDisplay.getFuelTime());
|
||||
List<Widget> widgets = Lists.newArrayList();
|
||||
widgets.add(Widgets.createRecipeBase(bounds));
|
||||
widgets.add(Widgets.createLabel(new Point(bounds.x + 26, bounds.getMaxY() - 15), new TranslatableText("category.rei.fuel.time", burnTime))
|
||||
widgets.add(Widgets
|
||||
.createLabel(new Point(bounds.x + 26, bounds.getMaxY() - 15),
|
||||
new TranslatableText("category.rei.fuel.time", burnTime))
|
||||
.color(0xFF404040, 0xFFBBBBBB).noShadow().leftAligned());
|
||||
widgets.add(Widgets.createBurningFire(new Point(bounds.x + 6, startPoint.y + 1)).animationDurationTicks(recipeDisplay.getFuelTime()));
|
||||
widgets.add(Widgets.createSlot(new Point(bounds.x + 6, startPoint.y + 18)).entries(recipeDisplay.getInputEntries().get(0)).markInput());
|
||||
widgets.add(Widgets.createBurningFire(new Point(bounds.x + 6, startPoint.y + 1))
|
||||
.animationDurationTicks(recipeDisplay.getFuelTime()));
|
||||
widgets.add(Widgets.createSlot(new Point(bounds.x + 6, startPoint.y + 18))
|
||||
.entries(recipeDisplay.getInputEntries().get(0)).markInput());
|
||||
return widgets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull RecipeEntry getSimpleRenderer(REIAlloyingFuelDisplay recipe) {
|
||||
Slot slot = Widgets.createSlot(new Point(0, 0)).entries(recipe.getInputEntries().get(0)).disableBackground().disableHighlight();
|
||||
Slot slot = Widgets.createSlot(new Point(0, 0)).entries(recipe.getInputEntries().get(0)).disableBackground()
|
||||
.disableHighlight();
|
||||
String burnItems = DECIMAL_FORMAT.format(recipe.getFuelTime() / 200d);
|
||||
return new RecipeEntry() {
|
||||
private TranslatableText text = new TranslatableText("category.rei.fuel.time_short.items", burnItems);
|
||||
|
@ -85,7 +90,8 @@ public class REIAlloyingFuelCategory implements RecipeCategory<REIAlloyingFuelDi
|
|||
slot.setZ(getZ() + 50);
|
||||
slot.getBounds().setLocation(bounds.x + 4, bounds.y + 2);
|
||||
slot.render(matrices, mouseX, mouseY, delta);
|
||||
MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, text.asOrderedText(), bounds.x + 25, bounds.y + 8, -1);
|
||||
MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, text.asOrderedText(), bounds.x + 25,
|
||||
bounds.y + 8, -1);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
|
||||
import me.shedaniel.rei.api.EntryStack;
|
||||
import me.shedaniel.rei.api.RecipeDisplay;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class REIAlloyingFuelDisplay implements RecipeDisplay {
|
||||
private final EntryStack fuel;
|
||||
|
@ -29,7 +29,7 @@ public class REIAlloyingFuelDisplay implements RecipeDisplay {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Identifier getRecipeCategory() {
|
||||
public @NotNull ResourceLocation getRecipeCategory() {
|
||||
return REIPlugin.ALLOYING_FUEL;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,20 +18,20 @@ import me.shedaniel.rei.api.widgets.Widgets;
|
|||
import me.shedaniel.rei.gui.entries.RecipeEntry;
|
||||
import me.shedaniel.rei.gui.entries.SimpleRecipeEntry;
|
||||
import me.shedaniel.rei.gui.widget.Widget;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import ru.betterend.blocks.basis.EndAnvilBlock;
|
||||
import ru.betterend.util.LangUtil;
|
||||
|
||||
public class REIAnvilCategory implements TransferRecipeCategory<REIAnvilDisplay> {
|
||||
|
||||
@Override
|
||||
public @NotNull Identifier getIdentifier() {
|
||||
public @NotNull ResourceLocation getIdentifier() {
|
||||
return REIPlugin.SMITHING;
|
||||
}
|
||||
|
||||
|
@ -39,12 +39,12 @@ public class REIAnvilCategory implements TransferRecipeCategory<REIAnvilDisplay>
|
|||
public @NotNull String getCategoryName() {
|
||||
return LangUtil.translate(Blocks.ANVIL.getTranslationKey());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull EntryStack getLogo() {
|
||||
return REIPlugin.ANVILS[0];
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull List<Widget> setupDisplay(REIAnvilDisplay display, Rectangle bounds) {
|
||||
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10);
|
||||
|
@ -65,11 +65,14 @@ public class REIAnvilCategory implements TransferRecipeCategory<REIAnvilDisplay>
|
|||
}).collect(Collectors.toList());
|
||||
materials.forEach(entryStack -> entryStack.setAmount(display.getInputCount()));
|
||||
widgets.add(Widgets.createArrow(new Point(x + 24, y + 4)));
|
||||
widgets.add(Widgets.createLabel(new Point(bounds.x + bounds.width - 7, bounds.y + bounds.height - 15),
|
||||
new TranslatableText("category.rei.damage.amount&dmg", display.getDamage())).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB));
|
||||
widgets.add(Widgets
|
||||
.createLabel(new Point(bounds.x + bounds.width - 7, bounds.y + bounds.height - 15),
|
||||
new TranslatableText("category.rei.damage.amount&dmg", display.getDamage()))
|
||||
.noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB));
|
||||
widgets.add(Widgets.createSlot(new Point(x - 20, y + 4)).entries(materials).markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(x + 1, y + 4)).entries(inputEntries.get(0)).markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(x + 61, y + 5)).entries(display.getResultingEntries().get(0)).disableBackground().markOutput());
|
||||
widgets.add(Widgets.createSlot(new Point(x + 61, y + 5)).entries(display.getResultingEntries().get(0))
|
||||
.disableBackground().markOutput());
|
||||
widgets.add(Widgets.createSlot(new Point(x - 9, y + 25)).entries(anvils));
|
||||
|
||||
return widgets;
|
||||
|
@ -82,17 +85,20 @@ public class REIAnvilCategory implements TransferRecipeCategory<REIAnvilDisplay>
|
|||
matrices.push();
|
||||
matrices.translate(0, 0, 400);
|
||||
if (redSlots.contains(0)) {
|
||||
DrawableHelper.fill(matrices, startPoint.x - 20, startPoint.y + 3, startPoint.x - 20 + 16, startPoint.y + 3 + 16, 1090453504);
|
||||
DrawableHelper.fill(matrices, startPoint.x + 1, startPoint.y + 3, startPoint.x + 1 + 16, startPoint.y + 3 + 16, 1090453504);
|
||||
DrawableHelper.fill(matrices, startPoint.x - 20, startPoint.y + 3, startPoint.x - 20 + 16,
|
||||
startPoint.y + 3 + 16, 1090453504);
|
||||
DrawableHelper.fill(matrices, startPoint.x + 1, startPoint.y + 3, startPoint.x + 1 + 16,
|
||||
startPoint.y + 3 + 16, 1090453504);
|
||||
}
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull RecipeEntry getSimpleRenderer(REIAnvilDisplay recipe) {
|
||||
return SimpleRecipeEntry.from(Collections.singletonList(recipe.getInputEntries().get(0)), recipe.getResultingEntries());
|
||||
return SimpleRecipeEntry.from(Collections.singletonList(recipe.getInputEntries().get(0)),
|
||||
recipe.getResultingEntries());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getDisplayHeight() {
|
||||
return 60;
|
||||
|
|
|
@ -9,23 +9,23 @@ import org.jetbrains.annotations.NotNull;
|
|||
import me.shedaniel.rei.api.EntryStack;
|
||||
import me.shedaniel.rei.api.TransferRecipeDisplay;
|
||||
import me.shedaniel.rei.server.ContainerInfo;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import ru.betterend.recipe.builders.AnvilRecipe;
|
||||
|
||||
public class REIAnvilDisplay implements TransferRecipeDisplay {
|
||||
|
||||
|
||||
private final AnvilRecipe recipe;
|
||||
private final List<List<EntryStack>> input;
|
||||
private final List<EntryStack> output;
|
||||
|
||||
|
||||
public REIAnvilDisplay(AnvilRecipe recipe) {
|
||||
this.recipe = recipe;
|
||||
this.input = EntryStack.ofIngredients(recipe.getPreviewInputs());
|
||||
this.output = Collections.singletonList(EntryStack.create(recipe.getOutput()));
|
||||
}
|
||||
|
||||
|
||||
public int getDamage() {
|
||||
return recipe.getDamage();
|
||||
}
|
||||
|
@ -37,9 +37,9 @@ public class REIAnvilDisplay implements TransferRecipeDisplay {
|
|||
public int getAnvilLevel() {
|
||||
return recipe.getAnvilLevel();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull Optional<Identifier> getRecipeLocation() {
|
||||
public @NotNull Optional<ResourceLocation> getRecipeLocation() {
|
||||
return Optional.ofNullable(recipe).map(Recipe::getId);
|
||||
}
|
||||
|
||||
|
@ -47,17 +47,17 @@ public class REIAnvilDisplay implements TransferRecipeDisplay {
|
|||
public @NotNull List<List<EntryStack>> getInputEntries() {
|
||||
return this.input;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull List<List<EntryStack>> getResultingEntries() {
|
||||
return Collections.singletonList(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Identifier getRecipeCategory() {
|
||||
public @NotNull ResourceLocation getRecipeCategory() {
|
||||
return REIPlugin.SMITHING;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull List<List<EntryStack>> getRequiredEntries() {
|
||||
return input;
|
||||
|
|
|
@ -17,18 +17,18 @@ import me.shedaniel.rei.gui.entries.SimpleRecipeEntry;
|
|||
import me.shedaniel.rei.gui.widget.Widget;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.recipe.builders.InfusionRecipe;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.util.LangUtil;
|
||||
|
||||
public class REIInfusionCategory implements TransferRecipeCategory<REIInfusionDisplay> {
|
||||
|
||||
private final static Identifier BACKGROUND = BetterEnd.makeID("textures/gui/rei_infusion.png");
|
||||
|
||||
private final static ResourceLocation BACKGROUND = BetterEnd.makeID("textures/gui/rei_infusion.png");
|
||||
|
||||
@Override
|
||||
public @NotNull Identifier getIdentifier() {
|
||||
public @NotNull ResourceLocation getIdentifier() {
|
||||
return InfusionRecipe.ID;
|
||||
}
|
||||
|
||||
|
@ -36,17 +36,17 @@ public class REIInfusionCategory implements TransferRecipeCategory<REIInfusionDi
|
|||
public @NotNull String getCategoryName() {
|
||||
return LangUtil.translate(EndBlocks.INFUSION_PEDESTAL.getTranslationKey());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull EntryStack getLogo() {
|
||||
return REIPlugin.INFUSION_RITUAL;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull RecipeEntry getSimpleRenderer(REIInfusionDisplay recipe) {
|
||||
return SimpleRecipeEntry.from(recipe.getInputEntries(), recipe.getResultingEntries());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull List<Widget> setupDisplay(REIInfusionDisplay display, Rectangle bounds) {
|
||||
Point centerPoint = new Point(bounds.getCenterX() - 34, bounds.getCenterY() - 2);
|
||||
|
@ -56,24 +56,36 @@ public class REIInfusionCategory implements TransferRecipeCategory<REIInfusionDi
|
|||
List<List<EntryStack>> outputEntries = display.getResultingEntries();
|
||||
widgets.add(Widgets.createTexturedWidget(BACKGROUND, bounds.x, bounds.y, 0, 0, 150, 104, 150, 104));
|
||||
widgets.add(Widgets.createSlot(centerPoint).entries(inputEntries.get(0)).disableBackground().markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(centerPoint.x, centerPoint.y - 28)).entries(inputEntries.get(1)).disableBackground().markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(centerPoint.x + 28, centerPoint.y)).entries(inputEntries.get(3)).disableBackground().markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(centerPoint.x, centerPoint.y + 28)).entries(inputEntries.get(5)).disableBackground().markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(centerPoint.x - 28, centerPoint.y)).entries(inputEntries.get(7)).disableBackground().markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(centerPoint.x + 24, centerPoint.y - 24)).entries(inputEntries.get(2)).disableBackground().markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(centerPoint.x + 24, centerPoint.y + 24)).entries(inputEntries.get(4)).disableBackground().markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(centerPoint.x - 24, centerPoint.y + 24)).entries(inputEntries.get(6)).disableBackground().markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(centerPoint.x - 24, centerPoint.y - 24)).entries(inputEntries.get(8)).disableBackground().markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(centerPoint.x + 80, centerPoint.y)).entries(outputEntries.get(0)).disableBackground().markOutput());
|
||||
widgets.add(Widgets.createLabel(new Point(bounds.getMaxX() - 5, bounds.y + 6), new TranslatableText("category.rei.infusion.time&val", display.getInfusionTime()))
|
||||
widgets.add(Widgets.createSlot(new Point(centerPoint.x, centerPoint.y - 28)).entries(inputEntries.get(1))
|
||||
.disableBackground().markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(centerPoint.x + 28, centerPoint.y)).entries(inputEntries.get(3))
|
||||
.disableBackground().markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(centerPoint.x, centerPoint.y + 28)).entries(inputEntries.get(5))
|
||||
.disableBackground().markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(centerPoint.x - 28, centerPoint.y)).entries(inputEntries.get(7))
|
||||
.disableBackground().markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(centerPoint.x + 24, centerPoint.y - 24)).entries(inputEntries.get(2))
|
||||
.disableBackground().markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(centerPoint.x + 24, centerPoint.y + 24)).entries(inputEntries.get(4))
|
||||
.disableBackground().markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(centerPoint.x - 24, centerPoint.y + 24)).entries(inputEntries.get(6))
|
||||
.disableBackground().markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(centerPoint.x - 24, centerPoint.y - 24)).entries(inputEntries.get(8))
|
||||
.disableBackground().markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(centerPoint.x + 80, centerPoint.y)).entries(outputEntries.get(0))
|
||||
.disableBackground().markOutput());
|
||||
widgets.add(Widgets
|
||||
.createLabel(new Point(bounds.getMaxX() - 5, bounds.y + 6),
|
||||
new TranslatableText("category.rei.infusion.time&val", display.getInfusionTime()))
|
||||
.noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB));
|
||||
return widgets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderRedSlots(MatrixStack matrices, List<Widget> widgets, Rectangle bounds,
|
||||
REIInfusionDisplay display, IntList redSlots) {}
|
||||
|
||||
public void renderRedSlots(MatrixStack matrices, List<Widget> widgets, Rectangle bounds, REIInfusionDisplay display,
|
||||
IntList redSlots) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDisplayHeight() {
|
||||
return 104;
|
||||
|
|
|
@ -11,36 +11,36 @@ import com.google.common.collect.Lists;
|
|||
import me.shedaniel.rei.api.EntryStack;
|
||||
import me.shedaniel.rei.api.TransferRecipeDisplay;
|
||||
import me.shedaniel.rei.server.ContainerInfo;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import ru.betterend.recipe.builders.AlloyingRecipe;
|
||||
import ru.betterend.recipe.builders.InfusionRecipe;
|
||||
|
||||
public class REIInfusionDisplay implements TransferRecipeDisplay {
|
||||
|
||||
|
||||
private final InfusionRecipe recipe;
|
||||
private final List<List<EntryStack>> input;
|
||||
private final List<EntryStack> output;
|
||||
private final int time;
|
||||
|
||||
|
||||
public REIInfusionDisplay(InfusionRecipe recipe) {
|
||||
this.recipe = recipe;
|
||||
this.input = Lists.newArrayList();
|
||||
this.output = Collections.singletonList(EntryStack.create(recipe.getOutput()));
|
||||
this.time = recipe.getInfusionTime();
|
||||
|
||||
|
||||
recipe.getPreviewInputs().forEach(ingredient -> {
|
||||
input.add(EntryStack.ofIngredient(ingredient));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public int getInfusionTime() {
|
||||
return this.time;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull Optional<Identifier> getRecipeLocation() {
|
||||
public @NotNull Optional<ResourceLocation> getRecipeLocation() {
|
||||
return Optional.ofNullable(recipe).map(Recipe::getId);
|
||||
}
|
||||
|
||||
|
@ -48,17 +48,17 @@ public class REIInfusionDisplay implements TransferRecipeDisplay {
|
|||
public @NotNull List<List<EntryStack>> getInputEntries() {
|
||||
return this.input;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull List<List<EntryStack>> getResultingEntries() {
|
||||
return Collections.singletonList(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Identifier getRecipeCategory() {
|
||||
public @NotNull ResourceLocation getRecipeCategory() {
|
||||
return AlloyingRecipe.ID;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull List<List<EntryStack>> getRequiredEntries() {
|
||||
return this.input;
|
||||
|
@ -75,7 +75,8 @@ public class REIInfusionDisplay implements TransferRecipeDisplay {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<ScreenHandler> containerInfo, ScreenHandler container) {
|
||||
public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<ScreenHandler> containerInfo,
|
||||
ScreenHandler container) {
|
||||
return this.input;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,10 +12,10 @@ import me.shedaniel.rei.plugin.DefaultPlugin;
|
|||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.impl.content.registry.FuelRegistryImpl;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.recipe.BlastingRecipe;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.crafting.BlastingRecipe;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.blocks.basis.EndAnvilBlock;
|
||||
import ru.betterend.blocks.basis.EndFurnaceBlock;
|
||||
|
@ -28,11 +28,11 @@ import ru.betterend.registry.EndItems;
|
|||
@Environment(EnvType.CLIENT)
|
||||
public class REIPlugin implements REIPluginV0 {
|
||||
|
||||
public final static Identifier PLUGIN_ID = BetterEnd.makeID("rei_plugin");
|
||||
public final static Identifier ALLOYING_FUEL = BetterEnd.makeID("alloying_fuel");
|
||||
public final static Identifier ALLOYING = AlloyingRecipe.ID;
|
||||
public final static Identifier SMITHING = AnvilRecipe.ID;
|
||||
public final static Identifier INFUSION = InfusionRecipe.ID;
|
||||
public final static ResourceLocation PLUGIN_ID = BetterEnd.makeID("rei_plugin");
|
||||
public final static ResourceLocation ALLOYING_FUEL = BetterEnd.makeID("alloying_fuel");
|
||||
public final static ResourceLocation ALLOYING = AlloyingRecipe.ID;
|
||||
public final static ResourceLocation SMITHING = AnvilRecipe.ID;
|
||||
public final static ResourceLocation INFUSION = InfusionRecipe.ID;
|
||||
|
||||
public final static EntryStack END_STONE_SMELTER = EntryStack.create(EndBlocks.END_STONE_SMELTER);
|
||||
public final static EntryStack INFUSION_RITUAL = EntryStack.create(EndBlocks.INFUSION_PEDESTAL);
|
||||
|
@ -40,12 +40,12 @@ public class REIPlugin implements REIPluginV0 {
|
|||
public final static EntryStack[] ANVILS;
|
||||
|
||||
@Override
|
||||
public Identifier getPluginIdentifier() {
|
||||
public ResourceLocation getPluginIdentifier() {
|
||||
return PLUGIN_ID;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerRecipeDisplays(RecipeHelper recipeHelper) {
|
||||
public void registerRecipeDisplays(RecipeHelper recipeHelper) {
|
||||
recipeHelper.registerRecipes(ALLOYING, AlloyingRecipe.class, REIAlloyingDisplay::new);
|
||||
recipeHelper.registerRecipes(ALLOYING, BlastingRecipe.class, REIAlloyingDisplay::new);
|
||||
recipeHelper.registerRecipes(SMITHING, AnvilRecipe.class, REIAnvilDisplay::new);
|
||||
|
@ -56,7 +56,7 @@ public class REIPlugin implements REIPluginV0 {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerOthers(RecipeHelper recipeHelper) {
|
||||
recipeHelper.registerWorkingStations(ALLOYING_FUEL, END_STONE_SMELTER);
|
||||
|
@ -68,15 +68,12 @@ public class REIPlugin implements REIPluginV0 {
|
|||
|
||||
recipeHelper.registerWorkingStations(DefaultPlugin.SMELTING, FURNACES);
|
||||
recipeHelper.registerWorkingStations(DefaultPlugin.FUEL, FURNACES);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPluginCategories(RecipeHelper recipeHelper) {
|
||||
recipeHelper.registerCategories(
|
||||
new REIAlloyingFuelCategory(),
|
||||
new REIAlloyingCategory(),
|
||||
new REIInfusionCategory(),
|
||||
new REIAnvilCategory());
|
||||
recipeHelper.registerCategories(new REIAlloyingFuelCategory(), new REIAlloyingCategory(),
|
||||
new REIInfusionCategory(), new REIAnvilCategory());
|
||||
}
|
||||
|
||||
static {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue