/** * Sets a property of the window * * @param id of the property * @param value value of property */ public void setProperty(int id, int value) { properties.put(id, value); switch (Spout.getPlatform()) { case PROXY: case SERVER: callProtocolEvent(new WindowPropertyEvent(this, id, value)); break; case CLIENT: // TODO: Window properties break; default: throw new IllegalStateException("Unknown platform: " + Spout.getPlatform()); } }
@Override public void ban(boolean kick, Object... reason) { if (Spout.getPlatform() != Platform.SERVER) { throw new IllegalStateException("Banning is only available in server mode."); } ((Server) Spout.getEngine()).getAccessManager().ban(BanType.PLAYER, name, kick, reason); }
@Override public void onAttached() { if (Spout.getPlatform() != Platform.CLIENT) { throw new UnsupportedOperationException( "SpoutFallbackMovementComponent can only be attached client side!"); } }
public WeatherSimulator(Sky sky) { if (Spout.getPlatform() != Platform.SERVER) { throw new UnsupportedOperationException("Weather simulation can only happen on the server"); } this.sky = sky; this.lightning = new LightningSimulator(this); this.snowfall = new SnowSimulator(this); }
public FullScreen() { if (Spout.getPlatform() == Platform.CLIENT) { try { ((Client) Spout.getEngine()) .getScreenStack() .subscribe(ScreenStack.SIGNAL_RESIZED, this, "onScreenResized"); } catch (SecurityException e) { } catch (NoSuchMethodException e) { } } }
static { if (Spout.getPlatform() == Platform.CLIENT) { DEFAULT_FONT = (Font) Spout.getFileSystem().getResource("font://Spout/fonts/ubuntu/Ubuntu-M.ttf"); GUI_COLOR = (RenderMaterial) FILE_SYSTEM.getResource("material://Spout/materials/GUIColorMaterial.smt"); } else { DEFAULT_FONT = null; GUI_COLOR = null; } }
public AbstractWindow(Player owner, WindowType type, String title, int offset) { this.owner = owner; this.type = type; this.title = title; this.offset = offset; switch (Spout.getPlatform()) { case PROXY: case SERVER: // Initialize the window id on the server id = windowId++; break; } }
/** Reloads the window's items */ @ServerOnly public final void reload() { if (Spout.getPlatform() == Platform.CLIENT) { throw new IllegalStateException("Cannot reload window in client mode."); } ItemStack[] items = new ItemStack[getSize()]; for (int i = 0; i < items.length; i++) { Slot entry = getSlot(i); if (entry != null) { items[i] = entry.get(); } } callProtocolEvent(new WindowItemsEvent(this, items)); }
@SuppressWarnings("incomplete-switch") @Override public void onTick(float dt) { switch (Spout.getPlatform()) { case PROXY: case SERVER: World world = head.getPosition().getWorld(); if (!(world.getBlock(head.getPosition()).getMaterial() instanceof Water)) { setAir(MAX_AIR); return; } if (getOwner() instanceof Player && !getOwner().get(Human.class).getGameMode().equals(GameMode.SURVIVAL)) { return; } setAir(getAir() - dt); if (getAir() < 0) { // out of air; damage one heart every second if (damageTimer-- < 0) { health.damage( 2, new BlockDamageCause(world.getBlock(head.getPosition()), DamageType.DROWN)); damageTimer = 20; } } break; case CLIENT: if (!(getOwner() instanceof Player)) { return; } // Animate air meter final float maxSecsBubbles = VanillaData.AIR_SECS.getDefaultValue(); final float secsBubbles = getData().get(VanillaData.AIR_SECS); if (secsBubbles == maxSecsBubbles) { hideBubbles(); } else { HUDComponent hud = getOwner().get(HUDComponent.class); if (hud != null) { hud.getAirMeter().update(); } } break; } }
/** * Sets the item on the cursor. * * @param cursorItem */ public void setCursorItem(ItemStack cursorItem) { this.cursorItem = cursorItem; if (Spout.getPlatform() == Platform.CLIENT) { // TODO: Attach item to cursor } }