java - Replace color of a dye in player's inventory with another -
i replace dye in player's inventory new dye, of different color, example cyan gray.
my plugin changes 1 dye perfectly, when move hotbar, can't drop , when click on in inventory, disappears. in case suppose item not exist.
how can change color of item?
code:
dye dye = new dye(); dye.setcolor(dyecolor.red); itemstack dye4 = dye.toitemstack(); dye4.setamount(1); dye.setcolor(dyecolor.orange); itemstack dye3 = dye.toitemstack(); dye4.setamount(1); dye.setcolor(dyecolor.purple); itemstack dye2 = dye.toitemstack(); dye4.setamount(1); dye.setcolor(dyecolor.cyan); itemstack dye1 = dye.toitemstack(); dye4.setamount(1); dye.setcolor(dyecolor.gray); itemstack dye0 = dye.toitemstack(); arraylist<itemstack> dyes = new arraylist<itemstack>(arrays.aslist( dye0, dye1, dye2, dye3, dye4 )); p.getopeninventory().gettopinventory().setitem(1, dyes.get(0));
note: i've shortened code example.
screenshots:
before
after
i moved hotbar - second before disappeared (because didn't click on :d)
download
i made example plugin error:
how can fix error?
i have stupid bug in code, didn't set amount of gray dye 1.
final code
dye dye = new dye(); dye.setcolor(dyecolor.red); itemstack dye4 = dye.toitemstack(); dye4.setamount(1); dye.setcolor(dyecolor.orange); itemstack dye3 = dye.toitemstack(); dye3.setamount(1); dye.setcolor(dyecolor.purple); itemstack dye2 = dye.toitemstack(); dye2.setamount(1); dye.setcolor(dyecolor.cyan); itemstack dye1 = dye.toitemstack(); dye1.setamount(1); dye.setcolor(dyecolor.gray); itemstack dye0 = dye.toitemstack(); dye0.setamount(1); immutablelist<itemstack> dyes = immutablelist.of(dye0, dye1, dye2, dye3, dye4); p.getopeninventory().gettopinventory().setitem(1, dyes.get(0));
Comments
Post a Comment