use of WayofTime.bloodmagic.recipe.LivingArmourDowngradeRecipe in project BloodMagic by WayofTime.
the class ArmourDowngradeRecipeMaker method getRecipes.
@Nonnull
public static List<ArmourDowngradeRecipeJEI> getRecipes() {
List<LivingArmourDowngradeRecipe> recipeList = LivingArmourDowngradeRecipeRegistry.getRecipeList();
ArrayList<ArmourDowngradeRecipeJEI> recipes = new ArrayList<>();
for (LivingArmourDowngradeRecipe recipe : recipeList) recipes.add(new ArmourDowngradeRecipeJEI(recipe));
return recipes;
}
use of WayofTime.bloodmagic.recipe.LivingArmourDowngradeRecipe in project BloodMagic by WayofTime.
the class RitualLivingArmourDowngrade method performRitual.
@Override
public void performRitual(IMasterRitualStone masterRitualStone) {
World world = masterRitualStone.getWorldObj();
int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
if (currentEssence < getRefreshCost()) {
masterRitualStone.getOwnerNetwork().causeNausea();
return;
}
BlockPos masterPos = masterRitualStone.getBlockPos();
AreaDescriptor downgradeRange = getBlockRange(DOWNGRADE_RANGE);
boolean isActivatorPresent = false;
for (EntityPlayer player : world.getEntitiesWithinAABB(EntityPlayer.class, downgradeRange.getAABB(masterRitualStone.getBlockPos()))) {
if (player.getGameProfile().getId().equals(masterRitualStone.getOwner())) {
ItemStack keyStack = getStackFromItemFrame(world, masterPos, masterRitualStone.getDirection());
if (keyStack.isEmpty()) {
return;
}
List<ITextComponent> textList = LivingArmourDowngradeRecipeRegistry.getDialogForProcessTick(keyStack, internalTimer);
if (textList != null) {
ChatUtil.sendChat(player, textList.toArray(new ITextComponent[textList.size()]));
}
internalTimer++;
if (player.isSneaking()) {
double distance2 = masterPos.offset(EnumFacing.UP).distanceSqToCenter(player.posX, player.posY, player.posZ);
if (distance2 > 1) {
return;
}
BlockPos chestPos = masterPos.offset(masterRitualStone.getDirection(), 2).offset(EnumFacing.UP);
TileEntity tile = world.getTileEntity(chestPos);
if (tile == null) {
return;
}
IItemHandler inv = Utils.getInventory(tile, null);
if (inv != null) {
List<ItemStack> recipeList = new ArrayList<>();
for (int i = 0; i < inv.getSlots(); i++) {
ItemStack invStack = inv.getStackInSlot(i);
if (!invStack.isEmpty()) {
recipeList.add(invStack);
}
}
LivingArmourDowngradeRecipe recipe = LivingArmourDowngradeRecipeRegistry.getMatchingRecipe(keyStack, recipeList, world, masterPos);
if (recipe != null) {
LivingArmourUpgrade upgrade = recipe.getRecipeOutput();
if (LivingArmour.hasFullSet(player)) {
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null) {
if (armour.canApplyUpgrade(player, upgrade)) {
if (armour.upgradeArmour(player, upgrade)) {
ItemLivingArmour.setLivingArmour(chestStack, armour);
recipe.consumeInventory(inv);
EntityLightningBolt lightning = new EntityLightningBolt(world, chestPos.getX(), chestPos.getY(), chestPos.getZ(), true);
world.spawnEntity(lightning);
masterRitualStone.setActive(false);
}
} else {
// TODO: You are not able to receive my blessing...
// TODO: Need to add a timer that will stop it from working.
}
}
}
}
}
}
return;
}
}
if (!isActivatorPresent) {
internalTimer = 0;
}
}
Aggregations