From 609c15c0fedbfd6bde8e80dc8a3cc66a1b89f0b4 Mon Sep 17 00:00:00 2001 From: IzzelAliz Date: Mon, 17 Aug 2020 23:05:28 +0800 Subject: [PATCH] Merge mixins, cleanup code. --- .../common/bridge/entity/EntityBridge.java | 2 - .../bridge/entity/LivingEntityBridge.java | 5 - .../common/bridge/item/BlockItemBridge.java | 11 - .../play/ServerPlayNetHandlerBridge.java | 11 - .../PlayerInteractionManagerBridge.java | 9 - .../server/management/PlayerListBridge.java | 13 - .../common/bridge/world/ExplosionBridge.java | 2 - .../server/ServerChunkProviderBridge.java | 6 - .../bridge/world/storage/MapDataBridge.java | 7 - .../mixin/bukkit/JavaPluginLoaderMixin.java | 8 +- .../core/block/AbstractButtonBlockMixin.java | 35 ++ .../mixin/core/block/CactusBlockMixin.java | 7 + .../block/CakeBlockMixin.java} | 4 +- .../block/CauldronBlockMixin.java} | 4 +- .../block/ChestBlock2Mixin.java} | 4 +- .../block/ChorusFlowerBlockMixin.java} | 7 +- .../block/CocoaBlockMixin.java} | 4 +- .../block/CoralBlockMixin.java} | 4 +- .../block/CoralFinBlockMixin.java} | 4 +- .../block/CoralPlantBlockMixin.java} | 4 +- .../block/CoralWallFanBlockMixin.java} | 4 +- .../mixin/core/block/CropsBlockMixin.java | 6 + .../mixin/core/block/FarmlandBlockMixin.java | 7 + .../mixin/core/block/FireBlockMixin.java | 20 ++ .../block/GrassBlockMixin.java} | 4 +- .../block/KelpTopBlockMixin.java} | 4 +- .../block/LeavesBlockMixin.java} | 4 +- .../block/LeverBlockMixin.java} | 4 +- .../block/LilyPadBlockMixin.java} | 4 +- .../block/MushroomBlockMixin.java} | 4 +- .../core/block/NetherPortalBlockMixin.java | 13 + .../block/NetherWartBlockMixin.java} | 4 +- .../mixin/core/block/NoteBlockMixin.java | 5 + .../block/ObserverBlockMixin.java} | 4 +- .../mixin/core/block/PistonBlockMixin.java | 58 ++++ .../block/RedstoneDiodeBlockMixin.java} | 4 +- .../core/block/RedstoneLampBlockMixin.java | 10 + .../block/RedstoneOreBlockMixin.java} | 4 +- .../block/ScaffoldingBlockMixin.java} | 4 +- .../block/SnowBlockMixin.java} | 4 +- .../block/SpreadableSnowyDirtBlockMixin.java} | 4 +- .../block/StemBlockMixin.java} | 4 +- .../block/SugarCaneBlockMixin.java} | 6 +- .../block/SweetBerryBushBlockMixin.java} | 4 +- .../mixin/core/block/TripWireBlockMixin.java | 4 +- .../mixin/core/block/TurtleEggBlockMixin.java | 36 ++ .../block/VineBlockMixin.java} | 5 +- .../block/WitherRoseBlockMixin.java | 2 +- .../command/impl/TeleportCommandMixin.java} | 4 +- .../command/impl/TimeCommandMixin.java | 2 +- .../FrostWalkerEnchantmentMixin.java} | 4 +- .../entity/AreaEffectCloudEntityMixin.java | 8 +- .../common/mixin/core/entity/EntityMixin.java | 150 ++++++++ .../mixin/core/entity/LivingEntityMixin.java | 233 ++++++++++++- .../entity/ai/goal/FollowOwnerGoalMixin.java} | 4 +- .../entity/boss/WitherEntityMixin.java} | 6 +- .../entity/item/ArmorStandEntityMixin.java | 33 ++ .../entity/item/FallingBlockEntityMixin.java} | 4 +- .../core/entity/item/ItemEntityMixin.java | 8 + .../entity/item/LeashKnotEntityMixin.java | 2 +- .../monster/AbstractRaiderEntityMixin.java | 2 +- .../entity/monster/EndermanEntityMixin.java | 30 ++ .../entity/monster/RavagerEntityMixin.java} | 4 +- .../entity/monster/ShulkerEntityMixin.java} | 4 +- .../monster/ZombiePigmanEntityMixin.java} | 5 +- .../entity/passive/BeeEntityMixin.java | 3 +- .../passive/BeeEntity_AngerGoalMixin.java | 2 +- ...Entity_FindPollinationTargetGoalMixin.java | 2 +- .../core/entity/player/PlayerEntityMixin.java | 113 +++++- .../player/ServerPlayerEntityMixin.java | 276 ++++++++++++++- .../container/EnchantmentContainerMixin.java | 2 +- .../mixin/core/item/BlockItemMixin.java | 5 +- .../common/mixin/core/item/BoatItemMixin.java | 2 +- .../common/mixin/core/item/BowItemMixin.java | 2 +- .../mixin/core/item/ChorusFruitItemMixin.java | 4 +- .../mixin/core/item/EnderPearlItemMixin.java | 2 +- .../item/LeadItemMixin.java} | 4 +- .../item/crafting/RecipeManagerMixin.java | 2 +- .../item/crafting/SpecialRecipeMixin.java | 2 +- .../play/ServerPlayNetHandlerMixin.java | 19 +- .../PlayerInteractionManagerMixin.java | 113 +++++- .../server/management/PlayerListMixin.java | 25 +- .../tileentity/BeehiveTileEntityMixin.java | 3 +- .../mixin/core/world/ExplosionMixin.java | 103 +++++- .../world/TeleporterMixin.java} | 4 +- .../common/mixin/core/world/WorldMixin.java | 7 + .../world/biome/BiomeContainerMixin.java | 2 +- .../mixin/core/world/chunk/ChunkMixin.java | 13 + .../world/dimension/DimensionTypeMixin.java} | 4 +- .../structure/SwampHutPieceMixin.java} | 4 +- .../server/ServerChunkProviderMixin.java | 3 +- .../world/server/ServerMultiWorldMixin.java} | 5 +- .../core/world/server/ServerWorldMixin.java | 27 +- .../world/server/TicketManagerMixin.java} | 4 +- .../world/spawner/AbstractSpawnerMixin.java | 5 +- .../spawner/WorldEntitySpawnerMixin.java} | 4 +- .../core/world/storage/MapDataMixin.java | 2 +- .../storage/loot/LootTableManagerMixin.java | 2 +- .../world/storage/loot/LootTableMixin.java | 2 +- .../block/AbstractButtonBlockMixin_1_15.java | 61 ---- .../v1_15/block/CactusBlockMixin_1_15.java | 19 - .../v1_15/block/CropsBlockMixin_1_15.java | 19 - .../v1_15/block/FarmlandBlockMixin_1_15.java | 19 - .../v1_15/block/FireBlockMixin_1_15.java | 34 -- .../block/NetherPortalBlockMixin_1_15.java | 25 -- .../v1_15/block/NoteBlockMixin_1_15.java | 19 - .../v1_15/block/PistonBlockMixin_1_15.java | 76 ---- .../block/RedstoneLampBlockMixin_1_15.java | 24 -- .../v1_15/block/TurtleEggBlockMixin_1_15.java | 49 --- .../mixin/v1_15/entity/EntityMixin_1_15.java | 215 ------------ .../v1_15/entity/LivingEntityMixin_1_15.java | 280 --------------- .../item/ArmorStandEntityMixin_1_15.java | 48 --- .../entity/item/ItemEntityMixin_1_15.java | 18 - .../monster/EndermanEntityMixin_1_15.java | 41 --- .../entity/player/PlayerEntityMixin_1_15.java | 143 -------- .../player/ServerPlayerEntityMixin_1_15.java | 328 ------------------ .../mixin/v1_15/item/BlockItemMixin_1_15.java | 18 - .../play/ServerPlayNetHandlerMixin_1_15.java | 29 -- .../PlayerInteractionManagerMixin_1_15.java | 126 ------- .../management/PlayerListMixin_1_15.java | 44 --- .../v1_15/world/ExplosionMixin_1_15.java | 139 -------- .../mixin/v1_15/world/WorldMixin_1_14.java | 18 - .../v1_15/world/chunk/ChunkMixin_1_15.java | 28 -- .../server/ServerChunkProviderMixin_1_15.java | 20 -- .../world/server/ServerWorldMixin_1_15.java | 47 --- .../world/storage/MapDataMixin_1_15.java | 19 - .../common/mod/ArclightConnector.java | 4 - .../resources/mixins.arclight.core.1_15.json | 94 ----- .../main/resources/mixins.arclight.core.json | 52 +++ build.gradle | 20 +- 130 files changed, 1479 insertions(+), 2259 deletions(-) delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/bridge/item/BlockItemBridge.java rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/CakeBlockMixin_1_15.java => core/block/CakeBlockMixin.java} (93%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/CauldronBlockMixin_1_15.java => core/block/CauldronBlockMixin.java} (98%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/ChestBlock2Mixin_1_15.java => core/block/ChestBlock2Mixin.java} (90%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/ChorusFlowerBlockMixin_1_15.java => core/block/ChorusFlowerBlockMixin.java} (95%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/CocoaBlockMixin_1_15.java => core/block/CocoaBlockMixin.java} (89%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/CoralBlockMixin_1_15.java => core/block/CoralBlockMixin.java} (93%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/CoralFinBlockMixin_1_15.java => core/block/CoralFinBlockMixin.java} (93%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/CoralPlantBlockMixin_1_15.java => core/block/CoralPlantBlockMixin.java} (93%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/CoralWallFanBlockMixin_1_15.java => core/block/CoralWallFanBlockMixin.java} (93%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/GrassBlockMixin_1_15.java => core/block/GrassBlockMixin.java} (89%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/KelpTopBlockMixin_1_15.java => core/block/KelpTopBlockMixin.java} (89%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/LeavesBlockMixin_1_15.java => core/block/LeavesBlockMixin.java} (93%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/LeverBlockMixin_1_15.java => core/block/LeverBlockMixin.java} (95%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/LilyPadBlockMixin_1_15.java => core/block/LilyPadBlockMixin.java} (91%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/MushroomBlockMixin_1_15.java => core/block/MushroomBlockMixin.java} (90%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/NetherWartBlockMixin_1_15.java => core/block/NetherWartBlockMixin.java} (89%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/ObserverBlockMixin_1_15.java => core/block/ObserverBlockMixin.java} (94%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/RedstoneDiodeBlockMixin_1_15.java => core/block/RedstoneDiodeBlockMixin.java} (93%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/RedstoneOreBlockMixin_1_15.java => core/block/RedstoneOreBlockMixin.java} (97%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/ScaffoldingBlockMixin_1_15.java => core/block/ScaffoldingBlockMixin.java} (92%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/SnowBlockMixin_1_15.java => core/block/SnowBlockMixin.java} (92%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/SpreadableSnowyDirtBlockMixin_1_15.java => core/block/SpreadableSnowyDirtBlockMixin.java} (93%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/StemBlockMixin_1_15.java => core/block/StemBlockMixin.java} (96%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/SugarCaneBlockMixin_1_15.java => core/block/SugarCaneBlockMixin.java} (74%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/SweetBerryBushBlockMixin_1_15.java => core/block/SweetBerryBushBlockMixin.java} (94%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/block/VineBlockMixin_1_15.java => core/block/VineBlockMixin.java} (97%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15 => core}/block/WitherRoseBlockMixin.java (95%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/command/impl/TeleportCommandMixin_1_15.java => core/command/impl/TeleportCommandMixin.java} (97%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15 => core}/command/impl/TimeCommandMixin.java (96%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/enchantment/FrostWalkerEnchantmentMixin_1_15.java => core/enchantment/FrostWalkerEnchantmentMixin.java} (96%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/entity/ai/goal/FollowOwnerGoalMixin_1_15.java => core/entity/ai/goal/FollowOwnerGoalMixin.java} (95%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/entity/boss/WitherEntityMixin_1_15.java => core/entity/boss/WitherEntityMixin.java} (97%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/entity/item/FallingBlockEntityMixin_1_15.java => core/entity/item/FallingBlockEntityMixin.java} (93%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15 => core}/entity/monster/AbstractRaiderEntityMixin.java (95%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/entity/monster/RavagerEntityMixin_1_15.java => core/entity/monster/RavagerEntityMixin.java} (88%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/entity/monster/ShulkerEntityMixin_1_15.java => core/entity/monster/ShulkerEntityMixin.java} (85%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/entity/monster/ZombiePigmanEntityMixin_1_15.java => core/entity/monster/ZombiePigmanEntityMixin.java} (91%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15 => core}/entity/passive/BeeEntityMixin.java (94%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15 => core}/entity/passive/BeeEntity_AngerGoalMixin.java (93%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15 => core}/entity/passive/BeeEntity_FindPollinationTargetGoalMixin.java (95%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/item/LeadItemMixin_1_15.java => core/item/LeadItemMixin.java} (96%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15 => core}/item/crafting/SpecialRecipeMixin.java (88%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15 => core}/tileentity/BeehiveTileEntityMixin.java (97%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/world/TeleporterMixin_1_15.java => core/world/TeleporterMixin.java} (99%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15 => core}/world/biome/BiomeContainerMixin.java (93%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/world/dimension/DimensionTypeMixin_1_15.java => core/world/dimension/DimensionTypeMixin.java} (93%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/world/gen/feature/structure/SwampHutPieceMixin_1_15.java => core/world/gen/feature/structure/SwampHutPieceMixin.java} (90%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/world/server/ServerMultiWorldMixin_1_15.java => core/world/server/ServerMultiWorldMixin.java} (89%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/world/server/TicketManagerMixin_1_15.java => core/world/server/TicketManagerMixin.java} (97%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15/world/spawner/WorldEntitySpawnerMixin_1_15.java => core/world/spawner/WorldEntitySpawnerMixin.java} (93%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15 => core}/world/storage/loot/LootTableManagerMixin.java (95%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/{v1_15 => core}/world/storage/loot/LootTableMixin.java (97%) delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/AbstractButtonBlockMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CactusBlockMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CropsBlockMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/FarmlandBlockMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/FireBlockMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/NetherPortalBlockMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/NoteBlockMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/PistonBlockMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/RedstoneLampBlockMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/TurtleEggBlockMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/EntityMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/LivingEntityMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/item/ArmorStandEntityMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/item/ItemEntityMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/monster/EndermanEntityMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/player/PlayerEntityMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/player/ServerPlayerEntityMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/item/BlockItemMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/network/play/ServerPlayNetHandlerMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/server/management/PlayerInteractionManagerMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/server/management/PlayerListMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/ExplosionMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/WorldMixin_1_14.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/chunk/ChunkMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/server/ServerChunkProviderMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/server/ServerWorldMixin_1_15.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/storage/MapDataMixin_1_15.java delete mode 100644 arclight-common/src/main/resources/mixins.arclight.core.1_15.json diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/entity/EntityBridge.java b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/entity/EntityBridge.java index 4be710d2..5a3a83e7 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/entity/EntityBridge.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/entity/EntityBridge.java @@ -52,6 +52,4 @@ public interface EntityBridge extends ICommandSourceBridge { void bridge$setRideCooldown(int rideCooldown); int bridge$getRideCooldown(); - - double bridge$getEyeHeight(); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/entity/LivingEntityBridge.java b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/entity/LivingEntityBridge.java index 6661c064..9ffa8c8d 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/entity/LivingEntityBridge.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/entity/LivingEntityBridge.java @@ -1,6 +1,5 @@ package io.izzel.arclight.common.bridge.entity; -import net.minecraft.entity.LivingEntity; import net.minecraft.potion.Effect; import net.minecraft.potion.EffectInstance; import org.bukkit.craftbukkit.v.entity.CraftLivingEntity; @@ -21,10 +20,6 @@ public interface LivingEntityBridge extends EntityBridge { int bridge$getExpToDrop(); - void bridge$dropExperience(); - - void bridge$createWitherRose(LivingEntity entity); - void bridge$pushHealReason(EntityRegainHealthEvent.RegainReason regainReason); void bridge$heal(float healAmount, EntityRegainHealthEvent.RegainReason regainReason); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/item/BlockItemBridge.java b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/item/BlockItemBridge.java deleted file mode 100644 index 613f1c3b..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/item/BlockItemBridge.java +++ /dev/null @@ -1,11 +0,0 @@ -package io.izzel.arclight.common.bridge.item; - -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.world.World; - -public interface BlockItemBridge { - - boolean bridge$noCollisionInSel(World world, BlockState state, BlockPos pos, ISelectionContext context); -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/network/play/ServerPlayNetHandlerBridge.java b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/network/play/ServerPlayNetHandlerBridge.java index 642437c9..847e1b5f 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/network/play/ServerPlayNetHandlerBridge.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/network/play/ServerPlayNetHandlerBridge.java @@ -1,10 +1,5 @@ package io.izzel.arclight.common.bridge.network.play; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.nbt.StringNBT; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.world.server.ServerWorld; import org.bukkit.Location; import org.bukkit.event.player.PlayerTeleportEvent; @@ -17,12 +12,6 @@ public interface ServerPlayNetHandlerBridge { void bridge$teleport(Location dest); - boolean bridge$worldNoCollision(ServerWorld world, Entity entity, AxisAlignedBB aabb); - - StringNBT bridge$stringNbt(String s); - - void bridge$dropItems(ServerPlayerEntity player, boolean all); - boolean bridge$processedDisconnect(); boolean bridge$isDisconnected(); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/server/management/PlayerInteractionManagerBridge.java b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/server/management/PlayerInteractionManagerBridge.java index bb6baca9..9b328831 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/server/management/PlayerInteractionManagerBridge.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/server/management/PlayerInteractionManagerBridge.java @@ -1,10 +1,5 @@ package io.izzel.arclight.common.bridge.server.management; -import net.minecraft.block.BlockState; -import net.minecraft.network.play.client.CPlayerDiggingPacket; -import net.minecraft.network.play.server.SPlayerDiggingPacket; -import net.minecraft.util.math.BlockPos; - public interface PlayerInteractionManagerBridge { boolean bridge$isFiredInteract(); @@ -14,8 +9,4 @@ public interface PlayerInteractionManagerBridge { boolean bridge$getInteractResult(); void bridge$setInteractResult(boolean b); - - SPlayerDiggingPacket bridge$diggingPacket(BlockPos pos, BlockState state, CPlayerDiggingPacket.Action action, boolean successful, String context); - - void bridge$creativeHarvestBlock(BlockPos pos, CPlayerDiggingPacket.Action action, String context); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/server/management/PlayerListBridge.java b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/server/management/PlayerListBridge.java index 36421dba..3be6399c 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/server/management/PlayerListBridge.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/server/management/PlayerListBridge.java @@ -1,14 +1,7 @@ package io.izzel.arclight.common.bridge.server.management; -import net.minecraft.entity.Entity; import com.mojang.authlib.GameProfile; import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.network.play.server.SRespawnPacket; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.GameType; -import net.minecraft.world.WorldType; -import net.minecraft.world.dimension.DimensionType; -import net.minecraft.world.server.ServerWorld; import net.minecraft.network.login.ServerLoginNetHandler; import org.bukkit.craftbukkit.v.CraftServer; @@ -24,10 +17,4 @@ public interface PlayerListBridge { CraftServer bridge$getCraftServer(); ServerPlayerEntity bridge$canPlayerLogin(SocketAddress socketAddress, GameProfile gameProfile, ServerLoginNetHandler handler); - - boolean bridge$worldNoCollision(ServerWorld world, Entity entity); - - void bridge$setSpawnPoint(ServerPlayerEntity player, BlockPos pos, boolean flag, DimensionType type, boolean flag1); - - SRespawnPacket bridge$respawnPacket(DimensionType type, long seed, WorldType worldType, GameType gameType); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/world/ExplosionBridge.java b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/world/ExplosionBridge.java index caedf4fb..1b003fc0 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/world/ExplosionBridge.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/world/ExplosionBridge.java @@ -14,6 +14,4 @@ public interface ExplosionBridge { Explosion.Mode bridge$getMode(); boolean bridge$wasCancelled(); - - float bridge$callBlockExplodeEvent(); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/world/server/ServerChunkProviderBridge.java b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/world/server/ServerChunkProviderBridge.java index baa59b9a..24cfc507 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/world/server/ServerChunkProviderBridge.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/world/server/ServerChunkProviderBridge.java @@ -1,9 +1,5 @@ package io.izzel.arclight.common.bridge.world.server; -import net.minecraft.entity.EntityClassification; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; import net.minecraft.world.server.ServerWorldLightManager; import java.io.IOException; @@ -19,6 +15,4 @@ public interface ServerChunkProviderBridge { boolean bridge$isChunkLoaded(int x, int z); ServerWorldLightManager bridge$getLightManager(); - - void bridge$worldNaturalSpawn(EntityClassification classification, World worldIn, Chunk chunk, BlockPos pos); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/world/storage/MapDataBridge.java b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/world/storage/MapDataBridge.java index a57cddea..d6eec6d6 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/world/storage/MapDataBridge.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/world/storage/MapDataBridge.java @@ -1,15 +1,8 @@ package io.izzel.arclight.common.bridge.world.storage; -import net.minecraft.world.World; -import net.minecraft.world.dimension.Dimension; -import net.minecraft.world.dimension.DimensionType; import org.bukkit.craftbukkit.v.map.CraftMapView; -import java.util.function.BiFunction; - public interface MapDataBridge { CraftMapView bridge$getMapView(); - - DimensionType bridge$dimension(int id, String suffix, String dir, BiFunction provider, boolean skyLight); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/JavaPluginLoaderMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/JavaPluginLoaderMixin.java index 33100cba..bbfbd5d1 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/JavaPluginLoaderMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/JavaPluginLoaderMixin.java @@ -73,12 +73,8 @@ public abstract class JavaPluginLoaderMixin implements JavaPluginLoaderBridge { Method[] publicMethods = listener.getClass().getMethods(); Method[] privateMethods = listener.getClass().getDeclaredMethods(); methods = new HashSet<>(publicMethods.length + privateMethods.length, 1.0f); - for (Method method : publicMethods) { - methods.add(method); - } - for (Method method : privateMethods) { - methods.add(method); - } + methods.addAll(Arrays.asList(publicMethods)); + methods.addAll(Arrays.asList(privateMethods)); } catch (NoClassDefFoundError e) { plugin.getLogger().severe("Plugin " + plugin.getDescription().getFullName() + " has failed to register events for " + listener.getClass() + " because " + e.getMessage() + " does not exist."); return ret; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/AbstractButtonBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/AbstractButtonBlockMixin.java index d82e7aa2..bf1f36ff 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/AbstractButtonBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/AbstractButtonBlockMixin.java @@ -4,9 +4,13 @@ import io.izzel.arclight.common.bridge.entity.EntityBridge; import net.minecraft.block.AbstractButtonBlock; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.state.BooleanProperty; +import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.World; +import net.minecraft.world.server.ServerWorld; import org.bukkit.Bukkit; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v.block.CraftBlock; @@ -18,9 +22,11 @@ import org.spongepowered.asm.mixin.Shadow; 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; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import java.util.List; +import java.util.Random; @Mixin(AbstractButtonBlock.class) public class AbstractButtonBlockMixin { @@ -71,4 +77,33 @@ public class AbstractButtonBlockMixin { ci.cancel(); } } + + @Inject(method = "onBlockActivated", cancellable = true, at = @At(value = "HEAD")) + public void arclight$blockRedstone1(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit, CallbackInfoReturnable cir) { + if (!state.get(POWERED)) { + boolean powered = state.get(POWERED); + Block block = CraftBlock.at(worldIn, pos); + int old = (powered) ? 15 : 0; + int current = (!powered) ? 15 : 0; + + BlockRedstoneEvent event = new BlockRedstoneEvent(block, old, current); + Bukkit.getPluginManager().callEvent(event); + + if ((event.getNewCurrent() > 0) == (powered)) { + cir.setReturnValue(true); + } + } + } + + @Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) + private void arclight$blockRedstone2(BlockState state, ServerWorld worldIn, BlockPos pos, Random rand, CallbackInfo ci) { + Block block = CraftBlock.at(worldIn, pos); + + BlockRedstoneEvent event = new BlockRedstoneEvent(block, 15, 0); + Bukkit.getPluginManager().callEvent(event); + + if (event.getNewCurrent() > 0) { + ci.cancel(); + } + } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CactusBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CactusBlockMixin.java index 2085b1e6..4fb10dc8 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CactusBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CactusBlockMixin.java @@ -5,11 +5,13 @@ import net.minecraft.block.CactusBlock; import net.minecraft.entity.Entity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraft.world.server.ServerWorld; import org.bukkit.craftbukkit.v.block.CraftBlock; import org.bukkit.craftbukkit.v.event.CraftEventFactory; 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.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(CactusBlock.class) @@ -24,4 +26,9 @@ public class CactusBlockMixin { private void arclight$cactusDamage2(BlockState state, World worldIn, BlockPos pos, Entity entityIn, CallbackInfo ci) { CraftEventFactory.blockDamage = null; } + + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z")) + private boolean arclight$blockGrow(ServerWorld serverWorld, BlockPos pos, BlockState state) { + return CraftEventFactory.handleBlockGrowEvent(serverWorld, pos, state); + } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CakeBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CakeBlockMixin.java similarity index 93% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CakeBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CakeBlockMixin.java index 360ffb5f..a7f769ff 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CakeBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CakeBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge; import net.minecraft.block.BlockState; @@ -14,7 +14,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(CakeBlock.class) -public class CakeBlockMixin_1_15 { +public class CakeBlockMixin { @Redirect(method = "func_226911_a_", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/FoodStats;addStats(IF)V")) private void arclight$eatCake(FoodStats foodStats, int foodLevelIn, float foodSaturationModifier, IWorld worldIn, BlockPos pos, BlockState state, PlayerEntity player) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CauldronBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CauldronBlockMixin.java similarity index 98% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CauldronBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CauldronBlockMixin.java index 62052c38..4085f13f 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CauldronBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CauldronBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import io.izzel.arclight.common.bridge.entity.EntityBridge; import net.minecraft.block.BlockState; @@ -26,7 +26,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(CauldronBlock.class) -public class CauldronBlockMixin_1_15 { +public class CauldronBlockMixin { @Inject(method = "onEntityCollision", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;extinguish()V")) public void arclight$extinguish(BlockState state, World worldIn, BlockPos pos, Entity entityIn, CallbackInfo ci) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/ChestBlock2Mixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/ChestBlock2Mixin.java similarity index 90% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/ChestBlock2Mixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/ChestBlock2Mixin.java index cf5ddb58..ba53ebe5 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/ChestBlock2Mixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/ChestBlock2Mixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import io.izzel.arclight.common.mod.util.ChestBlockDoubleInventoryHacks; import net.minecraft.inventory.DoubleSidedInventory; @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.Overwrite; import java.util.Optional; @Mixin(targets = "net/minecraft/block/ChestBlock$2") -public class ChestBlock2Mixin_1_15 { +public class ChestBlock2Mixin { /** * @author IzzelAliz diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/ChorusFlowerBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/ChorusFlowerBlockMixin.java similarity index 95% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/ChorusFlowerBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/ChorusFlowerBlockMixin.java index 0d343d75..88f64dfb 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/ChorusFlowerBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/ChorusFlowerBlockMixin.java @@ -1,6 +1,5 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; -import io.izzel.arclight.common.mixin.core.block.BlockMixin; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -23,7 +22,7 @@ import javax.annotation.Nullable; import java.util.Random; @Mixin(ChorusFlowerBlock.class) -public abstract class ChorusFlowerBlockMixin_1_15 extends BlockMixin { +public abstract class ChorusFlowerBlockMixin extends BlockMixin { // @formatter:off @Shadow @Final public static IntegerProperty AGE; @@ -74,7 +73,7 @@ public abstract class ChorusFlowerBlockMixin_1_15 extends BlockMixin { flag = true; } - if (flag && areAllNeighborsEmpty(worldIn, blockpos, (Direction) null) && worldIn.isAirBlock(pos.up(2))) { + if (flag && areAllNeighborsEmpty(worldIn, blockpos, null) && worldIn.isAirBlock(pos.up(2))) { if (CraftEventFactory.handleBlockSpreadEvent(worldIn, pos, pos.up(), state.with(ChorusFlowerBlock.AGE, i), 2)) { worldIn.setBlockState(pos, this.plantBlock.makeConnections(worldIn, pos), 2); this.placeGrownFlower(worldIn, blockpos, i); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CocoaBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CocoaBlockMixin.java similarity index 89% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CocoaBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CocoaBlockMixin.java index 216589a6..c066ce66 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CocoaBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CocoaBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import net.minecraft.block.BlockState; import net.minecraft.block.CocoaBlock; @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(CocoaBlock.class) -public class CocoaBlockMixin_1_15 { +public class CocoaBlockMixin { @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) public boolean arclight$blockGrow(ServerWorld world, BlockPos pos, BlockState newState, int flags) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CoralBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CoralBlockMixin.java similarity index 93% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CoralBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CoralBlockMixin.java index 46f98f6d..4e1b7518 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CoralBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CoralBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -16,7 +16,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.Random; @Mixin(CoralBlock.class) -public class CoralBlockMixin_1_15 { +public class CoralBlockMixin { // @formatter:off @Shadow @Final private Block deadBlock; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CoralFinBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CoralFinBlockMixin.java similarity index 93% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CoralFinBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CoralFinBlockMixin.java index b719b5fd..cf462861 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CoralFinBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CoralFinBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import net.minecraft.block.AbstractCoralPlantBlock; import net.minecraft.block.Block; @@ -17,7 +17,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.Random; @Mixin(CoralFinBlock.class) -public class CoralFinBlockMixin_1_15 { +public class CoralFinBlockMixin { // @formatter:off @Shadow @Final private Block deadBlock; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CoralPlantBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CoralPlantBlockMixin.java similarity index 93% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CoralPlantBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CoralPlantBlockMixin.java index f169d858..1c62f3ac 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CoralPlantBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CoralPlantBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import net.minecraft.block.AbstractCoralPlantBlock; import net.minecraft.block.Block; @@ -17,7 +17,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.Random; @Mixin(CoralPlantBlock.class) -public class CoralPlantBlockMixin_1_15 { +public class CoralPlantBlockMixin { // @formatter:off @Shadow @Final private Block deadBlock; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CoralWallFanBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CoralWallFanBlockMixin.java similarity index 93% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CoralWallFanBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CoralWallFanBlockMixin.java index 5eceb859..03773f04 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CoralWallFanBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CoralWallFanBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import net.minecraft.block.AbstractCoralPlantBlock; import net.minecraft.block.Block; @@ -18,7 +18,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.Random; @Mixin(CoralWallFanBlock.class) -public class CoralWallFanBlockMixin_1_15 { +public class CoralWallFanBlockMixin { // @formatter:off @Shadow @Final private Block deadBlock; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CropsBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CropsBlockMixin.java index a2c377f2..35b3f589 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CropsBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/CropsBlockMixin.java @@ -5,6 +5,7 @@ import net.minecraft.block.CropsBlock; import net.minecraft.entity.Entity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraft.world.server.ServerWorld; import net.minecraftforge.event.ForgeEventFactory; import org.bukkit.craftbukkit.v.event.CraftEventFactory; import org.bukkit.event.entity.EntityChangeBlockEvent; @@ -27,4 +28,9 @@ public class CropsBlockMixin { EntityChangeBlockEvent event = CraftEventFactory.callEntityChangeBlockEvent(entity, pos, state, result); return event.isCancelled(); } + + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) + public boolean arclight$blockGrowTick(ServerWorld world, BlockPos pos, BlockState newState, int flags) { + return CraftEventFactory.handleBlockGrowEvent(world, pos, newState, flags); + } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/FarmlandBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/FarmlandBlockMixin.java index eb37b70e..021d1ff5 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/FarmlandBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/FarmlandBlockMixin.java @@ -5,10 +5,12 @@ import net.minecraft.block.Blocks; import net.minecraft.block.FarmlandBlock; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraft.world.server.ServerWorld; import org.bukkit.craftbukkit.v.event.CraftEventFactory; 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.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(FarmlandBlock.class) @@ -20,4 +22,9 @@ public abstract class FarmlandBlockMixin extends BlockMixin { ci.cancel(); } } + + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) + public boolean arclight$moistureChange(ServerWorld world, BlockPos pos, BlockState newState, int flags) { + return CraftEventFactory.handleMoistureChangeEvent(world, pos, newState, flags); + } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/FireBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/FireBlockMixin.java index 24c8647d..f61035cb 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/FireBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/FireBlockMixin.java @@ -10,6 +10,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraft.world.World; +import net.minecraft.world.server.ServerWorld; import org.bukkit.Bukkit; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v.block.CraftBlock; @@ -35,6 +36,25 @@ public abstract class FireBlockMixin implements FireBlockBridge { @Shadow @Final private Object2IntMap flammabilities; // @formatter:on + @Redirect(method = "tick", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) + public boolean arclight$fireSpread(ServerWorld world, BlockPos mutablePos, BlockState newState, int flags, + BlockState state, ServerWorld worldIn, BlockPos pos) { + if (world.getBlockState(mutablePos).getBlock() != Blocks.FIRE) { + if (!CraftEventFactory.callBlockIgniteEvent(world, mutablePos, pos).isCancelled()) { + return CraftEventFactory.handleBlockSpreadEvent(world, pos, mutablePos, newState, flags); + } + } + return false; + } + + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;removeBlock(Lnet/minecraft/util/math/BlockPos;Z)Z")) + public boolean arclight$extinguish1(ServerWorld world, BlockPos pos, boolean isMoving) { + if (!CraftEventFactory.callBlockFadeEvent(world, pos, Blocks.AIR.getDefaultState()).isCancelled()) { + world.removeBlock(pos, isMoving); + } + return false; + } + @Inject(method = "tryCatchFire", cancellable = true, at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/world/World;getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;")) public void arclight$blockBurn(World worldIn, BlockPos pos, int chance, Random random, int age, Direction face, CallbackInfo ci) { Block theBlock = CraftBlock.at(worldIn, pos); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/GrassBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/GrassBlockMixin.java similarity index 89% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/GrassBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/GrassBlockMixin.java index cf211075..2c42b23b 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/GrassBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/GrassBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import net.minecraft.block.BlockState; import net.minecraft.block.GrassBlock; @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(GrassBlock.class) -public class GrassBlockMixin_1_15 { +public class GrassBlockMixin { @Redirect(method = "grow", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) public boolean arclight$blockGrow(ServerWorld world, BlockPos pos, BlockState newState, int flags) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/KelpTopBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/KelpTopBlockMixin.java similarity index 89% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/KelpTopBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/KelpTopBlockMixin.java index 3d6b32a1..3b21418f 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/KelpTopBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/KelpTopBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import net.minecraft.block.BlockState; import net.minecraft.block.KelpTopBlock; @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(KelpTopBlock.class) -public class KelpTopBlockMixin_1_15 { +public class KelpTopBlockMixin { @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z")) public boolean arclight$blockGrow(ServerWorld world, BlockPos pos, BlockState state) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/LeavesBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/LeavesBlockMixin.java similarity index 93% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/LeavesBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/LeavesBlockMixin.java index 503929e4..27f06c0f 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/LeavesBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/LeavesBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import net.minecraft.block.BlockState; import net.minecraft.block.LeavesBlock; @@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.Random; @Mixin(LeavesBlock.class) -public class LeavesBlockMixin_1_15 { +public class LeavesBlockMixin { @Inject(method = "randomTick", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/block/LeavesBlock;spawnDrops(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)V")) public void arclight$leavesDecay(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/LeverBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/LeverBlockMixin.java similarity index 95% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/LeverBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/LeverBlockMixin.java index d0b47879..b1e62643 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/LeverBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/LeverBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import net.minecraft.block.BlockState; import net.minecraft.block.LeverBlock; @@ -20,7 +20,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(LeverBlock.class) -public class LeverBlockMixin_1_15 { +public class LeverBlockMixin { // @formatter:off @Shadow @Final public static BooleanProperty POWERED; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/LilyPadBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/LilyPadBlockMixin.java similarity index 91% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/LilyPadBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/LilyPadBlockMixin.java index 62153816..3c640f79 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/LilyPadBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/LilyPadBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(LilyPadBlock.class) -public class LilyPadBlockMixin_1_15 { +public class LilyPadBlockMixin { @Inject(method = "onEntityCollision", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;destroyBlock(Lnet/minecraft/util/math/BlockPos;ZLnet/minecraft/entity/Entity;)Z")) public void arclight$entityChangeBlock(BlockState state, World worldIn, BlockPos pos, Entity entityIn, CallbackInfo ci) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/MushroomBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/MushroomBlockMixin.java similarity index 90% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/MushroomBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/MushroomBlockMixin.java index 8c90b3fe..de2dcb34 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/MushroomBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/MushroomBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import net.minecraft.block.BlockState; import net.minecraft.block.MushroomBlock; @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(MushroomBlock.class) -public class MushroomBlockMixin_1_15 { +public class MushroomBlockMixin { @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) public boolean arclight$blockSpread(ServerWorld world, BlockPos toPos, BlockState newState, int flags, BlockState state, ServerWorld worldIn, BlockPos fromPos) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/NetherPortalBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/NetherPortalBlockMixin.java index 1ca19d68..272e6cb7 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/NetherPortalBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/NetherPortalBlockMixin.java @@ -2,19 +2,27 @@ package io.izzel.arclight.common.mixin.core.block; import io.izzel.arclight.common.bridge.block.NetherPortalBlockBridge; import io.izzel.arclight.common.bridge.entity.EntityBridge; +import io.izzel.arclight.common.bridge.entity.EntityTypeBridge; import io.izzel.arclight.common.bridge.world.WorldBridge; import net.minecraft.block.BlockState; import net.minecraft.block.NetherPortalBlock; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.SpawnReason; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; import net.minecraft.world.IWorld; import net.minecraft.world.World; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.EntityPortalEnterEvent; 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.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @@ -22,6 +30,11 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin(NetherPortalBlock.class) public class NetherPortalBlockMixin { + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/EntityType;spawn(Lnet/minecraft/world/World;Lnet/minecraft/nbt/CompoundNBT;Lnet/minecraft/util/text/ITextComponent;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/SpawnReason;ZZ)Lnet/minecraft/entity/Entity;")) + public Entity arclight$spawn(EntityType entityType, World worldIn, CompoundNBT compound, ITextComponent customName, PlayerEntity playerIn, BlockPos pos, SpawnReason reason, boolean flag, boolean flag1) { + return ((EntityTypeBridge) entityType).bridge$spawnCreature(worldIn, compound, customName, playerIn, pos, reason, flag, flag1, CreatureSpawnEvent.SpawnReason.NETHER_PORTAL); + } + @Inject(method = "trySpawnPortal", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/block/NetherPortalBlock$Size;placePortalBlocks()V")) public void arclight$spawnPortal(IWorld worldIn, BlockPos pos, CallbackInfoReturnable cir, NetherPortalBlock.Size size) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/NetherWartBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/NetherWartBlockMixin.java similarity index 89% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/NetherWartBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/NetherWartBlockMixin.java index 65bc7a02..e54c9e65 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/NetherWartBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/NetherWartBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import net.minecraft.block.BlockState; import net.minecraft.block.NetherWartBlock; @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(NetherWartBlock.class) -public class NetherWartBlockMixin_1_15 { +public class NetherWartBlockMixin { @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) public boolean arclight$cropGrow(ServerWorld world, BlockPos pos, BlockState newState, int flags) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/NoteBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/NoteBlockMixin.java index f5f54370..86b11ce4 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/NoteBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/NoteBlockMixin.java @@ -21,6 +21,11 @@ public abstract class NoteBlockMixin implements NoteBlockBridge { @Shadow protected abstract void triggerNote(World worldIn, BlockPos pos); // @formatter:on + @Redirect(method = "onBlockActivated", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/NoteBlock;triggerNote(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)V")) + public void arclight$callNote2(NoteBlock noteBlock, World worldIn, BlockPos pos, BlockState blockState) { + this.bridge$play(worldIn, pos, blockState); + } + @Redirect(method = "neighborChanged", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/NoteBlock;triggerNote(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)V")) public void arclight$callNote1(NoteBlock noteBlock, World worldIn, BlockPos pos, BlockState blockState) { this.play(worldIn, pos, blockState); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/ObserverBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/ObserverBlockMixin.java similarity index 94% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/ObserverBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/ObserverBlockMixin.java index ab34eca8..16161d07 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/ObserverBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/ObserverBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import net.minecraft.block.BlockState; import net.minecraft.block.ObserverBlock; @@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.Random; @Mixin(ObserverBlock.class) -public class ObserverBlockMixin_1_15 { +public class ObserverBlockMixin { @Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) public void arclight$redstoneChange1(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/PistonBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/PistonBlockMixin.java index 55b05334..594901b0 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/PistonBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/PistonBlockMixin.java @@ -2,13 +2,17 @@ package io.izzel.arclight.common.mixin.core.block; import com.google.common.collect.ImmutableList; import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.block.PistonBlock; +import net.minecraft.block.PistonBlockStructureHelper; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import org.bukkit.Bukkit; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v.block.CraftBlock; +import org.bukkit.event.block.BlockPistonEvent; +import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonRetractEvent; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -16,8 +20,12 @@ import org.spongepowered.asm.mixin.Shadow; 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; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +import java.util.AbstractList; +import java.util.List; + @Mixin(PistonBlock.class) public class PistonBlockMixin { @@ -36,4 +44,54 @@ public class PistonBlockMixin { } } } + + @Inject(method = "doMove", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, + at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/block/PistonBlockStructureHelper;getBlocksToDestroy()Ljava/util/List;")) + public void arclight$pistonAction(World worldIn, BlockPos pos, Direction directionIn, boolean extending, CallbackInfoReturnable cir, + BlockPos blockPos, PistonBlockStructureHelper helper) { + final Block craftBlock = CraftBlock.at(worldIn, pos); + + final List moved = helper.getBlocksToMove(); + final List broken = helper.getBlocksToDestroy(); + + class BlockList extends AbstractList { + + @Override + public int size() { + return moved.size() + broken.size(); + } + + @Override + public org.bukkit.block.Block get(int index) { + if (index >= size() || index < 0) { + throw new ArrayIndexOutOfBoundsException(index); + } + BlockPos pos = index < moved.size() ? moved.get(index) : broken.get(index - moved.size()); + return craftBlock.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); + } + } + + List blocks = new BlockList(); + + Direction direction = extending ? directionIn : directionIn.getOpposite(); + BlockPistonEvent event; + if (extending) { + event = new BlockPistonExtendEvent(craftBlock, blocks, CraftBlock.notchToBlockFace(direction)); + } else { + event = new BlockPistonRetractEvent(craftBlock, blocks, CraftBlock.notchToBlockFace(direction)); + } + Bukkit.getPluginManager().callEvent(event); + + if (event.isCancelled()) { + for (BlockPos b : broken) { + worldIn.notifyBlockUpdate(b, Blocks.AIR.getDefaultState(), worldIn.getBlockState(b), 3); + } + for (BlockPos b : moved) { + worldIn.notifyBlockUpdate(b, Blocks.AIR.getDefaultState(), worldIn.getBlockState(b), 3); + b = b.offset(direction); + worldIn.notifyBlockUpdate(b, Blocks.AIR.getDefaultState(), worldIn.getBlockState(b), 3); + } + cir.setReturnValue(false); + } + } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/RedstoneDiodeBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/RedstoneDiodeBlockMixin.java similarity index 93% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/RedstoneDiodeBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/RedstoneDiodeBlockMixin.java index 7b1a96bd..c889d21f 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/RedstoneDiodeBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/RedstoneDiodeBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import net.minecraft.block.BlockState; import net.minecraft.block.RedstoneDiodeBlock; @@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.Random; @Mixin(RedstoneDiodeBlock.class) -public class RedstoneDiodeBlockMixin_1_15 { +public class RedstoneDiodeBlockMixin { @Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) public void arclight$turnOff(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/RedstoneLampBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/RedstoneLampBlockMixin.java index 97204ac1..2ef4c206 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/RedstoneLampBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/RedstoneLampBlockMixin.java @@ -5,15 +5,25 @@ import net.minecraft.block.BlockState; import net.minecraft.block.RedstoneLampBlock; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraft.world.server.ServerWorld; import org.bukkit.craftbukkit.v.event.CraftEventFactory; 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 java.util.Random; + @Mixin(RedstoneLampBlock.class) public class RedstoneLampBlockMixin { + @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) + private void arclight$redstoneChange(BlockState state, ServerWorld worldIn, BlockPos pos, Random rand, CallbackInfo ci) { + if (CraftEventFactory.callRedstoneChange(worldIn, pos, 15, 0).getNewCurrent() != 0) { + ci.cancel(); + } + } + @Inject(method = "neighborChanged", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) public void arclight$blockRedstone(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving, CallbackInfo ci) { if (CraftEventFactory.callRedstoneChange(worldIn, pos, 0, 15).getNewCurrent() != 15) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/RedstoneOreBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/RedstoneOreBlockMixin.java similarity index 97% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/RedstoneOreBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/RedstoneOreBlockMixin.java index baeb1e0b..cc49fb62 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/RedstoneOreBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/RedstoneOreBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import io.izzel.arclight.common.bridge.entity.EntityBridge; import net.minecraft.block.BlockState; @@ -26,7 +26,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import java.util.Random; @Mixin(RedstoneOreBlock.class) -public abstract class RedstoneOreBlockMixin_1_15 { +public abstract class RedstoneOreBlockMixin { // @formatter:off @Shadow private static void activate(BlockState p_196500_0_, World p_196500_1_, BlockPos p_196500_2_) { } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/ScaffoldingBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/ScaffoldingBlockMixin.java similarity index 92% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/ScaffoldingBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/ScaffoldingBlockMixin.java index 82852e1e..9b694012 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/ScaffoldingBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/ScaffoldingBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -14,7 +14,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; import java.util.Random; @Mixin(ScaffoldingBlock.class) -public class ScaffoldingBlockMixin_1_15 { +public class ScaffoldingBlockMixin { @Redirect(method = "tick", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/block/BlockState;get(Lnet/minecraft/state/IProperty;)Ljava/lang/Comparable;")) public Comparable arclight$blockFade(BlockState state, IProperty property, BlockState blockState, ServerWorld worldIn, BlockPos pos, Random random) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/SnowBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/SnowBlockMixin.java similarity index 92% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/SnowBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/SnowBlockMixin.java index 7a689444..b84a29df 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/SnowBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/SnowBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -14,7 +14,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.Random; @Mixin(SnowBlock.class) -public class SnowBlockMixin_1_15 { +public class SnowBlockMixin { @Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/block/SnowBlock;spawnDrops(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)V")) public void arclight$blockFade(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/SpreadableSnowyDirtBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/SpreadableSnowyDirtBlockMixin.java similarity index 93% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/SpreadableSnowyDirtBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/SpreadableSnowyDirtBlockMixin.java index f46eab27..7f0dba61 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/SpreadableSnowyDirtBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/SpreadableSnowyDirtBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.Random; @Mixin(SpreadableSnowyDirtBlock.class) -public class SpreadableSnowyDirtBlockMixin_1_15 { +public class SpreadableSnowyDirtBlockMixin { @Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z")) public void arclight$blockFade(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/StemBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/StemBlockMixin.java similarity index 96% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/StemBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/StemBlockMixin.java index 60d468d9..6b4a3c47 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/StemBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/StemBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import net.minecraft.block.BlockState; import net.minecraft.block.StemBlock; @@ -14,7 +14,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.Random; @Mixin(StemBlock.class) -public class StemBlockMixin_1_15 { +public class StemBlockMixin { private transient boolean arclight$success = false; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/SugarCaneBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/SugarCaneBlockMixin.java similarity index 74% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/SugarCaneBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/SugarCaneBlockMixin.java index 65cb0355..711f1849 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/SugarCaneBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/SugarCaneBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import net.minecraft.block.BlockState; import net.minecraft.block.SugarCaneBlock; @@ -10,9 +10,9 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(SugarCaneBlock.class) -public class SugarCaneBlockMixin_1_15 { +public class SugarCaneBlockMixin { - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z")) + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z")) public boolean arclight$cropGrow(ServerWorld world, BlockPos pos, BlockState state) { return CraftEventFactory.handleBlockGrowEvent(world, pos, state); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/SweetBerryBushBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/SweetBerryBushBlockMixin.java similarity index 94% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/SweetBerryBushBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/SweetBerryBushBlockMixin.java index 358894fd..eec1ab84 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/SweetBerryBushBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/SweetBerryBushBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import net.minecraft.block.BlockState; import net.minecraft.block.SweetBerryBushBlock; @@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(SweetBerryBushBlock.class) -public class SweetBerryBushBlockMixin_1_15 { +public class SweetBerryBushBlockMixin { @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) public boolean arclight$cropGrow(ServerWorld world, BlockPos pos, BlockState newState, int flags) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/TripWireBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/TripWireBlockMixin.java index 35f775f7..c99d757f 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/TripWireBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/TripWireBlockMixin.java @@ -39,7 +39,7 @@ public abstract class TripWireBlockMixin extends BlockMixin { BlockState blockstate = worldIn.getBlockState(pos); boolean flag = blockstate.get(POWERED); boolean flag1 = false; - List list = worldIn.getEntitiesWithinAABBExcludingEntity((Entity) null, blockstate.getShape(worldIn, pos).getBoundingBox().offset(pos)); + List list = worldIn.getEntitiesWithinAABBExcludingEntity(null, blockstate.getShape(worldIn, pos).getBoundingBox().offset(pos)); if (!list.isEmpty()) { for (Entity entity : list) { if (!entity.doesEntityNotTriggerPressurePlate()) { @@ -49,7 +49,7 @@ public abstract class TripWireBlockMixin extends BlockMixin { } } - if (flag != flag1 && flag1 && (Boolean) blockstate.get(TripWireBlock.ATTACHED)) { + if (flag != flag1 && flag1 && blockstate.get(TripWireBlock.ATTACHED)) { org.bukkit.block.Block block = CraftBlock.at(worldIn, pos); boolean allowed = false; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/TurtleEggBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/TurtleEggBlockMixin.java index a72a329e..1758dd03 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/TurtleEggBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/TurtleEggBlockMixin.java @@ -1,25 +1,61 @@ package io.izzel.arclight.common.mixin.core.block; import io.izzel.arclight.common.bridge.entity.EntityBridge; +import io.izzel.arclight.common.bridge.world.WorldBridge; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.block.TurtleEggBlock; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.state.IntegerProperty; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraft.world.server.ServerWorld; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v.block.CraftBlock; import org.bukkit.craftbukkit.v.event.CraftEventFactory; import org.bukkit.event.Cancellable; import org.bukkit.event.block.Action; +import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.EntityInteractEvent; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +import java.util.Random; @Mixin(TurtleEggBlock.class) public class TurtleEggBlockMixin { + @Shadow @Final public static IntegerProperty HATCH; + + @Inject(method = "tick", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, + at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/server/ServerWorld;playSound(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/SoundEvent;Lnet/minecraft/util/SoundCategory;FF)V")) + private void arclight$hatch(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci, int i) { + if (!CraftEventFactory.handleBlockGrowEvent(worldIn, pos, state.with(HATCH, i + 1), 2)) { + ci.cancel(); + } + } + + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) + private boolean arclight$handledHatch(ServerWorld world, BlockPos pos, BlockState newState, int flags) { + return true; + } + + @Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/world/server/ServerWorld;playSound(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/SoundEvent;Lnet/minecraft/util/SoundCategory;FF)V")) + private void arclight$born(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci) { + if (CraftEventFactory.callBlockFadeEvent(worldIn, pos, Blocks.AIR.getDefaultState()).isCancelled()) { + ci.cancel(); + } else { + ((WorldBridge) worldIn).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.EGG); + } + } + @Inject(method = "tryTrample", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/block/TurtleEggBlock;removeOneEgg(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)V")) public void arclight$stepOn(World world, BlockPos pos, Entity entity, int i, CallbackInfo ci) { Cancellable cancellable; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/VineBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/VineBlockMixin.java similarity index 97% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/VineBlockMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/VineBlockMixin.java index ee1dc504..2fc290bd 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/VineBlockMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/VineBlockMixin.java @@ -1,6 +1,5 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; -import io.izzel.arclight.common.mixin.core.block.BlockMixin; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.VineBlock; @@ -18,7 +17,7 @@ import org.spongepowered.asm.mixin.Shadow; import java.util.Random; @Mixin(VineBlock.class) -public abstract class VineBlockMixin_1_15 extends BlockMixin { +public abstract class VineBlockMixin extends BlockMixin { // @formatter:off @Shadow protected abstract BlockState func_196545_h(BlockState p_196545_1_, IBlockReader p_196545_2_, BlockPos p_196545_3_); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/WitherRoseBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/WitherRoseBlockMixin.java similarity index 95% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/WitherRoseBlockMixin.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/WitherRoseBlockMixin.java index 0f6bd962..1ec7e6a9 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/WitherRoseBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/block/WitherRoseBlockMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.block; +package io.izzel.arclight.common.mixin.core.block; import io.izzel.arclight.common.bridge.entity.LivingEntityBridge; import net.minecraft.block.BlockState; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/command/impl/TeleportCommandMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/command/impl/TeleportCommandMixin.java similarity index 97% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/command/impl/TeleportCommandMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/command/impl/TeleportCommandMixin.java index 1fd6f5f5..5aea2f3e 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/command/impl/TeleportCommandMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/command/impl/TeleportCommandMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.command.impl; +package io.izzel.arclight.common.mixin.core.command.impl; import io.izzel.arclight.common.bridge.entity.EntityBridge; import io.izzel.arclight.common.bridge.network.play.ServerPlayNetHandlerBridge; @@ -26,7 +26,7 @@ import javax.annotation.Nullable; import java.util.Set; @Mixin(TeleportCommand.class) -public class TeleportCommandMixin_1_15 { +public class TeleportCommandMixin { /** * @author IzzelAliz diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/command/impl/TimeCommandMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/command/impl/TimeCommandMixin.java similarity index 96% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/command/impl/TimeCommandMixin.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/command/impl/TimeCommandMixin.java index 2831c2dc..7592421e 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/command/impl/TimeCommandMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/command/impl/TimeCommandMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.command.impl; +package io.izzel.arclight.common.mixin.core.command.impl; import io.izzel.arclight.common.bridge.world.server.ServerWorldBridge; import net.minecraft.command.impl.TimeCommand; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/enchantment/FrostWalkerEnchantmentMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/enchantment/FrostWalkerEnchantmentMixin.java similarity index 96% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/enchantment/FrostWalkerEnchantmentMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/enchantment/FrostWalkerEnchantmentMixin.java index c1816219..8824ee95 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/enchantment/FrostWalkerEnchantmentMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/enchantment/FrostWalkerEnchantmentMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.enchantment; +package io.izzel.arclight.common.mixin.core.enchantment; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -18,7 +18,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; @Mixin(FrostWalkerEnchantment.class) -public class FrostWalkerEnchantmentMixin_1_15 { +public class FrostWalkerEnchantmentMixin { /** * @author IzzelAliz diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/AreaEffectCloudEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/AreaEffectCloudEntityMixin.java index 814a3452..3b629a7e 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/AreaEffectCloudEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/AreaEffectCloudEntityMixin.java @@ -1,6 +1,7 @@ package io.izzel.arclight.common.mixin.core.entity; import com.google.common.collect.Lists; +import io.izzel.arclight.common.bridge.entity.AreaEffectCloudEntityBridge; import io.izzel.arclight.common.bridge.entity.LivingEntityBridge; import net.minecraft.entity.AreaEffectCloudEntity; import net.minecraft.entity.Entity; @@ -24,7 +25,6 @@ import org.spongepowered.asm.mixin.Interface; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; -import io.izzel.arclight.common.bridge.entity.AreaEffectCloudEntityBridge; import javax.annotation.Nullable; import java.util.Iterator; @@ -80,7 +80,7 @@ public abstract class AreaEffectCloudEntityMixin extends EntityMixin implements int k = j >> 16 & 255; int l = j >> 8 & 255; int i1 = j & 255; - this.world.addOptionalParticle(iparticledata, this.posX + (double) f3, this.posY, this.posZ + (double) f4, (double) ((float) k / 255.0F), (double) ((float) l / 255.0F), (double) ((float) i1 / 255.0F)); + this.world.addOptionalParticle(iparticledata, this.posX + (double) f3, this.posY, this.posZ + (double) f4, (float) k / 255.0F, (float) l / 255.0F, (float) i1 / 255.0F); } else { this.world.addOptionalParticle(iparticledata, this.posX + (double) f3, this.posY, this.posZ + (double) f4, 0.0D, 0.0D, 0.0D); } @@ -99,9 +99,9 @@ public abstract class AreaEffectCloudEntityMixin extends EntityMixin implements int i2 = l1 >> 16 & 255; int j2 = l1 >> 8 & 255; int j1 = l1 & 255; - this.world.addOptionalParticle(iparticledata, this.posX + (double) f8, this.posY, this.posZ + (double) f9, (double) ((float) i2 / 255.0F), (double) ((float) j2 / 255.0F), (double) ((float) j1 / 255.0F)); + this.world.addOptionalParticle(iparticledata, this.posX + (double) f8, this.posY, this.posZ + (double) f9, (float) i2 / 255.0F, (float) j2 / 255.0F, (float) j1 / 255.0F); } else { - this.world.addOptionalParticle(iparticledata, this.posX + (double) f8, this.posY, this.posZ + (double) f9, (0.5D - this.rand.nextDouble()) * 0.15D, (double) 0.01F, (0.5D - this.rand.nextDouble()) * 0.15D); + this.world.addOptionalParticle(iparticledata, this.posX + (double) f8, this.posY, this.posZ + (double) f9, (0.5D - this.rand.nextDouble()) * 0.15D, 0.01F, (0.5D - this.rand.nextDouble()) * 0.15D); } } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/EntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/EntityMixin.java index 799dcf1b..de14f30f 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/EntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/EntityMixin.java @@ -9,6 +9,7 @@ import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge; import io.izzel.arclight.common.bridge.world.WorldBridge; import io.izzel.arclight.common.bridge.world.storage.SaveHandlerBridge; import io.izzel.arclight.common.mod.util.ArclightCaptures; +import net.minecraft.block.pattern.BlockPattern; import net.minecraft.command.CommandSource; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; @@ -27,16 +28,22 @@ import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.scoreboard.Team; import net.minecraft.server.MinecraftServer; import net.minecraft.util.DamageSource; +import net.minecraft.util.Direction; import net.minecraft.util.SoundEvent; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.util.text.ITextComponent; import net.minecraft.world.World; import net.minecraft.world.dimension.DimensionType; +import net.minecraft.world.gen.Heightmap; import net.minecraft.world.server.ServerWorld; +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.util.ITeleporter; import org.bukkit.Bukkit; import org.bukkit.Server; +import org.bukkit.block.BlockFace; import org.bukkit.command.CommandSender; import org.bukkit.craftbukkit.v.CraftServer; import org.bukkit.craftbukkit.v.CraftWorld; @@ -50,15 +57,18 @@ import org.bukkit.event.entity.EntityCombustByBlockEvent; import org.bukkit.event.entity.EntityCombustByEntityEvent; import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityDropItemEvent; +import org.bukkit.event.entity.EntityPortalEvent; import org.bukkit.event.entity.EntityPoseChangeEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.vehicle.VehicleBlockCollisionEvent; import org.bukkit.event.vehicle.VehicleEnterEvent; import org.bukkit.event.vehicle.VehicleExitEvent; import org.bukkit.plugin.PluginManager; import org.bukkit.projectiles.ProjectileSource; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -166,6 +176,14 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, @Shadow @Nullable public abstract Entity changeDimension(DimensionType destination); @Shadow public abstract boolean isRidingSameEntity(Entity entityIn); @Shadow public abstract boolean isInvulnerable(); + @Shadow public abstract double getPosX(); + @Shadow public abstract double getPosZ(); + @Shadow public abstract Vec3d getLastPortalVec(); + @Shadow public abstract double getPosY(); + @Shadow public abstract Direction getTeleportDirection(); + @Shadow public abstract double getPosYEye(); + @Shadow public abstract Vec3d getPositionVec(); + @Shadow(remap = false) public abstract void revive(); // @formatter:on private static final int CURRENT_LEVEL = 2; @@ -729,4 +747,136 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, return teleportTo(type, blockPos); } + @Inject(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;canTriggerWalking()Z")) + private void arclight$move$blockCollide(MoverType typeIn, Vec3d pos, CallbackInfo ci) { + if (collidedHorizontally && this.bridge$getBukkitEntity() instanceof Vehicle) { + Vehicle vehicle = (Vehicle) this.bridge$getBukkitEntity(); + org.bukkit.block.Block block = ((WorldBridge) this.world).bridge$getWorld().getBlockAt(MathHelper.floor(this.getPosX()), MathHelper.floor(this.getPosY()), MathHelper.floor(this.getPosZ())); + Vec3d vec3d = this.getAllowedMovement(pos); + if (pos.x > vec3d.x) { + block = block.getRelative(BlockFace.EAST); + } else if (vec3d.x < vec3d.x) { + block = block.getRelative(BlockFace.WEST); + } else if (pos.z > vec3d.z) { + block = block.getRelative(BlockFace.SOUTH); + } else if (pos.z < vec3d.z) { + block = block.getRelative(BlockFace.NORTH); + } + + if (block.getType() != org.bukkit.Material.AIR) { + VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, block); + Bukkit.getPluginManager().callEvent(event); + } + } + } + + /** + * @author IzzelAliz + * @reason + */ + @Overwrite(remap = false) + @Nullable + public Entity changeDimension(DimensionType destination, ITeleporter teleporter) { + BlockPos location = ((InternalEntityBridge) this).internal$capturedPos(); + if (!ForgeHooks.onTravelToDimension((Entity) (Object) this, destination)) return null; + if (!this.world.isRemote && !this.removed) { + this.world.getProfiler().startSection("changeDimension"); + MinecraftServer minecraftserver = this.getServer(); + DimensionType dimensiontype = this.dimension; + ServerWorld serverworld = minecraftserver.getWorld(dimensiontype); + ServerWorld[] serverworld1 = new ServerWorld[]{minecraftserver.getWorld(destination)}; + + if (serverworld1 == null) { + return null; + } + //this.dimension = destination; + //this.detach(); + this.world.getProfiler().startSection("reposition"); + Entity transportedEntity = teleporter.placeEntity((Entity) (Object) this, serverworld, serverworld1[0], this.rotationYaw, spawnPortal -> { //Forge: Start vanilla logic + Vec3d vec3d = this.getMotion(); + float f = 0.0F; + BlockPos blockpos = location; + if (blockpos == null) { + if (dimensiontype == DimensionType.THE_END && destination == DimensionType.OVERWORLD) { + EntityPortalEvent event = CraftEventFactory.callEntityPortalEvent((Entity) (Object) this, serverworld1[0], serverworld1[0].getHeight(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, serverworld1[0].getSpawnPoint()), 0); + if (event == null) { + return null; + } + serverworld1[0] = ((CraftWorld) event.getTo().getWorld()).getHandle(); + blockpos = new BlockPos(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); + //blockpos = serverworld1[0].getHeight(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, serverworld1[0].getSpawnPoint()); + } else if (destination == DimensionType.THE_END) { + EntityPortalEvent event = CraftEventFactory.callEntityPortalEvent((Entity) (Object) this, serverworld1[0], (serverworld1[0].getSpawnCoordinate() != null) ? serverworld1[0].getSpawnCoordinate() : serverworld1[0].getSpawnPoint(), 0); + if (event == null) { + return null; + } + serverworld1[0] = ((CraftWorld) event.getTo().getWorld()).getHandle(); + blockpos = new BlockPos(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); + //blockpos = serverworld1[0].getSpawnCoordinate(); + } else { + double movementFactor = serverworld.getDimension().getMovementFactor() / serverworld1[0].getDimension().getMovementFactor(); + double d0 = this.getPosX() * movementFactor; + double d1 = this.getPosZ() * movementFactor; + + double d3 = Math.min(-2.9999872E7D, serverworld1[0].getWorldBorder().minX() + 16.0D); + double d4 = Math.min(-2.9999872E7D, serverworld1[0].getWorldBorder().minZ() + 16.0D); + double d5 = Math.min(2.9999872E7D, serverworld1[0].getWorldBorder().maxX() - 16.0D); + double d6 = Math.min(2.9999872E7D, serverworld1[0].getWorldBorder().maxZ() - 16.0D); + d0 = MathHelper.clamp(d0, d3, d5); + d1 = MathHelper.clamp(d1, d4, d6); + Vec3d vec3d1 = this.getLastPortalVec(); + blockpos = new BlockPos(d0, this.getPosY(), d1); + + EntityPortalEvent event2 = CraftEventFactory.callEntityPortalEvent((Entity) (Object) this, serverworld1[0], blockpos, 128); + if (event2 == null) { + return null; + } + serverworld1[0] = ((CraftWorld) event2.getTo().getWorld()).getHandle(); + blockpos = new BlockPos(event2.getTo().getX(), event2.getTo().getY(), event2.getTo().getZ()); + int searchRadius = event2.getSearchRadius(); + // todo 实现 radius + + if (spawnPortal) { + BlockPattern.PortalInfo blockpattern$portalinfo = serverworld1[0].getDefaultTeleporter().placeInExistingPortal(blockpos, vec3d, this.getTeleportDirection(), vec3d1.x, vec3d1.y, (Object) this instanceof PlayerEntity); + if (blockpattern$portalinfo == null) { + return null; + } + + blockpos = new BlockPos(blockpattern$portalinfo.pos); + vec3d = blockpattern$portalinfo.motion; + f = (float) blockpattern$portalinfo.rotation; + } + } + } + + this.dimension = destination; + this.detach(); + + this.world.getProfiler().endStartSection("reloading"); + Entity entity = this.getType().create(serverworld1[0]); + if (entity != null) { + entity.copyDataFromOld((Entity) (Object) this); + entity.moveToBlockPosAndAngles(blockpos, entity.rotationYaw + f, entity.rotationPitch); + entity.setMotion(vec3d); + serverworld1[0].addFromAnotherDimension(entity); + + ((InternalEntityBridge) this).internal$getBukkitEntity().setHandle(entity); + ((EntityBridge) entity).bridge$setBukkitEntity(((InternalEntityBridge) this).internal$getBukkitEntity()); + if ((Object) this instanceof MobEntity) { + ((MobEntity) (Object) this).clearLeashed(true, false); + } + } + return entity; + });//Forge: End vanilla logic + + this.remove(false); + this.world.getProfiler().endSection(); + serverworld.resetUpdateEntityTick(); + serverworld1[0].resetUpdateEntityTick(); + this.world.getProfiler().endSection(); + return transportedEntity; + } else { + return null; + } + } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/LivingEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/LivingEntityMixin.java index 1cca13ed..eee8e87a 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/LivingEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/LivingEntityMixin.java @@ -1,6 +1,9 @@ package io.izzel.arclight.common.mixin.core.entity; import com.google.common.base.Function; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.mojang.datafixers.util.Either; import io.izzel.arclight.common.bridge.entity.LivingEntityBridge; import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge; import io.izzel.arclight.common.bridge.world.WorldBridge; @@ -12,6 +15,7 @@ import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AbstractAttributeMap; import net.minecraft.entity.ai.attributes.IAttribute; import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.item.ExperienceOrbEntity; import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.entity.passive.TameableEntity; @@ -25,6 +29,7 @@ import net.minecraft.nbt.FloatNBT; import net.minecraft.nbt.INBT; import net.minecraft.nbt.IntNBT; import net.minecraft.network.datasync.DataParameter; +import net.minecraft.particles.ParticleTypes; import net.minecraft.potion.Effect; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; @@ -39,7 +44,9 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.world.GameRules; import net.minecraft.world.World; import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeEventFactory; +import net.minecraftforge.event.entity.living.PotionEvent; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.craftbukkit.v.attribute.CraftAttributeMap; @@ -67,6 +74,10 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import javax.annotation.Nullable; import java.util.Collection; +import java.util.ConcurrentModificationException; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.Random; @@ -143,7 +154,16 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt @Shadow public abstract ItemStack getHeldItemOffhand(); @Shadow public abstract Random getRNG(); @Shadow public abstract Optional getBedPosition(); - @Shadow public abstract boolean addPotionEffect(EffectInstance effectInstanceIn); + @Shadow @Final private static DataParameter POTION_EFFECTS; + @Shadow @Final private static DataParameter HIDE_PARTICLES; + @Shadow @Final public Map activePotionsMap; + @Shadow protected abstract void onFinishedPotionEffect(EffectInstance effect); + @Shadow protected abstract void onChangedPotionEffect(EffectInstance id, boolean reapply); + @Shadow protected abstract void updatePotionMetadata(); + @Shadow public abstract boolean isPotionApplicable(EffectInstance potioneffectIn); + @Shadow protected abstract void onNewPotionEffect(EffectInstance id); + @Shadow @Nullable public abstract EffectInstance removeActivePotionEffect(@Nullable Effect potioneffectin); + @Shadow protected abstract void createWitherRose(@Nullable LivingEntity p_226298_1_); // @formatter:on public int expToDrop; @@ -159,6 +179,217 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt this.collides = true; } + /** + * @author IzzelAliz + * @reason + */ + @Overwrite + protected void onDeathUpdate() { + ++this.deathTime; + if (this.deathTime >= 20 && !this.removed) { + + this.remove((Object) this instanceof ServerPlayerEntity); //Forge keep data until we revive player + + for (int k = 0; k < 20; ++k) { + double d2 = this.rand.nextGaussian() * 0.02D; + double d0 = this.rand.nextGaussian() * 0.02D; + double d1 = this.rand.nextGaussian() * 0.02D; + this.world.addParticle(ParticleTypes.POOF, this.getPosX() + (double) (this.rand.nextFloat() * this.getWidth() * 2.0F) - (double) this.getWidth(), this.getPosY() + (double) (this.rand.nextFloat() * this.getHeight()), this.getPosZ() + (double) (this.rand.nextFloat() * this.getWidth() * 2.0F) - (double) this.getWidth(), d2, d0, d1); + } + } + } + + @Redirect(method = "spawnDrops", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;dropExperience()V")) + private void arclight$dropLater(LivingEntity livingEntity) { + } + + @Inject(method = "spawnDrops", at = @At("RETURN")) + private void arclight$dropLast(DamageSource damageSourceIn, CallbackInfo ci) { + this.dropExperience(); + } + + /** + * @author IzzelAliz + * @reason + */ + @Overwrite + protected void dropExperience() { + // if (!this.world.isRemote && (this.isPlayer() || this.recentlyHit > 0 && this.canDropLoot() && this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT))) { + if (true) { + int i = bridge$getExpToDrop(); + while (i > 0) { + int j = ExperienceOrbEntity.getXPSplit(i); + i -= j; + this.world.addEntity(new ExperienceOrbEntity(this.world, this.getPosX(), this.getPosY(), this.getPosZ(), j)); + } + bridge$setExpToDrop(0); + } + } + + private boolean isTickingEffects = false; + private List, EntityPotionEffectEvent.Cause>> effectsToProcess = Lists.newArrayList(); + + /** + * @author IzzelAliz + * @reason + */ + @Overwrite + protected void updatePotionEffects() { + this.isTickingEffects = true; + Iterator iterator = this.activePotionsMap.keySet().iterator(); + + try { + while (iterator.hasNext()) { + Effect effect = iterator.next(); + EffectInstance effectinstance = this.activePotionsMap.get(effect); + if (!effectinstance.tick((LivingEntity) (Object) this, () -> { + onChangedPotionEffect(effectinstance, true); + })) { + if (!this.world.isRemote && !MinecraftForge.EVENT_BUS.post(new PotionEvent.PotionExpiryEvent((LivingEntity) (Object) this, effectinstance))) { + + EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent((LivingEntity) (Object) this, effectinstance, null, EntityPotionEffectEvent.Cause.EXPIRATION); + if (event.isCancelled()) { + continue; + } + + iterator.remove(); + this.onFinishedPotionEffect(effectinstance); + } + } else if (effectinstance.getDuration() % 600 == 0) { + this.onChangedPotionEffect(effectinstance, false); + } + } + } catch (ConcurrentModificationException ignored) { + } + + isTickingEffects = false; + for (Map.Entry, EntityPotionEffectEvent.Cause> e : effectsToProcess) { + Either either = e.getKey(); + EntityPotionEffectEvent.Cause cause = e.getValue(); + bridge$pushEffectCause(cause); + if (either.left().isPresent()) { + addPotionEffect(either.left().get()); + } else { + removePotionEffect(either.right().get()); + } + } + effectsToProcess.clear(); + + if (this.potionsNeedUpdate) { + if (!this.world.isRemote) { + this.updatePotionMetadata(); + } + + this.potionsNeedUpdate = false; + } + + int i = this.dataManager.get(POTION_EFFECTS); + boolean flag1 = this.dataManager.get(HIDE_PARTICLES); + if (i > 0) { + boolean flag; + if (this.isInvisible()) { + flag = this.rand.nextInt(15) == 0; + } else { + flag = this.rand.nextBoolean(); + } + + if (flag1) { + flag &= this.rand.nextInt(5) == 0; + } + + if (flag && i > 0) { + double d0 = (double) (i >> 16 & 255) / 255.0D; + double d1 = (double) (i >> 8 & 255) / 255.0D; + double d2 = (double) (i >> 0 & 255) / 255.0D; + this.world.addParticle(flag1 ? ParticleTypes.AMBIENT_ENTITY_EFFECT : ParticleTypes.ENTITY_EFFECT, this.getPosX() + (this.rand.nextDouble() - 0.5D) * (double) this.getWidth(), this.getPosY() + this.rand.nextDouble() * (double) this.getHeight(), this.getPosZ() + (this.rand.nextDouble() - 0.5D) * (double) this.getWidth(), d0, d1, d2); + } + } + } + + /** + * @author IzzelAliz + * @reason + */ + @Overwrite + public boolean addPotionEffect(EffectInstance effectInstanceIn) { + EntityPotionEffectEvent.Cause cause = bridge$getEffectCause().orElse(EntityPotionEffectEvent.Cause.UNKNOWN); + if (isTickingEffects) { + effectsToProcess.add(Maps.immutableEntry(Either.left(effectInstanceIn), cause)); + return true; + } + + if (!this.isPotionApplicable(effectInstanceIn)) { + return false; + } else { + EffectInstance effectinstance = this.activePotionsMap.get(effectInstanceIn.getPotion()); + + boolean override = false; + if (effectinstance != null) { + override = new EffectInstance(effectinstance).combine(effectInstanceIn); + } + + EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent((LivingEntity) (Object) this, effectinstance, effectInstanceIn, cause, override); + if (event.isCancelled()) { + return false; + } + + MinecraftForge.EVENT_BUS.post(new PotionEvent.PotionAddedEvent((LivingEntity) (Object) this, effectinstance, effectInstanceIn)); + if (effectinstance == null) { + this.activePotionsMap.put(effectInstanceIn.getPotion(), effectInstanceIn); + this.onNewPotionEffect(effectInstanceIn); + return true; + } else if (event.isOverride()) { + effectinstance.combine(effectInstanceIn); + this.onChangedPotionEffect(effectinstance, true); + return true; + } else { + return false; + } + } + } + + @SuppressWarnings("unused") // mock + public EffectInstance c(@Nullable Effect potioneffectin, EntityPotionEffectEvent.Cause cause) { + bridge$pushEffectCause(cause); + return removeActivePotionEffect(potioneffectin); + } + + @Inject(method = "removeActivePotionEffect", cancellable = true, at = @At("HEAD")) + public void arclight$clearActive(Effect effect, CallbackInfoReturnable cir) { + EntityPotionEffectEvent.Cause cause = bridge$getEffectCause().orElse(EntityPotionEffectEvent.Cause.UNKNOWN); + if (isTickingEffects) { + effectsToProcess.add(Maps.immutableEntry(Either.right(effect), cause)); + cir.setReturnValue(null); + return; + } + + EffectInstance effectInstance = this.activePotionsMap.get(effect); + if (effectInstance == null) { + cir.setReturnValue(null); + return; + } + + EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent((LivingEntity) (Object) this, effectInstance, null, cause); + if (event.isCancelled()) { + cir.setReturnValue(null); + } + } + + + private transient boolean arclight$fallSuccess; + + @Inject(method = "onLivingFall", cancellable = true, at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/entity/LivingEntity;attackEntityFrom(Lnet/minecraft/util/DamageSource;F)Z")) + public void arclight$fall(float distance, float damageMultiplier, CallbackInfoReturnable cir) { + if (!arclight$fallSuccess) { + cir.setReturnValue(true); + } + } + + @Redirect(method = "onLivingFall", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;attackEntityFrom(Lnet/minecraft/util/DamageSource;F)Z")) + public boolean arclight$fall(LivingEntity livingEntity, DamageSource source, float amount) { + return arclight$fallSuccess = livingEntity.attackEntityFrom(source, amount); + } + @Override public boolean bridge$canPickUpLoot() { return canPickUpLoot; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/ai/goal/FollowOwnerGoalMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/ai/goal/FollowOwnerGoalMixin.java similarity index 95% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/ai/goal/FollowOwnerGoalMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/ai/goal/FollowOwnerGoalMixin.java index 2a3f3453..79f798e7 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/ai/goal/FollowOwnerGoalMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/ai/goal/FollowOwnerGoalMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.entity.ai.goal; +package io.izzel.arclight.common.mixin.core.entity.ai.goal; import io.izzel.arclight.common.bridge.entity.EntityBridge; import net.minecraft.entity.ai.goal.FollowOwnerGoal; @@ -16,7 +16,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(FollowOwnerGoal.class) -public class FollowOwnerGoalMixin_1_15 { +public class FollowOwnerGoalMixin { // @formatter:off @Shadow @Final private TameableEntity tameable; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/boss/WitherEntityMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/boss/WitherEntityMixin.java similarity index 97% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/boss/WitherEntityMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/boss/WitherEntityMixin.java index f4f51cba..b162eaff 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/boss/WitherEntityMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/boss/WitherEntityMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.entity.boss; +package io.izzel.arclight.common.mixin.core.entity.boss; import io.izzel.arclight.common.mixin.core.entity.CreatureEntityMixin; import net.minecraft.block.BlockState; @@ -27,7 +27,7 @@ import org.spongepowered.asm.mixin.Shadow; import java.util.List; @Mixin(WitherEntity.class) -public abstract class WitherEntityMixin_1_15 extends CreatureEntityMixin { +public abstract class WitherEntityMixin extends CreatureEntityMixin { // @formatter:off @Shadow public abstract int getInvulTime(); @@ -56,7 +56,7 @@ public abstract class WitherEntityMixin_1_15 extends CreatureEntityMixin { ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 7.0F, false); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { - this.world.createExplosion((WitherEntity) (Object) this, this.posX, this.bridge$getEyeHeight(), this.posZ, event.getRadius(), event.getFire(), explosion$mode); + this.world.createExplosion((WitherEntity) (Object) this, this.posX, this.getPosYEye(), this.posZ, event.getRadius(), event.getFire(), explosion$mode); } this.world.playBroadcastSound(1023, new BlockPos((WitherEntity) (Object) this), 0); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/item/ArmorStandEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/item/ArmorStandEntityMixin.java index 6552dfd3..9e94430a 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/item/ArmorStandEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/item/ArmorStandEntityMixin.java @@ -1,16 +1,27 @@ package io.izzel.arclight.common.mixin.core.entity.item; import com.google.common.collect.Lists; +import io.izzel.arclight.common.bridge.entity.EntityBridge; +import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge; import io.izzel.arclight.common.mixin.core.entity.LivingEntityMixin; import net.minecraft.entity.item.ArmorStandEntity; import net.minecraft.entity.item.ItemEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; +import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.GameRules; import net.minecraft.world.World; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v.CraftEquipmentSlot; import org.bukkit.craftbukkit.v.event.CraftEventFactory; import org.bukkit.craftbukkit.v.inventory.CraftItemStack; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerArmorStandManipulateEvent; +import org.bukkit.inventory.EquipmentSlot; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -27,7 +38,10 @@ import java.util.stream.Collectors; @Mixin(ArmorStandEntity.class) public abstract class ArmorStandEntityMixin extends LivingEntityMixin { + // @formatter:off @Shadow private boolean canInteract; + @Shadow public abstract ItemStack getItemStackFromSlot(EquipmentSlotType slotIn); + // @formatter:on @Override public float getBukkitYaw() { @@ -123,4 +137,23 @@ public abstract class ArmorStandEntityMixin extends LivingEntityMixin { } CraftEventFactory.callEntityDeathEvent((ArmorStandEntity) (Object) this, drops); } + + @Inject(method = "func_226529_a_", cancellable = true, at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerEntity;abilities:Lnet/minecraft/entity/player/PlayerAbilities;")) + public void arclight$manipulateEvent(PlayerEntity playerEntity, EquipmentSlotType slotType, ItemStack itemStack, Hand hand, CallbackInfoReturnable cir) { + ItemStack itemStack1 = this.getItemStackFromSlot(slotType); + + org.bukkit.inventory.ItemStack armorStandItem = CraftItemStack.asCraftMirror(itemStack1); + org.bukkit.inventory.ItemStack playerHeldItem = CraftItemStack.asCraftMirror(itemStack); + + Player player = ((ServerPlayerEntityBridge) playerEntity).bridge$getBukkitEntity(); + ArmorStand self = (ArmorStand) ((EntityBridge) this).bridge$getBukkitEntity(); + + EquipmentSlot slot = CraftEquipmentSlot.getSlot(slotType); + PlayerArmorStandManipulateEvent event = new PlayerArmorStandManipulateEvent(player, self, playerHeldItem, armorStandItem, slot); + Bukkit.getPluginManager().callEvent(event); + + if (event.isCancelled()) { + cir.setReturnValue(true); + } + } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/item/FallingBlockEntityMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/item/FallingBlockEntityMixin.java similarity index 93% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/item/FallingBlockEntityMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/item/FallingBlockEntityMixin.java index 391347ea..ab4a3ad6 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/item/FallingBlockEntityMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/item/FallingBlockEntityMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.entity.item; +package io.izzel.arclight.common.mixin.core.entity.item; import io.izzel.arclight.common.mixin.core.entity.EntityMixin; import net.minecraft.block.Block; @@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin(FallingBlockEntity.class) -public abstract class FallingBlockEntityMixin_1_15 extends EntityMixin { +public abstract class FallingBlockEntityMixin extends EntityMixin { @Shadow private BlockState fallTile; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/item/ItemEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/item/ItemEntityMixin.java index 5a5fa88e..f1d98338 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/item/ItemEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/item/ItemEntityMixin.java @@ -23,6 +23,7 @@ import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -121,4 +122,11 @@ public abstract class ItemEntityMixin extends EntityMixin { private void arclight$markDirty(ItemStack stack, CallbackInfo ci) { ((EntityDataManagerBridge) this.getDataManager()).bridge$markDirty(ITEM); } + + @Redirect(method = "func_226531_a_", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/ItemEntity;setItem(Lnet/minecraft/item/ItemStack;)V")) + private static void arclight$setNonEmpty(ItemEntity itemEntity, ItemStack stack) { + if (!stack.isEmpty()) { + itemEntity.setItem(stack); + } + } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/item/LeashKnotEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/item/LeashKnotEntityMixin.java index 7197b966..0090cef1 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/item/LeashKnotEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/item/LeashKnotEntityMixin.java @@ -36,7 +36,7 @@ public abstract class LeashKnotEntityMixin extends HangingEntityMixin { } boolean flag = false; final double d0 = 7.0; - final List list = this.world.getEntitiesWithinAABB((Class) MobEntity.class, new AxisAlignedBB(this.posX - 7.0, this.posY - 7.0, this.posZ - 7.0, this.posX + 7.0, this.posY + 7.0, this.posZ + 7.0)); + final List list = this.world.getEntitiesWithinAABB(MobEntity.class, new AxisAlignedBB(this.posX - 7.0, this.posY - 7.0, this.posZ - 7.0, this.posX + 7.0, this.posY + 7.0, this.posZ + 7.0)); for (final MobEntity entityinsentient : list) { if (entityinsentient.getLeashHolder() == entityhuman) { if (CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, (LeashKnotEntity) (Object) this, entityhuman).isCancelled()) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/monster/AbstractRaiderEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/AbstractRaiderEntityMixin.java similarity index 95% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/monster/AbstractRaiderEntityMixin.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/AbstractRaiderEntityMixin.java index df695861..46045a09 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/monster/AbstractRaiderEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/AbstractRaiderEntityMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.entity.monster; +package io.izzel.arclight.common.mixin.core.entity.monster; import io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge; import net.minecraft.entity.Entity; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/EndermanEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/EndermanEntityMixin.java index 8330b33c..79a8a142 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/EndermanEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/EndermanEntityMixin.java @@ -3,10 +3,16 @@ package io.izzel.arclight.common.mixin.core.entity.monster; import io.izzel.arclight.common.bridge.entity.monster.EndermanEntityBridge; import io.izzel.arclight.common.mixin.core.entity.CreatureEntityMixin; import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.ai.attributes.IAttributeInstance; import net.minecraft.entity.monster.EndermanEntity; +import net.minecraft.network.datasync.DataParameter; import org.bukkit.event.entity.EntityTargetEvent; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; import javax.annotation.Nullable; import java.util.concurrent.atomic.AtomicBoolean; @@ -14,6 +20,30 @@ import java.util.concurrent.atomic.AtomicBoolean; @Mixin(EndermanEntity.class) public abstract class EndermanEntityMixin extends CreatureEntityMixin implements EndermanEntityBridge { + // @formatter:off + @Shadow private int targetChangeTime; + @Shadow @Final private static DataParameter SCREAMING; + @Shadow @Final private static DataParameter field_226535_bx_; + @Shadow @Final private static AttributeModifier ATTACKING_SPEED_BOOST; + // @formatter:on + + @Override + public void bridge$updateTarget(LivingEntity livingEntity) { + IAttributeInstance iattributeinstance = this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); + if (livingEntity == null) { + this.targetChangeTime = 0; + this.dataManager.set(SCREAMING, false); + this.dataManager.set(field_226535_bx_, false); + iattributeinstance.removeModifier(ATTACKING_SPEED_BOOST); + } else { + this.targetChangeTime = this.ticksExisted; + this.dataManager.set(SCREAMING, true); + if (!iattributeinstance.hasModifier(ATTACKING_SPEED_BOOST)) { + iattributeinstance.applyModifier(ATTACKING_SPEED_BOOST); + } + } + } + @Override public boolean setGoalTarget(LivingEntity livingEntity, EntityTargetEvent.TargetReason reason, boolean fireEvent) { if (!super.setGoalTarget(livingEntity, reason, fireEvent)) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/monster/RavagerEntityMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/RavagerEntityMixin.java similarity index 88% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/monster/RavagerEntityMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/RavagerEntityMixin.java index 01c77636..b3ccd6eb 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/monster/RavagerEntityMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/RavagerEntityMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.entity.monster; +package io.izzel.arclight.common.mixin.core.entity.monster; import io.izzel.arclight.common.mixin.core.entity.CreatureEntityMixin; import net.minecraft.block.Blocks; @@ -12,7 +12,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(RavagerEntity.class) -public abstract class RavagerEntityMixin_1_15 extends CreatureEntityMixin { +public abstract class RavagerEntityMixin extends CreatureEntityMixin { @Redirect(method = "livingTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;destroyBlock(Lnet/minecraft/util/math/BlockPos;ZLnet/minecraft/entity/Entity;)Z")) private boolean arclight$entityChangeBlock(World world, BlockPos pos, boolean p_225521_2_, Entity entityIn) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/monster/ShulkerEntityMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/ShulkerEntityMixin.java similarity index 85% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/monster/ShulkerEntityMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/ShulkerEntityMixin.java index b0195618..da107075 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/monster/ShulkerEntityMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/ShulkerEntityMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.entity.monster; +package io.izzel.arclight.common.mixin.core.entity.monster; import io.izzel.arclight.common.mixin.core.entity.CreatureEntityMixin; import net.minecraft.entity.monster.ShulkerEntity; @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ShulkerEntity.class) -public abstract class ShulkerEntityMixin_1_15 extends CreatureEntityMixin { +public abstract class ShulkerEntityMixin extends CreatureEntityMixin { @Inject(method = "notifyDataManagerChange", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/entity/monster/ShulkerEntity;forceSetPosition(DDD)V")) private void arclight$chunkCheck(DataParameter key, CallbackInfo ci) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/monster/ZombiePigmanEntityMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/ZombiePigmanEntityMixin.java similarity index 91% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/monster/ZombiePigmanEntityMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/ZombiePigmanEntityMixin.java index 6b284ac4..79164df8 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/monster/ZombiePigmanEntityMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/monster/ZombiePigmanEntityMixin.java @@ -1,7 +1,6 @@ -package io.izzel.arclight.common.mixin.v1_15.entity.monster; +package io.izzel.arclight.common.mixin.core.entity.monster; import io.izzel.arclight.common.bridge.entity.EntityBridge; -import io.izzel.arclight.common.mixin.core.entity.monster.ZombieEntityMixin; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.monster.ZombiePigmanEntity; @@ -18,7 +17,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(ZombiePigmanEntity.class) -public abstract class ZombiePigmanEntityMixin_1_15 extends ZombieEntityMixin { +public abstract class ZombiePigmanEntityMixin extends ZombieEntityMixin { // @formatter:off @Shadow protected abstract boolean func_226547_i_(LivingEntity p_70835_1_); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/passive/BeeEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/passive/BeeEntityMixin.java similarity index 94% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/passive/BeeEntityMixin.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/passive/BeeEntityMixin.java index 16ed2f05..a0978535 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/passive/BeeEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/passive/BeeEntityMixin.java @@ -1,7 +1,6 @@ -package io.izzel.arclight.common.mixin.v1_15.entity.passive; +package io.izzel.arclight.common.mixin.core.entity.passive; import io.izzel.arclight.common.bridge.entity.LivingEntityBridge; -import io.izzel.arclight.common.mixin.core.entity.passive.AnimalEntityMixin; import net.minecraft.entity.Entity; import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.entity.passive.BeeEntity; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/passive/BeeEntity_AngerGoalMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/passive/BeeEntity_AngerGoalMixin.java similarity index 93% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/passive/BeeEntity_AngerGoalMixin.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/passive/BeeEntity_AngerGoalMixin.java index b15a8591..0267a55a 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/passive/BeeEntity_AngerGoalMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/passive/BeeEntity_AngerGoalMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.entity.passive; +package io.izzel.arclight.common.mixin.core.entity.passive; import io.izzel.arclight.common.bridge.entity.MobEntityBridge; import net.minecraft.entity.LivingEntity; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/passive/BeeEntity_FindPollinationTargetGoalMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/passive/BeeEntity_FindPollinationTargetGoalMixin.java similarity index 95% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/passive/BeeEntity_FindPollinationTargetGoalMixin.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/passive/BeeEntity_FindPollinationTargetGoalMixin.java index c2e3ba8d..b7bb1a46 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/passive/BeeEntity_FindPollinationTargetGoalMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/passive/BeeEntity_FindPollinationTargetGoalMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.entity.passive; +package io.izzel.arclight.common.mixin.core.entity.passive; import net.minecraft.block.Block; import net.minecraft.block.BlockState; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/player/PlayerEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/player/PlayerEntityMixin.java index 2d866e46..4bfe58ac 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/player/PlayerEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/player/PlayerEntityMixin.java @@ -1,6 +1,7 @@ package io.izzel.arclight.common.mixin.core.entity.player; import com.mojang.authlib.GameProfile; +import com.mojang.datafixers.util.Either; import io.izzel.arclight.common.bridge.entity.EntityBridge; import io.izzel.arclight.common.bridge.entity.InternalEntityBridge; import io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge; @@ -8,6 +9,7 @@ import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge; import io.izzel.arclight.common.bridge.inventory.IInventoryBridge; import io.izzel.arclight.common.bridge.util.DamageSourceBridge; import io.izzel.arclight.common.bridge.util.FoodStatsBridge; +import io.izzel.arclight.common.bridge.world.WorldBridge; import io.izzel.arclight.common.bridge.world.server.ServerWorldBridge; import io.izzel.arclight.common.mixin.core.entity.LivingEntityMixin; import net.minecraft.enchantment.EnchantmentHelper; @@ -37,32 +39,37 @@ import net.minecraft.scoreboard.Scoreboard; import net.minecraft.stats.Stat; import net.minecraft.stats.Stats; import net.minecraft.util.DamageSource; +import net.minecraft.util.Direction; import net.minecraft.util.FoodStats; import net.minecraft.util.Hand; import net.minecraft.util.HandSide; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; +import net.minecraft.util.Unit; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.util.text.ITextComponent; import net.minecraft.world.Difficulty; import net.minecraft.world.World; +import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.common.ForgeHooks; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v.block.CraftBlock; import org.bukkit.craftbukkit.v.entity.CraftHumanEntity; import org.bukkit.craftbukkit.v.event.CraftEventFactory; import org.bukkit.craftbukkit.v.util.CraftVector; -import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.EntityCombustByEntityEvent; import org.bukkit.event.entity.EntityPotionEffectEvent; import org.bukkit.event.entity.EntityRegainHealthEvent; +import org.bukkit.event.player.PlayerBedLeaveEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.scoreboard.Team; @@ -115,6 +122,9 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin implements Pla @Shadow protected boolean isMovementBlocked() { return false; } @Shadow public abstract Scoreboard getWorldScoreboard(); @Shadow protected EnderChestInventory enterChestInventory; + @Shadow public abstract Either trySleep(BlockPos at); + @Shadow public abstract void startSleeping(BlockPos p_213342_1_); + @Shadow public int sleepTimer; // @formatter:on public boolean fauxSleeping; @@ -125,7 +135,104 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin implements Pla private void arclight$init(World worldIn, GameProfile gameProfileIn, CallbackInfo ci) { oldLevel = -1; ((FoodStatsBridge) this.foodStats).bridge$setEntityHuman((PlayerEntity) (Object) this); - ((IInventoryBridge) this.enterChestInventory).setOwner(((HumanEntity) this.getBukkitEntity())); + ((IInventoryBridge) this.enterChestInventory).setOwner(this.getBukkitEntity()); + } + + private boolean arclight$forceSleep = false; + private Object arclight$processSleep = null; + + private Either getBedResult(BlockPos at, Direction direction) { + arclight$processSleep = true; + Either either = this.trySleep(at); + arclight$processSleep = null; + return either; + } + + public Either sleep(BlockPos at, boolean force) { + arclight$forceSleep = force; + try { + return this.trySleep(at); + } finally { + arclight$forceSleep = false; + } + } + + @Inject(method = "trySleep", cancellable = true, at = @At(value = "HEAD")) + public void arclight$onSleep(BlockPos at, CallbackInfoReturnable> cir) { + if (arclight$processSleep == null) { + Either result = getBedResult(at, null); + + if (result.left().orElse(null) == PlayerEntity.SleepResult.OTHER_PROBLEM) { + cir.setReturnValue(result); + return; + } + if (arclight$forceSleep) { + result = Either.right(Unit.INSTANCE); + } + if (this.bridge$getBukkitEntity() instanceof Player) { + result = CraftEventFactory.callPlayerBedEnterEvent((PlayerEntity) (Object) this, at, result); + if (result.left().isPresent()) { + cir.setReturnValue(result); + return; + } + } + + this.startSleeping(at); + this.sleepTimer = 0; + if (this.world instanceof ServerWorld) { + ((ServerWorld) this.world).updateAllPlayersSleepingFlag(); + } + cir.setReturnValue(Either.right(Unit.INSTANCE)); + } + } + + @Inject(method = "trySleep", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;startSleeping(Lnet/minecraft/util/math/BlockPos;)V")) + public void arclight$preSleep(BlockPos at, CallbackInfoReturnable> cir) { + if (arclight$processSleep != null) { + cir.setReturnValue(Either.right(Unit.INSTANCE)); + } + } + + @Inject(method = "stopSleepInBed", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerEntity;sleepTimer:I")) + private void arclight$wakeup(boolean flag, boolean flag1, CallbackInfo ci) { + BlockPos blockPos = this.getBedPosition().orElse(null); + if (this.bridge$getBukkitEntity() instanceof Player) { + Player player = (Player) this.bridge$getBukkitEntity(); + Block bed; + if (blockPos != null) { + bed = CraftBlock.at(this.world, blockPos); + } else { + bed = ((WorldBridge) this.world).bridge$getWorld().getBlockAt(player.getLocation()); + } + PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed, true); + Bukkit.getPluginManager().callEvent(event); + } + } + + @Inject(method = "setSpawnPoint", remap = false, at = @At("RETURN")) + private void arclight$updateSpawnpoint(BlockPos pos, boolean p_226560_2_, boolean p_226560_3_, DimensionType dim, CallbackInfo ci) { + bridge$setSpawnWorld(pos == null ? "" : this.world.worldInfo.getWorldName()); + } + + @Inject(method = "startFallFlying", cancellable = true, at = @At("HEAD")) + private void arclight$startGlidingEvent(CallbackInfo ci) { + if (CraftEventFactory.callToggleGlideEvent((PlayerEntity) (Object) this, true).isCancelled()) { + this.setFlag(7, true); + this.setFlag(7, false); + ci.cancel(); + } + } + + @Inject(method = "stopFallFlying", cancellable = true, at = @At("HEAD")) + private void arclight$stopGlidingEvent(CallbackInfo ci) { + if (CraftEventFactory.callToggleGlideEvent((PlayerEntity) (Object) this, false).isCancelled()) { + ci.cancel(); + } + } + + @Override + public Either bridge$trySleep(BlockPos at, boolean force) { + return sleep(at, force); } @Override @@ -328,7 +435,7 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin implements Pla } if (flag4) { final float f5 = 1.0f + EnchantmentHelper.getSweepingDamageRatio((PlayerEntity) (Object) this) * f; - final List list = this.world.getEntitiesWithinAABB((Class) LivingEntity.class, entity.getBoundingBox().grow(1.0, 0.25, 1.0)); + final List list = this.world.getEntitiesWithinAABB(LivingEntity.class, entity.getBoundingBox().grow(1.0, 0.25, 1.0)); for (final LivingEntity entityliving : list) { if (entityliving != (Object) this && entityliving != entity && !this.isOnSameTeam(entityliving) && (!(entityliving instanceof ArmorStandEntity) || !((ArmorStandEntity) entityliving).hasMarker()) && this.getDistanceSq(entityliving) < 9.0 && entityliving.attackEntityFrom(((DamageSourceBridge) DamageSource.causePlayerDamage((PlayerEntity) (Object) this)).bridge$sweep(), f5)) { entityliving.knockBack((PlayerEntity) (Object) this, 0.4f, MathHelper.sin(this.rotationYaw * 0.017453292f), -MathHelper.cos(this.rotationYaw * 0.017453292f)); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/player/ServerPlayerEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/player/ServerPlayerEntityMixin.java index a00d5531..6321abd0 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/player/ServerPlayerEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/entity/player/ServerPlayerEntityMixin.java @@ -1,14 +1,22 @@ package io.izzel.arclight.common.mixin.core.entity.player; import com.google.common.collect.Lists; +import com.mojang.datafixers.util.Either; import io.izzel.arclight.common.bridge.entity.EntityBridge; import io.izzel.arclight.common.bridge.entity.InternalEntityBridge; import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge; import io.izzel.arclight.common.bridge.inventory.container.ContainerBridge; +import io.izzel.arclight.common.bridge.network.play.ServerPlayNetHandlerBridge; import io.izzel.arclight.common.bridge.util.FoodStatsBridge; +import io.izzel.arclight.common.bridge.world.TeleporterBridge; import io.izzel.arclight.common.bridge.world.WorldBridge; +import io.izzel.arclight.common.bridge.world.dimension.DimensionTypeBridge; +import io.izzel.arclight.common.bridge.world.server.ServerWorldBridge; import io.izzel.arclight.common.mod.util.ArclightCaptures; import io.izzel.arclight.common.mod.util.ChestBlockDoubleInventoryHacks; +import net.minecraft.advancements.CriteriaTriggers; +import net.minecraft.block.Blocks; +import net.minecraft.block.pattern.BlockPattern; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.item.ItemEntity; @@ -28,14 +36,21 @@ import net.minecraft.network.play.client.CClientSettingsPacket; import net.minecraft.network.play.server.SChangeGameStatePacket; import net.minecraft.network.play.server.SCombatPacket; import net.minecraft.network.play.server.SOpenHorseWindowPacket; +import net.minecraft.network.play.server.SPlayEntityEffectPacket; +import net.minecraft.network.play.server.SPlaySoundEventPacket; +import net.minecraft.network.play.server.SPlayerAbilitiesPacket; +import net.minecraft.network.play.server.SRespawnPacket; +import net.minecraft.network.play.server.SServerDifficultyPacket; import net.minecraft.network.play.server.SSetSlotPacket; import net.minecraft.network.play.server.SUpdateHealthPacket; +import net.minecraft.potion.EffectInstance; import net.minecraft.scoreboard.Score; import net.minecraft.scoreboard.ScoreCriteria; import net.minecraft.scoreboard.Scoreboard; import net.minecraft.scoreboard.Team; import net.minecraft.server.MinecraftServer; import net.minecraft.server.management.PlayerInteractionManager; +import net.minecraft.server.management.PlayerList; import net.minecraft.stats.Stat; import net.minecraft.stats.Stats; import net.minecraft.util.CombatTracker; @@ -43,6 +58,7 @@ import net.minecraft.util.DamageSource; import net.minecraft.util.FoodStats; import net.minecraft.util.HandSide; import net.minecraft.util.NonNullList; +import net.minecraft.util.Unit; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; @@ -53,26 +69,38 @@ import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.util.text.event.HoverEvent; import net.minecraft.world.GameRules; import net.minecraft.world.GameType; +import net.minecraft.world.Teleporter; import net.minecraft.world.World; +import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.storage.WorldInfo; +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.util.ITeleporter; +import net.minecraftforge.fml.hooks.BasicEventHooks; +import net.minecraftforge.fml.network.NetworkHooks; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.WeatherType; +import org.bukkit.block.BlockState; import org.bukkit.craftbukkit.v.CraftServer; import org.bukkit.craftbukkit.v.CraftWorld; import org.bukkit.craftbukkit.v.entity.CraftPlayer; import org.bukkit.craftbukkit.v.event.CraftEventFactory; import org.bukkit.craftbukkit.v.inventory.CraftItemStack; import org.bukkit.craftbukkit.v.scoreboard.CraftScoreboardManager; +import org.bukkit.craftbukkit.v.util.BlockStateListPopulator; import org.bukkit.craftbukkit.v.util.CraftChatMessage; import org.bukkit.event.entity.EntityPotionEffectEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.player.PlayerChangedMainHandEvent; +import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.PlayerGameModeChangeEvent; import org.bukkit.event.player.PlayerLocaleChangeEvent; +import org.bukkit.event.player.PlayerPortalEvent; import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.world.PortalCreateEvent; import org.bukkit.inventory.MainHand; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -147,6 +175,250 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen this.maxHealthCache = this.getMaxHealth(); } + /** + * @author IzzelAliz + * @reason + */ + @Overwrite(remap = false) + @Nullable + public Entity changeDimension(DimensionType dim, ITeleporter teleporter) { + DimensionType[] destination = {dim}; + if (this.isSleeping()) return (ServerPlayerEntity) (Object) this; + + if (!ForgeHooks.onTravelToDimension((ServerPlayerEntity) (Object) this, destination[0])) return null; + + PlayerTeleportEvent.TeleportCause cause = bridge$getTeleportCause().orElse(PlayerTeleportEvent.TeleportCause.UNKNOWN); + // this.invulnerableDimensionChange = true; + DimensionType dimensiontype = this.dimension; + if (((DimensionTypeBridge) dimensiontype).bridge$getType() == DimensionType.THE_END && ((DimensionTypeBridge) destination[0]).bridge$getType() == DimensionType.OVERWORLD && teleporter instanceof Teleporter) { //Forge: Fix non-vanilla teleporters triggering end credits + this.invulnerableDimensionChange = true; + this.detach(); + this.getServerWorld().removePlayer((ServerPlayerEntity) (Object) this, true); //Forge: The player entity is cloned so keep the data until after cloning calls copyFrom + if (!this.queuedEndExit) { + this.queuedEndExit = true; + this.connection.sendPacket(new SChangeGameStatePacket(4, this.seenCredits ? 0.0F : 1.0F)); + this.seenCredits = true; + } + + return (ServerPlayerEntity) (Object) this; + } else { + ServerWorld serverworld = this.server.getWorld(dimensiontype); + // this.dimension = destination; + ServerWorld[] serverworld1 = {this.server.getWorld(destination[0])}; + + /* + WorldInfo worldinfo = serverworld1.getWorldInfo(); + NetworkHooks.sendDimensionDataPacket(this.connection.netManager, (ServerPlayerEntity) (Object) this); + this.connection.sendPacket(new SRespawnPacket(destination, WorldInfo.byHashing(worldinfo.getSeed()), worldinfo.getGenerator(), this.interactionManager.getGameType())); + this.connection.sendPacket(new SServerDifficultyPacket(worldinfo.getDifficulty(), worldinfo.isDifficultyLocked())); + PlayerList playerlist = this.server.getPlayerList(); + playerlist.updatePermissionLevel((ServerPlayerEntity) (Object) this); + serverworld.removeEntity((ServerPlayerEntity) (Object) this, true); //Forge: the player entity is moved to the new world, NOT cloned. So keep the data alive with no matching invalidate call. + this.revive(); + */ + PlayerList[] playerlist = new PlayerList[1]; + + Entity e = teleporter.placeEntity((ServerPlayerEntity) (Object) this, serverworld, serverworld1[0], this.rotationYaw, spawnPortal -> {//Forge: Start vanilla logic + double d0 = this.getPosX(); + double d1 = this.getPosY(); + double d2 = this.getPosZ(); + float f = this.rotationPitch; + float f1 = this.rotationYaw; + double d3 = 8.0D; + float f2 = f1; + serverworld.getProfiler().startSection("moving"); + + if (serverworld1[0] != null) { + double moveFactor = serverworld.getDimension().getMovementFactor() / serverworld1[0].getDimension().getMovementFactor(); + d0 *= moveFactor; + d2 *= moveFactor; + if (dimensiontype == DimensionType.OVERWORLD && destination[0] == DimensionType.THE_NETHER) { + this.enteredNetherPosition = this.getPositionVec(); + } else if (dimensiontype == DimensionType.OVERWORLD && destination[0] == DimensionType.THE_END) { + BlockPos blockpos = serverworld1[0].getSpawnCoordinate(); + d0 = blockpos.getX(); + d1 = blockpos.getY(); + d2 = blockpos.getZ(); + f1 = 90.0F; + f = 0.0F; + } + } + + Location enter = this.bridge$getBukkitEntity().getLocation(); + Location exit = (serverworld1[0] == null) ? null : new Location(((ServerWorldBridge) serverworld1[0]).bridge$getWorld(), d0, d1, d2, f1, f); + PlayerPortalEvent event = new PlayerPortalEvent(this.bridge$getBukkitEntity(), enter, exit, cause, 128, true, ((DimensionTypeBridge) destination[0]).bridge$getType() == DimensionType.THE_END ? 0 : 16); + Bukkit.getServer().getPluginManager().callEvent(event); + if (event.isCancelled() || event.getTo() == null) { + return null; + } + + exit = event.getTo(); + if (exit == null) { + return null; + } + serverworld1[0] = ((CraftWorld) exit.getWorld()).getHandle(); + d0 = exit.getX(); + d1 = exit.getY(); + d2 = exit.getZ(); + + // this.setLocationAndAngles(d0, d1, d2, f1, f); + serverworld.getProfiler().endSection(); + serverworld.getProfiler().startSection("placing"); + double d7 = Math.max(-2.9999872E7D, serverworld1[0].getWorldBorder().minX() + 16.0D); + double d4 = Math.max(-2.9999872E7D, serverworld1[0].getWorldBorder().minZ() + 16.0D); + double d5 = Math.min(2.9999872E7D, serverworld1[0].getWorldBorder().maxX() - 16.0D); + double d6 = Math.min(2.9999872E7D, serverworld1[0].getWorldBorder().maxZ() - 16.0D); + d0 = MathHelper.clamp(d0, d7, d5); + d2 = MathHelper.clamp(d2, d4, d6); + // this.setLocationAndAngles(d0, d1, d2, f1, f); + + Vec3d exitVelocity = Vec3d.ZERO; + BlockPos exitPosition = new BlockPos(d0, d1, d2); + + if (((DimensionTypeBridge) destination[0]).bridge$getType() == DimensionType.THE_END) { + int i = exitPosition.getX(); + int j = exitPosition.getY() - 1; + int k = exitPosition.getZ(); + + if (event.getCanCreatePortal()) { + + BlockStateListPopulator blockList = new BlockStateListPopulator(serverworld1[0]); + + for (int j1 = -2; j1 <= 2; ++j1) { + for (int k1 = -2; k1 <= 2; ++k1) { + for (int l1 = -1; l1 < 3; ++l1) { + int i2 = i + k1 * 1 + j1 * 0; + int j2 = j + l1; + int k2 = k + k1 * 0 - j1 * 1; + boolean flag = l1 < 0; + blockList.setBlockState(new BlockPos(i2, j2, k2), flag ? Blocks.OBSIDIAN.getDefaultState() : Blocks.AIR.getDefaultState(), 3); + } + } + } + + org.bukkit.World bworld = ((ServerWorldBridge) serverworld1[0]).bridge$getWorld(); + PortalCreateEvent portalEvent = new PortalCreateEvent((List) (List) blockList.getList(), bworld, this.bridge$getBukkitEntity(), PortalCreateEvent.CreateReason.END_PLATFORM); + + Bukkit.getPluginManager().callEvent(portalEvent); + if (!portalEvent.isCancelled()) { + blockList.updateList(); + } + } + + // this.setLocationAndAngles(i, j, k, f1, 0.0F); + exit.setX(i); + exit.setY(j); + exit.setZ(k); + // this.setMotion(Vec3d.ZERO); + exitVelocity = Vec3d.ZERO; + } else { + BlockPattern.PortalInfo portalInfo = ((TeleporterBridge) serverworld1[0].getDefaultTeleporter()).bridge$placeInPortal((ServerPlayerEntity) (Object) this, exitPosition, f2, event.getSearchRadius(), true); + if (spawnPortal && portalInfo == null && event.getCanCreatePortal()) { + if (((TeleporterBridge) serverworld1[0].getDefaultTeleporter()).bridge$makePortal((ServerPlayerEntity) (Object) this, exitPosition, event.getCreationRadius())) { + // serverworld1.getDefaultTeleporter().placeInPortal((ServerPlayerEntity) (Object) this, f2); + portalInfo = ((TeleporterBridge) serverworld1[0].getDefaultTeleporter()).bridge$placeInPortal((ServerPlayerEntity) (Object) this, exitPosition, f2, event.getSearchRadius(), true); + } + } + if (portalInfo == null) { + return null; + } + + exitVelocity = portalInfo.motion; + exit.setX(portalInfo.pos.getX()); + exit.setY(portalInfo.pos.getY()); + exit.setZ(portalInfo.pos.getZ()); + exit.setYaw(f2 + (float) portalInfo.rotation); + } + + serverworld.getProfiler().endSection(); + + PlayerTeleportEvent tpEvent = new PlayerTeleportEvent(this.bridge$getBukkitEntity(), enter, exit, cause); + Bukkit.getServer().getPluginManager().callEvent(tpEvent); + if (tpEvent.isCancelled() || tpEvent.getTo() == null) { + return null; + } + exit = tpEvent.getTo(); + if (exit == null) { + return null; + } + serverworld1[0] = ((CraftWorld) exit.getWorld()).getHandle(); + this.invulnerableDimensionChange = true; + + destination[0] = serverworld1[0].getDimension().getType(); + this.dimension = destination[0]; + + WorldInfo worldinfo = serverworld1[0].getWorldInfo(); + NetworkHooks.sendDimensionDataPacket(this.connection.netManager, (ServerPlayerEntity) (Object) this); + this.connection.sendPacket(new SRespawnPacket(destination[0], WorldInfo.byHashing(worldinfo.getSeed()), worldinfo.getGenerator(), this.interactionManager.getGameType())); + this.connection.sendPacket(new SServerDifficultyPacket(worldinfo.getDifficulty(), worldinfo.isDifficultyLocked())); + + playerlist[0] = this.server.getPlayerList(); + playerlist[0].updatePermissionLevel((ServerPlayerEntity) (Object) this); + + serverworld.removeEntity((ServerPlayerEntity) (Object) this, true); //Forge: the player entity is moved to the new world, NOT cloned. So keep the data alive with no matching invalidate call. + this.revive(); + + this.setMotion(exitVelocity); + + this.setWorld(serverworld1[0]); + serverworld1[0].addDuringPortalTeleport((ServerPlayerEntity) (Object) this); + this.func_213846_b(serverworld); + + // this.connection.setPlayerLocation(this.getPosX(), this.getPosY(), this.getPosZ(), f1, f); + ((ServerPlayNetHandlerBridge) this.connection).bridge$teleport(exit); + this.connection.captureCurrentPosition(); + + return (ServerPlayerEntity) (Object) this;//forge: this is part of the ITeleporter patch + });//Forge: End vanilla logic + if (e == null) { + return (ServerPlayerEntity) (Object) this; + } else if (e != (Object) this) { + throw new IllegalArgumentException(String.format("Teleporter %s returned not the player entity but instead %s, expected PlayerEntity %s", teleporter, e, this)); + } + this.interactionManager.setWorld(serverworld1[0]); + this.connection.sendPacket(new SPlayerAbilitiesPacket(this.abilities)); + playerlist[0].sendWorldInfo((ServerPlayerEntity) (Object) this, serverworld1[0]); + playerlist[0].sendInventory((ServerPlayerEntity) (Object) this); + + for (EffectInstance effectinstance : this.getActivePotionEffects()) { + this.connection.sendPacket(new SPlayEntityEffectPacket(this.getEntityId(), effectinstance)); + } + + this.connection.sendPacket(new SPlaySoundEventPacket(1032, BlockPos.ZERO, 0, false)); + this.lastExperience = -1; + this.lastHealth = -1.0F; + this.lastFoodLevel = -1; + BasicEventHooks.firePlayerChangedDimensionEvent((ServerPlayerEntity) (Object) this, dimensiontype, destination[0]); + + PlayerChangedWorldEvent changeEvent = new PlayerChangedWorldEvent(this.bridge$getBukkitEntity(), ((WorldBridge) serverworld).bridge$getWorld()); + Bukkit.getPluginManager().callEvent(changeEvent); + return (ServerPlayerEntity) (Object) this; + } + } + + public Entity a(DimensionType dimensionmanager, final PlayerTeleportEvent.TeleportCause cause) { + bridge$pushChangeDimensionCause(cause); + return this.changeDimension(dimensionmanager); + } + + @Override + public Either sleep(BlockPos at, boolean force) { + return super.sleep(at, force).ifRight((p_213849_1_) -> { + this.addStat(Stats.SLEEP_IN_BED); + CriteriaTriggers.SLEPT_IN_BED.trigger((ServerPlayerEntity) (Object) this); + }); + } + + @Inject(method = "stopSleepInBed", cancellable = true, at = @At("HEAD")) + private void arclight$notWake(boolean flag, boolean flag1, CallbackInfo ci) { + if (!isSleeping()) ci.cancel(); + } + + @Override + public Entity bridge$changeDimension(DimensionType dimensionType, PlayerTeleportEvent.TeleportCause cause) { + return a(dimensionType, cause); + } + public BlockPos getSpawnPoint(ServerWorld worldserver) { BlockPos blockposition = worldserver.getSpawnPoint(); if (worldserver.dimension.hasSkyLight() && worldserver.getWorldInfo().getGameType() != GameType.ADVENTURE) { @@ -313,7 +585,7 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen } this.spawnShoulderEntities(); - this.bridge$dropExperience(); + this.dropExperience(); if (!event.getKeepInventory()) { this.inventory.clear(); @@ -325,7 +597,7 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen if (entityliving != null) { this.addStat(Stats.ENTITY_KILLED_BY.get(entityliving.getType())); entityliving.awardKillScore((ServerPlayerEntity) (Object) this, this.scoreValue, damagesource); - this.bridge$createWitherRose(entityliving); + this.createWitherRose(entityliving); } this.world.setEntityState((ServerPlayerEntity) (Object) this, (byte) 3); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/inventory/container/EnchantmentContainerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/inventory/container/EnchantmentContainerMixin.java index 03ed6c49..a68a1839 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/inventory/container/EnchantmentContainerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/inventory/container/EnchantmentContainerMixin.java @@ -251,7 +251,7 @@ public abstract class EnchantmentContainerMixin extends ContainerMixin implement this.tableInventory.markDirty(); this.xpSeed.set(playerIn.getXPSeed()); this.onCraftMatrixChanged(this.tableInventory); - p_217003_6_.playSound((PlayerEntity) null, p_217003_7_, SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE, SoundCategory.BLOCKS, 1.0F, p_217003_6_.rand.nextFloat() * 0.1F + 0.9F); + p_217003_6_.playSound(null, p_217003_7_, SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE, SoundCategory.BLOCKS, 1.0F, p_217003_6_.rand.nextFloat() * 0.1F + 0.9F); } }); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/BlockItemMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/BlockItemMixin.java index 0711ca01..5f0f2296 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/BlockItemMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/BlockItemMixin.java @@ -1,7 +1,6 @@ package io.izzel.arclight.common.mixin.core.item; import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge; -import io.izzel.arclight.common.bridge.item.BlockItemBridge; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; @@ -21,7 +20,7 @@ import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; @Mixin(BlockItem.class) -public abstract class BlockItemMixin implements BlockItemBridge { +public abstract class BlockItemMixin { // @formatter:off @Shadow protected abstract boolean checkPosition(); @@ -48,7 +47,7 @@ public abstract class BlockItemMixin implements BlockItemBridge { protected boolean canPlace(BlockItemUseContext context, BlockState state) { PlayerEntity playerentity = context.getPlayer(); ISelectionContext iselectioncontext = playerentity == null ? ISelectionContext.dummy() : ISelectionContext.forEntity(playerentity); - boolean original = (!this.checkPosition() || state.isValidPosition(context.getWorld(), context.getPos())) && this.bridge$noCollisionInSel(context.getWorld(), state, context.getPos(), iselectioncontext); + boolean original = (!this.checkPosition() || state.isValidPosition(context.getWorld(), context.getPos())) && context.getWorld().func_226663_a_(state, context.getPos(), iselectioncontext); Player player = (context.getPlayer() instanceof ServerPlayerEntityBridge) ? ((ServerPlayerEntityBridge) context.getPlayer()).bridge$getBukkitEntity() : null; BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(context.getWorld(), context.getPos()), player, CraftBlockData.fromData(state), original); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/BoatItemMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/BoatItemMixin.java index 45ba73ad..5cd52cf1 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/BoatItemMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/BoatItemMixin.java @@ -57,7 +57,7 @@ public class BoatItemMixin extends Item { Vec3d vec3d1 = playerIn.getEyePosition(1.0F); for (Entity entity : list) { - AxisAlignedBB axisalignedbb = entity.getBoundingBox().grow((double) entity.getCollisionBorderSize()); + AxisAlignedBB axisalignedbb = entity.getBoundingBox().grow(entity.getCollisionBorderSize()); if (axisalignedbb.contains(vec3d1)) { return new ActionResult<>(ActionResultType.PASS, itemstack); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/BowItemMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/BowItemMixin.java index 6312d5eb..83282a9e 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/BowItemMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/BowItemMixin.java @@ -105,7 +105,7 @@ public abstract class BowItemMixin extends ShootableItem { } } - worldIn.playSound((PlayerEntity) null, playerentity.posX, playerentity.posY, playerentity.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (random.nextFloat() * 0.4F + 1.2F) + f * 0.5F); + worldIn.playSound(null, playerentity.posX, playerentity.posY, playerentity.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (random.nextFloat() * 0.4F + 1.2F) + f * 0.5F); if (!flag1 && !playerentity.abilities.isCreativeMode) { itemstack.shrink(1); if (itemstack.isEmpty()) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/ChorusFruitItemMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/ChorusFruitItemMixin.java index 26fd828e..928e6aa4 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/ChorusFruitItemMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/ChorusFruitItemMixin.java @@ -39,7 +39,7 @@ public class ChorusFruitItemMixin extends Item { for (int i = 0; i < 16; ++i) { double d3 = entityLiving.posX + (entityLiving.getRNG().nextDouble() - 0.5D) * 16.0D; - double d4 = MathHelper.clamp(entityLiving.posY + (double) (entityLiving.getRNG().nextInt(16) - 8), 0.0D, (double) (worldIn.getActualHeight() - 1)); + double d4 = MathHelper.clamp(entityLiving.posY + (double) (entityLiving.getRNG().nextInt(16) - 8), 0.0D, worldIn.getActualHeight() - 1); double d5 = entityLiving.posZ + (entityLiving.getRNG().nextDouble() - 0.5D) * 16.0D; if (entityLiving instanceof ServerPlayerEntity) { @@ -59,7 +59,7 @@ public class ChorusFruitItemMixin extends Item { } if (entityLiving.attemptTeleport(d3, d4, d5, true)) { - worldIn.playSound((PlayerEntity) null, d0, d1, d2, SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F); + worldIn.playSound(null, d0, d1, d2, SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F); entityLiving.playSound(SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, 1.0F, 1.0F); break; } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/EnderPearlItemMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/EnderPearlItemMixin.java index c3edd175..84596482 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/EnderPearlItemMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/EnderPearlItemMixin.java @@ -43,7 +43,7 @@ public class EnderPearlItemMixin extends Item { } } - worldIn.playSound((PlayerEntity) null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F)); + worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F)); playerIn.getCooldownTracker().setCooldown(this, 20); playerIn.addStat(Stats.ITEM_USED.get(this)); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/item/LeadItemMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/LeadItemMixin.java similarity index 96% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/item/LeadItemMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/LeadItemMixin.java index 8828ba95..305430fd 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/item/LeadItemMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/LeadItemMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.item; +package io.izzel.arclight.common.mixin.core.item; import io.izzel.arclight.common.bridge.entity.EntityBridge; import io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge; @@ -21,7 +21,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; @Mixin(LeadItem.class) -public class LeadItemMixin_1_15 { +public class LeadItemMixin { /** * @author IzzelAliz diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/crafting/RecipeManagerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/crafting/RecipeManagerMixin.java index 6eb2adc8..e910c8f4 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/crafting/RecipeManagerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/crafting/RecipeManagerMixin.java @@ -76,7 +76,7 @@ public abstract class RecipeManagerMixin implements RecipeManagerBridge { } this.recipes = (Map) map; - LOGGER.info("Loaded {} recipes", (int) map.size()); + LOGGER.info("Loaded {} recipes", map.size()); } /** diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/item/crafting/SpecialRecipeMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/crafting/SpecialRecipeMixin.java similarity index 88% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/item/crafting/SpecialRecipeMixin.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/crafting/SpecialRecipeMixin.java index d9bc8f9c..5f019cfe 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/item/crafting/SpecialRecipeMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/item/crafting/SpecialRecipeMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.item.crafting; +package io.izzel.arclight.common.mixin.core.item.crafting; import io.izzel.arclight.common.bridge.item.crafting.IRecipeBridge; import net.minecraft.item.crafting.SpecialRecipe; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/play/ServerPlayNetHandlerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/play/ServerPlayNetHandlerMixin.java index 0e9b2df3..0e1fa39f 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/play/ServerPlayNetHandlerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/play/ServerPlayNetHandlerMixin.java @@ -38,6 +38,7 @@ import net.minecraft.item.Items; import net.minecraft.item.WritableBookItem; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.ListNBT; +import net.minecraft.nbt.StringNBT; import net.minecraft.network.IPacket; import net.minecraft.network.NetworkManager; import net.minecraft.network.PacketThreadUtil; @@ -309,7 +310,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB this.netManager.sendPacket(new SMoveVehiclePacket(entity)); return; } - boolean flag = this.bridge$worldNoCollision(worldserver, entity, entity.getBoundingBox().shrink(0.0625)); + boolean flag = worldserver.hasNoCollisions(entity, entity.getBoundingBox().shrink(0.0625)); d7 = d4 - this.lowestRiddenX1; d8 = d5 - this.lowestRiddenY1 - 1.0E-6; d9 = d6 - this.lowestRiddenZ1; @@ -329,7 +330,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB } entity.setPositionAndRotation(d4, d5, d6, f, f2); this.player.setPositionAndRotation(d4, d5, d6, this.player.rotationYaw, this.player.rotationPitch); - boolean flag3 = this.bridge$worldNoCollision(worldserver, entity, entity.getBoundingBox().shrink(0.0625)); + boolean flag3 = worldserver.hasNoCollisions(entity, entity.getBoundingBox().shrink(0.0625)); if (flag && (flag2 || !flag3)) { entity.setPositionAndRotation(d0, d2, d3, f, f2); this.player.setPositionAndRotation(d0, d2, d3, this.player.rotationYaw, this.player.rotationPitch); @@ -421,14 +422,14 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB if (nbttagcompound != null) { itemstack3.setTag(nbttagcompound.copy()); } - itemstack3.setTagInfo("author", this.bridge$stringNbt(this.player.getName().getString())); - itemstack3.setTagInfo("title", this.bridge$stringNbt(itemstack.getTag().getString("title"))); + itemstack3.setTagInfo("author", StringNBT.valueOf(this.player.getName().getString())); + itemstack3.setTagInfo("title", StringNBT.valueOf(itemstack.getTag().getString("title"))); ListNBT nbttaglist = itemstack.getTag().getList("pages", 8); for (int i = 0; i < nbttaglist.size(); ++i) { String s = nbttaglist.getString(i); StringTextComponent chatcomponenttext = new StringTextComponent(s); s = ITextComponent.Serializer.toJson(chatcomponenttext); - nbttaglist.set(i, this.bridge$stringNbt(s)); + nbttaglist.set(i, StringNBT.valueOf(s)); } itemstack3.setTagInfo("pages", nbttaglist); this.player.setHeldItem(packetplayinbedit.getHand(), CraftEventFactory.handleEditBookEvent(this.player, enumitemslot, itemstack2, itemstack3)); @@ -688,13 +689,13 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB return; } } - this.bridge$dropItems(this.player, false); + this.player.drop(false); } return; } case DROP_ALL_ITEMS: { if (!this.player.isSpectator()) { - this.bridge$dropItems(this.player, true); + this.player.drop(true); } return; } @@ -778,7 +779,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB float f8 = f3 * f5; double d4 = (this.player.interactionManager.getGameType() == GameType.CREATIVE) ? 5.0 : 4.5; Vec3d vec3d2 = vec3d.add(f7 * d4, f6 * d4, f8 * d4); - RayTraceResult movingobjectposition = this.player.world.rayTraceBlocks(new RayTraceContext(vec3d, vec3d2, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, this.player)); + BlockRayTraceResult movingobjectposition = this.player.world.rayTraceBlocks(new RayTraceContext(vec3d, vec3d2, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, this.player)); boolean cancelled; if (movingobjectposition == null || movingobjectposition.getType() != RayTraceResult.Type.BLOCK) { PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack, enumhand); @@ -787,7 +788,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB ((PlayerInteractionManagerBridge) this.player.interactionManager).bridge$setFiredInteract(false); cancelled = ((PlayerInteractionManagerBridge) this.player.interactionManager).bridge$getInteractResult(); } else { - BlockRayTraceResult movingobjectpositionblock = (BlockRayTraceResult) movingobjectposition; + BlockRayTraceResult movingobjectpositionblock = movingobjectposition; PlayerInteractEvent event2 = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_BLOCK, movingobjectpositionblock.getPos(), movingobjectpositionblock.getFace(), itemstack, true, enumhand); cancelled = (event2.useItemInHand() == Event.Result.DENY); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/management/PlayerInteractionManagerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/management/PlayerInteractionManagerMixin.java index 9aedd29f..efcbea80 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/management/PlayerInteractionManagerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/management/PlayerInteractionManagerMixin.java @@ -1,23 +1,34 @@ package io.izzel.arclight.common.mixin.core.server.management; +import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge; import io.izzel.arclight.common.bridge.server.management.PlayerInteractionManagerBridge; import io.izzel.arclight.common.mod.ArclightMod; import io.izzel.arclight.common.mod.util.ArclightCaptures; import net.minecraft.block.BlockState; +import net.minecraft.block.CakeBlock; import net.minecraft.block.DoorBlock; import net.minecraft.block.TrapDoorBlock; import net.minecraft.entity.item.ItemEntity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.inventory.container.INamedContainerProvider; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemUseContext; import net.minecraft.network.play.client.CPlayerDiggingPacket; import net.minecraft.network.play.server.SChangeBlockPacket; +import net.minecraft.network.play.server.SPlayerDiggingPacket; import net.minecraft.server.management.PlayerInteractionManager; import net.minecraft.state.properties.DoubleBlockHalf; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.GameType; +import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; +import net.minecraftforge.common.ForgeHooks; import org.bukkit.craftbukkit.v.block.CraftBlock; import org.bukkit.craftbukkit.v.event.CraftEventFactory; import org.bukkit.event.Event; @@ -51,6 +62,7 @@ public abstract class PlayerInteractionManagerMixin implements PlayerInteraction @Shadow private boolean receivedFinishDiggingPacket; @Shadow private BlockPos delayedDestroyPos; @Shadow private int initialBlockDamage; + @Shadow public abstract void func_229860_a_(BlockPos p_229860_1_, CPlayerDiggingPacket.Action p_229860_2_, String p_229860_3_); // @formatter:on public boolean interactResult = false; @@ -70,18 +82,18 @@ public abstract class PlayerInteractionManagerMixin implements PlayerInteraction dist *= dist; net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock forgeEvent = net.minecraftforge.common.ForgeHooks.onLeftClickBlock(player, blockPos, direction); if (forgeEvent.isCanceled() || (!this.isCreative() && forgeEvent.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY)) { // Restore block and te data - player.connection.sendPacket(this.bridge$diggingPacket(blockPos, world.getBlockState(blockPos), action, false, "mod canceled")); + player.connection.sendPacket(new SPlayerDiggingPacket(blockPos, world.getBlockState(blockPos), action, false, "mod canceled")); world.notifyBlockUpdate(blockPos, world.getBlockState(blockPos), world.getBlockState(blockPos), 3); return; } if (d4 > dist) { - this.player.connection.sendPacket(this.bridge$diggingPacket(blockPos, this.world.getBlockState(blockPos), action, false, "too far")); + this.player.connection.sendPacket(new SPlayerDiggingPacket(blockPos, this.world.getBlockState(blockPos), action, false, "too far")); } else if (blockPos.getY() >= i) { - this.player.connection.sendPacket(this.bridge$diggingPacket(blockPos, this.world.getBlockState(blockPos), action, false, "too high")); + this.player.connection.sendPacket(new SPlayerDiggingPacket(blockPos, this.world.getBlockState(blockPos), action, false, "too high")); } else if (action == CPlayerDiggingPacket.Action.START_DESTROY_BLOCK) { if (!this.world.isBlockModifiable(this.player, blockPos)) { CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockPos, direction, this.player.inventory.getCurrentItem(), Hand.MAIN_HAND); - this.player.connection.sendPacket(this.bridge$diggingPacket(blockPos, this.world.getBlockState(blockPos), action, false, "may not interact")); + this.player.connection.sendPacket(new SPlayerDiggingPacket(blockPos, this.world.getBlockState(blockPos), action, false, "may not interact")); TileEntity tileentity = this.world.getTileEntity(blockPos); if (tileentity != null) { this.player.connection.sendPacket(tileentity.getUpdatePacket()); @@ -99,14 +111,14 @@ public abstract class PlayerInteractionManagerMixin implements PlayerInteraction } if (this.isCreative()) { if (!this.world.extinguishFire(null, blockPos, direction)) { - this.bridge$creativeHarvestBlock(blockPos, action, "creative destroy"); + this.func_229860_a_(blockPos, action, "creative destroy"); } else { - this.player.connection.sendPacket(this.bridge$diggingPacket(blockPos, this.world.getBlockState(blockPos), action, true, "fire put out")); + this.player.connection.sendPacket(new SPlayerDiggingPacket(blockPos, this.world.getBlockState(blockPos), action, true, "fire put out")); } return; } if (this.player.blockActionRestricted(this.world, blockPos, this.gameType)) { - this.player.connection.sendPacket(this.bridge$diggingPacket(blockPos, this.world.getBlockState(blockPos), action, false, "block action restricted")); + this.player.connection.sendPacket(new SPlayerDiggingPacket(blockPos, this.world.getBlockState(blockPos), action, false, "block action restricted")); return; } this.initialDamage = this.ticks; @@ -143,16 +155,16 @@ public abstract class PlayerInteractionManagerMixin implements PlayerInteraction f = 2.0f; } if (!iblockdata.isAir() && f >= 1.0f) { - this.bridge$creativeHarvestBlock(blockPos, action, "insta mine"); + this.func_229860_a_(blockPos, action, "insta mine"); } else { if (this.isDestroyingBlock) { - this.player.connection.sendPacket(this.bridge$diggingPacket(this.destroyPos, this.world.getBlockState(this.destroyPos), CPlayerDiggingPacket.Action.START_DESTROY_BLOCK, false, "abort destroying since another started (client insta mine, server disagreed)")); + this.player.connection.sendPacket(new SPlayerDiggingPacket(this.destroyPos, this.world.getBlockState(this.destroyPos), CPlayerDiggingPacket.Action.START_DESTROY_BLOCK, false, "abort destroying since another started (client insta mine, server disagreed)")); } this.isDestroyingBlock = true; this.destroyPos = blockPos; int j = (int) (f * 10.0f); this.world.sendBlockBreakProgress(this.player.getEntityId(), blockPos, j); - this.player.connection.sendPacket(this.bridge$diggingPacket(blockPos, this.world.getBlockState(blockPos), action, true, "actual start of destroying")); + this.player.connection.sendPacket(new SPlayerDiggingPacket(blockPos, this.world.getBlockState(blockPos), action, true, "actual start of destroying")); this.durabilityRemainingOnBlock = j; } } else if (action == CPlayerDiggingPacket.Action.STOP_DESTROY_BLOCK) { @@ -164,7 +176,7 @@ public abstract class PlayerInteractionManagerMixin implements PlayerInteraction if (f2 >= 0.7f) { this.isDestroyingBlock = false; this.world.sendBlockBreakProgress(this.player.getEntityId(), blockPos, -1); - this.bridge$creativeHarvestBlock(blockPos, action, "destroyed"); + this.func_229860_a_(blockPos, action, "destroyed"); return; } if (!this.receivedFinishDiggingPacket) { @@ -175,16 +187,16 @@ public abstract class PlayerInteractionManagerMixin implements PlayerInteraction } } } - this.player.connection.sendPacket(this.bridge$diggingPacket(blockPos, this.world.getBlockState(blockPos), action, true, "stopped destroying")); + this.player.connection.sendPacket(new SPlayerDiggingPacket(blockPos, this.world.getBlockState(blockPos), action, true, "stopped destroying")); } else if (action == CPlayerDiggingPacket.Action.ABORT_DESTROY_BLOCK) { this.isDestroyingBlock = false; if (!Objects.equals(this.destroyPos, blockPos)) { ArclightMod.LOGGER.debug("Mismatch in destroy block pos: " + this.destroyPos + " " + blockPos); this.world.sendBlockBreakProgress(this.player.getEntityId(), this.destroyPos, -1); - this.player.connection.sendPacket(this.bridge$diggingPacket(this.destroyPos, this.world.getBlockState(this.destroyPos), action, true, "aborted mismatched destroying")); + this.player.connection.sendPacket(new SPlayerDiggingPacket(this.destroyPos, this.world.getBlockState(this.destroyPos), action, true, "aborted mismatched destroying")); } this.world.sendBlockBreakProgress(this.player.getEntityId(), blockPos, -1); - this.player.connection.sendPacket(this.bridge$diggingPacket(blockPos, this.world.getBlockState(blockPos), action, true, "aborted destroying")); + this.player.connection.sendPacket(new SPlayerDiggingPacket(blockPos, this.world.getBlockState(blockPos), action, true, "aborted destroying")); } } @@ -218,4 +230,77 @@ public abstract class PlayerInteractionManagerMixin implements PlayerInteraction public void bridge$setInteractResult(boolean b) { this.interactResult = b; } + + /** + * @author IzzelAliz + * @reason + */ + @Overwrite + public ActionResultType func_219441_a(PlayerEntity playerIn, World worldIn, ItemStack stackIn, Hand handIn, BlockRayTraceResult blockRaytraceResultIn) { + BlockPos blockpos = blockRaytraceResultIn.getPos(); + BlockState blockstate = worldIn.getBlockState(blockpos); + ActionResultType resultType = ActionResultType.PASS; + boolean cancelledBlock = false; + if (this.gameType == GameType.SPECTATOR) { + INamedContainerProvider provider = blockstate.getContainer(worldIn, blockpos); + cancelledBlock = !(provider instanceof INamedContainerProvider); + } + if (playerIn.getCooldownTracker().hasCooldown(stackIn.getItem())) { + cancelledBlock = true; + } + + PlayerInteractEvent bukkitEvent = CraftEventFactory.callPlayerInteractEvent(playerIn, Action.RIGHT_CLICK_BLOCK, blockpos, blockRaytraceResultIn.getFace(), stackIn, cancelledBlock, handIn); + bridge$setFiredInteract(true); + bridge$setInteractResult(bukkitEvent.useItemInHand() == Event.Result.DENY); + if (bukkitEvent.useInteractedBlock() == Event.Result.DENY) { + if (blockstate.getBlock() instanceof DoorBlock) { + boolean bottom = blockstate.get(DoorBlock.HALF) == DoubleBlockHalf.LOWER; + ((ServerPlayerEntity) playerIn).connection.sendPacket(new SChangeBlockPacket(this.world, bottom ? blockpos.up() : blockpos.down())); + } else if (blockstate.getBlock() instanceof CakeBlock) { + ((ServerPlayerEntityBridge) playerIn).bridge$getBukkitEntity().sendHealthUpdate(); + } + ((ServerPlayerEntityBridge) playerIn).bridge$getBukkitEntity().updateInventory(); + resultType = ((bukkitEvent.useItemInHand() != Event.Result.ALLOW) ? ActionResultType.SUCCESS : ActionResultType.PASS); + } else if (this.gameType == GameType.SPECTATOR) { + INamedContainerProvider inamedcontainerprovider = blockstate.getContainer(worldIn, blockpos); + if (inamedcontainerprovider != null) { + playerIn.openContainer(inamedcontainerprovider); + return ActionResultType.SUCCESS; + } else { + return ActionResultType.PASS; + } + } else { + net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock event = ForgeHooks.onRightClickBlock(playerIn, handIn, blockpos, blockRaytraceResultIn.getFace()); + if (event.isCanceled()) return event.getCancellationResult(); + ItemUseContext itemusecontext = new ItemUseContext(playerIn, handIn, blockRaytraceResultIn); + if (event.getUseItem() != net.minecraftforge.eventbus.api.Event.Result.DENY) { + ActionResultType result = stackIn.onItemUseFirst(itemusecontext); + if (result != ActionResultType.PASS) return result; + } + boolean flag = !playerIn.getHeldItemMainhand().isEmpty() || !playerIn.getHeldItemOffhand().isEmpty(); + boolean flag1 = (playerIn.isSecondaryUseActive() && flag) && !(playerIn.getHeldItemMainhand().doesSneakBypassUse(worldIn, blockpos, playerIn) && playerIn.getHeldItemOffhand().doesSneakBypassUse(worldIn, blockpos, playerIn)); + if (event.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY && !flag1) { + resultType = blockstate.onBlockActivated(worldIn, playerIn, handIn, blockRaytraceResultIn); + if (resultType.isSuccessOrConsume()) { + return resultType; + } + } + if (!stackIn.isEmpty() && resultType != ActionResultType.SUCCESS && !bridge$getInteractResult()) { + if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY) { + return ActionResultType.PASS; + } + if (this.isCreative()) { + int i = stackIn.getCount(); + resultType = stackIn.onItemUse(itemusecontext); + stackIn.setCount(i); + return resultType; + } else { + return stackIn.onItemUse(itemusecontext); + } + } else { + return resultType; + } + } + return resultType; + } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/management/PlayerListMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/management/PlayerListMixin.java index 56c48dac..17a11ded 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/management/PlayerListMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/management/PlayerListMixin.java @@ -27,7 +27,9 @@ import net.minecraft.network.login.ServerLoginNetHandler; import net.minecraft.network.play.server.SChangeGameStatePacket; import net.minecraft.network.play.server.SChatPacket; import net.minecraft.network.play.server.SEntityStatusPacket; +import net.minecraft.network.play.server.SJoinGamePacket; import net.minecraft.network.play.server.SPlayEntityEffectPacket; +import net.minecraft.network.play.server.SRespawnPacket; import net.minecraft.network.play.server.SServerDifficultyPacket; import net.minecraft.network.play.server.SSetExperiencePacket; import net.minecraft.network.play.server.SSpawnPositionPacket; @@ -48,8 +50,10 @@ import net.minecraft.util.text.ChatType; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.GameRules; +import net.minecraft.world.GameType; import net.minecraft.world.IWorld; import net.minecraft.world.World; +import net.minecraft.world.WorldType; import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.server.ServerWorld; import net.minecraft.world.storage.IPlayerFileData; @@ -151,6 +155,11 @@ public abstract class PlayerListMixin implements PlayerListBridge { ((ServerPlayerEntityBridge) playerIn).bridge$getBukkitEntity().sendSupportedChannels(); } + @Redirect(method = "initializeConnectionToPlayer", at = @At(value = "NEW", target = "net/minecraft/network/play/server/SJoinGamePacket")) + private SJoinGamePacket arclight$spawnPacket(int playerId, GameType gameType, long hashedSeed, boolean hardcoreMode, DimensionType dimensionType, int maxPlayers, WorldType worldType, int viewDistance, boolean reducedDebugInfo, boolean enableRespawnScreen, NetworkManager netManager, ServerPlayerEntity playerIn) { + return new SJoinGamePacket(playerId, gameType, hashedSeed, hardcoreMode, ((DimensionTypeBridge) dimensionType).bridge$getType(), maxPlayers, worldType, ((ServerWorldBridge) playerIn.getServerWorld()).bridge$spigotConfig().viewDistance, reducedDebugInfo, enableRespawnScreen); + } + @Inject(method = "func_212504_a", cancellable = true, at = @At("HEAD")) private void arclight$returnIfSet(ServerWorld world, CallbackInfo ci) { if (this.playerDataManager != null) { @@ -240,7 +249,7 @@ public abstract class PlayerListMixin implements PlayerListBridge { isBedSpawn = true; location = new Location(cworld, vec3d.x, vec3d.y, vec3d.z); } else { - this.bridge$setSpawnPoint(playerIn, null, true, playerIn.dimension, false); + playerIn.setSpawnPoint(null, true, false, playerIn.dimension); playerIn.connection.sendPacket(new SChangeGameStatePacket(0, 0.0f)); } } @@ -269,11 +278,11 @@ public abstract class PlayerListMixin implements PlayerListBridge { playerIn.setPosition(playerIn.getPosX(), playerIn.getPosY() + 1.0, playerIn.getPosZ()); } if (fromWorld.getEnvironment() == ((WorldBridge) serverWorld).bridge$getWorld().getEnvironment()) { - playerIn.connection.sendPacket(this.bridge$respawnPacket((serverWorld.dimension.getType().getId() >= 0) ? DimensionType.THE_NETHER : DimensionType.OVERWORLD, serverWorld.getWorldInfo().getSeed(), serverWorld.getWorldInfo().getGenerator(), playerIn.interactionManager.getGameType())); + playerIn.connection.sendPacket(new SRespawnPacket((serverWorld.dimension.getType().getId() >= 0) ? DimensionType.THE_NETHER : DimensionType.OVERWORLD, WorldInfo.byHashing(serverWorld.getWorldInfo().getSeed()), serverWorld.getWorldInfo().getGenerator(), playerIn.interactionManager.getGameType())); } WorldInfo worldInfo = serverWorld.getWorldInfo(); net.minecraftforge.fml.network.NetworkHooks.sendDimensionDataPacket(playerIn.connection.netManager, playerIn); - playerIn.connection.sendPacket(this.bridge$respawnPacket(((DimensionTypeBridge) serverWorld.dimension.getType()).bridge$getType(), serverWorld.getWorldInfo().getSeed(), serverWorld.getWorldInfo().getGenerator(), playerIn.interactionManager.getGameType())); + playerIn.connection.sendPacket(new SRespawnPacket(((DimensionTypeBridge) serverWorld.dimension.getType()).bridge$getType(), WorldInfo.byHashing(serverWorld.getWorldInfo().getSeed()), serverWorld.getWorldInfo().getGenerator(), playerIn.interactionManager.getGameType())); playerIn.connection.sendPacket(new SUpdateViewDistancePacket(((ServerWorldBridge) serverWorld).bridge$spigotConfig().viewDistance)); playerIn.setWorld(serverWorld); playerIn.interactionManager.setWorld(serverWorld); @@ -359,7 +368,7 @@ public abstract class PlayerListMixin implements PlayerListBridge { isBedSpawn = true; location = new Location(cworld, vec3d.x, vec3d.y, vec3d.z); } else { - this.bridge$setSpawnPoint(playerIn, null, true, playerIn.dimension, false); + playerIn.setSpawnPoint(null, true, false, playerIn.dimension); playerIn.connection.sendPacket(new SChangeGameStatePacket(0, 0.0f)); } } @@ -414,17 +423,17 @@ public abstract class PlayerListMixin implements PlayerListBridge { this.setPlayerGameTypeBasedOnOther(serverplayerentity, playerIn, serverworld); - while (avoidSuffocation && !this.bridge$worldNoCollision(serverworld, serverplayerentity) && serverplayerentity.posY < 256.0D) { + while (avoidSuffocation && !serverworld.hasNoCollisions(serverplayerentity) && serverplayerentity.posY < 256.0D) { serverplayerentity.setPosition(serverplayerentity.posX, serverplayerentity.posY + 1.0D, serverplayerentity.posZ); } if (fromWorld.getEnvironment() == ((WorldBridge) serverworld).bridge$getWorld().getEnvironment()) { - serverplayerentity.connection.sendPacket(this.bridge$respawnPacket((((DimensionTypeBridge) serverplayerentity.dimension).bridge$getType().getId() >= 0) ? DimensionType.THE_NETHER : DimensionType.OVERWORLD, serverworld.getWorldInfo().getSeed(), serverworld.getWorldInfo().getGenerator(), playerIn.interactionManager.getGameType())); + serverplayerentity.connection.sendPacket(new SRespawnPacket((((DimensionTypeBridge) serverplayerentity.dimension).bridge$getType().getId() >= 0) ? DimensionType.THE_NETHER : DimensionType.OVERWORLD, WorldInfo.byHashing(serverworld.getWorldInfo().getSeed()), serverworld.getWorldInfo().getGenerator(), playerIn.interactionManager.getGameType())); } WorldInfo worldinfo = serverplayerentity.world.getWorldInfo(); NetworkHooks.sendDimensionDataPacket(serverplayerentity.connection.netManager, serverplayerentity); - serverplayerentity.connection.sendPacket(this.bridge$respawnPacket(((DimensionTypeBridge) serverplayerentity.dimension).bridge$getType(), worldinfo.getSeed(), worldinfo.getGenerator(), serverplayerentity.interactionManager.getGameType())); + serverplayerentity.connection.sendPacket(new SRespawnPacket(((DimensionTypeBridge) serverplayerentity.dimension).bridge$getType(), WorldInfo.byHashing(worldinfo.getSeed()), worldinfo.getGenerator(), serverplayerentity.interactionManager.getGameType())); serverplayerentity.connection.sendPacket(new SUpdateViewDistancePacket(((WorldBridge) serverworld).bridge$spigotConfig().viewDistance)); BlockPos blockpos1 = serverworld.getSpawnPoint(); serverplayerentity.connection.setPlayerLocation(serverplayerentity.posX, serverplayerentity.posY, serverplayerentity.posZ, serverplayerentity.rotationYaw, serverplayerentity.rotationPitch); @@ -456,7 +465,7 @@ public abstract class PlayerListMixin implements PlayerListBridge { public void sendAll(IPacket packet, PlayerEntity entityhuman) { for (ServerPlayerEntity entityplayer : this.players) { - if (entityhuman == null || !(entityhuman instanceof ServerPlayerEntity) || ((ServerPlayerEntityBridge) entityplayer).bridge$getBukkitEntity().canSee(((ServerPlayerEntityBridge) entityhuman).bridge$getBukkitEntity())) { + if (!(entityhuman instanceof ServerPlayerEntity) || ((ServerPlayerEntityBridge) entityplayer).bridge$getBukkitEntity().canSee(((ServerPlayerEntityBridge) entityhuman).bridge$getBukkitEntity())) { entityplayer.connection.sendPacket(packet); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/tileentity/BeehiveTileEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/tileentity/BeehiveTileEntityMixin.java similarity index 97% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/tileentity/BeehiveTileEntityMixin.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/tileentity/BeehiveTileEntityMixin.java index 1683458d..e28b572e 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/tileentity/BeehiveTileEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/tileentity/BeehiveTileEntityMixin.java @@ -1,9 +1,8 @@ -package io.izzel.arclight.common.mixin.v1_15.tileentity; +package io.izzel.arclight.common.mixin.core.tileentity; import com.google.common.collect.Lists; import io.izzel.arclight.common.bridge.entity.EntityBridge; import io.izzel.arclight.common.bridge.world.WorldBridge; -import io.izzel.arclight.common.mixin.core.tileentity.TileEntityMixin; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/ExplosionMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/ExplosionMixin.java index c76d04ee..0a8d34be 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/ExplosionMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/ExplosionMixin.java @@ -2,10 +2,14 @@ package io.izzel.arclight.common.mixin.core.world; import com.google.common.collect.Lists; import com.google.common.collect.Sets; +import com.mojang.datafixers.util.Pair; import io.izzel.arclight.common.bridge.entity.EntityBridge; import io.izzel.arclight.common.bridge.world.ExplosionBridge; import io.izzel.arclight.common.bridge.world.WorldBridge; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import net.minecraft.block.Block; import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.enchantment.ProtectionEnchantment; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; @@ -14,17 +18,26 @@ import net.minecraft.entity.item.TNTEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.projectile.DamagingProjectileEntity; import net.minecraft.fluid.IFluidState; +import net.minecraft.item.ItemStack; +import net.minecraft.particles.ParticleTypes; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.DamageSource; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.SoundEvents; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.Explosion; import net.minecraft.world.World; +import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.storage.loot.LootContext; +import net.minecraft.world.storage.loot.LootParameters; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.craftbukkit.v.event.CraftEventFactory; import org.bukkit.event.block.BlockExplodeEvent; +import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -37,8 +50,10 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import javax.annotation.Nullable; +import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Random; import java.util.Set; @Mixin(Explosion.class) @@ -59,6 +74,9 @@ public abstract class ExplosionMixin implements ExplosionBridge { @Accessor("size") public abstract float bridge$getSize(); @Accessor("size") public abstract void bridge$setSize(float size); @Accessor("mode") public abstract Explosion.Mode bridge$getMode(); + @Shadow @Final private boolean causesFire; + @Shadow @Final private Random random; + @Shadow private static void func_229976_a_(ObjectArrayList> p_229976_0_, ItemStack p_229976_1_, BlockPos p_229976_2_) { } // @formatter:on @Inject(method = "(Lnet/minecraft/world/World;Lnet/minecraft/entity/Entity;DDDFZLnet/minecraft/world/Explosion$Mode;)V", @@ -135,7 +153,7 @@ public abstract class ExplosionMixin implements ExplosionBridge { double d12 = MathHelper.sqrt(entity.getDistanceSq(vec3d)) / f3; if (d12 <= 1.0D) { double d5 = entity.posX - this.x; - double d7 = ((EntityBridge) entity).bridge$getEyeHeight() - this.y; + double d7 = entity.getPosYEye() - this.y; double d9 = entity.posZ - this.z; double d13 = MathHelper.sqrt(d5 * d5 + d7 * d7 + d9 * d9); if (d13 != 0.0D) { @@ -172,8 +190,89 @@ public abstract class ExplosionMixin implements ExplosionBridge { } + public boolean wasCanceled = false; + @Override - public float bridge$callBlockExplodeEvent() { + public boolean bridge$wasCancelled() { + return wasCanceled; + } + + /** + * @author IzzelAliz + * @reason + */ + @Overwrite + public void doExplosionB(boolean spawnParticles) { + if (this.world.isRemote) { + this.world.playSound(this.x, this.y, this.z, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4.0F, (1.0F + (this.world.rand.nextFloat() - this.world.rand.nextFloat()) * 0.2F) * 0.7F, false); + } + + boolean flag = this.mode != Explosion.Mode.NONE; + if (spawnParticles) { + if (!(this.size < 2.0F) && flag) { + this.world.addParticle(ParticleTypes.EXPLOSION_EMITTER, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D); + } else { + this.world.addParticle(ParticleTypes.EXPLOSION, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D); + } + } + + if (flag) { + ObjectArrayList> objectarraylist = new ObjectArrayList<>(); + Collections.shuffle(this.affectedBlockPositions, this.world.rand); + + float yield = this.callBlockExplodeEvent(); + + if (Float.isNaN(yield)) { + this.wasCanceled = true; + return; + } + + for (BlockPos blockpos : this.affectedBlockPositions) { + BlockState blockstate = this.world.getBlockState(blockpos); + Block block = blockstate.getBlock(); + if (!blockstate.isAir(this.world, blockpos)) { + BlockPos blockpos1 = blockpos.toImmutable(); + this.world.getProfiler().startSection("explosion_blocks"); + if (blockstate.canDropFromExplosion(this.world, blockpos, (Explosion) (Object) this) && this.world instanceof ServerWorld) { + TileEntity tileentity = blockstate.hasTileEntity() ? this.world.getTileEntity(blockpos) : null; + LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerWorld) this.world)).withRandom(this.world.rand).withParameter(LootParameters.POSITION, blockpos).withParameter(LootParameters.TOOL, ItemStack.EMPTY).withNullableParameter(LootParameters.BLOCK_ENTITY, tileentity).withNullableParameter(LootParameters.THIS_ENTITY, this.exploder); + if (this.mode == Explosion.Mode.DESTROY || yield < 1.0F) { + lootcontext$builder.withParameter(LootParameters.EXPLOSION_RADIUS, 1.0F / yield); + } + + blockstate.getDrops(lootcontext$builder).forEach((p_229977_2_) -> { + func_229976_a_(objectarraylist, p_229977_2_, blockpos1); + }); + } + + blockstate.onBlockExploded(this.world, blockpos, (Explosion) (Object) this); + this.world.getProfiler().endSection(); + } + } + + for (Pair pair : objectarraylist) { + Block.spawnAsEntity(this.world, pair.getSecond(), pair.getFirst()); + } + } + + if (this.causesFire) { + for (BlockPos blockpos2 : this.affectedBlockPositions) { + if (this.random.nextInt(3) == 0 && this.world.getBlockState(blockpos2).isAir() && this.world.getBlockState(blockpos2.down()).isOpaqueCube(this.world, blockpos2.down())) { + BlockIgniteEvent event = CraftEventFactory.callBlockIgniteEvent(this.world, blockpos2.getX(), blockpos2.getY(), blockpos2.getZ(), (Explosion) (Object) this); + if (!event.isCancelled()) { + this.world.setBlockState(blockpos2, Blocks.FIRE.getDefaultState()); + } + } + } + } + } + + @Inject(method = "func_229976_a_", cancellable = true, at = @At("HEAD")) + private static void arclight$fix(ObjectArrayList> p_229976_0_, ItemStack stack, BlockPos p_229976_2_, CallbackInfo ci) { + if (stack.isEmpty()) ci.cancel(); + } + + private float callBlockExplodeEvent() { org.bukkit.World world = ((WorldBridge) this.world).bridge$getWorld(); org.bukkit.entity.Entity exploder = this.exploder == null ? null : ((EntityBridge) this.exploder).bridge$getBukkitEntity(); Location location = new Location(world, this.x, this.y, this.z); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/TeleporterMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/TeleporterMixin.java similarity index 99% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/TeleporterMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/TeleporterMixin.java index 0414bace..96aaebc3 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/TeleporterMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/TeleporterMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.world; +package io.izzel.arclight.common.mixin.core.world; import io.izzel.arclight.common.bridge.entity.EntityBridge; import io.izzel.arclight.common.bridge.world.TeleporterBridge; @@ -38,7 +38,7 @@ import java.util.Random; import java.util.stream.Collectors; @Mixin(Teleporter.class) -public abstract class TeleporterMixin_1_15 implements TeleporterBridge { +public abstract class TeleporterMixin implements TeleporterBridge { // @formatter:off @Shadow @Final protected ServerWorld world; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/WorldMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/WorldMixin.java index 1b2b9f13..bfc49b29 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/WorldMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/WorldMixin.java @@ -3,6 +3,7 @@ package io.izzel.arclight.common.mixin.core.world; import io.izzel.arclight.api.ArclightVersion; import io.izzel.arclight.common.bridge.world.WorldBridge; import io.izzel.arclight.common.bridge.world.border.WorldBorderBridge; +import io.izzel.arclight.common.bridge.world.dimension.DimensionTypeBridge; import io.izzel.arclight.common.bridge.world.storage.DerivedWorldInfoBridge; import io.izzel.arclight.common.mod.util.ArclightCaptures; import net.minecraft.block.Block; @@ -35,6 +36,7 @@ import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @@ -176,6 +178,11 @@ public abstract class WorldMixin implements WorldBridge { } } + @Redirect(method = "isNightTime", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/dimension/Dimension;getType()Lnet/minecraft/world/dimension/DimensionType;")) + private DimensionType arclight$nightTimeType(Dimension dimension) { + return ((DimensionTypeBridge) dimension.getType()).bridge$getType(); + } + public CraftServer getServer() { return (CraftServer) Bukkit.getServer(); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/biome/BiomeContainerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/biome/BiomeContainerMixin.java similarity index 93% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/biome/BiomeContainerMixin.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/biome/BiomeContainerMixin.java index 8377a5e7..3b1170cf 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/biome/BiomeContainerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/biome/BiomeContainerMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.world.biome; +package io.izzel.arclight.common.mixin.core.world.biome; import net.minecraft.util.math.MathHelper; import net.minecraft.world.biome.Biome; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/chunk/ChunkMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/chunk/ChunkMixin.java index 5f3e4ad9..7c9bfd92 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/chunk/ChunkMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/chunk/ChunkMixin.java @@ -2,13 +2,20 @@ package io.izzel.arclight.common.mixin.core.world.chunk; import io.izzel.arclight.common.bridge.world.WorldBridge; import io.izzel.arclight.common.bridge.world.chunk.ChunkBridge; +import net.minecraft.block.Block; import net.minecraft.block.BlockState; +import net.minecraft.fluid.Fluid; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; +import net.minecraft.util.palette.UpgradeData; +import net.minecraft.world.ITickList; import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeContainer; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.ChunkPrimer; +import net.minecraft.world.chunk.ChunkSection; import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v.CraftChunk; import org.bukkit.event.world.ChunkLoadEvent; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -20,6 +27,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import javax.annotation.Nullable; +import java.util.function.Consumer; @Mixin(Chunk.class) public abstract class ChunkMixin implements ChunkBridge { @@ -38,6 +46,11 @@ public abstract class ChunkMixin implements ChunkBridge { public boolean needsDecoration; private transient boolean arclight$doPlace; + @Inject(method = "(Lnet/minecraft/world/World;Lnet/minecraft/util/math/ChunkPos;Lnet/minecraft/world/biome/BiomeContainer;Lnet/minecraft/util/palette/UpgradeData;Lnet/minecraft/world/ITickList;Lnet/minecraft/world/ITickList;J[Lnet/minecraft/world/chunk/ChunkSection;Ljava/util/function/Consumer;)V", at = @At("RETURN")) + private void arclight$init(World worldIn, ChunkPos chunkPosIn, BiomeContainer biomeContainerIn, UpgradeData upgradeDataIn, ITickList tickBlocksIn, ITickList tickFluidsIn, long inhabitedTimeIn, ChunkSection[] sectionsIn, Consumer postLoadConsumerIn, CallbackInfo ci) { + bridge$setBukkitChunk(new CraftChunk((Chunk) (Object) this)); + } + public org.bukkit.Chunk getBukkitChunk() { return bukkitChunk; } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/dimension/DimensionTypeMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/dimension/DimensionTypeMixin.java similarity index 93% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/dimension/DimensionTypeMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/dimension/DimensionTypeMixin.java index 9665f47e..49e166fc 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/dimension/DimensionTypeMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/dimension/DimensionTypeMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.world.dimension; +package io.izzel.arclight.common.mixin.core.world.dimension; import io.izzel.arclight.common.bridge.world.dimension.DimensionTypeBridge; import net.minecraft.world.World; @@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import java.util.function.BiFunction; @Mixin(DimensionType.class) -public class DimensionTypeMixin_1_15 implements DimensionTypeBridge { +public class DimensionTypeMixin implements DimensionTypeBridge { protected void arclight$constructor(int idIn, String suffixIn, String directoryIn, BiFunction p_i49935_4_, boolean p_i49935_5_, IBiomeMagnifier p_i225789_6_) { throw new RuntimeException(); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/gen/feature/structure/SwampHutPieceMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/gen/feature/structure/SwampHutPieceMixin.java similarity index 90% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/gen/feature/structure/SwampHutPieceMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/gen/feature/structure/SwampHutPieceMixin.java index 1d5167d5..b976825d 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/gen/feature/structure/SwampHutPieceMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/gen/feature/structure/SwampHutPieceMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.world.gen.feature.structure; +package io.izzel.arclight.common.mixin.core.world.gen.feature.structure; import io.izzel.arclight.common.bridge.world.IWorldWriterBridge; import net.minecraft.util.math.ChunkPos; @@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import java.util.Random; @Mixin(SwampHutPiece.class) -public class SwampHutPieceMixin_1_15 { +public class SwampHutPieceMixin { @Inject(method = "create", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/IWorld;addEntity(Lnet/minecraft/entity/Entity;)Z")) public void arclight$spawnReason(IWorld worldIn, ChunkGenerator chunkGeneratorIn, Random randomIn, MutableBoundingBox mutableBoundingBoxIn, ChunkPos chunkPosIn, CallbackInfoReturnable cir) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/server/ServerChunkProviderMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/server/ServerChunkProviderMixin.java index 02709aa7..3494ee26 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/server/ServerChunkProviderMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/server/ServerChunkProviderMixin.java @@ -24,6 +24,7 @@ import net.minecraft.world.server.ServerWorld; import net.minecraft.world.server.ServerWorldLightManager; import net.minecraft.world.server.TicketManager; import net.minecraft.world.server.TicketType; +import net.minecraft.world.spawner.WorldEntitySpawner; import net.minecraft.world.storage.WorldInfo; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -174,7 +175,7 @@ public abstract class ServerChunkProviderMixin implements ServerChunkProviderBri if (entityclassification != EntityClassification.MISC && (!entityclassification.getPeacefulCreature() || this.spawnPassives) && (entityclassification.getPeacefulCreature() || this.spawnHostiles) && (!entityclassification.getAnimal() || flag2)) { int i1 = limit * l / field_217238_b; if (object2intmap.getInt(entityclassification) <= i1) { - this.bridge$worldNaturalSpawn(entityclassification, this.world, chunk, blockpos); + WorldEntitySpawner.spawnEntitiesInChunk(entityclassification, this.world, chunk, blockpos); } } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/server/ServerMultiWorldMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/server/ServerMultiWorldMixin.java similarity index 89% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/server/ServerMultiWorldMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/server/ServerMultiWorldMixin.java index c2eefd3f..fc4d5dba 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/server/ServerMultiWorldMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/server/ServerMultiWorldMixin.java @@ -1,6 +1,5 @@ -package io.izzel.arclight.common.mixin.v1_15.world.server; +package io.izzel.arclight.common.mixin.core.world.server; -import io.izzel.arclight.common.mixin.core.world.server.ServerWorldMixin; import net.minecraft.profiler.IProfiler; import net.minecraft.server.MinecraftServer; import net.minecraft.world.border.IBorderListener; @@ -18,7 +17,7 @@ import org.spongepowered.asm.mixin.Shadow; import java.util.concurrent.Executor; @Mixin(ServerMultiWorld.class) -public abstract class ServerMultiWorldMixin_1_15 extends ServerWorldMixin { +public abstract class ServerMultiWorldMixin extends ServerWorldMixin { // @formatter:off @Shadow(remap = false) @Final @Mutable private ServerWorld delegate; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/server/ServerWorldMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/server/ServerWorldMixin.java index 8e4e972a..76a5bc55 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/server/ServerWorldMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/server/ServerWorldMixin.java @@ -18,6 +18,7 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityClassification; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.MobEntity; import net.minecraft.entity.effect.LightningBoltEntity; import net.minecraft.entity.player.ServerPlayerEntity; @@ -52,6 +53,7 @@ import org.bukkit.entity.LightningStrike; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.server.MapInitializeEvent; import org.bukkit.event.weather.LightningStrikeEvent; +import org.bukkit.event.world.TimeSkipEvent; import org.bukkit.event.world.WorldSaveEvent; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Final; @@ -90,6 +92,8 @@ public abstract class ServerWorldMixin extends WorldMixin implements ServerWorld @Shadow @Final public Int2ObjectMap entitiesById; @Shadow public abstract ServerChunkProvider getChunkProvider(); @Shadow @Final @Mutable @Nullable private WanderingTraderSpawner wanderingTraderSpawner; + @Shadow private boolean allPlayersSleeping; + @Shadow protected abstract void wakeUpAllPlayers(); // @formatter:on public void arclight$constructor(MinecraftServer serverIn, Executor executor, SaveHandler saveHandler, WorldInfo worldInfo, DimensionType dimType, IProfiler profiler, IChunkStatusListener listener) { @@ -104,7 +108,7 @@ public abstract class ServerWorldMixin extends WorldMixin implements ServerWorld } public int sendParticles(final ServerPlayerEntity sender, final T t0, final double d0, final double d1, final double d2, final int i, final double d3, final double d4, final double d5, final double d6, final boolean force) { - SSpawnParticlePacket packet = new SSpawnParticlePacket((T) t0, force, d0, d1, d2, (float) d3, (float) d4, (float) d5, (float) d6, i); + SSpawnParticlePacket packet = new SSpawnParticlePacket(t0, force, d0, d1, d2, (float) d3, (float) d4, (float) d5, (float) d6, i); int j = 0; for (ServerPlayerEntity entity : this.players) { if (sender == null || ((ServerPlayerEntityBridge) entity).bridge$getBukkitEntity().canSee(((ServerPlayerEntityBridge) sender).bridge$getBukkitEntity())) { @@ -368,4 +372,25 @@ public abstract class ServerWorldMixin extends WorldMixin implements ServerWorld } return map; } + + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setDayTime(J)V")) + private void arclight$timeSkip(ServerWorld world, long time) { + TimeSkipEvent event = new TimeSkipEvent(this.bridge$getWorld(), TimeSkipEvent.SkipReason.NIGHT_SKIP, (time - time % 24000L) - this.getDayTime()); + Bukkit.getPluginManager().callEvent(event); + arclight$timeSkipCancelled = event.isCancelled(); + if (!event.isCancelled()) { + world.setDayTime(this.getDayTime() + event.getSkipAmount()); + this.allPlayersSleeping = this.players.stream().allMatch(LivingEntity::isSleeping); + } + } + + private transient boolean arclight$timeSkipCancelled; + + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;wakeUpAllPlayers()V")) + private void arclight$notWakeIfCancelled(ServerWorld world) { + if (!arclight$timeSkipCancelled) { + this.wakeUpAllPlayers(); + } + arclight$timeSkipCancelled = false; + } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/server/TicketManagerMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/server/TicketManagerMixin.java similarity index 97% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/server/TicketManagerMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/server/TicketManagerMixin.java index bb95c407..d2188adc 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/server/TicketManagerMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/server/TicketManagerMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.world.server; +package io.izzel.arclight.common.mixin.core.world.server; import io.izzel.arclight.common.bridge.world.server.TicketManagerBridge; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; @@ -16,7 +16,7 @@ import org.spongepowered.asm.mixin.gen.Invoker; import java.util.Iterator; @Mixin(TicketManager.class) -public abstract class TicketManagerMixin_1_15 implements TicketManagerBridge { +public abstract class TicketManagerMixin implements TicketManagerBridge { // @formatter:off @Shadow private long currentTime; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/AbstractSpawnerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/AbstractSpawnerMixin.java index 16ba09a4..e99d010a 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/AbstractSpawnerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/AbstractSpawnerMixin.java @@ -5,7 +5,6 @@ import io.izzel.arclight.common.bridge.world.WorldBridge; import net.minecraft.entity.Entity; import net.minecraft.entity.EntitySpawnPlacementRegistry; import net.minecraft.entity.EntityType; -import net.minecraft.entity.ILivingEntityData; import net.minecraft.entity.MobEntity; import net.minecraft.entity.SpawnReason; import net.minecraft.nbt.CompoundNBT; @@ -117,7 +116,7 @@ public abstract class AbstractSpawnerMixin { return; } - int k = world.getEntitiesWithinAABB(entity.getClass(), (new AxisAlignedBB((double) blockpos.getX(), (double) blockpos.getY(), (double) blockpos.getZ(), (double) (blockpos.getX() + 1), (double) (blockpos.getY() + 1), (double) (blockpos.getZ() + 1))).grow((double) this.spawnRange)).size(); + int k = world.getEntitiesWithinAABB(entity.getClass(), (new AxisAlignedBB(blockpos.getX(), blockpos.getY(), blockpos.getZ(), blockpos.getX() + 1, blockpos.getY() + 1, blockpos.getZ() + 1)).grow(this.spawnRange)).size(); if (k >= this.maxNearbyEntities) { this.resetTimer(); return; @@ -131,7 +130,7 @@ public abstract class AbstractSpawnerMixin { } if (this.spawnData.getNbt().size() == 1 && this.spawnData.getNbt().contains("id", 8)) { - ((MobEntity) entity).onInitialSpawn(world, world.getDifficultyForLocation(new BlockPos(entity)), SpawnReason.SPAWNER, (ILivingEntityData) null, (CompoundNBT) null); + ((MobEntity) entity).onInitialSpawn(world, world.getDifficultyForLocation(new BlockPos(entity)), SpawnReason.SPAWNER, null, null); } if (((WorldBridge) mobentity.world).bridge$spigotConfig().nerfSpawnerMobs) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/spawner/WorldEntitySpawnerMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/WorldEntitySpawnerMixin.java similarity index 93% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/spawner/WorldEntitySpawnerMixin_1_15.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/WorldEntitySpawnerMixin.java index 75f42856..a1840bde 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/spawner/WorldEntitySpawnerMixin_1_15.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/WorldEntitySpawnerMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.world.spawner; +package io.izzel.arclight.common.mixin.core.world.spawner; import io.izzel.arclight.common.bridge.world.IWorldWriterBridge; import io.izzel.arclight.common.bridge.world.WorldBridge; @@ -18,7 +18,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.Random; @Mixin(WorldEntitySpawner.class) -public class WorldEntitySpawnerMixin_1_15 { +public class WorldEntitySpawnerMixin { @Inject(method = "spawnEntitiesInChunk", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;addEntity(Lnet/minecraft/entity/Entity;)Z")) private static void arclight$naturalSpawn(EntityClassification p_222263_0_, ServerWorld worldIn, Chunk p_222263_2_, BlockPos p_222263_3_, CallbackInfo ci) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/MapDataMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/MapDataMixin.java index b3c59d64..e508e573 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/MapDataMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/MapDataMixin.java @@ -54,7 +54,7 @@ public abstract class MapDataMixin implements MapDataBridge { if (type == null) { /* All Maps which do not have their valid world loaded are set to a dimension which hopefully won't be reached. This is to prevent them being corrupted with the wrong map data. */ - type = this.bridge$dimension(ArclightConstants.ARCLIGHT_DIMENSION, "", "", OverworldDimension::new, false); + type = new DimensionType(ArclightConstants.ARCLIGHT_DIMENSION, "", "", OverworldDimension::new, false, null, null, null); ((DimensionTypeBridge) type).bridge$setType(DimensionType.OVERWORLD); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/storage/loot/LootTableManagerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/loot/LootTableManagerMixin.java similarity index 95% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/storage/loot/LootTableManagerMixin.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/loot/LootTableManagerMixin.java index e64aeefb..eb8d0cff 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/storage/loot/LootTableManagerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/loot/LootTableManagerMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.world.storage.loot; +package io.izzel.arclight.common.mixin.core.world.storage.loot; import com.google.common.collect.ImmutableMap; import com.google.gson.JsonObject; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/storage/loot/LootTableMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/loot/LootTableMixin.java similarity index 97% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/storage/loot/LootTableMixin.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/loot/LootTableMixin.java index bee8fb0f..4acb9bad 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/storage/loot/LootTableMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/loot/LootTableMixin.java @@ -1,4 +1,4 @@ -package io.izzel.arclight.common.mixin.v1_15.world.storage.loot; +package io.izzel.arclight.common.mixin.core.world.storage.loot; import io.izzel.arclight.common.bridge.world.storage.loot.LootTableBridge; import net.minecraft.inventory.IInventory; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/AbstractButtonBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/AbstractButtonBlockMixin_1_15.java deleted file mode 100644 index 366458c8..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/AbstractButtonBlockMixin_1_15.java +++ /dev/null @@ -1,61 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.block; - -import net.minecraft.block.AbstractButtonBlock; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.state.BooleanProperty; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; -import org.bukkit.Bukkit; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v.block.CraftBlock; -import org.bukkit.event.block.BlockRedstoneEvent; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -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; - -import java.util.Random; - -@Mixin(AbstractButtonBlock.class) -public class AbstractButtonBlockMixin_1_15 { - - // @formatter:off - @Shadow @Final public static BooleanProperty POWERED; - // @formatter:on - - @Inject(method = "onBlockActivated", cancellable = true, at = @At(value = "HEAD")) - public void arclight$blockRedstone1(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit, CallbackInfoReturnable cir) { - if (!state.get(POWERED)) { - boolean powered = state.get(POWERED); - Block block = CraftBlock.at(worldIn, pos); - int old = (powered) ? 15 : 0; - int current = (!powered) ? 15 : 0; - - BlockRedstoneEvent event = new BlockRedstoneEvent(block, old, current); - Bukkit.getPluginManager().callEvent(event); - - if ((event.getNewCurrent() > 0) == (powered)) { - cir.setReturnValue(true); - } - } - } - - @Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) - private void arclight$blockRedstone2(BlockState state, ServerWorld worldIn, BlockPos pos, Random rand, CallbackInfo ci) { - Block block = CraftBlock.at(worldIn, pos); - - BlockRedstoneEvent event = new BlockRedstoneEvent(block, 15, 0); - Bukkit.getPluginManager().callEvent(event); - - if (event.getNewCurrent() > 0) { - ci.cancel(); - } - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CactusBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CactusBlockMixin_1_15.java deleted file mode 100644 index 8d84a76a..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CactusBlockMixin_1_15.java +++ /dev/null @@ -1,19 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.block; - -import net.minecraft.block.BlockState; -import net.minecraft.block.CactusBlock; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.server.ServerWorld; -import org.bukkit.craftbukkit.v.event.CraftEventFactory; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(CactusBlock.class) -public class CactusBlockMixin_1_15 { - - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Z")) - private boolean arclight$blockGrow(ServerWorld serverWorld, BlockPos pos, BlockState state) { - return CraftEventFactory.handleBlockGrowEvent(serverWorld, pos, state); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CropsBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CropsBlockMixin_1_15.java deleted file mode 100644 index 3fe86b64..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/CropsBlockMixin_1_15.java +++ /dev/null @@ -1,19 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.block; - -import net.minecraft.block.BlockState; -import net.minecraft.block.CropsBlock; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.server.ServerWorld; -import org.bukkit.craftbukkit.v.event.CraftEventFactory; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(CropsBlock.class) -public class CropsBlockMixin_1_15 { - - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) - public boolean arclight$blockGrowTick(ServerWorld world, BlockPos pos, BlockState newState, int flags) { - return CraftEventFactory.handleBlockGrowEvent(world, pos, newState, flags); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/FarmlandBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/FarmlandBlockMixin_1_15.java deleted file mode 100644 index 7ca0f9ba..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/FarmlandBlockMixin_1_15.java +++ /dev/null @@ -1,19 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.block; - -import net.minecraft.block.BlockState; -import net.minecraft.block.FarmlandBlock; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.server.ServerWorld; -import org.bukkit.craftbukkit.v.event.CraftEventFactory; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(FarmlandBlock.class) -public class FarmlandBlockMixin_1_15 { - - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) - public boolean arclight$moistureChange(ServerWorld world, BlockPos pos, BlockState newState, int flags) { - return CraftEventFactory.handleMoistureChangeEvent(world, pos, newState, flags); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/FireBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/FireBlockMixin_1_15.java deleted file mode 100644 index 5208f372..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/FireBlockMixin_1_15.java +++ /dev/null @@ -1,34 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.block; - -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.FireBlock; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.server.ServerWorld; -import org.bukkit.craftbukkit.v.event.CraftEventFactory; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(FireBlock.class) -public class FireBlockMixin_1_15 { - - @Redirect(method = "tick", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) - public boolean arclight$fireSpread(ServerWorld world, BlockPos mutablePos, BlockState newState, int flags, - BlockState state, ServerWorld worldIn, BlockPos pos) { - if (world.getBlockState(mutablePos).getBlock() != Blocks.FIRE) { - if (!CraftEventFactory.callBlockIgniteEvent(world, mutablePos, pos).isCancelled()) { - return CraftEventFactory.handleBlockSpreadEvent(world, pos, mutablePos, newState, flags); - } - } - return false; - } - - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;removeBlock(Lnet/minecraft/util/math/BlockPos;Z)Z")) - public boolean arclight$extinguish1(ServerWorld world, BlockPos pos, boolean isMoving) { - if (!CraftEventFactory.callBlockFadeEvent(world, pos, Blocks.AIR.getDefaultState()).isCancelled()) { - world.removeBlock(pos, isMoving); - } - return false; - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/NetherPortalBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/NetherPortalBlockMixin_1_15.java deleted file mode 100644 index 58d87342..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/NetherPortalBlockMixin_1_15.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.block; - -import io.izzel.arclight.common.bridge.entity.EntityTypeBridge; -import net.minecraft.block.NetherPortalBlock; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.SpawnReason; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.world.World; -import org.bukkit.event.entity.CreatureSpawnEvent; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(NetherPortalBlock.class) -public class NetherPortalBlockMixin_1_15 { - - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/EntityType;spawn(Lnet/minecraft/world/World;Lnet/minecraft/nbt/CompoundNBT;Lnet/minecraft/util/text/ITextComponent;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/SpawnReason;ZZ)Lnet/minecraft/entity/Entity;")) - public Entity arclight$spawn(EntityType entityType, World worldIn, CompoundNBT compound, ITextComponent customName, PlayerEntity playerIn, BlockPos pos, SpawnReason reason, boolean flag, boolean flag1) { - return ((EntityTypeBridge) entityType).bridge$spawnCreature(worldIn, compound, customName, playerIn, pos, reason, flag, flag1, CreatureSpawnEvent.SpawnReason.NETHER_PORTAL); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/NoteBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/NoteBlockMixin_1_15.java deleted file mode 100644 index 006b9eef..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/NoteBlockMixin_1_15.java +++ /dev/null @@ -1,19 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.block; - -import io.izzel.arclight.common.bridge.block.NoteBlockBridge; -import net.minecraft.block.BlockState; -import net.minecraft.block.NoteBlock; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(NoteBlock.class) -public abstract class NoteBlockMixin_1_15 implements NoteBlockBridge { - - @Redirect(method = "onBlockActivated", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/NoteBlock;triggerNote(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)V")) - public void arclight$callNote2(NoteBlock noteBlock, World worldIn, BlockPos pos, BlockState blockState) { - this.bridge$play(worldIn, pos, blockState); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/PistonBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/PistonBlockMixin_1_15.java deleted file mode 100644 index 8505657f..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/PistonBlockMixin_1_15.java +++ /dev/null @@ -1,76 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.block; - -import net.minecraft.block.Blocks; -import net.minecraft.block.PistonBlock; -import net.minecraft.block.PistonBlockStructureHelper; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import org.bukkit.Bukkit; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v.block.CraftBlock; -import org.bukkit.event.block.BlockPistonEvent; -import org.bukkit.event.block.BlockPistonExtendEvent; -import org.bukkit.event.block.BlockPistonRetractEvent; -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.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -import java.util.AbstractList; -import java.util.List; - -@Mixin(PistonBlock.class) -public class PistonBlockMixin_1_15 { - - @Inject(method = "doMove", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, - at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/block/PistonBlockStructureHelper;getBlocksToDestroy()Ljava/util/List;")) - public void arclight$pistonAction(World worldIn, BlockPos pos, Direction directionIn, boolean extending, CallbackInfoReturnable cir, - BlockPos blockPos, PistonBlockStructureHelper helper) { - final Block craftBlock = CraftBlock.at(worldIn, pos); - - final List moved = helper.getBlocksToMove(); - final List broken = helper.getBlocksToDestroy(); - - class BlockList extends AbstractList { - - @Override - public int size() { - return moved.size() + broken.size(); - } - - @Override - public org.bukkit.block.Block get(int index) { - if (index >= size() || index < 0) { - throw new ArrayIndexOutOfBoundsException(index); - } - BlockPos pos = index < moved.size() ? moved.get(index) : broken.get(index - moved.size()); - return craftBlock.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); - } - } - - List blocks = new BlockList(); - - Direction direction = extending ? directionIn : directionIn.getOpposite(); - BlockPistonEvent event; - if (extending) { - event = new BlockPistonExtendEvent(craftBlock, blocks, CraftBlock.notchToBlockFace(direction)); - } else { - event = new BlockPistonRetractEvent(craftBlock, blocks, CraftBlock.notchToBlockFace(direction)); - } - Bukkit.getPluginManager().callEvent(event); - - if (event.isCancelled()) { - for (BlockPos b : broken) { - worldIn.notifyBlockUpdate(b, Blocks.AIR.getDefaultState(), worldIn.getBlockState(b), 3); - } - for (BlockPos b : moved) { - worldIn.notifyBlockUpdate(b, Blocks.AIR.getDefaultState(), worldIn.getBlockState(b), 3); - b = b.offset(direction); - worldIn.notifyBlockUpdate(b, Blocks.AIR.getDefaultState(), worldIn.getBlockState(b), 3); - } - cir.setReturnValue(false); - } - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/RedstoneLampBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/RedstoneLampBlockMixin_1_15.java deleted file mode 100644 index 3c09a930..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/RedstoneLampBlockMixin_1_15.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.block; - -import net.minecraft.block.BlockState; -import net.minecraft.block.RedstoneLampBlock; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.server.ServerWorld; -import org.bukkit.craftbukkit.v.event.CraftEventFactory; -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 java.util.Random; - -@Mixin(RedstoneLampBlock.class) -public class RedstoneLampBlockMixin_1_15 { - - @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) - private void arclight$redstoneChange(BlockState state, ServerWorld worldIn, BlockPos pos, Random rand, CallbackInfo ci) { - if (CraftEventFactory.callRedstoneChange(worldIn, pos, 15, 0).getNewCurrent() != 0) { - ci.cancel(); - } - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/TurtleEggBlockMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/TurtleEggBlockMixin_1_15.java deleted file mode 100644 index 02e41f35..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/block/TurtleEggBlockMixin_1_15.java +++ /dev/null @@ -1,49 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.block; - -import io.izzel.arclight.common.bridge.world.WorldBridge; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.TurtleEggBlock; -import net.minecraft.state.IntegerProperty; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.server.ServerWorld; -import org.bukkit.craftbukkit.v.event.CraftEventFactory; -import org.bukkit.event.entity.CreatureSpawnEvent; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -import java.util.Random; - -@Mixin(TurtleEggBlock.class) -public class TurtleEggBlockMixin_1_15 { - - @Shadow @Final public static IntegerProperty HATCH; - - @Inject(method = "tick", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, - at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/server/ServerWorld;playSound(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/SoundEvent;Lnet/minecraft/util/SoundCategory;FF)V")) - private void arclight$hatch(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci, int i) { - if (!CraftEventFactory.handleBlockGrowEvent(worldIn, pos, state.with(HATCH, i + 1), 2)) { - ci.cancel(); - } - } - - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) - private boolean arclight$handledHatch(ServerWorld world, BlockPos pos, BlockState newState, int flags) { - return true; - } - - @Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/world/server/ServerWorld;playSound(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/SoundEvent;Lnet/minecraft/util/SoundCategory;FF)V")) - private void arclight$born(BlockState state, ServerWorld worldIn, BlockPos pos, Random random, CallbackInfo ci) { - if (CraftEventFactory.callBlockFadeEvent(worldIn, pos, Blocks.AIR.getDefaultState()).isCancelled()) { - ci.cancel(); - } else { - ((WorldBridge) worldIn).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.EGG); - } - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/EntityMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/EntityMixin_1_15.java deleted file mode 100644 index 53867d68..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/EntityMixin_1_15.java +++ /dev/null @@ -1,215 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.entity; - -import io.izzel.arclight.common.bridge.entity.EntityBridge; -import io.izzel.arclight.common.bridge.entity.InternalEntityBridge; -import io.izzel.arclight.common.bridge.world.WorldBridge; -import net.minecraft.block.pattern.BlockPattern; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.MobEntity; -import net.minecraft.entity.MoverType; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.network.datasync.EntityDataManager; -import net.minecraft.server.MinecraftServer; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; -import net.minecraft.world.dimension.DimensionType; -import net.minecraft.world.gen.Heightmap; -import net.minecraft.world.server.ServerWorld; -import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.util.ITeleporter; -import org.bukkit.Bukkit; -import org.bukkit.block.BlockFace; -import org.bukkit.craftbukkit.v.CraftWorld; -import org.bukkit.craftbukkit.v.event.CraftEventFactory; -import org.bukkit.entity.Vehicle; -import org.bukkit.event.entity.EntityPortalEvent; -import org.bukkit.event.vehicle.VehicleBlockCollisionEvent; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import javax.annotation.Nullable; -import java.util.Random; - -@Mixin(Entity.class) -public abstract class EntityMixin_1_15 implements EntityBridge { - - // @formatter:off - @Shadow public World world; - @Shadow @Deprecated public boolean removed; - @Shadow @Nullable public abstract MinecraftServer getServer(); - @Shadow public DimensionType dimension; - @Shadow public abstract void detach(); - @Shadow public float rotationYaw; - @Shadow public float rotationPitch; - @Shadow public abstract void setMotion(Vec3d motionIn); - @Shadow(remap = false) public abstract void remove(boolean keepData); - @Shadow public abstract Vec3d getMotion(); - @Shadow public abstract double getPosX(); - @Shadow public abstract double getPosZ(); - @Shadow public abstract Vec3d getLastPortalVec(); - @Shadow public abstract double getPosY(); - @Shadow public abstract Direction getTeleportDirection(); - @Shadow public abstract EntityType getType(); - @Shadow @Final protected EntityDataManager dataManager; - @Shadow public abstract boolean isInvisible(); - @Shadow @Final protected Random rand; - @Shadow public abstract float getWidth(); - @Shadow public abstract float getHeight(); - @Shadow public abstract double getPosYEye(); - @Shadow public abstract void setFlag(int flag, boolean set); - @Shadow public abstract Vec3d getPositionVec(); - @Shadow(remap = false) public abstract void revive(); - @Shadow public abstract void setWorld(World worldIn); - @Shadow public abstract int getEntityId(); - @Shadow @Nullable public abstract Entity changeDimension(DimensionType destination); - @Shadow public boolean collidedHorizontally; - @Shadow protected abstract Vec3d getAllowedMovement(Vec3d vec); - // @formatter:on - - @Inject(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;canTriggerWalking()Z")) - private void arclight$move$blockCollide(MoverType typeIn, Vec3d pos, CallbackInfo ci) { - if (collidedHorizontally && this.bridge$getBukkitEntity() instanceof Vehicle) { - Vehicle vehicle = (Vehicle) this.bridge$getBukkitEntity(); - org.bukkit.block.Block block = ((WorldBridge) this.world).bridge$getWorld().getBlockAt(MathHelper.floor(this.getPosX()), MathHelper.floor(this.getPosY()), MathHelper.floor(this.getPosZ())); - Vec3d vec3d = this.getAllowedMovement(pos); - if (pos.x > vec3d.x) { - block = block.getRelative(BlockFace.EAST); - } else if (vec3d.x < vec3d.x) { - block = block.getRelative(BlockFace.WEST); - } else if (pos.z > vec3d.z) { - block = block.getRelative(BlockFace.SOUTH); - } else if (pos.z < vec3d.z) { - block = block.getRelative(BlockFace.NORTH); - } - - if (block.getType() != org.bukkit.Material.AIR) { - VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, block); - Bukkit.getPluginManager().callEvent(event); - } - } - } - - /** - * @author IzzelAliz - * @reason - */ - @Overwrite(remap = false) - @Nullable - public Entity changeDimension(DimensionType destination, ITeleporter teleporter) { - BlockPos location = ((InternalEntityBridge) this).internal$capturedPos(); - if (!ForgeHooks.onTravelToDimension((Entity) (Object) this, destination)) return null; - if (!this.world.isRemote && !this.removed) { - this.world.getProfiler().startSection("changeDimension"); - MinecraftServer minecraftserver = this.getServer(); - DimensionType dimensiontype = this.dimension; - ServerWorld serverworld = minecraftserver.getWorld(dimensiontype); - ServerWorld[] serverworld1 = new ServerWorld[]{minecraftserver.getWorld(destination)}; - - if (serverworld1 == null) { - return null; - } - //this.dimension = destination; - //this.detach(); - this.world.getProfiler().startSection("reposition"); - Entity transportedEntity = teleporter.placeEntity((Entity) (Object) this, serverworld, serverworld1[0], this.rotationYaw, spawnPortal -> { //Forge: Start vanilla logic - Vec3d vec3d = this.getMotion(); - float f = 0.0F; - BlockPos blockpos = location; - if (blockpos == null) { - if (dimensiontype == DimensionType.THE_END && destination == DimensionType.OVERWORLD) { - EntityPortalEvent event = CraftEventFactory.callEntityPortalEvent((Entity) (Object) this, serverworld1[0], serverworld1[0].getHeight(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, serverworld1[0].getSpawnPoint()), 0); - if (event == null) { - return null; - } - serverworld1[0] = ((CraftWorld) event.getTo().getWorld()).getHandle(); - blockpos = new BlockPos(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); - //blockpos = serverworld1[0].getHeight(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, serverworld1[0].getSpawnPoint()); - } else if (destination == DimensionType.THE_END) { - EntityPortalEvent event = CraftEventFactory.callEntityPortalEvent((Entity) (Object) this, serverworld1[0], (serverworld1[0].getSpawnCoordinate() != null) ? serverworld1[0].getSpawnCoordinate() : serverworld1[0].getSpawnPoint(), 0); - if (event == null) { - return null; - } - serverworld1[0] = ((CraftWorld) event.getTo().getWorld()).getHandle(); - blockpos = new BlockPos(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); - //blockpos = serverworld1[0].getSpawnCoordinate(); - } else { - double movementFactor = serverworld.getDimension().getMovementFactor() / serverworld1[0].getDimension().getMovementFactor(); - double d0 = this.getPosX() * movementFactor; - double d1 = this.getPosZ() * movementFactor; - - double d3 = Math.min(-2.9999872E7D, serverworld1[0].getWorldBorder().minX() + 16.0D); - double d4 = Math.min(-2.9999872E7D, serverworld1[0].getWorldBorder().minZ() + 16.0D); - double d5 = Math.min(2.9999872E7D, serverworld1[0].getWorldBorder().maxX() - 16.0D); - double d6 = Math.min(2.9999872E7D, serverworld1[0].getWorldBorder().maxZ() - 16.0D); - d0 = MathHelper.clamp(d0, d3, d5); - d1 = MathHelper.clamp(d1, d4, d6); - Vec3d vec3d1 = this.getLastPortalVec(); - blockpos = new BlockPos(d0, this.getPosY(), d1); - - EntityPortalEvent event2 = CraftEventFactory.callEntityPortalEvent((Entity) (Object) this, serverworld1[0], blockpos, 128); - if (event2 == null) { - return null; - } - serverworld1[0] = ((CraftWorld) event2.getTo().getWorld()).getHandle(); - blockpos = new BlockPos(event2.getTo().getX(), event2.getTo().getY(), event2.getTo().getZ()); - int searchRadius = event2.getSearchRadius(); - // todo 实现 radius - - if (spawnPortal) { - BlockPattern.PortalInfo blockpattern$portalinfo = serverworld1[0].getDefaultTeleporter().placeInExistingPortal(blockpos, vec3d, this.getTeleportDirection(), vec3d1.x, vec3d1.y, (Object) this instanceof PlayerEntity); - if (blockpattern$portalinfo == null) { - return null; - } - - blockpos = new BlockPos(blockpattern$portalinfo.pos); - vec3d = blockpattern$portalinfo.motion; - f = (float) blockpattern$portalinfo.rotation; - } - } - } - - this.dimension = destination; - this.detach(); - - this.world.getProfiler().endStartSection("reloading"); - Entity entity = this.getType().create(serverworld1[0]); - if (entity != null) { - entity.copyDataFromOld((Entity) (Object) this); - entity.moveToBlockPosAndAngles(blockpos, entity.rotationYaw + f, entity.rotationPitch); - entity.setMotion(vec3d); - serverworld1[0].addFromAnotherDimension(entity); - - ((InternalEntityBridge) this).internal$getBukkitEntity().setHandle(entity); - ((EntityBridge) entity).bridge$setBukkitEntity(((InternalEntityBridge) this).internal$getBukkitEntity()); - if ((Object) this instanceof MobEntity) { - ((MobEntity) (Object) this).clearLeashed(true, false); - } - } - return entity; - });//Forge: End vanilla logic - - this.remove(false); - this.world.getProfiler().endSection(); - serverworld.resetUpdateEntityTick(); - serverworld1[0].resetUpdateEntityTick(); - this.world.getProfiler().endSection(); - return transportedEntity; - } else { - return null; - } - } - - @Override - public double bridge$getEyeHeight() { - return this.getPosYEye(); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/LivingEntityMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/LivingEntityMixin_1_15.java deleted file mode 100644 index 82cfd9be..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/LivingEntityMixin_1_15.java +++ /dev/null @@ -1,280 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.entity; - -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.mojang.datafixers.util.Either; -import io.izzel.arclight.common.bridge.entity.LivingEntityBridge; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.item.ExperienceOrbEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.network.datasync.DataParameter; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.potion.Effect; -import net.minecraft.potion.EffectInstance; -import net.minecraft.util.DamageSource; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.living.PotionEvent; -import org.bukkit.craftbukkit.v.event.CraftEventFactory; -import org.bukkit.event.entity.EntityPotionEffectEvent; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import javax.annotation.Nullable; -import java.util.Collection; -import java.util.ConcurrentModificationException; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -@Mixin(LivingEntity.class) -public abstract class LivingEntityMixin_1_15 extends EntityMixin_1_15 implements LivingEntityBridge { - - // @formatter:off - @Shadow @Final private static DataParameter POTION_EFFECTS; - @Shadow @Final private static DataParameter HIDE_PARTICLES; - @Shadow @Final public Map activePotionsMap; - @Shadow public boolean potionsNeedUpdate; - @Shadow protected abstract void onFinishedPotionEffect(EffectInstance effect); - @Shadow protected abstract void onChangedPotionEffect(EffectInstance id, boolean reapply); - @Shadow protected abstract void updatePotionMetadata(); - @Shadow public abstract boolean removePotionEffect(Effect effectIn); - @Shadow public abstract boolean isPotionApplicable(EffectInstance potioneffectIn); - @Shadow protected abstract void onNewPotionEffect(EffectInstance id); - @Shadow @Nullable public abstract EffectInstance removeActivePotionEffect(@Nullable Effect potioneffectin); - @Shadow public int deathTime; - @Shadow protected abstract void createWitherRose(@Nullable LivingEntity p_226298_1_); - @Shadow public abstract Optional getBedPosition(); - @Shadow public abstract boolean isSleeping(); - @Shadow public abstract Collection getActivePotionEffects(); - // @formatter:on - - /** - * @author IzzelAliz - * @reason - */ - @Overwrite - protected void onDeathUpdate() { - ++this.deathTime; - if (this.deathTime >= 20 && !this.removed) { - - this.remove((Object) this instanceof ServerPlayerEntity); //Forge keep data until we revive player - - for (int k = 0; k < 20; ++k) { - double d2 = this.rand.nextGaussian() * 0.02D; - double d0 = this.rand.nextGaussian() * 0.02D; - double d1 = this.rand.nextGaussian() * 0.02D; - this.world.addParticle(ParticleTypes.POOF, this.getPosX() + (double) (this.rand.nextFloat() * this.getWidth() * 2.0F) - (double) this.getWidth(), this.getPosY() + (double) (this.rand.nextFloat() * this.getHeight()), this.getPosZ() + (double) (this.rand.nextFloat() * this.getWidth() * 2.0F) - (double) this.getWidth(), d2, d0, d1); - } - } - } - - @Redirect(method = "spawnDrops", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;dropExperience()V")) - private void arclight$dropLater(LivingEntity livingEntity) { - } - - @Inject(method = "spawnDrops", at = @At("RETURN")) - private void arclight$dropLast(DamageSource damageSourceIn, CallbackInfo ci) { - this.dropExperience(); - } - - /** - * @author IzzelAliz - * @reason - */ - @Overwrite - protected void dropExperience() { - // if (!this.world.isRemote && (this.isPlayer() || this.recentlyHit > 0 && this.canDropLoot() && this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT))) { - if (true) { - int i = bridge$getExpToDrop(); - while (i > 0) { - int j = ExperienceOrbEntity.getXPSplit(i); - i -= j; - this.world.addEntity(new ExperienceOrbEntity(this.world, this.getPosX(), this.getPosY(), this.getPosZ(), j)); - } - bridge$setExpToDrop(0); - } - } - - private boolean isTickingEffects = false; - private List, EntityPotionEffectEvent.Cause>> effectsToProcess = Lists.newArrayList(); - - /** - * @author IzzelAliz - * @reason - */ - @Overwrite - protected void updatePotionEffects() { - this.isTickingEffects = true; - Iterator iterator = this.activePotionsMap.keySet().iterator(); - - try { - while (iterator.hasNext()) { - Effect effect = iterator.next(); - EffectInstance effectinstance = this.activePotionsMap.get(effect); - if (!effectinstance.tick((LivingEntity) (Object) this, () -> { - onChangedPotionEffect(effectinstance, true); - })) { - if (!this.world.isRemote && !MinecraftForge.EVENT_BUS.post(new PotionEvent.PotionExpiryEvent((LivingEntity) (Object) this, effectinstance))) { - - EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent((LivingEntity) (Object) this, effectinstance, null, EntityPotionEffectEvent.Cause.EXPIRATION); - if (event.isCancelled()) { - continue; - } - - iterator.remove(); - this.onFinishedPotionEffect(effectinstance); - } - } else if (effectinstance.getDuration() % 600 == 0) { - this.onChangedPotionEffect(effectinstance, false); - } - } - } catch (ConcurrentModificationException ignored) { - } - - isTickingEffects = false; - for (Map.Entry, EntityPotionEffectEvent.Cause> e : effectsToProcess) { - Either either = e.getKey(); - EntityPotionEffectEvent.Cause cause = e.getValue(); - bridge$pushEffectCause(cause); - if (either.left().isPresent()) { - addPotionEffect(either.left().get()); - } else { - removePotionEffect(either.right().get()); - } - } - effectsToProcess.clear(); - - if (this.potionsNeedUpdate) { - if (!this.world.isRemote) { - this.updatePotionMetadata(); - } - - this.potionsNeedUpdate = false; - } - - int i = this.dataManager.get(POTION_EFFECTS); - boolean flag1 = this.dataManager.get(HIDE_PARTICLES); - if (i > 0) { - boolean flag; - if (this.isInvisible()) { - flag = this.rand.nextInt(15) == 0; - } else { - flag = this.rand.nextBoolean(); - } - - if (flag1) { - flag &= this.rand.nextInt(5) == 0; - } - - if (flag && i > 0) { - double d0 = (double) (i >> 16 & 255) / 255.0D; - double d1 = (double) (i >> 8 & 255) / 255.0D; - double d2 = (double) (i >> 0 & 255) / 255.0D; - this.world.addParticle(flag1 ? ParticleTypes.AMBIENT_ENTITY_EFFECT : ParticleTypes.ENTITY_EFFECT, this.getPosX() + (this.rand.nextDouble() - 0.5D) * (double) this.getWidth(), this.getPosY() + this.rand.nextDouble() * (double) this.getHeight(), this.getPosZ() + (this.rand.nextDouble() - 0.5D) * (double) this.getWidth(), d0, d1, d2); - } - } - } - - /** - * @author IzzelAliz - * @reason - */ - @Overwrite - public boolean addPotionEffect(EffectInstance effectInstanceIn) { - EntityPotionEffectEvent.Cause cause = bridge$getEffectCause().orElse(EntityPotionEffectEvent.Cause.UNKNOWN); - if (isTickingEffects) { - effectsToProcess.add(Maps.immutableEntry(Either.left(effectInstanceIn), cause)); - return true; - } - - if (!this.isPotionApplicable(effectInstanceIn)) { - return false; - } else { - EffectInstance effectinstance = this.activePotionsMap.get(effectInstanceIn.getPotion()); - - boolean override = false; - if (effectinstance != null) { - override = new EffectInstance(effectinstance).combine(effectInstanceIn); - } - - EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent((LivingEntity) (Object) this, effectinstance, effectInstanceIn, cause, override); - if (event.isCancelled()) { - return false; - } - - MinecraftForge.EVENT_BUS.post(new PotionEvent.PotionAddedEvent((LivingEntity) (Object) this, effectinstance, effectInstanceIn)); - if (effectinstance == null) { - this.activePotionsMap.put(effectInstanceIn.getPotion(), effectInstanceIn); - this.onNewPotionEffect(effectInstanceIn); - return true; - } else if (event.isOverride()) { - effectinstance.combine(effectInstanceIn); - this.onChangedPotionEffect(effectinstance, true); - return true; - } else { - return false; - } - } - } - - @SuppressWarnings("unused") // mock - public EffectInstance c(@Nullable Effect potioneffectin, EntityPotionEffectEvent.Cause cause) { - bridge$pushEffectCause(cause); - return removeActivePotionEffect(potioneffectin); - } - - @Inject(method = "removeActivePotionEffect", cancellable = true, at = @At("HEAD")) - public void arclight$clearActive(Effect effect, CallbackInfoReturnable cir) { - EntityPotionEffectEvent.Cause cause = bridge$getEffectCause().orElse(EntityPotionEffectEvent.Cause.UNKNOWN); - if (isTickingEffects) { - effectsToProcess.add(Maps.immutableEntry(Either.right(effect), cause)); - cir.setReturnValue(null); - return; - } - - EffectInstance effectInstance = this.activePotionsMap.get(effect); - if (effectInstance == null) { - cir.setReturnValue(null); - return; - } - - EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent((LivingEntity) (Object) this, effectInstance, null, cause); - if (event.isCancelled()) { - cir.setReturnValue(null); - } - } - - - private transient boolean arclight$fallSuccess; - - @Inject(method = "onLivingFall", cancellable = true, at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/entity/LivingEntity;attackEntityFrom(Lnet/minecraft/util/DamageSource;F)Z")) - public void arclight$fall(float distance, float damageMultiplier, CallbackInfoReturnable cir) { - if (!arclight$fallSuccess) { - cir.setReturnValue(true); - } - } - - @Redirect(method = "onLivingFall", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;attackEntityFrom(Lnet/minecraft/util/DamageSource;F)Z")) - public boolean arclight$fall(LivingEntity livingEntity, DamageSource source, float amount) { - return arclight$fallSuccess = livingEntity.attackEntityFrom(source, amount); - } - - @Override - public void bridge$dropExperience() { - this.dropExperience(); - } - - @Override - public void bridge$createWitherRose(LivingEntity entity) { - this.createWitherRose(entity); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/item/ArmorStandEntityMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/item/ArmorStandEntityMixin_1_15.java deleted file mode 100644 index c96f2d89..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/item/ArmorStandEntityMixin_1_15.java +++ /dev/null @@ -1,48 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.entity.item; - -import io.izzel.arclight.common.bridge.entity.EntityBridge; -import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge; -import net.minecraft.entity.item.ArmorStandEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Hand; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v.CraftEquipmentSlot; -import org.bukkit.craftbukkit.v.inventory.CraftItemStack; -import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerArmorStandManipulateEvent; -import org.bukkit.inventory.EquipmentSlot; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(ArmorStandEntity.class) -public abstract class ArmorStandEntityMixin_1_15 { - - // @formatter:off - @Shadow public abstract ItemStack getItemStackFromSlot(EquipmentSlotType slotIn); - // @formatter:on - - @Inject(method = "func_226529_a_", cancellable = true, at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerEntity;abilities:Lnet/minecraft/entity/player/PlayerAbilities;")) - public void arclight$manipulateEvent(PlayerEntity playerEntity, EquipmentSlotType slotType, ItemStack itemStack, Hand hand, CallbackInfoReturnable cir) { - ItemStack itemStack1 = this.getItemStackFromSlot(slotType); - - org.bukkit.inventory.ItemStack armorStandItem = CraftItemStack.asCraftMirror(itemStack1); - org.bukkit.inventory.ItemStack playerHeldItem = CraftItemStack.asCraftMirror(itemStack); - - Player player = ((ServerPlayerEntityBridge) playerEntity).bridge$getBukkitEntity(); - ArmorStand self = (ArmorStand) ((EntityBridge) this).bridge$getBukkitEntity(); - - EquipmentSlot slot = CraftEquipmentSlot.getSlot(slotType); - PlayerArmorStandManipulateEvent event = new PlayerArmorStandManipulateEvent(player, self, playerHeldItem, armorStandItem, slot); - Bukkit.getPluginManager().callEvent(event); - - if (event.isCancelled()) { - cir.setReturnValue(true); - } - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/item/ItemEntityMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/item/ItemEntityMixin_1_15.java deleted file mode 100644 index 1cfd4465..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/item/ItemEntityMixin_1_15.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.entity.item; - -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.ItemStack; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(ItemEntity.class) -public class ItemEntityMixin_1_15 { - - @Redirect(method = "func_226531_a_", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/ItemEntity;setItem(Lnet/minecraft/item/ItemStack;)V")) - private static void arclight$setNonEmpty(ItemEntity itemEntity, ItemStack stack) { - if (!stack.isEmpty()) { - itemEntity.setItem(stack); - } - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/monster/EndermanEntityMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/monster/EndermanEntityMixin_1_15.java deleted file mode 100644 index 2f08c68d..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/monster/EndermanEntityMixin_1_15.java +++ /dev/null @@ -1,41 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.entity.monster; - -import io.izzel.arclight.common.bridge.entity.monster.EndermanEntityBridge; -import io.izzel.arclight.common.mixin.core.entity.CreatureEntityMixin; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.ai.attributes.AttributeModifier; -import net.minecraft.entity.ai.attributes.IAttributeInstance; -import net.minecraft.entity.monster.EndermanEntity; -import net.minecraft.network.datasync.DataParameter; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(EndermanEntity.class) -public abstract class EndermanEntityMixin_1_15 extends CreatureEntityMixin implements EndermanEntityBridge { - - // @formatter:off - @Shadow private int targetChangeTime; - @Shadow @Final private static DataParameter SCREAMING; - @Shadow @Final private static DataParameter field_226535_bx_; - @Shadow @Final private static AttributeModifier ATTACKING_SPEED_BOOST; - // @formatter:on - - @Override - public void bridge$updateTarget(LivingEntity livingEntity) { - IAttributeInstance iattributeinstance = this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); - if (livingEntity == null) { - this.targetChangeTime = 0; - this.dataManager.set(SCREAMING, false); - this.dataManager.set(field_226535_bx_, false); - iattributeinstance.removeModifier(ATTACKING_SPEED_BOOST); - } else { - this.targetChangeTime = this.ticksExisted; - this.dataManager.set(SCREAMING, true); - if (!iattributeinstance.hasModifier(ATTACKING_SPEED_BOOST)) { - iattributeinstance.applyModifier(ATTACKING_SPEED_BOOST); - } - } - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/player/PlayerEntityMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/player/PlayerEntityMixin_1_15.java deleted file mode 100644 index 6957827b..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/player/PlayerEntityMixin_1_15.java +++ /dev/null @@ -1,143 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.entity.player; - -import com.mojang.datafixers.util.Either; -import io.izzel.arclight.common.bridge.entity.InternalEntityBridge; -import io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge; -import io.izzel.arclight.common.bridge.world.WorldBridge; -import io.izzel.arclight.common.mixin.v1_15.entity.LivingEntityMixin_1_15; -import net.minecraft.entity.player.PlayerAbilities; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.Unit; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.dimension.DimensionType; -import net.minecraft.world.server.ServerWorld; -import org.bukkit.Bukkit; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v.block.CraftBlock; -import org.bukkit.craftbukkit.v.entity.CraftHumanEntity; -import org.bukkit.craftbukkit.v.event.CraftEventFactory; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerBedLeaveEvent; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -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(PlayerEntity.class) -public abstract class PlayerEntityMixin_1_15 extends LivingEntityMixin_1_15 implements PlayerEntityBridge { - - // @formatter:off - @Shadow public abstract Either trySleep(BlockPos at); - @Shadow public abstract void startSleeping(BlockPos p_213342_1_); - @Shadow public int sleepTimer; - @Shadow @Final public PlayerAbilities abilities; - @Shadow public abstract void addStat(ResourceLocation stat); - // @formatter:on - - @Override - public CraftHumanEntity bridge$getBukkitEntity() { - return (CraftHumanEntity) ((InternalEntityBridge) this).internal$getBukkitEntity(); - } - - private boolean arclight$forceSleep = false; - private Object arclight$processSleep = null; - - private Either getBedResult(BlockPos at, Direction direction) { - arclight$processSleep = true; - Either either = this.trySleep(at); - arclight$processSleep = null; - return either; - } - - public Either sleep(BlockPos at, boolean force) { - arclight$forceSleep = force; - try { - return this.trySleep(at); - } finally { - arclight$forceSleep = false; - } - } - - @Inject(method = "trySleep", cancellable = true, at = @At(value = "HEAD")) - public void arclight$onSleep(BlockPos at, CallbackInfoReturnable> cir) { - if (arclight$processSleep == null) { - Either result = getBedResult(at, null); - - if (result.left().orElse(null) == PlayerEntity.SleepResult.OTHER_PROBLEM) { - cir.setReturnValue(result); - return; - } - if (arclight$forceSleep) { - result = Either.right(Unit.INSTANCE); - } - if (this.bridge$getBukkitEntity() instanceof Player) { - result = CraftEventFactory.callPlayerBedEnterEvent((PlayerEntity) (Object) this, at, result); - if (result.left().isPresent()) { - cir.setReturnValue(result); - return; - } - } - - this.startSleeping(at); - this.sleepTimer = 0; - if (this.world instanceof ServerWorld) { - ((ServerWorld) this.world).updateAllPlayersSleepingFlag(); - } - cir.setReturnValue(Either.right(Unit.INSTANCE)); - } - } - - @Inject(method = "trySleep", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;startSleeping(Lnet/minecraft/util/math/BlockPos;)V")) - public void arclight$preSleep(BlockPos at, CallbackInfoReturnable> cir) { - if (arclight$processSleep != null) { - cir.setReturnValue(Either.right(Unit.INSTANCE)); - } - } - - @Inject(method = "stopSleepInBed", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerEntity;sleepTimer:I")) - private void arclight$wakeup(boolean flag, boolean flag1, CallbackInfo ci) { - BlockPos blockPos = this.getBedPosition().orElse(null); - if (this.bridge$getBukkitEntity() instanceof Player) { - Player player = (Player) this.bridge$getBukkitEntity(); - Block bed; - if (blockPos != null) { - bed = CraftBlock.at(this.world, blockPos); - } else { - bed = ((WorldBridge) this.world).bridge$getWorld().getBlockAt(player.getLocation()); - } - PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed, true); - Bukkit.getPluginManager().callEvent(event); - } - } - - @Inject(method = "setSpawnPoint", remap = false, at = @At("RETURN")) - private void arclight$updateSpawnpoint(BlockPos pos, boolean p_226560_2_, boolean p_226560_3_, DimensionType dim, CallbackInfo ci) { - bridge$setSpawnWorld(pos == null ? "" : this.world.worldInfo.getWorldName()); - } - - @Inject(method = "startFallFlying", cancellable = true, at = @At("HEAD")) - private void arclight$startGlidingEvent(CallbackInfo ci) { - if (CraftEventFactory.callToggleGlideEvent((PlayerEntity) (Object) this, true).isCancelled()) { - this.setFlag(7, true); - this.setFlag(7, false); - ci.cancel(); - } - } - - @Inject(method = "stopFallFlying", cancellable = true, at = @At("HEAD")) - private void arclight$stopGlidingEvent(CallbackInfo ci) { - if (CraftEventFactory.callToggleGlideEvent((PlayerEntity) (Object) this, false).isCancelled()) { - ci.cancel(); - } - } - - @Override - public Either bridge$trySleep(BlockPos at, boolean force) { - return sleep(at, force); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/player/ServerPlayerEntityMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/player/ServerPlayerEntityMixin_1_15.java deleted file mode 100644 index 245ab3bd..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/entity/player/ServerPlayerEntityMixin_1_15.java +++ /dev/null @@ -1,328 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.entity.player; - -import com.mojang.datafixers.util.Either; -import io.izzel.arclight.common.bridge.entity.InternalEntityBridge; -import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge; -import io.izzel.arclight.common.bridge.network.play.ServerPlayNetHandlerBridge; -import io.izzel.arclight.common.bridge.world.TeleporterBridge; -import io.izzel.arclight.common.bridge.world.WorldBridge; -import io.izzel.arclight.common.bridge.world.dimension.DimensionTypeBridge; -import io.izzel.arclight.common.bridge.world.server.ServerWorldBridge; -import net.minecraft.advancements.CriteriaTriggers; -import net.minecraft.block.Blocks; -import net.minecraft.block.pattern.BlockPattern; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.network.play.ServerPlayNetHandler; -import net.minecraft.network.play.server.SChangeGameStatePacket; -import net.minecraft.network.play.server.SPlayEntityEffectPacket; -import net.minecraft.network.play.server.SPlaySoundEventPacket; -import net.minecraft.network.play.server.SPlayerAbilitiesPacket; -import net.minecraft.network.play.server.SRespawnPacket; -import net.minecraft.network.play.server.SServerDifficultyPacket; -import net.minecraft.potion.EffectInstance; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.management.PlayerInteractionManager; -import net.minecraft.server.management.PlayerList; -import net.minecraft.stats.Stats; -import net.minecraft.util.Unit; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.Teleporter; -import net.minecraft.world.dimension.DimensionType; -import net.minecraft.world.server.ServerWorld; -import net.minecraft.world.storage.WorldInfo; -import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.util.ITeleporter; -import net.minecraftforge.fml.hooks.BasicEventHooks; -import net.minecraftforge.fml.network.NetworkHooks; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.block.BlockState; -import org.bukkit.craftbukkit.v.CraftWorld; -import org.bukkit.craftbukkit.v.entity.CraftPlayer; -import org.bukkit.craftbukkit.v.util.BlockStateListPopulator; -import org.bukkit.event.player.PlayerChangedWorldEvent; -import org.bukkit.event.player.PlayerPortalEvent; -import org.bukkit.event.player.PlayerTeleportEvent; -import org.bukkit.event.world.PortalCreateEvent; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import javax.annotation.Nullable; -import java.util.List; - -@Mixin(ServerPlayerEntity.class) -public abstract class ServerPlayerEntityMixin_1_15 extends PlayerEntityMixin_1_15 implements ServerPlayerEntityBridge { - - // @formatter:off - @Shadow public boolean invulnerableDimensionChange; - @Shadow public abstract ServerWorld getServerWorld(); - @Shadow public boolean queuedEndExit; - @Shadow public ServerPlayNetHandler connection; - @Shadow private boolean seenCredits; - @Shadow @Final public MinecraftServer server; - @Shadow @Final public PlayerInteractionManager interactionManager; - @Shadow @Nullable private Vec3d enteredNetherPosition; - @Shadow public abstract void func_213846_b(ServerWorld p_213846_1_); - @Shadow public int lastExperience; - @Shadow private float lastHealth; - @Shadow private int lastFoodLevel; - // @formatter:on - - @Override - public CraftPlayer bridge$getBukkitEntity() { - return (CraftPlayer) ((InternalEntityBridge) this).internal$getBukkitEntity(); - } - - /** - * @author IzzelAliz - * @reason - */ - @Overwrite(remap = false) - @Nullable - public Entity changeDimension(DimensionType dim, ITeleporter teleporter) { - DimensionType[] destination = {dim}; - if (this.isSleeping()) return (ServerPlayerEntity) (Object) this; - - if (!ForgeHooks.onTravelToDimension((ServerPlayerEntity) (Object) this, destination[0])) return null; - - PlayerTeleportEvent.TeleportCause cause = bridge$getTeleportCause().orElse(PlayerTeleportEvent.TeleportCause.UNKNOWN); - // this.invulnerableDimensionChange = true; - DimensionType dimensiontype = this.dimension; - if (((DimensionTypeBridge) dimensiontype).bridge$getType() == DimensionType.THE_END && ((DimensionTypeBridge) destination[0]).bridge$getType() == DimensionType.OVERWORLD && teleporter instanceof Teleporter) { //Forge: Fix non-vanilla teleporters triggering end credits - this.invulnerableDimensionChange = true; - this.detach(); - this.getServerWorld().removePlayer((ServerPlayerEntity) (Object) this, true); //Forge: The player entity is cloned so keep the data until after cloning calls copyFrom - if (!this.queuedEndExit) { - this.queuedEndExit = true; - this.connection.sendPacket(new SChangeGameStatePacket(4, this.seenCredits ? 0.0F : 1.0F)); - this.seenCredits = true; - } - - return (ServerPlayerEntity) (Object) this; - } else { - ServerWorld serverworld = this.server.getWorld(dimensiontype); - // this.dimension = destination; - ServerWorld[] serverworld1 = {this.server.getWorld(destination[0])}; - - /* - WorldInfo worldinfo = serverworld1.getWorldInfo(); - NetworkHooks.sendDimensionDataPacket(this.connection.netManager, (ServerPlayerEntity) (Object) this); - this.connection.sendPacket(new SRespawnPacket(destination, WorldInfo.byHashing(worldinfo.getSeed()), worldinfo.getGenerator(), this.interactionManager.getGameType())); - this.connection.sendPacket(new SServerDifficultyPacket(worldinfo.getDifficulty(), worldinfo.isDifficultyLocked())); - PlayerList playerlist = this.server.getPlayerList(); - playerlist.updatePermissionLevel((ServerPlayerEntity) (Object) this); - serverworld.removeEntity((ServerPlayerEntity) (Object) this, true); //Forge: the player entity is moved to the new world, NOT cloned. So keep the data alive with no matching invalidate call. - this.revive(); - */ - PlayerList[] playerlist = new PlayerList[1]; - - Entity e = teleporter.placeEntity((ServerPlayerEntity) (Object) this, serverworld, serverworld1[0], this.rotationYaw, spawnPortal -> {//Forge: Start vanilla logic - double d0 = this.getPosX(); - double d1 = this.getPosY(); - double d2 = this.getPosZ(); - float f = this.rotationPitch; - float f1 = this.rotationYaw; - double d3 = 8.0D; - float f2 = f1; - serverworld.getProfiler().startSection("moving"); - - if (serverworld1[0] != null) { - double moveFactor = serverworld.getDimension().getMovementFactor() / serverworld1[0].getDimension().getMovementFactor(); - d0 *= moveFactor; - d2 *= moveFactor; - if (dimensiontype == DimensionType.OVERWORLD && destination[0] == DimensionType.THE_NETHER) { - this.enteredNetherPosition = this.getPositionVec(); - } else if (dimensiontype == DimensionType.OVERWORLD && destination[0] == DimensionType.THE_END) { - BlockPos blockpos = serverworld1[0].getSpawnCoordinate(); - d0 = blockpos.getX(); - d1 = blockpos.getY(); - d2 = blockpos.getZ(); - f1 = 90.0F; - f = 0.0F; - } - } - - Location enter = this.bridge$getBukkitEntity().getLocation(); - Location exit = (serverworld1[0] == null) ? null : new Location(((ServerWorldBridge) serverworld1[0]).bridge$getWorld(), d0, d1, d2, f1, f); - PlayerPortalEvent event = new PlayerPortalEvent(this.bridge$getBukkitEntity(), enter, exit, cause, 128, true, ((DimensionTypeBridge) destination[0]).bridge$getType() == DimensionType.THE_END ? 0 : 16); - Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled() || event.getTo() == null) { - return null; - } - - exit = event.getTo(); - if (exit == null) { - return null; - } - serverworld1[0] = ((CraftWorld) exit.getWorld()).getHandle(); - d0 = exit.getX(); - d1 = exit.getY(); - d2 = exit.getZ(); - - // this.setLocationAndAngles(d0, d1, d2, f1, f); - serverworld.getProfiler().endSection(); - serverworld.getProfiler().startSection("placing"); - double d7 = Math.max(-2.9999872E7D, serverworld1[0].getWorldBorder().minX() + 16.0D); - double d4 = Math.max(-2.9999872E7D, serverworld1[0].getWorldBorder().minZ() + 16.0D); - double d5 = Math.min(2.9999872E7D, serverworld1[0].getWorldBorder().maxX() - 16.0D); - double d6 = Math.min(2.9999872E7D, serverworld1[0].getWorldBorder().maxZ() - 16.0D); - d0 = MathHelper.clamp(d0, d7, d5); - d2 = MathHelper.clamp(d2, d4, d6); - // this.setLocationAndAngles(d0, d1, d2, f1, f); - - Vec3d exitVelocity = Vec3d.ZERO; - BlockPos exitPosition = new BlockPos(d0, d1, d2); - - if (((DimensionTypeBridge) destination[0]).bridge$getType() == DimensionType.THE_END) { - int i = exitPosition.getX(); - int j = exitPosition.getY() - 1; - int k = exitPosition.getZ(); - - if (event.getCanCreatePortal()) { - - BlockStateListPopulator blockList = new BlockStateListPopulator(serverworld1[0]); - - for (int j1 = -2; j1 <= 2; ++j1) { - for (int k1 = -2; k1 <= 2; ++k1) { - for (int l1 = -1; l1 < 3; ++l1) { - int i2 = i + k1 * 1 + j1 * 0; - int j2 = j + l1; - int k2 = k + k1 * 0 - j1 * 1; - boolean flag = l1 < 0; - blockList.setBlockState(new BlockPos(i2, j2, k2), flag ? Blocks.OBSIDIAN.getDefaultState() : Blocks.AIR.getDefaultState(), 3); - } - } - } - - org.bukkit.World bworld = ((ServerWorldBridge) serverworld1[0]).bridge$getWorld(); - PortalCreateEvent portalEvent = new PortalCreateEvent((List) (List) blockList.getList(), bworld, this.bridge$getBukkitEntity(), PortalCreateEvent.CreateReason.END_PLATFORM); - - Bukkit.getPluginManager().callEvent(portalEvent); - if (!portalEvent.isCancelled()) { - blockList.updateList(); - } - } - - // this.setLocationAndAngles(i, j, k, f1, 0.0F); - exit.setX(i); - exit.setY(j); - exit.setZ(k); - // this.setMotion(Vec3d.ZERO); - exitVelocity = Vec3d.ZERO; - } else { - BlockPattern.PortalInfo portalInfo = ((TeleporterBridge) serverworld1[0].getDefaultTeleporter()).bridge$placeInPortal((ServerPlayerEntity) (Object) this, exitPosition, f2, event.getSearchRadius(), true); - if (spawnPortal && portalInfo == null && event.getCanCreatePortal()) { - if (((TeleporterBridge) serverworld1[0].getDefaultTeleporter()).bridge$makePortal((ServerPlayerEntity) (Object) this, exitPosition, event.getCreationRadius())) { - // serverworld1.getDefaultTeleporter().placeInPortal((ServerPlayerEntity) (Object) this, f2); - portalInfo = ((TeleporterBridge) serverworld1[0].getDefaultTeleporter()).bridge$placeInPortal((ServerPlayerEntity) (Object) this, exitPosition, f2, event.getSearchRadius(), true); - } - } - if (portalInfo == null) { - return null; - } - - exitVelocity = portalInfo.motion; - exit.setX(portalInfo.pos.getX()); - exit.setY(portalInfo.pos.getY()); - exit.setZ(portalInfo.pos.getZ()); - exit.setYaw(f2 + (float) portalInfo.rotation); - } - - serverworld.getProfiler().endSection(); - - PlayerTeleportEvent tpEvent = new PlayerTeleportEvent(this.bridge$getBukkitEntity(), enter, exit, cause); - Bukkit.getServer().getPluginManager().callEvent(tpEvent); - if (tpEvent.isCancelled() || tpEvent.getTo() == null) { - return null; - } - exit = tpEvent.getTo(); - if (exit == null) { - return null; - } - serverworld1[0] = ((CraftWorld) exit.getWorld()).getHandle(); - this.invulnerableDimensionChange = true; - - destination[0] = serverworld1[0].getDimension().getType(); - this.dimension = destination[0]; - - WorldInfo worldinfo = serverworld1[0].getWorldInfo(); - NetworkHooks.sendDimensionDataPacket(this.connection.netManager, (ServerPlayerEntity) (Object) this); - this.connection.sendPacket(new SRespawnPacket(destination[0], WorldInfo.byHashing(worldinfo.getSeed()), worldinfo.getGenerator(), this.interactionManager.getGameType())); - this.connection.sendPacket(new SServerDifficultyPacket(worldinfo.getDifficulty(), worldinfo.isDifficultyLocked())); - - playerlist[0] = this.server.getPlayerList(); - playerlist[0].updatePermissionLevel((ServerPlayerEntity) (Object) this); - - serverworld.removeEntity((ServerPlayerEntity) (Object) this, true); //Forge: the player entity is moved to the new world, NOT cloned. So keep the data alive with no matching invalidate call. - this.revive(); - - this.setMotion(exitVelocity); - - this.setWorld(serverworld1[0]); - serverworld1[0].addDuringPortalTeleport((ServerPlayerEntity) (Object) this); - this.func_213846_b(serverworld); - - // this.connection.setPlayerLocation(this.getPosX(), this.getPosY(), this.getPosZ(), f1, f); - ((ServerPlayNetHandlerBridge) this.connection).bridge$teleport(exit); - this.connection.captureCurrentPosition(); - - return (ServerPlayerEntity) (Object) this;//forge: this is part of the ITeleporter patch - });//Forge: End vanilla logic - if (e == null) { - return (ServerPlayerEntity) (Object) this; - } else if (e != (Object) this) { - throw new IllegalArgumentException(String.format("Teleporter %s returned not the player entity but instead %s, expected PlayerEntity %s", teleporter, e, this)); - } - this.interactionManager.setWorld(serverworld1[0]); - this.connection.sendPacket(new SPlayerAbilitiesPacket(this.abilities)); - playerlist[0].sendWorldInfo((ServerPlayerEntity) (Object) this, serverworld1[0]); - playerlist[0].sendInventory((ServerPlayerEntity) (Object) this); - - for (EffectInstance effectinstance : this.getActivePotionEffects()) { - this.connection.sendPacket(new SPlayEntityEffectPacket(this.getEntityId(), effectinstance)); - } - - this.connection.sendPacket(new SPlaySoundEventPacket(1032, BlockPos.ZERO, 0, false)); - this.lastExperience = -1; - this.lastHealth = -1.0F; - this.lastFoodLevel = -1; - BasicEventHooks.firePlayerChangedDimensionEvent((ServerPlayerEntity) (Object) this, dimensiontype, destination[0]); - - PlayerChangedWorldEvent changeEvent = new PlayerChangedWorldEvent(this.bridge$getBukkitEntity(), ((WorldBridge) serverworld).bridge$getWorld()); - Bukkit.getPluginManager().callEvent(changeEvent); - return (ServerPlayerEntity) (Object) this; - } - } - - public Entity a(DimensionType dimensionmanager, final PlayerTeleportEvent.TeleportCause cause) { - bridge$pushChangeDimensionCause(cause); - return this.changeDimension(dimensionmanager); - } - - @Override - public Either sleep(BlockPos at, boolean force) { - return super.sleep(at, force).ifRight((p_213849_1_) -> { - this.addStat(Stats.SLEEP_IN_BED); - CriteriaTriggers.SLEPT_IN_BED.trigger((ServerPlayerEntity) (Object) this); - }); - } - - @Inject(method = "stopSleepInBed", cancellable = true, at = @At("HEAD")) - private void arclight$notWake(boolean flag, boolean flag1, CallbackInfo ci) { - if (!isSleeping()) ci.cancel(); - } - - @Override - public Entity bridge$changeDimension(DimensionType dimensionType, PlayerTeleportEvent.TeleportCause cause) { - return a(dimensionType, cause); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/item/BlockItemMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/item/BlockItemMixin_1_15.java deleted file mode 100644 index ea45890f..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/item/BlockItemMixin_1_15.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.item; - -import io.izzel.arclight.common.bridge.item.BlockItemBridge; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItem; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.world.World; -import org.spongepowered.asm.mixin.Mixin; - -@Mixin(BlockItem.class) -public class BlockItemMixin_1_15 implements BlockItemBridge { - - @Override - public boolean bridge$noCollisionInSel(World world, BlockState state, BlockPos pos, ISelectionContext context) { - return world.func_226663_a_(state, pos, context); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/network/play/ServerPlayNetHandlerMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/network/play/ServerPlayNetHandlerMixin_1_15.java deleted file mode 100644 index 46ee9fc8..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/network/play/ServerPlayNetHandlerMixin_1_15.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.network.play; - -import io.izzel.arclight.common.bridge.network.play.ServerPlayNetHandlerBridge; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.nbt.StringNBT; -import net.minecraft.network.play.ServerPlayNetHandler; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.world.server.ServerWorld; -import org.spongepowered.asm.mixin.Mixin; - -@Mixin(ServerPlayNetHandler.class) -public abstract class ServerPlayNetHandlerMixin_1_15 implements ServerPlayNetHandlerBridge { - - @Override - public boolean bridge$worldNoCollision(ServerWorld world, Entity entity, AxisAlignedBB aabb) { - return world.hasNoCollisions(entity, aabb); - } - - @Override - public StringNBT bridge$stringNbt(String s) { - return StringNBT.valueOf(s); - } - - @Override - public void bridge$dropItems(ServerPlayerEntity player, boolean all) { - player.drop(all); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/server/management/PlayerInteractionManagerMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/server/management/PlayerInteractionManagerMixin_1_15.java deleted file mode 100644 index 7dd40de0..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/server/management/PlayerInteractionManagerMixin_1_15.java +++ /dev/null @@ -1,126 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.server.management; - -import io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge; -import io.izzel.arclight.common.bridge.server.management.PlayerInteractionManagerBridge; -import net.minecraft.block.BlockState; -import net.minecraft.block.CakeBlock; -import net.minecraft.block.DoorBlock; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.inventory.container.INamedContainerProvider; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.network.play.client.CPlayerDiggingPacket; -import net.minecraft.network.play.server.SChangeBlockPacket; -import net.minecraft.network.play.server.SPlayerDiggingPacket; -import net.minecraft.server.management.PlayerInteractionManager; -import net.minecraft.state.properties.DoubleBlockHalf; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.GameType; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; -import net.minecraftforge.common.ForgeHooks; -import org.bukkit.craftbukkit.v.event.CraftEventFactory; -import org.bukkit.event.Event; -import org.bukkit.event.block.Action; -import org.bukkit.event.player.PlayerInteractEvent; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(PlayerInteractionManager.class) -public abstract class PlayerInteractionManagerMixin_1_15 implements PlayerInteractionManagerBridge { - - // @formatter:off - @Shadow public abstract void func_229860_a_(BlockPos p_229860_1_, CPlayerDiggingPacket.Action p_229860_2_, String p_229860_3_); - @Shadow private GameType gameType; - @Shadow public abstract boolean isCreative(); - @Shadow public ServerWorld world; - // @formatter:on - - @Override - public SPlayerDiggingPacket bridge$diggingPacket(BlockPos pos, BlockState state, CPlayerDiggingPacket.Action action, boolean successful, String context) { - return new SPlayerDiggingPacket(pos, state, action, successful, context); - } - - @Override - public void bridge$creativeHarvestBlock(BlockPos pos, CPlayerDiggingPacket.Action action, String context) { - this.func_229860_a_(pos, action, context); - } - - /** - * @author IzzelAliz - * @reason - */ - @Overwrite - public ActionResultType func_219441_a(PlayerEntity playerIn, World worldIn, ItemStack stackIn, Hand handIn, BlockRayTraceResult blockRaytraceResultIn) { - BlockPos blockpos = blockRaytraceResultIn.getPos(); - BlockState blockstate = worldIn.getBlockState(blockpos); - ActionResultType resultType = ActionResultType.PASS; - boolean cancelledBlock = false; - if (this.gameType == GameType.SPECTATOR) { - INamedContainerProvider provider = blockstate.getContainer(worldIn, blockpos); - cancelledBlock = !(provider instanceof INamedContainerProvider); - } - if (playerIn.getCooldownTracker().hasCooldown(stackIn.getItem())) { - cancelledBlock = true; - } - - PlayerInteractEvent bukkitEvent = CraftEventFactory.callPlayerInteractEvent(playerIn, Action.RIGHT_CLICK_BLOCK, blockpos, blockRaytraceResultIn.getFace(), stackIn, cancelledBlock, handIn); - bridge$setFiredInteract(true); - bridge$setInteractResult(bukkitEvent.useItemInHand() == Event.Result.DENY); - if (bukkitEvent.useInteractedBlock() == Event.Result.DENY) { - if (blockstate.getBlock() instanceof DoorBlock) { - boolean bottom = blockstate.get(DoorBlock.HALF) == DoubleBlockHalf.LOWER; - ((ServerPlayerEntity) playerIn).connection.sendPacket(new SChangeBlockPacket(this.world, bottom ? blockpos.up() : blockpos.down())); - } else if (blockstate.getBlock() instanceof CakeBlock) { - ((ServerPlayerEntityBridge) playerIn).bridge$getBukkitEntity().sendHealthUpdate(); - } - ((ServerPlayerEntityBridge) playerIn).bridge$getBukkitEntity().updateInventory(); - resultType = ((bukkitEvent.useItemInHand() != Event.Result.ALLOW) ? ActionResultType.SUCCESS : ActionResultType.PASS); - } else if (this.gameType == GameType.SPECTATOR) { - INamedContainerProvider inamedcontainerprovider = blockstate.getContainer(worldIn, blockpos); - if (inamedcontainerprovider != null) { - playerIn.openContainer(inamedcontainerprovider); - return ActionResultType.SUCCESS; - } else { - return ActionResultType.PASS; - } - } else { - net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock event = ForgeHooks.onRightClickBlock(playerIn, handIn, blockpos, blockRaytraceResultIn.getFace()); - if (event.isCanceled()) return event.getCancellationResult(); - ItemUseContext itemusecontext = new ItemUseContext(playerIn, handIn, blockRaytraceResultIn); - if (event.getUseItem() != net.minecraftforge.eventbus.api.Event.Result.DENY) { - ActionResultType result = stackIn.onItemUseFirst(itemusecontext); - if (result != ActionResultType.PASS) return result; - } - boolean flag = !playerIn.getHeldItemMainhand().isEmpty() || !playerIn.getHeldItemOffhand().isEmpty(); - boolean flag1 = (playerIn.isSecondaryUseActive() && flag) && !(playerIn.getHeldItemMainhand().doesSneakBypassUse(worldIn, blockpos, playerIn) && playerIn.getHeldItemOffhand().doesSneakBypassUse(worldIn, blockpos, playerIn)); - if (event.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY && !flag1) { - resultType = blockstate.onBlockActivated(worldIn, playerIn, handIn, blockRaytraceResultIn); - if (resultType.isSuccessOrConsume()) { - return resultType; - } - } - if (!stackIn.isEmpty() && resultType != ActionResultType.SUCCESS && !bridge$getInteractResult()) { - if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY) { - return ActionResultType.PASS; - } - if (this.isCreative()) { - int i = stackIn.getCount(); - resultType = stackIn.onItemUse(itemusecontext); - stackIn.setCount(i); - return resultType; - } else { - return stackIn.onItemUse(itemusecontext); - } - } else { - return resultType; - } - } - return resultType; - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/server/management/PlayerListMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/server/management/PlayerListMixin_1_15.java deleted file mode 100644 index dc7eeb08..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/server/management/PlayerListMixin_1_15.java +++ /dev/null @@ -1,44 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.server.management; - -import io.izzel.arclight.common.bridge.server.management.PlayerListBridge; -import io.izzel.arclight.common.bridge.world.dimension.DimensionTypeBridge; -import io.izzel.arclight.common.bridge.world.server.ServerWorldBridge; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.play.server.SJoinGamePacket; -import net.minecraft.network.play.server.SRespawnPacket; -import net.minecraft.server.management.PlayerList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.GameType; -import net.minecraft.world.WorldType; -import net.minecraft.world.dimension.DimensionType; -import net.minecraft.world.server.ServerWorld; -import net.minecraft.world.storage.WorldInfo; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(PlayerList.class) -public abstract class PlayerListMixin_1_15 implements PlayerListBridge { - - @Override - public boolean bridge$worldNoCollision(ServerWorld world, Entity entity) { - return world.hasNoCollisions(entity); - } - - @Override - public void bridge$setSpawnPoint(ServerPlayerEntity player, BlockPos pos, boolean flag, DimensionType type, boolean flag1) { - player.setSpawnPoint(pos, flag, flag1, type); - } - - @Override - public SRespawnPacket bridge$respawnPacket(DimensionType type, long seed, WorldType worldType, GameType gameType) { - return new SRespawnPacket(type, WorldInfo.byHashing(seed), worldType, gameType); - } - - @Redirect(method = "initializeConnectionToPlayer", at = @At(value = "NEW", target = "net/minecraft/network/play/server/SJoinGamePacket")) - private SJoinGamePacket arclight$spawnPacket(int playerId, GameType gameType, long hashedSeed, boolean hardcoreMode, DimensionType dimensionType, int maxPlayers, WorldType worldType, int viewDistance, boolean reducedDebugInfo, boolean enableRespawnScreen, NetworkManager netManager, ServerPlayerEntity playerIn) { - return new SJoinGamePacket(playerId, gameType, hashedSeed, hardcoreMode, ((DimensionTypeBridge) dimensionType).bridge$getType(), maxPlayers, worldType, ((ServerWorldBridge) playerIn.getServerWorld()).bridge$spigotConfig().viewDistance, reducedDebugInfo, enableRespawnScreen); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/ExplosionMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/ExplosionMixin_1_15.java deleted file mode 100644 index c561698d..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/ExplosionMixin_1_15.java +++ /dev/null @@ -1,139 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.world; - -import com.mojang.datafixers.util.Pair; -import io.izzel.arclight.common.bridge.world.ExplosionBridge; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.item.ItemStack; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.Explosion; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; -import net.minecraft.world.storage.loot.LootContext; -import net.minecraft.world.storage.loot.LootParameters; -import org.bukkit.craftbukkit.v.event.CraftEventFactory; -import org.bukkit.event.block.BlockIgniteEvent; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.gen.Accessor; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.Collections; -import java.util.List; -import java.util.Random; - -@Mixin(Explosion.class) -public abstract class ExplosionMixin_1_15 implements ExplosionBridge { - - // @formatter:off - @Shadow @Final private World world; - @Shadow @Final private Explosion.Mode mode; - @Shadow @Mutable @Final private float size; - @Shadow @Final private List affectedBlockPositions; - @Shadow @Final private double x; - @Shadow @Final private double y; - @Shadow @Final private double z; - @Shadow @Final private boolean causesFire; - @Shadow @Final private Random random; - @Shadow @Final public Entity exploder; - @Shadow private static void func_229976_a_(ObjectArrayList> p_229976_0_, ItemStack p_229976_1_, BlockPos p_229976_2_) { } - @Accessor("exploder") public abstract Entity bridge$getExploder(); - @Accessor("size") public abstract float bridge$getSize(); - @Accessor("size") public abstract void bridge$setSize(float size); - @Accessor("mode") public abstract Explosion.Mode bridge$getMode(); - // @formatter:on - - public boolean wasCanceled = false; - - /** - * @author IzzelAliz - * @reason - */ - @Overwrite - public void doExplosionB(boolean spawnParticles) { - if (this.world.isRemote) { - this.world.playSound(this.x, this.y, this.z, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4.0F, (1.0F + (this.world.rand.nextFloat() - this.world.rand.nextFloat()) * 0.2F) * 0.7F, false); - } - - boolean flag = this.mode != Explosion.Mode.NONE; - if (spawnParticles) { - if (!(this.size < 2.0F) && flag) { - this.world.addParticle(ParticleTypes.EXPLOSION_EMITTER, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D); - } else { - this.world.addParticle(ParticleTypes.EXPLOSION, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D); - } - } - - if (flag) { - ObjectArrayList> objectarraylist = new ObjectArrayList<>(); - Collections.shuffle(this.affectedBlockPositions, this.world.rand); - - float yield = this.bridge$callBlockExplodeEvent(); - - if (Float.isNaN(yield)) { - this.wasCanceled = true; - return; - } - - for (BlockPos blockpos : this.affectedBlockPositions) { - BlockState blockstate = this.world.getBlockState(blockpos); - Block block = blockstate.getBlock(); - if (!blockstate.isAir(this.world, blockpos)) { - BlockPos blockpos1 = blockpos.toImmutable(); - this.world.getProfiler().startSection("explosion_blocks"); - if (blockstate.canDropFromExplosion(this.world, blockpos, (Explosion) (Object) this) && this.world instanceof ServerWorld) { - TileEntity tileentity = blockstate.hasTileEntity() ? this.world.getTileEntity(blockpos) : null; - LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerWorld) this.world)).withRandom(this.world.rand).withParameter(LootParameters.POSITION, blockpos).withParameter(LootParameters.TOOL, ItemStack.EMPTY).withNullableParameter(LootParameters.BLOCK_ENTITY, tileentity).withNullableParameter(LootParameters.THIS_ENTITY, this.exploder); - if (this.mode == Explosion.Mode.DESTROY || yield < 1.0F) { - lootcontext$builder.withParameter(LootParameters.EXPLOSION_RADIUS, 1.0F / yield); - } - - blockstate.getDrops(lootcontext$builder).forEach((p_229977_2_) -> { - func_229976_a_(objectarraylist, p_229977_2_, blockpos1); - }); - } - - blockstate.onBlockExploded(this.world, blockpos, (Explosion) (Object) this); - this.world.getProfiler().endSection(); - } - } - - for (Pair pair : objectarraylist) { - Block.spawnAsEntity(this.world, pair.getSecond(), pair.getFirst()); - } - } - - if (this.causesFire) { - for (BlockPos blockpos2 : this.affectedBlockPositions) { - if (this.random.nextInt(3) == 0 && this.world.getBlockState(blockpos2).isAir() && this.world.getBlockState(blockpos2.down()).isOpaqueCube(this.world, blockpos2.down())) { - BlockIgniteEvent event = CraftEventFactory.callBlockIgniteEvent(this.world, blockpos2.getX(), blockpos2.getY(), blockpos2.getZ(), (Explosion) (Object) this); - if (!event.isCancelled()) { - this.world.setBlockState(blockpos2, Blocks.FIRE.getDefaultState()); - } - } - } - } - } - - @Inject(method = "func_229976_a_", cancellable = true, at = @At("HEAD")) - private static void arclight$fix(ObjectArrayList> p_229976_0_, ItemStack stack, BlockPos p_229976_2_, CallbackInfo ci) { - if (stack.isEmpty()) ci.cancel(); - } - - @Override - public boolean bridge$wasCancelled() { - return wasCanceled; - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/WorldMixin_1_14.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/WorldMixin_1_14.java deleted file mode 100644 index 68fff45b..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/WorldMixin_1_14.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.world; - -import io.izzel.arclight.common.bridge.world.dimension.DimensionTypeBridge; -import net.minecraft.world.World; -import net.minecraft.world.dimension.Dimension; -import net.minecraft.world.dimension.DimensionType; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(World.class) -public class WorldMixin_1_14 { - - @Redirect(method = "isNightTime", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/dimension/Dimension;getType()Lnet/minecraft/world/dimension/DimensionType;")) - private DimensionType arclight$nightTimeType(Dimension dimension) { - return ((DimensionTypeBridge) dimension.getType()).bridge$getType(); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/chunk/ChunkMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/chunk/ChunkMixin_1_15.java deleted file mode 100644 index e94e59b6..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/chunk/ChunkMixin_1_15.java +++ /dev/null @@ -1,28 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.world.chunk; - -import io.izzel.arclight.common.bridge.world.chunk.ChunkBridge; -import net.minecraft.block.Block; -import net.minecraft.fluid.Fluid; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.palette.UpgradeData; -import net.minecraft.world.ITickList; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeContainer; -import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.chunk.ChunkSection; -import org.bukkit.craftbukkit.v.CraftChunk; -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 java.util.function.Consumer; - -@Mixin(Chunk.class) -public abstract class ChunkMixin_1_15 implements ChunkBridge { - - @Inject(method = "(Lnet/minecraft/world/World;Lnet/minecraft/util/math/ChunkPos;Lnet/minecraft/world/biome/BiomeContainer;Lnet/minecraft/util/palette/UpgradeData;Lnet/minecraft/world/ITickList;Lnet/minecraft/world/ITickList;J[Lnet/minecraft/world/chunk/ChunkSection;Ljava/util/function/Consumer;)V", at = @At("RETURN")) - private void arclight$init(World worldIn, ChunkPos chunkPosIn, BiomeContainer biomeContainerIn, UpgradeData upgradeDataIn, ITickList tickBlocksIn, ITickList tickFluidsIn, long inhabitedTimeIn, ChunkSection[] sectionsIn, Consumer postLoadConsumerIn, CallbackInfo ci) { - bridge$setBukkitChunk(new CraftChunk((Chunk) (Object) this)); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/server/ServerChunkProviderMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/server/ServerChunkProviderMixin_1_15.java deleted file mode 100644 index c8b5a9d1..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/server/ServerChunkProviderMixin_1_15.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.world.server; - -import io.izzel.arclight.common.bridge.world.server.ServerChunkProviderBridge; -import net.minecraft.entity.EntityClassification; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.server.ServerChunkProvider; -import net.minecraft.world.server.ServerWorld; -import net.minecraft.world.spawner.WorldEntitySpawner; -import org.spongepowered.asm.mixin.Mixin; - -@Mixin(ServerChunkProvider.class) -public abstract class ServerChunkProviderMixin_1_15 implements ServerChunkProviderBridge { - - @Override - public void bridge$worldNaturalSpawn(EntityClassification classification, World worldIn, Chunk chunk, BlockPos pos) { - WorldEntitySpawner.spawnEntitiesInChunk(classification, (ServerWorld) worldIn, chunk, pos); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/server/ServerWorldMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/server/ServerWorldMixin_1_15.java deleted file mode 100644 index 7ac5fb25..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/server/ServerWorldMixin_1_15.java +++ /dev/null @@ -1,47 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.world.server; - -import io.izzel.arclight.common.bridge.world.server.ServerWorldBridge; -import io.izzel.arclight.common.mixin.core.world.WorldMixin; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.world.server.ServerWorld; -import org.bukkit.Bukkit; -import org.bukkit.event.world.TimeSkipEvent; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.List; - -@Mixin(ServerWorld.class) -public abstract class ServerWorldMixin_1_15 extends WorldMixin implements ServerWorldBridge { - - // @formatter:off - @Shadow private boolean allPlayersSleeping; - @Shadow @Final private List players; - @Shadow protected abstract void wakeUpAllPlayers(); - // @formatter:on - - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;setDayTime(J)V")) - private void arclight$timeSkip(ServerWorld world, long time) { - TimeSkipEvent event = new TimeSkipEvent(this.bridge$getWorld(), TimeSkipEvent.SkipReason.NIGHT_SKIP, (time - time % 24000L) - this.getDayTime()); - Bukkit.getPluginManager().callEvent(event); - arclight$timeSkipCancelled = event.isCancelled(); - if (!event.isCancelled()) { - world.setDayTime(this.getDayTime() + event.getSkipAmount()); - this.allPlayersSleeping = this.players.stream().allMatch(LivingEntity::isSleeping); - } - } - - private transient boolean arclight$timeSkipCancelled; - - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/server/ServerWorld;wakeUpAllPlayers()V")) - private void arclight$notWakeIfCancelled(ServerWorld world) { - if (!arclight$timeSkipCancelled) { - this.wakeUpAllPlayers(); - } - arclight$timeSkipCancelled = false; - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/storage/MapDataMixin_1_15.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/storage/MapDataMixin_1_15.java deleted file mode 100644 index e59fe056..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/v1_15/world/storage/MapDataMixin_1_15.java +++ /dev/null @@ -1,19 +0,0 @@ -package io.izzel.arclight.common.mixin.v1_15.world.storage; - -import io.izzel.arclight.common.bridge.world.storage.MapDataBridge; -import net.minecraft.world.World; -import net.minecraft.world.dimension.Dimension; -import net.minecraft.world.dimension.DimensionType; -import net.minecraft.world.storage.MapData; -import org.spongepowered.asm.mixin.Mixin; - -import java.util.function.BiFunction; - -@Mixin(MapData.class) -public abstract class MapDataMixin_1_15 implements MapDataBridge { - - @Override - public DimensionType bridge$dimension(int id, String suffix, String dir, BiFunction provider, boolean skyLight) { - return new DimensionType(id, suffix, dir, provider, skyLight, null, null, null); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mod/ArclightConnector.java b/arclight-common/src/main/java/io/izzel/arclight/common/mod/ArclightConnector.java index 39a14777..bfa0f976 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mod/ArclightConnector.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mod/ArclightConnector.java @@ -1,7 +1,6 @@ package io.izzel.arclight.common.mod; import cpw.mods.modlauncher.api.ITransformingClassLoader; -import io.izzel.arclight.api.ArclightVersion; import io.izzel.arclight.common.mod.util.log.ArclightI18nLogger; import org.apache.logging.log4j.Logger; import org.spongepowered.asm.mixin.Mixins; @@ -24,9 +23,6 @@ public class ArclightConnector implements IMixinConnector { Mixins.addConfiguration("mixins.arclight.core.json"); Mixins.addConfiguration("mixins.arclight.bukkit.json"); Mixins.addConfiguration("mixins.arclight.forge.json"); - if (ArclightVersion.atLeast(ArclightVersion.v1_15)) { - Mixins.addConfiguration("mixins.arclight.core.1_15.json"); - } LOGGER.info("mixin-load.core"); } } diff --git a/arclight-common/src/main/resources/mixins.arclight.core.1_15.json b/arclight-common/src/main/resources/mixins.arclight.core.1_15.json deleted file mode 100644 index 049226b9..00000000 --- a/arclight-common/src/main/resources/mixins.arclight.core.1_15.json +++ /dev/null @@ -1,94 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "io.izzel.arclight.common.mixin.v1_15", - "target": "@env(DEFAULT)", - "refmap": "mixins.arclight.refmap.json", - "setSourceFile": true, - "plugin": "io.izzel.arclight.common.mod.ArclightMixinPlugin", - "injectors": { - "maxShiftBy": 2, - "defaultRequire": 1 - }, - "mixins": [ - "block.AbstractButtonBlockMixin_1_15", - "block.CactusBlockMixin_1_15", - "block.CakeBlockMixin_1_15", - "block.CauldronBlockMixin_1_15", - "block.ChestBlock2Mixin_1_15", - "block.ChorusFlowerBlockMixin_1_15", - "block.CocoaBlockMixin_1_15", - "block.CoralBlockMixin_1_15", - "block.CoralFinBlockMixin_1_15", - "block.CoralPlantBlockMixin_1_15", - "block.CoralWallFanBlockMixin_1_15", - "block.CropsBlockMixin_1_15", - "block.FarmlandBlockMixin_1_15", - "block.FireBlockMixin_1_15", - "block.GrassBlockMixin_1_15", - "block.KelpTopBlockMixin_1_15", - "block.LeavesBlockMixin_1_15", - "block.LeverBlockMixin_1_15", - "block.LilyPadBlockMixin_1_15", - "block.MushroomBlockMixin_1_15", - "block.NetherPortalBlockMixin_1_15", - "block.NetherWartBlockMixin_1_15", - "block.NoteBlockMixin_1_15", - "block.ObserverBlockMixin_1_15", - "block.PistonBlockMixin_1_15", - "block.RedstoneDiodeBlockMixin_1_15", - "block.RedstoneLampBlockMixin_1_15", - "block.RedstoneOreBlockMixin_1_15", - "block.ScaffoldingBlockMixin_1_15", - "block.SnowBlockMixin_1_15", - "block.SpreadableSnowyDirtBlockMixin_1_15", - "block.StemBlockMixin_1_15", - "block.SugarCaneBlockMixin_1_15", - "block.SweetBerryBushBlockMixin_1_15", - "block.TurtleEggBlockMixin_1_15", - "block.VineBlockMixin_1_15", - "block.WitherRoseBlockMixin", - "command.impl.TeleportCommandMixin_1_15", - "command.impl.TimeCommandMixin", - "enchantment.FrostWalkerEnchantmentMixin_1_15", - "entity.EntityMixin_1_15", - "entity.LivingEntityMixin_1_15", - "entity.ai.goal.FollowOwnerGoalMixin_1_15", - "entity.boss.WitherEntityMixin_1_15", - "entity.item.ArmorStandEntityMixin_1_15", - "entity.item.FallingBlockEntityMixin_1_15", - "entity.item.ItemEntityMixin_1_15", - "entity.monster.AbstractRaiderEntityMixin", - "entity.monster.EndermanEntityMixin_1_15", - "entity.monster.RavagerEntityMixin_1_15", - "entity.monster.ShulkerEntityMixin_1_15", - "entity.monster.ZombiePigmanEntityMixin_1_15", - "entity.passive.BeeEntity_AngerGoalMixin", - "entity.passive.BeeEntity_FindPollinationTargetGoalMixin", - "entity.passive.BeeEntityMixin", - "entity.player.PlayerEntityMixin_1_15", - "entity.player.ServerPlayerEntityMixin_1_15", - "item.BlockItemMixin_1_15", - "item.LeadItemMixin_1_15", - "item.crafting.SpecialRecipeMixin", - "network.play.ServerPlayNetHandlerMixin_1_15", - "server.management.PlayerInteractionManagerMixin_1_15", - "server.management.PlayerListMixin_1_15", - "tileentity.BeehiveTileEntityMixin", - "world.ExplosionMixin_1_15", - "world.TeleporterMixin_1_15", - "world.WorldMixin_1_14", - "world.biome.BiomeContainerMixin", - "world.chunk.ChunkMixin_1_15", - "world.dimension.DimensionTypeMixin_1_15", - "world.gen.feature.structure.SwampHutPieceMixin_1_15", - "world.server.ServerChunkProviderMixin_1_15", - "world.server.ServerMultiWorldMixin_1_15", - "world.server.ServerWorldMixin_1_15", - "world.server.TicketManagerMixin_1_15", - "world.spawner.WorldEntitySpawnerMixin_1_15", - "world.storage.MapDataMixin_1_15", - "world.storage.loot.LootTableManagerMixin", - "world.storage.loot.LootTableMixin" - ] -} \ No newline at end of file diff --git a/arclight-common/src/main/resources/mixins.arclight.core.json b/arclight-common/src/main/resources/mixins.arclight.core.json index 8ed23c18..175cfb23 100644 --- a/arclight-common/src/main/resources/mixins.arclight.core.json +++ b/arclight-common/src/main/resources/mixins.arclight.core.json @@ -21,8 +21,13 @@ "block.BlockStateMixin", "block.BushBlockMixin", "block.CactusBlockMixin", + "block.CakeBlockMixin", "block.CampfireBlockMixin", "block.CarvedPumpkinBlockMixin", + "block.CauldronBlockMixin", + "block.ChestBlock2Mixin", + "block.ChorusFlowerBlockMixin", + "block.CocoaBlockMixin", "block.CommandBlockBlockMixin", "block.ComparatorBlockMixin", "block.ComposterBlock_EmptyInventoryMixin", @@ -30,6 +35,10 @@ "block.ComposterBlock_PartialInventoryMixin", "block.ComposterBlockMixin", "block.ConcretePowderBlockMixin", + "block.CoralBlockMixin", + "block.CoralFinBlockMixin", + "block.CoralPlantBlockMixin", + "block.CoralWallFanBlockMixin", "block.CropsBlockMixin", "block.DaylightDetectorBlockMixin", "block.DetectorRailBlockMixin", @@ -44,28 +53,46 @@ "block.FenceGateBlockMixin", "block.FireBlockMixin", "block.FlowingFluidBlockMixin", + "block.GrassBlockMixin", "block.IceBlockMixin", "block.JukeBoxBlockMixin", + "block.KelpTopBlockMixin", + "block.LeavesBlockMixin", "block.LecternBlockMixin", + "block.LeverBlockMixin", + "block.LilyPadBlockMixin", "block.MagmaBlockMixin", + "block.MushroomBlockMixin", "block.NetherPortalBlock_SizeMixin", "block.NetherPortalBlockMixin", + "block.NetherWartBlockMixin", "block.NoteBlockMixin", + "block.ObserverBlockMixin", "block.PistonBlockMixin", "block.PoweredRailBlockMixin", "block.PressurePlateBlockMixin", + "block.RedstoneDiodeBlockMixin", "block.RedstoneLampBlockMixin", + "block.RedstoneOreBlockMixin", "block.RedstoneTorchBlockMixin", "block.RedstoneWireBlockMixin", "block.SaplingBlockMixin", + "block.ScaffoldingBlockMixin", "block.SilverfishBlockMixin", + "block.SnowBlockMixin", "block.SpongeBlockMixin", + "block.SpreadableSnowyDirtBlockMixin", + "block.StemBlockMixin", + "block.SugarCaneBlockMixin", + "block.SweetBerryBushBlockMixin", "block.TNTBlockMixin", "block.TrapDoorBlockMixin", "block.TripWireBlockMixin", "block.TripWireHookBlockMixin", "block.TurtleEggBlockMixin", + "block.VineBlockMixin", "block.WeightedPressurePlateBlockMixin", + "block.WitherRoseBlockMixin", "block.WitherSkeletonSkullBlockMixin", "command.CommandNodeMixin", "command.CommandsMixin", @@ -77,7 +104,10 @@ "command.arguments.EntitySelectorParserMixin", "command.impl.EffectCommandMixin", "command.impl.SummonCommandMixin", + "command.impl.TeleportCommandMixin", + "command.impl.TimeCommandMixin", "enchantment.DamageEnchantmentMixin", + "enchantment.FrostWalkerEnchantmentMixin", "entity.AgeableEntityMixin", "entity.AreaEffectCloudEntityMixin", "entity.CreatureEntityMixin", @@ -97,6 +127,7 @@ "entity.ai.goal.BreedGoalMixin", "entity.ai.goal.DefendVillageTargetGoalMixin", "entity.ai.goal.EatGrassGoalMixin", + "entity.ai.goal.FollowOwnerGoalMixin", "entity.ai.goal.HurtByTargetGoalMixin", "entity.ai.goal.NearestAttackableTargetGoalMixin", "entity.ai.goal.OwnerHurtByTargetGoalMixin", @@ -104,6 +135,7 @@ "entity.ai.goal.TargetGoalMixin", "entity.ai.goal.TemptGoalMixin", "entity.ai.goal.TriggerSkeletonTrapGoalMixin", + "entity.boss.WitherEntityMixin", "entity.boss.dragon.EnderDragonEntityMixin", "entity.boss.dragon.phase.PhaseManagerMixin", "entity.effect.LightningBoltEntityMixin", @@ -113,6 +145,7 @@ "entity.item.EnderPearlEntityMixin", "entity.item.ExperienceBottleEntityMixin", "entity.item.ExperienceOrbEntityMixin", + "entity.item.FallingBlockEntityMixin", "entity.item.FireworkRocketEntityMixin", "entity.item.HangingEntityMixin", "entity.item.ItemEntityMixin", @@ -128,6 +161,7 @@ "entity.merchant.villager.VillagerEntityMixin", "entity.merchant.villager.WanderingTraderEntityMixin", "entity.monster.AbstractRaiderEntity_FindTargetGoalMixin", + "entity.monster.AbstractRaiderEntityMixin", "entity.monster.AbstractSkeletonEntityMixin", "entity.monster.CaveSpiderEntityMixin", "entity.monster.CreeperEntityMixin", @@ -140,6 +174,8 @@ "entity.monster.IllusionerEntity_BlindnessSpellGoalMixin", "entity.monster.IllusionerEntity_MirrorSpellGoalMixin", "entity.monster.PhantomEntity_AttackPlayerGoalMixin", + "entity.monster.RavagerEntityMixin", + "entity.monster.ShulkerEntityMixin", "entity.monster.SilverfishEntity_HideInStoneGoalMixin", "entity.monster.SilverfishEntity_SummonSilverfishGoalMixin", "entity.monster.SlimeEntityMixin", @@ -149,9 +185,13 @@ "entity.monster.WitherSkeletonEntityMixin", "entity.monster.ZombieEntityMixin", "entity.monster.ZombiePigmanEntity_HurtByAggressorGoalMixin", + "entity.monster.ZombiePigmanEntityMixin", "entity.monster.ZombieVillagerEntityMixin", "entity.passive.AnimalEntityMixin", "entity.passive.BatEntityMixin", + "entity.passive.BeeEntity_AngerGoalMixin", + "entity.passive.BeeEntity_FindPollinationTargetGoalMixin", + "entity.passive.BeeEntityMixin", "entity.passive.CatEntityMixin", "entity.passive.ChickenEntityMixin", "entity.passive.CowEntityMixin", @@ -254,6 +294,7 @@ "item.FlintAndSteelItemMixin", "item.HangingEntityItemMixin", "item.ItemStackMixin", + "item.LeadItemMixin", "item.MerchantOfferMixin", "item.MilkBucketItemMixin", "item.MinecartItemMixin", @@ -281,6 +322,7 @@ "item.crafting.ShieldRecipesMixin", "item.crafting.ShulkerBoxColoringRecipeMixin", "item.crafting.SmokingRecipeMixin", + "item.crafting.SpecialRecipeMixin", "item.crafting.StonecuttingRecipeMixin", "item.crafting.SuspiciousStewRecipeMixin", "item.crafting.TippedArrowRecipeMixin", @@ -313,6 +355,7 @@ "tileentity.AbstractFurnaceTileEntityMixin", "tileentity.BarrelTileEntityMixin", "tileentity.BeaconTileEntityMixin", + "tileentity.BeehiveTileEntityMixin", "tileentity.BrewingStandTileEntityMixin", "tileentity.CampfireTileEntityMixin", "tileentity.ChestTileEntityMixin", @@ -338,33 +381,42 @@ "world.ExplosionMixin", "world.IBlockReaderMixin", "world.IWorldWriterMixin", + "world.TeleporterMixin", "world.TrackedEntityMixin", "world.WorldMixin", + "world.biome.BiomeContainerMixin", "world.border.WorldBorderMixin", "world.chunk.ChunkMixin", "world.chunk.storage.ChunkLoaderMixin", "world.chunk.storage.RegionFileCacheMixin", "world.dimension.DimensionMixin", + "world.dimension.DimensionTypeMixin", "world.gen.WorldGenRegionMixin", "world.gen.feature.structure.StructureMixin", + "world.gen.feature.structure.SwampHutPieceMixin", "world.raid.RaidManagerMixin", "world.raid.RaidMixin", "world.server.ChunkHolderMixin", "world.server.ChunkManagerMixin", "world.server.ServerChunkProvider_ChunkExecutorMixin", "world.server.ServerChunkProviderMixin", + "world.server.ServerMultiWorldMixin", "world.server.ServerWorldMixin", + "world.server.TicketManagerMixin", "world.server.TicketTypeMixin", "world.spawner.AbstractSpawnerMixin", "world.spawner.PatrolSpawnerMixin", "world.spawner.PhantomSpawnerMixin", "world.spawner.WanderingTraderSpawnerMixin", + "world.spawner.WorldEntitySpawnerMixin", "world.storage.DerivedWorldInfoMixin", "world.storage.MapData_MapInfoMixin", "world.storage.MapDataMixin", "world.storage.SaveHandlerMixin", "world.storage.WorldInfoMixin", "world.storage.loot.LootParametersMixin", + "world.storage.loot.LootTableManagerMixin", + "world.storage.loot.LootTableMixin", "world.storage.loot.conditions.RandomChanceWithLootingMixin", "world.storage.loot.conditions.SurvivesExplosionMixin", "world.storage.loot.functions.LootingEnchantBonusMixin" diff --git a/build.gradle b/build.gradle index 045ad354..fc67a6fc 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,3 @@ -import java.nio.file.* -import java.nio.file.attribute.BasicFileAttributes - allprojects { group 'io.izzel.arclight' version '1.0.7-SNAPSHOT' @@ -11,22 +8,7 @@ allprojects { task cleanBuild { doFirst { - def f = project.file("build/libs") - if (Files.exists(f.toPath())) { - Files.walkFileTree(f.toPath(), new SimpleFileVisitor() { - @Override - FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - Files.delete(file) - return FileVisitResult.CONTINUE - } - - @Override - FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { - Files.delete(dir) - return FileVisitResult.CONTINUE - } - }) - } + project.file("build/libs").deleteDir() } } }