Skip to content

Commit

Permalink
A fix for multiplayer
Browse files Browse the repository at this point in the history
  • Loading branch information
OldSerpskiStalker committed Oct 10, 2024
1 parent 20164a3 commit 8de19c5
Show file tree
Hide file tree
Showing 29 changed files with 115 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.minecraft.block.state.IBlockState;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
Expand Down Expand Up @@ -67,9 +67,9 @@ public String getUsage(@Nonnull ICommandSender sender)
@Override
public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String... args)
{
if (sender instanceof EntityPlayer)
if (sender instanceof EntityPlayerMP)
{
EntityPlayer player = (EntityPlayer) sender;
EntityPlayerMP player = (EntityPlayerMP) sender;
RayTraceResult result = RayTrace.getMovingObjectPositionFromPlayer(player.getEntityWorld(), player, false);

if (result != null && result.typeOfHit == RayTraceResult.Type.BLOCK)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.TextComponentString;
Expand Down Expand Up @@ -59,7 +59,7 @@ public String getUsage(@Nonnull ICommandSender sender)
@Override
public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String... args)
{
if (sender instanceof EntityPlayer)
if (sender instanceof EntityPlayerMP)
{
RayTraceResult result = Minecraft.getMinecraft().objectMouseOver;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
Expand Down Expand Up @@ -65,9 +65,9 @@ public String getUsage(@Nonnull ICommandSender sender)
@Override
public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String... args)
{
if (sender instanceof EntityPlayer)
if (sender instanceof EntityPlayerMP)
{
EntityPlayer player = (EntityPlayer) sender;
EntityPlayerMP player = (EntityPlayerMP) sender;
ItemStack heldItem = player.getHeldItem(EnumHand.MAIN_HAND);
Item item = heldItem.getItem();
sender.sendMessage(new TextComponentString(TextFormatting.GOLD + Objects.requireNonNull(item.getRegistryName()).toString()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World;
Expand Down Expand Up @@ -63,13 +63,13 @@ public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sen
return;
}

if (!(sender instanceof EntityPlayer))
if (!(sender instanceof EntityPlayerMP))
{
sender.sendMessage(new TextComponentString("This command can only be used by players!"));
return;
}

EntityPlayer player = (EntityPlayer) sender;
EntityPlayerMP player = (EntityPlayerMP) sender;
World world = player.getEntityWorld();
double speed, explosionStrength;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.passive.EntityAmbientCreature;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextFormatting;
Expand Down Expand Up @@ -66,14 +66,14 @@ public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sen
if (args.length > 0)
{
String argument0 = args[0].toLowerCase();
WorldServer worldServer = server.getWorld((sender instanceof EntityPlayer) ? sender.getEntityWorld().provider.getDimension() : 0);
WorldServer worldServer = server.getWorld((sender instanceof EntityPlayerMP) ? sender.getEntityWorld().provider.getDimension() : 0);
List<Entity> entityList = new ArrayList<>();

if ("all".equals(argument0))
{
for (Entity entity : worldServer.loadedEntityList)
{
if (!(entity instanceof EntityPlayer))
if (!(entity instanceof EntityPlayerMP))
{
entityList.add(entity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -69,9 +69,9 @@ public synchronized void onHit(LivingHurtEvent event)
entity.setFire(5);
}
}
else if (entityGetTrueSource instanceof EntityPlayer)
else if (entityGetTrueSource instanceof EntityPlayerMP)
{
EntityPlayer player = (EntityPlayer)entityGetTrueSource;
EntityPlayerMP player = (EntityPlayerMP)entityGetTrueSource;

if (Block.getBlockFromItem(player.getHeldItemMainhand().getItem()) instanceof BlockTorch)
{
Expand All @@ -97,7 +97,7 @@ else if (entityGetTrueSource instanceof EntitySkeleton)
@SubscribeEvent
public synchronized void onBreak(BlockEvent.BreakEvent event)
{
EntityPlayer player = event.getPlayer();
EntityPlayerMP player = (EntityPlayerMP) event.getPlayer();

if (Block.getBlockFromItem(player.getHeldItemMainhand().getItem()) instanceof BlockTorch)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -832,7 +832,7 @@ public static List<Predicate<NBTTagCompound>> getNbtMatchers(JsonArray nbtArray)
*/
public static boolean isFakePlayer(Entity entity)
{
if (!(entity instanceof EntityPlayer))
if (!(entity instanceof EntityPlayerMP))
{
return false;
}
Expand All @@ -844,7 +844,7 @@ public static boolean isFakePlayer(Entity entity)

// Если этот метод возвращает false, всё ещё возможно, что это фальшивый игрок. Попробуем найти игрока в списке онлайн-игроков
PlayerList playerList = Objects.requireNonNull(DimensionManager.getWorld(0).getMinecraftServer()).getPlayerList();
EntityPlayerMP playerByUUID = playerList.getPlayerByUUID(((EntityPlayer) entity).getGameProfile().getId());
EntityPlayerMP playerByUUID = playerList.getPlayerByUUID(((EntityPlayerMP) entity).getGameProfile().getId());

if (playerByUUID == null)
{
Expand All @@ -863,7 +863,7 @@ public static boolean isFakePlayer(Entity entity)
*/
public static boolean isRealPlayer(Entity entity)
{
if (!(entity instanceof EntityPlayer))
if (!(entity instanceof EntityPlayerMP))
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
Expand Down Expand Up @@ -601,7 +601,7 @@ public void addHelmetCheck(AttributeMap<?> map)

this.ARRAY_LIST.add((event, query) ->
{
EntityPlayer player = query.getPlayer(event);
EntityPlayerMP player = query.getPlayer(event);

if (player != null)
{
Expand All @@ -626,7 +626,7 @@ public void addChestPlateCheck(AttributeMap<?> map)

this.ARRAY_LIST.add((event, query) ->
{
EntityPlayer player = query.getPlayer(event);
EntityPlayerMP player = query.getPlayer(event);

if (player != null)
{
Expand All @@ -651,7 +651,7 @@ public void addLeggingsCheck(AttributeMap<?> map)

this.ARRAY_LIST.add((event, query) ->
{
EntityPlayer player = query.getPlayer(event);
EntityPlayerMP player = query.getPlayer(event);

if (player != null)
{
Expand All @@ -676,7 +676,7 @@ public void addBootsCheck(AttributeMap<?> map)

this.ARRAY_LIST.add((event, query) ->
{
EntityPlayer player = query.getPlayer(event);
EntityPlayerMP player = query.getPlayer(event);

if (player != null)
{
Expand Down Expand Up @@ -1059,11 +1059,11 @@ private void addPlayerCheck(AttributeMap<?> map)
if ((Boolean)asPlayer)
{
this.ARRAY_LIST.add((event, query) ->
query.getAttacker(event) instanceof EntityPlayer);
query.getAttacker(event) instanceof EntityPlayerMP);
}
//else
//{
// _arrayList.add((event, query) -> query.getAttacker(event) instanceof EntityPlayer);
// _arrayList.add((event, query) -> query.getAttacker(event) instanceof EntityPlayerMP);
//}
}

Expand Down Expand Up @@ -1118,7 +1118,7 @@ public void addHeldItemCheck(AttributeMap<?> map, AttributeKey<String> key)

this.ARRAY_LIST.add((event,query) ->
{
EntityPlayer player = query.getPlayer(event);
EntityPlayerMP player = query.getPlayer(event);

if (player != null)
{
Expand Down Expand Up @@ -1150,7 +1150,7 @@ public void addOffHandItemCheck(AttributeMap<?> map)

this.ARRAY_LIST.add((event,query) ->
{
EntityPlayer player = query.getPlayer(event);
EntityPlayerMP player = query.getPlayer(event);

if (player != null)
{
Expand Down Expand Up @@ -1282,7 +1282,7 @@ public void addBothHandsItemCheck(AttributeMap<?> map)

this.ARRAY_LIST.add((event,query) ->
{
EntityPlayer player = query.getPlayer(event);
EntityPlayerMP player = query.getPlayer(event);

if (player != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.monster.EntityPigZombie;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -191,11 +191,11 @@ private void addDoMessageAction(AttributeMap<?> map)

this.ACTIONS.add(event ->
{
EntityPlayer player = event.getPlayer();
EntityPlayerMP player = event.getPlayer();

if (player == null)
{
player = event.getWorld().getClosestPlayerToEntity(event.getEntityLiving(), 100);
player = (EntityPlayerMP) event.getWorld().getClosestPlayerToEntity(event.getEntityLiving(), 100);
}

if (player != null)
Expand All @@ -222,7 +222,7 @@ public void addAngryAction(AttributeMap<?> map)
if (entityLiving instanceof EntityPigZombie)
{
EntityPigZombie pigZombie = (EntityPigZombie) entityLiving;
EntityPlayer player = event.getWorld().getClosestPlayerToEntity(entityLiving, 50);
EntityPlayerMP player = (EntityPlayerMP) event.getWorld().getClosestPlayerToEntity(entityLiving, 50);

if (player != null)
{
Expand All @@ -231,7 +231,7 @@ public void addAngryAction(AttributeMap<?> map)
}
else if (entityLiving instanceof EntityLiving)
{
EntityPlayer player = event.getWorld().getClosestPlayerToEntity(entityLiving, 50);
EntityPlayerMP player = (EntityPlayerMP) event.getWorld().getClosestPlayerToEntity(entityLiving, 50);

if (player != null)
{
Expand Down Expand Up @@ -576,7 +576,7 @@ private void addGiveAction(AttributeMap<?> map)

this.ACTIONS.add(event ->
{
EntityPlayer player = event.getPlayer();
EntityPlayerMP player = event.getPlayer();

if (player != null)
{
Expand All @@ -593,7 +593,7 @@ private void addGiveAction(AttributeMap<?> map)

this.ACTIONS.add(event ->
{
EntityPlayer player = event.getPlayer();
EntityPlayerMP player = event.getPlayer();

if (player != null)
{
Expand Down Expand Up @@ -656,7 +656,7 @@ private void addCommandAction(AttributeMap<?> map)

this.ACTIONS.add(event ->
{
EntityPlayer player = event.getPlayer();
EntityPlayerMP player = event.getPlayer();
MinecraftServer server = event.getWorld().getMinecraftServer();

assert server != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
Expand All @@ -23,7 +23,7 @@ public final class RayTrace
* @param useLiquids
* @return
*/
public static RayTraceResult getMovingObjectPositionFromPlayer(World worldIn, EntityPlayer playerIn, boolean useLiquids)
public static RayTraceResult getMovingObjectPositionFromPlayer(World worldIn, EntityPlayerMP playerIn, boolean useLiquids)
{
float pitch = playerIn.rotationPitch;
float yaw = playerIn.rotationYaw;
Expand Down Expand Up @@ -54,7 +54,7 @@ public static RayTraceResult getMovingObjectPositionFromPlayer(World worldIn, En
* @param playerIn
* @return
*/
private static Vec3d getPlayerEyes(EntityPlayer playerIn)
private static Vec3d getPlayerEyes(EntityPlayerMP playerIn)
{
double x = playerIn.posX;
double y = playerIn.posY + playerIn.getEyeHeight();
Expand All @@ -69,7 +69,7 @@ private static Vec3d getPlayerEyes(EntityPlayer playerIn)
* @param player
* @return
*/
public static boolean isPlayerStandingOnBlock(World world, EntityPlayer player)
public static boolean isPlayerStandingOnBlock(World world, EntityPlayerMP player)
{
double posX = player.posX;
double posY = player.posY;
Expand All @@ -90,7 +90,7 @@ public static boolean isPlayerStandingOnBlock(World world, EntityPlayer player)
* @param player
* @return
*/
public static BlockPos getBlockPosBelowPlayer(EntityPlayer player)
public static BlockPos getBlockPosBelowPlayer(EntityPlayerMP player)
{
double posX = player.posX;
double posY = player.posY - 0.1;
Expand Down
Loading

0 comments on commit 8de19c5

Please sign in to comment.