public TemporaryStorage getTemporaryStorage( int x, int y, int z, int layer ) { short index = getIndex( x, y, z ); // Select correct layer Short2ObjectOpenHashMap<TemporaryStorage> storage = this.temporaryStorages[layer]; if ( storage == null ) { storage = new Short2ObjectOpenHashMap<>(); this.temporaryStorages[layer] = storage; } TemporaryStorage blockStorage = storage.get( index ); if ( blockStorage == null ) { blockStorage = new TemporaryStorage(); storage.put( index, blockStorage ); } return blockStorage; }
@Override public void clear() { Short2ObjectOpenHashMap.this.clear(); } /** {@inheritDoc} */
@Override public boolean contains(Object v) { return containsValue(v); } @Override
public void addTileEntityInternal( short index, TileEntity tileEntity ) { if ( this.tileEntities == null ) { this.tileEntities = new Short2ObjectOpenHashMap<>(); } this.tileEntities.put( index, tileEntity ); }
/** {@inheritDoc} */ @Override public V merge(final short k, final V v, final java.util.function.BiFunction<? super V, ? super V, ? extends V> remappingFunction) { java.util.Objects.requireNonNull(remappingFunction); final int pos = find(k); if (pos < 0 || value[pos] == null) { if (v == null) return defRetValue; insert(-pos - 1, k, v); return v; } final V newValue = remappingFunction.apply((value[pos]), (v)); if (newValue == null) { if (((k) == ((short) 0))) removeNullEntry(); else removeEntry(pos); return defRetValue; } return value[pos] = (newValue); } /*
return new Double2ObjectOpenHashMap(map); } else if (oCls.equals(Short.class)) { return new Short2ObjectOpenHashMap(map); } else if (oCls.equals(Byte.class)) { return new Byte2ObjectOpenHashMap(map);
/** * Get all tiles in this chunk for saving the data * * @return collection of all tiles in this chunks */ public Collection<TileEntity> getTileEntities() { List<TileEntity> tileEntities = new ArrayList<>(); for ( ChunkSlice chunkSlice : this.chunkSlices ) { if ( chunkSlice != null && chunkSlice.getTileEntities() != null ) { tileEntities.addAll( chunkSlice.getTileEntities().values() ); } } return tileEntities; }
@Override public void putAll(Map<? extends Short, ? extends V> m) { if (f <= .5) ensureCapacity(m.size()); // The resulting map will be sized for m.size() elements else tryCapacity(size() + m.size()); // The resulting map will be tentatively sized for size() + m.size() // elements super.putAll(m); }
/** * Creates a new hash map using the elements of two parallel arrays. * * @param k * the array of keys of the new hash map. * @param v * the array of corresponding values in the new hash map. * @param f * the load factor. * @throws IllegalArgumentException * if {@code k} and {@code v} have different lengths. */ public Short2ObjectOpenHashMap(final short[] k, final V[] v, final float f) { this(k.length, f); if (k.length != v.length) throw new IllegalArgumentException( "The key array and the value array have different lengths (" + k.length + " and " + v.length + ")"); for (int i = 0; i < k.length; i++) this.put(k[i], v[i]); } /**
/** {@inheritDoc} */ @Override public V computeIfPresent(final short k, final java.util.function.BiFunction<? super Short, ? super V, ? extends V> remappingFunction) { java.util.Objects.requireNonNull(remappingFunction); final int pos = find(k); if (pos < 0) return defRetValue; final V newValue = remappingFunction.apply(Short.valueOf(k), (value[pos])); if (newValue == null) { if (((k) == ((short) 0))) removeNullEntry(); else removeEntry(pos); return defRetValue; } return value[pos] = (newValue); } /** {@inheritDoc} */
<T extends io.gomint.world.block.Block> T getBlockInstance( int x, int y, int z, int layer ) { short index = getIndex( x, y, z ); Location blockLocation = this.getBlockLocation( x, y, z ); int runtimeID = this.getRuntimeID( layer, index ); if ( this.isAllAir || runtimeID == AIR_RUNTIME_ID ) { return this.getAirBlockInstance( blockLocation ); } BlockIdentifier identifier = BlockRuntimeIDs.toBlockIdentifier( runtimeID ); return (T) this.chunk.getWorld().getServer().getBlocks().get( identifier.getBlockId(), identifier.getData(), this.skyLight != null ? this.skyLight.get( index ) : 0, this.blockLight != null ? this.blockLight.get( index ) : 0, this.tileEntities != null ? this.tileEntities.get( index ) : null, blockLocation, layer ); }
/** {@inheritDoc} */ @Override public V replace(final short k, final V v) { final int pos = find(k); if (pos < 0) return defRetValue; final V oldValue = value[pos]; value[pos] = v; return oldValue; } /** {@inheritDoc} */
@Override public void readData(DataIn data) { startX = data.readVarInt(); startZ = data.readVarInt(); claimedChunks = data.readVarInt(); loadedChunks = data.readVarInt(); maxClaimedChunks = data.readVarInt(); maxLoadedChunks = data.readVarInt(); teams = new Short2ObjectOpenHashMap<>(); for (ClientClaimedChunks.Team team : data.readCollection(ClientClaimedChunks.Team.DESERIALIZER)) { teams.put(team.uid, team); } }
return new Double2ObjectOpenHashMap(map); } else if (oCls.equals(Short.class)) { return new Short2ObjectOpenHashMap(map); } else if (oCls.equals(Byte.class)) { return new Byte2ObjectOpenHashMap(map);
/** {@inheritDoc} */ @Override public V compute(final short k, final java.util.function.BiFunction<? super Short, ? super V, ? extends V> remappingFunction) { java.util.Objects.requireNonNull(remappingFunction); final int pos = find(k); final V newValue = remappingFunction.apply(Short.valueOf(k), pos >= 0 ? (value[pos]) : null); if (newValue == null) { if (pos >= 0) { if (((k) == ((short) 0))) removeNullEntry(); else removeEntry(pos); } return defRetValue; } V newVal = (newValue); if (pos < 0) { insert(-pos - 1, k, newVal); return newVal; } return value[pos] = newVal; } /** {@inheritDoc} */
@Override public void writeData(DataOut data) { data.writeVarInt(startX); data.writeVarInt(startZ); data.writeVarInt(claimedChunks); data.writeVarInt(loadedChunks); data.writeVarInt(maxClaimedChunks); data.writeVarInt(maxLoadedChunks); data.writeCollection(teams.values(), ClientClaimedChunks.Team.SERIALIZER); }
/** {@inheritDoc} */ @Override public boolean replace(final short k, final V oldValue, final V v) { final int pos = find(k); if (pos < 0 || !java.util.Objects.equals(oldValue, value[pos])) return false; value[pos] = v; return true; } /** {@inheritDoc} */
teams = new Short2ObjectOpenHashMap<>(); ClientClaimedChunks.Team team = teams.get(chunkTeam.getUID()); team.nameComponent = chunkTeam.getTitle(); team.isAlly = chunkTeam.isAlly(p); teams.put(chunkTeam.getUID(), team);