Fix curios version string, fix armors not using mana for durability, fix fluid display in pure daisy JEI

This commit is contained in:
Vincent Lee committed 2019-09-14 12:36:04 -05:00
1 parent 3bc86fbc54
commit 4cd4b220d3
5 files changed
+36 -16

No files matched your search

@@ -18,6 +18,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.BlockState;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.block.FlowingFluidBlock;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.Items;
import net.minecraft.item.ItemStack;
@@ -89,23 +90,21 @@ public class PureDaisyRecipeCategory implements IRecipeCategory<RecipePureDaisy>
BlockState state = recipe.getInput() instanceof BlockState ? (BlockState) recipe.getInput() : ((Block) recipe.getInput()).getDefaultState();
Block b = state.getBlock();
// todo 1.13 fluids
//if(FluidRegistry.lookupFluidForBlock(b) != null) {
// iIngredients.setInput(VanillaTypes.FLUID, new FluidStack(FluidRegistry.lookupFluidForBlock(b), 1000));
//} else {
if (b instanceof FlowingFluidBlock) {
iIngredients.setInput(VanillaTypes.FLUID, new FluidStack(((FlowingFluidBlock) b).getFluid(), 1000));
} else {
if(b.asItem() != Items.AIR)
iIngredients.setInput(VanillaTypes.ITEM, new ItemStack(b));
//}
}
}
Block outBlock = recipe.getOutputState().getBlock();
// todo 1.13 fluids
//if(FluidRegistry.lookupFluidForBlock(outBlock) != null) {
// iIngredients.setOutput(VanillaTypes.FLUID, new FluidStack(FluidRegistry.lookupFluidForBlock(outBlock), 1000));
//} else {
if(outBlock instanceof FlowingFluidBlock) {
iIngredients.setOutput(VanillaTypes.FLUID, new FluidStack(((FlowingFluidBlock) outBlock).getFluid(), 1000));
} else {
if(outBlock.asItem() != Items.AIR)
iIngredients.setOutput(VanillaTypes.ITEM, new ItemStack(outBlock));
//}
}
}
@Override
@@ -56,6 +56,7 @@ import javax.annotation.Nonnull;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
public class ItemManasteelArmor extends ArmorItem implements IManaUsingItem, IPhantomInkable {
@@ -87,9 +88,9 @@ public class ItemManasteelArmor extends ArmorItem implements IManaUsingItem, IPh
stack.setDamage(stack.getDamage() - 1);
}
// todo 1.13
public void damageArmor(LivingEntity entity, @Nonnull ItemStack stack, DamageSource source, int damage, int slot) {
ToolCommons.damageItem(stack, damage, entity, MANA_PER_DAMAGE);
@Override
public <T extends LivingEntity> int damageItem(ItemStack stack, int amount, T entity, Consumer<T> onBroken) {
return ToolCommons.damageItemIfPossible(stack, amount, entity, MANA_PER_DAMAGE);
}
@Nonnull
@@ -26,6 +26,7 @@ import vazkii.botania.common.lib.LibItemNames;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.function.Consumer;
public class ItemManaweaveHelm extends ItemManaweaveArmor implements IManaDiscountArmor, IManaProficiencyArmor {
@@ -52,8 +53,7 @@ public class ItemManaweaveHelm extends ItemManaweaveArmor implements IManaDiscou
}
@Override
public void damageArmor(LivingEntity entity, @Nonnull ItemStack stack, DamageSource source, int damage, int slot) {
ToolCommons.damageItem(stack, damage, entity, MANA_PER_DAMAGE);
public <T extends LivingEntity> int damageItem(ItemStack stack, int amount, T entity, Consumer<T> onBroken) {
return ToolCommons.damageItemIfPossible(stack, amount, entity, MANA_PER_DAMAGE);
}
}
@@ -50,6 +50,25 @@ public final class ToolCommons {
public static final List<Material> materialsShovel = Arrays.asList(Material.ORGANIC, Material.EARTH, Material.SAND, Material.SNOW, Material.SNOW_BLOCK, Material.CLAY);
public static final List<Material> materialsAxe = Arrays.asList(Material.CORAL, Material.LEAVES, Material.PLANTS, Material.WOOD, Material.GOURD);
/**
* Consumes as much mana as possible, returning the amount of damage that couldn't be paid with mana
*/
public static int damageItemIfPossible(ItemStack stack, int amount, LivingEntity entity, int manaPerDamage) {
if(!(entity instanceof PlayerEntity))
return amount;
PlayerEntity player = (PlayerEntity) entity;
while (amount > 0) {
if (ManaItemHandler.requestManaExactForTool(stack, player, manaPerDamage, true)) {
amount--;
} else {
break;
}
}
return amount;
}
public static void damageItem(ItemStack stack, int dmg, LivingEntity entity, int manaPerDamage) {
int manaToRequest = dmg * manaPerDamage;
boolean manaRequested = entity instanceof PlayerEntity && ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) entity, manaToRequest, true);