2015-12-01 17:28:50 +01:00
|
|
|
/*
|
|
|
|
* This file ("VanillaPacketSyncer.java") is part of the Actually Additions Mod for Minecraft.
|
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-01-03 16:05:51 +01:00
|
|
|
* http://ellpeck.de/actaddlicense/
|
2015-12-01 17:28:50 +01:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2016-01-03 16:05:51 +01:00
|
|
|
* © 2016 Ellpeck
|
2015-12-01 17:28:50 +01:00
|
|
|
*/
|
|
|
|
|
2015-12-30 22:02:15 +01:00
|
|
|
package de.ellpeck.actuallyadditions.network;
|
2015-12-01 17:28:50 +01:00
|
|
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class VanillaPacketSyncer{
|
|
|
|
|
|
|
|
public static void sendTileToNearbyPlayers(TileEntity tile){
|
|
|
|
List allPlayers = tile.getWorldObj().playerEntities;
|
|
|
|
for(Object player : allPlayers){
|
|
|
|
if(player instanceof EntityPlayerMP){
|
|
|
|
sendTileToPlayer(tile, (EntityPlayerMP)player, 64);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void sendTileToPlayer(TileEntity tile, EntityPlayerMP player, int maxDistance){
|
|
|
|
if(player.getDistance(tile.xCoord, tile.yCoord, tile.zCoord) <= maxDistance){
|
|
|
|
sendTileToPlayer(tile, player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void sendTileToPlayer(TileEntity tile, EntityPlayerMP player){
|
|
|
|
player.playerNetServerHandler.sendPacket(tile.getDescriptionPacket());
|
|
|
|
}
|
|
|
|
}
|