[Feature] Build for 1.19.4

This commit is contained in:
Frank 2023-04-08 12:53:46 +02:00
parent 8a8e73348c
commit 55930d73d5
55 changed files with 380 additions and 304 deletions

@ -1 +1 @@
Subproject commit 02ea056d4050c11b1d0f9314baf6da6c08f05f42 Subproject commit 7ff96d5c744127d887861ad8c06b8c7400ec9880

View file

@ -1,20 +1,20 @@
# Done to increase the memory available to gradle. # Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx8G org.gradle.jvmargs=-Xmx8G
#Modrinth #Modrinth
modrinth_versions=["1.19.3"] modrinth_versions=["1.19.4"]
#`release`, `beta` or `alpha` #`release`, `beta` or `alpha`
release_channel=beta release_channel=beta
#Loom #Loom
loom_version=1.0-SNAPSHOT loom_version=1.0-SNAPSHOT
# Fabric Properties # Fabric Properties
# check these on https://fabricmc.net/versions.html # check these on https://fabricmc.net/versions.html
minecraft_version=1.19.3 minecraft_version=1.19.4
loader_version=0.14.11 loader_version=0.14.19
fabric_version=0.68.1+1.19.3 fabric_version=0.77.0+1.19.4
# Mod Properties # Mod Properties
mod_version=2.2.5 mod_version=2.3.0
maven_group=org.betterx.bclib maven_group=org.betterx.bclib
archives_base_name=bclib archives_base_name=bclib
# Dependencies # Dependencies
modmenu_version=5.0.1 modmenu_version=6.1.0-rc.3
emi_version=0.6.2+1.19.3 emi_version=0.7.3+1.19.4

View file

@ -7,6 +7,7 @@ import org.betterx.bclib.items.complex.EquipmentSet;
import net.minecraft.advancements.*; import net.minecraft.advancements.*;
import net.minecraft.advancements.critereon.*; import net.minecraft.advancements.critereon.*;
import net.minecraft.client.Minecraft;
import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.data.recipes.RecipeBuilder; import net.minecraft.data.recipes.RecipeBuilder;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
@ -199,7 +200,7 @@ public class AdvancementManager {
T recipe, T recipe,
AdvancementType type AdvancementType type
) { ) {
Item item = recipe.getResultItem().getItem(); Item item = recipe.getResultItem(Minecraft.getInstance().level.registryAccess()).getItem();
return create(item, type, displayBuilder -> displayBuilder.hideToast().hideFromChat()) return create(item, type, displayBuilder -> displayBuilder.hideToast().hideFromChat())
//.awardRecipe(item) //.awardRecipe(item)
.addRecipeUnlockCriterion("has_the_recipe", recipe) .addRecipeUnlockCriterion("has_the_recipe", recipe)

View file

@ -45,7 +45,7 @@ public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceW
Set<Holder<Biome>> dynamicPossibleBiomes; Set<Holder<Biome>> dynamicPossibleBiomes;
protected BCLBiomeSource(long seed) { protected BCLBiomeSource(long seed) {
super(List.of()); super();
this.dynamicPossibleBiomes = Set.of(); this.dynamicPossibleBiomes = Set.of();
this.currentSeed = seed; this.currentSeed = seed;
this.didCreatePickers = false; this.didCreatePickers = false;

View file

@ -28,6 +28,7 @@ import java.awt.*;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Stream;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWithConfig<BCLibEndBiomeSource, BCLEndBiomeSourceConfig> { public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWithConfig<BCLibEndBiomeSource, BCLEndBiomeSourceConfig> {
@ -94,6 +95,11 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
} }
} }
@Override
protected Stream<Holder<Biome>> collectPossibleBiomes() {
return null;
}
@Override @Override
protected BiomeAPI.BiomeType defaultBiomeType() { protected BiomeAPI.BiomeType defaultBiomeType() {
return BiomeAPI.BiomeType.END; return BiomeAPI.BiomeType.END;

View file

@ -27,6 +27,7 @@ import net.fabricmc.fabric.api.biome.v1.NetherBiomes;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Stream;
public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourceWithConfig<BCLibNetherBiomeSource, BCLNetherBiomeSourceConfig> { public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourceWithConfig<BCLibNetherBiomeSource, BCLNetherBiomeSourceConfig> {
public static final Codec<BCLibNetherBiomeSource> CODEC = RecordCodecBuilder public static final Codec<BCLibNetherBiomeSource> CODEC = RecordCodecBuilder
@ -78,6 +79,11 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
} }
} }
@Override
protected Stream<Holder<Biome>> collectPossibleBiomes() {
return null;
}
@Override @Override
protected BiomeAPI.BiomeType defaultBiomeType() { protected BiomeAPI.BiomeType defaultBiomeType() {
return BiomeAPI.BiomeType.NETHER; return BiomeAPI.BiomeType.NETHER;

View file

@ -30,7 +30,6 @@ import net.minecraft.world.level.storage.LevelStorageSource;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer; import java.util.function.Consumer;
public class LevelGenEvents { public class LevelGenEvents {
@ -73,17 +72,17 @@ public class LevelGenEvents {
return DataFixerAPI.fixData(storageAccess, allDone != null && BCLib.isClient(), allDone); return DataFixerAPI.fixData(storageAccess, allDone != null && BCLib.isClient(), allDone);
} }
private static Optional<Holder<WorldPreset>> adaptWorldPreset( private static Holder<WorldPreset> adaptWorldPreset(
Optional<Holder<WorldPreset>> currentPreset, Holder<WorldPreset> currentPreset,
WorldDimensions worldDims WorldDimensions worldDims
) { ) {
LevelStem endStem = worldDims.dimensions().get(LevelStem.END); LevelStem endStem = worldDims.dimensions().get(LevelStem.END);
//We probably loaded a Datapack for the End //We probably loaded a Datapack for the End
if (!(endStem.generator().getBiomeSource() instanceof BCLibEndBiomeSource)) { if (!(endStem.generator().getBiomeSource() instanceof BCLibEndBiomeSource)) {
if (currentPreset.isPresent()) { if (currentPreset != null) {
if (currentPreset.get().value() instanceof TogetherWorldPreset worldPreset) { if (currentPreset instanceof TogetherWorldPreset worldPreset) {
ResourceKey worldPresetKey = currentPreset.get().unwrapKey().orElse(null); ResourceKey worldPresetKey = currentPreset.unwrapKey().orElse(null);
//user did not configure/change the Preset! //user did not configure/change the Preset!
if (PresetsRegistry.BCL_WORLD.equals(worldPresetKey) if (PresetsRegistry.BCL_WORLD.equals(worldPresetKey)

View file

@ -93,7 +93,7 @@ public class BCLBiomeBuilder {
private BiomeSpecialEffects.Builder effectsBuilder; private BiomeSpecialEffects.Builder effectsBuilder;
private MobSpawnSettings.Builder spawnSettings; private MobSpawnSettings.Builder spawnSettings;
private SurfaceRules.RuleSource surfaceRule; private SurfaceRules.RuleSource surfaceRule;
private Precipitation precipitation; private boolean hasPrecipitation;
final private ResourceLocation biomeID; final private ResourceLocation biomeID;
@ -116,7 +116,7 @@ public class BCLBiomeBuilder {
BCLBiomeBuilder(ResourceLocation biomeID) { BCLBiomeBuilder(ResourceLocation biomeID) {
this.biomeID = biomeID; this.biomeID = biomeID;
this.precipitation = Precipitation.NONE; this.hasPrecipitation = false;
this.generationSettings = null; this.generationSettings = null;
this.effectsBuilder = null; this.effectsBuilder = null;
this.spawnSettings = null; this.spawnSettings = null;
@ -174,9 +174,21 @@ public class BCLBiomeBuilder {
* *
* @param precipitation {@link Precipitation} * @param precipitation {@link Precipitation}
* @return same {@link BCLBiomeBuilder} instance. * @return same {@link BCLBiomeBuilder} instance.
* @deprecated Use hasPrecipitation() instead
*/ */
@Deprecated(forRemoval = true)
public BCLBiomeBuilder precipitation(Precipitation precipitation) { public BCLBiomeBuilder precipitation(Precipitation precipitation) {
this.precipitation = precipitation; return hasPrecipitation(precipitation != Precipitation.NONE);
}
/**
* Set biome {@link Precipitation}. Affect biome visual effects (rain, snow, none).
*
* @param precipitation true, if this biome can have presipitation. Rain/Snow is determined by temperature
* @return same {@link BCLBiomeBuilder} instance.
*/
public BCLBiomeBuilder hasPrecipitation(boolean precipitation) {
this.hasPrecipitation = precipitation;
return this; return this;
} }
@ -948,7 +960,7 @@ public class BCLBiomeBuilder {
BiomeBuilder builder = new BiomeBuilder() BiomeBuilder builder = new BiomeBuilder()
.precipitation(precipitation) .hasPrecipitation(hasPrecipitation)
.temperature(temperature) .temperature(temperature)
.downfall(downfall); .downfall(downfall);

View file

@ -253,8 +253,8 @@ public class StructureWorldNBT extends StructureNBT {
float y1 = Math.min(offsetY, 0); float y1 = Math.min(offsetY, 0);
float y2 = Math.max(offsetY, 0); float y2 = Math.max(offsetY, 0);
BlockPos start = pos.offset(-(size.getX() >> 1), y1, -(size.getZ() >> 1)); BlockPos start = pos.offset(-(size.getX() >> 1), (int) y1, -(size.getZ() >> 1));
BlockPos end = pos.offset(size.getX() >> 1, y2, size.getZ() >> 1); BlockPos end = pos.offset(size.getX() >> 1, (int) y2, size.getZ() >> 1);
int count = 0; int count = 0;
for (int x = start.getX(); x <= end.getX(); x++) { for (int x = start.getX(); x <= end.getX(); x++) {

View file

@ -10,12 +10,12 @@ import net.minecraft.client.resources.model.BlockModelRotation;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.ButtonBlock; import net.minecraft.world.level.block.ButtonBlock;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.AttachFace; import net.minecraft.world.level.block.state.properties.AttachFace;
import net.minecraft.world.level.block.state.properties.BlockSetType;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
@ -30,14 +30,19 @@ import org.jetbrains.annotations.Nullable;
public abstract class BaseButtonBlock extends ButtonBlock implements BlockModelProvider { public abstract class BaseButtonBlock extends ButtonBlock implements BlockModelProvider {
private final Block parent; private final Block parent;
protected BaseButtonBlock(Block parent, Properties properties, boolean sensitive) { protected BaseButtonBlock(Block parent, Properties properties, boolean sensitive, BlockSetType type) {
this(parent, properties, 30, sensitive); this(parent, properties, 30, sensitive, type);
} }
protected BaseButtonBlock(Block parent, Properties properties, int ticksToStayPressed, boolean sensitive) { protected BaseButtonBlock(
Block parent,
Properties properties,
int ticksToStayPressed,
boolean sensitive,
BlockSetType type
) {
super( super(
properties.noCollission(), ticksToStayPressed, sensitive, properties.noCollission(), type, ticksToStayPressed, sensitive
SoundEvents.STONE_BUTTON_CLICK_OFF, SoundEvents.STONE_BUTTON_CLICK_ON
); );
this.parent = parent; this.parent = parent;
} }

View file

@ -13,7 +13,6 @@ import net.minecraft.client.resources.model.BlockModelRotation;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.tags.BlockTags; import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags; import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey; import net.minecraft.tags.TagKey;
@ -24,6 +23,7 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.DoorBlock; import net.minecraft.world.level.block.DoorBlock;
import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockSetType;
import net.minecraft.world.level.block.state.properties.DoorHingeSide; import net.minecraft.world.level.block.state.properties.DoorHingeSide;
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
@ -38,12 +38,12 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class BaseDoorBlock extends DoorBlock implements RenderLayerProvider, BlockModelProvider, TagProvider { public class BaseDoorBlock extends DoorBlock implements RenderLayerProvider, BlockModelProvider, TagProvider {
public BaseDoorBlock(Block source) { public BaseDoorBlock(Block source, BlockSetType type) {
this(Properties.copy(source).strength(3F, 3F).noOcclusion()); this(Properties.copy(source).strength(3F, 3F).noOcclusion(), type);
} }
public BaseDoorBlock(BlockBehaviour.Properties properties) { public BaseDoorBlock(BlockBehaviour.Properties properties, BlockSetType type) {
super(properties, SoundEvents.WOODEN_DOOR_CLOSE, SoundEvents.WOODEN_DOOR_OPEN); super(properties, type);
} }
@Override @Override

View file

@ -9,11 +9,11 @@ import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.FenceGateBlock; import net.minecraft.world.level.block.FenceGateBlock;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.WoodType;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
@ -28,8 +28,8 @@ import org.jetbrains.annotations.Nullable;
public class BaseGateBlock extends FenceGateBlock implements BlockModelProvider { public class BaseGateBlock extends FenceGateBlock implements BlockModelProvider {
private final Block parent; private final Block parent;
public BaseGateBlock(Block source) { public BaseGateBlock(Block source, WoodType type) {
super(Properties.copy(source).noOcclusion(), SoundEvents.FENCE_GATE_CLOSE, SoundEvents.FENCE_GATE_OPEN); super(Properties.copy(source).noOcclusion(), type);
this.parent = source; this.parent = source;
} }

View file

@ -9,11 +9,11 @@ import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.PressurePlateBlock; import net.minecraft.world.level.block.PressurePlateBlock;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockSetType;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
@ -28,10 +28,10 @@ import org.jetbrains.annotations.Nullable;
public class BasePressurePlateBlock extends PressurePlateBlock implements BlockModelProvider { public class BasePressurePlateBlock extends PressurePlateBlock implements BlockModelProvider {
private final Block parent; private final Block parent;
public BasePressurePlateBlock(Sensitivity rule, Block source) { public BasePressurePlateBlock(Sensitivity rule, Block source, BlockSetType type) {
super( super(
rule, Properties.copy(source).noCollission().noOcclusion().strength(0.5F), rule, Properties.copy(source).noCollission().noOcclusion().strength(0.5F),
SoundEvents.WOODEN_PRESSURE_PLATE_CLICK_OFF, SoundEvents.WOODEN_PRESSURE_PLATE_CLICK_ON type
); );
this.parent = source; this.parent = source;
} }

View file

@ -3,11 +3,12 @@ package org.betterx.bclib.blocks;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.properties.BlockSetType;
public class BaseStoneButtonBlock extends BaseButtonBlock { public class BaseStoneButtonBlock extends BaseButtonBlock {
public BaseStoneButtonBlock(Block source) { public BaseStoneButtonBlock(Block source, BlockSetType type) {
super(source, Properties.copy(source).noOcclusion(), false); super(source, Properties.copy(source).noOcclusion(), false, type);
} }
@Override @Override

View file

@ -11,12 +11,12 @@ import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.BlockModelRotation; import net.minecraft.client.resources.model.BlockModelRotation;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.TrapDoorBlock; import net.minecraft.world.level.block.TrapDoorBlock;
import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockSetType;
import net.minecraft.world.level.block.state.properties.Half; import net.minecraft.world.level.block.state.properties.Half;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
@ -27,12 +27,12 @@ import java.util.*;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class BaseTrapdoorBlock extends TrapDoorBlock implements RenderLayerProvider, BlockModelProvider { public class BaseTrapdoorBlock extends TrapDoorBlock implements RenderLayerProvider, BlockModelProvider {
public BaseTrapdoorBlock(Block source) { public BaseTrapdoorBlock(Block source, BlockSetType type) {
this(Properties.copy(source).strength(3.0F, 3.0F).noOcclusion()); this(Properties.copy(source).strength(3.0F, 3.0F).noOcclusion(), type);
} }
public BaseTrapdoorBlock(BlockBehaviour.Properties properties) { public BaseTrapdoorBlock(BlockBehaviour.Properties properties, BlockSetType type) {
super(properties, SoundEvents.WOODEN_TRAPDOOR_CLOSE, SoundEvents.WOODEN_TRAPDOOR_OPEN); super(properties, type);
} }
@Override @Override

View file

@ -9,11 +9,11 @@ import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.WeightedPressurePlateBlock; import net.minecraft.world.level.block.WeightedPressurePlateBlock;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockSetType;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
@ -28,7 +28,7 @@ import org.jetbrains.annotations.Nullable;
public class BaseWeightedPlateBlock extends WeightedPressurePlateBlock implements BlockModelProvider { public class BaseWeightedPlateBlock extends WeightedPressurePlateBlock implements BlockModelProvider {
private final Block parent; private final Block parent;
public BaseWeightedPlateBlock(Block source) { public BaseWeightedPlateBlock(Block source, BlockSetType type) {
super( super(
15, 15,
Properties.copy(source) Properties.copy(source)
@ -36,7 +36,7 @@ public class BaseWeightedPlateBlock extends WeightedPressurePlateBlock implement
.noOcclusion() .noOcclusion()
.requiresCorrectToolForDrops() .requiresCorrectToolForDrops()
.strength(0.5F), .strength(0.5F),
SoundEvents.METAL_PRESSURE_PLATE_CLICK_OFF, SoundEvents.METAL_PRESSURE_PLATE_CLICK_ON type
); );
this.parent = source; this.parent = source;
} }

View file

@ -3,11 +3,12 @@ package org.betterx.bclib.blocks;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.properties.BlockSetType;
public class BaseWoodenButtonBlock extends BaseButtonBlock { public class BaseWoodenButtonBlock extends BaseButtonBlock {
public BaseWoodenButtonBlock(Block source) { public BaseWoodenButtonBlock(Block source, BlockSetType type) {
super(source, Properties.copy(source).strength(0.5F, 0.5F).noOcclusion(), true); super(source, Properties.copy(source).strength(0.5F, 0.5F).noOcclusion(), true, type);
} }
@Override @Override

View file

@ -1,9 +1,10 @@
package org.betterx.bclib.blocks; package org.betterx.bclib.blocks;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.properties.BlockSetType;
public class StonePressurePlateBlock extends BasePressurePlateBlock { public class StonePressurePlateBlock extends BasePressurePlateBlock {
public StonePressurePlateBlock(Block source) { public StonePressurePlateBlock(Block source, BlockSetType type) {
super(Sensitivity.MOBS, source); super(Sensitivity.MOBS, source, type);
} }
} }

View file

@ -1,9 +1,10 @@
package org.betterx.bclib.blocks; package org.betterx.bclib.blocks;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.properties.BlockSetType;
public class WoodenPressurePlateBlock extends BasePressurePlateBlock { public class WoodenPressurePlateBlock extends BasePressurePlateBlock {
public WoodenPressurePlateBlock(Block source) { public WoodenPressurePlateBlock(Block source, BlockSetType type) {
super(Sensitivity.EVERYTHING, source); super(Sensitivity.EVERYTHING, source, type);
} }
} }

View file

@ -112,6 +112,18 @@ class ProgressLogoRender extends CustomRenderComponent<ProgressLogoRender> {
); );
} }
} }
private boolean focused;
@Override
public boolean isFocused() {
return focused;
}
@Override
public void setFocused(boolean bl) {
focused = bl;
}
} }
public class ProgressScreen extends LayoutScreen implements ProgressListener, AtomicProgressListener { public class ProgressScreen extends LayoutScreen implements ProgressListener, AtomicProgressListener {

View file

@ -7,12 +7,12 @@ import org.betterx.bclib.api.v2.generator.config.BCLNetherBiomeSourceConfig;
import org.betterx.bclib.api.v2.levelgen.LevelGenUtil; import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
import org.betterx.bclib.registry.PresetsRegistry; import org.betterx.bclib.registry.PresetsRegistry;
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset; import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
import org.betterx.worlds.together.worldPreset.WorldGenSettingsComponentAccessor;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.GuiComponent; import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen; import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen;
import net.minecraft.client.gui.screens.worldselection.WorldCreationContext; import net.minecraft.client.gui.screens.worldselection.WorldCreationContext;
import net.minecraft.client.gui.screens.worldselection.WorldCreationUiState;
import net.minecraft.core.Holder; import net.minecraft.core.Holder;
import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
@ -22,6 +22,7 @@ import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.levelgen.WorldDimensions; import net.minecraft.world.level.levelgen.WorldDimensions;
import net.minecraft.world.level.levelgen.presets.WorldPreset;
import net.minecraft.world.level.levelgen.presets.WorldPresets; import net.minecraft.world.level.levelgen.presets.WorldPresets;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
@ -34,7 +35,6 @@ import org.wunder.lib.ui.layout.values.Size;
import org.wunder.lib.ui.vanilla.LayoutScreen; import org.wunder.lib.ui.vanilla.LayoutScreen;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
@ -300,16 +300,14 @@ public class WorldSetupScreen extends LayoutScreen {
updateConfiguration(LevelStem.NETHER, BuiltinDimensionTypes.NETHER, endGenerator); updateConfiguration(LevelStem.NETHER, BuiltinDimensionTypes.NETHER, endGenerator);
} }
if (createWorldScreen.worldGenSettingsComponent instanceof WorldGenSettingsComponentAccessor acc final WorldCreationUiState acc = createWorldScreen.getUiState();
&& acc.bcl_getPreset() final Holder<WorldPreset> configuredPreset = acc.getWorldType().preset();
.isPresent() && acc.bcl_getPreset() if (configuredPreset != null && configuredPreset.value() instanceof TogetherWorldPreset worldPreset) {
.get() acc.setWorldType(new WorldCreationUiState.WorldTypeEntry(Holder.direct(
.value() instanceof TogetherWorldPreset worldPreset) {
acc.bcl_setPreset(Optional.of(Holder.direct(
worldPreset.withDimensions( worldPreset.withDimensions(
createWorldScreen createWorldScreen
.worldGenSettingsComponent .getUiState()
.settings() .getSettings()
.selectedDimensions() .selectedDimensions()
.dimensions() .dimensions()
) )
@ -323,7 +321,7 @@ public class WorldSetupScreen extends LayoutScreen {
ResourceKey<DimensionType> dimensionTypeKey, ResourceKey<DimensionType> dimensionTypeKey,
ChunkGenerator chunkGenerator ChunkGenerator chunkGenerator
) { ) {
createWorldScreen.worldGenSettingsComponent.updateSettings( createWorldScreen.getUiState().updateDimensions(
(registryAccess, worldDimensions) -> new WorldDimensions(LevelGenUtil.replaceGenerator( (registryAccess, worldDimensions) -> new WorldDimensions(LevelGenUtil.replaceGenerator(
dimensionKey, dimensionKey,
dimensionTypeKey, dimensionTypeKey,
@ -359,12 +357,10 @@ public class WorldSetupScreen extends LayoutScreen {
protected LayoutComponent<?, ?> initContent() { protected LayoutComponent<?, ?> initContent() {
BCLEndBiomeSourceConfig endConfig = BCLEndBiomeSourceConfig.VANILLA; BCLEndBiomeSourceConfig endConfig = BCLEndBiomeSourceConfig.VANILLA;
BCLNetherBiomeSourceConfig netherConfig = BCLNetherBiomeSourceConfig.VANILLA; BCLNetherBiomeSourceConfig netherConfig = BCLNetherBiomeSourceConfig.VANILLA;
if (createWorldScreen.worldGenSettingsComponent instanceof WorldGenSettingsComponentAccessor acc
&& acc.bcl_getPreset()
.isPresent() && acc.bcl_getPreset()
.get()
.value() instanceof TogetherWorldPreset wp) {
final WorldCreationUiState acc = createWorldScreen.getUiState();
final Holder<WorldPreset> configuredPreset = acc.getWorldType().preset();
if (configuredPreset.value() instanceof TogetherWorldPreset wp) {
LevelStem endStem = wp.getDimension(LevelStem.END); LevelStem endStem = wp.getDimension(LevelStem.END);
if (endStem != null && endStem.generator().getBiomeSource() instanceof BCLibEndBiomeSource bs) { if (endStem != null && endStem.generator().getBiomeSource() instanceof BCLibEndBiomeSource bs) {
endConfig = bs.getTogetherConfig(); endConfig = bs.getTogetherConfig();
@ -375,8 +371,8 @@ public class WorldSetupScreen extends LayoutScreen {
} }
} }
var netherPage = netherPage(netherConfig); LayoutComponent<?, ? extends LayoutComponent<?, ?>> netherPage = netherPage(netherConfig);
var endPage = endPage(endConfig); LayoutComponent<?, ? extends LayoutComponent<?, ?>> endPage = endPage(endConfig);
Tabs main = new Tabs(fill(), fill()).setPadding(8, 0, 0, 0); Tabs main = new Tabs(fill(), fill()).setPadding(8, 0, 0, 0);
main.addPage(Component.translatable("title.bclib.the_nether"), VerticalScroll.create(netherPage)); main.addPage(Component.translatable("title.bclib.the_nether"), VerticalScroll.create(netherPage));

View file

@ -3,7 +3,6 @@ package org.betterx.bclib.client.render;
import org.betterx.bclib.blockentities.BaseSignBlockEntity; import org.betterx.bclib.blockentities.BaseSignBlockEntity;
import org.betterx.bclib.blocks.BaseSignBlock; import org.betterx.bclib.blocks.BaseSignBlock;
import com.mojang.blaze3d.platform.NativeImage;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Axis; import com.mojang.math.Axis;
@ -20,6 +19,7 @@ import net.minecraft.client.renderer.blockentity.SignRenderer;
import net.minecraft.client.resources.model.Material; import net.minecraft.client.resources.model.Material;
import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.FastColor;
import net.minecraft.util.FormattedCharSequence; import net.minecraft.util.FormattedCharSequence;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -85,10 +85,10 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
matrixStack.translate(0.0D, 0.3333333432674408D, 0.046666666865348816D); matrixStack.translate(0.0D, 0.3333333432674408D, 0.046666666865348816D);
matrixStack.scale(0.010416667F, -0.010416667F, 0.010416667F); matrixStack.scale(0.010416667F, -0.010416667F, 0.010416667F);
int m = signBlockEntity.getColor().getTextColor(); int m = signBlockEntity.getColor().getTextColor();
int n = (int) (NativeImage.getR(m) * 0.4D); int n = (int) (FastColor.ARGB32.red(m) * 0.4D);
int o = (int) (NativeImage.getG(m) * 0.4D); int o = (int) (FastColor.ARGB32.green(m) * 0.4D);
int p = (int) (NativeImage.getB(m) * 0.4D); int p = (int) (FastColor.ARGB32.blue(m) * 0.4D);
int q = NativeImage.combine(0, p, o, n); int q = FastColor.ARGB32.color(0, p, o, n);
FormattedCharSequence[] formattedCharSequences = signBlockEntity.getRenderMessages( FormattedCharSequence[] formattedCharSequences = signBlockEntity.getRenderMessages(
Minecraft.getInstance() Minecraft.getInstance()
@ -114,11 +114,12 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
for (int s = 0; s < 4; ++s) { for (int s = 0; s < 4; ++s) {
FormattedCharSequence formattedCharSequence = formattedCharSequences[s]; FormattedCharSequence formattedCharSequence = formattedCharSequences[s];
float t = (float) (-this.font.width(formattedCharSequence) / 2); float t = (float) (-this.font.width(formattedCharSequence) / 2);
int marginHeight = 4 * signBlockEntity.getTextLineHeight() / 2;
if (drawOutlined) { if (drawOutlined) {
this.font.drawInBatch8xOutline( this.font.drawInBatch8xOutline(
formattedCharSequence, formattedCharSequence,
t, t,
(float) (s * 10 - 20), (float) (s * signBlockEntity.getTextLineHeight() - marginHeight),
drawColor, drawColor,
m, m,
matrixStack.last().pose(), matrixStack.last().pose(),
@ -129,12 +130,12 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
this.font.drawInBatch( this.font.drawInBatch(
formattedCharSequence, formattedCharSequence,
t, t,
(float) (s * 10 - 20), (float) (s * signBlockEntity.getTextLineHeight() - marginHeight),
drawColor, drawColor,
false, false,
matrixStack.last().pose(), matrixStack.last().pose(),
provider, provider,
false, Font.DisplayMode.NORMAL,
0, 0,
drawLight drawLight
); );

View file

@ -194,7 +194,7 @@ public class CommandRegistry {
final ServerPlayer player = source.getPlayerOrException(); final ServerPlayer player = source.getPlayerOrException();
Vec3 pos = source.getPosition(); Vec3 pos = source.getPosition();
final ServerLevel level = source.getLevel(); final ServerLevel level = source.getLevel();
MutableBlockPos mPos = new BlockPos(pos).mutable(); MutableBlockPos mPos = new BlockPos((int) pos.x, (int) pos.y, (int) pos.z).mutable();
System.out.println("Staring at: " + mPos + " -> " + level.getBlockState(mPos)); System.out.println("Staring at: " + mPos + " -> " + level.getBlockState(mPos));
boolean found = org.betterx.bclib.util.BlocksHelper.findSurroundingSurface( boolean found = org.betterx.bclib.util.BlocksHelper.findSurroundingSurface(
level, level,
@ -204,7 +204,11 @@ public class CommandRegistry {
state -> BlocksHelper.isTerrain(state) state -> BlocksHelper.isTerrain(state)
); );
System.out.println("Ending at: " + mPos + " -> " + level.getBlockState(mPos) + " = " + found); System.out.println("Ending at: " + mPos + " -> " + level.getBlockState(mPos) + " = " + found);
org.betterx.bclib.util.BlocksHelper.setWithoutUpdate(level, new BlockPos(pos), Blocks.YELLOW_CONCRETE); org.betterx.bclib.util.BlocksHelper.setWithoutUpdate(
level,
new BlockPos((int) pos.x, (int) pos.y, (int) pos.z),
Blocks.YELLOW_CONCRETE
);
org.betterx.bclib.util.BlocksHelper.setWithoutUpdate(level, mPos, Blocks.LIGHT_BLUE_CONCRETE); org.betterx.bclib.util.BlocksHelper.setWithoutUpdate(level, mPos, Blocks.LIGHT_BLUE_CONCRETE);
return Command.SINGLE_SUCCESS; return Command.SINGLE_SUCCESS;
} }

View file

@ -1,12 +1,33 @@
package org.betterx.bclib.complexmaterials; package org.betterx.bclib.complexmaterials;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.properties.BlockSetType;
import net.minecraft.world.level.block.state.properties.WoodType; import net.minecraft.world.level.block.state.properties.WoodType;
public class BCLWoodType extends WoodType { public class BCLWoodType extends WoodType {
private String modID; private String modID;
protected BCLWoodType(String modID, String string) { protected BCLWoodType(String modID, String string) {
super(string); super(string, new BlockSetType(modID + "_" + string));
this.modID = modID;
}
protected BCLWoodType(String modID, String string, BlockSetType setType) {
super(string, setType);
this.modID = modID;
}
protected BCLWoodType(
String modID,
String string,
BlockSetType setType,
SoundType soundType,
SoundType hangingSignSoundType,
SoundEvent fenceGateClose,
SoundEvent fenceGateOpen
) {
super(string, setType, soundType, hangingSignSoundType, fenceGateClose, fenceGateOpen);
this.modID = modID; this.modID = modID;
} }
} }

View file

@ -157,34 +157,40 @@ public class WoodenComplexMaterial extends ComplexMaterial {
addBlockEntry(new BlockEntry( addBlockEntry(new BlockEntry(
BLOCK_GATE, BLOCK_GATE,
(complexMaterial, settings) -> new BaseGateBlock(getBlock(BLOCK_PLANKS)) (complexMaterial, settings) -> new BaseGateBlock(getBlock(BLOCK_PLANKS), this.woodType)
) )
.setBlockTags(BlockTags.FENCE_GATES)); .setBlockTags(BlockTags.FENCE_GATES));
addBlockEntry(new BlockEntry( addBlockEntry(new BlockEntry(
BLOCK_BUTTON, BLOCK_BUTTON,
(complexMaterial, settings) -> new BaseWoodenButtonBlock(getBlock(BLOCK_PLANKS)) (complexMaterial, settings) -> new BaseWoodenButtonBlock(
getBlock(BLOCK_PLANKS),
this.woodType.setType()
)
) )
.setBlockTags(BlockTags.BUTTONS, BlockTags.WOODEN_BUTTONS) .setBlockTags(BlockTags.BUTTONS, BlockTags.WOODEN_BUTTONS)
.setItemTags(ItemTags.BUTTONS, ItemTags.WOODEN_BUTTONS)); .setItemTags(ItemTags.BUTTONS, ItemTags.WOODEN_BUTTONS));
addBlockEntry(new BlockEntry( addBlockEntry(new BlockEntry(
BLOCK_PRESSURE_PLATE, BLOCK_PRESSURE_PLATE,
(complexMaterial, settings) -> new WoodenPressurePlateBlock(getBlock(BLOCK_PLANKS)) (complexMaterial, settings) -> new WoodenPressurePlateBlock(
getBlock(BLOCK_PLANKS),
this.woodType.setType()
)
) )
.setBlockTags(BlockTags.PRESSURE_PLATES, BlockTags.WOODEN_PRESSURE_PLATES) .setBlockTags(BlockTags.PRESSURE_PLATES, BlockTags.WOODEN_PRESSURE_PLATES)
.setItemTags(ItemTags.WOODEN_PRESSURE_PLATES)); .setItemTags(ItemTags.WOODEN_PRESSURE_PLATES));
addBlockEntry(new BlockEntry( addBlockEntry(new BlockEntry(
BLOCK_TRAPDOOR, BLOCK_TRAPDOOR,
(complexMaterial, settings) -> new BaseTrapdoorBlock(getBlock(BLOCK_PLANKS)) (complexMaterial, settings) -> new BaseTrapdoorBlock(getBlock(BLOCK_PLANKS), this.woodType.setType())
) )
.setBlockTags(BlockTags.TRAPDOORS, BlockTags.WOODEN_TRAPDOORS) .setBlockTags(BlockTags.TRAPDOORS, BlockTags.WOODEN_TRAPDOORS)
.setItemTags(ItemTags.TRAPDOORS, ItemTags.WOODEN_TRAPDOORS)); .setItemTags(ItemTags.TRAPDOORS, ItemTags.WOODEN_TRAPDOORS));
addBlockEntry(new BlockEntry( addBlockEntry(new BlockEntry(
BLOCK_DOOR, BLOCK_DOOR,
(complexMaterial, settings) -> new BaseDoorBlock(getBlock(BLOCK_PLANKS)) (complexMaterial, settings) -> new BaseDoorBlock(getBlock(BLOCK_PLANKS), this.woodType.setType())
) )
.setBlockTags(BlockTags.DOORS, BlockTags.WOODEN_DOORS) .setBlockTags(BlockTags.DOORS, BlockTags.WOODEN_DOORS)
.setItemTags(ItemTags.DOORS, ItemTags.WOODEN_DOORS)); .setItemTags(ItemTags.DOORS, ItemTags.WOODEN_DOORS));

View file

@ -1,5 +1,6 @@
package org.betterx.bclib.integration.emi; package org.betterx.bclib.integration.emi;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.Container; import net.minecraft.world.Container;
@ -35,7 +36,7 @@ public abstract class EMIAbstractAlloyingRecipe<C extends Container, T extends R
: EmiIngredient.of(Ingredient.EMPTY) : EmiIngredient.of(Ingredient.EMPTY)
); );
this.output = List.of(EmiStack.of(recipe.getResultItem())); this.output = List.of(EmiStack.of(recipe.getResultItem(Minecraft.getInstance().level.registryAccess())));
this.fuelMultiplier = fuelMultiplier; this.fuelMultiplier = fuelMultiplier;
this.infiniBurn = infiniBurn; this.infiniBurn = infiniBurn;
} }

View file

@ -3,6 +3,7 @@ package org.betterx.bclib.integration.emi;
import org.betterx.bclib.BCLib; import org.betterx.bclib.BCLib;
import org.betterx.bclib.recipes.AnvilRecipe; import org.betterx.bclib.recipes.AnvilRecipe;
import net.minecraft.client.Minecraft;
import net.minecraft.core.Holder; import net.minecraft.core.Holder;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
@ -36,7 +37,7 @@ public class EMIAnvilRecipe implements EmiRecipe {
EmiIngredient.of(recipe.getMainIngredient(), recipe.getInputCount()), EmiIngredient.of(recipe.getMainIngredient(), recipe.getInputCount()),
EmiIngredient.of(Ingredient.of(hammer)) EmiIngredient.of(Ingredient.of(hammer))
); );
this.output = List.of(EmiStack.of(recipe.getResultItem())); this.output = List.of(EmiStack.of(recipe.getResultItem(Minecraft.getInstance().level.registryAccess())));
this.category = EMIPlugin.getAnvilCategoryForLevel(recipe.getAnvilLevel()); this.category = EMIPlugin.getAnvilCategoryForLevel(recipe.getAnvilLevel());
} }

View file

@ -67,16 +67,104 @@ public class EMIAnvilRecipeCategory extends EmiRecipeCategory {
final int yy = y + 6 + 3; final int yy = y + 6 + 3;
final Matrix4f matrix = stack.last().pose(); final Matrix4f matrix = stack.last().pose();
font.drawInBatch(content, xx - 1, yy - 1, 0xFF000000, false, matrix, bufferSource, false, 0, 0xF000F0); font.drawInBatch(
font.drawInBatch(content, xx, yy - 1, 0xFF000000, false, matrix, bufferSource, false, 0, 0xF000F0); content,
font.drawInBatch(content, xx + 1, yy - 1, 0xFF000000, false, matrix, bufferSource, false, 0, 0xF000F0); xx - 1,
font.drawInBatch(content, xx - 1, yy, 0xFF000000, false, matrix, bufferSource, false, 0, 0xF000F0); yy - 1,
font.drawInBatch(content, xx + 1, yy, 0xFF000000, false, matrix, bufferSource, false, 0, 0xF000F0); 0xFF000000,
font.drawInBatch(content, xx - 1, yy + 1, 0xFF000000, false, matrix, bufferSource, false, 0, 0xF000F0); false,
font.drawInBatch(content, xx + 1, yy + 1, 0xFF000000, false, matrix, bufferSource, false, 0, 0xF000F0); matrix,
font.drawInBatch(content, xx, yy + 1, 0xFF000000, false, matrix, bufferSource, false, 0, 0xF000F0); bufferSource,
Font.DisplayMode.NORMAL,
0,
0xF000F0
);
font.drawInBatch(
content,
xx,
yy - 1,
0xFF000000,
false,
matrix,
bufferSource,
Font.DisplayMode.NORMAL,
0,
0xF000F0
);
font.drawInBatch(
content,
xx + 1,
yy - 1,
0xFF000000,
false,
matrix,
bufferSource,
Font.DisplayMode.NORMAL,
0,
0xF000F0
);
font.drawInBatch(
content,
xx - 1,
yy,
0xFF000000,
false,
matrix,
bufferSource,
Font.DisplayMode.NORMAL,
0,
0xF000F0
);
font.drawInBatch(
content,
xx + 1,
yy,
0xFF000000,
false,
matrix,
bufferSource,
Font.DisplayMode.NORMAL,
0,
0xF000F0
);
font.drawInBatch(
content,
xx - 1,
yy + 1,
0xFF000000,
false,
matrix,
bufferSource,
Font.DisplayMode.NORMAL,
0,
0xF000F0
);
font.drawInBatch(
content,
xx + 1,
yy + 1,
0xFF000000,
false,
matrix,
bufferSource,
Font.DisplayMode.NORMAL,
0,
0xF000F0
);
font.drawInBatch(
content,
xx,
yy + 1,
0xFF000000,
false,
matrix,
bufferSource,
Font.DisplayMode.NORMAL,
0,
0xF000F0
);
font.drawInBatch(content, xx, yy, 0xFFFFFFFF, true, matrix, bufferSource, false, 0, 0xF000F0); font.drawInBatch(content, xx, yy, 0xFFFFFFFF, true, matrix, bufferSource, Font.DisplayMode.NORMAL, 0, 0xF000F0);
bufferSource.endBatch(); bufferSource.endBatch();
} }

View file

@ -25,10 +25,10 @@ public class BaseArmorItem extends ArmorItem implements ItemModelProvider {
protected final Multimap<Attribute, AttributeModifier> defaultModifiers; protected final Multimap<Attribute, AttributeModifier> defaultModifiers;
public BaseArmorItem(ArmorMaterial material, EquipmentSlot equipmentSlot, Properties settings) { public BaseArmorItem(ArmorMaterial material, Type type, Properties settings) {
super(material, equipmentSlot, settings); super(material, type, settings);
this.defaultModifiers = HashMultimap.create(); this.defaultModifiers = HashMultimap.create();
UUID uuid = ARMOR_MODIFIER_UUID_PER_SLOT[equipmentSlot.getIndex()]; UUID uuid = ARMOR_MODIFIER_UUID_PER_SLOT[type.getSlot().getIndex()];
addAttributeModifier( addAttributeModifier(
Attributes.ARMOR, Attributes.ARMOR,
new AttributeModifier(uuid, "Armor modifier", getDefense(), AttributeModifier.Operation.ADDITION) new AttributeModifier(uuid, "Armor modifier", getDefense(), AttributeModifier.Operation.ADDITION)
@ -52,7 +52,7 @@ public class BaseArmorItem extends ArmorItem implements ItemModelProvider {
@Override @Override
public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(EquipmentSlot equipmentSlot) { public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(EquipmentSlot equipmentSlot) {
return equipmentSlot == slot ? defaultModifiers : super.getDefaultAttributeModifiers(equipmentSlot); return equipmentSlot == type.getSlot() ? defaultModifiers : super.getDefaultAttributeModifiers(equipmentSlot);
} }
protected void addAttributeModifier(Attribute attribute, AttributeModifier modifier) { protected void addAttributeModifier(Attribute attribute, AttributeModifier modifier) {

View file

@ -49,13 +49,13 @@ public class EquipmentDescription<I extends Item> {
if (tool instanceof ShearsItem) { if (tool instanceof ShearsItem) {
builder.setShape(" #", "# "); builder.setShape(" #", "# ");
} else if (tool instanceof BaseArmorItem bai) { } else if (tool instanceof BaseArmorItem bai) {
if (bai.getSlot() == EquipmentSlot.FEET) { if (bai.getType().getSlot() == EquipmentSlot.FEET) {
builder.setShape("# #", "# #"); builder.setShape("# #", "# #");
} else if (bai.getSlot() == EquipmentSlot.HEAD) { } else if (bai.getType().getSlot() == EquipmentSlot.HEAD) {
builder.setShape("###", "# #"); builder.setShape("###", "# #");
} else if (bai.getSlot() == EquipmentSlot.CHEST) { } else if (bai.getType().getSlot() == EquipmentSlot.CHEST) {
builder.setShape("# #", "###", "###"); builder.setShape("# #", "###", "###");
} else if (bai.getSlot() == EquipmentSlot.LEGS) { } else if (bai.getType().getSlot() == EquipmentSlot.LEGS) {
builder.setShape("###", "# #", "# #"); builder.setShape("###", "# #", "# #");
} else return true; } else return true;
} else { } else {

View file

@ -37,6 +37,18 @@ public class AnvilScreenMixin extends ItemCombinerScreen<AnvilMenu> {
super(handler, playerInventory, title, texture); super(handler, playerInventory, title, texture);
} }
@Override
protected void renderErrorIcon(PoseStack poseStack, int i, int j) {
if (this.hasRecipeError()) {
blit(poseStack, i + 65, j + 46, this.imageWidth, 0, 28, 21);
}
}
private boolean hasRecipeError() {
//TODO: 1.19.4 check error conditions
return false;
}
@Inject(method = "subInit", at = @At("TAIL")) @Inject(method = "subInit", at = @At("TAIL"))
protected void be_subInit(CallbackInfo info) { protected void be_subInit(CallbackInfo info) {
int x = (width - imageWidth) / 2; int x = (width - imageWidth) / 2;

View file

@ -2,17 +2,17 @@ package org.betterx.bclib.mixin.client;
import org.betterx.bclib.api.v2.dataexchange.DataExchangeAPI; import org.betterx.bclib.api.v2.dataexchange.DataExchangeAPI;
import net.minecraft.client.Game; import net.minecraft.client.multiplayer.ClientPacketListener;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(Game.class) @Mixin(ClientPacketListener.class)
public class GameMixin { public class ClientPacketListenerMixin {
@Inject(method = "onStartGameSession", at = @At("TAIL")) @Inject(method = "handleLogin", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/telemetry/WorldSessionTelemetryManager;onPlayerInfoReceived(Lnet/minecraft/world/level/GameType;Z)V"))
public void bclib_onStart(CallbackInfo ci) { public void bclib_onStart(CallbackInfo ci) {
DataExchangeAPI.sendOnEnter(); DataExchangeAPI.sendOnEnter();
} }

View file

@ -5,6 +5,7 @@ import org.betterx.bclib.blocks.LeveledAnvilBlock;
import org.betterx.bclib.interfaces.AnvilScreenHandlerExtended; import org.betterx.bclib.interfaces.AnvilScreenHandlerExtended;
import org.betterx.bclib.recipes.AnvilRecipe; import org.betterx.bclib.recipes.AnvilRecipe;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.tags.BlockTags; import net.minecraft.tags.BlockTags;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
@ -164,7 +165,7 @@ public abstract class AnvilMenuMixin extends ItemCombinerMenu implements AnvilSc
private void be_updateResult() { private void be_updateResult() {
if (be_currentRecipe == null) return; if (be_currentRecipe == null) return;
resultSlots.setItem(0, be_currentRecipe.assemble(inputSlots)); resultSlots.setItem(0, be_currentRecipe.assemble(inputSlots, Minecraft.getInstance().level.registryAccess()));
broadcastChanges(); broadcastChanges();
} }

View file

@ -8,11 +8,7 @@ import net.minecraft.world.level.biome.BiomeSource;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.List;
import java.util.Set; import java.util.Set;
@Mixin(BiomeSource.class) @Mixin(BiomeSource.class)
@ -26,14 +22,4 @@ public abstract class BiomeSourceMixin implements BiomeSourceAccessor {
BCLib.LOGGER.info("Rebuilding features in BiomeSource " + this); BCLib.LOGGER.info("Rebuilding features in BiomeSource " + this);
//featuresPerStep = Suppliers.memoize(() -> FeatureSorter.buildFeaturesPerStep(this.possibleBiomes().stream().toList(), true)); //featuresPerStep = Suppliers.memoize(() -> FeatureSorter.buildFeaturesPerStep(this.possibleBiomes().stream().toList(), true));
} }
@Inject(method = "<init>(Ljava/util/List;)V", at = @At("TAIL"))
public void bcl_init(List list, CallbackInfo ci) {
// System.out.println("new BiomeSource (" + Integer.toHexString(hashCode()) + ", biomes=" + possibleBiomes().size() + ")");
// if (possibleBiomes().size() == 27) {
// System.out.println("Nether????");
// } else if (possibleBiomes().size() == 2) {
// System.out.println("Datapack Nether???");
// }
}
} }

View file

@ -5,6 +5,7 @@ import org.betterx.worlds.together.world.BiomeSourceWithNoiseRelatedSettings;
import org.betterx.worlds.together.world.BiomeSourceWithSeed; import org.betterx.worlds.together.world.BiomeSourceWithSeed;
import net.minecraft.core.Holder; import net.minecraft.core.Holder;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@ -34,6 +35,7 @@ public abstract class ServerLevelMixin extends Level {
protected ServerLevelMixin( protected ServerLevelMixin(
WritableLevelData writableLevelData, WritableLevelData writableLevelData,
ResourceKey<Level> resourceKey, ResourceKey<Level> resourceKey,
RegistryAccess registryAccess,
Holder<DimensionType> holder, Holder<DimensionType> holder,
Supplier<ProfilerFiller> supplier, Supplier<ProfilerFiller> supplier,
boolean bl, boolean bl,
@ -41,7 +43,7 @@ public abstract class ServerLevelMixin extends Level {
long l, long l,
int i int i
) { ) {
super(writableLevelData, resourceKey, holder, supplier, bl, bl2, l, i); super(writableLevelData, resourceKey, registryAccess, holder, supplier, bl, bl2, l, i);
} }

View file

@ -135,14 +135,14 @@ public class VoronoiNoise {
} }
BlockPos p1 = new BlockPos( BlockPos p1 = new BlockPos(
(ix + (double) selX) * scale, (int) ((ix + (double) selX) * scale),
(iy + (double) selY) * scale, (int) ((iy + (double) selY) * scale),
(iz + (double) selZ) * scale (int) ((iz + (double) selZ) * scale)
); );
BlockPos p2 = new BlockPos( BlockPos p2 = new BlockPos(
(ix + (double) selXPre) * scale, (int) ((ix + (double) selXPre) * scale),
(iy + (double) selYPre) * scale, (int) ((iy + (double) selYPre) * scale),
(iz + (double) selZPre) * scale (int) ((iz + (double) selZPre) * scale)
); );
return new BlockPos[]{p1, p2}; return new BlockPos[]{p1, p2};
} }

View file

@ -201,10 +201,10 @@ public class AbstractAdvancementRecipe {
* *
* @param recipe The generated recipe that need to be linked to the Advancement * @param recipe The generated recipe that need to be linked to the Advancement
*/ */
protected void registerAdvancement(Recipe<?> recipe) { protected void registerAdvancement(Recipe<?> recipe, ItemLike icon) {
if (hasUnlockTrigger && generateAdvancement && advancement != null) { if (hasUnlockTrigger && generateAdvancement && advancement != null) {
advancement advancement
.startDisplay(recipe.getResultItem().getItem()) .startDisplay(icon)
.hideFromChat() .hideFromChat()
.hideToast() .hideToast()
.endDisplay() .endDisplay()

View file

@ -97,6 +97,6 @@ public abstract class AbstractSimpleRecipe<T extends AbstractSimpleRecipe, C ext
R recipe = buildRecipe(); R recipe = buildRecipe();
BCLRecipeManager.addRecipe(type, recipe); BCLRecipeManager.addRecipe(type, recipe);
registerAdvancement(recipe); registerAdvancement(recipe, output);
} }
} }

View file

@ -8,6 +8,7 @@ import org.betterx.bclib.util.ItemUtil;
import org.betterx.bclib.util.RecipeHelper; import org.betterx.bclib.util.RecipeHelper;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.core.RegistryAccess;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey; import net.minecraft.tags.TagKey;
@ -89,7 +90,7 @@ public class AlloyingRecipe implements Recipe<Container>, UnknownReceipBookCateg
} }
@Override @Override
public ItemStack assemble(Container inv) { public ItemStack assemble(Container inv, RegistryAccess registryAccess) {
return this.output.copy(); return this.output.copy();
} }
@ -99,7 +100,7 @@ public class AlloyingRecipe implements Recipe<Container>, UnknownReceipBookCateg
} }
@Override @Override
public ItemStack getResultItem() { public ItemStack getResultItem(RegistryAccess acc) {
return this.output; return this.output;
} }

View file

@ -9,9 +9,11 @@ import org.betterx.worlds.together.tag.v3.CommonItemTags;
import org.betterx.worlds.together.world.event.WorldBootstrap; import org.betterx.worlds.together.world.event.WorldBootstrap;
import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.client.Minecraft;
import net.minecraft.core.Holder; import net.minecraft.core.Holder;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.TagParser; import net.minecraft.nbt.TagParser;
@ -100,7 +102,7 @@ public class AnvilRecipe implements Recipe<Container>, UnknownReceipBookCategory
} }
@Override @Override
public ItemStack getResultItem() { public ItemStack getResultItem(RegistryAccess acc) {
return this.output; return this.output;
} }
@ -110,7 +112,7 @@ public class AnvilRecipe implements Recipe<Container>, UnknownReceipBookCategory
} }
@Override @Override
public ItemStack assemble(@NotNull Container craftingInventory) { public ItemStack assemble(@NotNull Container craftingInventory, RegistryAccess acc) {
return this.output.copy(); return this.output.copy();
} }
@ -155,7 +157,7 @@ public class AnvilRecipe implements Recipe<Container>, UnknownReceipBookCategory
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
} }
return this.assemble(craftingInventory); return this.assemble(craftingInventory, Minecraft.getInstance().level.registryAccess());
} }
public boolean checkHammerDurability(Container craftingInventory, Player player) { public boolean checkHammerDurability(Container craftingInventory, Player player) {

View file

@ -110,7 +110,7 @@ public class FurnaceRecipe extends AbstractAdvancementRecipe {
time time
); );
BCLRecipeManager.addRecipe(RecipeType.SMELTING, recipe); BCLRecipeManager.addRecipe(RecipeType.SMELTING, recipe);
registerAdvancement(recipe); registerAdvancement(recipe, output);
if (blasting) { if (blasting) {
BlastingRecipe recipe2 = new BlastingRecipe( BlastingRecipe recipe2 = new BlastingRecipe(

View file

@ -161,6 +161,6 @@ public class GridRecipe extends AbstractAdvancementRecipe {
) : new ShapelessRecipe(id, group, bookCategory, result, materials); ) : new ShapelessRecipe(id, group, bookCategory, result, materials);
BCLRecipeManager.addRecipe(type, recipe); BCLRecipeManager.addRecipe(type, recipe);
registerAdvancement(recipe); registerAdvancement(recipe, output);
} }
} }

View file

@ -9,10 +9,11 @@ import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.item.crafting.UpgradeRecipe; import net.minecraft.world.item.crafting.SmithingRecipe;
import net.minecraft.world.item.crafting.SmithingTransformRecipe;
import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.ItemLike;
public class SmithingTableRecipe extends AbstractSimpleRecipe<SmithingTableRecipe, Container, UpgradeRecipe> { public class SmithingTableRecipe extends AbstractSimpleRecipe<SmithingTableRecipe, Container, SmithingRecipe> {
protected Ingredient addon; protected Ingredient addon;
protected SmithingTableRecipe(ResourceLocation id, ItemLike output) { protected SmithingTableRecipe(ResourceLocation id, ItemLike output) {
@ -57,7 +58,7 @@ public class SmithingTableRecipe extends AbstractSimpleRecipe<SmithingTableRecip
} }
@Override @Override
protected UpgradeRecipe buildRecipe() { protected SmithingRecipe buildRecipe() {
return new UpgradeRecipe(id, input, addon, new ItemStack(output, count)); return new SmithingTransformRecipe(id, input, addon, null, new ItemStack(output, count));
} }
} }

View file

@ -80,7 +80,7 @@ public class StructureHelper {
rotation, rotation,
BlockPos.ZERO BlockPos.ZERO
); );
return pos.offset(-offset.x * 0.5, 0, -offset.z * 0.5); return pos.offset((int) (-offset.x * 0.5), 0, (int) (-offset.z * 0.5));
} }
public static void placeCenteredBottom( public static void placeCenteredBottom(
@ -126,8 +126,8 @@ public class StructureHelper {
) { ) {
Vec3i max = structure.getSize(); Vec3i max = structure.getSize();
Vec3 min = StructureTemplate.transform(Vec3.atCenterOf(structure.getSize()), mirror, rotation, BlockPos.ZERO); Vec3 min = StructureTemplate.transform(Vec3.atCenterOf(structure.getSize()), mirror, rotation, BlockPos.ZERO);
max = max.offset(-min.x, -min.y, -min.z); max = max.offset((int) -min.x, (int) -min.y, (int) -min.z);
return BoundingBox.fromCorners(pos.offset(min.x, min.y, min.z), max.offset(pos)); return BoundingBox.fromCorners(pos.offset((int) min.x, (int) min.y, (int) min.z), max.offset(pos));
} }
public static BoundingBox intersectBoxes(BoundingBox box1, BoundingBox box2) { public static BoundingBox intersectBoxes(BoundingBox box1, BoundingBox box2) {

View file

@ -3,15 +3,15 @@ package org.betterx.worlds.together.mixin.client;
import org.betterx.worlds.together.world.event.WorldBootstrap; import org.betterx.worlds.together.world.event.WorldBootstrap;
import org.betterx.worlds.together.worldPreset.WorldPresets; import org.betterx.worlds.together.worldPreset.WorldPresets;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen; import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen;
import net.minecraft.client.gui.screens.worldselection.WorldGenSettingsComponent; import net.minecraft.client.gui.screens.worldselection.WorldCreationContext;
import net.minecraft.client.gui.screens.worldselection.WorldCreationUiState;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.WorldDataConfiguration;
import net.minecraft.world.level.levelgen.presets.WorldPreset; import net.minecraft.world.level.levelgen.presets.WorldPreset;
import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraft.world.level.storage.LevelStorageSource;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
@ -21,26 +21,27 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Optional; import java.util.Optional;
import java.util.OptionalLong;
@Mixin(CreateWorldScreen.class) @Mixin(CreateWorldScreen.class)
public class CreateWorldScreen_Mixin { public abstract class CreateWorldScreen_Mixin {
@Shadow @Shadow
@Final public abstract WorldCreationUiState getUiState();
public WorldGenSettingsComponent worldGenSettingsComponent;
@Inject(method = "<init>", at = @At("TAIL")) @Inject(method = "<init>", at = @At("TAIL"))
private void wt_init( private void wt_init(
Minecraft minecraft,
Screen screen, Screen screen,
WorldDataConfiguration worldDataConfiguration, WorldCreationContext worldCreationContext,
WorldGenSettingsComponent worldGenSettingsComponent, Optional optional,
OptionalLong optionalLong,
CallbackInfo ci CallbackInfo ci
) { ) {
//WorldBootstrap.InGUI.registryReadyOnNewWorld(worldGenSettingsComponent); //WorldBootstrap.InGUI.registryReadyOnNewWorld(worldGenSettingsComponent);
} }
//Change the WorldPreset that is selected by default on the Create World Screen //Change the WorldPreset that is selected by default on the Create World Screen
@ModifyArg(method = "openFresh", index = 1, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/worldselection/WorldGenSettingsComponent;<init>(Lnet/minecraft/client/gui/screens/worldselection/WorldCreationContext;Ljava/util/Optional;Ljava/util/OptionalLong;)V")) @ModifyArg(method = "openFresh", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/worldselection/CreateWorldScreen;<init>(Lnet/minecraft/client/Minecraft;Lnet/minecraft/client/gui/screens/Screen;Lnet/minecraft/client/gui/screens/worldselection/WorldCreationContext;Ljava/util/Optional;Ljava/util/OptionalLong;)V"))
private static Optional<ResourceKey<WorldPreset>> wt_NewDefault(Optional<ResourceKey<WorldPreset>> preset) { private static Optional<ResourceKey<WorldPreset>> wt_NewDefault(Optional<ResourceKey<WorldPreset>> preset) {
return Optional.of(WorldPresets.getDEFAULT()); return Optional.of(WorldPresets.getDEFAULT());
} }
@ -48,7 +49,7 @@ public class CreateWorldScreen_Mixin {
//this is called when a new world is first created //this is called when a new world is first created
@Inject(method = "createNewWorldDirectory", at = @At("RETURN")) @Inject(method = "createNewWorldDirectory", at = @At("RETURN"))
void wt_createNewWorld(CallbackInfoReturnable<Optional<LevelStorageSource.LevelStorageAccess>> cir) { void wt_createNewWorld(CallbackInfoReturnable<Optional<LevelStorageSource.LevelStorageAccess>> cir) {
WorldBootstrap.InGUI.registryReadyOnNewWorld(this.worldGenSettingsComponent); WorldBootstrap.InGUI.registryReadyOnNewWorld(this.getUiState().getSettings());
WorldBootstrap.InGUI.setupNewWorld(cir.getReturnValue(), this.worldGenSettingsComponent); WorldBootstrap.InGUI.setupNewWorld(cir.getReturnValue(), this.getUiState());
} }
} }

View file

@ -1,78 +0,0 @@
package org.betterx.worlds.together.mixin.client;
import org.betterx.worlds.together.worldPreset.WorldGenSettingsComponentAccessor;
import net.minecraft.client.gui.screens.worldselection.WorldCreationContext;
import net.minecraft.client.gui.screens.worldselection.WorldGenSettingsComponent;
import net.minecraft.core.Holder;
import net.minecraft.world.level.levelgen.presets.WorldPreset;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.OptionalLong;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@Mixin(WorldGenSettingsComponent.class)
public abstract class WorldGenSettingsComponentMixin implements WorldGenSettingsComponentAccessor {
@Override
@Accessor("preset")
public abstract Optional<Holder<WorldPreset>> bcl_getPreset();
@Override
@Accessor("preset")
public abstract void bcl_setPreset(Optional<Holder<WorldPreset>> preset);
@Shadow
private WorldCreationContext settings;
@Shadow
public abstract void updateSettings(WorldCreationContext.DimensionsUpdater dimensionsUpdater);
@Shadow
private Optional<Holder<WorldPreset>> preset;
@Inject(method = "<init>", at = @At("TAIL"))
public void wt_init(
WorldCreationContext worldCreationContext,
Optional worldPreset,
OptionalLong seed,
CallbackInfo ci
) {
if (this.preset.isPresent()) {
//make sure the initial dimensions are in sync with the selected World Preset
this.updateSettings((frozen, worldDimensions) -> this.preset.get().value().createWorldDimensions());
}
}
@ModifyArg(method = "init", index = 0, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/CycleButton$Builder;withValues(Ljava/util/List;Ljava/util/List;)Lnet/minecraft/client/gui/components/CycleButton$Builder;"))
public List<Holder<WorldPreset>> bcl_SortLists(List<Holder<WorldPreset>> list) {
final Predicate<Holder<WorldPreset>> vanilla = (p -> p.unwrapKey()
.orElseThrow()
.location()
.getNamespace()
.equals("minecraft"));
List<Holder<WorldPreset>> custom = list
.stream()
.filter(p -> !vanilla.test(p))
.collect(Collectors.toCollection(LinkedList::new));
custom.addAll(list
.stream()
.filter(vanilla)
.toList());
return custom;
}
}

View file

@ -4,10 +4,8 @@ import net.minecraft.core.Holder;
import net.minecraft.world.level.levelgen.WorldDimensions; import net.minecraft.world.level.levelgen.WorldDimensions;
import net.minecraft.world.level.levelgen.presets.WorldPreset; import net.minecraft.world.level.levelgen.presets.WorldPreset;
import java.util.Optional;
public class AdaptWorldPresetSettingEvent extends EventImpl<OnAdaptWorldPresetSettings> { public class AdaptWorldPresetSettingEvent extends EventImpl<OnAdaptWorldPresetSettings> {
public Optional<Holder<WorldPreset>> emit(Optional<Holder<WorldPreset>> start, WorldDimensions worldDims) { public Holder<WorldPreset> emit(Holder<WorldPreset> start, WorldDimensions worldDims) {
for (OnAdaptWorldPresetSettings a : handlers) { for (OnAdaptWorldPresetSettings a : handlers) {
start = a.adapt(start, worldDims); start = a.adapt(start, worldDims);
} }

View file

@ -4,12 +4,10 @@ import net.minecraft.core.Holder;
import net.minecraft.world.level.levelgen.WorldDimensions; import net.minecraft.world.level.levelgen.WorldDimensions;
import net.minecraft.world.level.levelgen.presets.WorldPreset; import net.minecraft.world.level.levelgen.presets.WorldPreset;
import java.util.Optional;
@FunctionalInterface @FunctionalInterface
public interface OnAdaptWorldPresetSettings { public interface OnAdaptWorldPresetSettings {
Optional<Holder<WorldPreset>> adapt( Holder<WorldPreset> adapt(
Optional<Holder<WorldPreset>> currentPreset, Holder<WorldPreset> currentPreset,
WorldDimensions worldDims WorldDimensions worldDims
); );
} }

View file

@ -9,10 +9,10 @@ import org.betterx.worlds.together.mixin.common.WorldPresetAccessor;
import org.betterx.worlds.together.surfaceRules.SurfaceRuleUtil; import org.betterx.worlds.together.surfaceRules.SurfaceRuleUtil;
import org.betterx.worlds.together.world.WorldConfig; import org.betterx.worlds.together.world.WorldConfig;
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset; import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
import org.betterx.worlds.together.worldPreset.WorldGenSettingsComponentAccessor;
import org.betterx.worlds.together.worldPreset.WorldPresets; import org.betterx.worlds.together.worldPreset.WorldPresets;
import net.minecraft.client.gui.screens.worldselection.WorldGenSettingsComponent; import net.minecraft.client.gui.screens.worldselection.WorldCreationContext;
import net.minecraft.client.gui.screens.worldselection.WorldCreationUiState;
import net.minecraft.core.Holder; import net.minecraft.core.Holder;
import net.minecraft.core.LayeredRegistryAccess; import net.minecraft.core.LayeredRegistryAccess;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
@ -94,14 +94,14 @@ public class WorldBootstrap {
return dimensions; return dimensions;
} }
private static Optional<Holder<WorldPreset>> presetFromDatapack(Optional<Holder<WorldPreset>> currentPreset) { private static Holder<WorldPreset> presetFromDatapack(Holder<WorldPreset> currentPreset) {
if (currentPreset.isPresent() && LAST_REGISTRY_ACCESS != null) { if (currentPreset != null && LAST_REGISTRY_ACCESS != null) {
var presetKey = currentPreset.get().unwrapKey(); Optional<ResourceKey<WorldPreset>> presetKey = currentPreset.unwrapKey();
if (presetKey.isPresent()) { if (presetKey.isPresent()) {
Optional<Holder.Reference<WorldPreset>> newPreset = LAST_REGISTRY_ACCESS Optional<Holder.Reference<WorldPreset>> newPreset = LAST_REGISTRY_ACCESS
.registryOrThrow(Registries.WORLD_PRESET) .registryOrThrow(Registries.WORLD_PRESET)
.getHolder(presetKey.get()); .getHolder(presetKey.get());
if (newPreset.isPresent()) currentPreset = (Optional<Holder<WorldPreset>>) (Optional<?>) newPreset; currentPreset = newPreset.orElse(null);
} }
} }
return currentPreset; return currentPreset;
@ -126,7 +126,7 @@ public class WorldBootstrap {
true, true true, true
); );
Optional<Holder<WorldPreset>> currentPreset = Optional.of(Helpers.defaultServerPreset()); Holder<WorldPreset> currentPreset = Helpers.defaultServerPreset();
writeWorldPresets(dimensions, currentPreset); writeWorldPresets(dimensions, currentPreset);
finishedWorldLoad(); finishedWorldLoad();
} else { } else {
@ -155,8 +155,8 @@ public class WorldBootstrap {
} }
public static class InGUI { public static class InGUI {
public static void registryReadyOnNewWorld(WorldGenSettingsComponent worldGenSettingsComponent) { public static void registryReadyOnNewWorld(WorldCreationContext worldGenSettingsComponent) {
Helpers.onRegistryReady(worldGenSettingsComponent.registryHolder()); Helpers.onRegistryReady(worldGenSettingsComponent.worldgenLoadContext());
} }
public static void registryReady(RegistryAccess access) { public static void registryReady(RegistryAccess access) {
@ -165,22 +165,19 @@ public class WorldBootstrap {
public static void setupNewWorld( public static void setupNewWorld(
Optional<LevelStorageSource.LevelStorageAccess> levelStorageAccess, Optional<LevelStorageSource.LevelStorageAccess> levelStorageAccess,
WorldGenSettingsComponent worldGenSettingsComponent WorldCreationUiState uiState
) { ) {
if (levelStorageAccess.isPresent()) { if (levelStorageAccess.isPresent()) {
if (worldGenSettingsComponent instanceof WorldGenSettingsComponentAccessor acc) { Holder<WorldPreset> currentPreset = uiState.getWorldType().preset();
Optional<Holder<WorldPreset>> currentPreset = acc.bcl_getPreset(); currentPreset = Helpers.presetFromDatapack(currentPreset);
currentPreset = Helpers.presetFromDatapack(currentPreset); Holder<WorldPreset> newPreset = setupNewWorldCommon(
Optional<Holder<WorldPreset>> newPreset = setupNewWorldCommon( levelStorageAccess.get(),
levelStorageAccess.get(), currentPreset,
currentPreset, uiState.getSettings().selectedDimensions()
worldGenSettingsComponent.settings().selectedDimensions() );
); if (newPreset != null && newPreset != currentPreset) {
if (newPreset != currentPreset) { uiState.setWorldType(new WorldCreationUiState.WorldTypeEntry(newPreset));
acc.bcl_setPreset(newPreset);
}
} else {
WorldsTogether.LOGGER.error("Unable to access WorldGenSettingsComponent.");
} }
} else { } else {
WorldsTogether.LOGGER.error("Unable to access Level Folder."); WorldsTogether.LOGGER.error("Unable to access Level Folder.");
@ -188,13 +185,13 @@ public class WorldBootstrap {
} }
static Optional<Holder<WorldPreset>> setupNewWorldCommon( static Holder<WorldPreset> setupNewWorldCommon(
LevelStorageSource.LevelStorageAccess levelStorageAccess, LevelStorageSource.LevelStorageAccess levelStorageAccess,
Optional<Holder<WorldPreset>> currentPreset, Holder<WorldPreset> currentPreset,
WorldDimensions worldDims WorldDimensions worldDims
) { ) {
final WorldDimensions dimensions; final WorldDimensions dimensions;
if (currentPreset.map(Holder::value).orElse(null) instanceof TogetherWorldPreset t) { if (currentPreset.value() instanceof TogetherWorldPreset t) {
dimensions = t.getWorldDimensions(); dimensions = t.getWorldDimensions();
} else { } else {
dimensions = TogetherWorldPreset.getWorldDimensions(net.minecraft.world.level.levelgen.presets.WorldPresets.NORMAL); dimensions = TogetherWorldPreset.getWorldDimensions(net.minecraft.world.level.levelgen.presets.WorldPresets.NORMAL);
@ -251,7 +248,7 @@ public class WorldBootstrap {
String levelID, String levelID,
WorldDimensions worldDims, WorldDimensions worldDims,
LevelStorageSource levelSource, LevelStorageSource levelSource,
Optional<Holder<WorldPreset>> worldPreset Holder<WorldPreset> worldPreset
) { ) {
try { try {
var levelStorageAccess = levelSource.createAccess(levelID); var levelStorageAccess = levelSource.createAccess(levelID);
@ -280,10 +277,10 @@ public class WorldBootstrap {
} }
} }
private static void writeWorldPresets(WorldDimensions dimensions, Optional<Holder<WorldPreset>> currentPreset) { private static void writeWorldPresets(WorldDimensions dimensions, Holder<WorldPreset> currentPreset) {
currentPreset = WorldEventsImpl.ADAPT_WORLD_PRESET.emit(currentPreset, dimensions); currentPreset = WorldEventsImpl.ADAPT_WORLD_PRESET.emit(currentPreset, dimensions);
if (currentPreset.map(Holder::value).orElse(null) instanceof WorldPresetAccessor acc) { if (currentPreset != null && currentPreset.value() instanceof WorldPresetAccessor acc) {
TogetherWorldPreset.writeWorldPresetSettings(acc.bcl_getDimensions()); TogetherWorldPreset.writeWorldPresetSettings(acc.bcl_getDimensions());
} else { } else {
WorldsTogether.LOGGER.error("Failed writing together File"); WorldsTogether.LOGGER.error("Failed writing together File");

View file

@ -1,11 +0,0 @@
package org.betterx.worlds.together.worldPreset;
import net.minecraft.core.Holder;
import net.minecraft.world.level.levelgen.presets.WorldPreset;
import java.util.Optional;
public interface WorldGenSettingsComponentAccessor {
Optional<Holder<WorldPreset>> bcl_getPreset();
void bcl_setPreset(Optional<Holder<WorldPreset>> preset);
}

View file

@ -11,10 +11,7 @@ import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.BootstapContext; import net.minecraft.data.worldgen.BootstapContext;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.*;
import net.minecraft.world.level.biome.BiomeSource;
import net.minecraft.world.level.biome.MultiNoiseBiomeSource;
import net.minecraft.world.level.biome.TheEndBiomeSource;
import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.dimension.BuiltinDimensionTypes; import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.world.level.dimension.DimensionType;
@ -69,7 +66,10 @@ public class WorldPresets {
public final WorldGenUtil.Context netherContext; public final WorldGenUtil.Context netherContext;
public final WorldGenUtil.Context endContext; public final WorldGenUtil.Context endContext;
public final HolderGetter<MultiNoiseBiomeSourceParameterList> parameterLists;
public BootstrapData(BootstapContext<WorldPreset> bootstapContext) { public BootstrapData(BootstapContext<WorldPreset> bootstapContext) {
this.parameterLists = bootstapContext.lookup(Registries.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST);
final HolderGetter<DimensionType> dimensionTypes = bootstapContext.lookup(Registries.DIMENSION_TYPE); final HolderGetter<DimensionType> dimensionTypes = bootstapContext.lookup(Registries.DIMENSION_TYPE);
this.noiseSettings = bootstapContext.lookup(Registries.NOISE_SETTINGS); this.noiseSettings = bootstapContext.lookup(Registries.NOISE_SETTINGS);
@ -78,16 +78,20 @@ public class WorldPresets {
this.structureSets = bootstapContext.lookup(Registries.STRUCTURE_SET); this.structureSets = bootstapContext.lookup(Registries.STRUCTURE_SET);
this.overworldDimensionType = dimensionTypes.getOrThrow(BuiltinDimensionTypes.OVERWORLD); this.overworldDimensionType = dimensionTypes.getOrThrow(BuiltinDimensionTypes.OVERWORLD);
MultiNoiseBiomeSource overworldBiomeSource = MultiNoiseBiomeSource.Preset.OVERWORLD.biomeSource(this.biomes); Holder.Reference<MultiNoiseBiomeSourceParameterList> overworldParameters = parameterLists
.getOrThrow(MultiNoiseBiomeSourceParameterLists.OVERWORLD);
MultiNoiseBiomeSource overworldBiomeSource = MultiNoiseBiomeSource.createFromPreset(overworldParameters);
Holder<NoiseGeneratorSettings> defaultOverworldNoise = this.noiseSettings.getOrThrow(NoiseGeneratorSettings.OVERWORLD); Holder<NoiseGeneratorSettings> defaultOverworldNoise = this.noiseSettings.getOrThrow(NoiseGeneratorSettings.OVERWORLD);
this.overworldStem = makeNoiseBasedOverworld(overworldBiomeSource, defaultOverworldNoise); this.overworldStem = makeNoiseBasedOverworld(overworldBiomeSource, defaultOverworldNoise);
this.netherDimensionType = dimensionTypes.getOrThrow(BuiltinDimensionTypes.NETHER); this.netherDimensionType = dimensionTypes.getOrThrow(BuiltinDimensionTypes.NETHER);
Holder.Reference<MultiNoiseBiomeSourceParameterList> netherParameters = parameterLists
.getOrThrow(MultiNoiseBiomeSourceParameterLists.NETHER);
Holder<NoiseGeneratorSettings> defaultNetherNoise = this.noiseSettings.getOrThrow(NoiseGeneratorSettings.NETHER); Holder<NoiseGeneratorSettings> defaultNetherNoise = this.noiseSettings.getOrThrow(NoiseGeneratorSettings.NETHER);
this.netherStem = new LevelStem( this.netherStem = new LevelStem(
netherDimensionType, netherDimensionType,
new NoiseBasedChunkGenerator( new NoiseBasedChunkGenerator(
MultiNoiseBiomeSource.Preset.NETHER.biomeSource(this.biomes), MultiNoiseBiomeSource.createFromPreset(netherParameters),
defaultNetherNoise defaultNetherNoise
) )
); );

View file

@ -10,13 +10,13 @@ accessible class net/minecraft/world/level/levelgen/SurfaceRules$LazyCondition
accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource
accessible class net/minecraft/world/level/levelgen/presets/WorldPresets$Bootstrap accessible class net/minecraft/world/level/levelgen/presets/WorldPresets$Bootstrap
extendable class net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator extendable class net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator
accessible class net/minecraft/core/registries/BuiltInRegistries$RegistryBootstrap accessible class net/minecraft/core/registries/BuiltInRegistries$RegistryBootstrap
accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource
accessible class net/minecraft/server/dedicated/DedicatedServerProperties$WorldDimensionData accessible class net/minecraft/server/dedicated/DedicatedServerProperties$WorldDimensionData
accessible class net/minecraft/client/resources/model/AtlasSet$AtlasEntry accessible class net/minecraft/client/resources/model/AtlasSet$AtlasEntry
extendable class net/minecraft/world/level/block/state/properties/WoodType
#Methods #Methods
accessible method net/minecraft/client/gui/screens/worldselection/WorldGenSettingsComponent updateSettings (Lnet/minecraft/client/gui/screens/worldselection/WorldCreationContext$DimensionsUpdater;)V
accessible method net/minecraft/world/level/storage/loot/LootPool <init> ([Lnet/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer;[Lnet/minecraft/world/level/storage/loot/predicates/LootItemCondition;[Lnet/minecraft/world/level/storage/loot/functions/LootItemFunction;Lnet/minecraft/world/level/storage/loot/providers/number/NumberProvider;Lnet/minecraft/world/level/storage/loot/providers/number/NumberProvider;)V accessible method net/minecraft/world/level/storage/loot/LootPool <init> ([Lnet/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer;[Lnet/minecraft/world/level/storage/loot/predicates/LootItemCondition;[Lnet/minecraft/world/level/storage/loot/functions/LootItemFunction;Lnet/minecraft/world/level/storage/loot/providers/number/NumberProvider;Lnet/minecraft/world/level/storage/loot/providers/number/NumberProvider;)V
accessible method net/minecraft/world/entity/ai/village/poi/PoiTypes register (Lnet/minecraft/core/Registry;Lnet/minecraft/resources/ResourceKey;Ljava/util/Set;II)Lnet/minecraft/world/entity/ai/village/poi/PoiType; accessible method net/minecraft/world/entity/ai/village/poi/PoiTypes register (Lnet/minecraft/core/Registry;Lnet/minecraft/resources/ResourceKey;Ljava/util/Set;II)Lnet/minecraft/world/entity/ai/village/poi/PoiType;
accessible method net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource <init> (Ljava/util/List;)V accessible method net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource <init> (Ljava/util/List;)V

View file

@ -7,9 +7,9 @@
"AnvilScreenMixin", "AnvilScreenMixin",
"AtlasSetMixin", "AtlasSetMixin",
"BlockMixin", "BlockMixin",
"ClientPacketListenerMixin",
"ClientRecipeBookMixin", "ClientRecipeBookMixin",
"FogRendererMixin", "FogRendererMixin",
"GameMixin",
"MinecraftMixin", "MinecraftMixin",
"ModelManagerMixin", "ModelManagerMixin",
"PresetEditorMixin", "PresetEditorMixin",

View file

@ -46,10 +46,10 @@
"bclib.mixins.client.json" "bclib.mixins.client.json"
], ],
"depends": { "depends": {
"fabricloader": ">=0.14.11", "fabricloader": ">=0.14.19",
"fabric": ">=0.68.1", "fabric": ">=0.77.0",
"minecraft": [ "minecraft": [
"1.19.3" "1.19.4"
] ]
}, },
"custom": { "custom": {

View file

@ -5,7 +5,6 @@
"compatibilityLevel": "JAVA_17", "compatibilityLevel": "JAVA_17",
"client": [ "client": [
"CreateWorldScreen_Mixin", "CreateWorldScreen_Mixin",
"WorldGenSettingsComponentMixin",
"WorldOpenFlowsMixin" "WorldOpenFlowsMixin"
], ],
"injectors": { "injectors": {