player actions
This commit is contained in:
1 parent
dc0dc9e406
commit
50d1d74579
10 files changed
+612
-1057
No files matched your search
+16
-7
@@ -3,8 +3,12 @@ package carpet.mixins;
|
||||
import carpet.settings.CarpetSettings;
|
||||
import net.minecraft.client.network.packet.EntityPositionS2CPacket;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.mob.MobEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -12,22 +16,27 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
public abstract class Entity_horseFixMixin
|
||||
@Mixin(PlayerEntity.class)
|
||||
public abstract class PlayerEntity_horseFixMixin extends Entity
|
||||
{
|
||||
@Shadow private Entity vehicle;
|
||||
|
||||
@Shadow public abstract World getEntityWorld();
|
||||
@Shadow public abstract ActionResult interact(Entity entity_1, Hand hand_1);
|
||||
|
||||
public PlayerEntity_horseFixMixin(EntityType<?> entityType_1, World world_1)
|
||||
{
|
||||
super(entityType_1, world_1);
|
||||
}
|
||||
|
||||
@Inject(method = "stopRiding", at = @At("HEAD"))
|
||||
private void resetNavigation(CallbackInfo ci)
|
||||
{
|
||||
if (vehicle != null && vehicle instanceof MobEntity && CarpetSettings.horseWanderingFix)
|
||||
if (this.getVehicle() != null && CarpetSettings.horseWanderingFix)
|
||||
{
|
||||
((MobEntity) vehicle).getNavigation().stop();
|
||||
if (getVehicle() instanceof MobEntity)
|
||||
((MobEntity) getVehicle()).getNavigation().stop();
|
||||
if (!getEntityWorld().isClient)
|
||||
{
|
||||
((ServerWorld) getEntityWorld()).method_14178().sendToNearbyPlayers((Entity)(Object)this, new EntityPositionS2CPacket(vehicle));
|
||||
((ServerWorld) getEntityWorld()).method_14178().sendToNearbyPlayers((Entity)(Object)this, new EntityPositionS2CPacket(getVehicle()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetServer;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.network.packet.CustomPayloadC2SPacket;
|
||||
import net.minecraft.text.Text;
|
||||
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;
|
||||
|
||||
@Mixin(ServerPlayNetworkHandler.class)
|
||||
public class ServerPlayNetworkHandler_coreMixin {
|
||||
@Shadow
|
||||
public ServerPlayerEntity player;
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void onPlayerConnect(MinecraftServer server, ClientConnection client, ServerPlayerEntity player, CallbackInfo ci) {
|
||||
CarpetServer.onPlayerLoggedIn(player);
|
||||
}
|
||||
|
||||
@Inject(method = "onDisconnected", at = @At("HEAD"))
|
||||
private void onPlayerDisconnect(Text reason, CallbackInfo ci) {
|
||||
CarpetServer.onPlayerLoggedOut(this.player);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -12,7 +12,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ServerPlayNetworkHandler.class)
|
||||
public class ServerPlayNetworkHandlerMixin
|
||||
public class ServerPlayNetworkHandler_tickMixin
|
||||
{
|
||||
@Shadow public ServerPlayerEntity player;
|
||||
|
||||
Reference in new issue
Block a user