From a18cbcd26455f0ffcad5e52c5de885e759f40326 Mon Sep 17 00:00:00 2001 From: Siuolplex Date: Wed, 10 Jul 2024 15:00:26 -0500 Subject: [PATCH] Another day of slogging through the code. College in like 7 weeks Im both shocked and unsurprised at the changes in the 1.21 + Neoforge change. Anyways college is coming up relatively soon, so that fun. Anyways, Ima go do my thing, I got a decent amount of code done. Signed-off-by: Siuolplex --- dependencies.properties | 2 +- src/main/java/org/violetmoon/zeta/Zeta.java | 10 +-- .../zeta/advancement/ManualTrigger.java | 23 +++-- .../zeta/advancement/MutableAdvancement.java | 10 +-- .../violetmoon/zeta/block/ZetaBushBlock.java | 5 ++ .../block/ZetaCeilingHangingSignBlock.java | 2 +- .../violetmoon/zeta/block/ZetaDoorBlock.java | 2 +- .../zeta/block/ZetaSaplingBlock.java | 6 +- .../zeta/block/be/ZetaBlockEntity.java | 10 ++- .../capability/ZetaCapabilityManager.java | 5 +- .../violetmoon/zeta/client/ClientTicker.java | 2 +- .../config/screen/StringListInputScreen.java | 2 +- .../violetmoon/zeta/event/bus/Resultable.java | 2 +- .../violetmoon/zeta/event/play/ZBlock.java | 5 +- .../zeta/event/play/ZRecipeCrawl.java | 53 ++++++------ ...ItemPickup.java => ZItemEntityPickup.java} | 7 +- .../play/entity/living/ZMobSpawnEvent.java | 2 +- .../entity/living/ZSleepingLocationCheck.java | 4 + .../play/loading/ZAttachCapabilities.java | 9 +- .../violetmoon/zeta/item/ZetaArrowItem.java | 8 +- .../zeta/item/ZetaMobBucketItem.java | 2 +- .../violetmoon/zeta/recipe/ZetaDyeRecipe.java | 30 ++++--- .../zeta/registry/DyeablesRegistry.java | 4 +- .../zeta/util/handler/RecipeCrawlHandler.java | 34 ++++---- .../violetmoon/zetaimplforge/ForgeZeta.java | 50 ++++------- .../capability/ForgeCapabilityManager.java | 84 ------------------- .../client/event/play/ForgeZClientTick.java | 17 +--- .../client/event/play/ForgeZRenderTick.java | 5 +- .../zetaimplforge/event/play/ForgeZBlock.java | 9 +- .../play/entity/ForgeZEntityItemPickup.java | 13 +-- .../entity/living/ForgeZMobSpawnEvent.java | 4 +- .../living/ForgeZSleepingLocationCheck.java | 37 -------- .../loading/ForgeZAttachCapabilities.java | 59 ------------- .../mixins/self/IZetaItemMixin_FAKE.java | 1 + .../resources/META-INF/accesstransformer.cfg | 3 +- 35 files changed, 160 insertions(+), 361 deletions(-) rename src/main/java/org/violetmoon/zeta/event/play/entity/{ZEntityItemPickup.java => ZItemEntityPickup.java} (50%) delete mode 100644 src/main/java/org/violetmoon/zetaimplforge/capability/ForgeCapabilityManager.java delete mode 100644 src/main/java/org/violetmoon/zetaimplforge/event/play/entity/living/ForgeZSleepingLocationCheck.java delete mode 100644 src/main/java/org/violetmoon/zetaimplforge/event/play/loading/ForgeZAttachCapabilities.java diff --git a/dependencies.properties b/dependencies.properties index 51976ab..d0c5c8e 100644 --- a/dependencies.properties +++ b/dependencies.properties @@ -1 +1 @@ -neoforge=21.0.10-beta \ No newline at end of file +neoforge=21.0.78-beta \ No newline at end of file diff --git a/src/main/java/org/violetmoon/zeta/Zeta.java b/src/main/java/org/violetmoon/zeta/Zeta.java index 3205ba6..9006e6f 100644 --- a/src/main/java/org/violetmoon/zeta/Zeta.java +++ b/src/main/java/org/violetmoon/zeta/Zeta.java @@ -5,12 +5,12 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.phys.BlockHitResult; import net.neoforged.bus.api.IEventBus; +import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.Nullable; import org.violetmoon.zeta.advancement.AdvancementModifierRegistry; import org.violetmoon.zeta.block.ext.BlockExtensionFactory; -import org.violetmoon.zeta.capability.ZetaCapabilityManager; import org.violetmoon.zeta.config.ConfigManager; import org.violetmoon.zeta.config.IZetaConfigInternals; import org.violetmoon.zeta.config.SectionDefinition; @@ -70,7 +70,7 @@ public Zeta(String modid, Logger log, ZetaSide side) { this.blockExtensions = createBlockExtensionFactory(); this.itemExtensions = createItemExtensionFactory(); - this.capabilityManager = createCapabilityManager(); + //this.capabilityManager = createCapabilityManager(); this.raytracingUtil = createRaytracingUtil(); this.nameChanger = createNameChanger(); @@ -111,7 +111,7 @@ public Zeta(String modid, Logger log, ZetaSide side) { public final VariantRegistry variantRegistry = new VariantRegistry(this); //extensions - public final ZetaCapabilityManager capabilityManager; + //public final ZetaCapabilityManager capabilityManager; public final BlockExtensionFactory blockExtensions; public final ItemExtensionFactory itemExtensions; @@ -182,7 +182,7 @@ public AdvancementModifierRegistry createAdvancementModifierRegistry() { return new AdvancementModifierRegistry(this); } public abstract PottedPlantRegistry createPottedPlantRegistry(); - public abstract ZetaCapabilityManager createCapabilityManager(); + //public abstract ZetaCapabilityManager createCapabilityManager(); public BlockExtensionFactory createBlockExtensionFactory() { return BlockExtensionFactory.DEFAULT; } @@ -204,7 +204,7 @@ public EntitySpawnHandler createEntitySpawnHandler() { public abstract T fireExternalEvent(T impl); // ummmmmm why is this here - public abstract boolean fireRightClickBlock(Player player, InteractionHand hand, BlockPos pos, BlockHitResult bhr); + public abstract PlayerInteractEvent.RightClickBlock fireRightClickBlock(Player player, InteractionHand hand, BlockPos pos, BlockHitResult bhr); // Let's Jump public abstract void start(IEventBus modbus); diff --git a/src/main/java/org/violetmoon/zeta/advancement/ManualTrigger.java b/src/main/java/org/violetmoon/zeta/advancement/ManualTrigger.java index f169883..f6c9d80 100644 --- a/src/main/java/org/violetmoon/zeta/advancement/ManualTrigger.java +++ b/src/main/java/org/violetmoon/zeta/advancement/ManualTrigger.java @@ -1,16 +1,18 @@ package org.violetmoon.zeta.advancement; +import com.mojang.serialization.Codec; import org.jetbrains.annotations.NotNull; import com.google.gson.JsonObject; -import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance; import net.minecraft.advancements.critereon.ContextAwarePredicate; -import net.minecraft.advancements.critereon.DeserializationContext; import net.minecraft.advancements.critereon.SimpleCriterionTrigger; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; +import java.util.Optional; + +//todo: Check if this works public class ManualTrigger extends SimpleCriterionTrigger { final ResourceLocation id; @@ -24,21 +26,18 @@ public void trigger(ServerPlayer player) { } @Override - public ResourceLocation getId() { - return this.id; + public Codec codec() { + return null; } - @Override - protected @NotNull Instance createInstance(@NotNull JsonObject jsonObject, @NotNull ContextAwarePredicate contextAwarePredicate, @NotNull DeserializationContext deserializationContext) { - return new Instance(id, contextAwarePredicate); - } + public static class Instance implements SimpleCriterionTrigger.SimpleInstance { - public static class Instance extends AbstractCriterionTriggerInstance { + public Instance(ResourceLocation id, ContextAwarePredicate contextAwarePredicate) {} - public Instance(ResourceLocation id, ContextAwarePredicate contextAwarePredicate) { - super(id, contextAwarePredicate); + @Override + public Optional player() { + return Optional.empty(); } - } } diff --git a/src/main/java/org/violetmoon/zeta/advancement/MutableAdvancement.java b/src/main/java/org/violetmoon/zeta/advancement/MutableAdvancement.java index d9da821..4e39b82 100644 --- a/src/main/java/org/violetmoon/zeta/advancement/MutableAdvancement.java +++ b/src/main/java/org/violetmoon/zeta/advancement/MutableAdvancement.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Map; +import net.minecraft.advancements.AdvancementRequirements; import org.violetmoon.zeta.api.IMutableAdvancement; import com.google.common.collect.ImmutableMap; @@ -44,18 +45,17 @@ public Criterion getCriterion(String title) { } private void mutabilize() { - this.criteria = Maps.newHashMap(advancement.criteria); + this.criteria = Maps.newHashMap(advancement.criteria()); this.requirements = new ArrayList<>(); - String[][] arr = advancement.requirements; - for(String[] req : arr) { - List reqList = new ArrayList<>(Arrays.asList(req)); + AdvancementRequirements advReq = advancement.requirements(); + for (List reqList : advReq.requirements()) { this.requirements.add(reqList); } } public void commit() { - advancement.criteria() = ImmutableMap.copyOf(criteria); + advancement.criteria = ImmutableMap.copyOf(criteria); //todo: Mixin I believe would fix this List requirementArrays = new ArrayList<>(); for(List list : requirements) { diff --git a/src/main/java/org/violetmoon/zeta/block/ZetaBushBlock.java b/src/main/java/org/violetmoon/zeta/block/ZetaBushBlock.java index 09c2bca..73a3e7f 100644 --- a/src/main/java/org/violetmoon/zeta/block/ZetaBushBlock.java +++ b/src/main/java/org/violetmoon/zeta/block/ZetaBushBlock.java @@ -2,6 +2,7 @@ import java.util.function.BooleanSupplier; +import com.mojang.serialization.MapCodec; import org.jetbrains.annotations.Nullable; import org.violetmoon.zeta.module.ZetaModule; import org.violetmoon.zeta.registry.RenderLayerRegistry; @@ -46,4 +47,8 @@ public ZetaModule getModule() { return module; } + @Override + protected MapCodec codec() { + return null; //Might cause issues but it should be overriden by any children classes. Maybe make this abstract? + } } diff --git a/src/main/java/org/violetmoon/zeta/block/ZetaCeilingHangingSignBlock.java b/src/main/java/org/violetmoon/zeta/block/ZetaCeilingHangingSignBlock.java index 0980efb..76b697e 100644 --- a/src/main/java/org/violetmoon/zeta/block/ZetaCeilingHangingSignBlock.java +++ b/src/main/java/org/violetmoon/zeta/block/ZetaCeilingHangingSignBlock.java @@ -15,7 +15,7 @@ public class ZetaCeilingHangingSignBlock extends CeilingHangingSignBlock impleme private BooleanSupplier enabledSupplier = BooleanSuppliers.TRUE; public ZetaCeilingHangingSignBlock(String regname, @Nullable ZetaModule module, WoodType type, BlockBehaviour.Properties properties) { - super(properties, type); + super(type, properties); this.module = module; if(module == null) //auto registration below this line diff --git a/src/main/java/org/violetmoon/zeta/block/ZetaDoorBlock.java b/src/main/java/org/violetmoon/zeta/block/ZetaDoorBlock.java index 66ddd09..789792a 100644 --- a/src/main/java/org/violetmoon/zeta/block/ZetaDoorBlock.java +++ b/src/main/java/org/violetmoon/zeta/block/ZetaDoorBlock.java @@ -23,7 +23,7 @@ public class ZetaDoorBlock extends DoorBlock implements IZetaBlock, IZetaBlockIt private BooleanSupplier enabledSupplier = BooleanSuppliers.TRUE; public ZetaDoorBlock(BlockSetType setType, String regname, @Nullable ZetaModule module, Properties properties) { - super(properties, setType); + super(setType, properties); this.module = module; if(module == null) //auto registration below this line diff --git a/src/main/java/org/violetmoon/zeta/block/ZetaSaplingBlock.java b/src/main/java/org/violetmoon/zeta/block/ZetaSaplingBlock.java index b887c50..3dc3174 100644 --- a/src/main/java/org/violetmoon/zeta/block/ZetaSaplingBlock.java +++ b/src/main/java/org/violetmoon/zeta/block/ZetaSaplingBlock.java @@ -2,6 +2,7 @@ import java.util.function.BooleanSupplier; +import net.minecraft.world.level.block.grower.TreeGrower; import org.jetbrains.annotations.Nullable; import org.violetmoon.zeta.module.ZetaModule; import org.violetmoon.zeta.registry.RenderLayerRegistry; @@ -11,15 +12,14 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.SaplingBlock; -import net.minecraft.world.level.block.grower.AbstractTreeGrower; public class ZetaSaplingBlock extends SaplingBlock implements IZetaBlock { private final @Nullable ZetaModule module; private BooleanSupplier enabledSupplier = BooleanSuppliers.TRUE; - public ZetaSaplingBlock(String name, @Nullable ZetaModule module, AbstractTreeGrower tree) { - super(tree, Block.Properties.copy(Blocks.OAK_SAPLING)); + public ZetaSaplingBlock(String name, @Nullable ZetaModule module, TreeGrower tree) { + super(tree, Block.Properties.ofFullCopy(Blocks.OAK_SAPLING)); this.module = module; if(module == null) //auto registration below this line diff --git a/src/main/java/org/violetmoon/zeta/block/be/ZetaBlockEntity.java b/src/main/java/org/violetmoon/zeta/block/be/ZetaBlockEntity.java index 7bacea6..5700b8a 100644 --- a/src/main/java/org/violetmoon/zeta/block/be/ZetaBlockEntity.java +++ b/src/main/java/org/violetmoon/zeta/block/be/ZetaBlockEntity.java @@ -11,6 +11,8 @@ package org.violetmoon.zeta.block.be; import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.Connection; import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; @@ -26,15 +28,15 @@ public ZetaBlockEntity(BlockEntityType tileEntityTypeIn, BlockPos pos, BlockS } @Override - protected void saveAdditional(CompoundTag nbt) { - super.saveAdditional(nbt); + protected void saveAdditional(CompoundTag nbt, HolderLookup.Provider provider) { + super.saveAdditional(nbt, provider); writeSharedNBT(nbt); } @Override - public void load(CompoundTag nbt) { - super.load(nbt); + public void loadWithComponents(CompoundTag nbt, HolderLookup.Provider provider) { + super.loadWithComponents(nbt, provider); readSharedNBT(nbt); } diff --git a/src/main/java/org/violetmoon/zeta/capability/ZetaCapabilityManager.java b/src/main/java/org/violetmoon/zeta/capability/ZetaCapabilityManager.java index 7ae00dd..b6bc5ee 100644 --- a/src/main/java/org/violetmoon/zeta/capability/ZetaCapabilityManager.java +++ b/src/main/java/org/violetmoon/zeta/capability/ZetaCapabilityManager.java @@ -7,12 +7,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; +@Deprecated(forRemoval = true) public interface ZetaCapabilityManager { /** * Register a capability with the ZetaCapabilityManager. * Left side is the ZetaCapability token, right side is the platform-specific object used to back this capability. */ - ZetaCapabilityManager register(ZetaCapability cap, Object backing); + /*ZetaCapabilityManager register(ZetaCapability cap, Object backing); boolean hasCapability(ZetaCapability cap, ItemStack stack); @Nullable T getCapability(ZetaCapability cap, ItemStack stack); @@ -26,5 +27,5 @@ public interface ZetaCapabilityManager { //On Forge, 'target' is AttachCapabilitiesEvent. Yeah this is kinda janky and stupid. // Not sure what this looks like on Fabric. // TODO: give this a rethink. - void attachCapability(Object target, ResourceLocation id, ZetaCapability cap, T impl); + void attachCapability(Object target, ResourceLocation id, ZetaCapability cap, T impl);*/ } diff --git a/src/main/java/org/violetmoon/zeta/client/ClientTicker.java b/src/main/java/org/violetmoon/zeta/client/ClientTicker.java index cb28ee2..95e9201 100644 --- a/src/main/java/org/violetmoon/zeta/client/ClientTicker.java +++ b/src/main/java/org/violetmoon/zeta/client/ClientTicker.java @@ -24,7 +24,7 @@ public void onRenderTick(ZRenderTick event) { @PlayEvent public void onEndClientTick(ZClientTick event) { - if(event.getPhase() != ZPhase.END) + if(event. != ZPhase.END) return; Screen gui = Minecraft.getInstance().screen; diff --git a/src/main/java/org/violetmoon/zeta/client/config/screen/StringListInputScreen.java b/src/main/java/org/violetmoon/zeta/client/config/screen/StringListInputScreen.java index 6e34f10..2dbb7ea 100644 --- a/src/main/java/org/violetmoon/zeta/client/config/screen/StringListInputScreen.java +++ b/src/main/java/org/violetmoon/zeta/client/config/screen/StringListInputScreen.java @@ -113,7 +113,7 @@ public Entry(int index) { EditBox field = new EditBox(mc.font, 10, 3, 210, 20, Component.literal("")); field.setMaxLength(256); field.setValue(here); - field.moveCursorTo(0); + field.moveCursorTo(0, false); field.setResponder(str -> setString(index, str)); addScrollingWidget(field); diff --git a/src/main/java/org/violetmoon/zeta/event/bus/Resultable.java b/src/main/java/org/violetmoon/zeta/event/bus/Resultable.java index 12f16f5..8c258a9 100644 --- a/src/main/java/org/violetmoon/zeta/event/bus/Resultable.java +++ b/src/main/java/org/violetmoon/zeta/event/bus/Resultable.java @@ -1,6 +1,6 @@ package org.violetmoon.zeta.event.bus; public interface Resultable { - ZResult getResult(); + boolean getResult(); void setResult(ZResult value); } diff --git a/src/main/java/org/violetmoon/zeta/event/play/ZBlock.java b/src/main/java/org/violetmoon/zeta/event/play/ZBlock.java index deeab73..0b66446 100644 --- a/src/main/java/org/violetmoon/zeta/event/play/ZBlock.java +++ b/src/main/java/org/violetmoon/zeta/event/play/ZBlock.java @@ -4,7 +4,6 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.state.BlockState; -import net.neoforged.neoforge.common.ToolAction; import org.jetbrains.annotations.Nullable; import org.violetmoon.zeta.event.bus.IZetaPlayEvent; @@ -21,8 +20,8 @@ interface EntityPlace extends ZBlock { BlockState getPlacedBlock(); } - interface BlockToolModification extends ZBlock { + /*interface BlockToolModification extends ZBlock { ToolAction getToolAction(); void setFinalState(@Nullable BlockState finalState); - } + }*/ } diff --git a/src/main/java/org/violetmoon/zeta/event/play/ZRecipeCrawl.java b/src/main/java/org/violetmoon/zeta/event/play/ZRecipeCrawl.java index 8d57156..a5d0abe 100644 --- a/src/main/java/org/violetmoon/zeta/event/play/ZRecipeCrawl.java +++ b/src/main/java/org/violetmoon/zeta/event/play/ZRecipeCrawl.java @@ -9,6 +9,7 @@ import com.google.common.collect.Sets; import com.google.common.collect.Streams; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.item.crafting.*; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; import org.violetmoon.zeta.event.bus.IZetaPlayEvent; @@ -20,12 +21,6 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.AbstractCookingRecipe; -import net.minecraft.world.item.crafting.CustomRecipe; -import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.Recipe; -import net.minecraft.world.item.crafting.ShapedRecipe; -import net.minecraft.world.item.crafting.ShapelessRecipe; import org.violetmoon.zeta.util.RegistryUtil; public abstract class ZRecipeCrawl implements IZetaPlayEvent { @@ -33,56 +28,58 @@ public abstract class ZRecipeCrawl implements IZetaPlayEvent { public static class Reset extends ZRecipeCrawl { } public static class Starting extends ZRecipeCrawl { } - public static abstract class Visit> extends ZRecipeCrawl { + public static abstract class Visit> extends ZRecipeCrawl { - public final T recipe; + public final RecipeHolder recipeHolder; + public final Recipe recipe; public final ResourceLocation recipeID; public final ItemStack output; public final NonNullList ingredients; - public Visit(T recipe, RegistryAccess access) { - this.recipe = recipe; - this.recipeID = recipe.getId(); //todo: Get ID another way - this.output = recipe.getResultItem(access); - this.ingredients = recipe.getIngredients(); + public Visit(RecipeHolder recipeHolder, RegistryAccess access) { + this.recipeHolder = recipeHolder; + this.recipe = recipeHolder.value(); + this.recipeID = recipeHolder.id(); + this.output = recipeHolder.value().getResultItem(access); + this.ingredients = recipeHolder.value().getIngredients(); } - public static class Shaped extends Visit { + public static class Shaped extends Visit> { - public Shaped(ShapedRecipe recipe, RegistryAccess access) { - super(recipe, access); + public Shaped(RecipeHolder recipeHolder, RegistryAccess access) { + super(recipeHolder, access); } } - public static class Shapeless extends Visit { + public static class Shapeless extends Visit> { - public Shapeless(ShapelessRecipe recipe, RegistryAccess access) { - super(recipe, access); + public Shapeless(RecipeHolder recipeHolder, RegistryAccess access) { + super(recipeHolder, access); } } - public static class Custom extends Visit { + public static class Custom extends Visit> { - public Custom(CustomRecipe recipe, RegistryAccess access) { - super(recipe, access); + public Custom(RecipeHolder recipeHolder, RegistryAccess access) { + super(recipeHolder, access); } } - public static class Cooking extends Visit { + public static class Cooking extends Visit> { - public Cooking(AbstractCookingRecipe recipe, RegistryAccess access) { - super(recipe, access); + public Cooking(RecipeHolder recipeHolder, RegistryAccess access) { + super(recipeHolder, access); } } - public static class Misc extends Visit> { + public static class Misc extends Visit>> { - public Misc(Recipe recipe, RegistryAccess access) { - super(recipe, access); + public Misc(RecipeHolder> recipeHolder, RegistryAccess access) { + super(recipeHolder, access); } } diff --git a/src/main/java/org/violetmoon/zeta/event/play/entity/ZEntityItemPickup.java b/src/main/java/org/violetmoon/zeta/event/play/entity/ZItemEntityPickup.java similarity index 50% rename from src/main/java/org/violetmoon/zeta/event/play/entity/ZEntityItemPickup.java rename to src/main/java/org/violetmoon/zeta/event/play/entity/ZItemEntityPickup.java index cfe6f70..02b3214 100644 --- a/src/main/java/org/violetmoon/zeta/event/play/entity/ZEntityItemPickup.java +++ b/src/main/java/org/violetmoon/zeta/event/play/entity/ZItemEntityPickup.java @@ -5,6 +5,11 @@ import net.minecraft.world.entity.item.ItemEntity; -public interface ZEntityItemPickup extends IZetaPlayEvent, PlayerGetter { +/** + * Event for when specifically a PLAYER picks up an Item. + * Other mobs who pick up items (Zombies, Skeletons, etc.) are not seemingly detected by this event. + * Sorry... + */ +public interface ZItemEntityPickup extends IZetaPlayEvent, PlayerGetter { ItemEntity getItem(); } diff --git a/src/main/java/org/violetmoon/zeta/event/play/entity/living/ZMobSpawnEvent.java b/src/main/java/org/violetmoon/zeta/event/play/entity/living/ZMobSpawnEvent.java index 0f3435c..0991066 100644 --- a/src/main/java/org/violetmoon/zeta/event/play/entity/living/ZMobSpawnEvent.java +++ b/src/main/java/org/violetmoon/zeta/event/play/entity/living/ZMobSpawnEvent.java @@ -8,7 +8,7 @@ import net.minecraft.world.level.BaseSpawner; import net.minecraft.world.level.ServerLevelAccessor; -public interface ZMobSpawnEvent extends IZetaPlayEvent, Resultable { +public interface ZMobSpawnEvent extends IZetaPlayEvent /*, Resultable*/ { Mob getEntity(); ServerLevelAccessor getLevel(); double getX(); diff --git a/src/main/java/org/violetmoon/zeta/event/play/entity/living/ZSleepingLocationCheck.java b/src/main/java/org/violetmoon/zeta/event/play/entity/living/ZSleepingLocationCheck.java index 4d9a6ef..56c79dd 100644 --- a/src/main/java/org/violetmoon/zeta/event/play/entity/living/ZSleepingLocationCheck.java +++ b/src/main/java/org/violetmoon/zeta/event/play/entity/living/ZSleepingLocationCheck.java @@ -1,11 +1,15 @@ package org.violetmoon.zeta.event.play.entity.living; +import net.minecraft.world.entity.ai.behavior.SleepInBed; import org.violetmoon.zeta.event.bus.IZetaPlayEvent; import org.violetmoon.zeta.event.bus.Resultable; import org.violetmoon.zeta.event.bus.helpers.LivingGetter; import net.minecraft.core.BlockPos; +@Deprecated +//todo: Deprecated for now, corresponding NeoForge event seems to no longer exist public interface ZSleepingLocationCheck extends IZetaPlayEvent, LivingGetter, Resultable { BlockPos getSleepingLocation(); + } diff --git a/src/main/java/org/violetmoon/zeta/event/play/loading/ZAttachCapabilities.java b/src/main/java/org/violetmoon/zeta/event/play/loading/ZAttachCapabilities.java index 4f4f278..50de962 100644 --- a/src/main/java/org/violetmoon/zeta/event/play/loading/ZAttachCapabilities.java +++ b/src/main/java/org/violetmoon/zeta/event/play/loading/ZAttachCapabilities.java @@ -6,12 +6,13 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.neoforged.neoforge.capabilities.ICapabilityProvider; import org.violetmoon.zeta.capability.ZetaCapability; -import org.violetmoon.zeta.capability.ZetaCapabilityManager; import org.violetmoon.zeta.event.bus.IZetaPlayEvent; +//todo: Capabilities are no more, only reason why this is deprecated vs removed is to double check if we need a replacement +@Deprecated(forRemoval = true) public interface ZAttachCapabilities extends IZetaPlayEvent { - ZetaCapabilityManager getCapabilityManager(); - T getObject(); + //ZetaCapabilityManager getCapabilityManager(); + /* getObject(); void addCapability(ResourceLocation key, ZetaCapability cap, C impl); @@ -20,5 +21,5 @@ interface BlockEntityCaps extends ZAttachCapabilities { } interface LevelCaps extends ZAttachCapabilities { } @Deprecated //Forge only API, we should migrate off ICapabilityProvider. - void addCapabilityForgeApi(ResourceLocation key, ICapabilityProvider cap); + void addCapabilityForgeApi(ResourceLocation key, ICapabilityProvider cap);*/ } diff --git a/src/main/java/org/violetmoon/zeta/item/ZetaArrowItem.java b/src/main/java/org/violetmoon/zeta/item/ZetaArrowItem.java index 2c22262..124a85e 100644 --- a/src/main/java/org/violetmoon/zeta/item/ZetaArrowItem.java +++ b/src/main/java/org/violetmoon/zeta/item/ZetaArrowItem.java @@ -59,12 +59,12 @@ public Impl(String name, ZetaModule module, ArrowCreator creator) { } @Override - public AbstractArrow createArrow(Level p_40513_, ItemStack p_40514_, LivingEntity p_40515_) { - return creator.createArrow(p_40513_, p_40514_, p_40515_); + public AbstractArrow createArrow(Level level, ItemStack arrowStack, LivingEntity entity, @javax.annotation.Nullable ItemStack weaponStack) { + return creator.createArrow(level, arrowStack, entity, weaponStack); } - public static interface ArrowCreator { - public AbstractArrow createArrow(Level level, ItemStack stack, LivingEntity living); + public interface ArrowCreator { + AbstractArrow createArrow(Level level, ItemStack stack, LivingEntity living, @javax.annotation.Nullable ItemStack weaponStack); } } diff --git a/src/main/java/org/violetmoon/zeta/item/ZetaMobBucketItem.java b/src/main/java/org/violetmoon/zeta/item/ZetaMobBucketItem.java index 410a868..82f1673 100644 --- a/src/main/java/org/violetmoon/zeta/item/ZetaMobBucketItem.java +++ b/src/main/java/org/violetmoon/zeta/item/ZetaMobBucketItem.java @@ -21,7 +21,7 @@ public class ZetaMobBucketItem extends MobBucketItem implements IZetaItem { private BooleanSupplier enabledSupplier = BooleanSuppliers.TRUE; - public ZetaMobBucketItem(Supplier> entity, Supplier fluid, Supplier sound, String name, @Nullable ZetaModule module) { + public ZetaMobBucketItem(EntityType entity, Fluid fluid, SoundEvent sound, String name, @Nullable ZetaModule module) { super(entity, fluid, sound, (new Properties()).stacksTo(1)); this.module = module; diff --git a/src/main/java/org/violetmoon/zeta/recipe/ZetaDyeRecipe.java b/src/main/java/org/violetmoon/zeta/recipe/ZetaDyeRecipe.java index 3b38ab2..1c39b64 100644 --- a/src/main/java/org/violetmoon/zeta/recipe/ZetaDyeRecipe.java +++ b/src/main/java/org/violetmoon/zeta/recipe/ZetaDyeRecipe.java @@ -3,6 +3,8 @@ import java.util.List; import java.util.function.Supplier; +import net.minecraft.core.HolderLookup; +import net.minecraft.world.item.crafting.*; import org.violetmoon.zeta.registry.DyeablesRegistry; import com.google.common.collect.Lists; @@ -13,10 +15,6 @@ import net.minecraft.world.item.DyeItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.CraftingBookCategory; -import net.minecraft.world.item.crafting.CustomRecipe; -import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraft.world.item.crafting.SimpleCraftingRecipeSerializer; import net.minecraft.world.level.Level; // copy of ArmorDyeRecipe @@ -24,29 +22,29 @@ public class ZetaDyeRecipe extends CustomRecipe { protected final DyeablesRegistry dyeablesRegistry; protected final RecipeSerializer serializer; - public ZetaDyeRecipe(ResourceLocation id, CraftingBookCategory cat, DyeablesRegistry dyeablesRegistry) { + public ZetaDyeRecipe(CraftingBookCategory cat, DyeablesRegistry dyeablesRegistry) { super(cat); this.dyeablesRegistry = dyeablesRegistry; // We need to plug the serializer into itself, so that when a fresh copy of this ZetaDyeRecipe is constructed // it will have the exact same serializer instance already registered in the recipe serializer registry. // Yeah, it's weird i know. Don't try this at home, it's like searching Google into Google. // Btw, the serializer can't be made `static` because constructing this recipe type requires a DyeablesRegistry. - this.serializer = new SimpleCraftingRecipeSerializer<>((id_, cat_) -> new ZetaDyeRecipe(id_, cat_, dyeablesRegistry, this::getSerializer)); + this.serializer = new SimpleCraftingRecipeSerializer<>((cat_) -> new ZetaDyeRecipe(cat_, dyeablesRegistry, this::getSerializer)); } - protected ZetaDyeRecipe(ResourceLocation id, CraftingBookCategory cat, DyeablesRegistry dyeablesRegistry, Supplier> loopCloser) { - super(id, cat); + protected ZetaDyeRecipe(CraftingBookCategory cat, DyeablesRegistry dyeablesRegistry, Supplier> loopCloser) { + super(cat); this.dyeablesRegistry = dyeablesRegistry; this.serializer = loopCloser.get(); } @Override - public boolean matches(CraftingContainer p_43769_, Level p_43770_) { + public boolean matches(CraftingInput craftingInput, Level level) { ItemStack itemstack = ItemStack.EMPTY; List list = Lists.newArrayList(); - for(int i = 0; i < p_43769_.getContainerSize(); ++i) { - ItemStack itemstack1 = p_43769_.getItem(i); + for(int i = 0; i < craftingInput.size(); ++i) { + ItemStack itemstack1 = craftingInput.getItem(i); if (!itemstack1.isEmpty()) { if (dyeablesRegistry.isDyeable(itemstack1)) { // <- changed if (!itemstack.isEmpty()) { @@ -68,12 +66,12 @@ public boolean matches(CraftingContainer p_43769_, Level p_43770_) { } @Override - public ItemStack assemble(CraftingContainer p_43767_, RegistryAccess pissing) { + public ItemStack assemble(CraftingInput input, HolderLookup.Provider pissing) { List list = Lists.newArrayList(); ItemStack itemstack = ItemStack.EMPTY; - for(int i = 0; i < p_43767_.getContainerSize(); ++i) { - ItemStack itemstack1 = p_43767_.getItem(i); + for(int i = 0; i < input.size(); ++i) { + ItemStack itemstack1 = input.getItem(i); if (!itemstack1.isEmpty()) { Item item = itemstack1.getItem(); if (dyeablesRegistry.isDyeable(itemstack1)) { // <- changed @@ -93,8 +91,8 @@ public ItemStack assemble(CraftingContainer p_43767_, RegistryAccess pissing) { } return !itemstack.isEmpty() && !list.isEmpty() ? - dyeablesRegistry.dyeItem(itemstack, list) : // <- changed - ItemStack.EMPTY; + dyeablesRegistry.dyeItem(itemstack, list) : // <- changed + ItemStack.EMPTY; } @Override diff --git a/src/main/java/org/violetmoon/zeta/registry/DyeablesRegistry.java b/src/main/java/org/violetmoon/zeta/registry/DyeablesRegistry.java index 90fef3c..a039475 100644 --- a/src/main/java/org/violetmoon/zeta/registry/DyeablesRegistry.java +++ b/src/main/java/org/violetmoon/zeta/registry/DyeablesRegistry.java @@ -39,7 +39,7 @@ public class DyeablesRegistry { @LoadEvent public void register(ZRegister event) { ResourceLocation id = event.getRegistry().newResourceLocation("dye_item"); - ZetaDyeRecipe recipe = new ZetaDyeRecipe(id, CraftingBookCategory.EQUIPMENT, this); + ZetaDyeRecipe recipe = new ZetaDyeRecipe(CraftingBookCategory.EQUIPMENT, this); event.getRegistry().register(recipe.getSerializer(), id, Registries.RECIPE_SERIALIZER); } @@ -47,7 +47,7 @@ public void register(ZRegister event) { public void registerPost(ZRegister.Post event) { WashingInteraction wosh = new WashingInteraction(); for(Item item : dyeableConditions.keySet()) - CauldronInteraction.WATER.put(item, wosh); + CauldronInteraction.WATER.map().put(item, wosh); } class WashingInteraction implements CauldronInteraction { diff --git a/src/main/java/org/violetmoon/zeta/util/handler/RecipeCrawlHandler.java b/src/main/java/org/violetmoon/zeta/util/handler/RecipeCrawlHandler.java index ff0784e..1599a77 100644 --- a/src/main/java/org/violetmoon/zeta/util/handler/RecipeCrawlHandler.java +++ b/src/main/java/org/violetmoon/zeta/util/handler/RecipeCrawlHandler.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.function.Consumer; +import net.minecraft.world.item.crafting.*; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; import org.violetmoon.zeta.Zeta; @@ -27,13 +28,6 @@ import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.AbstractCookingRecipe; -import net.minecraft.world.item.crafting.CustomRecipe; -import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.Recipe; -import net.minecraft.world.item.crafting.RecipeManager; -import net.minecraft.world.item.crafting.ShapedRecipe; -import net.minecraft.world.item.crafting.ShapelessRecipe; @ApiStatus.Internal public class RecipeCrawlHandler { @@ -87,8 +81,10 @@ private static void load(RecipeManager manager, RegistryAccess access) { vanillaRecipeDigestion.clear(); backwardsVanillaDigestion.clear(); - for (Recipe recipe : manager.getRecipes()) { + //todo: Chat verify this works, and then clean it up + for (RecipeHolder recipeHolder : manager.getRecipes()) { try { + Recipe recipe = recipeHolder.value(); if (recipe == null) throw new IllegalStateException("Recipe is null"); if (recipe.getIngredients() == null) @@ -97,16 +93,16 @@ private static void load(RecipeManager manager, RegistryAccess access) { throw new IllegalStateException("Recipe getResultItem is null"); ZRecipeCrawl.Visit event; - if (recipe instanceof ShapedRecipe sr) - event = new ZRecipeCrawl.Visit.Shaped(sr, access); - else if (recipe instanceof ShapelessRecipe sr) - event = new ZRecipeCrawl.Visit.Shapeless(sr, access); - else if (recipe instanceof CustomRecipe cr) - event = new ZRecipeCrawl.Visit.Custom(cr, access); - else if (recipe instanceof AbstractCookingRecipe acr) - event = new ZRecipeCrawl.Visit.Cooking(acr, access); + if (recipe instanceof ShapedRecipe) + event = new ZRecipeCrawl.Visit.Shaped((RecipeHolder) recipeHolder, access); + else if (recipe instanceof ShapelessRecipe) + event = new ZRecipeCrawl.Visit.Shapeless((RecipeHolder) recipeHolder, access); + else if (recipe instanceof CustomRecipe) + event = new ZRecipeCrawl.Visit.Custom((RecipeHolder) recipeHolder, access); + else if (recipe instanceof AbstractCookingRecipe) + event = new ZRecipeCrawl.Visit.Cooking((RecipeHolder) recipeHolder, access); else - event = new ZRecipeCrawl.Visit.Misc(recipe, access); + event = new ZRecipeCrawl.Visit.Misc((RecipeHolder>) recipeHolder, access); //misc recipes could have custom logic that we cant make many assumptions on. For example FD cutting board recipes are lossy. //for instance a hanging sign can be cut into a plank. A hanging sign is magnetic but this does not mean planks are @@ -115,10 +111,10 @@ else if (recipe instanceof AbstractCookingRecipe acr) } fire(event); } catch (Exception e) { - if (recipe == null) + if (recipeHolder == null) Zeta.GLOBAL_LOG.error("Encountered null recipe in RecipeManager.getRecipes. This is not good"); else - Zeta.GLOBAL_LOG.error("Failed to scan recipe " + recipe.getId() + ". This should be reported to " + recipe.getId().getNamespace() + "!", e); + Zeta.GLOBAL_LOG.error("Failed to scan recipe " + recipeHolder.id() + ". This should be reported to " + recipeHolder.id().getNamespace() + "!", e); } } } diff --git a/src/main/java/org/violetmoon/zetaimplforge/ForgeZeta.java b/src/main/java/org/violetmoon/zetaimplforge/ForgeZeta.java index b4b88bc..1b419c7 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/ForgeZeta.java +++ b/src/main/java/org/violetmoon/zetaimplforge/ForgeZeta.java @@ -3,11 +3,8 @@ import net.minecraft.core.BlockPos; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.FlowerPotBlock; -import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.phys.BlockHitResult; import net.neoforged.bus.api.EventPriority; import net.neoforged.bus.api.IEventBus; @@ -34,12 +31,7 @@ import net.neoforged.neoforge.event.entity.living.LivingDropsEvent; import net.neoforged.neoforge.event.entity.living.LivingFallEvent; import net.neoforged.neoforge.event.entity.living.MobSpawnEvent; -import net.neoforged.neoforge.event.entity.player.AnvilRepairEvent; -import net.neoforged.neoforge.event.entity.player.BonemealEvent; -import net.neoforged.neoforge.event.entity.player.ItemTooltipEvent; -import net.neoforged.neoforge.event.entity.player.PlayerDestroyItemEvent; -import net.neoforged.neoforge.event.entity.player.PlayerEvent; -import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent; +import net.neoforged.neoforge.event.entity.player.*; import net.neoforged.neoforge.event.furnace.FurnaceFuelBurnTimeEvent; import net.neoforged.neoforge.event.level.BlockEvent; import net.neoforged.neoforge.event.level.NoteBlockEvent; @@ -50,7 +42,6 @@ import org.jetbrains.annotations.Nullable; import org.violetmoon.zeta.Zeta; import org.violetmoon.zeta.block.ext.BlockExtensionFactory; -import org.violetmoon.zeta.capability.ZetaCapabilityManager; import org.violetmoon.zeta.config.IZetaConfigInternals; import org.violetmoon.zeta.config.SectionDefinition; import org.violetmoon.zeta.event.bus.ZResult; @@ -72,27 +63,17 @@ import org.violetmoon.zeta.event.play.ZServerTick; import org.violetmoon.zeta.event.play.entity.ZEntityConstruct; import org.violetmoon.zeta.event.play.entity.ZEntityInteract; -import org.violetmoon.zeta.event.play.entity.ZEntityItemPickup; +import org.violetmoon.zeta.event.play.entity.ZItemEntityPickup; import org.violetmoon.zeta.event.play.entity.ZEntityJoinLevel; import org.violetmoon.zeta.event.play.entity.ZEntityMobGriefing; import org.violetmoon.zeta.event.play.entity.ZEntityTeleport; -import org.violetmoon.zeta.event.play.entity.living.ZAnimalTame; -import org.violetmoon.zeta.event.play.entity.living.ZBabyEntitySpawn; -import org.violetmoon.zeta.event.play.entity.living.ZLivingChangeTarget; -import org.violetmoon.zeta.event.play.entity.living.ZLivingConversion; -import org.violetmoon.zeta.event.play.entity.living.ZLivingDeath; -import org.violetmoon.zeta.event.play.entity.living.ZLivingDrops; -import org.violetmoon.zeta.event.play.entity.living.ZLivingFall; -import org.violetmoon.zeta.event.play.entity.living.ZLivingTick; -import org.violetmoon.zeta.event.play.entity.living.ZMobSpawnEvent; -import org.violetmoon.zeta.event.play.entity.living.ZSleepingLocationCheck; +import org.violetmoon.zeta.event.play.entity.living.*; import org.violetmoon.zeta.event.play.entity.player.ZPlayer; import org.violetmoon.zeta.event.play.entity.player.ZPlayerDestroyItem; import org.violetmoon.zeta.event.play.entity.player.ZPlayerInteract; import org.violetmoon.zeta.event.play.entity.player.ZPlayerTick; import org.violetmoon.zeta.event.play.entity.player.ZRightClickBlock; import org.violetmoon.zeta.event.play.entity.player.ZRightClickItem; -import org.violetmoon.zeta.event.play.loading.ZAttachCapabilities; import org.violetmoon.zeta.event.play.loading.ZLootTableLoad; import org.violetmoon.zeta.event.play.loading.ZVillagerTrades; import org.violetmoon.zeta.event.play.loading.ZWandererTrades; @@ -107,7 +88,6 @@ import org.violetmoon.zeta.util.ZetaSide; import org.violetmoon.zetaimplforge.api.GatherAdvancementModifiersEvent; import org.violetmoon.zetaimplforge.block.IForgeBlockBlockExtensions; -import org.violetmoon.zetaimplforge.capability.ForgeCapabilityManager; import org.violetmoon.zetaimplforge.config.ConfigEventDispatcher; import org.violetmoon.zetaimplforge.config.ForgeBackedConfig; import org.violetmoon.zetaimplforge.config.TerribleForgeConfigHackery; @@ -139,14 +119,12 @@ import org.violetmoon.zetaimplforge.event.play.entity.living.ForgeZLivingFall; import org.violetmoon.zetaimplforge.event.play.entity.living.ForgeZLivingTick; import org.violetmoon.zetaimplforge.event.play.entity.living.ForgeZMobSpawnEvent; -import org.violetmoon.zetaimplforge.event.play.entity.living.ForgeZSleepingLocationCheck; import org.violetmoon.zetaimplforge.event.play.entity.player.ForgeZPlayer; import org.violetmoon.zetaimplforge.event.play.entity.player.ForgeZPlayerDestroyItem; import org.violetmoon.zetaimplforge.event.play.entity.player.ForgeZPlayerInteract; import org.violetmoon.zetaimplforge.event.play.entity.player.ForgeZPlayerTick; import org.violetmoon.zetaimplforge.event.play.entity.player.ForgeZRightClickBlock; import org.violetmoon.zetaimplforge.event.play.entity.player.ForgeZRightClickItem; -import org.violetmoon.zetaimplforge.event.play.loading.ForgeZAttachCapabilities; import org.violetmoon.zetaimplforge.event.play.loading.ForgeZLootTableLoad; import org.violetmoon.zetaimplforge.event.play.loading.ForgeZVillagerTrades; import org.violetmoon.zetaimplforge.event.play.loading.ForgeZWandererTrades; @@ -208,10 +186,10 @@ public PottedPlantRegistry createPottedPlantRegistry() { return (resloc, potted) -> ((FlowerPotBlock)Blocks.FLOWER_POT).addPlant(resloc, () -> potted); } - @Override + /*@Override public ZetaCapabilityManager createCapabilityManager() { return new ForgeCapabilityManager(); - } + }*/ @Override public BlockExtensionFactory createBlockExtensionFactory() { @@ -234,7 +212,7 @@ public ZetaNetworkHandler createNetworkHandler(int protocolVersion) { } @Override - public boolean fireRightClickBlock(Player player, InteractionHand hand, BlockPos pos, BlockHitResult bhr) { + public PlayerInteractEvent.RightClickBlock fireRightClickBlock(Player player, InteractionHand hand, BlockPos pos, BlockHitResult bhr) { return NeoForge.EVENT_BUS.post(new PlayerInteractEvent.RightClickBlock(player, hand, pos, bhr)); } @@ -289,9 +267,9 @@ public void start(IEventBus modbus) { NeoForge.EVENT_BUS.addListener(this::babyEntitySpawnLowest); NeoForge.EVENT_BUS.addListener(this::entityJoinLevel); - NeoForge.EVENT_BUS.addGenericListener(ItemStack.class, this::itemStackCaps); + /*NeoForge.EVENT_BUS.addGenericListener(ItemStack.class, this::itemStackCaps); NeoForge.EVENT_BUS.addGenericListener(BlockEntity.class, this::blockEntityCaps); - NeoForge.EVENT_BUS.addGenericListener(Level.class, this::levelCaps); + NeoForge.EVENT_BUS.addGenericListener(Level.class, this::levelCaps);*/ NeoForge.EVENT_BUS.addListener(this::serverTickStart); NeoForge.EVENT_BUS.addListener(this::serverTickEnd); @@ -458,7 +436,7 @@ public void entityJoinLevel(EntityJoinLevelEvent e) { playBus.fire(new ForgeZEntityJoinLevel(e), ZEntityJoinLevel.class); } - public void itemStackCaps(AttachCapabilitiesEvent e) { + /*public void itemStackCaps(AttachCapabilitiesEvent e) { playBus.fire(new ForgeZAttachCapabilities.ItemStackCaps(capabilityManager, e), ZAttachCapabilities.ItemStackCaps.class); } @@ -468,7 +446,7 @@ public void blockEntityCaps(AttachCapabilitiesEvent e) { public void levelCaps(AttachCapabilitiesEvent e) { playBus.fire(new ForgeZAttachCapabilities.LevelCaps(capabilityManager, e), ZAttachCapabilities.LevelCaps.class); - } + }*/ public void serverTickStart(TickEvent.ServerTickEvent e) { if (e.phase == TickEvent.Phase.START) @@ -530,12 +508,12 @@ public void livingChangeTarget(LivingChangeTargetEvent e) { playBus.fire(new ForgeZLivingChangeTarget(e), ZLivingChangeTarget.class); } - public void sleepingLocationCheck(SleepingLocationCheckEvent e) { + /*public void sleepingLocationCheck(SleepingLocationCheckEvent e) { playBus.fire(new ForgeZSleepingLocationCheck(e), ZSleepingLocationCheck.class); - } + }*/ - public void entityItemPickup(EntityItemPickupEvent e) { - playBus.fire(new ForgeZEntityItemPickup(e), ZEntityItemPickup.class); + public void entityItemPickup(ItemEntityPickupEvent e) { + playBus.fire(new ForgeZEntityItemPickup(e), ZItemEntityPickup.class); } public void blockBreak(BlockEvent.BreakEvent e) { diff --git a/src/main/java/org/violetmoon/zetaimplforge/capability/ForgeCapabilityManager.java b/src/main/java/org/violetmoon/zetaimplforge/capability/ForgeCapabilityManager.java deleted file mode 100644 index d18ea6c..0000000 --- a/src/main/java/org/violetmoon/zetaimplforge/capability/ForgeCapabilityManager.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.violetmoon.zetaimplforge.capability; - -import net.minecraft.core.Direction; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.neoforged.neoforge.capabilities.ICapabilityProvider; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.violetmoon.zeta.capability.ZetaCapability; -import org.violetmoon.zeta.capability.ZetaCapabilityManager; - -import java.util.IdentityHashMap; -import java.util.Map; - -public class ForgeCapabilityManager implements ZetaCapabilityManager { - protected Map, Capability> toForge = new IdentityHashMap<>(); - - @SuppressWarnings("unchecked") - protected Capability forgify(ZetaCapability zcap) { - return (Capability) toForge.get(zcap); - } - - @Override - public ForgeCapabilityManager register(ZetaCapability cap, Object backing) { - if(backing instanceof Capability forgecap) - toForge.put(cap, forgecap); - else - throw new IllegalArgumentException("Can only register Capability objects"); - - return this; - } - - @Override - public boolean hasCapability(ZetaCapability cap, ItemStack stack) { - return stack.getCapability(forgify(cap)).isPresent(); - } - - @SuppressWarnings("DataFlowIssue") //passing null into nonnull - @Override - public T getCapability(ZetaCapability cap, ItemStack stack) { - return stack.getCapability(forgify(cap)).orElse(null); - } - - @Override - public boolean hasCapability(ZetaCapability cap, BlockEntity be) { - return be.getCapability(forgify(cap)).isPresent(); - } - - @SuppressWarnings("DataFlowIssue") //passing null into nonnull - @Override - public @Nullable T getCapability(ZetaCapability cap, BlockEntity be) { - return be.getCapability(forgify(cap)).orElse(null); - } - - @Override - public boolean hasCapability(ZetaCapability cap, Level level) { - return level.getCapability(forgify(cap)).isPresent(); - } - - @SuppressWarnings("DataFlowIssue") //passing null into nonnull - @Override - public @Nullable T getCapability(ZetaCapability cap, Level level) { - return level.getCapability(forgify(cap)).orElse(null); - } - - @Override - public void attachCapability(Object target, ResourceLocation id, ZetaCapability cap, T impl) { - ((AttachCapabilitiesEvent) target).addCapability(id, new ImmediateProvider<>(forgify(cap), impl)); - } - - // Capability Provider For Player With No Time For Nonsense - protected record ImmediateProvider(Capability cap, LazyOptional impl) implements ICapabilityProvider { - ImmediateProvider(Capability cap, C impl) { - this(cap, LazyOptional.of(() -> impl)); - } - - @Override - public @NotNull LazyOptional getCapability(@NotNull Capability cap, @Nullable Direction side) { - return cap == this.cap ? impl.cast() : LazyOptional.empty(); - } - } -} diff --git a/src/main/java/org/violetmoon/zetaimplforge/client/event/play/ForgeZClientTick.java b/src/main/java/org/violetmoon/zetaimplforge/client/event/play/ForgeZClientTick.java index 7d8df27..cc56a65 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/client/event/play/ForgeZClientTick.java +++ b/src/main/java/org/violetmoon/zetaimplforge/client/event/play/ForgeZClientTick.java @@ -13,20 +13,11 @@ public ForgeZClientTick(ClientTickEvent e) { @Override public ZPhase getPhase() { - return from(e.phase); + return from(e instanceof ClientTickEvent.Pre); } - public static ZPhase from(Phase r) { - return switch(r) { - case START -> ZPhase.START; - case END -> ZPhase.END; - }; - } - - public static Phase to(ZPhase r) { - return switch(r) { - case START -> Phase.START; - case END -> Phase.END; - }; + public static ZPhase from(boolean bool) { + return (bool) ? ZPhase.START : ZPhase.END; } } + diff --git a/src/main/java/org/violetmoon/zetaimplforge/client/event/play/ForgeZRenderTick.java b/src/main/java/org/violetmoon/zetaimplforge/client/event/play/ForgeZRenderTick.java index c94b546..2a9d473 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/client/event/play/ForgeZRenderTick.java +++ b/src/main/java/org/violetmoon/zetaimplforge/client/event/play/ForgeZRenderTick.java @@ -1,15 +1,16 @@ package org.violetmoon.zetaimplforge.client.event.play; +import net.neoforged.neoforge.client.event.RenderFrameEvent; import org.violetmoon.zeta.client.event.play.ZRenderTick; public record ForgeZRenderTick(RenderFrameEvent e) implements ZRenderTick { @Override public float getRenderTickTime() { - return e.renderTickTime; + return e.getPartialTick().getRealtimeDeltaTicks(); //todo: Test this } @Override public boolean isEndPhase() { - return e.phase == TickEvent.Phase.END; + return e instanceof RenderFrameEvent.Post; } } diff --git a/src/main/java/org/violetmoon/zetaimplforge/event/play/ForgeZBlock.java b/src/main/java/org/violetmoon/zetaimplforge/event/play/ForgeZBlock.java index df82862..0a8d6e0 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/event/play/ForgeZBlock.java +++ b/src/main/java/org/violetmoon/zetaimplforge/event/play/ForgeZBlock.java @@ -4,7 +4,6 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.state.BlockState; -import net.neoforged.neoforge.common.ToolAction; import net.neoforged.neoforge.event.level.BlockEvent; import org.jetbrains.annotations.Nullable; import org.violetmoon.zeta.event.play.ZBlock; @@ -59,7 +58,7 @@ public BlockState getPlacedBlock() { } } - public static class BlockToolModification extends ForgeZBlock implements ZBlock.BlockToolModification { + /*public static class BlockToolModification extends ForgeZBlock implements ZBlock.BlockToolModification { private final BlockEvent.BlockToolModificationEvent e; public BlockToolModification(BlockEvent.BlockToolModificationEvent e) { @@ -67,8 +66,8 @@ public BlockToolModification(BlockEvent.BlockToolModificationEvent e) { this.e = e; } - @Override - public ToolAction getToolAction() { + //@Override + //public ToolAction getToolAction() { return e.getToolAction(); } @@ -76,5 +75,5 @@ public ToolAction getToolAction() { public void setFinalState(@Nullable BlockState finalState) { e.setFinalState(finalState); } - } + }*/ } diff --git a/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/ForgeZEntityItemPickup.java b/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/ForgeZEntityItemPickup.java index 2acb3f3..494439c 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/ForgeZEntityItemPickup.java +++ b/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/ForgeZEntityItemPickup.java @@ -1,24 +1,25 @@ package org.violetmoon.zetaimplforge.event.play.entity; -import org.violetmoon.zeta.event.play.entity.ZEntityItemPickup; +import net.neoforged.neoforge.event.entity.player.ItemEntityPickupEvent; +import org.violetmoon.zeta.event.play.entity.ZItemEntityPickup; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; -public class ForgeZEntityItemPickup implements ZEntityItemPickup { - private final EntityItemPickupEvent e; +public class ForgeZEntityItemPickup implements ZItemEntityPickup { + private final ItemEntityPickupEvent e; - public ForgeZEntityItemPickup(EntityItemPickupEvent e) { + public ForgeZEntityItemPickup(ItemEntityPickupEvent e) { this.e = e; } @Override public Player getEntity() { - return e.getEntity(); + return e.getPlayer(); } @Override public ItemEntity getItem() { - return e.getItem(); + return e.getItemEntity(); } } diff --git a/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/living/ForgeZMobSpawnEvent.java b/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/living/ForgeZMobSpawnEvent.java index 3515c38..3e3f0f5 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/living/ForgeZMobSpawnEvent.java +++ b/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/living/ForgeZMobSpawnEvent.java @@ -41,7 +41,7 @@ public double getZ() { return e.getZ(); } - @Override + /*@Override public ZResult getResult() { return ForgeZeta.from(e.getResult()); } @@ -49,7 +49,7 @@ public ZResult getResult() { @Override public void setResult(ZResult value) { e.setResult(ForgeZeta.to(value)); - } + }*/ public static class FinalizeSpawn extends ForgeZMobSpawnEvent implements ZMobSpawnEvent.CheckSpawn { private final MobSpawnEvent.FinalizeSpawn e; diff --git a/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/living/ForgeZSleepingLocationCheck.java b/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/living/ForgeZSleepingLocationCheck.java deleted file mode 100644 index 0bb70d5..0000000 --- a/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/living/ForgeZSleepingLocationCheck.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.violetmoon.zetaimplforge.event.play.entity.living; - -import org.violetmoon.zeta.event.bus.ZResult; -import org.violetmoon.zeta.event.play.entity.living.ZSleepingLocationCheck; -import org.violetmoon.zetaimplforge.ForgeZeta; - -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.LivingEntity; - -public class ForgeZSleepingLocationCheck implements ZSleepingLocationCheck { - private final SleepingLocationCheckEvent e; - - public ForgeZSleepingLocationCheck(SleepingLocationCheckEvent e) { - this.e = e; - } - - @Override - public LivingEntity getEntity() { - return e.getEntity(); - } - - - @Override - public BlockPos getSleepingLocation() { - return e.getSleepingLocation(); - } - - @Override - public ZResult getResult() { - return ForgeZeta.from(e.getResult()); - } - - @Override - public void setResult(ZResult value) { - e.setResult(ForgeZeta.to(value)); - } -} diff --git a/src/main/java/org/violetmoon/zetaimplforge/event/play/loading/ForgeZAttachCapabilities.java b/src/main/java/org/violetmoon/zetaimplforge/event/play/loading/ForgeZAttachCapabilities.java deleted file mode 100644 index a897f44..0000000 --- a/src/main/java/org/violetmoon/zetaimplforge/event/play/loading/ForgeZAttachCapabilities.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.violetmoon.zetaimplforge.event.play.loading; - -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.neoforged.neoforge.capabilities.ICapabilityProvider; -import org.violetmoon.zeta.capability.ZetaCapability; -import org.violetmoon.zeta.capability.ZetaCapabilityManager; -import org.violetmoon.zeta.event.play.loading.ZAttachCapabilities; - -public abstract class ForgeZAttachCapabilities implements ZAttachCapabilities { - protected final ZetaCapabilityManager zetaCaps; - protected final AttachCapabilitiesEvent e; - - public ForgeZAttachCapabilities(ZetaCapabilityManager zetaCaps, AttachCapabilitiesEvent e) { - this.zetaCaps = zetaCaps; - this.e = e; - } - - @Override - public ZetaCapabilityManager getCapabilityManager() { - return zetaCaps; - } - - @Override - public T getObject() { - return e.getObject(); - } - - @Override - public void addCapability(ResourceLocation key, ZetaCapability cap, C impl) { - zetaCaps.attachCapability(e, key, cap, impl); - } - - @Override - @Deprecated //Forge only API, we should migrate off ICapabilityProvider. - public void addCapabilityForgeApi(ResourceLocation key, ICapabilityProvider cap) { - e.addCapability(key, cap); - } - - public static class ItemStackCaps extends ForgeZAttachCapabilities implements ZAttachCapabilities.ItemStackCaps { - public ItemStackCaps(ZetaCapabilityManager zetaCaps, AttachCapabilitiesEvent e) { - super(zetaCaps, e); - } - } - - public static class BlockEntityCaps extends ForgeZAttachCapabilities implements ZAttachCapabilities.BlockEntityCaps { - public BlockEntityCaps(ZetaCapabilityManager zetaCaps, AttachCapabilitiesEvent e) { - super(zetaCaps, e); - } - } - - public static class LevelCaps extends ForgeZAttachCapabilities implements ZAttachCapabilities.LevelCaps { - public LevelCaps(ZetaCapabilityManager zetaCaps, AttachCapabilitiesEvent e) { - super(zetaCaps, e); - } - } -} diff --git a/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/self/IZetaItemMixin_FAKE.java b/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/self/IZetaItemMixin_FAKE.java index 7c04be9..bcb97ef 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/self/IZetaItemMixin_FAKE.java +++ b/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/self/IZetaItemMixin_FAKE.java @@ -33,6 +33,7 @@ ZetaBlockItem.class, ZetaItem.class, }) +//todo: Chat... I think its over for IForgeItem public class IZetaItemMixin_FAKE implements IForgeItem, IZetaItemExtensions { @Override public InteractionResult onItemUseFirst(ItemStack stack, UseOnContext context) { diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 4b8dcf1..50ae262 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -9,4 +9,5 @@ public-f net.minecraft.advancements.critereon.ItemUsedOnLocationTrigger$TriggerI public-f net.minecraft.advancements.critereon.ContextAwarePredicate f_285559_ # compositePredicates 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 \ No newline at end of file +public net.minecraft.world.item.Item f_41379_ # descriptionId +public net.minecraft.advancements.critereon.ContextAwarePredicate f_285559_ # compositePredicates \ No newline at end of file