-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from cdqtzrc/fabric/1.21
修复服务端无法启动
- Loading branch information
Showing
3 changed files
with
26 additions
and
5 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/main/java/dev/dubhe/gugle/carpet/mixin/EntityMixin.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,25 @@ | ||
package dev.dubhe.gugle.carpet.mixin; | ||
|
||
import dev.dubhe.gugle.carpet.GcaSetting; | ||
import net.minecraft.client.player.RemotePlayer; | ||
import net.minecraft.world.InteractionHand; | ||
import net.minecraft.world.InteractionResult; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.player.Player; | ||
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(Entity.class) | ||
public class EntityMixin { | ||
@SuppressWarnings("ConstantValue") | ||
@Inject(method = "interact", at = @At("HEAD"), cancellable = true) | ||
private void interact(Player player, InteractionHand interactionHand, CallbackInfoReturnable<InteractionResult> cir) { | ||
// 在客户端中,玩家可以与客户端的被交互玩家交互并返回PASS,这时交互玩家手上如果拿着可以使用的物品,则物品会被使用 | ||
// 所以如果判断被交互实体是客户端玩家,返回SUCCESS | ||
if ((Object) this instanceof RemotePlayer && (GcaSetting.openFakePlayerInventory || GcaSetting.openFakePlayerEnderChest)) { | ||
cir.setReturnValue(InteractionResult.SUCCESS); | ||
} | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
"server": [ | ||
], | ||
"client": [ | ||
"EntityMixin", | ||
"ServerPlayerMixin" | ||
], | ||
"injectors": { | ||
|