Search in sources :

Example 1 with PlayerConfig

use of logisticspipes.config.PlayerConfig in project LogisticsPipes by RS485.

the class LogisticsEventListener method getPlayerConfig.

public static PlayerConfig getPlayerConfig(PlayerIdentifier ident) {
    PlayerConfig config = LogisticsEventListener.playerConfigs.get(ident);
    if (config == null) {
        config = new PlayerConfig(ident);
        config.readFromFile();
        LogisticsEventListener.playerConfigs.put(ident, config);
    }
    return config;
}
Also used : PlayerConfig(logisticspipes.config.PlayerConfig)

Example 2 with PlayerConfig

use of logisticspipes.config.PlayerConfig in project LogisticsPipes by RS485.

the class LogisticsBlockGenericPipe method addDestroyEffects.

/**
	 * Spawn particles for when the block is destroyed. Due to the nature of how
	 * this is invoked, the x/y/z locations are not always guaranteed to host
	 * your block. So be sure to do proper sanity checks before assuming that
	 * the location is this block.
	 *
	 * @param worldObj
	 *            The current world
	 * @param x
	 *            X position to spawn the particle
	 * @param y
	 *            Y position to spawn the particle
	 * @param z
	 *            Z position to spawn the particle
	 * @param meta
	 *            The metadata for the block before it was destroyed.
	 * @param effectRenderer
	 *            A reference to the current effect renderer.
	 * @return True to prevent vanilla break particles from spawning.
	 */
@SideOnly(Side.CLIENT)
@Override
public boolean addDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
    CoreUnroutedPipe pipe = LogisticsBlockGenericPipe.getPipe(worldObj, x, y, z);
    if (pipe == null) {
        return false;
    }
    PlayerConfig config = LogisticsPipes.getClientPlayerConfig();
    if (config.isUseNewRenderer()) {
        LogisticsNewRenderPipe.renderDestruction(pipe, worldObj, x, y, z, effectRenderer);
    } else {
        IIcon icon = pipe.getIconProvider().getIcon(pipe.getIconIndexForItem());
        byte its = 4;
        for (int i = 0; i < its; ++i) {
            for (int j = 0; j < its; ++j) {
                for (int k = 0; k < its; ++k) {
                    if (pipe.isMultiBlock()) {
                        LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> set = ((CoreMultiBlockPipe) pipe).getRotatedSubBlocks();
                        set.add(new DoubleCoordinatesType<>(0, 0, 0, CoreMultiBlockPipe.SubBlockTypeForShare.NON_SHARE));
                        for (DoubleCoordinates pos : set) {
                            int localx = x + pos.getXInt();
                            int localy = y + pos.getYInt();
                            int localz = z + pos.getZInt();
                            double px = localx + (i + 0.5D) / its;
                            double py = localy + (j + 0.5D) / its;
                            double pz = localz + (k + 0.5D) / its;
                            int random = rand.nextInt(6);
                            EntityDiggingFX fx = new EntityDiggingFX(worldObj, px, py, pz, px - localx - 0.5D, py - localy - 0.5D, pz - localz - 0.5D, LogisticsPipes.LogisticsPipeBlock, random, meta);
                            fx.setParticleIcon(icon);
                            effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z));
                        }
                    } else {
                        double px = x + (i + 0.5D) / its;
                        double py = y + (j + 0.5D) / its;
                        double pz = z + (k + 0.5D) / its;
                        int random = rand.nextInt(6);
                        EntityDiggingFX fx = new EntityDiggingFX(worldObj, px, py, pz, px - x - 0.5D, py - y - 0.5D, pz - z - 0.5D, LogisticsPipes.LogisticsPipeBlock, random, meta);
                        fx.setParticleIcon(icon);
                        effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z));
                    }
                }
            }
        }
    }
    return true;
}
Also used : EntityDiggingFX(net.minecraft.client.particle.EntityDiggingFX) DoubleCoordinatesType(network.rs485.logisticspipes.world.DoubleCoordinatesType) IIcon(net.minecraft.util.IIcon) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) PlayerConfig(logisticspipes.config.PlayerConfig) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 3 with PlayerConfig

use of logisticspipes.config.PlayerConfig in project LogisticsPipes by RS485.

the class LogisticsEventListener method onPlayerLogin.

@SubscribeEvent
public void onPlayerLogin(PlayerLoggedInEvent event) {
    if (MainProxy.isServer(event.player.worldObj)) {
        SimpleServiceLocator.securityStationManager.sendClientAuthorizationList(event.player);
        SimpleServiceLocator.craftingPermissionManager.sendCraftingPermissionsToPlayer(event.player);
    }
    SimpleServiceLocator.serverBufferHandler.clear(event.player);
    PlayerConfig config = LogisticsEventListener.getPlayerConfig(PlayerIdentifier.get(event.player));
    MainProxy.sendPacketToPlayer(PacketHandler.getPacket(PlayerConfigToClientPacket.class).setConfig(config), event.player);
}
Also used : PlayerConfig(logisticspipes.config.PlayerConfig) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 4 with PlayerConfig

use of logisticspipes.config.PlayerConfig in project LogisticsPipes by RS485.

the class LogisticsEventListener method onPlayerLogout.

@SubscribeEvent
public void onPlayerLogout(PlayerLoggedOutEvent event) {
    SimpleServiceLocator.serverBufferHandler.clear(event.player);
    PlayerIdentifier ident = PlayerIdentifier.get(event.player);
    PlayerConfig config = LogisticsEventListener.playerConfigs.get(ident);
    if (config != null) {
        config.writeToFile();
    }
    LogisticsEventListener.playerConfigs.remove(ident);
}
Also used : PlayerIdentifier(logisticspipes.utils.PlayerIdentifier) PlayerConfig(logisticspipes.config.PlayerConfig) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 5 with PlayerConfig

use of logisticspipes.config.PlayerConfig in project LogisticsPipes by RS485.

the class PlayerConfigToServerPacket method readData.

@Override
public void readData(LPDataInput input) {
    config = new PlayerConfig(null);
    config.readData(input);
}
Also used : PlayerConfig(logisticspipes.config.PlayerConfig)

Aggregations

PlayerConfig (logisticspipes.config.PlayerConfig)5 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)2 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 PlayerIdentifier (logisticspipes.utils.PlayerIdentifier)1 EntityDiggingFX (net.minecraft.client.particle.EntityDiggingFX)1 IIcon (net.minecraft.util.IIcon)1 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)1 DoubleCoordinatesType (network.rs485.logisticspipes.world.DoubleCoordinatesType)1