Reorganized Imports/Packages
This commit is contained in:
parent
a8beba9196
commit
770a5b4046
854 changed files with 42775 additions and 41811 deletions
|
@ -0,0 +1,5 @@
|
|||
package org.betterx.betterend.integration;
|
||||
|
||||
public interface EndBiomeIntegration {
|
||||
void addBiomes();
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package org.betterx.betterend.integration;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.MappedRegistry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
|
||||
|
||||
import org.betterx.bclib.api.biomes.BiomeAPI;
|
||||
import org.betterx.bclib.api.tag.CommonBlockTags;
|
||||
import org.betterx.bclib.api.tag.TagAPI;
|
||||
import org.betterx.bclib.integration.ModIntegration;
|
||||
import org.betterx.bclib.world.features.BCLFeature;
|
||||
|
||||
public class EnderscapeIntegration extends ModIntegration {
|
||||
public EnderscapeIntegration() {
|
||||
super("enderscape");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
Class<?> enderscape = getClass("net.enderscape.Enderscape");
|
||||
Class<?> enderscapeIslandsBiome = getClass("net.enderscape.world.biomes.EnderscapeIslandsBiome");
|
||||
MappedRegistry<?> biomes = getStaticFieldValue(enderscape, "ENDERSCAPE_BIOME");
|
||||
biomes.entrySet().forEach(entry -> {
|
||||
ResourceKey key = entry.getKey();
|
||||
Holder<Biome> biome = getBiome(key.location().getPath());
|
||||
if (enderscapeIslandsBiome.isInstance(entry.getValue())) {
|
||||
BiomeAPI.registerEndVoidBiome(biome);
|
||||
} else {
|
||||
BiomeAPI.registerEndLandBiome(biome);
|
||||
}
|
||||
});
|
||||
|
||||
BCLFeature scatteredShadowQuartzOre = getFeature("scattered_shadow_quartz_ore",
|
||||
Decoration.UNDERGROUND_DECORATION);
|
||||
BCLFeature voidNebuliteOre = getFeature("void_nebulite_ore", Decoration.UNDERGROUND_DECORATION);
|
||||
BCLFeature nebuliteOre = getFeature("nebulite_ore", Decoration.UNDERGROUND_DECORATION);
|
||||
|
||||
BiomeAPI.registerEndBiomeModification((biomeID, biome) -> {
|
||||
if (!biomeID.getNamespace().equals("enderscape")) {
|
||||
BiomeAPI.addBiomeFeature(biome, scatteredShadowQuartzOre);
|
||||
BiomeAPI.addBiomeFeature(biome, voidNebuliteOre);
|
||||
BiomeAPI.addBiomeFeature(biome, nebuliteOre);
|
||||
}
|
||||
});
|
||||
|
||||
TagAPI.addBlockTag(CommonBlockTags.END_STONES, getBlock("nebulite_ore"));
|
||||
TagAPI.addBlockTag(CommonBlockTags.END_STONES, getBlock("shadow_quartz_ore"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package org.betterx.betterend.integration;
|
||||
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import org.betterx.bclib.integration.ModIntegration;
|
||||
import org.betterx.bclib.util.ColorUtil;
|
||||
import org.betterx.betterend.blocks.HydraluxPetalColoredBlock;
|
||||
import org.betterx.betterend.complexmaterials.ColoredMaterial;
|
||||
import org.betterx.betterend.registry.EndBlocks;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Map;
|
||||
|
||||
public class FlamboyantRefabricatedIntegration extends ModIntegration {
|
||||
public FlamboyantRefabricatedIntegration() {
|
||||
super("flamboyant");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
Map<Integer, String> colors = Maps.newHashMap();
|
||||
Map<Integer, ItemLike> dyes = Maps.newHashMap();
|
||||
|
||||
addColor("fead1d", "amber", colors, dyes);
|
||||
addColor("bd9a5f", "beige", colors, dyes);
|
||||
addColor("edeada", "cream", colors, dyes);
|
||||
addColor("33430e", "dark_green", colors, dyes);
|
||||
addColor("639920", "forest_green", colors, dyes);
|
||||
addColor("f0618c", "hot_pink", colors, dyes);
|
||||
addColor("491c7b", "indigo", colors, dyes);
|
||||
addColor("65291b", "maroon", colors, dyes);
|
||||
addColor("2c3969", "navy", colors, dyes);
|
||||
addColor("827c17", "olive", colors, dyes);
|
||||
addColor("7bc618", "pale_green", colors, dyes);
|
||||
addColor("f4a4bd", "pale_pink", colors, dyes);
|
||||
addColor("f8d45a", "pale_yellow", colors, dyes);
|
||||
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 = ColorUtil.color(hex);
|
||||
colors.put(color, name);
|
||||
dyes.put(color, getItem(name + "_dye"));
|
||||
|
||||
System.out.println(name + " " + color + " " + new Color(color));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package org.betterx.betterend.integration;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
import org.betterx.bclib.api.ModIntegrationAPI;
|
||||
import org.betterx.bclib.integration.ModIntegration;
|
||||
import org.betterx.bclib.recipes.GridRecipe;
|
||||
import org.betterx.betterend.BetterEnd;
|
||||
import org.betterx.betterend.config.Configs;
|
||||
import org.betterx.betterend.events.PlayerAdvancementsCallback;
|
||||
import org.betterx.betterend.integration.byg.BYGIntegration;
|
||||
import org.betterx.betterend.item.GuideBookItem;
|
||||
import org.betterx.betterend.registry.EndItems;
|
||||
|
||||
public class Integrations {
|
||||
public static final ModIntegration BYG = ModIntegrationAPI.register(new BYGIntegration());
|
||||
public static final ModIntegration NOURISH = ModIntegrationAPI.register(new NourishIntegration());
|
||||
public static final ModIntegration FLAMBOYANT_REFABRICATED = ModIntegrationAPI.register(new FlamboyantRefabricatedIntegration());
|
||||
public static final ModIntegration ENDERSCAPE = ModIntegrationAPI.register(new EnderscapeIntegration());
|
||||
|
||||
private static boolean hasHydrogen;
|
||||
|
||||
public static void init() {
|
||||
if (hasGuideBook()) {
|
||||
GuideBookItem.register();
|
||||
|
||||
PlayerAdvancementsCallback.PLAYER_ADVANCEMENT_COMPLETE.register((player, advancement, criterionName) -> {
|
||||
ResourceLocation advId = new ResourceLocation("minecraft:end/enter_end_gateway");
|
||||
if (advId.equals(advancement.getId())) {
|
||||
player.addItem(new ItemStack(GuideBookItem.GUIDE_BOOK));
|
||||
}
|
||||
});
|
||||
|
||||
GridRecipe.make(BetterEnd.MOD_ID, "guide_book", GuideBookItem.GUIDE_BOOK)
|
||||
.checkConfig(Configs.RECIPE_CONFIG)
|
||||
.setShape("D", "B", "C")
|
||||
.addMaterial('D', EndItems.ENDER_DUST)
|
||||
.addMaterial('B', Items.BOOK)
|
||||
.addMaterial('C', EndItems.CRYSTAL_SHARDS)
|
||||
.build();
|
||||
}
|
||||
hasHydrogen = FabricLoader.getInstance().isModLoaded("hydrogen");
|
||||
}
|
||||
|
||||
public static boolean hasGuideBook() {
|
||||
return FabricLoader.getInstance().isModLoaded("patchouli");
|
||||
}
|
||||
|
||||
public static boolean hasHydrogen() {
|
||||
return hasHydrogen;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package org.betterx.betterend.integration;
|
||||
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
import org.betterx.bclib.api.tag.TagAPI;
|
||||
import org.betterx.bclib.integration.ModIntegration;
|
||||
import org.betterx.betterend.registry.EndItems;
|
||||
|
||||
public class NourishIntegration extends ModIntegration {
|
||||
public NourishIntegration() {
|
||||
super("nourish");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
TagKey<Item> fats = getItemTag("fats");
|
||||
TagKey<Item> fruit = getItemTag("fruit");
|
||||
TagKey<Item> protein = getItemTag("protein");
|
||||
TagKey<Item> sweets = getItemTag("sweets");
|
||||
|
||||
TagAPI.addItemTag(fats, EndItems.END_FISH_RAW, EndItems.END_FISH_COOKED);
|
||||
TagAPI.addItemTag(
|
||||
fruit,
|
||||
EndItems.SHADOW_BERRY_RAW,
|
||||
EndItems.SHADOW_BERRY_COOKED,
|
||||
EndItems.BLOSSOM_BERRY,
|
||||
EndItems.SHADOW_BERRY_JELLY,
|
||||
EndItems.SWEET_BERRY_JELLY,
|
||||
EndItems.BLOSSOM_BERRY_JELLY,
|
||||
EndItems.AMBER_ROOT_RAW,
|
||||
EndItems.CHORUS_MUSHROOM_RAW,
|
||||
EndItems.CHORUS_MUSHROOM_COOKED,
|
||||
EndItems.BOLUX_MUSHROOM_COOKED
|
||||
);
|
||||
TagAPI.addItemTag(
|
||||
protein,
|
||||
EndItems.END_FISH_RAW,
|
||||
EndItems.END_FISH_COOKED,
|
||||
EndItems.CHORUS_MUSHROOM_COOKED,
|
||||
EndItems.BOLUX_MUSHROOM_COOKED,
|
||||
EndItems.CAVE_PUMPKIN_PIE
|
||||
);
|
||||
TagAPI.addItemTag(
|
||||
sweets,
|
||||
EndItems.SHADOW_BERRY_JELLY,
|
||||
EndItems.SWEET_BERRY_JELLY,
|
||||
EndItems.BLOSSOM_BERRY_JELLY,
|
||||
EndItems.CAVE_PUMPKIN_PIE
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package org.betterx.betterend.integration.byg;
|
||||
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import org.betterx.bclib.blocks.BaseVineBlock;
|
||||
import org.betterx.betterend.blocks.basis.EndWallPlantBlock;
|
||||
import org.betterx.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 BaseVineBlock());
|
||||
|
||||
public static void register() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package org.betterx.betterend.integration.byg;
|
||||
|
||||
import org.betterx.bclib.integration.ModIntegration;
|
||||
import org.betterx.betterend.integration.EndBiomeIntegration;
|
||||
|
||||
public class BYGIntegration extends ModIntegration implements EndBiomeIntegration {
|
||||
public BYGIntegration() {
|
||||
super("byg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
/*Block block = Integrations.BYG.getBlock("ivis_phylium");
|
||||
if (block != null) {
|
||||
TagAPI.addTags(block, CommonBlockTags.END_STONES, CommonBlockTags.GEN_END_STONES);
|
||||
}
|
||||
BYGBlocks.register();
|
||||
BYGFeatures.register();
|
||||
BYGBiomes.register();*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBiomes() {
|
||||
//BYGBiomes.addBiomes();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package org.betterx.betterend.integration.byg.biomes;
|
||||
|
||||
import org.betterx.betterend.BetterEnd;
|
||||
import org.betterx.betterend.integration.Integrations;
|
||||
import org.betterx.betterend.registry.EndBiomes;
|
||||
import org.betterx.betterend.world.biome.EndBiome;
|
||||
|
||||
public class BYGBiomes {
|
||||
// New Biomes
|
||||
public static final EndBiome OLD_BULBIS_GARDENS = EndBiomes.registerSubBiomeIntegration(new OldBulbisGardens());
|
||||
public static final EndBiome NIGHTSHADE_REDWOODS = EndBiomes.registerSubBiomeIntegration(new NightshadeRedwoods());
|
||||
//public static final EndBiome ETHERIAL_GROVE = EndBiomes.registerSubBiomeIntegration(new EterialGrove());
|
||||
|
||||
public static void register() {
|
||||
BetterEnd.LOGGER.info("Registered " + OLD_BULBIS_GARDENS);
|
||||
}
|
||||
|
||||
public static void addBiomes() {
|
||||
EndBiomes.addSubBiomeIntegration(OLD_BULBIS_GARDENS, Integrations.BYG.getID("bulbis_gardens"));
|
||||
EndBiomes.addSubBiomeIntegration(NIGHTSHADE_REDWOODS, Integrations.BYG.getID("nightshade_forest"));
|
||||
//EndBiomes.addSubBiomeIntegration(ETHERIAL_GROVE, Integrations.BYG.getID("ethereal_islands"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package org.betterx.betterend.integration.byg.biomes;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.BiomeSpecialEffects;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
|
||||
import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.api.biomes.BCLBiomeBuilder;
|
||||
import org.betterx.betterend.integration.Integrations;
|
||||
import org.betterx.betterend.integration.byg.features.BYGFeatures;
|
||||
import org.betterx.betterend.registry.EndFeatures;
|
||||
import org.betterx.betterend.world.biome.EndBiome;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NightshadeRedwoods extends EndBiome.Config {
|
||||
public NightshadeRedwoods() {
|
||||
super("nightshade_redwoods");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addCustomBuildData(BCLBiomeBuilder builder) {
|
||||
Holder<Biome> biome = Integrations.BYG.getBiome("nightshade_forest");
|
||||
BiomeSpecialEffects effects = biome.value().getSpecialEffects();
|
||||
|
||||
builder.fogColor(140, 108, 47)
|
||||
.fogDensity(1.5F)
|
||||
.waterAndFogColor(55, 70, 186)
|
||||
.foliageColor(122, 17, 155)
|
||||
.particles(
|
||||
ParticleTypes.REVERSE_PORTAL,
|
||||
0.002F
|
||||
)
|
||||
//TODO: 1.18 surface rules
|
||||
// .setSurface(biome.getGenerationSettings()
|
||||
// .getSurfaceBuilder()
|
||||
// .get())
|
||||
.grassColor(48, 13, 89)
|
||||
.plantsColor(200, 125, 9)
|
||||
.feature(EndFeatures.END_LAKE_RARE)
|
||||
.feature(BYGFeatures.NIGHTSHADE_REDWOOD_TREE)
|
||||
.feature(BYGFeatures.NIGHTSHADE_MOSS_WOOD)
|
||||
.feature(BYGFeatures.NIGHTSHADE_MOSS);
|
||||
|
||||
if (BCLib.isClient()) {
|
||||
SoundEvent loop = effects.getAmbientLoopSoundEvent()
|
||||
.get();
|
||||
SoundEvent music = effects.getBackgroundMusic()
|
||||
.get()
|
||||
.getEvent();
|
||||
SoundEvent additions = effects.getAmbientAdditionsSettings()
|
||||
.get()
|
||||
.getSoundEvent();
|
||||
SoundEvent mood = effects.getAmbientMoodSettings()
|
||||
.get()
|
||||
.getSoundEvent();
|
||||
builder.loop(loop)
|
||||
.music(music)
|
||||
.additions(additions)
|
||||
.mood(mood);
|
||||
}
|
||||
biome.value().getGenerationSettings()
|
||||
.features()
|
||||
.forEach((list) -> {
|
||||
list.forEach((feature) -> {
|
||||
builder.feature(Decoration.VEGETAL_DECORATION, feature);
|
||||
});
|
||||
});
|
||||
|
||||
for (MobCategory group : MobCategory.values()) {
|
||||
List<SpawnerData> list = biome.value()
|
||||
.getMobSettings()
|
||||
.getMobs(group)
|
||||
.unwrap();
|
||||
list.forEach((entry) -> {
|
||||
builder.spawn((EntityType<? extends Mob>) entry.type, 1, entry.minCount, entry.maxCount);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,120 @@
|
|||
package org.betterx.betterend.integration.byg.biomes;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
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.placement.PlacedFeature;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.api.biomes.BCLBiomeBuilder;
|
||||
import org.betterx.betterend.integration.Integrations;
|
||||
import org.betterx.betterend.integration.byg.features.BYGFeatures;
|
||||
import org.betterx.betterend.registry.EndFeatures;
|
||||
import org.betterx.betterend.world.biome.EndBiome;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
||||
public class OldBulbisGardens extends EndBiome.Config {
|
||||
public OldBulbisGardens() {
|
||||
super("old_bulbis_gardens");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addCustomBuildData(BCLBiomeBuilder builder) {
|
||||
Holder<Biome> biome = Integrations.BYG.getBiome("bulbis_gardens");
|
||||
BiomeSpecialEffects effects = biome.value().getSpecialEffects();
|
||||
|
||||
Block ivis = Integrations.BYG.getBlock("ivis_phylium");
|
||||
// Block origin = biome.getGenerationSettings()
|
||||
// .getSurfaceBuilderConfig()
|
||||
// .getTopMaterial()
|
||||
// .getBlock();
|
||||
builder.fogColor(215, 132, 207)
|
||||
.fogDensity(1.8F)
|
||||
.waterAndFogColor(40, 0, 56)
|
||||
.foliageColor(122, 17, 155)
|
||||
.particles(
|
||||
ParticleTypes.REVERSE_PORTAL,
|
||||
0.002F
|
||||
)
|
||||
//TODO: 1.18 surface rules
|
||||
//.surface(ivis, origin)
|
||||
.feature(EndFeatures.END_LAKE_RARE)
|
||||
.feature(BYGFeatures.OLD_BULBIS_TREE);
|
||||
|
||||
if (BCLib.isClient()) {
|
||||
SoundEvent loop = effects.getAmbientLoopSoundEvent()
|
||||
.get();
|
||||
SoundEvent music = effects.getBackgroundMusic()
|
||||
.get()
|
||||
.getEvent();
|
||||
SoundEvent additions = effects.getAmbientAdditionsSettings()
|
||||
.get()
|
||||
.getSoundEvent();
|
||||
SoundEvent mood = effects.getAmbientMoodSettings()
|
||||
.get()
|
||||
.getSoundEvent();
|
||||
builder.loop(loop)
|
||||
.music(music)
|
||||
.additions(additions)
|
||||
.mood(mood);
|
||||
}
|
||||
|
||||
for (MobCategory group : MobCategory.values()) {
|
||||
List<SpawnerData> list = biome.value()
|
||||
.getMobSettings()
|
||||
.getMobs(group)
|
||||
.unwrap();
|
||||
list.forEach((entry) -> {
|
||||
builder.spawn((EntityType<? extends Mob>) entry.type, 1, entry.minCount, entry.maxCount);
|
||||
});
|
||||
}
|
||||
|
||||
List<HolderSet<PlacedFeature>> features = biome.value().getGenerationSettings()
|
||||
.features();
|
||||
HolderSet<PlacedFeature> vegetal = features.get(Decoration.VEGETAL_DECORATION.ordinal());
|
||||
if (vegetal.size() > 2) {
|
||||
Supplier<PlacedFeature> getter;
|
||||
//TODO: 1.18.2 BRING BACK FEATURE COPY CODE
|
||||
for (var placed : vegetal) {
|
||||
System.out.print(placed);
|
||||
}
|
||||
// // Trees (first two features)
|
||||
// // 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);
|
||||
// Holder<PlacedFeature> feature = getter.get();
|
||||
// ResourceLocation id = BetterEnd.makeID("obg_feature_" + i);
|
||||
// feature = Registry.register(
|
||||
// BuiltinRegistries.PLACED_FEATURE,
|
||||
// id,
|
||||
// feature
|
||||
// );
|
||||
// builder.feature(Decoration.VEGETAL_DECORATION, feature);
|
||||
// }
|
||||
// // Grasses and other features
|
||||
// for (int i = 2; i < vegetal.size(); i++) {
|
||||
// getter = vegetal.get(i);
|
||||
// Holder<PlacedFeature> feature = getter.get();
|
||||
// builder.feature(Decoration.VEGETAL_DECORATION, feature);
|
||||
// }
|
||||
}
|
||||
|
||||
builder.feature(EndFeatures.PURPLE_POLYPORE)
|
||||
.feature(BYGFeatures.IVIS_MOSS_WOOD)
|
||||
.feature(BYGFeatures.IVIS_MOSS)
|
||||
.feature(BYGFeatures.IVIS_VINE)
|
||||
.feature(BYGFeatures.IVIS_SPROUT);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package org.betterx.betterend.integration.byg.features;
|
||||
|
||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
|
||||
|
||||
import org.betterx.bclib.api.features.BCLCommonFeatures;
|
||||
import org.betterx.bclib.world.features.BCLFeature;
|
||||
import org.betterx.betterend.BetterEnd;
|
||||
import org.betterx.betterend.integration.Integrations;
|
||||
import org.betterx.betterend.integration.byg.BYGBlocks;
|
||||
import org.betterx.betterend.world.features.SinglePlantFeature;
|
||||
import org.betterx.betterend.world.features.VineFeature;
|
||||
import org.betterx.betterend.world.features.WallPlantFeature;
|
||||
import org.betterx.betterend.world.features.WallPlantOnLogFeature;
|
||||
|
||||
public class BYGFeatures {
|
||||
public static final BCLFeature OLD_BULBIS_TREE = redisterVegetation(
|
||||
"old_bulbis_tree",
|
||||
new OldBulbisTreeFeature(),
|
||||
1
|
||||
);
|
||||
public static final BCLFeature IVIS_SPROUT = redisterVegetation(
|
||||
"ivis_sprout",
|
||||
new SinglePlantFeature(Integrations.BYG.getBlock("ivis_sprout"), 6, 2),
|
||||
6
|
||||
);
|
||||
public static final BCLFeature IVIS_VINE = redisterVegetation(
|
||||
"ivis_vine",
|
||||
new VineFeature(BYGBlocks.IVIS_VINE, 24),
|
||||
5
|
||||
);
|
||||
public static final BCLFeature IVIS_MOSS = redisterVegetation(
|
||||
"ivis_moss",
|
||||
new WallPlantFeature(BYGBlocks.IVIS_MOSS, 6),
|
||||
1
|
||||
);
|
||||
public static final BCLFeature IVIS_MOSS_WOOD = redisterVegetation(
|
||||
"ivis_moss_wood",
|
||||
new WallPlantOnLogFeature(BYGBlocks.IVIS_MOSS, 6),
|
||||
15
|
||||
);
|
||||
public static final BCLFeature NIGHTSHADE_MOSS = redisterVegetation(
|
||||
"nightshade_moss",
|
||||
new WallPlantFeature(BYGBlocks.NIGHTSHADE_MOSS, 5),
|
||||
2
|
||||
);
|
||||
public static final BCLFeature NIGHTSHADE_MOSS_WOOD = redisterVegetation(
|
||||
"nightshade_moss_wood",
|
||||
new WallPlantOnLogFeature(BYGBlocks.NIGHTSHADE_MOSS, 5),
|
||||
8
|
||||
);
|
||||
|
||||
public static final BCLFeature NIGHTSHADE_REDWOOD_TREE = redisterVegetation(
|
||||
"nightshade_redwood_tree",
|
||||
new NightshadeRedwoodTreeFeature(),
|
||||
1
|
||||
);
|
||||
public static final BCLFeature BIG_ETHER_TREE = redisterVegetation("big_ether_tree", new BigEtherTreeFeature(), 1);
|
||||
|
||||
public static void register() {
|
||||
}
|
||||
|
||||
private static BCLFeature redisterVegetation(String name, Feature<NoneFeatureConfiguration> feature, int density) {
|
||||
return BCLCommonFeatures.makeVegetationFeature(BetterEnd.makeID(name), feature, density);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package org.betterx.betterend.integration.byg.features;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
|
||||
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 org.betterx.bclib.api.tag.CommonBlockTags;
|
||||
import org.betterx.bclib.sdf.SDF;
|
||||
import org.betterx.bclib.util.MHelper;
|
||||
import org.betterx.bclib.util.SplineHelper;
|
||||
import org.betterx.bclib.world.features.DefaultFeature;
|
||||
import org.betterx.betterend.integration.Integrations;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BigEtherTreeFeature extends DefaultFeature {
|
||||
@Override
|
||||
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
|
||||
final RandomSource random = featureConfig.random();
|
||||
final BlockPos pos = featureConfig.origin();
|
||||
final WorldGenLevel world = featureConfig.level();
|
||||
if (!world.getBlockState(pos.below()).is(CommonBlockTags.END_STONES)) return false;
|
||||
|
||||
BlockState log = Integrations.BYG.getDefaultState("ether_log");
|
||||
BlockState wood = Integrations.BYG.getDefaultState("ether_wood");
|
||||
Function<BlockPos, BlockState> splinePlacer = (bpos) -> {
|
||||
return log;
|
||||
};
|
||||
Function<BlockState, Boolean> replace = (state) -> {
|
||||
return state.is(CommonBlockTags.END_STONES) || 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;
|
||||
float startAngle = random.nextFloat() * MHelper.PI2;
|
||||
float length = (1 - splinePos) * height * 0.4F;
|
||||
int points = (int) (length / 3);
|
||||
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);
|
||||
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.is(CommonBlockTags.END_STONES) || 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;
|
||||
}
|
||||
return info.getState();
|
||||
}).fillRecursive(world, pos);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,200 @@
|
|||
package org.betterx.betterend.integration.byg.features;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.RandomSource;
|
||||
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.levelgen.feature.FeaturePlaceContext;
|
||||
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 org.betterx.bclib.api.tag.CommonBlockTags;
|
||||
import org.betterx.bclib.sdf.PosInfo;
|
||||
import org.betterx.bclib.sdf.SDF;
|
||||
import org.betterx.bclib.sdf.operator.SDFDisplacement;
|
||||
import org.betterx.bclib.sdf.operator.SDFFlatWave;
|
||||
import org.betterx.bclib.sdf.operator.SDFSmoothUnion;
|
||||
import org.betterx.bclib.sdf.primitive.SDFCappedCone;
|
||||
import org.betterx.bclib.sdf.primitive.SDFSphere;
|
||||
import org.betterx.bclib.util.BlocksHelper;
|
||||
import org.betterx.bclib.util.MHelper;
|
||||
import org.betterx.bclib.util.SplineHelper;
|
||||
import org.betterx.bclib.world.features.DefaultFeature;
|
||||
import org.betterx.betterend.integration.Integrations;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NightshadeRedwoodTreeFeature extends DefaultFeature {
|
||||
private static final List<Vector3f> BRANCH;
|
||||
|
||||
@Override
|
||||
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
|
||||
final RandomSource random = featureConfig.random();
|
||||
final BlockPos pos = featureConfig.origin();
|
||||
final WorldGenLevel world = featureConfig.level();
|
||||
if (!world.getBlockState(pos.below()).is(CommonBlockTags.END_STONES)) 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<BlockState, Boolean> replace = (state) -> {
|
||||
return state.is(CommonBlockTags.END_STONES) || 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))) {
|
||||
return wood;
|
||||
}
|
||||
return info.getState();
|
||||
};
|
||||
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;
|
||||
float max = height - 7;
|
||||
float startAngle = random.nextFloat() * MHelper.PI2;
|
||||
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.y() > max) {
|
||||
break;
|
||||
}
|
||||
List<Vector3f> branch = SplineHelper.copySpline(BRANCH);
|
||||
SplineHelper.rotateSpline(branch, i * 1.3F + startAngle);
|
||||
SplineHelper.scale(branch, scale);
|
||||
SplineHelper.offsetParts(branch, random, 0.3F, 0.3F, 0.3F);
|
||||
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);
|
||||
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.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.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;
|
||||
int rad = (int) (radius + 1);
|
||||
radius *= radius;
|
||||
for (int x = -rad; x <= rad; x++) {
|
||||
int x2 = x * x;
|
||||
for (int z = -rad; z <= rad; z++) {
|
||||
int z2 = z * z;
|
||||
if (x2 + z2 < radius - random.nextFloat() * rad) {
|
||||
BlockPos lp = p.offset(x, 0, z);
|
||||
if (world.isEmptyBlock(lp)) {
|
||||
BlocksHelper.setWithoutUpdate(world, lp, leaves);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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++) {
|
||||
int ax = Math.abs(x);
|
||||
mut.setX(x + info.getPos().getX());
|
||||
for (int z = -6; z < 7; z++) {
|
||||
int az = Math.abs(z);
|
||||
mut.setZ(z + info.getPos().getZ());
|
||||
for (int y = -6; y < 7; y++) {
|
||||
int ay = Math.abs(y);
|
||||
int d = ax + ay + az;
|
||||
if (d < 7) {
|
||||
mut.setY(y + info.getPos().getY());
|
||||
BlockState state = info.getState(mut);
|
||||
if (state.getBlock() instanceof LeavesBlock) {
|
||||
int distance = state.getValue(LeavesBlock.DISTANCE);
|
||||
if (d < distance) {
|
||||
info.setState(mut, state.setValue(LeavesBlock.DISTANCE, d));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return info.getState();
|
||||
};
|
||||
Function<PosInfo, BlockState> leavesPost2 = (info) -> {
|
||||
if (info.getState().getBlock() instanceof LeavesBlock) {
|
||||
int distance = info.getState().getValue(LeavesBlock.DISTANCE);
|
||||
if (distance > MHelper.randRange(2, 4, random)) {
|
||||
return Blocks.AIR.defaultBlockState();
|
||||
}
|
||||
for (Direction d : BlocksHelper.DIRECTIONS) {
|
||||
int airCount = 0;
|
||||
if (info.getState(d).isAir()) {
|
||||
airCount++;
|
||||
}
|
||||
if (airCount > 5) {
|
||||
return Blocks.AIR.defaultBlockState();
|
||||
}
|
||||
}
|
||||
if (random.nextInt(8) == 0) {
|
||||
return leaves_flower.setValue(LeavesBlock.DISTANCE, distance);
|
||||
}
|
||||
}
|
||||
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.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)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,214 @@
|
|||
package org.betterx.betterend.integration.byg.features;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.RandomSource;
|
||||
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.levelgen.feature.FeaturePlaceContext;
|
||||
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 org.betterx.bclib.api.tag.CommonBlockTags;
|
||||
import org.betterx.bclib.sdf.SDF;
|
||||
import org.betterx.bclib.sdf.operator.SDFDisplacement;
|
||||
import org.betterx.bclib.sdf.operator.SDFSubtraction;
|
||||
import org.betterx.bclib.sdf.operator.SDFTranslate;
|
||||
import org.betterx.bclib.sdf.operator.SDFUnion;
|
||||
import org.betterx.bclib.sdf.primitive.SDFSphere;
|
||||
import org.betterx.bclib.util.MHelper;
|
||||
import org.betterx.bclib.util.SplineHelper;
|
||||
import org.betterx.bclib.world.features.DefaultFeature;
|
||||
import org.betterx.betterend.integration.Integrations;
|
||||
import org.betterx.betterend.noise.OpenSimplexNoise;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class OldBulbisTreeFeature extends DefaultFeature {
|
||||
private static final List<Vector3f> SPLINE;
|
||||
private static final List<Vector3f> ROOT;
|
||||
private static final List<Vector3f> LEAF;
|
||||
private static final List<Vector3f> SIDE;
|
||||
|
||||
@Override
|
||||
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
|
||||
final RandomSource random = featureConfig.random();
|
||||
final BlockPos pos = featureConfig.origin();
|
||||
final WorldGenLevel world = featureConfig.level();
|
||||
if (!world.getBlockState(pos.below()).is(CommonBlockTags.END_STONES)) return false;
|
||||
if (!world.getBlockState(pos.below(4)).is(CommonBlockTags.GEN_END_STONES)) 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 glow = Integrations.BYG.getDefaultState("purple_shroomlight");
|
||||
|
||||
Function<BlockState, Boolean> replacement = (state) -> {
|
||||
if (state.equals(stem) || state.equals(wood) || state.is(CommonBlockTags.END_STONES) || 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 start = MHelper.randRange(0, MHelper.PI2, random);
|
||||
SDF sdf = null;
|
||||
int x1 = ((pos.getX() >> 4) << 4) - 16;
|
||||
int z1 = ((pos.getZ() >> 4) << 4) - 16;
|
||||
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);
|
||||
float sizeXZ = (size + MHelper.randRange(0, size * 0.5F, random)) * 0.7F;
|
||||
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
|
||||
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.offset(vec.x(), vec.y(), vec.z()), radius, cap, glow, wood, replacement, random);
|
||||
vec = SplineHelper.getPos(spline, 0.3F);
|
||||
makeRoots(world, pos.offset(vec.x(), vec.y(), vec.z()), 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))) {
|
||||
return wood;
|
||||
}
|
||||
return info.getState();
|
||||
}).fillArea(world, pos, limits);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void bigSphere(WorldGenLevel world,
|
||||
BlockPos pos,
|
||||
float radius,
|
||||
BlockState cap,
|
||||
BlockState glow,
|
||||
BlockState wood,
|
||||
Function<BlockState, Boolean> replacement,
|
||||
RandomSource 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.x() * 0.1, vec.y() * 0.1, vec.z() * 0.1);
|
||||
}).setSource(sphereInner);
|
||||
|
||||
SDF sphereGlow = new SDFSphere().setRadius(radius * 0.6F).setBlock(glow);
|
||||
sphereGlow = new SDFDisplacement().setFunction((vec) -> {
|
||||
return (float) noise.eval(vec.x() * 0.1, vec.y() * 0.1, vec.z() * 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;
|
||||
List<Vector3f> spline = SplineHelper.copySpline(LEAF);
|
||||
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 = 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.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 AABB(pos.above((int) offsetY)).inflate(radius * 1.3F));
|
||||
}
|
||||
|
||||
private void makeRoots(WorldGenLevel world,
|
||||
BlockPos pos,
|
||||
float radius,
|
||||
RandomSource 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.offset(last.x(), last.y(), last.z())).is(CommonBlockTags.GEN_END_STONES)) {
|
||||
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)
|
||||
);
|
||||
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)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
package org.betterx.betterend.integration.rei;
|
||||
|
||||
/*
|
||||
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;
|
||||
import me.shedaniel.rei.api.client.gui.widgets.Widget;
|
||||
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
|
||||
import me.shedaniel.rei.api.client.registry.display.DisplayCategory;
|
||||
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
|
||||
import me.shedaniel.rei.api.common.entry.EntryIngredient;
|
||||
import me.shedaniel.rei.api.common.entry.EntryStack;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
public class REIAlloyingCategory implements DisplayCategory<REIAlloyingDisplay> {
|
||||
private final EntryStack ICON;
|
||||
|
||||
REIAlloyingCategory(EntryStack icon) {
|
||||
ICON = icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull CategoryIdentifier getCategoryIdentifier() {
|
||||
return REIPlugin.ALLOYING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Component getTitle() {
|
||||
return Component.translatable(EndBlocks.END_STONE_SMELTER.getDescriptionId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull EntryStack getIcon() {
|
||||
return ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<Widget> setupDisplay(REIAlloyingDisplay display, Rectangle bounds) {
|
||||
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10);
|
||||
double smeltTime = display.getSmeltTime();
|
||||
DecimalFormat df = new DecimalFormat("###.##");
|
||||
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),
|
||||
Component.translatable("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<EntryIngredient> inputEntries = display.getInputEntries();
|
||||
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());
|
||||
}
|
||||
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 + 61, startPoint.y + 9))
|
||||
.entries(display.getOutputEntries().get(0))
|
||||
.disableBackground()
|
||||
.markOutput());
|
||||
return widgets;
|
||||
}
|
||||
|
||||
//TODO: 1.18 REI find replacement
|
||||
//@Override
|
||||
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.pushPose();
|
||||
matrices.translate(0, 0, 400);
|
||||
if (redSlots.contains(0)) {
|
||||
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.popPose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDisplayHeight() {
|
||||
return 49;
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -0,0 +1,108 @@
|
|||
package org.betterx.betterend.integration.rei;
|
||||
|
||||
/*
|
||||
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
|
||||
import me.shedaniel.rei.api.common.display.SimpleGridMenuDisplay;
|
||||
import me.shedaniel.rei.api.common.display.basic.BasicDisplay;
|
||||
import me.shedaniel.rei.api.common.entry.EntryStack;
|
||||
import me.shedaniel.rei.api.common.util.EntryIngredients;
|
||||
import me.shedaniel.rei.api.common.util.EntryStacks;
|
||||
import net.minecraft.ChatFormatting;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
||||
import ru.betterend.recipe.builders.AlloyingRecipe;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class REIAlloyingDisplay extends BasicDisplay implements SimpleGridMenuDisplay {
|
||||
|
||||
private static List<EntryStack> fuel;
|
||||
|
||||
private Recipe<?> recipe;
|
||||
private float xp;
|
||||
private double smeltTime;
|
||||
|
||||
|
||||
public REIAlloyingDisplay(AlloyingRecipe recipe) {
|
||||
this(recipe, recipe.getExperience(), recipe.getSmeltTime());
|
||||
}
|
||||
|
||||
protected REIAlloyingDisplay(Recipe<?> recipe, float xp, double smeltTime) {
|
||||
super(
|
||||
EntryIngredients.ofIngredients(recipe.getIngredients()),
|
||||
Collections.singletonList(EntryIngredients.of(recipe.getResultItem()))
|
||||
);
|
||||
this.recipe = recipe;
|
||||
this.xp = xp;
|
||||
this.smeltTime = smeltTime;
|
||||
}
|
||||
|
||||
|
||||
public static List<EntryStack> getFuel() {
|
||||
return fuel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Optional<ResourceLocation> getDisplayLocation() {
|
||||
return Optional.ofNullable(recipe).map(Recipe::getId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CategoryIdentifier<?> getCategoryIdentifier() {
|
||||
return REIPlugin.ALLOYING;
|
||||
}
|
||||
|
||||
// @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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<AbstractContainerMenu> containerInfo, AbstractContainerMenu container) {
|
||||
// return this.input;
|
||||
// }
|
||||
|
||||
static {
|
||||
fuel = EndStoneSmelterBlockEntity.availableFuels()
|
||||
.keySet()
|
||||
.stream()
|
||||
.map(Item::getDefaultInstance)
|
||||
.map(EntryStacks::of)
|
||||
.map(e -> e.setting(
|
||||
EntryStack.Settings.TOOLTIP_APPEND_EXTRA,
|
||||
stack -> Collections.singletonList(Component.translatable(
|
||||
"category.rei.smelting.fuel").withStyle(ChatFormatting.YELLOW))
|
||||
))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -0,0 +1,108 @@
|
|||
package org.betterx.betterend.integration.rei;
|
||||
/*
|
||||
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.client.gui.DisplayRenderer;
|
||||
import me.shedaniel.rei.api.client.gui.widgets.Slot;
|
||||
import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
|
||||
import me.shedaniel.rei.api.client.gui.widgets.Widget;
|
||||
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
|
||||
import me.shedaniel.rei.api.client.registry.display.DisplayCategory;
|
||||
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
|
||||
import me.shedaniel.rei.api.common.entry.EntryStack;
|
||||
import me.shedaniel.rei.api.common.util.EntryStacks;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import net.minecraft.world.item.Items;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
public class REIAlloyingFuelCategory implements DisplayCategory<REIAlloyingFuelDisplay> {
|
||||
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.##");
|
||||
|
||||
@Override
|
||||
public @NotNull CategoryIdentifier getCategoryIdentifier() {
|
||||
return REIPlugin.ALLOYING_FUEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Component getTitle() {
|
||||
return Component.translatable("category.rei.fuel");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDisplayHeight() {
|
||||
return 49;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull EntryStack getIcon() {
|
||||
return EntryStacks.of(Items.COAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Widget> setupDisplay(REIAlloyingFuelDisplay recipeDisplay, Rectangle bounds) {
|
||||
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 17);
|
||||
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),
|
||||
Component.translatable("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());
|
||||
return widgets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DisplayRenderer getDisplayRenderer(REIAlloyingFuelDisplay recipe) {
|
||||
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 DisplayRenderer() {
|
||||
private TranslatableComponent text = Component.translatable(
|
||||
"category.rei.fuel.time_short.items",
|
||||
burnItems
|
||||
);
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 22;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Tooltip getTooltip(Point point) {
|
||||
if (slot.containsMouse(point)) return slot.getCurrentTooltip(point);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
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().font.drawShadow(
|
||||
matrices,
|
||||
text.getVisualOrderText(),
|
||||
bounds.x + 25,
|
||||
bounds.y + 8,
|
||||
-1
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -0,0 +1,38 @@
|
|||
package org.betterx.betterend.integration.rei;
|
||||
/*
|
||||
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
|
||||
import me.shedaniel.rei.api.common.display.basic.BasicDisplay;
|
||||
import me.shedaniel.rei.api.common.entry.EntryIngredient;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class REIAlloyingFuelDisplay extends BasicDisplay {
|
||||
private final int fuelTime;
|
||||
|
||||
public REIAlloyingFuelDisplay(List<EntryIngredient> fuel, CompoundTag tag) {
|
||||
this(fuel, tag.getInt("fuelTime"));
|
||||
}
|
||||
|
||||
public REIAlloyingFuelDisplay(List<EntryIngredient> fuel, int fuelTime) {
|
||||
super(fuel, Collections.emptyList());
|
||||
this.fuelTime = fuelTime;
|
||||
}
|
||||
//public REIAlloyingFuelDisplay(EntryStack fuel, int fuelTime) {
|
||||
// this.fuel = fuel;
|
||||
// this.fuelTime = fuelTime;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public CategoryIdentifier<?> getCategoryIdentifier() {
|
||||
return REIPlugin.ALLOYING_FUEL;
|
||||
}
|
||||
|
||||
public int getFuelTime() {
|
||||
return fuelTime;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
*/
|
|
@ -0,0 +1,122 @@
|
|||
package org.betterx.betterend.integration.rei;
|
||||
/*
|
||||
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;
|
||||
import me.shedaniel.rei.api.client.gui.widgets.Widget;
|
||||
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
|
||||
import me.shedaniel.rei.api.client.registry.display.DisplayCategory;
|
||||
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
|
||||
import me.shedaniel.rei.api.common.entry.EntryIngredient;
|
||||
import me.shedaniel.rei.api.common.entry.EntryStack;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import ru.betterend.blocks.basis.EndAnvilBlock;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class REIAnvilCategory implements DisplayCategory<REIAnvilDisplay> {
|
||||
private final EntryStack<?>[] ANVILS;
|
||||
|
||||
REIAnvilCategory(EntryStack<?>[] anvils) {
|
||||
ANVILS = anvils;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CategoryIdentifier<REIAnvilDisplay> getCategoryIdentifier() {
|
||||
return REIPlugin.SMITHING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Component getTitle() {
|
||||
return Component.translatable(Blocks.ANVIL.getDescriptionId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull EntryStack<?> getIcon() {
|
||||
return ANVILS[0];
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull List<Widget> setupDisplay(REIAnvilDisplay display, Rectangle bounds) {
|
||||
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10);
|
||||
List<Widget> widgets = Lists.newArrayList();
|
||||
widgets.add(Widgets.createRecipeBase(bounds));
|
||||
int x = startPoint.x + 10;
|
||||
int y = startPoint.y;
|
||||
widgets.add(Widgets.createResultSlotBackground(new Point(x + 61, y + 5)));
|
||||
List<EntryIngredient> inputEntries = display.getInputEntries();
|
||||
EntryIngredient materials = inputEntries.get(1);
|
||||
int anvilLevel = display.getAnvilLevel();
|
||||
List<EntryStack<?>> anvils = Arrays.stream(ANVILS).filter(anvil -> {
|
||||
Object value = anvil.getValue();
|
||||
if (value instanceof ItemStack) {
|
||||
value = ((ItemStack) value).getItem();
|
||||
}
|
||||
Block block = ((BlockItem) value).getBlock();
|
||||
if (block instanceof EndAnvilBlock) {
|
||||
return ((EndAnvilBlock) block).getCraftingLevel() >= anvilLevel;
|
||||
}
|
||||
return anvilLevel == 1;
|
||||
}).collect(Collectors.toList());
|
||||
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),
|
||||
Component.translatable("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.getOutputEntries().get(0))
|
||||
.disableBackground()
|
||||
.markOutput());
|
||||
widgets.add(Widgets.createSlot(new Point(x - 9, y + 25)).entries(anvils));
|
||||
|
||||
return widgets;
|
||||
}
|
||||
|
||||
//TODO: 1.18 REI, find replacement
|
||||
//@Override
|
||||
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.pushPose();
|
||||
matrices.translate(0, 0, 400);
|
||||
if (redSlots.contains(0)) {
|
||||
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.popPose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDisplayHeight() {
|
||||
return 60;
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
|
@ -0,0 +1,63 @@
|
|||
package org.betterx.betterend.integration.rei;
|
||||
/*
|
||||
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
|
||||
import me.shedaniel.rei.api.common.display.SimpleGridMenuDisplay;
|
||||
import me.shedaniel.rei.api.common.display.basic.BasicDisplay;
|
||||
import me.shedaniel.rei.api.common.util.EntryIngredients;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.betterx.bclib.recipes.AnvilRecipe;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
|
||||
public class REIAnvilDisplay extends BasicDisplay implements SimpleGridMenuDisplay {
|
||||
|
||||
private final AnvilRecipe recipe;
|
||||
|
||||
public REIAnvilDisplay(AnvilRecipe recipe) {
|
||||
super(
|
||||
EntryIngredients.ofIngredients(recipe.getIngredients()),
|
||||
Collections.singletonList(EntryIngredients.of(recipe.getResultItem()))
|
||||
);
|
||||
this.recipe = recipe;
|
||||
|
||||
inputs.get(1).forEach(entryStack -> {
|
||||
if (entryStack.getValue() instanceof ItemStack itemStack) {
|
||||
itemStack.setCount(recipe.getInputCount());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public int getDamage() {
|
||||
return recipe.getDamage();
|
||||
}
|
||||
|
||||
public int getAnvilLevel() {
|
||||
return recipe.getAnvilLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Optional<ResourceLocation> getDisplayLocation() {
|
||||
return Optional.ofNullable(recipe).map(Recipe::getId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CategoryIdentifier<?> getCategoryIdentifier() {
|
||||
return REIPlugin.SMITHING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package org.betterx.betterend.integration.rei;
|
||||
/*
|
||||
import net.minecraft.world.item.crafting.BlastingRecipe;
|
||||
|
||||
public class REIBlastingDisplay extends REIAlloyingDisplay {
|
||||
public REIBlastingDisplay(BlastingRecipe recipe) {
|
||||
super(recipe, recipe.getExperience(), recipe.getCookingTime());
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -0,0 +1,9 @@
|
|||
package org.betterx.betterend.integration.rei;
|
||||
|
||||
public class REIContainer implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
//ContainerInfoHandler.registerContainerInfo(AlloyingRecipe.ID, CraftingContainerInfoWrapper.create(EndStoneSmelterScreenHandler.class));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
package org.betterx.betterend.integration.rei;
|
||||
/*
|
||||
import com.google.common.collect.Lists;
|
||||
import me.shedaniel.math.Point;
|
||||
import me.shedaniel.math.Rectangle;
|
||||
import me.shedaniel.rei.api.client.gui.widgets.Widget;
|
||||
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
|
||||
import me.shedaniel.rei.api.client.registry.display.DisplayCategory;
|
||||
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
|
||||
import me.shedaniel.rei.api.common.entry.EntryIngredient;
|
||||
import me.shedaniel.rei.api.common.entry.EntryStack;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.betterx.betterend.BetterEnd;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class REIInfusionCategory implements DisplayCategory<REIInfusionDisplay> {
|
||||
|
||||
private final static ResourceLocation BACKGROUND = BetterEnd.makeID("textures/gui/rei_infusion.png");
|
||||
private final EntryStack ICON;
|
||||
|
||||
REIInfusionCategory(EntryStack icon) {
|
||||
ICON = icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull CategoryIdentifier getCategoryIdentifier() {
|
||||
return REIPlugin.INFUSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Component getTitle() {
|
||||
return Component.translatable(EndBlocks.INFUSION_PEDESTAL.getDescriptionId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull EntryStack getIcon() {
|
||||
return ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<Widget> setupDisplay(REIInfusionDisplay display, Rectangle bounds) {
|
||||
Point centerPoint = new Point(bounds.getCenterX() - 34, bounds.getCenterY() - 2);
|
||||
List<Widget> widgets = Lists.newArrayList();
|
||||
widgets.add(Widgets.createRecipeBase(bounds));
|
||||
List<EntryIngredient> inputEntries = display.getInputEntries();
|
||||
List<EntryIngredient> outputEntries = display.getOutputEntries();
|
||||
if (inputEntries.size() < 9) {
|
||||
List<EntryIngredient> newList = new ArrayList<EntryIngredient>(9);
|
||||
newList.addAll(inputEntries);
|
||||
for (int i = inputEntries.size(); i < 9; i++) {
|
||||
newList.add(EntryIngredient.empty());
|
||||
}
|
||||
inputEntries = newList;
|
||||
}
|
||||
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),
|
||||
Component.translatable("category.rei.infusion.time&val", display.getInfusionTime())
|
||||
).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB));
|
||||
return widgets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDisplayHeight() {
|
||||
return 104;
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -0,0 +1,63 @@
|
|||
package org.betterx.betterend.integration.rei;
|
||||
/*
|
||||
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
|
||||
import me.shedaniel.rei.api.common.display.SimpleGridMenuDisplay;
|
||||
import me.shedaniel.rei.api.common.display.basic.BasicDisplay;
|
||||
import me.shedaniel.rei.api.common.util.EntryIngredients;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import ru.betterend.recipe.builders.InfusionRecipe;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
|
||||
public class REIInfusionDisplay extends BasicDisplay implements SimpleGridMenuDisplay {
|
||||
|
||||
private final InfusionRecipe recipe;
|
||||
private final int time;
|
||||
|
||||
public REIInfusionDisplay(InfusionRecipe recipe) {
|
||||
super(
|
||||
EntryIngredients.ofIngredients(recipe.getIngredients()),
|
||||
Collections.singletonList(EntryIngredients.of(recipe.getResultItem()))
|
||||
);
|
||||
this.recipe = recipe;
|
||||
this.time = recipe.getInfusionTime();
|
||||
}
|
||||
|
||||
public int getInfusionTime() {
|
||||
return this.time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Optional<ResourceLocation> getDisplayLocation() {
|
||||
return Optional.ofNullable(recipe).map(Recipe::getId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CategoryIdentifier<?> getCategoryIdentifier() {
|
||||
return REIPlugin.INFUSION;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public @NotNull List<List<EntryStack>> getRequiredEntries() {
|
||||
// return this.input;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<AbstractContainerMenu> containerInfo, AbstractContainerMenu container) {
|
||||
// return this.input;
|
||||
//}
|
||||
}
|
||||
*/
|
|
@ -0,0 +1,99 @@
|
|||
package org.betterx.betterend.integration.rei;
|
||||
/*
|
||||
import com.google.common.collect.Lists;
|
||||
import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
|
||||
import me.shedaniel.rei.api.client.registry.category.CategoryRegistry;
|
||||
import me.shedaniel.rei.api.client.registry.display.DisplayRegistry;
|
||||
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
|
||||
import me.shedaniel.rei.api.common.entry.EntryStack;
|
||||
import me.shedaniel.rei.api.common.util.EntryIngredients;
|
||||
import me.shedaniel.rei.api.common.util.EntryStacks;
|
||||
import me.shedaniel.rei.plugin.common.DefaultPlugin;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.BlastingRecipe;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import org.betterx.bclib.blocks.BaseFurnaceBlock;
|
||||
import org.betterx.bclib.recipes.AnvilRecipe;
|
||||
import org.betterx.betterend.BetterEnd;
|
||||
import ru.betterend.blocks.basis.EndAnvilBlock;
|
||||
import ru.betterend.recipe.builders.AlloyingRecipe;
|
||||
import ru.betterend.recipe.builders.InfusionRecipe;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
//https://github.com/shedaniel/RoughlyEnoughItems/blob/6.x-1.17/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java
|
||||
public class REIPlugin implements REIClientPlugin {
|
||||
public final static ResourceLocation PLUGIN_ID = BetterEnd.makeID("rei_plugin");
|
||||
public final static CategoryIdentifier<REIAlloyingFuelDisplay> ALLOYING_FUEL = CategoryIdentifier.of(
|
||||
BetterEnd.MOD_ID,
|
||||
"alloying_fuel"
|
||||
);
|
||||
public final static CategoryIdentifier<REIAlloyingDisplay> ALLOYING = CategoryIdentifier.of(
|
||||
BetterEnd.MOD_ID,
|
||||
AlloyingRecipe.GROUP
|
||||
);
|
||||
public final static CategoryIdentifier<REIAnvilDisplay> SMITHING = CategoryIdentifier.of(
|
||||
BetterEnd.MOD_ID,
|
||||
AnvilRecipe.ID.getPath()
|
||||
);
|
||||
public final static CategoryIdentifier<REIInfusionDisplay> INFUSION = CategoryIdentifier.of(
|
||||
BetterEnd.MOD_ID,
|
||||
InfusionRecipe.GROUP
|
||||
);
|
||||
|
||||
@Override
|
||||
public void registerDisplays(DisplayRegistry registry) {
|
||||
registry.registerRecipeFiller(AlloyingRecipe.class, AlloyingRecipe.TYPE, REIAlloyingDisplay::new);
|
||||
registry.registerRecipeFiller(BlastingRecipe.class, RecipeType.BLASTING, REIBlastingDisplay::new);
|
||||
registry.registerRecipeFiller(AnvilRecipe.class, AnvilRecipe.TYPE, REIAnvilDisplay::new);
|
||||
registry.registerRecipeFiller(InfusionRecipe.class, InfusionRecipe.TYPE, REIInfusionDisplay::new);
|
||||
|
||||
//TODO: 1.18 REI fix this
|
||||
// FuelRegistryImpl.INSTANCE.getFuelTimes().forEach((item, time) -> {
|
||||
// if (time >= 2000) {
|
||||
// final List<EntryIngredient> list = Collections.singletonList(EntryIngredients.of(item));
|
||||
// registry.add(new REIAlloyingFuelDisplay(list, time));
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCategories(CategoryRegistry registry) {
|
||||
EntryStack<ItemStack> endStoneSmelter = EntryStacks.of(EndBlocks.END_STONE_SMELTER);
|
||||
EntryStack<ItemStack> infusionRitual = EntryStacks.of(EndBlocks.INFUSION_PEDESTAL);
|
||||
List<EntryStack<?>> anvils = Lists.newArrayList(EntryIngredients.ofItems(EndBlocks.getModBlocks()
|
||||
.stream()
|
||||
.filter(EndAnvilBlock.class::isInstance)
|
||||
.collect(Collectors.toList())));
|
||||
anvils.add(0, EntryStacks.of(Blocks.ANVIL));
|
||||
List<EntryStack<?>> ITEM_FURNACES = Lists.newArrayList(EntryIngredients.ofItems(EndBlocks.getModBlocks()
|
||||
.stream()
|
||||
.filter(BaseFurnaceBlock.class::isInstance)
|
||||
.collect(Collectors.toList())));
|
||||
EntryStack<?>[] anvilsArray = anvils.toArray(new EntryStack[0]);
|
||||
EntryStack<?>[] ITEM_FURNACESArray = ITEM_FURNACES.toArray(new EntryStack[0]);
|
||||
|
||||
registry.add(
|
||||
new REIAlloyingFuelCategory(),
|
||||
new REIAlloyingCategory(endStoneSmelter),
|
||||
new REIInfusionCategory(infusionRitual),
|
||||
new REIAnvilCategory(anvilsArray)
|
||||
);
|
||||
|
||||
registry.addWorkstations(ALLOYING_FUEL, endStoneSmelter);
|
||||
registry.addWorkstations(ALLOYING, endStoneSmelter);
|
||||
registry.addWorkstations(INFUSION, infusionRitual);
|
||||
registry.addWorkstations(SMITHING, anvilsArray);
|
||||
registry.removePlusButton(ALLOYING_FUEL);
|
||||
registry.removePlusButton(SMITHING);
|
||||
|
||||
registry.addWorkstations(DefaultPlugin.SMELTING, ITEM_FURNACESArray);
|
||||
registry.addWorkstations(DefaultPlugin.FUEL, ITEM_FURNACESArray);
|
||||
}
|
||||
}
|
||||
*/
|
Loading…
Add table
Add a link
Reference in a new issue