java


get item slot from ItemStack


I am recently facing a problem that I can't get throught: how do I get the slot of an item?
let's say my code looks like that
ItemStack[] items = inv.getContents();
for (ItemStack item : items) {
if (item != null) {
if (position < 27 && position > -1) {
SOMETHING HERE LIKE ---> item.getRawSlot()
}
} else {
}
}
But the method getRawSlot() is not valid for item class, what can I do?
You can't know the index of your current array item when using a for-each loop. You'll have to use a regular for loop with an explicit index:
for (int = 0 ; i < items.length; ++i) {
Item item = items[i];
if (i < 27 && i > -1) {
// do something here like item.getRawSlot();
}
// another example of something you could now do that you
// couldn't do using for-each
items[i] = new Item(...);
}

Related Links

ScheduledTimerTask prevent overlap
ERROR ON QUERYING ORACLE DB
Unable to compile class for JSP after Jquery UI.js file included
Placing specific numbers in a specific JTextField that is in a grid of JTextFields
How to print string value out of while loop? [closed]
Spring 3 MVC + Hibernate 3.5.x : Autowiring and Dependency Injection of SessionFactory
Not able to stop vibration
org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/jsp/index.jsp at line 380 [duplicate]
Multiple Producer Multiple Resources One Cosumer
JPA TypedQuery: Parameter value element did not match expected type
jfreechart put abitrary text inside bars in a stacked bargraph
How to prevent Hibernate load the whole collection?
Can't return a Object[] casted as String[]
Why doesn't my Eclipse IDE allow write override annotation when I implement interface?
Display date in jsp
LibGDX persist actors while switching screens?

Categories

HOME
osgi
angular-material
spagobi
jsrender
contact
floating-action-button
windows-azure-storage
usergrid
visual-studio-2005
messages
ibm-odm
highlight.js
facebook-page
apache-metamodel
flux
text-rendering
beyondcompare
one-hot-encoding
scriptcs
chromium-embedded
numerical-methods
semantic-analysis
selectedindexchanged
uninstall
elasticsearch-net
buck
dbclient
subdomains
junit5
semantic-versioning
karaf
catch-all
avcapturesession
openoffice.org
mapdb
bower-install
dosbox
git-merge
scaffold
hockeyapp
event-driven
preconditions
turbogears
modelmapper
avconv
logparser
hendrix
diagnostics
np-complete
nsarray
spring-mongodb
chord-diagram
specrun
root-framework
ado.net-entity-data-model
transmitfile
etsy
skype4py
captivenetwork
apachebench
content-length
quicklisp
emailrelay
tableau-online
interrupted-exception
pretty-print
nstableviewcell
device-manager
typeof
p4java
cloud-connect
viadeo
terminal-services
flexmojos
c18
inbox
excel-2003
lcs
flashvars
quickdialog
pysimplesoap
code-cleanup
hirefire
cinema-4d
servicehost
telerik-scheduler
firefox-5
ti-dsp
adrotator
sustainable-pace
project-hosting
genealogy
data-acquisition
multiple-languages
wsdl.exe

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile