use of pl.asie.charset.lib.item.IDyeableItem in project Charset by CharsetMC.
the class DyeableItemWashHandler method onBlockInteract.
@SubscribeEvent
public void onBlockInteract(PlayerInteractEvent.RightClickBlock event) {
if (!event.getWorld().isRemote && !event.getEntityPlayer().isSneaking()) {
ItemStack stack = event.getEntityPlayer().getHeldItem(event.getHand());
if (!stack.isEmpty() && stack.getItem() instanceof IDyeableItem) {
IBlockState state = event.getWorld().getBlockState(event.getPos());
if (state.getBlock() instanceof BlockCauldron && state.getPropertyKeys().contains(BlockCauldron.LEVEL)) {
event.setCanceled(true);
int level = state.getValue(BlockCauldron.LEVEL);
if (level > 0 && ((IDyeableItem) stack.getItem()).hasColor(stack)) {
if (((IDyeableItem) stack.getItem()).removeColor(stack)) {
event.getWorld().setBlockState(event.getPos(), state.withProperty(BlockCauldron.LEVEL, level - 1));
event.getEntityPlayer().addStat(StatList.ARMOR_CLEANED);
}
}
}
}
}
}
use of pl.asie.charset.lib.item.IDyeableItem in project Charset by CharsetMC.
the class JEIRecipeDyeableItem method getIngredients.
@Override
public void getIngredients(IIngredients ingredients) {
ingredients.setInputLists(ItemStack.class, JEIPluginCharset.STACKS.expandRecipeItemStackInputs(Lists.newArrayList(recipe.input, recipe.DYE)));
ArrayList<ItemStack> stacks = new ArrayList<>();
for (ItemStack stack : recipe.input.getMatchingStacks()) {
IDyeableItem item = (IDyeableItem) stack.getItem();
for (EnumDyeColor color : EnumDyeColor.values()) {
ItemStack stackColored = stack.copy();
item.setColor(stackColored, ColorUtils.toIntColor(color));
stacks.add(stackColored);
}
}
ingredients.setOutputLists(ItemStack.class, Collections.singletonList(stacks));
}
Aggregations