-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
127 additions
and
319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 0 additions & 56 deletions
56
...nt/java/net/fabricmc/fabric/mixin/client/entity/event/elytra/ClientPlayerEntityMixin.java
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
fabric-entity-events-v1/src/client/resources/fabric-entity-events-v1.client.mixins.json
This file was deleted.
Oops, something went wrong.
80 changes: 80 additions & 0 deletions
80
...ntity-events-v1/src/main/java/net/fabricmc/fabric/impl/entity/event/EntityEventHooks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.fabricmc.fabric.impl.entity.event; | ||
|
||
import net.fabricmc.fabric.api.entity.event.v1.EntitySleepEvents; | ||
import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents; | ||
import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.InteractionResult; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.Mob; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.neoforged.bus.api.SubscribeEvent; | ||
import net.neoforged.fml.common.EventBusSubscriber; | ||
import net.neoforged.neoforge.event.entity.living.LivingAttackEvent; | ||
import net.neoforged.neoforge.event.entity.living.LivingConversionEvent; | ||
import net.neoforged.neoforge.event.entity.player.CanContinueSleepingEvent; | ||
import net.neoforged.neoforge.event.entity.player.CanPlayerSleepEvent; | ||
import net.neoforged.neoforge.event.entity.player.PlayerEvent; | ||
|
||
@EventBusSubscriber | ||
public final class EntityEventHooks { | ||
|
||
@SubscribeEvent | ||
public static void onLivingAttack(LivingAttackEvent event) { | ||
LivingEntity entity = event.getEntity(); | ||
if (!entity.level().isClientSide() && !ServerLivingEntityEvents.ALLOW_DAMAGE.invoker().allowDamage(entity, event.getSource(), event.getAmount())) { | ||
event.setCanceled(true); | ||
} | ||
} | ||
|
||
@SubscribeEvent | ||
public static void onPlayerSleepInBed(CanPlayerSleepEvent event) { | ||
Player.BedSleepingProblem failureReason = EntitySleepEvents.ALLOW_SLEEPING.invoker().allowSleep(event.getEntity(), event.getPos()); | ||
|
||
if (failureReason != null) { | ||
event.setProblem(failureReason); | ||
} | ||
} | ||
|
||
@SubscribeEvent | ||
public static void onPlayerSleepingTimeCheck(CanContinueSleepingEvent event) { | ||
event.getEntity().getSleepingPos().ifPresent(sleepingPos -> { | ||
if (event.getEntity() instanceof Player player) { | ||
InteractionResult result = EntitySleepEvents.ALLOW_SLEEP_TIME.invoker().allowSleepTime(player, sleepingPos, !player.level().isDay()); | ||
if (result != InteractionResult.PASS) { | ||
event.setContinueSleeping(result.consumesAction()); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
@SubscribeEvent | ||
public static void onPlayerClone(PlayerEvent.Clone event) { | ||
ServerPlayerEvents.COPY_FROM.invoker().copyFromPlayer((ServerPlayer) event.getOriginal(), (ServerPlayer) event.getEntity(), !event.isWasDeath()); | ||
} | ||
|
||
@SubscribeEvent | ||
public static void onLivingConversion(LivingConversionEvent.Post event) { | ||
if (event.getEntity() instanceof Mob mobEntity && event.getOutcome() instanceof Mob converted) { | ||
ServerLivingEntityEvents.MOB_CONVERSION.invoker().onConversion(mobEntity, converted, false); | ||
} | ||
} | ||
|
||
private EntityEventHooks() {} | ||
} |
19 changes: 19 additions & 0 deletions
19
...y-events-v1/src/main/java/net/fabricmc/fabric/mixin/entity/event/IItemExtensionMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package net.fabricmc.fabric.mixin.entity.event; | ||
|
||
import net.fabricmc.fabric.api.entity.event.v1.FabricElytraItem; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.neoforged.neoforge.common.extensions.IItemExtension; | ||
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; | ||
|
||
@Mixin(IItemExtension.class) | ||
public interface IItemExtensionMixin { | ||
|
||
@Inject(method = "canElytraFly", at = @At("HEAD"), cancellable = true) | ||
default void canElytraFly(ItemStack stack, LivingEntity entity, CallbackInfoReturnable<Boolean> cir) { | ||
cir.setReturnValue(this instanceof FabricElytraItem); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
...-events-v1/src/main/java/net/fabricmc/fabric/mixin/entity/event/MooshroomEntityMixin.java
This file was deleted.
Oops, something went wrong.
44 changes: 0 additions & 44 deletions
44
...entity-events-v1/src/main/java/net/fabricmc/fabric/mixin/entity/event/PigEntityMixin.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.