diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b432863..f40c2a1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,15 @@ # Changelog + Changelog to track updates for this mod. - Add your changes to Unreleased if you want to commit. - Please write according to [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +Add your changes to Unreleased if you want to commit. +Please write according to [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased] ### Added +- Add living tick event + ### Changed ### Deprecated @@ -20,28 +23,37 @@ Changelog to track updates for this mod. ## [3.3.0] - 2023-01-24 ### Added + - Add new utility class ## [3.3.0-beta.1] - 2023-01-22 ### Changed + - Port MC1.19.3 ### Removed + - Separated Fabric's built-in OBJ loader ([Special Model Loader](https://github.com/TeamFelnull/SpecialModelLoader)) ### Fixed + - Fixed a problem that crashes without notifying when Architecture is not installed (Forge Only) ## [3.3.0-alpha.1] - 2023-01-18 ### Changed + - Port MC1.19.3 ### Removed + - Separated Fabric's built-in OBJ loader ([Special Model Loader](https://github.com/TeamFelnull/SpecialModelLoader)) [Unreleased]: https://github.com/TeamFelnull/OtyacraftEngine/compare/v3.3.0...HEAD + [3.3.0]: https://github.com/TeamFelnull/OtyacraftEngine/compare/v3.3.0-beta.1...v3.3.0 + [3.3.0-beta.1]: https://github.com/TeamFelnull/OtyacraftEngine/compare/v3.3.0-alpha.1...v3.3.0-beta.1 + [3.3.0-alpha.1]: https://github.com/TeamFelnull/OtyacraftEngine/commits/v3.3.0-alpha.1 diff --git a/common/src/main/java/dev/felnull/otyacraftengine/event/MoreEntityEvent.java b/common/src/main/java/dev/felnull/otyacraftengine/event/MoreEntityEvent.java index 7608aa2d..68a16fef 100644 --- a/common/src/main/java/dev/felnull/otyacraftengine/event/MoreEntityEvent.java +++ b/common/src/main/java/dev/felnull/otyacraftengine/event/MoreEntityEvent.java @@ -2,14 +2,21 @@ import dev.architectury.event.Event; import dev.architectury.event.EventFactory; +import dev.architectury.event.EventResult; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; import org.jetbrains.annotations.NotNull; public interface MoreEntityEvent { Event ENTITY_DEFINE_SYNCHED_DATA = EventFactory.createLoop(); + Event LIVING_ENTITY_TICK = EventFactory.createEventResult(); interface EntityDefineSynchedData { void onDefineSynchedData(@NotNull Entity entity, @NotNull SynchedEntityData entityData); } + + interface LivingEntityTick { + EventResult livingEntityTick(@NotNull LivingEntity livingEntity); + } } diff --git a/common/src/main/java/dev/felnull/otyacraftengine/event/OECommonEventHooks.java b/common/src/main/java/dev/felnull/otyacraftengine/event/OECommonEventHooks.java index d7e4bde6..535a8886 100644 --- a/common/src/main/java/dev/felnull/otyacraftengine/event/OECommonEventHooks.java +++ b/common/src/main/java/dev/felnull/otyacraftengine/event/OECommonEventHooks.java @@ -2,10 +2,16 @@ import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; import org.jetbrains.annotations.NotNull; public class OECommonEventHooks { public static void onEntityDefineSynchedData(@NotNull Entity entity, @NotNull SynchedEntityData entityData) { MoreEntityEvent.ENTITY_DEFINE_SYNCHED_DATA.invoker().onDefineSynchedData(entity, entityData); } + + public static boolean onLivingEntityTick(@NotNull LivingEntity livingEntity) { + var event = MoreEntityEvent.LIVING_ENTITY_TICK.invoker().livingEntityTick(livingEntity); + return event.isEmpty() || event.isTrue(); + } } diff --git a/fabric/src/main/java/dev/felnull/otyacraftengine/fabric/mixin/LivingEntityMixin.java b/fabric/src/main/java/dev/felnull/otyacraftengine/fabric/mixin/LivingEntityMixin.java index d26f05fb..4d02d8fa 100644 --- a/fabric/src/main/java/dev/felnull/otyacraftengine/fabric/mixin/LivingEntityMixin.java +++ b/fabric/src/main/java/dev/felnull/otyacraftengine/fabric/mixin/LivingEntityMixin.java @@ -1,5 +1,6 @@ package dev.felnull.otyacraftengine.fabric.mixin; +import dev.felnull.otyacraftengine.event.OECommonEventHooks; import dev.felnull.otyacraftengine.item.EquipmentItem; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; @@ -7,6 +8,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(LivingEntity.class) @@ -19,4 +21,10 @@ private static void getEquipmentSlotForItem(ItemStack itemStack, CallbackInfoRet cir.setReturnValue(slot); } } + + @Inject(method = "tick", at = @At("HEAD"), cancellable = true) + private void tick(CallbackInfo ci) { + if (!OECommonEventHooks.onLivingEntityTick((LivingEntity) (Object) this)) + ci.cancel(); + } } \ No newline at end of file diff --git a/forge/src/main/java/dev/felnull/otyacraftengine/forge/handler/CommonHandlerForge.java b/forge/src/main/java/dev/felnull/otyacraftengine/forge/handler/CommonHandlerForge.java index 12652c48..dd2038d0 100644 --- a/forge/src/main/java/dev/felnull/otyacraftengine/forge/handler/CommonHandlerForge.java +++ b/forge/src/main/java/dev/felnull/otyacraftengine/forge/handler/CommonHandlerForge.java @@ -2,6 +2,7 @@ import dev.felnull.otyacraftengine.event.OECommonEventHooks; import net.minecraftforge.event.entity.EntityEvent; +import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; public class CommonHandlerForge { @@ -9,4 +10,10 @@ public class CommonHandlerForge { public static void onEntityConstructing(EntityEvent.EntityConstructing e) { OECommonEventHooks.onEntityDefineSynchedData(e.getEntity(), e.getEntity().getEntityData()); } + + @SubscribeEvent + public static void onLivingTick(LivingEvent.LivingTickEvent e) { + if (!OECommonEventHooks.onLivingEntityTick(e.getEntity())) + e.setCanceled(true); + } } diff --git a/gradle.properties b/gradle.properties index 77185e78..5b994944 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ enabled_platforms=fabric,forge #Mod archives_base_name=otyacraftengine mod_display_name=OtyacraftEngine -mod_version=3.3.0 +mod_version=3.4.0 #Dependencies architectury_version=7.0.65 fabric_loader_version=0.14.11 diff --git a/testmod-common/src/main/java/dev/felnull/otyacraftenginetest/OtyacraftEngineTest.java b/testmod-common/src/main/java/dev/felnull/otyacraftenginetest/OtyacraftEngineTest.java index 90ca4c42..500a729e 100644 --- a/testmod-common/src/main/java/dev/felnull/otyacraftenginetest/OtyacraftEngineTest.java +++ b/testmod-common/src/main/java/dev/felnull/otyacraftenginetest/OtyacraftEngineTest.java @@ -2,6 +2,7 @@ import dev.felnull.otyacraftenginetest.block.TestBlocks; import dev.felnull.otyacraftenginetest.blockentity.TestBlockEntitys; +import dev.felnull.otyacraftenginetest.handler.CommonHandler; import dev.felnull.otyacraftenginetest.item.TestItems; import dev.felnull.otyacraftenginetest.server.handler.ServerHandler; @@ -13,6 +14,7 @@ public static void init() { TestBlocks.init(); TestBlockEntitys.init(); + CommonHandler.init(); ServerHandler.init(); } } diff --git a/testmod-common/src/main/java/dev/felnull/otyacraftenginetest/handler/CommonHandler.java b/testmod-common/src/main/java/dev/felnull/otyacraftenginetest/handler/CommonHandler.java new file mode 100644 index 00000000..ce907948 --- /dev/null +++ b/testmod-common/src/main/java/dev/felnull/otyacraftenginetest/handler/CommonHandler.java @@ -0,0 +1,22 @@ +package dev.felnull.otyacraftenginetest.handler; + +import dev.architectury.event.EventResult; +import dev.felnull.otyacraftengine.event.MoreEntityEvent; +import net.minecraft.world.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; + +public class CommonHandler { + public static void init() { + MoreEntityEvent.LIVING_ENTITY_TICK.register(CommonHandler::livingEntityTick); + } + + private static EventResult livingEntityTick(@NotNull LivingEntity livingEntity) { + + /* System.out.println(livingEntity); + + if (livingEntity instanceof Villager) + return EventResult.interruptFalse();*/ + + return EventResult.pass(); + } +} diff --git a/testmod-fabric/src/main/generated/.cache/0d50bffddf75e22e52fc02f1ad4a51e0aed4f3e3 b/testmod-fabric/src/main/generated/.cache/0d50bffddf75e22e52fc02f1ad4a51e0aed4f3e3 index 79bdf4f1..f2777177 100644 --- a/testmod-fabric/src/main/generated/.cache/0d50bffddf75e22e52fc02f1ad4a51e0aed4f3e3 +++ b/testmod-fabric/src/main/generated/.cache/0d50bffddf75e22e52fc02f1ad4a51e0aed4f3e3 @@ -1 +1 @@ -// 1.19.3 2023-01-25T04:17:51.605033 Otyacraft Engine Test/Tags for minecraft:block +// 1.19.3 2023-01-25T23:26:30.4255283 Otyacraft Engine Test/Tags for minecraft:block diff --git a/testmod-fabric/src/main/generated/.cache/7ef7386eba12df43ed28295f8b18d4d73adaecc3 b/testmod-fabric/src/main/generated/.cache/7ef7386eba12df43ed28295f8b18d4d73adaecc3 index bd8330d2..ff249744 100644 --- a/testmod-fabric/src/main/generated/.cache/7ef7386eba12df43ed28295f8b18d4d73adaecc3 +++ b/testmod-fabric/src/main/generated/.cache/7ef7386eba12df43ed28295f8b18d4d73adaecc3 @@ -1,2 +1,2 @@ -// 1.19.3 2023-01-25T04:17:51.605033 Otyacraft Engine Test/Advancements +// 1.19.3 2023-01-25T23:26:30.4245289 Otyacraft Engine Test/Advancements 24ed8addd22a4702b7c77f0cd605fc53795f19e4 data\otyacraftenginetest\advancements\otyacraftenginetest\root.json diff --git a/testmod-fabric/src/main/generated/.cache/82fd91efd4f0f9bed8483c2564da5617cbe89e10 b/testmod-fabric/src/main/generated/.cache/82fd91efd4f0f9bed8483c2564da5617cbe89e10 index bdcfb30f..b039426b 100644 --- a/testmod-fabric/src/main/generated/.cache/82fd91efd4f0f9bed8483c2564da5617cbe89e10 +++ b/testmod-fabric/src/main/generated/.cache/82fd91efd4f0f9bed8483c2564da5617cbe89e10 @@ -1,3 +1,3 @@ -// 1.19.3 2023-01-25T04:17:51.6040356 Otyacraft Engine Test/Input copy +// 1.19.3 2023-01-25T23:26:30.423527 Otyacraft Engine Test/Input copy 183e554347c694dd0d75591721b58459636bd6f2 assets\otyacraftenginetest\copy_test\test.json 183e554347c694dd0d75591721b58459636bd6f2 assets\otyacraftenginetest\copy_test\fcoh\ikisugi.json diff --git a/testmod-fabric/src/main/generated/.cache/8a0e335825c442d2d05946d5f5bfc9cff6867414 b/testmod-fabric/src/main/generated/.cache/8a0e335825c442d2d05946d5f5bfc9cff6867414 index 0d2f96a9..32bcc67f 100644 --- a/testmod-fabric/src/main/generated/.cache/8a0e335825c442d2d05946d5f5bfc9cff6867414 +++ b/testmod-fabric/src/main/generated/.cache/8a0e335825c442d2d05946d5f5bfc9cff6867414 @@ -1,3 +1,3 @@ -// 1.19.3 2023-01-25T04:17:51.6040356 Otyacraft Engine Test/Recipes +// 1.19.3 2023-01-25T23:26:30.423527 Otyacraft Engine Test/Recipes afe1da46e75b1ff0ac6ea63110f2748c8aa84b96 data\otyacraftenginetest\recipes\test.json d1ccb28bcc88e720665ccb40ab3bc54348a05587 data\otyacraftenginetest\advancements\recipes\food\test.json diff --git a/testmod-fabric/src/main/generated/.cache/ba2d765169f46b9a6372777275918e1ed1f0fcc3 b/testmod-fabric/src/main/generated/.cache/ba2d765169f46b9a6372777275918e1ed1f0fcc3 index b5f09bdc..ceb81553 100644 --- a/testmod-fabric/src/main/generated/.cache/ba2d765169f46b9a6372777275918e1ed1f0fcc3 +++ b/testmod-fabric/src/main/generated/.cache/ba2d765169f46b9a6372777275918e1ed1f0fcc3 @@ -1,2 +1,2 @@ -// 1.19.3 2023-01-25T04:17:51.605033 Otyacraft Engine Test/Model Definitions +// 1.19.3 2023-01-25T23:26:30.4245289 Otyacraft Engine Test/Model Definitions d40f279d0798e10ef4fe6a50dc7c0c3b22f8f3a2 assets\otyacraftenginetest\models\item\test_item.json diff --git a/testmod-fabric/src/main/generated/.cache/ce80034259a34f1a7f73e142406aa3e0d228839b b/testmod-fabric/src/main/generated/.cache/ce80034259a34f1a7f73e142406aa3e0d228839b index 6194ea07..3e5f3030 100644 --- a/testmod-fabric/src/main/generated/.cache/ce80034259a34f1a7f73e142406aa3e0d228839b +++ b/testmod-fabric/src/main/generated/.cache/ce80034259a34f1a7f73e142406aa3e0d228839b @@ -1,3 +1,2 @@ -// 1.19.3 2023-01-25T04:17:51.6030333 Otyacraft Engine Test/Tags for minecraft:item +// 1.19.3 2023-01-25T23:26:30.4225289 Otyacraft Engine Test/Tags for minecraft:item 7eb508a49db08b3875db67cd0383ae0d7494beb6 data\minecraft\tags\items\boats.json -cfa612cb64f7e213d984ca4431202690f594df8a data\c\tags\items\ender_pearls.json diff --git a/testmod-fabric/src/main/generated/.cache/f61dec5b33b2b836451587dc0ec0b3cbe6b0bd80 b/testmod-fabric/src/main/generated/.cache/f61dec5b33b2b836451587dc0ec0b3cbe6b0bd80 index b37b5aae..c6233d15 100644 --- a/testmod-fabric/src/main/generated/.cache/f61dec5b33b2b836451587dc0ec0b3cbe6b0bd80 +++ b/testmod-fabric/src/main/generated/.cache/f61dec5b33b2b836451587dc0ec0b3cbe6b0bd80 @@ -1,4 +1,4 @@ -// 1.19.3 2023-01-25T04:17:51.6040356 Otyacraft Engine Test/Model Process +// 1.19.3 2023-01-25T23:26:30.423527 Otyacraft Engine Test/Model Process d949ee0f371db9fc9b8bceb58f7d74284b47ade3 assets\otyacraftenginetest\models\item\slide.json 8cb44dd96d67f1401394f517ced825ebc2b7728e assets\otyacraftenginetest\models\item\glock_17.json b2c02147d1dbbc14042fc6c1a40e7f1072660b5b assets\otyacraftenginetest\models\item\magazine.json diff --git a/testmod-fabric/src/main/generated/data/c/tags/items/ender_pearls.json b/testmod-fabric/src/main/generated/data/c/tags/items/ender_pearls.json deleted file mode 100644 index 0b410745..00000000 --- a/testmod-fabric/src/main/generated/data/c/tags/items/ender_pearls.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "replace": false, - "values": [ - "minecraft:ender_pearl" - ] -} \ No newline at end of file