diff --git a/dependencies.properties b/dependencies.properties index ce7901a..e61e593 100644 --- a/dependencies.properties +++ b/dependencies.properties @@ -1 +1 @@ -neoforge=21.0.98-beta \ No newline at end of file +neoforge=21.0.146 \ No newline at end of file diff --git a/src/main/java/org/violetmoon/zeta/advancement/modifier/AdventuringTimeModifier.java b/src/main/java/org/violetmoon/zeta/advancement/modifier/AdventuringTimeModifier.java index ad114bd..a6593fe 100644 --- a/src/main/java/org/violetmoon/zeta/advancement/modifier/AdventuringTimeModifier.java +++ b/src/main/java/org/violetmoon/zeta/advancement/modifier/AdventuringTimeModifier.java @@ -2,6 +2,9 @@ import java.util.Set; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.RegistryAccess; +import net.minecraft.core.registries.Registries; import org.violetmoon.zeta.advancement.AdvancementModifier; import org.violetmoon.zeta.api.IMutableAdvancement; import org.violetmoon.zeta.module.ZetaModule; @@ -35,12 +38,12 @@ public Set getTargets() { public boolean apply(ResourceLocation res, IMutableAdvancement adv) { for(ResourceKey key : locations) { String name = key.location().toString(); - - Criterion criterion = new Criterion(PlayerTrigger.TriggerInstance.located( - LocationPredicate.inBiome(key))); //todo: I dunno how to do codec - adv.addRequiredCriterion(name, criterion); + /* TODO: event.getRegistryAccess() IN AdvancementModifierRegistry, pass to here? + Criterion criterion = PlayerTrigger.TriggerInstance.located( + LocationPredicate.Builder.inBiome(access.registry(Registries.BIOME).get().getHolderOrThrow(key))); + adv.addRequiredCriterion(name, criterion); + */ } - return true; } diff --git a/src/main/java/org/violetmoon/zeta/block/ext/IZetaBlockExtensions.java b/src/main/java/org/violetmoon/zeta/block/ext/IZetaBlockExtensions.java index efeaa33..9da0395 100644 --- a/src/main/java/org/violetmoon/zeta/block/ext/IZetaBlockExtensions.java +++ b/src/main/java/org/violetmoon/zeta/block/ext/IZetaBlockExtensions.java @@ -13,6 +13,7 @@ import net.minecraft.world.level.block.*; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.FluidState; +import net.neoforged.neoforge.common.ItemAbility; import org.jetbrains.annotations.Nullable; import java.util.Optional; @@ -95,13 +96,13 @@ default boolean shouldDisplayFluidOverlayZeta(BlockState state, BlockAndTintGett } @Nullable - default BlockState getToolModifiedStateZeta(BlockState state, UseOnContext context, String itemAbility, boolean simulate) { + default BlockState getToolModifiedStateZeta(BlockState state, UseOnContext context, ItemAbility ability, boolean simulate) { //TODO, check i copied forge correctly //ItemStack itemStack = context.getItemInHand(); //if (!itemStack.canPerformAction(toolAction)) //Forge extension, TODO when i make an IZetaItemExtensions // return null; - return switch(itemAbility) { + return switch(ability.toString()) { case "axe_strip" -> AxeItem.getAxeStrippingState(state); //TODO forge extension case "axe_scrape" -> WeatheringCopper.getPrevious(state).orElse(null); case "axe_wax_off" -> Optional.ofNullable(HoneycombItem.WAX_OFF_BY_BLOCK.get().get(state.getBlock())).map(block -> block.withPropertiesOf(state)).orElse(null); diff --git a/src/main/java/org/violetmoon/zeta/client/config/widget/ScrollableWidgetList.java b/src/main/java/org/violetmoon/zeta/client/config/widget/ScrollableWidgetList.java index f12c757..cc356f1 100644 --- a/src/main/java/org/violetmoon/zeta/client/config/widget/ScrollableWidgetList.java +++ b/src/main/java/org/violetmoon/zeta/client/config/widget/ScrollableWidgetList.java @@ -18,7 +18,7 @@ public class ScrollableWidgetList public, and made more convenient (takes index instead of Entry) public void ensureVisible2(int index) { int i = this.getRowTop(index); - int j = i - this.y0 - 4 - this.itemHeight; + int j = i - this.getY() - 4 - this.itemHeight; if (j < 0) this.scroll2(j); - int k = this.y1 - i - this.itemHeight - this.itemHeight; + int k = this.getBottom() - i - this.itemHeight - this.itemHeight; if (k < 0) this.scroll2(-k); } diff --git a/src/main/java/org/violetmoon/zeta/client/event/play/ZScreen.java b/src/main/java/org/violetmoon/zeta/client/event/play/ZScreen.java index a4ab9d1..b05e7e4 100644 --- a/src/main/java/org/violetmoon/zeta/client/event/play/ZScreen.java +++ b/src/main/java/org/violetmoon/zeta/client/event/play/ZScreen.java @@ -40,7 +40,8 @@ interface Post extends MouseButtonPressed { } } interface MouseScrolled extends ZScreen, Cancellable { - double getScrollDelta(); + double getScrollDeltaX(); + double getScrollDeltaY(); interface Pre extends MouseScrolled { } interface Post extends MouseScrolled { } diff --git a/src/main/java/org/violetmoon/zeta/config/ConfigFlagManager.java b/src/main/java/org/violetmoon/zeta/config/ConfigFlagManager.java index 720c239..7c98de2 100644 --- a/src/main/java/org/violetmoon/zeta/config/ConfigFlagManager.java +++ b/src/main/java/org/violetmoon/zeta/config/ConfigFlagManager.java @@ -5,6 +5,7 @@ import java.util.Map; import java.util.Set; +import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType; import org.violetmoon.zeta.Zeta; import org.violetmoon.zeta.event.bus.LoadEvent; import org.violetmoon.zeta.event.load.ZRegister; @@ -26,6 +27,8 @@ public final class ConfigFlagManager { //TODO augh; needed for BrewingRegistry public final FlagIngredient.Serializer flagIngredientSerializer = new FlagIngredient.Serializer(this); + public static final LootItemConditionType FLAG_CONDITION_TYPE = new LootItemConditionType(FlagLootCondition.CODEC); + public ConfigFlagManager(Zeta zeta) { this.zeta = zeta; @@ -40,9 +43,7 @@ public void onRegister(ZRegister event) { ext.registerConditionSerializer(new FlagCondition.Serializer(this, ResourceLocation.fromNamespaceAndPath(zeta.modid, "flag"))); ext.registerConditionSerializer(new FlagCondition.Serializer(this, ResourceLocation.fromNamespaceAndPath(zeta.modid, "advancement_flag"), () -> ZetaGeneralConfig.enableModdedAdvancements)); - FlagLootCondition.FlagSerializer flagSerializer = new FlagLootCondition.FlagSerializer(this); - Registry.register(BuiltInRegistries.LOOT_CONDITION_TYPE, ResourceLocation.fromNamespaceAndPath(zeta.modid, "flag"), flagSerializer.selfType); - + Registry.register(BuiltInRegistries.LOOT_CONDITION_TYPE, ResourceLocation.fromNamespaceAndPath(zeta.modid, "flag"), FLAG_CONDITION_TYPE); ext.registerIngredientSerializer(ResourceLocation.fromNamespaceAndPath(zeta.modid, "flag"), flagIngredientSerializer); SyncedFlagHandler.setupFlagManager(this); @@ -75,5 +76,4 @@ public boolean getFlag(String flag) { public Set getAllFlags() { return allFlags; } - -} +} \ No newline at end of file diff --git a/src/main/java/org/violetmoon/zeta/config/FlagLootCondition.java b/src/main/java/org/violetmoon/zeta/config/FlagLootCondition.java index 78a168d..3ebf641 100644 --- a/src/main/java/org/violetmoon/zeta/config/FlagLootCondition.java +++ b/src/main/java/org/violetmoon/zeta/config/FlagLootCondition.java @@ -1,55 +1,34 @@ package org.violetmoon.zeta.config; -import org.jetbrains.annotations.NotNull; - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonObject; -import com.google.gson.JsonSerializationContext; - +import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.world.level.storage.loot.LootContext; -import net.minecraft.world.level.storage.loot.Serializer; import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType; +import org.jetbrains.annotations.NotNull; +import org.violetmoon.zeta.mod.ZetaMod; + +import static org.violetmoon.zeta.config.ConfigFlagManager.FLAG_CONDITION_TYPE; /** * @author WireSegal * Created at 1:23 PM on 8/24/19. */ -public record FlagLootCondition(ConfigFlagManager manager, String flag, LootItemConditionType selfType) implements LootItemCondition { +public record FlagLootCondition(String flag) implements LootItemCondition { + + public static MapCodec CODEC = RecordCodecBuilder.mapCodec( + inst -> inst.group(Codec.STRING.fieldOf("flag").forGetter(FlagLootCondition::flag) + ).apply(inst, FlagLootCondition::new)); @Override public boolean test(LootContext lootContext) { - return manager.getFlag(flag); + return ZetaMod.ZETA.configManager.getConfigFlagManager().getFlag(flag); } @NotNull @Override public LootItemConditionType getType() { - return selfType; + return FLAG_CONDITION_TYPE; } - - public static final class FlagSerializer implements Serializer { - private final ConfigFlagManager manager; - public final LootItemConditionType selfType; - - public FlagSerializer(ConfigFlagManager manager) { - this.manager = manager; - - //The LootItemCondition stuff has a circular dependency :/ - this.selfType = new LootItemConditionType(this); - } - - @Override - public void serialize(@NotNull JsonObject json, @NotNull FlagLootCondition value, @NotNull JsonSerializationContext context) { - json.addProperty("flag", value.flag); - } - - @NotNull - @Override - public FlagLootCondition deserialize(@NotNull JsonObject json, @NotNull JsonDeserializationContext context) { - String flag = json.getAsJsonPrimitive("flag").getAsString(); - return new FlagLootCondition(manager, flag, selfType); - } - } - } diff --git a/src/main/java/org/violetmoon/zeta/event/play/entity/player/ZPlayerInteract.java b/src/main/java/org/violetmoon/zeta/event/play/entity/player/ZPlayerInteract.java index 743eb08..96402b4 100644 --- a/src/main/java/org/violetmoon/zeta/event/play/entity/player/ZPlayerInteract.java +++ b/src/main/java/org/violetmoon/zeta/event/play/entity/player/ZPlayerInteract.java @@ -16,7 +16,6 @@ public interface ZPlayerInteract extends IZetaPlayEvent, Cancellable { InteractionHand getHand(); BlockPos getPos(); Level getLevel(); - void setCancellationResult(InteractionResult result); interface EntityInteractSpecific extends ZPlayerInteract { Entity getTarget(); diff --git a/src/main/java/org/violetmoon/zeta/mixin/mixins/InvokerSpawnPlacements.java b/src/main/java/org/violetmoon/zeta/mixin/mixins/InvokerSpawnPlacements.java new file mode 100644 index 0000000..eed1db0 --- /dev/null +++ b/src/main/java/org/violetmoon/zeta/mixin/mixins/InvokerSpawnPlacements.java @@ -0,0 +1,18 @@ +package org.violetmoon.zeta.mixin.mixins; + +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.SpawnPlacementType; +import net.minecraft.world.entity.SpawnPlacements; +import net.minecraft.world.level.levelgen.Heightmap; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(SpawnPlacements.class) +public interface InvokerSpawnPlacements { + + @Invoker("register") + static void zeta$register(EntityType entity, SpawnPlacementType type, Heightmap.Types heightMap, SpawnPlacements.SpawnPredicate predicate) { + throw new RuntimeException(); + } +} diff --git a/src/main/java/org/violetmoon/zeta/util/SimpleInventoryBlockEntity.java b/src/main/java/org/violetmoon/zeta/util/SimpleInventoryBlockEntity.java index f953e8d..8ea43d4 100644 --- a/src/main/java/org/violetmoon/zeta/util/SimpleInventoryBlockEntity.java +++ b/src/main/java/org/violetmoon/zeta/util/SimpleInventoryBlockEntity.java @@ -133,6 +133,8 @@ public boolean stillValid(@NotNull Player entityplayer) { return getLevel().getBlockEntity(getBlockPos()) == this && entityplayer.distanceToSqr(worldPosition.getX() + 0.5D, worldPosition.getY() + 0.5D, worldPosition.getZ() + 0.5D) <= 64; } + // TODO: REMOVE? + /* @SuppressWarnings("unchecked") @Override public @NotNull LazyOptional getCapability(@NotNull Capability capability, Direction facing) { @@ -141,6 +143,7 @@ public boolean stillValid(@NotNull Player entityplayer) { return LazyOptional.empty(); } + */ @Override public boolean canPlaceItem(int i, @NotNull ItemStack itemstack) { diff --git a/src/main/java/org/violetmoon/zeta/world/EntitySpawnHandler.java b/src/main/java/org/violetmoon/zeta/world/EntitySpawnHandler.java index 6023c56..0605907 100644 --- a/src/main/java/org/violetmoon/zeta/world/EntitySpawnHandler.java +++ b/src/main/java/org/violetmoon/zeta/world/EntitySpawnHandler.java @@ -10,6 +10,7 @@ import org.violetmoon.zeta.event.bus.LoadEvent; import org.violetmoon.zeta.event.load.ZConfigChanged; import org.violetmoon.zeta.item.ZetaSpawnEggItem; +import org.violetmoon.zeta.mixin.mixins.InvokerSpawnPlacements; import org.violetmoon.zeta.module.ZetaModule; import net.minecraft.core.registries.BuiltInRegistries; @@ -28,8 +29,7 @@ public EntitySpawnHandler(Zeta zeta) { } public void registerSpawn(EntityType entityType, MobCategory classification, SpawnPlacementType placementType, Heightmap.Types heightMapType, SpawnPredicate placementPredicate, EntitySpawnConfig config) { - SpawnPlacements.register(entityType, placementType, heightMapType, placementPredicate); //todo: Access Widener - + InvokerSpawnPlacements.zeta$register(entityType, placementType, heightMapType, placementPredicate); track(entityType, classification, config, false); } diff --git a/src/main/java/org/violetmoon/zetaimplforge/block/IForgeBlockBlockExtensions.java b/src/main/java/org/violetmoon/zetaimplforge/block/IForgeBlockBlockExtensions.java index a592700..b3967fc 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/block/IForgeBlockBlockExtensions.java +++ b/src/main/java/org/violetmoon/zetaimplforge/block/IForgeBlockBlockExtensions.java @@ -96,6 +96,7 @@ public boolean shouldDisplayFluidOverlayZeta(BlockState state, BlockAndTintGette return state.shouldDisplayFluidOverlay(level, pos, fluidState); } + @Override public @Nullable BlockState getToolModifiedStateZeta(BlockState state, UseOnContext context, ItemAbility ability, boolean simulate) { return ability == null ? null : state.getToolModifiedState(context, ability, simulate); diff --git a/src/main/java/org/violetmoon/zetaimplforge/client/event/play/ForgeZScreen.java b/src/main/java/org/violetmoon/zetaimplforge/client/event/play/ForgeZScreen.java index afe6f14..c98996d 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/client/event/play/ForgeZScreen.java +++ b/src/main/java/org/violetmoon/zetaimplforge/client/event/play/ForgeZScreen.java @@ -5,6 +5,7 @@ import net.minecraft.client.gui.screens.Screen; import net.neoforged.neoforge.client.event.ScreenEvent; import org.violetmoon.zeta.client.event.play.ZScreen; +import org.violetmoon.zetaimplforge.mixin.mixins.AccessorEvent; import java.util.List; @@ -122,12 +123,12 @@ public Pre(ScreenEvent.MouseButtonPressed.Pre e) { @Override public boolean isCanceled() { - return e.isCanceled(); + return ((AccessorEvent)e).zeta$isCanceled(); } @Override - public void setCanceled(boolean cancel) { - e.setCanceled(cancel); + public void setCanceled(boolean canceled) { + ((AccessorEvent)e).zeta$setCanceled(canceled); } } @@ -147,18 +148,23 @@ public MouseScrolled(ScreenEvent.MouseScrolled e) { } @Override - public double getScrollDelta() { - return e.getScrollDelta(); + public double getScrollDeltaX() { + return e.getScrollDeltaX(); + } + + @Override + public double getScrollDeltaY() { + return e.getScrollDeltaY(); } @Override public boolean isCanceled() { - return e.isCanceled(); + return ((AccessorEvent)e).zeta$isCanceled(); } @Override public void setCanceled(boolean cancel) { - e.setCanceled(cancel); + ((AccessorEvent)e).zeta$setCanceled(cancel); } public static class Pre extends ForgeZScreen.MouseScrolled implements ZScreen.MouseScrolled.Pre { @@ -199,12 +205,12 @@ public int getModifiers() { @Override public boolean isCanceled() { - return e.isCanceled(); + return ((AccessorEvent)e).zeta$isCanceled(); } @Override public void setCanceled(boolean cancel) { - e.setCanceled(cancel); + ((AccessorEvent)e).zeta$setCanceled(cancel); } public static class Pre extends ForgeZScreen.KeyPressed implements ZScreen.KeyPressed.Pre { @@ -240,12 +246,12 @@ public int getModifiers() { @Override public boolean isCanceled() { - return e.isCanceled(); + return ((AccessorEvent)e).zeta$isCanceled(); } @Override public void setCanceled(boolean cancel) { - e.setCanceled(true); + ((AccessorEvent)e).zeta$setCanceled(cancel); } public static class Pre extends ForgeZScreen.CharacterTyped implements ZScreen.CharacterTyped.Pre { diff --git a/src/main/java/org/violetmoon/zetaimplforge/config/TerribleForgeConfigHackery.java b/src/main/java/org/violetmoon/zetaimplforge/config/TerribleForgeConfigHackery.java index 19dfd57..c649c0a 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/config/TerribleForgeConfigHackery.java +++ b/src/main/java/org/violetmoon/zetaimplforge/config/TerribleForgeConfigHackery.java @@ -1,33 +1,37 @@ package org.violetmoon.zetaimplforge.config; import com.electronwill.nightconfig.core.CommentedConfig; -import com.electronwill.nightconfig.core.ConfigFormat; import com.electronwill.nightconfig.core.file.CommentedFileConfig; import com.electronwill.nightconfig.core.io.WritingMode; import net.neoforged.fml.ModContainer; import net.neoforged.fml.ModLoadingContext; -import net.neoforged.fml.config.ConfigFileTypeHandler; +import net.neoforged.fml.config.ConfigTracker; import net.neoforged.fml.config.ModConfig; import net.neoforged.fml.loading.FMLPaths; import net.neoforged.fml.util.ObfuscationReflectionHelper; import net.neoforged.neoforge.common.ModConfigSpec; +import org.violetmoon.zetaimplforge.mixin.mixins.AccessorConfigTracker; import java.io.Serial; import java.lang.reflect.Method; import java.nio.file.Path; +import java.util.concurrent.locks.ReentrantLock; + +import static org.violetmoon.zetaimplforge.mixin.mixins.AccessorModConfig.zeta$initModConfig; public class TerribleForgeConfigHackery { private static final Method SET_CONFIG_DATA = ObfuscationReflectionHelper.findMethod(ModConfig.class, "setConfigData", CommentedConfig.class); - private static final Method SETUP_CONFIG_FILE = ObfuscationReflectionHelper.findMethod(ConfigFileTypeHandler.class, - "setupConfigFile", ModConfig.class, Path.class, ConfigFormat.class); + private static final Method SETUP_CONFIG_FILE = ObfuscationReflectionHelper.findMethod(ConfigTracker.class, "setupConfigFile", ModConfig.class, Path.class); + // TODO: Replace the name string + not 100% sure about this public static void registerAndLoadConfigEarlierThanUsual(ModConfigSpec spec) { ModContainer container = ModLoadingContext.get().getActiveContainer(); - ModConfig modConfig = new ModConfig(ModConfig.Type.COMMON, spec, container); - container.addConfig(modConfig); + var lock = ((AccessorConfigTracker)ConfigTracker.INSTANCE).zeta$getLocksByMod().computeIfAbsent(container.getModId(), m -> new ReentrantLock()); + ModConfig modConfig = zeta$initModConfig(ModConfig.Type.COMMON, spec, container, "zetaConfig", lock); + container.registerConfig(ModConfig.Type.COMMON, spec); //same stuff that forge config tracker does - ConfigFileTypeHandler handler = modConfig.getHandler(); + ConfigTracker handler = modConfig.getHandler(); //read config without setting file watcher which could cause resets. forge will load it later CommentedFileConfig configData = readConfig(handler, FMLPaths.CONFIGDIR.get(), modConfig); //CommentedFileConfig configData = handler.reader(FMLPaths.CONFIGDIR.get()).apply( modConfig); @@ -35,14 +39,14 @@ public static void registerAndLoadConfigEarlierThanUsual(ModConfigSpec spec) { SET_CONFIG_DATA.setAccessible(true); try { SET_CONFIG_DATA.invoke(modConfig, configData); - }catch (Exception ignored){} + } catch (Exception ignored) {} //container.dispatchConfigEvent(IConfigEvent.loading(this.config)); modConfig.save(); } //we need this so we dont add a second file watcher. Same as handler::reader - private static CommentedFileConfig readConfig(ConfigFileTypeHandler handler, Path configBasePath, ModConfig c) { + private static CommentedFileConfig readConfig(ConfigTracker handler, Path configBasePath, ModConfig c) { Path configPath = configBasePath.resolve(c.getFileName()); CommentedFileConfig configData = CommentedFileConfig.builder(configPath).sync(). preserveInsertionOrder(). diff --git a/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/living/ForgeZLivingChangeTarget.java b/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/living/ForgeZLivingChangeTarget.java index a4869b2..cb57d60 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/living/ForgeZLivingChangeTarget.java +++ b/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/living/ForgeZLivingChangeTarget.java @@ -18,7 +18,7 @@ public LivingEntity getEntity() { @Override public LivingEntity getNewTarget() { - return e.getNewTarget(); + return e.getNewAboutToBeSetTarget(); } @Override diff --git a/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/living/ForgeZLivingConversion.java b/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/living/ForgeZLivingConversion.java index e731879..0494679 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/living/ForgeZLivingConversion.java +++ b/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/living/ForgeZLivingConversion.java @@ -4,6 +4,7 @@ import net.minecraft.world.entity.LivingEntity; import net.neoforged.neoforge.event.entity.living.LivingConversionEvent; import org.violetmoon.zeta.event.play.entity.living.ZLivingConversion; +import org.violetmoon.zetaimplforge.mixin.mixins.AccessorEvent; public class ForgeZLivingConversion implements ZLivingConversion { private final LivingConversionEvent e; @@ -19,12 +20,12 @@ public LivingEntity getEntity() { @Override public boolean isCanceled() { - return e.isCanceled(); + return ((AccessorEvent)e).zeta$isCanceled(); } @Override public void setCanceled(boolean cancel) { - e.setCanceled(cancel); + ((AccessorEvent)e).zeta$setCanceled(cancel); } public static class Pre extends ForgeZLivingConversion implements ZLivingConversion.Pre { diff --git a/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/player/ForgeZPlayerInteract.java b/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/player/ForgeZPlayerInteract.java index e462da0..f291db4 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/player/ForgeZPlayerInteract.java +++ b/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/player/ForgeZPlayerInteract.java @@ -9,6 +9,7 @@ import net.minecraft.world.level.Level; import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent; import org.violetmoon.zeta.event.play.entity.player.ZPlayerInteract; +import org.violetmoon.zetaimplforge.mixin.mixins.AccessorEvent; public class ForgeZPlayerInteract implements ZPlayerInteract { private final PlayerInteractEvent e; @@ -39,18 +40,12 @@ public Level getLevel() { @Override public boolean isCanceled() { - return e.isCanceled(); + return ((AccessorEvent)e).zeta$isCanceled(); } @Override public void setCanceled(boolean cancel) { - e.setCanceled(cancel); - } - - - @Override - public void setCancellationResult(InteractionResult result) { - e.setCancellationResult(result); + ((AccessorEvent)e).zeta$setCanceled(cancel); } public static class EntityInteractSpecific extends ForgeZPlayerInteract implements ZPlayerInteract.EntityInteractSpecific { @@ -65,6 +60,11 @@ public EntityInteractSpecific(PlayerInteractEvent.EntityInteractSpecific e) { public Entity getTarget() { return e.getTarget(); } + + @Override + public void setCancellationResult(InteractionResult result) { + e.setCancellationResult(result); + } } public static class EntityInteract extends ForgeZPlayerInteract implements ZPlayerInteract.EntityInteract { diff --git a/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/player/ForgeZRightClickBlock.java b/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/player/ForgeZRightClickBlock.java index d8be924..ca6cb85 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/player/ForgeZRightClickBlock.java +++ b/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/player/ForgeZRightClickBlock.java @@ -77,7 +77,7 @@ public void setCanceled(boolean cancel) { } @Override - public boolean getResult() { + public InteractionResult getResult() { return e.getCancellationResult(); } diff --git a/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/AccessorConfigTracker.java b/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/AccessorConfigTracker.java new file mode 100644 index 0000000..e9b9c72 --- /dev/null +++ b/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/AccessorConfigTracker.java @@ -0,0 +1,15 @@ +package org.violetmoon.zetaimplforge.mixin.mixins; + +import net.neoforged.fml.config.ConfigTracker; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import java.util.Map; +import java.util.concurrent.locks.ReentrantLock; + +@Mixin(ConfigTracker.class) +public interface AccessorConfigTracker { + + @Accessor("locksByMod") + Map zeta$getLocksByMod(); +} diff --git a/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/AccessorEvent.java b/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/AccessorEvent.java new file mode 100644 index 0000000..17c4ecc --- /dev/null +++ b/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/AccessorEvent.java @@ -0,0 +1,15 @@ +package org.violetmoon.zetaimplforge.mixin.mixins; + +import net.neoforged.bus.api.Event; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(Event.class) +public interface AccessorEvent { + + @Accessor("isCanceled") + boolean zeta$isCanceled(); + + @Accessor("isCanceled") + void zeta$setCanceled(boolean canceled); +} diff --git a/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/AccessorModConfig.java b/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/AccessorModConfig.java new file mode 100644 index 0000000..caafeda --- /dev/null +++ b/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/AccessorModConfig.java @@ -0,0 +1,18 @@ +package org.violetmoon.zetaimplforge.mixin.mixins; + +import net.neoforged.fml.ModContainer; +import net.neoforged.fml.config.IConfigSpec; +import net.neoforged.fml.config.ModConfig; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +import java.util.concurrent.locks.ReentrantLock; + +@Mixin(ModConfig.class) +public interface AccessorModConfig { + + @Invoker("") + static ModConfig zeta$initModConfig(ModConfig.Type type, IConfigSpec spec, ModContainer container, String fileName, ReentrantLock lock) { + throw new AssertionError(); + } +} diff --git a/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/self/IZetaBlockMixin_FAKE.java b/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/self/IZetaBlockMixin_FAKE.java index b453d65..80d9c0b 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/self/IZetaBlockMixin_FAKE.java +++ b/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/self/IZetaBlockMixin_FAKE.java @@ -124,8 +124,7 @@ public boolean shouldDisplayFluidOverlay(BlockState state, BlockAndTintGetter le @Override public @Nullable BlockState getToolModifiedState(BlockState state, UseOnContext context, ItemAbility itemAbility, boolean simulate) { - String toolActionName = itemAbility.name(); - return getToolModifiedStateZeta(state, context, toolActionName, simulate); + return getToolModifiedStateZeta(state, context, itemAbility, simulate); } @Override diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 9ea6033..0e4da36 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -11,4 +11,5 @@ public-f net.minecraft.world.level.storage.loot.LootPool f_79023_ # entries public net.minecraft.world.level.block.Block f_49787_ # descriptionId public net.minecraft.world.item.Item f_41379_ # descriptionId public net.minecraft.advancements.critereon.ContextAwarePredicate f_285559_ # compositePredicates -public net.minecraft.world.item.alchemy.PotionBrewing$Mix # Mix \ No newline at end of file +public net.minecraft.world.item.alchemy.PotionBrewing$Mix # Mix +public-f net.minecraft.world.level.block.grower.TreeGrower # TreeGrower \ No newline at end of file diff --git a/src/main/resources/zeta.mixins.json b/src/main/resources/zeta.mixins.json index 3b3490f..103c589 100644 --- a/src/main/resources/zeta.mixins.json +++ b/src/main/resources/zeta.mixins.json @@ -5,6 +5,7 @@ "refmap": "zeta.mixins.refmap.json", "package": "org.violetmoon.zeta.mixin.mixins", "mixins": [ + "AccessorAdvancement", "AccessorBlock", "AccessorContextAwarePredicate", "AccessorItem", @@ -13,6 +14,7 @@ "AccessorPistonStructureResolver", "InvokerBlockBehavior", "InvokerIItemStackExtension", + "InvokerSpawnPlacements", "PistonBaseBlockMixin", "RegistryDataLoaderMixin", "StructurePieceMixin", diff --git a/src/main/resources/zeta_forge.mixins.json b/src/main/resources/zeta_forge.mixins.json index a02e9f9..e0c6d29 100644 --- a/src/main/resources/zeta_forge.mixins.json +++ b/src/main/resources/zeta_forge.mixins.json @@ -6,9 +6,11 @@ "package": "org.violetmoon.zetaimplforge.mixin.mixins", "plugin": "org.violetmoon.zeta.mixin.plugin.InterfaceDelegateMixinPlugin", "mixins": [ + "AccessorEvent", + "AccessorModConfig", + "AccessorPotionBrewing", "IngredientMixin", "WeatheringCopperMixin", - "AccessorPotionBrewing", "self.IZetaBlockMixin_FAKE", "self.IZetaItemMixin_FAKE" ],