Some botania tweaks stuff (on discord) (#2791)

* Taste the rainbow

* Gunpowder to flint = flint to gunpowder

* Allow whatever in the Petal Apothecary, remove canFit in IFlowerComponent

* NBT aware apothecary altar stuff
This commit is contained in:
quaternary authored and Vasco Lavos committed 2018-11-30 04:33:43 +00:00
1 parent 8f716c98f0
commit 531912e726
9 files changed
+54 -63

No files matched your search

@@ -14,12 +14,17 @@ import net.minecraft.item.ItemStack;
import vazkii.botania.api.item.IPetalApothecary;
/**
* Have an Item implement this to allow it to be used in the Petal Apothecary.
* 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 {
public boolean canFit(ItemStack stack, IPetalApothecary apothecary);
//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 int getParticleColor(ItemStack stack);
}
@@ -12,6 +12,7 @@ package vazkii.botania.api.recipe;
import com.google.common.collect.ImmutableList;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.oredict.OreDictionary;
@@ -61,7 +62,7 @@ public class RecipePetals {
if(found)
break;
} else if(input instanceof ItemStack && simpleAreStacksEqual((ItemStack) input, stack)) {
} else if(input instanceof ItemStack && compareStacks((ItemStack) input, stack)) {
stackIndex = j;
break;
}
@@ -77,8 +78,20 @@ public class RecipePetals {
return inputsMissing.isEmpty();
}
private boolean simpleAreStacksEqual(ItemStack stack, ItemStack stack2) {
return stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage();
private boolean compareStacks(ItemStack recipe, ItemStack supplied) {
if(recipe.getItem() == supplied.getItem() && recipe.getItemDamage() == supplied.getItemDamage()) {
//check that the user supplied nbt tag is a superset of the recipe item nbt tag
//if the recipe doesn't have an NBT tag, the user supplied one doesn't matter, it is a superset
if(!recipe.hasTagCompound()) return true;
//if the recipe does have an NBT tag but the user supplied doesn't, also no way it's a superset
if(!supplied.hasTagCompound()) return false;
NBTTagCompound mergedNBT = supplied.getTagCompound().copy();
mergedNBT.merge(recipe.getTagCompound());
return supplied.getTagCompound().equals(mergedNBT);
}
return false;
}
public List<Object> getInputs() {
@@ -162,11 +162,6 @@ public class BlockModMushroom extends BlockMushroom implements IInfusionStabilis
ModelHandler.registerCustomItemblock(this, EnumDyeColor.values().length, i -> "mushroom_" + EnumDyeColor.byMetadata(i).getName());
}
@Override
public boolean canFit(ItemStack stack, IPetalApothecary apothecary) {
return true;
}
@Override
public int getParticleColor(ItemStack stack) {
return EnumDyeColor.byMetadata(stack.getItemDamage()).colorValue;
@@ -59,7 +59,7 @@ public class SubTileSpectrolus extends SubTileGenerating {
if(!stack.isEmpty() && stack.getItem() == wool && !item.isDead && item.age >= slowdown) {
int meta = stack.getItemDamage();
if(meta == nextColor) {
mana = Math.min(getMaxMana(), mana + 300);
mana = Math.min(getMaxMana(), mana + 2400);
nextColor = nextColor == 15 ? 0 : nextColor + 1;
sync();
@@ -78,7 +78,7 @@ public class SubTileSpectrolus extends SubTileGenerating {
@Override
public int getMaxMana() {
return 8000;
return 16000;
}
@Override
@@ -94,9 +94,10 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary,
}
}
boolean hasFluidCapability = stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
if(!hasWater() && !hasLava()) {
if(stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
if(hasFluidCapability) {
IFluidHandlerItem fluidHandler = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
FluidStack drainWater = fluidHandler.drain(new FluidStack(FluidRegistry.WATER, Fluid.BUCKET_VOLUME), false);
@@ -124,46 +125,43 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary,
item.setFire(100);
return true;
}
boolean didChange = false;
if(isFlowerComponent(stack)) {
if(!itemHandler.getStackInSlot(getSizeInventory() - 1).isEmpty())
return false;
for(int i = 0; i < getSizeInventory(); i++)
if(itemHandler.getStackInSlot(i).isEmpty()) {
itemHandler.setStackInSlot(i, stack.splitStack(1));
didChange = true;
world.playSound(null, pos, SoundEvents.ENTITY_GENERIC_SPLASH, SoundCategory.BLOCKS, 0.1F, 10F);
break;
}
} else if(!stack.isEmpty() && SEED_PATTERN.matcher(stack.getItem().getUnlocalizedName(stack)).find()) {
if(SEED_PATTERN.matcher(stack.getUnlocalizedName()).find()) {
for(RecipePetals recipe : BotaniaAPI.petalRecipes) {
if(recipe.matches(itemHandler)) {
saveLastRecipe();
for(int i = 0; i < getSizeInventory(); i++)
itemHandler.setStackInSlot(i, ItemStack.EMPTY);
stack.shrink(1);
ItemStack output = recipe.getOutput().copy();
EntityItem outputItem = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, output);
world.spawnEntity(outputItem);
setWater(false);
world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock());
world.addBlockEvent(getPos(), getBlockType(), CRAFT_EFFECT_EVENT, 0);
didChange = true;
break;
return true;
}
}
} else if(!hasFluidCapability) {
if(!itemHandler.getStackInSlot(getSizeInventory() - 1).isEmpty())
return false;
for(int i = 0; i < getSizeInventory(); i++) {
if(itemHandler.getStackInSlot(i).isEmpty()) {
itemHandler.setStackInSlot(i, stack.splitStack(1));
world.playSound(null, pos, SoundEvents.ENTITY_GENERIC_SPLASH, SoundCategory.BLOCKS, 0.1F, 10F);
return true;
}
}
}
return didChange;
return false;
}
private IFlowerComponent getFlowerComponent(ItemStack stack) {
@@ -175,11 +173,6 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary,
return c;
}
private boolean isFlowerComponent(ItemStack stack) {
IFlowerComponent c = getFlowerComponent(stack);
return c != null && c.canFit(stack, this);
}
public void saveLastRecipe() {
lastRecipe = new ArrayList<>();
@@ -252,8 +245,9 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary,
if(stackAt.isEmpty())
break;
if(Math.random() >= 0.97 && getFlowerComponent(stackAt) != null) {
Color color = new Color(getFlowerComponent(stackAt).getParticleColor(stackAt));
if(Math.random() >= 0.97) {
IFlowerComponent comp = getFlowerComponent(stackAt);
Color color = new Color(comp == null ? 0x888888 : comp.getParticleColor(stackAt));
float red = color.getRed() / 255F;
float green = color.getGreen() / 255F;
float blue = color.getBlue() / 255F;
@@ -107,7 +107,7 @@ public final class ModManaAlchemyRecipes {
gunpowderAndFlintRecipes = new ArrayList<>();
gunpowderAndFlintRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.FLINT), new ItemStack(Items.GUNPOWDER), 200));
gunpowderAndFlintRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.GUNPOWDER), new ItemStack(Items.FLINT), 4000));
gunpowderAndFlintRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.GUNPOWDER), new ItemStack(Items.FLINT), 200));
nameTagRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.NAME_TAG), new ItemStack(Items.WRITABLE_BOOK), 16000);
@@ -135,12 +135,6 @@ public class ItemManaResource extends ItemMod implements IFlowerComponent, IElve
return "item." + LibItemNames.MANA_RESOURCE_NAMES[Math.min(types - 1, par1ItemStack.getItemDamage())];
}
@Override
public boolean canFit(ItemStack stack, IPetalApothecary apothecary) {
int meta = stack.getItemDamage();
return meta == 6 || meta == 8 || meta == 5 || meta == 23;
}
@Override
public int getParticleColor(ItemStack stack) {
return 0x9b0000;
@@ -89,11 +89,6 @@ public class ItemPetal extends Item16Colors implements IFlowerComponent {
return MathHelper.clamp(stackMeta, 0, 15);
}
@Override
public boolean canFit(ItemStack stack, IPetalApothecary apothecary) {
return true;
}
@Override
public int getParticleColor(ItemStack stack) {
return EnumDyeColor.byMetadata(stack.getItemDamage()).colorValue;
@@ -48,11 +48,6 @@ public class ItemRune extends ItemMod implements IFlowerComponent {
return super.getUnlocalizedName(par1ItemStack);
}
@Override
public boolean canFit(ItemStack stack, IPetalApothecary apothecary) {
return true;
}
@Override
public int getParticleColor(ItemStack stack) {
return 0xA8A8A8;