mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 19:05:16 +00:00
Fixed mushrooms not fitting in the petal apothecary
This commit is contained in:
1 parent
6b764eef26
commit
e22003a4b2
2 files changed
+34
-4
No files matched your search
@@ -31,8 +31,10 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import thaumcraft.api.crafting.IInfusionStabiliser;
|
||||
import vazkii.botania.api.item.IHornHarvestable;
|
||||
import vazkii.botania.api.item.IPetalApothecary;
|
||||
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.client.render.IModelRegister;
|
||||
@@ -47,7 +49,7 @@ 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 {
|
||||
public class BlockModMushroom extends BlockMushroom implements IInfusionStabiliser, IHornHarvestable, ILexiconable, IModelRegister, IFlowerComponent {
|
||||
|
||||
private static final AxisAlignedBB AABB = new AxisAlignedBB(0.3, 0, 0.3, 0.8, 1, 0.8);
|
||||
|
||||
@@ -159,4 +161,14 @@ public class BlockModMushroom extends BlockMushroom implements IInfusionStabilis
|
||||
public void registerModels() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
@@ -36,6 +37,7 @@ import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import scala.reflect.internal.Trees.If;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.api.item.IPetalApothecary;
|
||||
@@ -48,6 +50,7 @@ import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.core.handler.ModSounds;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemBalanceCloak;
|
||||
import vazkii.botania.common.network.PacketBotaniaEffect;
|
||||
import vazkii.botania.common.network.PacketHandler;
|
||||
|
||||
@@ -122,7 +125,7 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary {
|
||||
|
||||
boolean didChange = false;
|
||||
|
||||
if(stack.getItem() instanceof IFlowerComponent && ((IFlowerComponent) stack.getItem()).canFit(stack, this)) {
|
||||
if(isFlowerComponent(stack)) {
|
||||
if(!itemHandler.getStackInSlot(getSizeInventory() - 1).isEmpty())
|
||||
return false;
|
||||
|
||||
@@ -160,6 +163,21 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary {
|
||||
|
||||
return didChange;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
private boolean isFlowerComponent(ItemStack stack) {
|
||||
IFlowerComponent c = getFlowerComponent(stack);
|
||||
return c != null && c.canFit(stack, this);
|
||||
}
|
||||
|
||||
public void saveLastRecipe() {
|
||||
lastRecipe = new ArrayList<>();
|
||||
@@ -239,13 +257,13 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary {
|
||||
break;
|
||||
|
||||
if(Math.random() >= 0.97) {
|
||||
Color color = new Color(((IFlowerComponent) stackAt.getItem()).getParticleColor(stackAt));
|
||||
Color color = new Color(getFlowerComponent(stackAt).getParticleColor(stackAt));
|
||||
float red = color.getRed() / 255F;
|
||||
float green = color.getGreen() / 255F;
|
||||
float blue = color.getBlue() / 255F;
|
||||
if(Math.random() >= 0.75F)
|
||||
world.playSound(null, pos, SoundEvents.ENTITY_GENERIC_SPLASH, SoundCategory.BLOCKS, 0.1F, 10F);
|
||||
Botania.proxy.sparkleFX(pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, red, green, blue, (float) Math.random(), 10);
|
||||
Botania.proxy.sparkleFX(pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1.2, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, red, green, blue, (float) Math.random(), 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user