diff --git a/src/main/java/org/violetmoon/quark/content/client/module/WoolShutsUpMinecartsModule.java b/src/main/java/org/violetmoon/quark/content/client/module/WoolShutsUpMinecartsModule.java index a4e5e5af59..0b38bec48e 100644 --- a/src/main/java/org/violetmoon/quark/content/client/module/WoolShutsUpMinecartsModule.java +++ b/src/main/java/org/violetmoon/quark/content/client/module/WoolShutsUpMinecartsModule.java @@ -5,7 +5,7 @@ import net.minecraft.tags.TagKey; import net.minecraft.world.entity.vehicle.AbstractMinecart; import net.minecraft.world.item.Item; - +import net.minecraft.world.phys.AABB; import org.violetmoon.zeta.event.bus.LoadEvent; import org.violetmoon.zeta.event.load.ZConfigChanged; import org.violetmoon.zeta.module.ZetaLoadModule; @@ -26,7 +26,12 @@ public final void configChanged(ZConfigChanged event) { } public static boolean canPlay(AbstractMinecart cart) { - return !staticEnabled || !cart.level().getBlockState(cart.blockPosition().below()).is(BlockTags.DAMPENS_VIBRATIONS); + if (!staticEnabled) + return true; + + AABB bounds = cart.getBoundingBox(); + bounds = bounds.move(0, bounds.minY - bounds.maxY, 0); + return cart.level().getBlockStates(bounds).noneMatch((it) -> it.is(BlockTags.DAMPENS_VIBRATIONS)); } } diff --git a/src/main/java/org/violetmoon/quark/content/experimental/module/GameNerfsModule.java b/src/main/java/org/violetmoon/quark/content/experimental/module/GameNerfsModule.java index 62593796bd..9d00046e92 100644 --- a/src/main/java/org/violetmoon/quark/content/experimental/module/GameNerfsModule.java +++ b/src/main/java/org/violetmoon/quark/content/experimental/module/GameNerfsModule.java @@ -249,6 +249,8 @@ public void onTick(ZLivingTick event) { gossips.remove(GossipType.MINOR_POSITIVE); } + zombie.gossips = manager.store(NbtOps.INSTANCE); + zombie.getPersistentData().putBoolean(TAG_TRADES_ADJUSTED, true); } } diff --git a/src/main/java/org/violetmoon/quark/content/management/module/ItemSharingModule.java b/src/main/java/org/violetmoon/quark/content/management/module/ItemSharingModule.java index a0040bcddf..db66c0bfe1 100755 --- a/src/main/java/org/violetmoon/quark/content/management/module/ItemSharingModule.java +++ b/src/main/java/org/violetmoon/quark/content/management/module/ItemSharingModule.java @@ -49,7 +49,7 @@ public class ItemSharingModule extends ZetaModule { @Config(description = "In ticks.") @Config.Min(0) - private static int cooldown = 5; //TODO: 100 ticks, it's low for testing + private static int cooldown = 100; @Config public static boolean renderItemsInChat = true; diff --git a/src/main/java/org/violetmoon/quark/content/tweaks/module/DoubleDoorOpeningModule.java b/src/main/java/org/violetmoon/quark/content/tweaks/module/DoubleDoorOpeningModule.java index f1fe8b642e..4daf9748a5 100644 --- a/src/main/java/org/violetmoon/quark/content/tweaks/module/DoubleDoorOpeningModule.java +++ b/src/main/java/org/violetmoon/quark/content/tweaks/module/DoubleDoorOpeningModule.java @@ -108,12 +108,8 @@ private boolean tryOpen(Level level, Player player, BlockState state, BlockPos o BlockHitResult res = new BlockHitResult(new Vec3(otherPos.getX() + 0.5, otherPos.getY() + 0.5, otherPos.getZ() + 0.5), direction, otherPos, false); if(res.getType() == HitResult.Type.BLOCK) { - boolean eventRes = Quark.ZETA.fireRightClickBlock(player, InteractionHand.MAIN_HAND, otherPos, res); - - if(!eventRes) { - InteractionResult interaction = other.use(level, player, InteractionHand.MAIN_HAND, res); - return interaction != InteractionResult.PASS; - } + InteractionResult interaction = other.use(level, player, InteractionHand.MAIN_HAND, res); + return interaction != InteractionResult.PASS; } } diff --git a/src/main/java/org/violetmoon/quark/mixin/mixins/client/MinecartSoundInstanceMixin.java b/src/main/java/org/violetmoon/quark/mixin/mixins/client/MinecartSoundInstanceMixin.java index 2f128a1b42..931926358a 100644 --- a/src/main/java/org/violetmoon/quark/mixin/mixins/client/MinecartSoundInstanceMixin.java +++ b/src/main/java/org/violetmoon/quark/mixin/mixins/client/MinecartSoundInstanceMixin.java @@ -1,27 +1,22 @@ package org.violetmoon.quark.mixin.mixins.client; -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import net.minecraft.client.resources.sounds.MinecartSoundInstance; import net.minecraft.world.entity.vehicle.AbstractMinecart; -import org.objectweb.asm.Opcodes; -import org.spongepowered.asm.mixin.Final; +import net.minecraft.world.phys.Vec3; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.violetmoon.quark.content.client.module.WoolShutsUpMinecartsModule; @Mixin(MinecartSoundInstance.class) public class MinecartSoundInstanceMixin { - @Shadow - @Final - private AbstractMinecart minecart; - - @ModifyExpressionValue(method = "tick()V", at = @At(value = "FIELD", target = "Lnet/minecraft/client/resources/sounds/MinecartSoundInstance;volume:F", opcode = Opcodes.PUTFIELD)) - public float muteIfOnWool(float volumeToSet) { - if (volumeToSet > 0 && !WoolShutsUpMinecartsModule.canPlay(minecart)) - return 0; - return volumeToSet; + @WrapOperation(method = "tick()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/vehicle/AbstractMinecart;getDeltaMovement()Lnet/minecraft/world/phys/Vec3;")) + public Vec3 pretendThereIsNoMovementIfMuted(AbstractMinecart minecart, Operation original) { + if (!WoolShutsUpMinecartsModule.canPlay(minecart)) + return Vec3.ZERO; + return original.call(minecart); } } diff --git a/src/main/java/org/violetmoon/zeta/registry/ZetaRegistry.java b/src/main/java/org/violetmoon/zeta/registry/ZetaRegistry.java index 92265e7443..343353fb78 100644 --- a/src/main/java/org/violetmoon/zeta/registry/ZetaRegistry.java +++ b/src/main/java/org/violetmoon/zeta/registry/ZetaRegistry.java @@ -6,9 +6,7 @@ import net.minecraft.core.Holder; import net.minecraft.core.Registry; import net.minecraft.core.WritableRegistry; -import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; -import net.minecraft.resources.RegistryDataLoader; import net.minecraft.resources.RegistryOps; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; @@ -16,7 +14,6 @@ import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import org.jetbrains.annotations.Nullable; -import org.violetmoon.quark.base.Quark; import org.violetmoon.zeta.Zeta; import org.violetmoon.zeta.item.ZetaBlockItem; import org.violetmoon.zeta.util.RegisterDynamicUtil; @@ -92,8 +89,6 @@ public void registerItem(Item item, String resloc) { public void registerBlock(Block block, ResourceLocation id, boolean hasBlockItem) { register(block, id, Registries.BLOCK); - //TODO: this supplier is mostly a load-bearing way to defer calling groups.get(registryName), - // until after CreativeTabHandler.finalizeTabs is called if(hasBlockItem) defers.put(Registries.ITEM.location(), () -> createItemBlock(block)); } @@ -177,7 +172,14 @@ private ResourceKey> erase(ResourceKey> we return (ResourceKey>) (Object) weeeejava; } - //main function - allows accessing the registry, but since it's lazily created, you don't get a Holder containing the object yet... + /** + * Register something to a worldgen registry that requires a `RegistryInfoLookup` to construct. + * You might use this when constructing placed features (which require configuredfeatures), biomes (which require placedfeatures and configuredcarvers), etc. + * + * The returned Holder type is a little odd. + * - We can't return a Holder.Direct, since it's not possible to construct the object yet. + * - We can't return a Holder.Reference, since the registry we're adding the object *to* doesn't even exist yet. + */ public LateBoundHolder registerDynamicF(Function objCreator, ResourceKey id, ResourceKey> registry) { RegisterDynamicUtil.signup(z); @@ -195,7 +197,9 @@ public LateBoundHolder registerDynamicF(Function Holder.Direct registerDynamic(T obj, ResourceKey id, ResourceKey> registry) { RegisterDynamicUtil.signup(z); dynamicDefers.computeIfAbsent(erase(registry), __ -> new ArrayList<>()).add(new DynamicEntry<>(id, __ -> obj, null)); @@ -217,7 +221,7 @@ public void performDynamicRegistration(RegistryOps.RegistryInfoLookup lookup if(entries == null || entries.isEmpty()) return; - Quark.ZETA.log.info("Dynamically registering {} thing{} into {}", entries.size(), entries.size() > 1 ? "s" : "", registryKey.location()); + z.log.info("Dynamically registering {} thing{} into {}", entries.size(), entries.size() > 1 ? "s" : "", registryKey.location()); List> typePun = ((List>) (Object) entries); typePun.forEach(entry -> { diff --git a/zeta-todo/porting-guide.md b/zeta-todo/porting-guide.md new file mode 100644 index 0000000000..1c5967de00 --- /dev/null +++ b/zeta-todo/porting-guide.md @@ -0,0 +1,33 @@ +Thanks for your interest in maintaining a Quark addon into 1.20. Please pardon our dust and let us know if there's something we missed. + +## Repackaging + +The source code has moved under the `org.violetmoon` organization. + +## all this "zeta" stuff? + +Zeta is a platform-agnostic modding platform. We are working on a Forge implementation of Zeta, and we are working on implementing Quark in terms of Zeta in order to achieve our goal of creating a Fabric port of Quark. + +Zeta aims to be a big framework for writing configurable mods. It ships with a config system and config GUI system, and its event bus is designed with configurability in mind (enabling/disabling modules is baked into the "load bus"/"play bus" distinction). Most of the useful stuff that was in AutoRegLib has moved to Zeta, too. + +Zeta is big, but intentionally avoids as much `static` as possible as a way of supporting multiple mods using the library simultaneously. You will not find many singletons in Zeta, and each mod is expected to create and manage their own instances of it. Quark's are under `Quark.ZETA` and `QuarkClient.ZETA_CLIENT`. + +## Constructing Quark's blocks + +Much like in the AutoRegLib days, Zeta leverages constructor registration for its blocks and items. This is now much more closely tied to the Zeta systems, but you can now pass `null` for any registry-name/module parameters, and Zeta just won't try to register them. + +## Dealing with events + +If Quark moves away from Forge, obviously we can't use its event bus. Most of the relevant Forge events have been reimplemented. + +Events fired into Zeta mods are handled with code at the bottom of `ForgeZeta` that temporarily translates them into Zeta's event system. + +If you want to listen to an event fired *from* a Zeta mod, you have two options: + +* Engage with the Zeta event bus. You can find this in `Quark.ZETA.loadBus`/`playBus`. + * The event bus itself is very basic and doesn't require you to write "a Zeta mod". + * Zeta's `@LoadEvent` and `@PlayEvent` are the analogs of Forge's `@SubscribeEvent`. + * Subscribing to the event bus works the same as Forge, where passing a `.class` subscribes static methods, and passing an instance of something subscribes non-static methods. +* Certain events get also fired as platform-specific events. See `ForgeZeta.fireExternalEvent`. + * Usually events corresponding to a "public api" go here. + * Listen to these events using the regular platform-specific event bus system. \ No newline at end of file