use of crazypants.enderio.base.recipe.enchanter.EnchanterRecipe in project EnderIO by SleepyTrousers.
the class ContainerEnchanter method addSlots.
@Override
protected void addSlots(@Nonnull InventoryPlayer playerInv) {
final TileEnchanter te = getInv();
addSlotToContainer(new Slot(te, 0, 16, 35) {
@Override
public int getSlotStackLimit() {
return 1;
}
@Override
public boolean isItemValid(@Nonnull ItemStack itemStack) {
return te.isItemValidForSlot(0, itemStack);
}
@Override
public void onSlotChanged() {
updateOutput();
}
});
addSlotToContainer(new Slot(te, 1, 65, 35) {
@Override
public boolean isItemValid(@Nonnull ItemStack itemStack) {
return te.isItemValidForSlot(1, itemStack);
}
@Override
public void onSlotChanged() {
updateOutput();
}
});
addSlotToContainer(new Slot(te, 2, 85, 35) {
@Override
public boolean isItemValid(@Nonnull ItemStack itemStack) {
return te.isItemValidForSlot(2, itemStack);
}
@Override
public void onSlotChanged() {
updateOutput();
}
});
addSlotToContainer(new Slot(te, 3, 144, 35) {
@Override
public int getSlotStackLimit() {
return 1;
}
@Override
public boolean isItemValid(@Nullable ItemStack itemStack) {
return false;
}
@Override
@Nonnull
public ItemStack onTake(@Nonnull EntityPlayer player, @Nonnull ItemStack stack) {
EnchanterRecipe currentEnchantmentRecipe = getInv().getCurrentEnchantmentRecipe();
if (currentEnchantmentRecipe != null) {
final int xpCost = currentEnchantmentRecipe.getXPCost(getInv().getInvAsMachineRecipeInput());
List<MachineRecipeInput> quantitiesConsumed = currentEnchantmentRecipe.getQuantitiesConsumed(getInv().getInvAsMachineRecipeInput());
for (MachineRecipeInput machineRecipeInput : quantitiesConsumed) {
te.decrStackSize(machineRecipeInput.slotNumber, machineRecipeInput.item.getCount());
}
if (!player.capabilities.isCreativeMode) {
player.addExperienceLevel(-xpCost);
}
} else {
Log.error("Enchanting yielded result without resources");
}
if (!te.getWorld().isRemote) {
te.getWorld().playEvent(1030, te.getPos(), 0);
te.getWorld().playEvent(2005, te.getPos().up(), 0);
}
return stack;
}
@Override
public boolean canTakeStack(@Nonnull EntityPlayer player) {
return playerHasEnoughLevels(player);
}
});
}
use of crazypants.enderio.base.recipe.enchanter.EnchanterRecipe in project EnderIO by SleepyTrousers.
the class Enchanting method register.
@Override
public void register(@Nonnull String recipeName) {
if (isValid() && isActive()) {
final Things thing = input.getThing();
final net.minecraft.enchantment.Enchantment enchantment2 = enchantment.getEnchantment();
if (!thing.isEmpty() && enchantment2 != null) {
EnchanterRecipe recipe = new EnchanterRecipe(thing, input.getAmount(), enchantment2, enchantment.getCostMultiplier());
MachineRecipeRegistry.instance.registerRecipe(MachineRecipeRegistry.ENCHANTER, recipe);
}
}
}
use of crazypants.enderio.base.recipe.enchanter.EnchanterRecipe in project EnderIO by SleepyTrousers.
the class ContainerEnchanter method updateOutput.
private void updateOutput() {
EnchanterRecipe currentEnchantmentRecipe = getInv().getCurrentEnchantmentRecipe();
if (currentEnchantmentRecipe != null) {
ResultStack[] completedResult = currentEnchantmentRecipe.getCompletedResult(0, 1F, getInv().getInvAsMachineRecipeInput());
getInv().setOutput(completedResult[0].item);
} else {
getInv().setOutput(Prep.getEmpty());
}
}
Aggregations