Continue mapping migration

This commit is contained in:
Aleksey 2021-04-12 21:38:22 +03:00
parent 99ade39404
commit f03fd03bd0
499 changed files with 12567 additions and 12723 deletions

View file

@ -2,10 +2,8 @@ package ru.betterend.integration;
import java.awt.Color;
import java.util.Map;
import com.google.common.collect.Maps;
import net.minecraft.world.level.ItemLike;
import com.google.common.collect.Maps;
import ru.betterend.blocks.HydraluxPetalColoredBlock;
import ru.betterend.blocks.complex.ColoredMaterial;
import ru.betterend.registry.EndBlocks;
@ -18,24 +16,25 @@ 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, ItemLike> 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);
@ -52,15 +51,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, ItemLike> dyes) {
int color = MHelper.color(hex);
colors.put(color, name);
dyes.put(color, getItem(name + "_dye"));
System.out.println(name + " " + color + " " + new Color(color));
}
}

View file

@ -7,19 +7,19 @@ import java.lang.reflect.Method;
import net.fabricmc.fabric.api.tag.TagRegistry;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.item.Item;
import net.minecraft.core.Registry;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.Tag;
import net.minecraft.tags.Tag.Named;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.Feature;
import ru.betterend.BetterEnd;
@ -27,25 +27,23 @@ 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 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));
}
@ -53,39 +51,39 @@ public abstract class ModIntegration {
public BlockState getDefaultState(String name) {
return getBlock(name).defaultBlockState();
}
public ResourceKey<Biome> getKey(String name) {
return ResourceKey.of(Registry.BIOME_KEY, getID(name));
return ResourceKey.create(Registry.BIOME_REGISTRY, getID(name));
}
public boolean modIsInstalled() {
return FabricLoader.getInstance().isModLoaded(modID);
}
public EndFeature getFeature(String featureID, String configuredFeatureID, GenerationStep.Feature featureStep) {
public EndFeature getFeature(String featureID, String configuredFeatureID, GenerationStep.Decoration 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) {
public EndFeature getFeature(String name, GenerationStep.Decoration 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();
@ -93,7 +91,7 @@ public abstract class ModIntegration {
}
return cl;
}
@SuppressWarnings("unchecked")
public <T extends Object> T getStaticFieldValue(Class<?> cl, String name) {
if (cl != null) {
@ -102,13 +100,14 @@ 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 {
@ -116,18 +115,20 @@ 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();
@ -136,12 +137,13 @@ 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();
@ -150,7 +152,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];
@ -162,10 +164,9 @@ 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++) {
@ -176,15 +177,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();
@ -195,16 +196,16 @@ public abstract class ModIntegration {
}
return null;
}
public Tag.Named<Item> getItemTag(String name) {
ResourceLocation id = getID(name);
Tag<Item> tag = ItemTags.getTagGroup().getTag(id);
return tag == null ? (Identified<Item>) TagRegistry.item(id) : (Identified<Item>) tag;
Tag<Item> tag = ItemTags.getAllTags().getTag(id);
return tag == null ? (Named<Item>) TagRegistry.item(id) : (Named<Item>) tag;
}
public Tag.Named<Block> getBlockTag(String name) {
ResourceLocation id = getID(name);
Tag<Block> tag = BlockTags.getTagGroup().getTag(id);
return tag == null ? (Identified<Block>) TagRegistry.block(id) : (Identified<Block>) tag;
Tag<Block> tag = BlockTags.getAllTags().getTag(id);
return tag == null ? (Named<Block>) TagRegistry.block(id) : (Named<Block>) tag;
}
}

View file

@ -1,7 +1,7 @@
package ru.betterend.integration;
import net.minecraft.world.item.Item;
import net.minecraft.tags.Tag;
import net.minecraft.world.item.Item;
import ru.betterend.registry.EndItems;
import ru.betterend.util.TagHelper;
@ -16,10 +16,9 @@ public class NourishIntegration extends ModIntegration {
Tag.Named<Item> fruit = getItemTag("fruit");
Tag.Named<Item> protein = getItemTag("protein");
Tag.Named<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);
}

View file

@ -8,9 +8,8 @@ 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() {}
}

View file

@ -2,10 +2,9 @@ package ru.betterend.integration.byg;
import java.util.List;
import java.util.stream.Collectors;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.collection.WeightedList;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.ai.behavior.WeightedList;
import net.minecraft.world.level.biome.Biome;
import ru.betterend.integration.Integrations;
import ru.betterend.integration.ModIntegration;
@ -32,31 +31,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) {
ResourceLocation biomeID = BuiltinRegistries.BIOME.getId(biome);
ResourceLocation biomeID = BuiltinRegistries.BIOME.getKey(biome);
EndBiome endBiome = EndBiomes.getBiome(biomeID);
Biome edge = this.getAndExecuteRuntime(biomeClass, obj, "getEdge");
if (edge != null) {
ResourceLocation edgeID = BuiltinRegistries.BIOME.getId(edge);
ResourceLocation edgeID = BuiltinRegistries.BIOME.getKey(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<ResourceLocation> 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);

View file

@ -1,12 +1,11 @@
package ru.betterend.integration.byg.biomes;
import java.util.List;
import net.minecraft.world.entity.SpawnGroup;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.biome.SpawnSettings.SpawnEntry;
import net.minecraft.world.level.biome.BiomeSpecialEffects;
import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
import ru.betterend.BetterEnd;
import ru.betterend.integration.Integrations;
import ru.betterend.integration.byg.features.BYGFeatures;
@ -17,30 +16,30 @@ public class EterialGrove extends EndBiome {
public EterialGrove() {
super(makeDef());
}
private static BiomeDefinition makeDef() {
Biome biome = Integrations.BYG.getBiome("ethereal_islands");
BiomeEffects effects = biome.getEffects();
BiomeSpecialEffects effects = biome.getSpecialEffects();
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();
SoundEvent additions = effects.getAdditionsSound().get().getSound();
SoundEvent mood = effects.getMoodSound().get().getSound();
SoundEvent loop = effects.getAmbientLoopSoundEvent().get();
SoundEvent music = effects.getBackgroundMusic().get().getEvent();
SoundEvent additions = effects.getAmbientAdditionsSettings().get().getSoundEvent();
SoundEvent mood = effects.getAmbientMoodSettings().get().getSoundEvent();
def.setLoop(loop).setMusic(music).setAdditions(additions).setMood(mood);
}
for (SpawnGroup group : SpawnGroup.values()) {
List<SpawnEntry> list = biome.getSpawnSettings().getSpawnEntry(group);
for (MobCategory group: MobCategory.values()) {
List<SpawnerData> list = biome.getMobSettings().getMobs(group);
list.forEach((entry) -> {
def.addMobSpawn(entry);
});
}
return def;
}
}

View file

@ -1,14 +1,13 @@
package ru.betterend.integration.byg.biomes;
import java.util.List;
import net.minecraft.world.entity.SpawnGroup;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.biome.SpawnSettings.SpawnEntry;
import net.minecraft.world.gen.GenerationStep.Feature;
import net.minecraft.world.level.biome.BiomeSpecialEffects;
import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
import ru.betterend.BetterEnd;
import ru.betterend.integration.Integrations;
import ru.betterend.integration.byg.features.BYGFeatures;
@ -20,39 +19,45 @@ 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)
BiomeSpecialEffects effects = biome.getSpecialEffects();
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();
SoundEvent additions = effects.getAdditionsSound().get().getSound();
SoundEvent mood = effects.getMoodSound().get().getSound();
SoundEvent loop = effects.getAmbientLoopSoundEvent().get();
SoundEvent music = effects.getBackgroundMusic().get().getEvent();
SoundEvent additions = effects.getAmbientAdditionsSettings().get().getSoundEvent();
SoundEvent mood = effects.getAmbientMoodSettings().get().getSoundEvent();
def.setLoop(loop).setMusic(music).setAdditions(additions).setMood(mood);
}
biome.getGenerationSettings().getFeatures().forEach((list) -> {
biome.getGenerationSettings().features().forEach((list) -> {
list.forEach((feature) -> {
def.addFeature(Feature.VEGETAL_DECORATION, feature.get());
def.addFeature(Decoration.VEGETAL_DECORATION, feature.get());
});
});
for (SpawnGroup group : SpawnGroup.values()) {
List<SpawnEntry> list = biome.getSpawnSettings().getSpawnEntry(group);
for (MobCategory group: MobCategory.values()) {
List<SpawnerData> list = biome.getMobSettings().getMobs(group);
list.forEach((entry) -> {
def.addMobSpawn(entry);
});
}
return def;
}
}

View file

@ -2,20 +2,19 @@ package ru.betterend.integration.byg.biomes;
import java.util.List;
import java.util.function.Supplier;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.entity.SpawnGroup;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.core.Registry;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.data.worldgen.Features;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.biome.SpawnSettings.SpawnEntry;
import net.minecraft.world.gen.GenerationStep.Feature;
import net.minecraft.world.level.biome.BiomeSpecialEffects;
import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeatures;
import ru.betterend.BetterEnd;
import ru.betterend.integration.Integrations;
import ru.betterend.integration.byg.features.BYGFeatures;
@ -27,60 +26,65 @@ public class OldBulbisGardens extends EndBiome {
public OldBulbisGardens() {
super(makeDef());
}
private static BiomeDefinition makeDef() {
Biome biome = Integrations.BYG.getBiome("bulbis_gardens");
BiomeEffects effects = biome.getEffects();
BiomeSpecialEffects effects = biome.getSpecialEffects();
Block ivis = Integrations.BYG.getBlock("ivis_phylium");
Block origin = biome.getGenerationSettings().getSurfaceBuilderConfig().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();
SoundEvent additions = effects.getAdditionsSound().get().getSound();
SoundEvent mood = effects.getMoodSound().get().getSound();
SoundEvent loop = effects.getAmbientLoopSoundEvent().get();
SoundEvent music = effects.getBackgroundMusic().get().getEvent();
SoundEvent additions = effects.getAmbientAdditionsSettings().get().getSoundEvent();
SoundEvent mood = effects.getAmbientMoodSettings().get().getSoundEvent();
def.setLoop(loop).setMusic(music).setAdditions(additions).setMood(mood);
}
for (SpawnGroup group : SpawnGroup.values()) {
List<SpawnEntry> list = biome.getSpawnSettings().getSpawnEntry(group);
for (MobCategory group: MobCategory.values()) {
List<SpawnerData> list = biome.getMobSettings().getMobs(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());
List<List<Supplier<ConfiguredFeature<?, ?>>>> features = biome.getGenerationSettings().features();
List<Supplier<ConfiguredFeature<?, ?>>> vegetal = features.get(Decoration.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();
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);
feature = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, feature.decorated(Features.Decorators.HEIGHTMAP_SQUARE).countRandom(1));
def.addFeature(Decoration.VEGETAL_DECORATION, feature);
}
// Grasses and other features
for (int i = 2; i < vegetal.size(); i++) {
getter = vegetal.get(i);
ConfiguredFeature<?, ?> feature = getter.get();
def.addFeature(Feature.VEGETAL_DECORATION, feature);
def.addFeature(Decoration.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;
}
}

View file

@ -2,16 +2,14 @@ package ru.betterend.integration.byg.features;
import java.util.List;
import java.util.Random;
import com.google.common.base.Function;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import com.google.common.base.Function;
import com.mojang.math.Vector3f;
import ru.betterend.integration.Integrations;
import ru.betterend.registry.EndTags;
import ru.betterend.util.MHelper;
@ -23,7 +21,7 @@ public class BigEtherTreeFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND))
return false;
BlockState log = Integrations.BYG.getDefaultState("ether_log");
@ -33,7 +31,7 @@ public class BigEtherTreeFeature extends DefaultFeature {
return log;
};
Function<BlockState, Boolean> replace = (state) -> {
return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)
return state.is(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)
|| state.getMaterial().isReplaceable();
};
@ -51,7 +49,7 @@ 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 = Mth.lerp(splinePos, 2.3F, 0.8F) * 0.8F;
// float startRad = MathHelper.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;
@ -65,7 +63,7 @@ public class BigEtherTreeFeature extends DefaultFeature {
}
sdf.setReplaceFunction((state) -> {
return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)
return state.is(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))) {
@ -77,7 +75,7 @@ public class BigEtherTreeFeature extends DefaultFeature {
return true;
}
// private void makeLeavesSphere(WorldGenLevel world, BlockPos pos,
// private void makeLeavesSphere(StructureWorldAccess world, BlockPos pos,
// BlockState leaves, Function<BlockState, Boolean> ignore) {
//
// }

View file

@ -2,21 +2,19 @@ package ru.betterend.integration.byg.features;
import java.util.List;
import java.util.Random;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
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 com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.mojang.math.Vector3f;
import ru.betterend.integration.Integrations;
import ru.betterend.registry.EndTags;
import ru.betterend.util.BlocksHelper;
@ -37,20 +35,20 @@ public class GreatNightshadeTreeFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(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 = Integrations.BYG.getDefaultState("nightshade_leaves").setValue(LeavesBlock.DISTANCE, 1);
BlockState leaves_flower = Integrations.BYG.getDefaultState("flowering_nightshade_leaves")
.with(LeavesBlock.DISTANCE, 1);
.setValue(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)
return state.is(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)
|| state.getMaterial().isReplaceable();
};
Function<PosInfo, BlockState> post = (info) -> {
@ -78,7 +76,7 @@ public class GreatNightshadeTreeFeature extends DefaultFeature {
for (int i = 0; i < count; i++) {
float scale = (float) (count - i) / count * 15;
Vector3f offset = SplineHelper.getPos(trunk, (float) i / count * delta + start);
if (offset.getY() > max) {
if (offset.y() > max) {
break;
}
List<Vector3f> branch = SplineHelper.copySpline(BRANCH);
@ -98,13 +96,13 @@ public class GreatNightshadeTreeFeature extends DefaultFeature {
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.offset(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5);
BlockPos p = pos.offset(last.x() + 0.5, last.y() + y, last.z() + 0.5);
BlocksHelper.setWithoutUpdate(world, p, y == 4 ? wood : log);
}
for (int y = 0; y < 16; y++) {
BlockPos p = pos.offset(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5);
if (world.isAir(p)) {
BlockPos p = pos.offset(last.x() + 0.5, last.y() + y, last.z() + 0.5);
if (world.isEmptyBlock(p)) {
BlocksHelper.setWithoutUpdate(world, p, leaves);
}
float radius = (1 - y / 16F) * 3F;
@ -115,8 +113,8 @@ public class GreatNightshadeTreeFeature extends DefaultFeature {
for (int z = -rad; z <= rad; z++) {
int z2 = z * z;
if (x2 + z2 < radius - random.nextFloat() * rad) {
BlockPos lp = p.add(x, 0, z);
if (world.isAir(lp)) {
BlockPos lp = p.offset(x, 0, z);
if (world.isEmptyBlock(lp)) {
BlocksHelper.setWithoutUpdate(world, lp, leaves);
}
}
@ -142,7 +140,7 @@ public class GreatNightshadeTreeFeature extends DefaultFeature {
if (state.getBlock() instanceof LeavesBlock) {
int distance = state.getValue(LeavesBlock.DISTANCE);
if (d < distance) {
info.setState(mut, state.with(LeavesBlock.DISTANCE, d));
info.setState(mut, state.setValue(LeavesBlock.DISTANCE, d));
}
}
}
@ -154,7 +152,7 @@ public class GreatNightshadeTreeFeature extends DefaultFeature {
};
Function<PosInfo, BlockState> leavesPost2 = (info) -> {
if (info.getState().getBlock() instanceof LeavesBlock) {
int distance = info.getState().get(LeavesBlock.DISTANCE);
int distance = info.getState().getValue(LeavesBlock.DISTANCE);
if (distance > MHelper.randRange(2, 4, random)) {
return Blocks.AIR.defaultBlockState();
}
@ -168,7 +166,7 @@ public class GreatNightshadeTreeFeature extends DefaultFeature {
}
}
if (random.nextInt(8) == 0) {
return leaves_flower.with(LeavesBlock.DISTANCE, distance);
return leaves_flower.setValue(LeavesBlock.DISTANCE, distance);
}
}
return info.getState();

View file

@ -2,21 +2,19 @@ package ru.betterend.integration.byg.features;
import java.util.List;
import java.util.Random;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
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 com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.mojang.math.Vector3f;
import ru.betterend.integration.Integrations;
import ru.betterend.registry.EndTags;
import ru.betterend.util.BlocksHelper;
@ -37,7 +35,7 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND))
return false;
BlockState log = Integrations.BYG.getDefaultState("nightshade_log");
@ -49,7 +47,7 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
return log;
};
Function<BlockState, Boolean> replace = (state) -> {
return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)
return state.is(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)
|| state.getMaterial().isReplaceable();
};
Function<PosInfo, BlockState> post = (info) -> {
@ -78,7 +76,7 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
for (int i = 0; i < count; i++) {
float scale = (float) (count - i) / count * 15;
Vector3f offset = SplineHelper.getPos(trunk, (float) i / count * delta + start);
if (offset.getY() > max) {
if (offset.y() > max) {
break;
}
List<Vector3f> branch = SplineHelper.copySpline(BRANCH);
@ -97,13 +95,13 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
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.offset(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5);
BlockPos p = pos.offset(last.x() + 0.5, last.y() + y, last.z() + 0.5);
BlocksHelper.setWithoutUpdate(world, p, y == 4 ? wood : log);
}
for (int y = 0; y < 16; y++) {
BlockPos p = pos.offset(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5);
if (world.isAir(p)) {
BlockPos p = pos.offset(last.x() + 0.5, last.y() + y, last.z() + 0.5);
if (world.isEmptyBlock(p)) {
BlocksHelper.setWithoutUpdate(world, p, leaves);
}
float radius = (1 - y / 16F) * 3F;
@ -114,8 +112,8 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
for (int z = -rad; z <= rad; z++) {
int z2 = z * z;
if (x2 + z2 < radius - random.nextFloat() * rad) {
BlockPos lp = p.add(x, 0, z);
if (world.isAir(lp)) {
BlockPos lp = p.offset(x, 0, z);
if (world.isEmptyBlock(lp)) {
BlocksHelper.setWithoutUpdate(world, lp, leaves);
}
}
@ -141,7 +139,7 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
if (state.getBlock() instanceof LeavesBlock) {
int distance = state.getValue(LeavesBlock.DISTANCE);
if (d < distance) {
info.setState(mut, state.with(LeavesBlock.DISTANCE, d));
info.setState(mut, state.setValue(LeavesBlock.DISTANCE, d));
}
}
}
@ -153,7 +151,7 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
};
Function<PosInfo, BlockState> leavesPost2 = (info) -> {
if (info.getState().getBlock() instanceof LeavesBlock) {
int distance = info.getState().get(LeavesBlock.DISTANCE);
int distance = info.getState().getValue(LeavesBlock.DISTANCE);
if (distance > MHelper.randRange(2, 4, random)) {
return Blocks.AIR.defaultBlockState();
}
@ -167,7 +165,7 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature {
}
}
if (random.nextInt(8) == 0) {
return leaves_flower.with(LeavesBlock.DISTANCE, distance);
return leaves_flower.setValue(LeavesBlock.DISTANCE, distance);
}
}
return info.getState();

View file

@ -3,19 +3,17 @@ package ru.betterend.integration.byg.features;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.google.common.collect.Lists;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.Material;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.world.phys.AABB;
import net.minecraft.util.Mth;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.AABB;
import com.google.common.collect.Lists;
import com.mojang.math.Vector3f;
import ru.betterend.integration.Integrations;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndTags;
@ -38,9 +36,9 @@ public class OldBulbisTreeFeature extends DefaultFeature {
@Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
NoneFeatureConfiguration config) {
if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND))
if (!world.getBlockState(pos.below()).getBlock().is(EndTags.END_GROUND))
return false;
if (!world.getBlockState(pos.down(4)).getBlock().isIn(EndTags.GEN_TERRAIN))
if (!world.getBlockState(pos.below(4)).getBlock().is(EndTags.GEN_TERRAIN))
return false;
BlockState stem = Integrations.BYG.getDefaultState("bulbis_stem");
@ -50,7 +48,7 @@ public class OldBulbisTreeFeature extends DefaultFeature {
BlockState glow = Integrations.BYG.getDefaultState("purple_shroomlight");
Function<BlockState, Boolean> replacement = (state) -> {
if (state.equals(stem) || state.equals(wood) || state.isIn(EndTags.END_GROUND)
if (state.equals(stem) || state.equals(wood) || state.is(EndTags.END_GROUND)
|| state.getMaterial().equals(Material.PLANT)) {
return true;
}
@ -67,7 +65,7 @@ public class OldBulbisTreeFeature extends DefaultFeature {
SDF sdf = null;
int x1 = ((pos.getX() >> 4) << 4) - 16;
int z1 = ((pos.getZ() >> 4) << 4) - 16;
Box limits = new Box(x1, pos.getY() - 5, z1, x1 + 47, pos.getY() + size * 2, z1 + 47);
AABB limits = new AABB(x1, pos.getY() - 5, z1, x1 + 47, pos.getY() + size * 2, z1 + 47);
for (int i = 0; i < count; i++) {
float angle = (float) i / (float) count * MHelper.PI2 + MHelper.randRange(0, var, random) + start;
List<Vector3f> spline = SplineHelper.copySpline(SPLINE);
@ -140,12 +138,12 @@ public class OldBulbisTreeFeature extends DefaultFeature {
List<Vector3f> side = SplineHelper.copySpline(SIDE);
SplineHelper.rotateSpline(side, angle);
SplineHelper.scale(side, scale * radius);
BlockPos p = pos.offset(point.getX() + 0.5F, point.getY() + 0.5F, point.getZ() + 0.5F);
BlockPos p = pos.offset(point.x() + 0.5F, point.y() + 0.5F, point.z() + 0.5F);
SplineHelper.fillSplineForce(side, world, wood, p, replacement);
}
}
sphere.fillArea(world, pos, new Box(pos.up((int) offsetY)).expand(radius * 1.3F));
sphere.fillArea(world, pos, new AABB(pos.above((int) offsetY)).inflate(radius * 1.3F));
}
private void makeRoots(WorldGenLevel world, BlockPos pos, float radius, Random random, BlockState wood,
@ -159,7 +157,7 @@ public class OldBulbisTreeFeature extends DefaultFeature {
SplineHelper.rotateSpline(branch, angle);
SplineHelper.scale(branch, scale);
Vector3f last = branch.get(branch.size() - 1);
if (world.getBlockState(pos.offset(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) {
if (world.getBlockState(pos.offset(last.x(), last.y(), last.z())).is(EndTags.GEN_TERRAIN)) {
SplineHelper.fillSpline(branch, world, wood, pos, replacement);
}
}

View file

@ -6,7 +6,7 @@ import java.util.List;
import org.jetbrains.annotations.NotNull;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.vertex.PoseStack;
import it.unimi.dsi.fastutil.ints.IntList;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
@ -16,9 +16,8 @@ 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.client.gui.DrawableHelper;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.TranslatableText;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation;
import ru.betterend.recipe.builders.AlloyingRecipe;
import ru.betterend.registry.EndBlocks;
@ -33,14 +32,14 @@ public class REIAlloyingCategory implements TransferRecipeCategory<REIAlloyingDi
@Override
public @NotNull String getCategoryName() {
return LangUtil.translate(EndBlocks.END_STONE_SMELTER.getTranslationKey());
return LangUtil.translate(EndBlocks.END_STONE_SMELTER.getDescriptionId());
}
@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,49 +48,39 @@ 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 TranslatableComponent("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;
}
@Override
public void renderRedSlots(MatrixStack matrices, List<Widget> widgets, Rectangle bounds, REIAlloyingDisplay display,
public void renderRedSlots(PoseStack matrices, List<Widget> widgets, Rectangle bounds, REIAlloyingDisplay display,
IntList redSlots) {
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 27);
matrices.push();
matrices.pushPose();
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);
GuiComponent.fill(matrices, startPoint.x - 20, startPoint.y + 1, startPoint.x - 20 + 16, startPoint.y + 1 + 16, 1090453504);
GuiComponent.fill(matrices, startPoint.x + 1, startPoint.y + 1, startPoint.x + 1 + 16, startPoint.y + 1 + 16, 1090453504);
}
matrices.pop();
matrices.popPose();
}
@Override
public @NotNull RecipeEntry getSimpleRenderer(REIAlloyingDisplay recipe) {
return SimpleRecipeEntry.from(recipe.getInputEntries(), recipe.getResultingEntries());
}
@Override
public int getDisplayHeight() {
return 49;

View file

@ -10,56 +10,56 @@ 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.ChatFormatting;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.AbstractContainerMenu;
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.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());
this.output = Collections.singletonList(EntryStack.create(recipe.getOutput()));
this.input = EntryStack.ofIngredients(recipe.getIngredients());
this.output = Collections.singletonList(EntryStack.create(recipe.getResultItem()));
this.xp = recipe.getExperience();
this.smeltTime = recipe.getSmeltTime();
}
public REIAlloyingDisplay(BlastingRecipe recipe) {
this.recipe = recipe;
this.input = EntryStack.ofIngredients(recipe.getPreviewInputs());
this.output = Collections.singletonList(EntryStack.create(recipe.getOutput()));
this.input = EntryStack.ofIngredients(recipe.getIngredients());
this.output = Collections.singletonList(EntryStack.create(recipe.getResultItem()));
this.xp = recipe.getExperience();
this.smeltTime = recipe.getCookTime();
this.smeltTime = recipe.getCookingTime();
}
public static List<EntryStack> getFuel() {
return fuel;
}
@Override
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);
@ -69,20 +69,20 @@ public class REIAlloyingDisplay implements TransferRecipeDisplay {
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,17 +98,14 @@ public class REIAlloyingDisplay implements TransferRecipeDisplay {
}
@Override
public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<ScreenHandler> containerInfo,
ScreenHandler container) {
public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<AbstractContainerMenu> containerInfo, AbstractContainerMenu container) {
return this.input;
}
static {
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());
fuel = EndStoneSmelterBlockEntity.availableFuels().keySet().stream()
.map(Item::getDefaultInstance).map(EntryStack::create)
.map(e -> e.setting(EntryStack.Settings.TOOLTIP_APPEND_EXTRA, stack -> Collections.singletonList(new TranslatableComponent("category.rei.smelting.fuel")
.withStyle(ChatFormatting.YELLOW)))).collect(Collectors.toList());
}
}

View file

@ -7,7 +7,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.vertex.PoseStack;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.EntryStack;
@ -18,11 +18,10 @@ import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.entries.RecipeEntry;
import me.shedaniel.rei.gui.widget.Widget;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.world.item.Items;
import net.minecraft.text.TranslatableText;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Items;
public class REIAlloyingFuelCategory implements RecipeCategory<REIAlloyingFuelDisplay> {
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.##");
@ -34,7 +33,7 @@ public class REIAlloyingFuelCategory implements RecipeCategory<REIAlloyingFuelDi
@Override
public @NotNull String getCategoryName() {
return I18n.translate("category.rei.fuel");
return I18n.get("category.rei.fuel");
}
@Override
@ -53,24 +52,19 @@ 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 TranslatableComponent("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);
private TranslatableComponent text = new TranslatableComponent("category.rei.fuel.time_short.items", burnItems);
@Override
public int getHeight() {
@ -86,12 +80,11 @@ public class REIAlloyingFuelCategory implements RecipeCategory<REIAlloyingFuelDi
}
@Override
public void render(MatrixStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) {
public void render(PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) {
slot.setZ(getZ() + 50);
slot.getBounds().setLocation(bounds.x + 4, bounds.y + 2);
slot.render(matrices, mouseX, mouseY, delta);
Minecraft.getInstance().textRenderer.drawWithShadow(matrices, text.asOrderedText(), bounds.x + 25,
bounds.y + 8, -1);
Minecraft.getInstance().font.drawShadow(matrices, text.getVisualOrderText(), bounds.x + 25, bounds.y + 8, -1);
}
};
}

View file

@ -8,7 +8,7 @@ import java.util.stream.Collectors;
import org.jetbrains.annotations.NotNull;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.vertex.PoseStack;
import it.unimi.dsi.fastutil.ints.IntList;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
@ -18,13 +18,12 @@ 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.client.gui.GuiComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BlockItem;
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.world.item.BlockItem;
import net.minecraft.text.TranslatableText;
import net.minecraft.resources.ResourceLocation;
import ru.betterend.blocks.basis.EndAnvilBlock;
import ru.betterend.util.LangUtil;
@ -37,14 +36,14 @@ public class REIAnvilCategory implements TransferRecipeCategory<REIAnvilDisplay>
@Override
public @NotNull String getCategoryName() {
return LangUtil.translate(Blocks.ANVIL.getTranslationKey());
return LangUtil.translate(Blocks.ANVIL.getDescriptionId());
}
@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,40 +64,34 @@ 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 TranslatableComponent("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;
}
@Override
public void renderRedSlots(MatrixStack matrices, List<Widget> widgets, Rectangle bounds, REIAnvilDisplay display,
public void renderRedSlots(PoseStack matrices, List<Widget> widgets, Rectangle bounds, REIAnvilDisplay display,
IntList redSlots) {
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 27);
matrices.push();
matrices.pushPose();
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);
GuiComponent.fill(matrices, startPoint.x - 20, startPoint.y + 3, startPoint.x - 20 + 16, startPoint.y + 3 + 16, 1090453504);
GuiComponent.fill(matrices, startPoint.x + 1, startPoint.y + 3, startPoint.x + 1 + 16, startPoint.y + 3 + 16, 1090453504);
}
matrices.pop();
matrices.popPose();
}
@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;

View file

@ -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.world.item.crafting.Recipe;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.item.crafting.Recipe;
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()));
this.input = EntryStack.ofIngredients(recipe.getIngredients());
this.output = Collections.singletonList(EntryStack.create(recipe.getResultItem()));
}
public int getDamage() {
return recipe.getDamage();
}
@ -37,7 +37,7 @@ public class REIAnvilDisplay implements TransferRecipeDisplay {
public int getAnvilLevel() {
return recipe.getAnvilLevel();
}
@Override
public @NotNull Optional<ResourceLocation> getRecipeLocation() {
return Optional.ofNullable(recipe).map(Recipe::getId);
@ -47,7 +47,7 @@ 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);
@ -57,7 +57,7 @@ public class REIAnvilDisplay implements TransferRecipeDisplay {
public @NotNull ResourceLocation getRecipeCategory() {
return REIPlugin.SMITHING;
}
@Override
public @NotNull List<List<EntryStack>> getRequiredEntries() {
return input;
@ -74,8 +74,8 @@ public class REIAnvilDisplay implements TransferRecipeDisplay {
}
@Override
public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<ScreenHandler> containerInfo,
ScreenHandler container) {
public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<AbstractContainerMenu> containerInfo,
AbstractContainerMenu container) {
return input;
}
}

View file

@ -5,7 +5,7 @@ import java.util.List;
import org.jetbrains.annotations.NotNull;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.vertex.PoseStack;
import it.unimi.dsi.fastutil.ints.IntList;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
@ -15,8 +15,7 @@ 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.client.util.math.MatrixStack;
import net.minecraft.text.TranslatableText;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation;
import ru.betterend.BetterEnd;
import ru.betterend.recipe.builders.InfusionRecipe;
@ -24,7 +23,7 @@ import ru.betterend.registry.EndBlocks;
import ru.betterend.util.LangUtil;
public class REIInfusionCategory implements TransferRecipeCategory<REIInfusionDisplay> {
private final static ResourceLocation BACKGROUND = BetterEnd.makeID("textures/gui/rei_infusion.png");
@Override
@ -34,19 +33,19 @@ public class REIInfusionCategory implements TransferRecipeCategory<REIInfusionDi
@Override
public @NotNull String getCategoryName() {
return LangUtil.translate(EndBlocks.INFUSION_PEDESTAL.getTranslationKey());
return LangUtil.translate(EndBlocks.INFUSION_PEDESTAL.getDescriptionId());
}
@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,36 +55,24 @@ 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 TranslatableComponent("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(PoseStack matrices, List<Widget> widgets, Rectangle bounds,
REIInfusionDisplay display, IntList redSlots) {}
@Override
public int getDisplayHeight() {
return 104;

View file

@ -11,34 +11,34 @@ 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.world.item.crafting.Recipe;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.item.crafting.Recipe;
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.output = Collections.singletonList(EntryStack.create(recipe.getResultItem()));
this.time = recipe.getInfusionTime();
recipe.getPreviewInputs().forEach(ingredient -> {
recipe.getIngredients().forEach(ingredient -> {
input.add(EntryStack.ofIngredient(ingredient));
});
}
public int getInfusionTime() {
return this.time;
}
@Override
public @NotNull Optional<ResourceLocation> getRecipeLocation() {
return Optional.ofNullable(recipe).map(Recipe::getId);
@ -48,7 +48,7 @@ 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);
@ -58,7 +58,7 @@ public class REIInfusionDisplay implements TransferRecipeDisplay {
public @NotNull ResourceLocation getRecipeCategory() {
return AlloyingRecipe.ID;
}
@Override
public @NotNull List<List<EntryStack>> getRequiredEntries() {
return this.input;
@ -75,8 +75,7 @@ public class REIInfusionDisplay implements TransferRecipeDisplay {
}
@Override
public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<ScreenHandler> containerInfo,
ScreenHandler container) {
public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<AbstractContainerMenu> containerInfo, AbstractContainerMenu container) {
return this.input;
}
}

View file

@ -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.world.level.block.Blocks;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.crafting.BlastingRecipe;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Blocks;
import ru.betterend.BetterEnd;
import ru.betterend.blocks.basis.EndAnvilBlock;
import ru.betterend.blocks.basis.EndFurnaceBlock;
@ -43,9 +43,9 @@ public class REIPlugin implements REIPluginV0 {
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,12 +68,15 @@ 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 {