[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.
org.gradle.jvmargs=-Xmx8G
#Modrinth
modrinth_versions=["1.19.3"]
modrinth_versions=["1.19.4"]
#`release`, `beta` or `alpha`
release_channel=beta
#Loom
loom_version=1.0-SNAPSHOT
# Fabric Properties
# check these on https://fabricmc.net/versions.html
minecraft_version=1.19.3
loader_version=0.14.11
fabric_version=0.68.1+1.19.3
minecraft_version=1.19.4
loader_version=0.14.19
fabric_version=0.77.0+1.19.4
# Mod Properties
mod_version=2.2.5
mod_version=2.3.0
maven_group=org.betterx.bclib
archives_base_name=bclib
# Dependencies
modmenu_version=5.0.1
emi_version=0.6.2+1.19.3
modmenu_version=6.1.0-rc.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.critereon.*;
import net.minecraft.client.Minecraft;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.data.recipes.RecipeBuilder;
import net.minecraft.network.chat.Component;
@ -199,7 +200,7 @@ public class AdvancementManager {
T recipe,
AdvancementType type
) {
Item item = recipe.getResultItem().getItem();
Item item = recipe.getResultItem(Minecraft.getInstance().level.registryAccess()).getItem();
return create(item, type, displayBuilder -> displayBuilder.hideToast().hideFromChat())
//.awardRecipe(item)
.addRecipeUnlockCriterion("has_the_recipe", recipe)

View file

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

View file

@ -28,6 +28,7 @@ import java.awt.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;
import org.jetbrains.annotations.NotNull;
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
protected BiomeAPI.BiomeType defaultBiomeType() {
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.Map;
import java.util.Set;
import java.util.stream.Stream;
public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourceWithConfig<BCLibNetherBiomeSource, BCLNetherBiomeSourceConfig> {
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
protected BiomeAPI.BiomeType defaultBiomeType() {
return BiomeAPI.BiomeType.NETHER;

View file

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

View file

@ -93,7 +93,7 @@ public class BCLBiomeBuilder {
private BiomeSpecialEffects.Builder effectsBuilder;
private MobSpawnSettings.Builder spawnSettings;
private SurfaceRules.RuleSource surfaceRule;
private Precipitation precipitation;
private boolean hasPrecipitation;
final private ResourceLocation biomeID;
@ -116,7 +116,7 @@ public class BCLBiomeBuilder {
BCLBiomeBuilder(ResourceLocation biomeID) {
this.biomeID = biomeID;
this.precipitation = Precipitation.NONE;
this.hasPrecipitation = false;
this.generationSettings = null;
this.effectsBuilder = null;
this.spawnSettings = null;
@ -174,9 +174,21 @@ public class BCLBiomeBuilder {
*
* @param precipitation {@link Precipitation}
* @return same {@link BCLBiomeBuilder} instance.
* @deprecated Use hasPrecipitation() instead
*/
@Deprecated(forRemoval = true)
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;
}
@ -948,7 +960,7 @@ public class BCLBiomeBuilder {
BiomeBuilder builder = new BiomeBuilder()
.precipitation(precipitation)
.hasPrecipitation(hasPrecipitation)
.temperature(temperature)
.downfall(downfall);

View file

@ -253,8 +253,8 @@ public class StructureWorldNBT extends StructureNBT {
float y1 = Math.min(offsetY, 0);
float y2 = Math.max(offsetY, 0);
BlockPos start = pos.offset(-(size.getX() >> 1), y1, -(size.getZ() >> 1));
BlockPos end = pos.offset(size.getX() >> 1, y2, size.getZ() >> 1);
BlockPos start = pos.offset(-(size.getX() >> 1), (int) y1, -(size.getZ() >> 1));
BlockPos end = pos.offset(size.getX() >> 1, (int) y2, size.getZ() >> 1);
int count = 0;
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.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.ButtonBlock;
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.BlockSetType;
import net.minecraft.world.level.storage.loot.LootContext;
import net.fabricmc.api.EnvType;
@ -30,14 +30,19 @@ import org.jetbrains.annotations.Nullable;
public abstract class BaseButtonBlock extends ButtonBlock implements BlockModelProvider {
private final Block parent;
protected BaseButtonBlock(Block parent, Properties properties, boolean sensitive) {
this(parent, properties, 30, sensitive);
protected BaseButtonBlock(Block parent, Properties properties, boolean sensitive, BlockSetType type) {
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(
properties.noCollission(), ticksToStayPressed, sensitive,
SoundEvents.STONE_BUTTON_CLICK_OFF, SoundEvents.STONE_BUTTON_CLICK_ON
properties.noCollission(), type, ticksToStayPressed, sensitive
);
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.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
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.state.BlockBehaviour;
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.DoubleBlockHalf;
import net.minecraft.world.level.storage.loot.LootContext;
@ -38,12 +38,12 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable;
public class BaseDoorBlock extends DoorBlock implements RenderLayerProvider, BlockModelProvider, TagProvider {
public BaseDoorBlock(Block source) {
this(Properties.copy(source).strength(3F, 3F).noOcclusion());
public BaseDoorBlock(Block source, BlockSetType type) {
this(Properties.copy(source).strength(3F, 3F).noOcclusion(), type);
}
public BaseDoorBlock(BlockBehaviour.Properties properties) {
super(properties, SoundEvents.WOODEN_DOOR_CLOSE, SoundEvents.WOODEN_DOOR_OPEN);
public BaseDoorBlock(BlockBehaviour.Properties properties, BlockSetType type) {
super(properties, type);
}
@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.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.FenceGateBlock;
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.fabricmc.api.EnvType;
@ -28,8 +28,8 @@ import org.jetbrains.annotations.Nullable;
public class BaseGateBlock extends FenceGateBlock implements BlockModelProvider {
private final Block parent;
public BaseGateBlock(Block source) {
super(Properties.copy(source).noOcclusion(), SoundEvents.FENCE_GATE_CLOSE, SoundEvents.FENCE_GATE_OPEN);
public BaseGateBlock(Block source, WoodType type) {
super(Properties.copy(source).noOcclusion(), type);
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.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.PressurePlateBlock;
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.fabricmc.api.EnvType;
@ -28,10 +28,10 @@ import org.jetbrains.annotations.Nullable;
public class BasePressurePlateBlock extends PressurePlateBlock implements BlockModelProvider {
private final Block parent;
public BasePressurePlateBlock(Sensitivity rule, Block source) {
public BasePressurePlateBlock(Sensitivity rule, Block source, BlockSetType type) {
super(
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;
}

View file

@ -3,11 +3,12 @@ package org.betterx.bclib.blocks;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.properties.BlockSetType;
public class BaseStoneButtonBlock extends BaseButtonBlock {
public BaseStoneButtonBlock(Block source) {
super(source, Properties.copy(source).noOcclusion(), false);
public BaseStoneButtonBlock(Block source, BlockSetType type) {
super(source, Properties.copy(source).noOcclusion(), false, type);
}
@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.UnbakedModel;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.TrapDoorBlock;
import net.minecraft.world.level.block.state.BlockBehaviour;
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.storage.loot.LootContext;
@ -27,12 +27,12 @@ import java.util.*;
import org.jetbrains.annotations.Nullable;
public class BaseTrapdoorBlock extends TrapDoorBlock implements RenderLayerProvider, BlockModelProvider {
public BaseTrapdoorBlock(Block source) {
this(Properties.copy(source).strength(3.0F, 3.0F).noOcclusion());
public BaseTrapdoorBlock(Block source, BlockSetType type) {
this(Properties.copy(source).strength(3.0F, 3.0F).noOcclusion(), type);
}
public BaseTrapdoorBlock(BlockBehaviour.Properties properties) {
super(properties, SoundEvents.WOODEN_TRAPDOOR_CLOSE, SoundEvents.WOODEN_TRAPDOOR_OPEN);
public BaseTrapdoorBlock(BlockBehaviour.Properties properties, BlockSetType type) {
super(properties, type);
}
@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.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.WeightedPressurePlateBlock;
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.fabricmc.api.EnvType;
@ -28,7 +28,7 @@ import org.jetbrains.annotations.Nullable;
public class BaseWeightedPlateBlock extends WeightedPressurePlateBlock implements BlockModelProvider {
private final Block parent;
public BaseWeightedPlateBlock(Block source) {
public BaseWeightedPlateBlock(Block source, BlockSetType type) {
super(
15,
Properties.copy(source)
@ -36,7 +36,7 @@ public class BaseWeightedPlateBlock extends WeightedPressurePlateBlock implement
.noOcclusion()
.requiresCorrectToolForDrops()
.strength(0.5F),
SoundEvents.METAL_PRESSURE_PLATE_CLICK_OFF, SoundEvents.METAL_PRESSURE_PLATE_CLICK_ON
type
);
this.parent = source;
}

View file

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

View file

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

View file

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

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.registry.PresetsRegistry;
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
import org.betterx.worlds.together.worldPreset.WorldGenSettingsComponentAccessor;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen;
import net.minecraft.client.gui.screens.worldselection.WorldCreationContext;
import net.minecraft.client.gui.screens.worldselection.WorldCreationUiState;
import net.minecraft.core.Holder;
import net.minecraft.network.chat.CommonComponents;
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.LevelStem;
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.fabricmc.api.EnvType;
@ -34,7 +35,6 @@ import org.wunder.lib.ui.layout.values.Size;
import org.wunder.lib.ui.vanilla.LayoutScreen;
import java.util.Map;
import java.util.Optional;
import org.jetbrains.annotations.Nullable;
@Environment(EnvType.CLIENT)
@ -300,16 +300,14 @@ public class WorldSetupScreen extends LayoutScreen {
updateConfiguration(LevelStem.NETHER, BuiltinDimensionTypes.NETHER, endGenerator);
}
if (createWorldScreen.worldGenSettingsComponent instanceof WorldGenSettingsComponentAccessor acc
&& acc.bcl_getPreset()
.isPresent() && acc.bcl_getPreset()
.get()
.value() instanceof TogetherWorldPreset worldPreset) {
acc.bcl_setPreset(Optional.of(Holder.direct(
final WorldCreationUiState acc = createWorldScreen.getUiState();
final Holder<WorldPreset> configuredPreset = acc.getWorldType().preset();
if (configuredPreset != null && configuredPreset.value() instanceof TogetherWorldPreset worldPreset) {
acc.setWorldType(new WorldCreationUiState.WorldTypeEntry(Holder.direct(
worldPreset.withDimensions(
createWorldScreen
.worldGenSettingsComponent
.settings()
.getUiState()
.getSettings()
.selectedDimensions()
.dimensions()
)
@ -323,7 +321,7 @@ public class WorldSetupScreen extends LayoutScreen {
ResourceKey<DimensionType> dimensionTypeKey,
ChunkGenerator chunkGenerator
) {
createWorldScreen.worldGenSettingsComponent.updateSettings(
createWorldScreen.getUiState().updateDimensions(
(registryAccess, worldDimensions) -> new WorldDimensions(LevelGenUtil.replaceGenerator(
dimensionKey,
dimensionTypeKey,
@ -359,12 +357,10 @@ public class WorldSetupScreen extends LayoutScreen {
protected LayoutComponent<?, ?> initContent() {
BCLEndBiomeSourceConfig endConfig = BCLEndBiomeSourceConfig.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);
if (endStem != null && endStem.generator().getBiomeSource() instanceof BCLibEndBiomeSource bs) {
endConfig = bs.getTogetherConfig();
@ -375,8 +371,8 @@ public class WorldSetupScreen extends LayoutScreen {
}
}
var netherPage = netherPage(netherConfig);
var endPage = endPage(endConfig);
LayoutComponent<?, ? extends LayoutComponent<?, ?>> netherPage = netherPage(netherConfig);
LayoutComponent<?, ? extends LayoutComponent<?, ?>> endPage = endPage(endConfig);
Tabs main = new Tabs(fill(), fill()).setPadding(8, 0, 0, 0);
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.blocks.BaseSignBlock;
import com.mojang.blaze3d.platform.NativeImage;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
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.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.FastColor;
import net.minecraft.util.FormattedCharSequence;
import net.minecraft.util.Mth;
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.scale(0.010416667F, -0.010416667F, 0.010416667F);
int m = signBlockEntity.getColor().getTextColor();
int n = (int) (NativeImage.getR(m) * 0.4D);
int o = (int) (NativeImage.getG(m) * 0.4D);
int p = (int) (NativeImage.getB(m) * 0.4D);
int q = NativeImage.combine(0, p, o, n);
int n = (int) (FastColor.ARGB32.red(m) * 0.4D);
int o = (int) (FastColor.ARGB32.green(m) * 0.4D);
int p = (int) (FastColor.ARGB32.blue(m) * 0.4D);
int q = FastColor.ARGB32.color(0, p, o, n);
FormattedCharSequence[] formattedCharSequences = signBlockEntity.getRenderMessages(
Minecraft.getInstance()
@ -114,11 +114,12 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
for (int s = 0; s < 4; ++s) {
FormattedCharSequence formattedCharSequence = formattedCharSequences[s];
float t = (float) (-this.font.width(formattedCharSequence) / 2);
int marginHeight = 4 * signBlockEntity.getTextLineHeight() / 2;
if (drawOutlined) {
this.font.drawInBatch8xOutline(
formattedCharSequence,
t,
(float) (s * 10 - 20),
(float) (s * signBlockEntity.getTextLineHeight() - marginHeight),
drawColor,
m,
matrixStack.last().pose(),
@ -129,12 +130,12 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
this.font.drawInBatch(
formattedCharSequence,
t,
(float) (s * 10 - 20),
(float) (s * signBlockEntity.getTextLineHeight() - marginHeight),
drawColor,
false,
matrixStack.last().pose(),
provider,
false,
Font.DisplayMode.NORMAL,
0,
drawLight
);

View file

@ -194,7 +194,7 @@ public class CommandRegistry {
final ServerPlayer player = source.getPlayerOrException();
Vec3 pos = source.getPosition();
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));
boolean found = org.betterx.bclib.util.BlocksHelper.findSurroundingSurface(
level,
@ -204,7 +204,11 @@ public class CommandRegistry {
state -> BlocksHelper.isTerrain(state)
);
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);
return Command.SINGLE_SUCCESS;
}

View file

@ -1,12 +1,33 @@
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;
public class BCLWoodType extends WoodType {
private String modID;
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;
}
}

View file

@ -157,34 +157,40 @@ public class WoodenComplexMaterial extends ComplexMaterial {
addBlockEntry(new BlockEntry(
BLOCK_GATE,
(complexMaterial, settings) -> new BaseGateBlock(getBlock(BLOCK_PLANKS))
(complexMaterial, settings) -> new BaseGateBlock(getBlock(BLOCK_PLANKS), this.woodType)
)
.setBlockTags(BlockTags.FENCE_GATES));
addBlockEntry(new BlockEntry(
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)
.setItemTags(ItemTags.BUTTONS, ItemTags.WOODEN_BUTTONS));
addBlockEntry(new BlockEntry(
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)
.setItemTags(ItemTags.WOODEN_PRESSURE_PLATES));
addBlockEntry(new BlockEntry(
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)
.setItemTags(ItemTags.TRAPDOORS, ItemTags.WOODEN_TRAPDOORS));
addBlockEntry(new BlockEntry(
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)
.setItemTags(ItemTags.DOORS, ItemTags.WOODEN_DOORS));

View file

@ -1,5 +1,6 @@
package org.betterx.bclib.integration.emi;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.Container;
@ -35,7 +36,7 @@ public abstract class EMIAbstractAlloyingRecipe<C extends Container, T extends R
: 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.infiniBurn = infiniBurn;
}

View file

@ -3,6 +3,7 @@ package org.betterx.bclib.integration.emi;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.recipes.AnvilRecipe;
import net.minecraft.client.Minecraft;
import net.minecraft.core.Holder;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
@ -36,7 +37,7 @@ public class EMIAnvilRecipe implements EmiRecipe {
EmiIngredient.of(recipe.getMainIngredient(), recipe.getInputCount()),
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());
}

View file

@ -67,16 +67,104 @@ public class EMIAnvilRecipeCategory extends EmiRecipeCategory {
final int yy = y + 6 + 3;
final Matrix4f matrix = stack.last().pose();
font.drawInBatch(content, xx - 1, yy - 1, 0xFF000000, false, matrix, bufferSource, false, 0, 0xF000F0);
font.drawInBatch(content, xx, yy - 1, 0xFF000000, false, matrix, bufferSource, false, 0, 0xF000F0);
font.drawInBatch(content, xx + 1, yy - 1, 0xFF000000, false, matrix, bufferSource, false, 0, 0xF000F0);
font.drawInBatch(content, xx - 1, yy, 0xFF000000, false, matrix, bufferSource, false, 0, 0xF000F0);
font.drawInBatch(content, xx + 1, yy, 0xFF000000, false, matrix, bufferSource, false, 0, 0xF000F0);
font.drawInBatch(content, xx - 1, yy + 1, 0xFF000000, false, matrix, bufferSource, false, 0, 0xF000F0);
font.drawInBatch(content, xx + 1, yy + 1, 0xFF000000, false, matrix, bufferSource, false, 0, 0xF000F0);
font.drawInBatch(content, xx, yy + 1, 0xFF000000, false, matrix, bufferSource, false, 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 + 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();
}

View file

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

View file

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

View file

@ -37,6 +37,18 @@ public class AnvilScreenMixin extends ItemCombinerScreen<AnvilMenu> {
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"))
protected void be_subInit(CallbackInfo info) {
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 net.minecraft.client.Game;
import net.minecraft.client.multiplayer.ClientPacketListener;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(Game.class)
public class GameMixin {
@Mixin(ClientPacketListener.class)
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) {
DataExchangeAPI.sendOnEnter();
}

View file

@ -5,6 +5,7 @@ import org.betterx.bclib.blocks.LeveledAnvilBlock;
import org.betterx.bclib.interfaces.AnvilScreenHandlerExtended;
import org.betterx.bclib.recipes.AnvilRecipe;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.entity.player.Inventory;
@ -164,7 +165,7 @@ public abstract class AnvilMenuMixin extends ItemCombinerMenu implements AnvilSc
private void be_updateResult() {
if (be_currentRecipe == null) return;
resultSlots.setItem(0, be_currentRecipe.assemble(inputSlots));
resultSlots.setItem(0, be_currentRecipe.assemble(inputSlots, Minecraft.getInstance().level.registryAccess()));
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.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;
@Mixin(BiomeSource.class)
@ -26,14 +22,4 @@ public abstract class BiomeSourceMixin implements BiomeSourceAccessor {
BCLib.LOGGER.info("Rebuilding features in BiomeSource " + this);
//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 net.minecraft.core.Holder;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
@ -34,6 +35,7 @@ public abstract class ServerLevelMixin extends Level {
protected ServerLevelMixin(
WritableLevelData writableLevelData,
ResourceKey<Level> resourceKey,
RegistryAccess registryAccess,
Holder<DimensionType> holder,
Supplier<ProfilerFiller> supplier,
boolean bl,
@ -41,7 +43,7 @@ public abstract class ServerLevelMixin extends Level {
long l,
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(
(ix + (double) selX) * scale,
(iy + (double) selY) * scale,
(iz + (double) selZ) * scale
(int) ((ix + (double) selX) * scale),
(int) ((iy + (double) selY) * scale),
(int) ((iz + (double) selZ) * scale)
);
BlockPos p2 = new BlockPos(
(ix + (double) selXPre) * scale,
(iy + (double) selYPre) * scale,
(iz + (double) selZPre) * scale
(int) ((ix + (double) selXPre) * scale),
(int) ((iy + (double) selYPre) * scale),
(int) ((iz + (double) selZPre) * scale)
);
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
*/
protected void registerAdvancement(Recipe<?> recipe) {
protected void registerAdvancement(Recipe<?> recipe, ItemLike icon) {
if (hasUnlockTrigger && generateAdvancement && advancement != null) {
advancement
.startDisplay(recipe.getResultItem().getItem())
.startDisplay(icon)
.hideFromChat()
.hideToast()
.endDisplay()

View file

@ -97,6 +97,6 @@ public abstract class AbstractSimpleRecipe<T extends AbstractSimpleRecipe, C ext
R recipe = buildRecipe();
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 net.minecraft.core.NonNullList;
import net.minecraft.core.RegistryAccess;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
@ -89,7 +90,7 @@ public class AlloyingRecipe implements Recipe<Container>, UnknownReceipBookCateg
}
@Override
public ItemStack assemble(Container inv) {
public ItemStack assemble(Container inv, RegistryAccess registryAccess) {
return this.output.copy();
}
@ -99,7 +100,7 @@ public class AlloyingRecipe implements Recipe<Container>, UnknownReceipBookCateg
}
@Override
public ItemStack getResultItem() {
public ItemStack getResultItem(RegistryAccess acc) {
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 com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.client.Minecraft;
import net.minecraft.core.Holder;
import net.minecraft.core.NonNullList;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.TagParser;
@ -100,7 +102,7 @@ public class AnvilRecipe implements Recipe<Container>, UnknownReceipBookCategory
}
@Override
public ItemStack getResultItem() {
public ItemStack getResultItem(RegistryAccess acc) {
return this.output;
}
@ -110,7 +112,7 @@ public class AnvilRecipe implements Recipe<Container>, UnknownReceipBookCategory
}
@Override
public ItemStack assemble(@NotNull Container craftingInventory) {
public ItemStack assemble(@NotNull Container craftingInventory, RegistryAccess acc) {
return this.output.copy();
}
@ -155,7 +157,7 @@ public class AnvilRecipe implements Recipe<Container>, UnknownReceipBookCategory
return ItemStack.EMPTY;
}
}
return this.assemble(craftingInventory);
return this.assemble(craftingInventory, Minecraft.getInstance().level.registryAccess());
}
public boolean checkHammerDurability(Container craftingInventory, Player player) {

View file

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

View file

@ -161,6 +161,6 @@ public class GridRecipe extends AbstractAdvancementRecipe {
) : new ShapelessRecipe(id, group, bookCategory, result, materials);
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.crafting.Ingredient;
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;
public class SmithingTableRecipe extends AbstractSimpleRecipe<SmithingTableRecipe, Container, UpgradeRecipe> {
public class SmithingTableRecipe extends AbstractSimpleRecipe<SmithingTableRecipe, Container, SmithingRecipe> {
protected Ingredient addon;
protected SmithingTableRecipe(ResourceLocation id, ItemLike output) {
@ -57,7 +58,7 @@ public class SmithingTableRecipe extends AbstractSimpleRecipe<SmithingTableRecip
}
@Override
protected UpgradeRecipe buildRecipe() {
return new UpgradeRecipe(id, input, addon, new ItemStack(output, count));
protected SmithingRecipe buildRecipe() {
return new SmithingTransformRecipe(id, input, addon, null, new ItemStack(output, count));
}
}

View file

@ -80,7 +80,7 @@ public class StructureHelper {
rotation,
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(
@ -126,8 +126,8 @@ public class StructureHelper {
) {
Vec3i max = structure.getSize();
Vec3 min = StructureTemplate.transform(Vec3.atCenterOf(structure.getSize()), mirror, rotation, BlockPos.ZERO);
max = max.offset(-min.x, -min.y, -min.z);
return BoundingBox.fromCorners(pos.offset(min.x, min.y, min.z), max.offset(pos));
max = max.offset((int) -min.x, (int) -min.y, (int) -min.z);
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) {

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.worldPreset.WorldPresets;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
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.world.level.WorldDataConfiguration;
import net.minecraft.world.level.levelgen.presets.WorldPreset;
import net.minecraft.world.level.storage.LevelStorageSource;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
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 java.util.Optional;
import java.util.OptionalLong;
@Mixin(CreateWorldScreen.class)
public class CreateWorldScreen_Mixin {
public abstract class CreateWorldScreen_Mixin {
@Shadow
@Final
public WorldGenSettingsComponent worldGenSettingsComponent;
public abstract WorldCreationUiState getUiState();
@Inject(method = "<init>", at = @At("TAIL"))
private void wt_init(
Minecraft minecraft,
Screen screen,
WorldDataConfiguration worldDataConfiguration,
WorldGenSettingsComponent worldGenSettingsComponent,
WorldCreationContext worldCreationContext,
Optional optional,
OptionalLong optionalLong,
CallbackInfo ci
) {
//WorldBootstrap.InGUI.registryReadyOnNewWorld(worldGenSettingsComponent);
}
//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) {
return Optional.of(WorldPresets.getDEFAULT());
}
@ -48,7 +49,7 @@ public class CreateWorldScreen_Mixin {
//this is called when a new world is first created
@Inject(method = "createNewWorldDirectory", at = @At("RETURN"))
void wt_createNewWorld(CallbackInfoReturnable<Optional<LevelStorageSource.LevelStorageAccess>> cir) {
WorldBootstrap.InGUI.registryReadyOnNewWorld(this.worldGenSettingsComponent);
WorldBootstrap.InGUI.setupNewWorld(cir.getReturnValue(), this.worldGenSettingsComponent);
WorldBootstrap.InGUI.registryReadyOnNewWorld(this.getUiState().getSettings());
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.presets.WorldPreset;
import java.util.Optional;
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) {
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.presets.WorldPreset;
import java.util.Optional;
@FunctionalInterface
public interface OnAdaptWorldPresetSettings {
Optional<Holder<WorldPreset>> adapt(
Optional<Holder<WorldPreset>> currentPreset,
Holder<WorldPreset> adapt(
Holder<WorldPreset> currentPreset,
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.world.WorldConfig;
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
import org.betterx.worlds.together.worldPreset.WorldGenSettingsComponentAccessor;
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.LayeredRegistryAccess;
import net.minecraft.core.Registry;
@ -94,14 +94,14 @@ public class WorldBootstrap {
return dimensions;
}
private static Optional<Holder<WorldPreset>> presetFromDatapack(Optional<Holder<WorldPreset>> currentPreset) {
if (currentPreset.isPresent() && LAST_REGISTRY_ACCESS != null) {
var presetKey = currentPreset.get().unwrapKey();
private static Holder<WorldPreset> presetFromDatapack(Holder<WorldPreset> currentPreset) {
if (currentPreset != null && LAST_REGISTRY_ACCESS != null) {
Optional<ResourceKey<WorldPreset>> presetKey = currentPreset.unwrapKey();
if (presetKey.isPresent()) {
Optional<Holder.Reference<WorldPreset>> newPreset = LAST_REGISTRY_ACCESS
.registryOrThrow(Registries.WORLD_PRESET)
.getHolder(presetKey.get());
if (newPreset.isPresent()) currentPreset = (Optional<Holder<WorldPreset>>) (Optional<?>) newPreset;
currentPreset = newPreset.orElse(null);
}
}
return currentPreset;
@ -126,7 +126,7 @@ public class WorldBootstrap {
true, true
);
Optional<Holder<WorldPreset>> currentPreset = Optional.of(Helpers.defaultServerPreset());
Holder<WorldPreset> currentPreset = Helpers.defaultServerPreset();
writeWorldPresets(dimensions, currentPreset);
finishedWorldLoad();
} else {
@ -155,8 +155,8 @@ public class WorldBootstrap {
}
public static class InGUI {
public static void registryReadyOnNewWorld(WorldGenSettingsComponent worldGenSettingsComponent) {
Helpers.onRegistryReady(worldGenSettingsComponent.registryHolder());
public static void registryReadyOnNewWorld(WorldCreationContext worldGenSettingsComponent) {
Helpers.onRegistryReady(worldGenSettingsComponent.worldgenLoadContext());
}
public static void registryReady(RegistryAccess access) {
@ -165,22 +165,19 @@ public class WorldBootstrap {
public static void setupNewWorld(
Optional<LevelStorageSource.LevelStorageAccess> levelStorageAccess,
WorldGenSettingsComponent worldGenSettingsComponent
WorldCreationUiState uiState
) {
if (levelStorageAccess.isPresent()) {
if (worldGenSettingsComponent instanceof WorldGenSettingsComponentAccessor acc) {
Optional<Holder<WorldPreset>> currentPreset = acc.bcl_getPreset();
currentPreset = Helpers.presetFromDatapack(currentPreset);
Optional<Holder<WorldPreset>> newPreset = setupNewWorldCommon(
levelStorageAccess.get(),
currentPreset,
worldGenSettingsComponent.settings().selectedDimensions()
);
if (newPreset != currentPreset) {
acc.bcl_setPreset(newPreset);
}
} else {
WorldsTogether.LOGGER.error("Unable to access WorldGenSettingsComponent.");
Holder<WorldPreset> currentPreset = uiState.getWorldType().preset();
currentPreset = Helpers.presetFromDatapack(currentPreset);
Holder<WorldPreset> newPreset = setupNewWorldCommon(
levelStorageAccess.get(),
currentPreset,
uiState.getSettings().selectedDimensions()
);
if (newPreset != null && newPreset != currentPreset) {
uiState.setWorldType(new WorldCreationUiState.WorldTypeEntry(newPreset));
}
} else {
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,
Optional<Holder<WorldPreset>> currentPreset,
Holder<WorldPreset> currentPreset,
WorldDimensions worldDims
) {
final WorldDimensions dimensions;
if (currentPreset.map(Holder::value).orElse(null) instanceof TogetherWorldPreset t) {
if (currentPreset.value() instanceof TogetherWorldPreset t) {
dimensions = t.getWorldDimensions();
} else {
dimensions = TogetherWorldPreset.getWorldDimensions(net.minecraft.world.level.levelgen.presets.WorldPresets.NORMAL);
@ -251,7 +248,7 @@ public class WorldBootstrap {
String levelID,
WorldDimensions worldDims,
LevelStorageSource levelSource,
Optional<Holder<WorldPreset>> worldPreset
Holder<WorldPreset> worldPreset
) {
try {
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);
if (currentPreset.map(Holder::value).orElse(null) instanceof WorldPresetAccessor acc) {
if (currentPreset != null && currentPreset.value() instanceof WorldPresetAccessor acc) {
TogetherWorldPreset.writeWorldPresetSettings(acc.bcl_getDimensions());
} else {
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.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.biome.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.biome.*;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
import net.minecraft.world.level.dimension.DimensionType;
@ -69,7 +66,10 @@ public class WorldPresets {
public final WorldGenUtil.Context netherContext;
public final WorldGenUtil.Context endContext;
public final HolderGetter<MultiNoiseBiomeSourceParameterList> parameterLists;
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);
this.noiseSettings = bootstapContext.lookup(Registries.NOISE_SETTINGS);
@ -78,16 +78,20 @@ public class WorldPresets {
this.structureSets = bootstapContext.lookup(Registries.STRUCTURE_SET);
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);
this.overworldStem = makeNoiseBasedOverworld(overworldBiomeSource, defaultOverworldNoise);
this.netherDimensionType = dimensionTypes.getOrThrow(BuiltinDimensionTypes.NETHER);
Holder.Reference<MultiNoiseBiomeSourceParameterList> netherParameters = parameterLists
.getOrThrow(MultiNoiseBiomeSourceParameterLists.NETHER);
Holder<NoiseGeneratorSettings> defaultNetherNoise = this.noiseSettings.getOrThrow(NoiseGeneratorSettings.NETHER);
this.netherStem = new LevelStem(
netherDimensionType,
new NoiseBasedChunkGenerator(
MultiNoiseBiomeSource.Preset.NETHER.biomeSource(this.biomes),
MultiNoiseBiomeSource.createFromPreset(netherParameters),
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/presets/WorldPresets$Bootstrap
extendable class net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator
accessible class net/minecraft/core/registries/BuiltInRegistries$RegistryBootstrap
accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource
accessible class net/minecraft/server/dedicated/DedicatedServerProperties$WorldDimensionData
accessible class net/minecraft/client/resources/model/AtlasSet$AtlasEntry
accessible class net/minecraft/core/registries/BuiltInRegistries$RegistryBootstrap
accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource
accessible class net/minecraft/server/dedicated/DedicatedServerProperties$WorldDimensionData
accessible class net/minecraft/client/resources/model/AtlasSet$AtlasEntry
extendable class net/minecraft/world/level/block/state/properties/WoodType
#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/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

View file

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

View file

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

View file

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