mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 19:29:31 +00:00
Fixes in the API
This commit is contained in:
1 parent
42f09fad22
commit
35e2a9039c
31 files changed
+120
-250
No files matched your search
@@ -258,7 +258,7 @@ public final class CorporeaHelper {
|
||||
}
|
||||
|
||||
|
||||
String name = stripControlCodes(stack.getDisplayName().toLowerCase().trim());
|
||||
String name = stripControlCodes(stack.getDisplayName().getString().toLowerCase().trim());
|
||||
return equalOrContain(name, s, contains) || equalOrContain(name + "s", s, contains) || equalOrContain(name + "es", s, contains) || name.endsWith("y") && equalOrContain(name.substring(0, name.length() - 1) + "ies", s, contains);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
*/
|
||||
package vazkii.botania.api.corporea;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
/**
|
||||
* Fired when a corporea request is initiated. Can be cancelled.
|
||||
|
||||
@@ -51,8 +51,8 @@ public interface IBaubleRender {
|
||||
* Use for renders under {@link RenderType#BODY}.
|
||||
*/
|
||||
public static void applySneakingRotation() {
|
||||
GlStateManager.translate(0F, 0.2F, 0F);
|
||||
GlStateManager.rotate(90F / (float) Math.PI, 1.0F, 0.0F, 0.0F);
|
||||
GlStateManager.translatef(0F, 0.2F, 0F);
|
||||
GlStateManager.rotatef(90F / (float) Math.PI, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,9 +60,9 @@ public interface IBaubleRender {
|
||||
* Use for renders under {@link RenderType#HEAD}.
|
||||
*/
|
||||
public static void translateToHeadLevel(EntityPlayer player) {
|
||||
GlStateManager.translate(0, -player.getDefaultEyeHeight(), 0);
|
||||
GlStateManager.translatef(0, -player.getDefaultEyeHeight(), 0);
|
||||
if (player.isSneaking())
|
||||
GlStateManager.translate(0.25F * MathHelper.sin(player.rotationPitch * (float) Math.PI / 180), 0.25F * MathHelper.cos(player.rotationPitch * (float) Math.PI / 180), 0F);
|
||||
GlStateManager.translatef(0.25F * MathHelper.sin(player.rotationPitch * (float) Math.PI / 180), 0.25F * MathHelper.cos(player.rotationPitch * (float) Math.PI / 180), 0F);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,9 +70,9 @@ public interface IBaubleRender {
|
||||
* Use for renders under {@link RenderType#HEAD}, and usually after calling {@link Helper#translateToHeadLevel(EntityPlayer)}.
|
||||
*/
|
||||
public static void translateToFace() {
|
||||
GlStateManager.rotate(90F, 0F, 1F, 0F);
|
||||
GlStateManager.rotate(180F, 1F, 0F, 0F);
|
||||
GlStateManager.translate(0f, -4.35f, -1.27f);
|
||||
GlStateManager.rotatef(90F, 0F, 1F, 0F);
|
||||
GlStateManager.rotatef(180F, 1F, 0F, 0F);
|
||||
GlStateManager.translatef(0f, -4.35f, -1.27f);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,8 +80,8 @@ public interface IBaubleRender {
|
||||
* Use for any render.
|
||||
*/
|
||||
public static void defaultTransforms() {
|
||||
GlStateManager.translate(0.0, 3.0, 1.0);
|
||||
GlStateManager.scale(0.55, 0.55, 0.55);
|
||||
GlStateManager.translated(0.0, 3.0, 1.0);
|
||||
GlStateManager.scaled(0.55, 0.55, 0.55);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,8 +89,8 @@ public interface IBaubleRender {
|
||||
* Use for renders under {@link RenderType#BODY}, and usually after calling {@link Helper#rotateIfSneaking(EntityPlayer)}.
|
||||
*/
|
||||
public static void translateToChest() {
|
||||
GlStateManager.rotate(180F, 1F, 0F, 0F);
|
||||
GlStateManager.translate(0F, -3.2F, -0.85F);
|
||||
GlStateManager.rotatef(180F, 1F, 0F, 0F);
|
||||
GlStateManager.translatef(0F, -3.2F, -0.85F);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*/
|
||||
package vazkii.botania.api.lexicon;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
import java.util.Queue;
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
package vazkii.botania.api.lexicon;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
@@ -123,7 +122,8 @@ public class LexiconEntry implements Comparable<LexiconEntry> {
|
||||
}
|
||||
|
||||
public final String getNameForSorting() {
|
||||
return (priority ? 0 : 1) + I18n.translateToLocal(getUnlocalizedName());
|
||||
// todo used to be localized
|
||||
return (priority ? 0 : 1) + getUnlocalizedName();
|
||||
}
|
||||
|
||||
public List<ItemStack> getDisplayedRecipes() {
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
package vazkii.botania.api.lexicon;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import vazkii.botania.api.mana.IManaItem;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -48,28 +46,20 @@ public final class LexiconRecipeMappings {
|
||||
}
|
||||
|
||||
public static EntryData getDataForStack(ItemStack stack) {
|
||||
String wildKey = stackToString(stack, true);
|
||||
String wildKey = stackToString(stack);
|
||||
if (mappings.containsKey(wildKey))
|
||||
return mappings.get(wildKey);
|
||||
return mappings.get(stackToString(stack));
|
||||
}
|
||||
|
||||
public static String stackToString(ItemStack stack) {
|
||||
return stackToString(stack, false);
|
||||
}
|
||||
|
||||
public static String stackToString(ItemStack stack, boolean forceIgnore) {
|
||||
private static String stackToString(ItemStack stack) {
|
||||
if(stack.isEmpty())
|
||||
return "NULL";
|
||||
|
||||
if(stack.hasTagCompound() && stack.getItem() instanceof IRecipeKeyProvider)
|
||||
if(stack.hasTag() && stack.getItem() instanceof IRecipeKeyProvider)
|
||||
return ((IRecipeKeyProvider) stack.getItem()).getKey(stack);
|
||||
|
||||
return stack.getTranslationKey() + (forceIgnore || ignoreMeta(stack) ? "" : "~" + stack.getItemDamage());
|
||||
}
|
||||
|
||||
public static boolean ignoreMeta(ItemStack stack) {
|
||||
return stack.isItemStackDamageable() || stack.getItem() instanceof IManaItem || stack.getItemDamage() == OreDictionary.WILDCARD_VALUE;
|
||||
return stack.getTranslationKey();
|
||||
}
|
||||
|
||||
public static class EntryData {
|
||||
@@ -77,7 +67,7 @@ public final class LexiconRecipeMappings {
|
||||
public final LexiconEntry entry;
|
||||
public final int page;
|
||||
|
||||
public EntryData(LexiconEntry entry, int page) {
|
||||
EntryData(LexiconEntry entry, int page) {
|
||||
this.entry = entry;
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class AnyComponent extends MultiblockComponent {
|
||||
@Override
|
||||
public boolean matches(World world, BlockPos pos) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
return !state.getBlock().isAir(state, world, pos) && state.getCollisionBoundingBox(world, pos) != null;
|
||||
return !state.getBlock().isAir(state, world, pos) && !state.getCollisionShape(world, pos).isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,18 +11,21 @@
|
||||
package vazkii.botania.api.lexicon.multiblock.component;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
/**
|
||||
* A multiblock component that matches any botania flower.
|
||||
*/
|
||||
public class FlowerComponent extends ColorSwitchingComponent {
|
||||
public class FlowerComponent extends TagComponent {
|
||||
|
||||
public FlowerComponent(BlockPos relPos, Block block) {
|
||||
super(relPos, block, BotaniaStateProps.COLOR);
|
||||
super(relPos, block, new BlockTags.Wrapper(new ResourceLocation(LibMisc.MOD_ID, "mystical_flowers")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ public class MultiblockComponent {
|
||||
}
|
||||
|
||||
public ItemStack[] getMaterials() {
|
||||
return new ItemStack[] { new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)) };
|
||||
return new ItemStack[] { new ItemStack(state.getBlock()) };
|
||||
}
|
||||
|
||||
public void rotate(double angle) {
|
||||
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
package vazkii.botania.api.lexicon.multiblock.component;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
// Multiblock component that only compares blocks, not blockstates
|
||||
public class StateInsensitiveComponent extends MultiblockComponent {
|
||||
|
||||
public StateInsensitiveComponent(BlockPos relPos, Block block) {
|
||||
super(relPos, block.getDefaultState(), false, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(World world, BlockPos pos) {
|
||||
return world.getBlockState(pos).getBlock() == getBlockState().getBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiblockComponent copy() {
|
||||
return new StateInsensitiveComponent(getRelativePosition(), getBlockState().getBlock());
|
||||
}
|
||||
|
||||
}
|
||||
+14
-13
@@ -11,39 +11,40 @@
|
||||
package vazkii.botania.api.lexicon.multiblock.component;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
|
||||
/**
|
||||
* A multiblock component that switches through the 16 colors of the
|
||||
* minecraft spectrum. This can be used for flowers, for example.
|
||||
*/
|
||||
public class ColorSwitchingComponent extends MultiblockComponent {
|
||||
public class TagComponent extends MultiblockComponent {
|
||||
|
||||
private final PropertyEnum<EnumDyeColor> colorProp;
|
||||
private final Tag<Block> tag;
|
||||
|
||||
public ColorSwitchingComponent(BlockPos relPos, Block block, PropertyEnum<EnumDyeColor> colorProp) {
|
||||
public TagComponent(BlockPos relPos, Block block, Tag<Block> tag) {
|
||||
super(relPos, block.getDefaultState());
|
||||
this.colorProp = colorProp;
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getBlockState() {
|
||||
return state.with(colorProp, EnumDyeColor.byMetadata((int) (BotaniaAPI.internalHandler.getWorldElapsedTicks() / 20) % 16));
|
||||
if (tag.getAllElements().isEmpty()) {
|
||||
return super.getBlockState();
|
||||
} else {
|
||||
Block[] arr = tag.getAllElements().toArray(new Block[0]);
|
||||
int idx = (int) (BotaniaAPI.internalHandler.getWorldElapsedTicks() / 20) % arr.length;
|
||||
return arr[idx].getDefaultState();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(World world, BlockPos pos) {
|
||||
return world.getBlockState(pos).getBlock() == getBlockState().getBlock();
|
||||
return world.getBlockState(pos).getBlock().isIn(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiblockComponent copy() {
|
||||
return new ColorSwitchingComponent(getRelativePosition(), getBlockState().getBlock(), colorProp);
|
||||
return new TagComponent(getRelativePosition(), getBlockState().getBlock(), tag);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@ package vazkii.botania.api.mana;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public class ManaDiscountEvent extends Event {
|
||||
|
||||
|
||||
@@ -33,25 +33,24 @@ public final class ManaItemHandler {
|
||||
*/
|
||||
public static List<ItemStack> getManaItems(EntityPlayer player) {
|
||||
if (player == null)
|
||||
return new ArrayList<ItemStack>();
|
||||
|
||||
IItemHandler mainInv = player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
|
||||
return new ArrayList<>();
|
||||
|
||||
List<ItemStack> toReturn = new ArrayList<ItemStack>();
|
||||
int size = mainInv.getSlots();
|
||||
player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(mainInv -> {
|
||||
int size = mainInv.getSlots();
|
||||
|
||||
for(int slot = 0; slot < size; slot++) {
|
||||
ItemStack stackInSlot = mainInv.getStackInSlot(slot);
|
||||
for(int slot = 0; slot < size; slot++) {
|
||||
ItemStack stackInSlot = mainInv.getStackInSlot(slot);
|
||||
|
||||
if(!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IManaItem) {
|
||||
toReturn.add(stackInSlot);
|
||||
if(!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IManaItem) {
|
||||
toReturn.add(stackInSlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ManaItemsEvent event = new ManaItemsEvent(player, toReturn);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
toReturn = event.getItems();
|
||||
return toReturn;
|
||||
return event.getItems();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,7 +185,7 @@ public final class ManaItemHandler {
|
||||
* Dispatches mana to items in a given player's inventory. Note that this method
|
||||
* does not automatically remove mana from the item which is exporting.
|
||||
* @param manaToSend How much mana is to be sent.
|
||||
* @param remove If true, the mana will be added from the target item. Set to false to just check.
|
||||
* @param add If true, the mana will be added from the target item. Set to false to just check.
|
||||
* @return The amount of mana actually sent.
|
||||
*/
|
||||
public static int dispatchMana(ItemStack stack, EntityPlayer player, int manaToSend, boolean add) {
|
||||
@@ -246,7 +245,7 @@ public final class ManaItemHandler {
|
||||
* Dispatches an exact amount of mana to items in a given player's inventory. Note that this method
|
||||
* does not automatically remove mana from the item which is exporting.
|
||||
* @param manaToSend How much mana is to be sent.
|
||||
* @param remove If true, the mana will be added from the target item. Set to false to just check.
|
||||
* @param add If true, the mana will be added from the target item. Set to false to just check.
|
||||
* @return If an item received the mana sent.
|
||||
*/
|
||||
public static boolean dispatchManaExact(ItemStack stack, EntityPlayer player, int manaToSend, boolean add) {
|
||||
|
||||
@@ -12,7 +12,7 @@ package vazkii.botania.api.mana;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ package vazkii.botania.api.mana;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public class ManaNetworkEvent extends Event {
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ package vazkii.botania.api.mana;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public class ManaProficiencyEvent extends Event {
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
package vazkii.botania.api;
|
||||
|
||||
+1
-9
@@ -15,16 +15,8 @@ import vazkii.botania.api.item.IPetalApothecary;
|
||||
|
||||
/**
|
||||
* An Item or Block that implements this interface can have a special particle color in the Petal Apothecary.
|
||||
* TODO (breaking change): Rename to something more like "ISpecialApothecary", since now all items can go in the Apothecary
|
||||
*/
|
||||
public interface IFlowerComponent {
|
||||
|
||||
//TODO remove 1.13, unused, all items can go in the Petal Apothecary
|
||||
@Deprecated
|
||||
public default boolean canFit(ItemStack stack, IPetalApothecary apothecary) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public interface ICustomApothecaryColor {
|
||||
public int getParticleColor(ItemStack stack);
|
||||
|
||||
}
|
||||
@@ -13,6 +13,7 @@ package vazkii.botania.api.recipe;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import vazkii.botania.api.brew.Brew;
|
||||
@@ -24,23 +25,15 @@ import java.util.List;
|
||||
public class RecipeBrew {
|
||||
|
||||
private final Brew brew;
|
||||
private final ImmutableList<Object> inputs;
|
||||
private final ImmutableList<Ingredient> inputs;
|
||||
|
||||
public RecipeBrew(Brew brew, Object... inputs) {
|
||||
public RecipeBrew(Brew brew, Ingredient... inputs) {
|
||||
this.brew = brew;
|
||||
|
||||
ImmutableList.Builder<Object> inputsToSet = ImmutableList.builder();
|
||||
for(Object obj : inputs) {
|
||||
if(obj instanceof String || obj instanceof ItemStack)
|
||||
inputsToSet.add(obj);
|
||||
else throw new IllegalArgumentException("Invalid input");
|
||||
}
|
||||
|
||||
this.inputs = inputsToSet.build();
|
||||
this.inputs = ImmutableList.copyOf(inputs);
|
||||
}
|
||||
|
||||
public boolean matches(IItemHandler inv) {
|
||||
List<Object> inputsMissing = new ArrayList<>(inputs);
|
||||
List<Ingredient> inputsMissing = new ArrayList<>(inputs);
|
||||
|
||||
for(int i = 0; i < inv.getSlots(); i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
@@ -50,24 +43,11 @@ public class RecipeBrew {
|
||||
if(stack.getItem() instanceof IBrewContainer)
|
||||
continue;
|
||||
|
||||
int stackIndex = -1, oredictIndex = -1;
|
||||
int stackIndex = -1;
|
||||
|
||||
for(int j = 0; j < inputsMissing.size(); j++) {
|
||||
Object input = inputsMissing.get(j);
|
||||
if(input instanceof String) {
|
||||
boolean found = false;
|
||||
for(ItemStack ostack : OreDictionary.getOres((String) input, false)) {
|
||||
if(OreDictionary.itemMatches(ostack, stack, false)) {
|
||||
oredictIndex = j;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(found)
|
||||
break;
|
||||
} else if(input instanceof ItemStack && simpleAreStacksEqual((ItemStack) input, stack)) {
|
||||
Ingredient input = inputsMissing.get(j);
|
||||
if(input.test(stack)) {
|
||||
stackIndex = j;
|
||||
break;
|
||||
}
|
||||
@@ -75,18 +55,12 @@ public class RecipeBrew {
|
||||
|
||||
if(stackIndex != -1)
|
||||
inputsMissing.remove(stackIndex);
|
||||
else if(oredictIndex != -1)
|
||||
inputsMissing.remove(oredictIndex);
|
||||
else return false;
|
||||
}
|
||||
|
||||
return inputsMissing.isEmpty();
|
||||
}
|
||||
|
||||
private boolean simpleAreStacksEqual(ItemStack stack, ItemStack stack2) {
|
||||
return stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage();
|
||||
}
|
||||
|
||||
public List<Object> getInputs() {
|
||||
return new ArrayList<>(inputs);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ package vazkii.botania.api.recipe;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -20,32 +21,21 @@ import java.util.List;
|
||||
public class RecipeManaInfusion {
|
||||
|
||||
private final ItemStack output;
|
||||
private final Object input;
|
||||
private final Ingredient input;
|
||||
private final int mana;
|
||||
private @Nullable IBlockState catalystState;
|
||||
|
||||
public static IBlockState alchemyState;
|
||||
public static IBlockState conjurationState;
|
||||
|
||||
public RecipeManaInfusion(ItemStack output, Object input, int mana) {
|
||||
public RecipeManaInfusion(ItemStack output, Ingredient input, int mana) {
|
||||
this.output = output;
|
||||
this.input = input;
|
||||
this.mana = mana;
|
||||
}
|
||||
|
||||
public boolean matches(ItemStack stack) {
|
||||
if(input instanceof ItemStack) {
|
||||
return OreDictionary.itemMatches((ItemStack) input, stack, false);
|
||||
}
|
||||
|
||||
if(input instanceof String) {
|
||||
for(ItemStack ostack : OreDictionary.getOres((String) input, false)) {
|
||||
if(OreDictionary.itemMatches(ostack, stack, false))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return input.test(stack);
|
||||
}
|
||||
|
||||
public IBlockState getCatalyst() {
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.google.common.base.Preconditions;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
@@ -40,8 +41,9 @@ public class RecipePureDaisy {
|
||||
this.input = input;
|
||||
outputState = state;
|
||||
this.time = time;
|
||||
if(input != null && !(input instanceof String || input instanceof Block || input instanceof IBlockState))
|
||||
throw new IllegalArgumentException("input must be an oredict String, Block, or IBlockState");
|
||||
if(input != null && !(input instanceof Tag || input instanceof Block || input instanceof IBlockState))
|
||||
throw new IllegalArgumentException("input must be a Tag<Block>, Block, or IBlockState");
|
||||
// todo 1.13 find way to throw or enforce Tag<Block>
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,22 +56,7 @@ public class RecipePureDaisy {
|
||||
if(input instanceof IBlockState)
|
||||
return state == input;
|
||||
|
||||
ItemStack stack = new ItemStack(state.getBlock(), 1, state.getBlock().damageDropped(state));
|
||||
String oredict = (String) input;
|
||||
return isOreDict(stack, oredict);
|
||||
}
|
||||
|
||||
private boolean isOreDict(ItemStack stack, String entry) {
|
||||
if(stack.isEmpty())
|
||||
return false;
|
||||
|
||||
for(ItemStack ostack : OreDictionary.getOres(entry, false)) {
|
||||
if(OreDictionary.itemMatches(ostack, stack, false)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return ((Tag<Block>) input).contains(state.getBlock());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,14 +10,10 @@ package vazkii.botania.api.state;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import net.minecraft.block.BlockRailBase;
|
||||
import net.minecraft.block.BlockRailPowered;
|
||||
import net.minecraft.block.BlockRotatedPillar;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.state.properties.RailShape;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -25,8 +21,6 @@ import net.minecraft.world.IBlockReader;
|
||||
import vazkii.botania.api.item.IFloatingFlower;
|
||||
import vazkii.botania.api.state.enums.AlfPortalState;
|
||||
import vazkii.botania.api.state.enums.CratePattern;
|
||||
import vazkii.botania.api.state.enums.LuminizerVariant;
|
||||
import vazkii.botania.api.state.enums.QuartzVariant;
|
||||
|
||||
/**
|
||||
* Holds all Botania block state properties. Use these to set botania blockstates
|
||||
@@ -65,14 +59,6 @@ public final class BotaniaStateProps {
|
||||
// Also for any other simple boolean "on/off" state
|
||||
public static final BooleanProperty POWERED = BooleanProperty.create("powered");
|
||||
|
||||
/** Properties for certain kinds of blocks **/
|
||||
|
||||
// The axis directions (think quartz pillars and wood logs)
|
||||
public static final EnumProperty<EnumFacing.Axis> AXIS_FACING = BlockRotatedPillar.AXIS;
|
||||
|
||||
// Extra Quartz Blocks
|
||||
public static final EnumProperty<QuartzVariant> QUARTZ_VARIANT = EnumProperty.create("variant", QuartzVariant.class);
|
||||
|
||||
/** Properties for individual blocks **/
|
||||
|
||||
// BlockAlfPortal
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
@@ -53,16 +54,12 @@ public class SimpleWikiProvider implements IWikiProvider {
|
||||
ItemStack stack = state.getBlock().getPickBlock(state, pos, world, bPos, player);
|
||||
|
||||
if(stack.isEmpty())
|
||||
stack = new ItemStack(state.getBlock(), 1, state.getBlock().damageDropped(state));
|
||||
stack = new ItemStack(state.getBlock());
|
||||
|
||||
if(stack.isEmpty())
|
||||
return null;
|
||||
|
||||
String name = stack.getDisplayName();
|
||||
if(name == null || name.isEmpty())
|
||||
return null;
|
||||
|
||||
return name;
|
||||
return stack.getDisplayName().getString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,15 +23,12 @@ public class WikiHooks {
|
||||
private static final Map<String, IWikiProvider> modWikis = new HashMap<>();
|
||||
|
||||
public static IWikiProvider getWikiFor(Block block) {
|
||||
ResourceLocation mod = Block.REGISTRY.getNameForObject(block);
|
||||
ResourceLocation mod = block.getRegistryName();
|
||||
return getWikiFor(mod == null ? "" : mod.getNamespace().toLowerCase());
|
||||
}
|
||||
|
||||
public static IWikiProvider getWikiFor(String mod) {
|
||||
if(!modWikis.containsKey(mod))
|
||||
modWikis.put(mod, FALLBACK_PROVIDER);
|
||||
|
||||
return modWikis.get(mod);
|
||||
return modWikis.getOrDefault(mod, FALLBACK_PROVIDER);
|
||||
}
|
||||
|
||||
public static void registerModWiki(String mod, IWikiProvider provider) {
|
||||
|
||||
@@ -12,16 +12,11 @@ package vazkii.botania.common.block.decor;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockMushroom;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
@@ -33,22 +28,17 @@ import thaumcraft.api.crafting.IInfusionStabiliser;
|
||||
import vazkii.botania.api.item.IHornHarvestable;
|
||||
import vazkii.botania.api.lexicon.ILexiconable;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.recipe.IFlowerComponent;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.client.core.handler.ModelHandler;
|
||||
import vazkii.botania.api.recipe.ICustomApothecaryColor;
|
||||
import vazkii.botania.client.render.IModelRegister;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.core.BotaniaCreativeTab;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Random;
|
||||
|
||||
@Optional.Interface(modid = "thaumcraft", iface = "thaumcraft.api.crafting.IInfusionStabiliser", striprefs = true)
|
||||
public class BlockModMushroom extends BlockMushroom implements IInfusionStabiliser, IHornHarvestable, ILexiconable, IModelRegister, IFlowerComponent {
|
||||
public class BlockModMushroom extends BlockMushroom implements IInfusionStabiliser, IHornHarvestable, ILexiconable, IModelRegister, ICustomApothecaryColor {
|
||||
|
||||
private static final VoxelShape SHAPE = makeCuboidShape(4.8, 0, 4.8, 12.8, 16, 12.8);
|
||||
private final EnumDyeColor color;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
@@ -41,7 +40,7 @@ import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.api.item.IPetalApothecary;
|
||||
import vazkii.botania.api.recipe.IFlowerComponent;
|
||||
import vazkii.botania.api.recipe.ICustomApothecaryColor;
|
||||
import vazkii.botania.api.recipe.RecipePetals;
|
||||
import vazkii.botania.client.core.handler.HUDHandler;
|
||||
import vazkii.botania.client.core.helper.RenderHelper;
|
||||
@@ -164,12 +163,12 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary,
|
||||
return false;
|
||||
}
|
||||
|
||||
private IFlowerComponent getFlowerComponent(ItemStack stack) {
|
||||
IFlowerComponent c = null;
|
||||
if(stack.getItem() instanceof IFlowerComponent)
|
||||
c = (IFlowerComponent) stack.getItem();
|
||||
else if(stack.getItem() instanceof ItemBlock && ((ItemBlock) stack.getItem()).getBlock() instanceof IFlowerComponent)
|
||||
c = (IFlowerComponent) ((ItemBlock) stack.getItem()).getBlock();
|
||||
private ICustomApothecaryColor getFlowerComponent(ItemStack stack) {
|
||||
ICustomApothecaryColor c = null;
|
||||
if(stack.getItem() instanceof ICustomApothecaryColor)
|
||||
c = (ICustomApothecaryColor) stack.getItem();
|
||||
else if(stack.getItem() instanceof ItemBlock && ((ItemBlock) stack.getItem()).getBlock() instanceof ICustomApothecaryColor)
|
||||
c = (ICustomApothecaryColor) ((ItemBlock) stack.getItem()).getBlock();
|
||||
|
||||
return c;
|
||||
}
|
||||
@@ -246,7 +245,7 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary,
|
||||
break;
|
||||
|
||||
if(Math.random() >= 0.97) {
|
||||
IFlowerComponent comp = getFlowerComponent(stackAt);
|
||||
ICustomApothecaryColor comp = getFlowerComponent(stackAt);
|
||||
Color color = new Color(comp == null ? 0x888888 : comp.getParticleColor(stackAt));
|
||||
float red = color.getRed() / 255F;
|
||||
float green = color.getGreen() / 255F;
|
||||
|
||||
@@ -11,31 +11,22 @@
|
||||
package vazkii.botania.common.item.material;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import vazkii.botania.api.item.IPetalApothecary;
|
||||
import vazkii.botania.api.recipe.IElvenItem;
|
||||
import vazkii.botania.api.recipe.IFlowerComponent;
|
||||
import vazkii.botania.api.recipe.ICustomApothecaryColor;
|
||||
import vazkii.botania.common.entity.EntityDoppleganger;
|
||||
import vazkii.botania.common.entity.EntityEnderAirBottle;
|
||||
import vazkii.botania.common.item.ItemMod;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
// todo 1.13 further break this up
|
||||
public class ItemManaResource extends ItemMod implements IFlowerComponent, IElvenItem {
|
||||
public class ItemManaResource extends ItemMod implements ICustomApothecaryColor, IElvenItem {
|
||||
public ItemManaResource(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@@ -11,32 +11,12 @@
|
||||
package vazkii.botania.common.item.material;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import vazkii.botania.api.item.IPetalApothecary;
|
||||
import vazkii.botania.api.recipe.IFlowerComponent;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.item.Item16Colors;
|
||||
import vazkii.botania.api.recipe.ICustomApothecaryColor;
|
||||
import vazkii.botania.common.item.block.ItemBlockMod;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ItemPetal extends ItemBlockMod implements IFlowerComponent {
|
||||
public class ItemPetal extends ItemBlockMod implements ICustomApothecaryColor {
|
||||
public final EnumDyeColor color;
|
||||
|
||||
public ItemPetal(Block buriedPetals, EnumDyeColor color, Properties props) {
|
||||
|
||||
@@ -12,11 +12,10 @@ package vazkii.botania.common.item.material;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import vazkii.botania.api.item.IPetalApothecary;
|
||||
import vazkii.botania.api.recipe.IFlowerComponent;
|
||||
import vazkii.botania.api.recipe.ICustomApothecaryColor;
|
||||
import vazkii.botania.common.item.ItemMod;
|
||||
|
||||
public class ItemRune extends ItemMod implements IFlowerComponent {
|
||||
public class ItemRune extends ItemMod implements ICustomApothecaryColor {
|
||||
|
||||
public ItemRune(Item.Properties builder) {
|
||||
super(builder);
|
||||
|
||||
Reference in new issue
Block a user