use of mcjty.rftools.playerprops.FavoriteDestinationsProperties in project RFTools by McJty.
the class CommonProxy method preInit.
public void preInit(FMLPreInitializationEvent e) {
MinecraftForge.EVENT_BUS.register(new ForgeEventHandlers());
McJtyLib.preInit(e);
CommandHandler.registerCommands();
reflect();
GeneralConfig.preInit(e);
modConfigDir = e.getModConfigurationDirectory();
mainConfig = new Configuration(new File(modConfigDir.getPath() + File.separator + "rftools", "rftools.cfg"));
CapabilityManager.INSTANCE.register(BuffProperties.class, new Capability.IStorage<BuffProperties>() {
@Override
public NBTBase writeNBT(Capability<BuffProperties> capability, BuffProperties instance, EnumFacing side) {
throw new UnsupportedOperationException();
}
@Override
public void readNBT(Capability<BuffProperties> capability, BuffProperties instance, EnumFacing side, NBTBase nbt) {
throw new UnsupportedOperationException();
}
}, () -> {
throw new UnsupportedOperationException();
});
CapabilityManager.INSTANCE.register(FavoriteDestinationsProperties.class, new Capability.IStorage<FavoriteDestinationsProperties>() {
@Override
public NBTBase writeNBT(Capability<FavoriteDestinationsProperties> capability, FavoriteDestinationsProperties instance, EnumFacing side) {
throw new UnsupportedOperationException();
}
@Override
public void readNBT(Capability<FavoriteDestinationsProperties> capability, FavoriteDestinationsProperties instance, EnumFacing side, NBTBase nbt) {
throw new UnsupportedOperationException();
}
}, () -> {
throw new UnsupportedOperationException();
});
CapabilityManager.INSTANCE.register(IModuleProvider.class, new Capability.IStorage<IModuleProvider>() {
@Override
public NBTBase writeNBT(Capability<IModuleProvider> capability, IModuleProvider instance, EnumFacing side) {
throw new UnsupportedOperationException();
}
@Override
public void readNBT(Capability<IModuleProvider> capability, IModuleProvider instance, EnumFacing side, NBTBase nbt) {
throw new UnsupportedOperationException();
}
}, () -> {
throw new UnsupportedOperationException();
});
readMainConfig();
SimpleNetworkWrapper network = PacketHandler.registerMessages(RFTools.MODID, "rftools");
RFToolsMessages.registerNetworkMessages(network);
ModItems.init();
ModBlocks.init();
ModWorldgen.init();
RFTools.screenModuleRegistry.registerBuiltins();
ForgeChunkManager.setForcedChunkLoadingCallback(RFTools.instance, (tickets, world) -> {
});
}
use of mcjty.rftools.playerprops.FavoriteDestinationsProperties in project RFTools by McJty.
the class DialingDeviceTileEntity method changeFavorite.
// Server side only.
private void changeFavorite(String playerName, BlockPos receiver, int dimension, boolean favorite) {
List<EntityPlayerMP> list = ((WorldServer) getWorld()).getMinecraftServer().getPlayerList().getPlayers();
for (EntityPlayerMP entityplayermp : list) {
if (playerName.equals(entityplayermp.getName())) {
FavoriteDestinationsProperties favoriteDestinations = PlayerExtendedProperties.getFavoriteDestinations(entityplayermp);
favoriteDestinations.setDestinationFavorite(new GlobalCoordinate(receiver, dimension), favorite);
return;
}
}
}
use of mcjty.rftools.playerprops.FavoriteDestinationsProperties in project RFTools by McJty.
the class TeleportDestinations method getValidDestinations.
// Server side only
public Collection<TeleportDestinationClientInfo> getValidDestinations(World worldObj, String playerName) {
FavoriteDestinationsProperties properties = null;
if (playerName != null) {
List<EntityPlayerMP> list = ((WorldServer) worldObj).getMinecraftServer().getPlayerList().getPlayers();
for (EntityPlayerMP entityplayermp : list) {
if (playerName.equals(entityplayermp.getName())) {
properties = PlayerExtendedProperties.getFavoriteDestinations(entityplayermp);
break;
}
}
}
List<TeleportDestinationClientInfo> result = new ArrayList<>();
for (TeleportDestination destination : destinations.values()) {
TeleportDestinationClientInfo destinationClientInfo = new TeleportDestinationClientInfo(destination);
BlockPos c = destination.getCoordinate();
World world = DimensionManager.getWorld(destination.getDimension());
String dimName = null;
if (world != null) {
dimName = DimensionManager.getProvider(destination.getDimension()).getDimensionType().getName();
}
// }
if (dimName == null || dimName.trim().isEmpty()) {
dimName = "Id " + destination.getDimension();
} else {
dimName = dimName + " (" + destination.getDimension() + ")";
}
destinationClientInfo.setDimensionName(dimName);
if (world != null) {
TileEntity te = world.getTileEntity(c);
if (te instanceof MatterReceiverTileEntity) {
MatterReceiverTileEntity matterReceiverTileEntity = (MatterReceiverTileEntity) te;
if (playerName != null && !matterReceiverTileEntity.checkAccess(playerName)) {
// No access.
continue;
}
}
}
if (properties != null) {
destinationClientInfo.setFavorite(properties.isDestinationFavorite(new GlobalCoordinate(c, destination.getDimension())));
}
result.add(destinationClientInfo);
}
Collections.sort(result);
return result;
}
use of mcjty.rftools.playerprops.FavoriteDestinationsProperties in project RFTools by McJty.
the class ForgeEventHandlers method onPlayerCloned.
@SubscribeEvent
public void onPlayerCloned(PlayerEvent.Clone event) {
if (event.isWasDeath()) {
// We need to copyFrom the capabilities
if (event.getOriginal().hasCapability(PlayerExtendedProperties.FAVORITE_DESTINATIONS_CAPABILITY, null)) {
FavoriteDestinationsProperties oldFavorites = event.getOriginal().getCapability(PlayerExtendedProperties.FAVORITE_DESTINATIONS_CAPABILITY, null);
FavoriteDestinationsProperties newFavorites = PlayerExtendedProperties.getFavoriteDestinations(event.getEntityPlayer());
newFavorites.copyFrom(oldFavorites);
}
}
}
Aggregations