public boolean execute( short key, V value) { put( key, value ); return true; } };
/** {@inheritDoc} */ public void putAll( Map<? extends Short, ? extends V> map ) { Set<? extends Map.Entry<? extends Short,? extends V>> set = map.entrySet(); for ( Map.Entry<? extends Short,? extends V> entry : set ) { put( entry.getKey(), entry.getValue() ); } }
@SuppressWarnings({"unchecked"}) public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { // VERSION in.readByte(); // SUPER super.readExternal( in ); // NO_ENTRY_KEY no_entry_key = in.readShort(); // NUMBER OF ENTRIES int size = in.readInt(); setUp( size ); // ENTRIES while (size-- > 0) { short key = in.readShort(); V val = (V) in.readObject(); put(key, val); } }
@Test public void testCompleteUpdateSendsBlockAddedEvents() throws Exception { final Chunk chunk = mockChunkAt(0, 0, 0); final short blockId = 42; final EntityRef blockEntity = mock(EntityRef.class); registerBlockWithIdAndEntity(blockId, blockEntity, blockManager); final TShortObjectHashMap<TIntList> blockPositionMappings = new TShortObjectHashMap<>(); blockPositionMappings.put(blockId, withPositions(new Vector3i(1, 2, 3))); final ReadyChunkInfo readyChunkInfo = ReadyChunkInfo.createForRestoredChunk(chunk, blockPositionMappings, mock(ChunkStore.class), Collections.emptyList()); when(chunkFinalizer.completeFinalization()).thenReturn(readyChunkInfo); chunkProvider.completeUpdate(); final ArgumentCaptor<Event> eventArgumentCaptor = ArgumentCaptor.forClass(Event.class); verify(blockEntity, atLeastOnce()).send(eventArgumentCaptor.capture()); final Event event = eventArgumentCaptor.getAllValues().get(0); assertThat(event, instanceOf(OnAddedBlocks.class)); assertThat(((OnAddedBlocks) event).getBlockPositions(), hasItem(new Vector3i(1, 2, 3))); }
@Test public void testCompleteUpdateSendsBlockActivatedEvents() throws Exception { final Chunk chunk = mockChunkAt(0, 0, 0); final TShortObjectHashMap<TIntList> blockPositionMappings = new TShortObjectHashMap<>(); final short blockId = 42; final EntityRef blockEntity = mock(EntityRef.class); registerBlockWithIdAndEntity(blockId, blockEntity, blockManager); blockPositionMappings.put(blockId, withPositions(new Vector3i(1, 2, 3))); final ReadyChunkInfo readyChunkInfo = ReadyChunkInfo.createForRestoredChunk(chunk, blockPositionMappings, mock(ChunkStore.class), Collections.emptyList()); when(chunkFinalizer.completeFinalization()).thenReturn(readyChunkInfo); chunkProvider.completeUpdate(); final ArgumentCaptor<Event> eventArgumentCaptor = ArgumentCaptor.forClass(Event.class); verify(blockEntity, atLeastOnce()).send(eventArgumentCaptor.capture()); final Event event = eventArgumentCaptor.getAllValues().get(1); assertThat(event, instanceOf(OnActivatedBlocks.class)); assertThat(((OnActivatedBlocks) event).getBlockPositions(), hasItem(new Vector3i(1, 2, 3))); }
public boolean execute( short key, V value) { put( key, value ); return true; } };
public boolean execute( short key, V value) { put( key, value ); return true; } };
@Override public boolean execute( short key, V value) { put( key, value ); return true; } };
public boolean execute( short key, V value) { put( key, value ); return true; } };
/** {@inheritDoc} */ public void putAll( Map<? extends Short, ? extends V> map ) { Set<? extends Map.Entry<? extends Short,? extends V>> set = map.entrySet(); for ( Map.Entry<? extends Short,? extends V> entry : set ) { put( entry.getKey(), entry.getValue() ); } }
/** {@inheritDoc} */ public void putAll( Map<? extends Short, ? extends V> map ) { Set<? extends Map.Entry<? extends Short,? extends V>> set = map.entrySet(); for ( Map.Entry<? extends Short,? extends V> entry : set ) { put( entry.getKey(), entry.getValue() ); } }
/** {@inheritDoc} */ @Override public void putAll( Map<? extends Short, ? extends V> map ) { Set<? extends Map.Entry<? extends Short,? extends V>> set = map.entrySet(); for ( Map.Entry<? extends Short,? extends V> entry : set ) { put( entry.getKey(), entry.getValue() ); } }
/** {@inheritDoc} */ public void putAll( Map<? extends Short, ? extends V> map ) { Set<? extends Map.Entry<? extends Short,? extends V>> set = map.entrySet(); for ( Map.Entry<? extends Short,? extends V> entry : set ) { put( entry.getKey(), entry.getValue() ); } }
@SuppressWarnings({"unchecked"}) public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { // VERSION in.readByte(); // SUPER super.readExternal( in ); // NO_ENTRY_KEY no_entry_key = in.readShort(); // NUMBER OF ENTRIES int size = in.readInt(); setUp( size ); // ENTRIES while (size-- > 0) { short key = in.readShort(); V val = (V) in.readObject(); put(key, val); } }
@SuppressWarnings({"unchecked"}) public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { // VERSION in.readByte(); // SUPER super.readExternal( in ); // NO_ENTRY_KEY no_entry_key = in.readShort(); // NUMBER OF ENTRIES int size = in.readInt(); setUp( size ); // ENTRIES while (size-- > 0) { short key = in.readShort(); V val = (V) in.readObject(); put(key, val); } }
@SuppressWarnings({"unchecked"}) public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { // VERSION in.readByte(); // SUPER super.readExternal( in ); // NO_ENTRY_KEY no_entry_key = in.readShort(); // NUMBER OF ENTRIES int size = in.readInt(); setUp( size ); // ENTRIES while (size-- > 0) { short key = in.readShort(); V val = (V) in.readObject(); put(key, val); } }
@Override @SuppressWarnings({"unchecked"}) public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { // VERSION in.readByte(); // SUPER super.readExternal( in ); // NO_ENTRY_KEY no_entry_key = in.readShort(); // NUMBER OF ENTRIES int size = in.readInt(); setUp( size ); // ENTRIES while (size-- > 0) { short key = in.readShort(); V val = (V) in.readObject(); put(key, val); } }
@Override @SideOnly(Side.CLIENT) public void registerModels() { super.registerModels(); TShortObjectHashMap<ModelResourceLocation> alreadyRegistered = new TShortObjectHashMap<>(); for (short metaItem : generatedItems) { OrePrefix prefix = this.orePrefixes[metaItem / 1000]; MaterialIconSet materialIconSet = Material.MATERIAL_REGISTRY.getObjectById(metaItem % 1000).materialIconSet; short registrationKey = (short) (metaItem / 1000 * 1000 + materialIconSet.ordinal()); if (!alreadyRegistered.containsKey(registrationKey)) { ResourceLocation resourceLocation = prefix.materialIconType.getItemModelPath(materialIconSet); ModelBakery.registerItemVariants(this, resourceLocation); alreadyRegistered.put(registrationKey, new ModelResourceLocation(resourceLocation, "inventory")); } ModelResourceLocation resourceLocation = alreadyRegistered.get(registrationKey); metaItemsModels.put(metaItem, resourceLocation); } }
resourceLocations[i] = new ModelResourceLocation(resourceLocation, "inventory"); specialItemsModels.put((short) (metaItemOffset + itemMetaKey), resourceLocations); continue;