diff --git a/gradle.properties b/gradle.properties index de02c6f9..90c39fde 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ fabric_version=0.100.0+1.21 maven_group = eu.pb4 -mod_version = 0.9.4 +mod_version = 0.9.5 minecraft_version_supported = ">=1.20.5-" diff --git a/polymer-autohost/src/main/java/eu/pb4/polymer/autohost/impl/AutoHost.java b/polymer-autohost/src/main/java/eu/pb4/polymer/autohost/impl/AutoHost.java index bdea79fb..bbbcd7d3 100644 --- a/polymer-autohost/src/main/java/eu/pb4/polymer/autohost/impl/AutoHost.java +++ b/polymer-autohost/src/main/java/eu/pb4/polymer/autohost/impl/AutoHost.java @@ -44,7 +44,6 @@ public class AutoHost implements ModInitializer { public static void init(MinecraftServer server) { var config = CommonImpl.loadConfig("auto-host", AutoHostConfig.class); AutoHost.config = config; - AutoHost.config.enabled |= Files.exists(FabricLoader.getInstance().getGameDir().resolve("polymer/.force_autohost")); if (!config.enabled) { return; diff --git a/polymer-autohost/src/main/java/eu/pb4/polymer/autohost/impl/providers/StandaloneWebServerProvider.java b/polymer-autohost/src/main/java/eu/pb4/polymer/autohost/impl/providers/StandaloneWebServerProvider.java index e838ec3d..96fbaad5 100644 --- a/polymer-autohost/src/main/java/eu/pb4/polymer/autohost/impl/providers/StandaloneWebServerProvider.java +++ b/polymer-autohost/src/main/java/eu/pb4/polymer/autohost/impl/providers/StandaloneWebServerProvider.java @@ -47,7 +47,9 @@ public void serverStarted(MinecraftServer minecraftServer) { @Nullable public void serverStopped(MinecraftServer minecraftServer) { - server.stop(0); + if (server != null) { + server.stop(0); + } } protected boolean updateHash() { diff --git a/polymer-autohost/src/main/java/eu/pb4/polymer/autohost/mixin/ServerConfigurationNetworkHandlerMixin.java b/polymer-autohost/src/main/java/eu/pb4/polymer/autohost/mixin/ServerConfigurationNetworkHandlerMixin.java index 5e323d39..0946a0ea 100644 --- a/polymer-autohost/src/main/java/eu/pb4/polymer/autohost/mixin/ServerConfigurationNetworkHandlerMixin.java +++ b/polymer-autohost/src/main/java/eu/pb4/polymer/autohost/mixin/ServerConfigurationNetworkHandlerMixin.java @@ -4,6 +4,7 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.llamalad7.mixinextras.sugar.Local; +import com.mojang.authlib.GameProfile; import eu.pb4.polymer.autohost.impl.AutoHost; import eu.pb4.polymer.autohost.impl.AutoHostTask; import eu.pb4.polymer.common.api.PolymerCommonUtils; @@ -34,9 +35,11 @@ public ServerConfigurationNetworkHandlerMixin(MinecraftServer server, ClientConn @Shadow protected abstract void onTaskFinished(ServerPlayerConfigurationTask.Key key); + @Shadow protected abstract GameProfile getProfile(); + @Inject(method = "queueSendResourcePackTask", at = @At("TAIL")) private void polymerAutoHost$addTask(CallbackInfo ci) { - if (AutoHost.config.enabled) { + if (AutoHost.config.enabled && !this.server.isHost(this.getProfile())) { var x = new ArrayList(); var ready = AutoHost.provider.isReady(); if (ready) { diff --git a/polymer-core/src/main/java/eu/pb4/polymer/core/api/item/PolymerItemUtils.java b/polymer-core/src/main/java/eu/pb4/polymer/core/api/item/PolymerItemUtils.java index 56ab1773..302732e0 100644 --- a/polymer-core/src/main/java/eu/pb4/polymer/core/api/item/PolymerItemUtils.java +++ b/polymer-core/src/main/java/eu/pb4/polymer/core/api/item/PolymerItemUtils.java @@ -302,7 +302,7 @@ public static boolean isPolymerServerItem(ItemStack itemStack, @Nullable ServerP return true; } else if (x.getValue() != null && x.getValue().isPresent() && x.getValue().get() instanceof TransformingComponent t - && t.polymer$requireModification(player)) { + && t.polymer$requireModification(ctx)) { return true; } } @@ -417,13 +417,18 @@ public static ItemStack createItemStack(ItemStack itemStack, TooltipType tooltip } } + var ctx = PacketContext.get(); + if (player != null && ctx.getPlayer() != player) { + ctx = PacketContext.of(player); + } + for (var i = 0; i < COMPONENTS_TO_COPY.length; i++) { var key = COMPONENTS_TO_COPY[i]; var x = itemStack.get(key); if (x instanceof TransformingComponent t) { //noinspection unchecked,rawtypes - out.set((ComponentType) key, t.polymer$getTransformed(player)); + out.set((ComponentType) key, t.polymer$getTransformed(ctx)); } else { //noinspection unchecked,rawtypes out.set((ComponentType) key, (Object) itemStack.get(key)); diff --git a/polymer-core/src/main/java/eu/pb4/polymer/core/api/other/PolymerComponent.java b/polymer-core/src/main/java/eu/pb4/polymer/core/api/other/PolymerComponent.java index 85278766..29326cf3 100644 --- a/polymer-core/src/main/java/eu/pb4/polymer/core/api/other/PolymerComponent.java +++ b/polymer-core/src/main/java/eu/pb4/polymer/core/api/other/PolymerComponent.java @@ -5,6 +5,7 @@ import eu.pb4.polymer.rsm.api.RegistrySyncUtils; import net.minecraft.component.ComponentType; import net.minecraft.registry.Registries; +import org.jetbrains.annotations.Nullable; import xyz.nucleoid.packettweaker.PacketContext; public interface PolymerComponent extends PolymerObject { @@ -26,7 +27,7 @@ static boolean isPolymerComponent(ComponentType type) { return PolymerComponentImpl.UNSYNCED_COMPONENTS.contains(type); } - static boolean canSync(ComponentType key, Object entry, PacketContext context) { + static boolean canSync(ComponentType key, @Nullable Object entry, PacketContext context) { if (entry instanceof PolymerComponent component && component.canSyncRawToClient(context)) { return true; } diff --git a/polymer-core/src/main/java/eu/pb4/polymer/core/impl/PolymerImplUtils.java b/polymer-core/src/main/java/eu/pb4/polymer/core/impl/PolymerImplUtils.java index 90be947a..618893a0 100644 --- a/polymer-core/src/main/java/eu/pb4/polymer/core/impl/PolymerImplUtils.java +++ b/polymer-core/src/main/java/eu/pb4/polymer/core/impl/PolymerImplUtils.java @@ -37,6 +37,7 @@ import net.minecraft.state.property.Property; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; import org.jetbrains.annotations.Nullable; import java.io.BufferedWriter; @@ -123,7 +124,14 @@ public static String dumpRegistry() { msg.accept(""); msg.accept("= Polymer Starts: " + PolymerImplUtils.getBlockStateOffset()); msg.accept(""); - msg.accept("= Vanilla ChunkDeltaUpdateS2CPacket broken: " + (PolymerImplUtils.getBlockStateOffset() >= 524288)); + msg.accept("= All States: " + Block.STATE_IDS.size()); + + //noinspection unchecked + var pl = (PolymerIdList) Block.STATE_IDS; + msg.accept("= Polymer States: " + pl.polymer$getPolymerEntries().size()); + msg.accept("= Server Bits: " + MathHelper.ceilLog2(Block.STATE_IDS.size())); + msg.accept("= Vanilla Bits: " + pl.polymer$getVanillaBitCount()); + msg.accept("= NonPolymer Bits: " + pl.polymer$getNonPolymerBitCount()); msg.accept(""); for (var state : Block.STATE_IDS) { diff --git a/polymer-core/src/main/java/eu/pb4/polymer/core/impl/TransformingComponent.java b/polymer-core/src/main/java/eu/pb4/polymer/core/impl/TransformingComponent.java index ba427722..f4068011 100644 --- a/polymer-core/src/main/java/eu/pb4/polymer/core/impl/TransformingComponent.java +++ b/polymer-core/src/main/java/eu/pb4/polymer/core/impl/TransformingComponent.java @@ -1,8 +1,9 @@ package eu.pb4.polymer.core.impl; import net.minecraft.server.network.ServerPlayerEntity; +import xyz.nucleoid.packettweaker.PacketContext; public interface TransformingComponent { - Object polymer$getTransformed(ServerPlayerEntity player); - boolean polymer$requireModification(ServerPlayerEntity player); + Object polymer$getTransformed(PacketContext context); + boolean polymer$requireModification(PacketContext context); } diff --git a/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/item/component/AttributeModifiersComponentMixin.java b/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/item/component/AttributeModifiersComponentMixin.java index 3470938a..eac4828a 100644 --- a/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/item/component/AttributeModifiersComponentMixin.java +++ b/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/item/component/AttributeModifiersComponentMixin.java @@ -7,6 +7,7 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import xyz.nucleoid.packettweaker.PacketContext; import java.util.ArrayList; import java.util.List; @@ -18,8 +19,8 @@ public class AttributeModifiersComponentMixin implements TransformingComponent { @Shadow @Final private boolean showInTooltip; @Override - public Object polymer$getTransformed(ServerPlayerEntity player) { - if (!polymer$requireModification(player)) { + public Object polymer$getTransformed(PacketContext context) { + if (!polymer$requireModification(context)) { return this; } var list = new ArrayList(); @@ -33,7 +34,7 @@ public class AttributeModifiersComponentMixin implements TransformingComponent { } @Override - public boolean polymer$requireModification(ServerPlayerEntity player) { + public boolean polymer$requireModification(PacketContext context) { for (var x : this.modifiers) { if (PolymerEntityUtils.isPolymerEntityAttribute(x.attribute())) { return true; diff --git a/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/item/component/DebugStickStateComponentMixin.java b/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/item/component/DebugStickStateComponentMixin.java new file mode 100644 index 00000000..99626a7d --- /dev/null +++ b/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/item/component/DebugStickStateComponentMixin.java @@ -0,0 +1,39 @@ +package eu.pb4.polymer.core.mixin.item.component; + +import eu.pb4.polymer.core.api.utils.PolymerSyncedObject; +import eu.pb4.polymer.core.impl.TransformingComponent; +import net.minecraft.block.Block; +import net.minecraft.component.type.DebugStickStateComponent; +import net.minecraft.registry.Registries; +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.state.property.Property; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import xyz.nucleoid.packettweaker.PacketContext; + +import java.util.Map; + +@Mixin(DebugStickStateComponent.class) +public class DebugStickStateComponentMixin implements TransformingComponent { + @Shadow @Final private Map, Property> properties; + + @Override + public Object polymer$getTransformed(PacketContext context) { + if (polymer$requireModification(context)) { + return DebugStickStateComponent.DEFAULT; + } + return this; + } + + @Override + public boolean polymer$requireModification(PacketContext context) { + for (var key : this.properties.keySet()) { + if (!PolymerSyncedObject.canSyncRawToClient(Registries.BLOCK, key.value(), context.getPlayer())) { + return true; + } + } + return false; + } +} diff --git a/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/item/component/FoodComponentMixin.java b/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/item/component/FoodComponentMixin.java index ab459564..f6bf3f28 100644 --- a/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/item/component/FoodComponentMixin.java +++ b/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/item/component/FoodComponentMixin.java @@ -8,6 +8,7 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import xyz.nucleoid.packettweaker.PacketContext; import java.util.List; import java.util.Optional; @@ -27,8 +28,8 @@ public abstract class FoodComponentMixin implements TransformingComponent { @Shadow public abstract Optional usingConvertsTo(); @Override - public Object polymer$getTransformed(ServerPlayerEntity player) { - if (!polymer$requireModification(player)) { + public Object polymer$getTransformed(PacketContext context) { + if (!polymer$requireModification(context)) { return this; } @@ -36,7 +37,7 @@ public abstract class FoodComponentMixin implements TransformingComponent { } @Override - public boolean polymer$requireModification(ServerPlayerEntity player) { + public boolean polymer$requireModification(PacketContext context) { for (var effect : this.effects) { if (effect.effect().getEffectType().value() instanceof PolymerObject) { return true; diff --git a/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/item/component/PotionContentsComponentMixin.java b/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/item/component/PotionContentsComponentMixin.java index bba2c57d..623b41fd 100644 --- a/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/item/component/PotionContentsComponentMixin.java +++ b/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/item/component/PotionContentsComponentMixin.java @@ -10,6 +10,7 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import xyz.nucleoid.packettweaker.PacketContext; import java.util.List; import java.util.Optional; @@ -23,8 +24,8 @@ public abstract class PotionContentsComponentMixin implements TransformingCompon @Shadow public abstract int getColor(); @Override - public Object polymer$getTransformed(ServerPlayerEntity player) { - if (!polymer$requireModification(player)) { + public Object polymer$getTransformed(PacketContext context) { + if (!polymer$requireModification(context)) { return this; } @@ -32,7 +33,7 @@ public abstract class PotionContentsComponentMixin implements TransformingCompon } @Override - public boolean polymer$requireModification(ServerPlayerEntity player) { + public boolean polymer$requireModification(PacketContext context) { if (this.potion.isPresent() && this.potion.get().value() instanceof PolymerObject) { return true; } diff --git a/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/item/component/SuspiciousStewComponentMixin.java b/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/item/component/SuspiciousStewComponentMixin.java index 97e8f3c2..79d1ce51 100644 --- a/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/item/component/SuspiciousStewComponentMixin.java +++ b/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/item/component/SuspiciousStewComponentMixin.java @@ -7,6 +7,7 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import xyz.nucleoid.packettweaker.PacketContext; import java.util.List; @@ -16,8 +17,8 @@ public abstract class SuspiciousStewComponentMixin implements TransformingCompon @Shadow @Final private List effects; @Override - public Object polymer$getTransformed(ServerPlayerEntity player) { - if (!polymer$requireModification(player)) { + public Object polymer$getTransformed(PacketContext context) { + if (!polymer$requireModification(context)) { return this; } @@ -25,7 +26,7 @@ public abstract class SuspiciousStewComponentMixin implements TransformingCompon } @Override - public boolean polymer$requireModification(ServerPlayerEntity player) { + public boolean polymer$requireModification(PacketContext context) { for (var effect : this.effects) { if (effect.effect().value() instanceof PolymerObject) { return true; diff --git a/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/other/ComponentChangesMixin.java b/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/other/ComponentChangesMixin.java new file mode 100644 index 00000000..21d3aaf5 --- /dev/null +++ b/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/other/ComponentChangesMixin.java @@ -0,0 +1,64 @@ +package eu.pb4.polymer.core.mixin.other; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.mojang.serialization.Codec; +import eu.pb4.polymer.common.api.PolymerCommonUtils; +import eu.pb4.polymer.core.api.other.PolymerComponent; +import eu.pb4.polymer.core.impl.TransformingComponent; +import eu.pb4.polymer.core.impl.networking.TransformingPacketCodec; +import net.minecraft.component.ComponentChanges; +import net.minecraft.component.ComponentType; +import net.minecraft.network.RegistryByteBuf; +import net.minecraft.network.codec.PacketCodec; +import org.spongepowered.asm.mixin.*; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import xyz.nucleoid.packettweaker.PacketContext; + +import java.util.function.Function; + +@Mixin(ComponentChanges.class) +public class ComponentChangesMixin { + @Mutable + @Shadow @Final public static PacketCodec PACKET_CODEC; + + @ModifyExpressionValue(method = "", at = @At(value = "INVOKE", target = "Lcom/mojang/serialization/Codec;xmap(Ljava/util/function/Function;Ljava/util/function/Function;)Lcom/mojang/serialization/Codec;")) + private static Codec patchCodec(Codec codec) { + return codec.xmap(Function.identity(), content -> { // Encode + if (PolymerCommonUtils.isServerNetworkingThread()) { + return transformContent(content); + } + return content; + }); + } + + @Inject(method = "", at = @At("TAIL")) + private static void patchNetCodec(CallbackInfo ci) { + PACKET_CODEC = TransformingPacketCodec.encodeOnly(PACKET_CODEC, ((byteBuf, content) -> transformContent(content))); + } + + @Unique + private static ComponentChanges transformContent(ComponentChanges content) { + var player = PacketContext.get(); + var builder = ComponentChanges.builder(); + for (var entry : content.entrySet()) { + if (!PolymerComponent.canSync(entry.getKey(), entry.getValue().orElse(null), player)) { + continue; + } else if (entry.getValue().isPresent() && entry.getValue().get() instanceof TransformingComponent t) { + //noinspection unchecked + builder.add((ComponentType) entry.getKey(), t.polymer$getTransformed(player)); + } + + if (entry.getValue().isPresent()) { + //noinspection unchecked + builder.add((ComponentType) entry.getKey(), entry.getValue().get()); + } else { + builder.remove(entry.getKey()); + } + } + return builder.build(); + } +} diff --git a/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/other/ComponentMapMixin.java b/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/other/ComponentMapMixin.java index 072cbb87..d895590f 100644 --- a/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/other/ComponentMapMixin.java +++ b/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/other/ComponentMapMixin.java @@ -8,6 +8,7 @@ import eu.pb4.polymer.core.api.item.PolymerItemUtils; import eu.pb4.polymer.core.api.other.PolymerComponent; import eu.pb4.polymer.core.impl.PolymerImplUtils; +import eu.pb4.polymer.core.impl.TransformingComponent; import net.minecraft.component.ComponentMap; import net.minecraft.component.ComponentType; import net.minecraft.text.HoverEvent; @@ -34,7 +35,9 @@ private static Codec, Object>> patchCodec(Codec, Object>(); for (var key : content.keySet()) { var entry = content.get(key); - if (PolymerComponent.canSync(key, entry, player)) { + if (entry instanceof TransformingComponent t) { + map.put(key, t.polymer$getTransformed(player)); + } else if (PolymerComponent.canSync(key, entry, player)) { map.put(key, entry); } } diff --git a/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/other/HoverEventMixin.java b/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/other/HoverEventMixin.java index 7a274dca..6a24206d 100644 --- a/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/other/HoverEventMixin.java +++ b/polymer-core/src/main/java/eu/pb4/polymer/core/mixin/other/HoverEventMixin.java @@ -45,6 +45,7 @@ private static Codec patchCodec(Codec codec) { } else if (content.getAction() == HoverEvent.Action.SHOW_ENTITY) { var val = Objects.requireNonNull(content.getValue(HoverEvent.Action.SHOW_ENTITY)); if (PolymerEntityUtils.isPolymerEntityType(val.entityType)) { + val = new HoverEvent.EntityContent(val.entityType, val.uuid, val.name); return new HoverEvent(HoverEvent.Action.SHOW_TEXT, Texts.join(val.asTooltip(), Text.literal("\n"))); } } diff --git a/polymer-core/src/main/resources/polymer-core.mixins.json b/polymer-core/src/main/resources/polymer-core.mixins.json index 6640ffd2..2737c87a 100644 --- a/polymer-core/src/main/resources/polymer-core.mixins.json +++ b/polymer-core/src/main/resources/polymer-core.mixins.json @@ -53,6 +53,7 @@ "entity.PlayerListS2CPacketAccessor", "entity.RemoveEntityStatusEffectS2CPacketMixin", "entity.ServerWorldAccessor", + "item.component.DebugStickStateComponentMixin", "item.ItemGroupMixin", "item.ItemGroupsMixin", "item.ItemStackMixin", @@ -70,6 +71,7 @@ "item.packet.SynchronizeRecipesS2CPacketMixin", "item.packet.TradedItemMixin", "other.CodecCacheMixin", + "other.ComponentChangesMixin", "other.ComponentMapMixin", "other.FluidMixin", "other.HoverEventMixin", diff --git a/polymer-core/src/testmod/java/eu/pb4/polymertest/TestBlock.java b/polymer-core/src/testmod/java/eu/pb4/polymertest/TestBlock.java index 30794fd8..e997bfea 100644 --- a/polymer-core/src/testmod/java/eu/pb4/polymertest/TestBlock.java +++ b/polymer-core/src/testmod/java/eu/pb4/polymertest/TestBlock.java @@ -5,6 +5,7 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.DispenserBlock; +import net.minecraft.component.DataComponentTypes; import net.minecraft.component.EnchantmentEffectComponentTypes; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; @@ -26,7 +27,7 @@ public TestBlock(Settings settings) { super(settings); } - private static final IntProperty TEST = IntProperty.of("test", 0, 10); + private static final IntProperty TEST = IntProperty.of("test", 0, 100); @Nullable @Override @@ -39,7 +40,7 @@ public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable Livi EnchantmentHelper.getEffect(itemStack, EnchantmentEffectComponentTypes.REPAIR_WITH_XP).isPresent(); EnchantmentHelper.getLevel(world.getRegistryManager().getWrapperOrThrow(RegistryKeys.ENCHANTMENT).getOrThrow(Enchantments.MENDING), itemStack); super.onPlaced(world, pos, state, placer, itemStack); - //itemStack.getOrCreateNbt().putInt("y", itemStack.getOrCreateNbt().getInt("y") + 1); + itemStack.set(DataComponentTypes.REPAIR_COST, (itemStack.getOrDefault(DataComponentTypes.REPAIR_COST, 0) + 1) % 100); } @Override diff --git a/polymer-core/src/testmod/java/eu/pb4/polymertest/TestMod.java b/polymer-core/src/testmod/java/eu/pb4/polymertest/TestMod.java index 8ac4e6dc..0c3a58b3 100644 --- a/polymer-core/src/testmod/java/eu/pb4/polymertest/TestMod.java +++ b/polymer-core/src/testmod/java/eu/pb4/polymertest/TestMod.java @@ -115,7 +115,7 @@ public void accept(ItemGroup.DisplayContext arg, ItemGroup.Entries entries) { public static BlockItem BLOCK_ITEM_2 = new PolymerBlockItem(BLOCK_2, new Item.Settings(), Items.TNT); public static BlockItem BLOCK_ITEM_3 = new PolymerBlockItem(BLOCK_3, new Item.Settings(), Items.COBWEB); public static TinyPotatoBlock TATER_BLOCK = new TinyPotatoBlock(AbstractBlock.Settings.create().strength(10f)); - public static BlockItem TATER_BLOCK_ITEM = new PolymerHeadBlockItem(TATER_BLOCK, new Item.Settings().maxCount(9999)); + public static BlockItem TATER_BLOCK_ITEM = new PolymerHeadBlockItem(TATER_BLOCK, new Item.Settings().maxCount(99)); public static BlockItem TATER_BLOCK_ITEM2 = new PolymerBlockItem(TATER_BLOCK, new Item.Settings(), Items.RAW_IRON_BLOCK); public static TestPickaxeItem PICKAXE = new TestPickaxeItem(Items.WOODEN_PICKAXE, ToolMaterials.NETHERITE, 10, -3.9f, new Item.Settings()); public static TestPickaxeItem PICKAXE2 = new TestPickaxeItem(Items.NETHERITE_PICKAXE, ToolMaterials.WOOD, 10, -5f, new Item.Settings()); @@ -317,7 +317,7 @@ public void onInitialize() { register(Registries.ITEM, Identifier.of("test", "mana_cauldron"), MANA_CAULDRON_ITEM); register(Registries.BLOCK, Identifier.of("test", "mana_cauldron"), MANA_CAULDRON); - for (var i = 0; i < 16; i++) { + for (var i = 0; i < 1600; i++) { register(Registries.BLOCK, Identifier.of("test", "filler_" + i), new TestBlock(AbstractBlock.Settings.create())); }