Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/dev/1.21.2' into de…
Browse files Browse the repository at this point in the history
…v/1.21.4

# Conflicts:
#	gradle.properties
  • Loading branch information
Patbox committed Nov 21, 2024
2 parents e9ab976 + 30794a1 commit 786bf19
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 19 deletions.
2 changes: 1 addition & 1 deletion polymer-autohost/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dependencies {

compileOnly (project(path: ':polymer-virtual-entity', configuration: 'namedElements'))
localRuntime (project(path: ':polymer-virtual-entity', configuration: 'namedElements'))
//modLocalRuntime("xyz.nucleoid:server-translations-api:2.0.0-beta.2+1.19.4-pre2")
modLocalRuntime("xyz.nucleoid:server-translations-api:2.4.0+1.21.2-rc1")
api include('io.netty:netty-codec-http:4.1.82.Final')

project(":polymer-core").afterEvaluate {
Expand Down
5 changes: 2 additions & 3 deletions polymer-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies {

//modRuntime "supercoder79:databreaker:0.2.7"

modCompileOnly('maven.modrinth:lithium:mc1.21-0.12.7')
modCompileOnly('maven.modrinth:lithium:mc1.21.1-0.14.0-beta.1')

//modCompileOnly ('nl.theepicblock:PolyMc:5.1.0+1.19')
modCompileOnly('com.github.TheEpicBlock:PolyMc:5.6.1') {
Expand All @@ -67,8 +67,7 @@ dependencies {

modCompileOnly "xyz.nucleoid:disguiselib-fabric:1.2.2"

modCompileOnly("xyz.nucleoid:server-translations-api:2.3.0+1.20.5-rc2")
//modLocalRuntime("xyz.nucleoid:server-translations-api:2.0.0-beta.2+1.19.4-pre2")
modCompileOnly("xyz.nucleoid:server-translations-api:2.4.0+1.21.2-rc1")

modCompileOnly 'com.github.iPortalTeam:ImmersivePortalsMod:v5.1.0-mc1.20.4'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static BlockState getBlockStateSafely(PolymerBlock block, BlockState bloc

int req = 0;
while (out.getBlock() instanceof PolymerBlock newBlock && newBlock != block && req < maxDistance) {
out = newBlock.getPolymerBlockState(blockState, context);
out = newBlock.getPolymerBlockState(out, context);
req++;
}
return out;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package eu.pb4.polymer.core.impl.other;

import net.minecraft.component.ComponentChanges;
import net.minecraft.component.ComponentMap;
import net.minecraft.component.ComponentType;
import org.jetbrains.annotations.Nullable;

import java.util.HashSet;
import java.util.Set;

public record ComponentChangesMap(ComponentChanges changes) implements ComponentMap {
@Nullable
@Override
public <T> T get(ComponentType<? extends T> type) {
var x = this.changes.get(type);
//noinspection OptionalAssignedToNull
return x != null ? x.orElse(null) : null;
}

@Override
public Set<ComponentType<?>> getTypes() {
var set = new HashSet<ComponentType<?>>();
for (var entry : this.changes.entrySet()) {
if (entry.getValue().isPresent()) {
set.add(entry.getKey());
}
}
return set;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ public class MicroUiElements {
EMPTY.set(DataComponentTypes.HIDE_TOOLTIP, Unit.INSTANCE);

BUTTON_PREVIOUS = Items.GREEN_STAINED_GLASS_PANE.getDefaultStack();
BUTTON_PREVIOUS.set(DataComponentTypes.CUSTOM_NAME, Text.translatable("createWorld.customize.custom.prev").setStyle(Style.EMPTY.withItalic(false).withColor(Formatting.GREEN)));
BUTTON_PREVIOUS.set(DataComponentTypes.CUSTOM_NAME, Text.translatable("spectatorMenu.previous_page").setStyle(Style.EMPTY.withItalic(false).withColor(Formatting.GREEN)));

BUTTON_PREVIOUS_LOCK = Items.WHITE_STAINED_GLASS_PANE.getDefaultStack();
BUTTON_PREVIOUS_LOCK.set(DataComponentTypes.CUSTOM_NAME, Text.translatable("createWorld.customize.custom.prev").setStyle(Style.EMPTY.withItalic(false).withColor(Formatting.DARK_GRAY)));
BUTTON_PREVIOUS_LOCK.set(DataComponentTypes.CUSTOM_NAME, Text.translatable("spectatorMenu.previous_page").setStyle(Style.EMPTY.withItalic(false).withColor(Formatting.DARK_GRAY)));

BUTTON_NEXT = Items.GREEN_STAINED_GLASS_PANE.getDefaultStack();
BUTTON_NEXT.set(DataComponentTypes.CUSTOM_NAME, Text.translatable("createWorld.customize.custom.next").setStyle(Style.EMPTY.withItalic(false).withColor(Formatting.GREEN)));
BUTTON_NEXT.set(DataComponentTypes.CUSTOM_NAME, Text.translatable("spectatorMenu.next_page").setStyle(Style.EMPTY.withItalic(false).withColor(Formatting.GREEN)));

BUTTON_NEXT_LOCK = Items.WHITE_STAINED_GLASS_PANE.getDefaultStack();
BUTTON_NEXT_LOCK.set(DataComponentTypes.CUSTOM_NAME, Text.translatable("createWorld.customize.custom.next").setStyle(Style.EMPTY.withItalic(false).withColor(Formatting.DARK_GRAY)));
BUTTON_NEXT_LOCK.set(DataComponentTypes.CUSTOM_NAME, Text.translatable("spectatorMenu.next_page").setStyle(Style.EMPTY.withItalic(false).withColor(Formatting.DARK_GRAY)));

BUTTON_BACK = Items.BARRIER.getDefaultStack();
BUTTON_BACK.set(DataComponentTypes.CUSTOM_NAME, Text.translatable("gui.back").setStyle(Style.EMPTY.withItalic(false).withColor(Formatting.RED)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
public class AbstractBlockMixin {
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
private void polymer$replaceOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
if (this instanceof PolymerBlock block && world instanceof World realWorld) {
var clientState = PolymerBlockUtils.getBlockStateSafely(block, state, PacketContext.create(realWorld.getRegistryManager()));
if (this instanceof PolymerBlock block) {
var clientState = PolymerBlockUtils.getBlockStateSafely(block, state,
world instanceof World realWorld ? PacketContext.create(realWorld.getRegistryManager()) : PacketContext.create());
if (!(clientState.getBlock() instanceof PolymerBlock)) {
cir.setReturnValue(clientState.getOutlineShape(world, pos, context));
}
Expand All @@ -31,11 +32,11 @@ public class AbstractBlockMixin {

@Inject(method = "getCollisionShape", at = @At("HEAD"), cancellable = true)
private void polymer$replaceCollision(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
if (this instanceof PolymerBlock block && world instanceof World realWorld) {
if (this instanceof PolymerBlock block) {
var clientState = context instanceof EntityShapeContext entityShapeContext
&& entityShapeContext.getEntity() instanceof ServerPlayerEntity player
? PolymerBlockUtils.getBlockStateSafely(block, state, PacketContext.create(player))
: PolymerBlockUtils.getBlockStateSafely(block, state, PacketContext.create(realWorld.getRegistryManager()));
: PolymerBlockUtils.getBlockStateSafely(block, state, world instanceof World realWorld ? PacketContext.create(realWorld.getRegistryManager()) : PacketContext.create());
if (!(clientState.getBlock() instanceof PolymerBlock)) {
cir.setReturnValue(clientState.getCollisionShape(world, pos, context));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package eu.pb4.polymer.core.mixin.compat;

import eu.pb4.polymer.core.api.block.PolymerBlockUtils;
import eu.pb4.polymer.core.api.utils.PolymerUtils;
import eu.pb4.polymer.core.impl.client.InternalClientRegistry;
import me.jellysquid.mods.lithium.common.world.chunk.LithiumHashPalette;
import net.caffeinemc.mods.lithium.common.world.chunk.LithiumHashPalette;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.BlockState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import eu.pb4.polymer.core.api.item.PolymerItemUtils;
import eu.pb4.polymer.core.impl.networking.TransformingPacketCodec;
import eu.pb4.polymer.core.impl.other.ComponentChangesMap;
import net.minecraft.component.ComponentMap;
import net.minecraft.network.RegistryByteBuf;
import net.minecraft.network.codec.PacketCodec;
import net.minecraft.predicate.ComponentPredicate;
Expand All @@ -16,11 +18,13 @@ public class TradedItemMixin {
@ModifyExpressionValue(method = "<clinit>", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/codec/PacketCodec;tuple(Lnet/minecraft/network/codec/PacketCodec;Ljava/util/function/Function;Lnet/minecraft/network/codec/PacketCodec;Ljava/util/function/Function;Lnet/minecraft/network/codec/PacketCodec;Ljava/util/function/Function;Lcom/mojang/datafixers/util/Function3;)Lnet/minecraft/network/codec/PacketCodec;"))
private static PacketCodec<RegistryByteBuf, TradedItem> polymerifyTheStack(PacketCodec<RegistryByteBuf, TradedItem> original) {
return new TransformingPacketCodec<>(original, (buf, tradedItem) -> {
var stack = PolymerItemUtils.getPolymerItemStack(tradedItem.itemStack(), PacketContext.get());
return new TradedItem(stack.getItem().getRegistryEntry(), stack.getCount(), ComponentPredicate.of(stack.getComponents()));
var input = tradedItem.itemStack();
var stack = PolymerItemUtils.getPolymerItemStack(input, PacketContext.get());
return stack != input ? new TradedItem(stack.getItem().getRegistryEntry(), stack.getCount(), ComponentPredicate.of(new ComponentChangesMap(stack.getComponentChanges()))) : tradedItem;
}, (buf, tradedItem) -> {
var stack = PolymerItemUtils.getRealItemStack(tradedItem.itemStack(), buf.getRegistryManager());
return new TradedItem(stack.getItem().getRegistryEntry(), stack.getCount(), ComponentPredicate.of(stack.getComponents()));
var input = tradedItem.itemStack();
var stack = PolymerItemUtils.getRealItemStack(input, buf.getRegistryManager());
return stack != input ? new TradedItem(stack.getItem().getRegistryEntry(), stack.getCount(), ComponentPredicate.of(new ComponentChangesMap(stack.getComponentChanges()))) : tradedItem;
});
}
}

0 comments on commit 786bf19

Please sign in to comment.