Skip to content

Commit 24d0095

Browse files
committed
try fix #4
1 parent 5bde30d commit 24d0095

File tree

5 files changed

+21
-45
lines changed

5 files changed

+21
-45
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
## Changelog
2-
- clean
2+
- try fix #4

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ loom.platform = neoforge
1010

1111
# Mod Properties
1212
upstream_version = 1.4.147
13-
mod_version = 0.1.2
13+
mod_version = 0.1.3
1414
maven_group = org.thinkingstudio.bedsheet
1515
archives_base_name = bedsheet
1616

src/main/java/carpet/mixins/ServerGamePacketListenerImpl_scarpetEventsMixin.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,16 @@ private void onQItem(ServerboundPlayerActionPacket playerActionC2SPacket_1, Call
7373
}
7474
}
7575

76-
// Use LivingSwapItemsEvent.Hands event with NeoForge patches
77-
// @Inject(method = "handlePlayerAction", cancellable = true, at = @At(
78-
// value = "INVOKE",
79-
// target = "Lnet/minecraft/server/level/ServerPlayer;getItemInHand(Lnet/minecraft/world/InteractionHand;)Lnet/minecraft/world/item/ItemStack;",
80-
// ordinal = 0,
81-
// shift = At.Shift.BEFORE
82-
// ))
83-
// private void onHandSwap(ServerboundPlayerActionPacket playerActionC2SPacket_1, CallbackInfo ci)
84-
// {
85-
// if(PLAYER_SWAPS_HANDS.onPlayerEvent(player)) ci.cancel();
86-
// }
76+
@Inject(method = "handlePlayerAction", cancellable = true, at = @At(
77+
value = "INVOKE",
78+
target = "Lnet/minecraft/server/level/ServerPlayer;getItemInHand(Lnet/minecraft/world/InteractionHand;)Lnet/minecraft/world/item/ItemStack;",
79+
ordinal = 0,
80+
shift = At.Shift.BEFORE
81+
))
82+
private void onHandSwap(ServerboundPlayerActionPacket playerActionC2SPacket_1, CallbackInfo ci)
83+
{
84+
if(PLAYER_SWAPS_HANDS.onPlayerEvent(player)) ci.cancel();
85+
}
8786

8887
@Inject(method = "handlePlayerAction", cancellable = true, at = @At(
8988
value = "INVOKE",

src/main/java/carpet/mixins/ServerPlayer_scarpetEventMixin.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,15 @@ private void grabStat(Stat<?> stat, int amount, CallbackInfo ci)
7373
STATISTICS.onPlayerStatistic((ServerPlayer) (Object)this, stat, amount);
7474
}
7575

76-
// use LivingDeathEvent replace
77-
// @Inject(method = "die", at = @At("HEAD"))
78-
// private void onDeathEvent(DamageSource source, CallbackInfo ci)
79-
// {
80-
// ((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.Event.ON_DEATH, source.getMsgId());
81-
// if (PLAYER_DIES.isNeeded())
82-
// {
83-
// PLAYER_DIES.onPlayerEvent((ServerPlayer) (Object)this);
84-
// }
85-
// }
76+
@Inject(method = "die", at = @At("HEAD"))
77+
private void onDeathEvent(DamageSource source, CallbackInfo ci)
78+
{
79+
((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.Event.ON_DEATH, source.getMsgId());
80+
if (PLAYER_DIES.isNeeded())
81+
{
82+
PLAYER_DIES.onPlayerEvent((ServerPlayer) (Object)this);
83+
}
84+
}
8685

8786
@Redirect(method = "setPlayerInput", at = @At(
8887
value = "INVOKE",

src/main/java/org/thinkingstudio/bedsheet/BedSheetModEvents.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
package org.thinkingstudio.bedsheet;
22

33
import carpet.CarpetServer;
4-
import carpet.fakes.EntityInterface;
54
import carpet.network.CarpetClient;
6-
import carpet.script.EntityEventsGroup;
75
import net.minecraft.server.level.ServerPlayer;
86
import net.neoforged.bus.api.EventPriority;
97
import net.neoforged.bus.api.IEventBus;
108
import net.neoforged.neoforge.event.RegisterCommandsEvent;
11-
import net.neoforged.neoforge.event.entity.living.LivingDeathEvent;
12-
import net.neoforged.neoforge.event.entity.living.LivingSwapItemsEvent;
139
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
1410
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
1511
import net.neoforged.neoforge.network.registration.PayloadRegistrar;
1612

17-
import static carpet.script.CarpetEventServer.Event.PLAYER_DIES;
18-
import static carpet.script.CarpetEventServer.Event.PLAYER_SWAPS_HANDS;
19-
2013
public class BedSheetModEvents {
2114
public static void registerEvents(IEventBus modEventBus, IEventBus forgeEventBus) {
2215
forgeEventBus.addListener(EventPriority.HIGHEST, RegisterCommandsEvent.class, event -> {
@@ -25,21 +18,6 @@ public static void registerEvents(IEventBus modEventBus, IEventBus forgeEventBus
2518
forgeEventBus.addListener(EventPriority.HIGHEST, PlayerEvent.PlayerLoggedInEvent.class, event -> {
2619
CarpetServer.onPlayerLoggedIn((ServerPlayer) event.getEntity());
2720
});
28-
forgeEventBus.addListener(EventPriority.HIGHEST, LivingSwapItemsEvent.Hands.class, event -> {
29-
if(PLAYER_SWAPS_HANDS.onPlayerEvent((ServerPlayer) event.getEntity())) {
30-
event.isCanceled();
31-
}
32-
});
33-
forgeEventBus.addListener(EventPriority.HIGHEST, LivingDeathEvent.class, event -> {
34-
if (event.getEntity() instanceof ServerPlayer serverPlayer) {
35-
((EntityInterface) serverPlayer).getEventContainer().onEvent(EntityEventsGroup.Event.ON_DEATH, event.getSource().getMsgId());
36-
if (PLAYER_DIES.isNeeded())
37-
{
38-
PLAYER_DIES.onPlayerEvent(serverPlayer);
39-
}
40-
}
41-
((EntityInterface) event.getEntity()).getEventContainer().onEvent(EntityEventsGroup.Event.ON_DEATH, event.getSource().getMsgId());
42-
});
4321

4422
modEventBus.addListener(EventPriority.HIGHEST, RegisterPayloadHandlersEvent.class, event -> {
4523
final PayloadRegistrar registrar = event.registrar(BedSheetModReference.MODID);

0 commit comments

Comments
 (0)