Search in sources :

Example 1 with FavoriteDestinationsProperties

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) -> {
    });
}
Also used : SimpleNetworkWrapper(net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper) BoosterConfiguration(mcjty.rftools.blocks.booster.BoosterConfiguration) BlockProtectorConfiguration(mcjty.rftools.blocks.blockprotector.BlockProtectorConfiguration) GeneralConfiguration(mcjty.rftools.GeneralConfiguration) SpawnerConfiguration(mcjty.rftools.blocks.spawner.SpawnerConfiguration) ModularStorageConfiguration(mcjty.rftools.blocks.storage.ModularStorageConfiguration) StorageScannerConfiguration(mcjty.rftools.blocks.storagemonitor.StorageScannerConfiguration) Configuration(net.minecraftforge.common.config.Configuration) ShieldConfiguration(mcjty.rftools.blocks.shield.ShieldConfiguration) CoalGeneratorConfiguration(mcjty.rftools.blocks.generator.CoalGeneratorConfiguration) SecurityConfiguration(mcjty.rftools.blocks.security.SecurityConfiguration) NetworkMonitorConfiguration(mcjty.rftools.items.netmonitor.NetworkMonitorConfiguration) TeleportConfiguration(mcjty.rftools.blocks.teleporter.TeleportConfiguration) MachineInfuserConfiguration(mcjty.rftools.blocks.infuser.MachineInfuserConfiguration) CrafterConfiguration(mcjty.rftools.blocks.crafter.CrafterConfiguration) EnvironmentalConfiguration(mcjty.rftools.blocks.environmental.EnvironmentalConfiguration) ElevatorConfiguration(mcjty.rftools.blocks.elevator.ElevatorConfiguration) ScannerConfiguration(mcjty.rftools.blocks.shaper.ScannerConfiguration) EndergenicConfiguration(mcjty.rftools.blocks.endergen.EndergenicConfiguration) ScreenConfiguration(mcjty.rftools.blocks.screens.ScreenConfiguration) PowerCellConfiguration(mcjty.rftools.blocks.powercell.PowerCellConfiguration) BuilderConfiguration(mcjty.rftools.blocks.builder.BuilderConfiguration) Capability(net.minecraftforge.common.capabilities.Capability) EnumFacing(net.minecraft.util.EnumFacing) FavoriteDestinationsProperties(mcjty.rftools.playerprops.FavoriteDestinationsProperties) BuffProperties(mcjty.rftools.playerprops.BuffProperties) NBTBase(net.minecraft.nbt.NBTBase) ForgeEventHandlers(mcjty.rftools.ForgeEventHandlers) IModuleProvider(mcjty.rftools.api.screens.IModuleProvider) File(java.io.File)

Example 2 with FavoriteDestinationsProperties

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;
        }
    }
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) WorldServer(net.minecraft.world.WorldServer) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) FavoriteDestinationsProperties(mcjty.rftools.playerprops.FavoriteDestinationsProperties)

Example 3 with FavoriteDestinationsProperties

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;
}
Also used : WorldServer(net.minecraft.world.WorldServer) World(net.minecraft.world.World) FavoriteDestinationsProperties(mcjty.rftools.playerprops.FavoriteDestinationsProperties) TileEntity(net.minecraft.tileentity.TileEntity) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) BlockPos(net.minecraft.util.math.BlockPos)

Example 4 with FavoriteDestinationsProperties

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);
        }
    }
}
Also used : FavoriteDestinationsProperties(mcjty.rftools.playerprops.FavoriteDestinationsProperties) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

FavoriteDestinationsProperties (mcjty.rftools.playerprops.FavoriteDestinationsProperties)4 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 WorldServer (net.minecraft.world.WorldServer)2 File (java.io.File)1 GlobalCoordinate (mcjty.lib.varia.GlobalCoordinate)1 ForgeEventHandlers (mcjty.rftools.ForgeEventHandlers)1 GeneralConfiguration (mcjty.rftools.GeneralConfiguration)1 IModuleProvider (mcjty.rftools.api.screens.IModuleProvider)1 BlockProtectorConfiguration (mcjty.rftools.blocks.blockprotector.BlockProtectorConfiguration)1 BoosterConfiguration (mcjty.rftools.blocks.booster.BoosterConfiguration)1 BuilderConfiguration (mcjty.rftools.blocks.builder.BuilderConfiguration)1 CrafterConfiguration (mcjty.rftools.blocks.crafter.CrafterConfiguration)1 ElevatorConfiguration (mcjty.rftools.blocks.elevator.ElevatorConfiguration)1 EndergenicConfiguration (mcjty.rftools.blocks.endergen.EndergenicConfiguration)1 EnvironmentalConfiguration (mcjty.rftools.blocks.environmental.EnvironmentalConfiguration)1 CoalGeneratorConfiguration (mcjty.rftools.blocks.generator.CoalGeneratorConfiguration)1 MachineInfuserConfiguration (mcjty.rftools.blocks.infuser.MachineInfuserConfiguration)1 PowerCellConfiguration (mcjty.rftools.blocks.powercell.PowerCellConfiguration)1 ScreenConfiguration (mcjty.rftools.blocks.screens.ScreenConfiguration)1 SecurityConfiguration (mcjty.rftools.blocks.security.SecurityConfiguration)1