Getting close

This commit is contained in:
Vincent Lee committed 2019-03-17 00:35:40 -05:00
1 parent fbbb4e3c02
commit 04900e560d
49 files changed
+241 -306

No files matched your search

@@ -37,6 +37,7 @@ import net.minecraft.util.registry.RegistryNamespaced;
import net.minecraft.util.registry.RegistryNamespacedDefaultedByKey;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.registries.ForgeRegistries;
import vazkii.botania.api.brew.Brew;
import vazkii.botania.api.internal.DummyMethodHandler;
import vazkii.botania.api.internal.DummySubTile;
@@ -100,7 +101,6 @@ public final class BotaniaAPI {
public static final Set<Class<? extends Entity>> gravityRodBlacklist = new LinkedHashSet<>();
public static final Set<Block> gaiaBreakBlacklist = new HashSet<>();
// TODO 1.13 move these to eliminate dependence on botania proper in Ingredients
private static final int[] MAX_DAMAGE_ARRAY = new int[]{13, 15, 16, 11};
public static final IArmorMaterial MANASTEEL_ARMOR_MAT = new IArmorMaterial() {
private final int[] damageReduction = { 2, 5, 6, 2 };
@@ -126,7 +126,8 @@ public final class BotaniaAPI {
@Override
public Ingredient getRepairMaterial() {
return Ingredient.fromItems(ModItems.manaSteel);
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation("botania", "manasteel_ingot"));
return Ingredient.fromItems(item);
}
@Override
@@ -168,7 +169,8 @@ public final class BotaniaAPI {
@Nonnull
@Override
public Ingredient getRepairMaterial() {
return Ingredient.fromItems(ModItems.manaSteel);
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation("botania", "manasteel_ingot"));
return Ingredient.fromItems(item);
}
};
@@ -196,7 +198,8 @@ public final class BotaniaAPI {
@Override
public Ingredient getRepairMaterial() {
return Ingredient.fromItems(ModItems.elementium);
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation("botania", "manasteel_ingot"));
return Ingredient.fromItems(item);
}
@Override
@@ -238,7 +241,8 @@ public final class BotaniaAPI {
@Nonnull
@Override
public Ingredient getRepairMaterial() {
return Ingredient.fromItems(ModItems.elementium);
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation("botania", "manasteel_ingot"));
return Ingredient.fromItems(item);
}
};
@@ -266,7 +270,8 @@ public final class BotaniaAPI {
@Override
public Ingredient getRepairMaterial() {
return Ingredient.fromItems(ModItems.terrasteel);
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation("botania", "terrasteel_ingot"));
return Ingredient.fromItems(item);
}
@Override
@@ -308,7 +313,8 @@ public final class BotaniaAPI {
@Nonnull
@Override
public Ingredient getRepairMaterial() {
return Ingredient.fromItems(ModItems.terrasteel);
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation("botania", "terrasteel_ingot"));
return Ingredient.fromItems(item);
}
};
public static final IArmorMaterial MANAWEAVE_ARMOR_MAT = new IArmorMaterial() {
@@ -335,7 +341,8 @@ public final class BotaniaAPI {
@Override
public Ingredient getRepairMaterial() {
return Ingredient.fromItems(ModItems.manaweaveCloth);
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation("botania", "manaweave_cloth"));
return Ingredient.fromItems(item);
}
@Override
@@ -552,7 +559,7 @@ public final class BotaniaAPI {
* or String (case for Ore Dictionary). The array can't be larger than 16.
* @return The recipe created.
*/
public static RecipePetals registerPetalRecipe(ItemStack output, Object... inputs) {
public static RecipePetals registerPetalRecipe(ItemStack output, Ingredient... inputs) {
Preconditions.checkArgument(inputs.length <= 16);
RecipePetals recipe = new RecipePetals(output, inputs);
petalRecipes.add(recipe);
@@ -617,7 +624,7 @@ public final class BotaniaAPI {
* Alchemy Catalyst below the pool).
* @see BotaniaAPI#registerManaInfusionRecipe
*/
public static RecipeManaInfusion registerManaAlchemyRecipe(ItemStack output, Object input, int mana) {
public static RecipeManaInfusion registerManaAlchemyRecipe(ItemStack output, Ingredient input, int mana) {
RecipeManaInfusion recipe = registerManaInfusionRecipe(output, input, mana);
recipe.setCatalyst(RecipeManaInfusion.alchemyState);
return recipe;
@@ -61,7 +61,7 @@ public class RecipeBrew {
return inputsMissing.isEmpty();
}
public List<Object> getInputs() {
public List<Ingredient> getInputs() {
return new ArrayList<>(inputs);
}
@@ -12,6 +12,7 @@ package vazkii.botania.api.recipe;
import com.google.common.collect.ImmutableList;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.oredict.OreDictionary;
@@ -23,67 +24,40 @@ import java.util.List;
public class RecipePetals {
private final ItemStack output;
private final ImmutableList<Object> inputs;
private final ImmutableList<Ingredient> inputs;
public RecipePetals(ItemStack output, Object... inputs) {
public RecipePetals(ItemStack output, Ingredient... inputs) {
this.output = output;
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> ingredientsMissing = new ArrayList<>(inputs);
for(int i = 0; i < inv.getSlots(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if(stack.isEmpty())
ItemStack input = inv.getStackInSlot(i);
if(input.isEmpty())
break;
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 && compareStacks((ItemStack) input, stack)) {
for(int j = 0; j < ingredientsMissing.size(); j++) {
Ingredient ingr = ingredientsMissing.get(j);
if(ingr.test(input)) {
stackIndex = j;
break;
}
}
if(stackIndex != -1)
inputsMissing.remove(stackIndex);
else if(oredictIndex != -1)
inputsMissing.remove(oredictIndex);
ingredientsMissing.remove(stackIndex);
else return false;
}
return inputsMissing.isEmpty();
return ingredientsMissing.isEmpty();
}
private boolean compareStacks(ItemStack recipe, ItemStack supplied) {
return recipe.getItem() == supplied.getItem() && recipe.getItemDamage() == supplied.getItemDamage() && ItemNBTHelper.isTagSubset(recipe.getTagCompound(), supplied.getTagCompound());
}
public List<Object> getInputs() {
public List<Ingredient> getInputs() {
return inputs;
}
@@ -11,12 +11,13 @@
package vazkii.botania.api.recipe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
public class RecipeRuneAltar extends RecipePetals {
private final int mana;
public RecipeRuneAltar(ItemStack output, int mana, Object... inputs) {
public RecipeRuneAltar(ItemStack output, int mana, Ingredient... inputs) {
super(output, inputs);
this.mana = mana;
}
@@ -11,6 +11,7 @@
package vazkii.botania.client.core.handler;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlowingFluid;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
@@ -393,7 +394,7 @@ public final class HUDHandler {
LexiconEntry entry = ((ILexiconable) block).getEntry(mc.world, pos.getBlockPos(), mc.player, stack);
if(entry != null) {
if(!((ILexicon) stack.getItem()).isKnowledgeUnlocked(stack, entry.getKnowledgeType()))
font = mc.standardGalacticFontRenderer;
font = mc.getFontResourceManager().getFontRenderer(Minecraft.standardGalacticFontRenderer);
drawStr = I18n.format(entry.getUnlocalizedName());
secondLine = TextFormatting.ITALIC + I18n.format(entry.getTagline());
@@ -403,7 +404,7 @@ public final class HUDHandler {
if(!ConfigHandler.CLIENT.lexicaOfflineMode.get() && !draw && pos.entity == null) {
profiler.startSection("wikiLookup");
if(!block.isAir(state, mc.world, pos.getBlockPos()) && !(block instanceof BlockLiquid)) {
if(!block.isAir(state, mc.world, pos.getBlockPos()) && !(block instanceof BlockFlowingFluid)) {
IWikiProvider provider = WikiHooks.getWikiFor(block);
String url = provider.getWikiURL(mc.world, pos, mc.player);
if(url != null && !url.isEmpty()) {
@@ -430,7 +431,7 @@ public final class HUDHandler {
if(!mc.player.isSneaking()) {
GlStateManager.scalef(0.5F, 0.5F, 1F);
mc.fontRenderer.drawStringWithShadow(TextFormatting.BOLD + mc.gameSettings.keyBindSneak.getDisplayName(), (sx + 10) * 2 - 16, (sy + 8) * 2 + 20, 0xFFFFFFFF);
mc.fontRenderer.drawStringWithShadow(TextFormatting.BOLD + mc.gameSettings.keyBindSneak.func_197978_k(), (sx + 10) * 2 - 16, (sy + 8) * 2 + 20, 0xFFFFFFFF);
GlStateManager.scalef(2F, 2F, 1F);
}
}
@@ -96,10 +96,12 @@ public class MiscellaneousIcons {
evt.getModelRegistry().put(infrangibleName, new PlatformModel(infrangible));
// Lexicon
evt.getModelRegistry().put(new ModelResourceLocation("botania:lexicon_3d_default", "inventory"),
new LexiconModel(new ModelResourceLocation("botania:lexicon_default", "inventory")));
evt.getModelRegistry().put(new ModelResourceLocation("botania:lexicon_3d_elven", "inventory"),
new LexiconModel(new ModelResourceLocation("botania:lexicon_elven", "inventory")));
IBakedModel original = evt.getModelRegistry().get(new ModelResourceLocation("botania:lexicon", "inventory"));
evt.getModelRegistry().put(new ModelResourceLocation("botania:lexicon", "inventory"),
new LexiconModel(original));
original = evt.getModelRegistry().get(new ModelResourceLocation("botania:lexicon_elven", "inventory"));
evt.getModelRegistry().put(new ModelResourceLocation("botania:lexicon_elven", "inventory"),
new LexiconModel(original));
// Mana Blaster
ModelResourceLocation key = new ModelResourceLocation("botania:managun", "inventory");
@@ -229,7 +229,7 @@ public class ClientProxy implements IProxy {
@Override
public boolean openWikiPage(World world, Block block, RayTraceResult pos) {
if(ConfigHandler.lexicaOfflineMode)
if(ConfigHandler.CLIENT.lexicaOfflineMode.get())
return false;
IWikiProvider wiki = WikiHooks.getWikiFor(block);
String url = wiki.getWikiURL(world, pos, Minecraft.getInstance().player);
@@ -114,7 +114,7 @@ public class GuiButtonCategory extends GuiButtonLexicon {
boolean shaders = ShaderHelper.useShaders();
if(shaders) {
OpenGlHelper.glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + ConfigHandler.glSecondaryTextureUnit);
OpenGlHelper.glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + ConfigHandler.CLIENT.glSecondaryTextureUnit.get());
texture = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
}
@@ -123,7 +123,7 @@ public class GuiButtonCategory extends GuiButtonLexicon {
ShaderHelper.releaseShader();
if(shaders) {
OpenGlHelper.glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + ConfigHandler.glSecondaryTextureUnit);
OpenGlHelper.glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + ConfigHandler.CLIENT.glSecondaryTextureUnit.get());
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
OpenGlHelper.glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB);
}
@@ -2,12 +2,10 @@ package vazkii.botania.client.model;
import com.google.common.collect.ImmutableList;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.model.BakedQuad;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.model.ItemOverrideList;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.EnumFacing;
import org.apache.commons.lang3.tuple.Pair;
@@ -19,10 +17,10 @@ import java.util.List;
import java.util.Random;
public class LexiconModel implements IBakedModel {
private final ModelResourceLocation path2D;
private final IBakedModel original;
public LexiconModel(ModelResourceLocation path) {
this.path2D = path;
public LexiconModel(IBakedModel original) {
this.original = original;
}
@Nonnull
@@ -32,7 +30,6 @@ public class LexiconModel implements IBakedModel {
|| cameraTransformType == ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND)
&& ConfigHandler.CLIENT.lexicon3dModel.get())
return Pair.of(this, null);
IBakedModel original = Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelShapes().getModelManager().getModel(path2D);
return original.handlePerspective(cameraTransformType);
}
@@ -40,7 +37,7 @@ public class LexiconModel implements IBakedModel {
@Override public boolean isAmbientOcclusion() { return false; }
@Override public boolean isGui3d() { return false; }
@Override public boolean isBuiltInRenderer() { return false; }
@Nonnull @Override public TextureAtlasSprite getParticleTexture() { return Minecraft.getInstance().getTextureMap().getAtlasSprite("botania:items/lexicon"); }
@Nonnull @Override public TextureAtlasSprite getParticleTexture() { return original.getParticleTexture(); }
@SuppressWarnings("deprecation") @Nonnull @Override public ItemCameraTransforms getItemCameraTransforms() { return ItemCameraTransforms.DEFAULT; }
@Nonnull @Override public ItemOverrideList getOverrides() { return ItemOverrideList.EMPTY; }
}
@@ -43,7 +43,7 @@ public class RenderTileBellows extends TileEntityRenderer<TileBellows> {
GlStateManager.translated(d0, d1, d2);
Minecraft.getInstance().textureManager.bindTexture(texture);
int meta = bellows != null && bellows.getWorld() != null ? bellows.getBlockMetadata() : 0;
int meta = 0; // todo 1.13 bellows != null && bellows.getWorld() != null ? bellows.getBlockMetadata() : 0;
GlStateManager.translatef(0.5F, 1.5F, 0.5F);
GlStateManager.scalef(1F, -1F, -1F);
@@ -141,71 +141,6 @@ public class RenderTileCorporeaCrystalCube extends TileEntityRenderer<TileCorpor
GlStateManager.scalef(1F, -1F, -1F);
GlStateManager.enableRescaleNormal();
GlStateManager.popMatrix();
renderAnimatedModel(cube, d0, d1, d2, f);
// todo 1.13 readd cube
}
// Copied from AnimationTESR
private static BlockRendererDispatcher blockRenderer;
private void renderAnimatedModel(TileCorporeaCrystalCube te, double x, double y, double z, float partialTick) {
// From FastTESR.render
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder worldRenderer = tessellator.getBuffer();
bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
RenderHelper.disableStandardItemLighting();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.enableBlend();
GlStateManager.disableCull();
if (Minecraft.isAmbientOcclusionEnabled())
{
GlStateManager.shadeModel(GL11.GL_SMOOTH);
}
else
{
GlStateManager.shadeModel(GL11.GL_FLAT);
}
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
// Inlined AnimationTESR.renderTileEntityFast
if(!te.hasCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null))
{
return;
}
if(blockRenderer == null) blockRenderer = Minecraft.getInstance().getBlockRendererDispatcher();
BlockPos pos = te.getPos();
IBlockReader world = MinecraftForgeClient.getRegionRenderCache(te.getWorld(), pos);
IBlockState state = world.getBlockState(pos);
if(state.getPropertyKeys().contains(Properties.StaticProperty))
{
state = state.with(Properties.StaticProperty, false);
}
if(state instanceof IExtendedBlockState)
{
IExtendedBlockState exState = (IExtendedBlockState)state;
if(exState.getUnlistedNames().contains(Properties.AnimationProperty))
{
float time = Animation.getWorldTime(getWorld(), partialTick);
Pair<IModelState, Iterable<Event>> pair = te.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null).apply(time);
// handleEvents(te, time, pair.getRight());
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(exState.getClean());
exState = exState.with(Properties.AnimationProperty, pair.getLeft());
worldRenderer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ());
blockRenderer.getBlockModelRenderer().renderModel(world, model, exState, pos, worldRenderer, false);
}
}
// End inline AnimationTESR.renderTileEntityFast
worldRenderer.setTranslation(0, 0, 0);
tessellator.draw();
RenderHelper.enableStandardItemLighting();
}
}
@@ -27,7 +27,10 @@ public final class SkyblockRenderEvents {
@SubscribeEvent
public static void onRender(RenderWorldLastEvent event) {
World world = Minecraft.getInstance().world;
if(ConfigHandler.CLIENT.enableFancySkybox.get() && world.getDimension().getType() == DimensionType.OVERWORLD && (ConfigHandler.enableFancySkyboxInNormalWorlds || WorldTypeSkyblock.isWorldSkyblock(Minecraft.getInstance().world))) {
if(ConfigHandler.CLIENT.enableFancySkybox.get()
&& world.getDimension().getType() == DimensionType.OVERWORLD
&& (ConfigHandler.CLIENT.enableFancySkyboxInNormalWorlds.get()
|| WorldTypeSkyblock.isWorldSkyblock(world))) {
if(!(world.getDimension().getSkyRenderer() instanceof SkyblockSkyRenderer))
world.getDimension().setSkyRenderer(new SkyblockSkyRenderer());
}
@@ -70,7 +70,7 @@ public class BlockAltGrass extends BlockMod implements ILexiconable {
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
public boolean onBlockActivated(IBlockState state, World world, BlockPos pos, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack held = player.getHeldItem(hand);
if(held.getItem() instanceof ItemHoe && world.isAirBlock(pos.up())) {
held.damageItem(1, player);
@@ -86,11 +86,10 @@ public class BlockAltGrass extends BlockMod implements ILexiconable {
if(!world.isRemote && state.getBlock() == this && world.getLight(pos.up()) >= 9) {
for(int l = 0; l < 4; ++l) {
BlockPos pos1 = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1);
BlockPos pos1up = pos1.up();
world.getBlockState(pos1.up()).getBlock();
if(world.getBlockState(pos1).getBlock() == Blocks.DIRT && world.getLight(pos1.up()) >= 4 && world.getBlockLightOpacity(pos1.up()) <= 2)
world.setBlockState(pos1, getDefaultState(), 1 | 2);
if(world.getBlockState(pos1).getBlock() == Blocks.DIRT && world.getLight(pos1up) >= 4 && world.getBlockState(pos1up).getOpacity(world, pos1up) <= 2)
world.setBlockState(pos1, getDefaultState());
}
}
}
@@ -119,7 +118,7 @@ public class BlockAltGrass extends BlockMod implements ILexiconable {
break;
case SCORCHED:
if(r.nextInt(80) == 0)
world.spawnParticle(Particles.FLAME, pos.getX() + r.nextFloat(), pos.getY() + 1.1, pos.getZ() + r.nextFloat(), 0, 0, 0);
world.addParticle(Particles.FLAME, pos.getX() + r.nextFloat(), pos.getY() + 1.1, pos.getZ() + r.nextFloat(), 0, 0, 0);
break;
case INFUSED:
if(r.nextInt(100) == 0)
@@ -31,6 +31,7 @@ import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
@@ -139,7 +140,7 @@ public class BlockAltar extends BlockMod implements ILexiconable {
if(stack.getItem() == ModItems.waterRod)
ManaItemHandler.requestManaExact(stack, player, ItemWaterRod.COST, true);
else if(!player.abilities.isCreativeMode)
player.setHeldItem(hand, drain(FluidRegistry.WATER, stack));
player.setHeldItem(hand, new ItemStack(Items.BUCKET) /* todo 1.13 drain(FluidRegistry.WATER, stack) */);
tile.setWater(true);
world.updateComparatorOutputLevel(pos, this);
@@ -149,7 +150,7 @@ public class BlockAltar extends BlockMod implements ILexiconable {
return true;
} else if(!stack.isEmpty() && stack.getItem() == Items.LAVA_BUCKET) {
if(!player.abilities.isCreativeMode)
player.setHeldItem(hand, drain(FluidRegistry.LAVA, stack));
player.setHeldItem(hand, new ItemStack(Items.BUCKET) /* todo 1.13 drain(FluidRegistry.LAVA, stack) */);
tile.setLava(true);
tile.setWater(false);
@@ -196,25 +197,26 @@ public class BlockAltar extends BlockMod implements ILexiconable {
if(stack.isEmpty() || stack.getCount() != 1)
return false;
if(stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
IFluidHandler handler = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
LazyOptional<IFluidHandlerItem> cap = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY);
if(cap.isPresent()) {
IFluidHandler handler = cap.orElseThrow(IllegalStateException::new);
/* todo 1.13
FluidStack simulate = handler.drain(new FluidStack(FluidRegistry.WATER, Fluid.BUCKET_VOLUME), false);
if(simulate != null && simulate.getFluid() == FluidRegistry.WATER && simulate.amount == Fluid.BUCKET_VOLUME)
return true;
*/
}
return false;
}
private ItemStack drain(Fluid fluid, ItemStack stack) {
IFluidHandlerItem handler = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
handler.drain(new FluidStack(fluid, Fluid.BUCKET_VOLUME), true);
return handler.getContainer();
}
@Override
public boolean isOpaqueCube(IBlockState state) {
return false;
return stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY)
.map(handler -> {
handler.drain(new FluidStack(fluid, Fluid.BUCKET_VOLUME), true);
return handler.getContainer();
})
.orElse(stack);
}
@Override
@@ -229,7 +231,7 @@ public class BlockAltar extends BlockMod implements ILexiconable {
@Nonnull
@Override
public TileEntity createTileEntity(@Nonnull World world, @Nonnull IBlockState state) {
public TileEntity createTileEntity(@Nonnull IBlockState state, @Nonnull IBlockReader world) {
return new TileAltar();
}
@@ -116,9 +116,9 @@ public class BlockSparkChanger extends BlockMod implements ILexiconable {
public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos) {
TileSparkChanger changer = (TileSparkChanger) world.getTileEntity(pos);
ItemStack stack = changer.getItemHandler().getStackInSlot(0);
if(stack.isEmpty())
return 0;
return stack.getItemDamage() + 1;
if(!stack.isEmpty() && stack.getItem() instanceof ItemSparkUpgrade)
return ((ItemSparkUpgrade) stack.getItem()).type.ordinal() + 1;
return 0;
}
@Override
@@ -127,6 +127,7 @@ public class BlockSpecialFlower extends BlockFlower implements ISpecialFlower, I
return SHAPE.withOffset(shift.x, shift.y, shift.z);
}
/* todo 1.13
@Nonnull
@Override
public IExtendedBlockState getExtendedState(@Nonnull IBlockState state, IBlockReader world, BlockPos pos) {
@@ -139,6 +140,7 @@ public class BlockSpecialFlower extends BlockFlower implements ISpecialFlower, I
return (IExtendedBlockState) state;
}
}
*/
@Override
public int getLightValue(@Nonnull IBlockState state, IWorldReader world, @Nonnull BlockPos pos) {
@@ -56,7 +56,7 @@ public class BlockBuriedPetals extends BlockModFlower {
@OnlyIn(Dist.CLIENT)
@Override
public void animateTick(IBlockState state, World world, BlockPos pos, Random rand) {
int hex = color.getColorValue();
int hex = color.colorValue;
int r = (hex & 0xFF0000) >> 16;
int g = (hex & 0xFF00) >> 8;
int b = hex & 0xFF;
@@ -33,7 +33,7 @@ public class BehaviourCocoaBeans extends BehaviorDefaultDispenseItem {
BlockPos pos = source.getBlockPos().offset(facing);
World world = source.getWorld();
IBlockState cocoa = block.getStateForPlacement(new BlockItemUseContext(world, null, ItemStack.EMPTY, pos, facing.getOpposite(), 0, 0, 0));
IBlockState cocoa = block.getStateForPlacement(new BlockItemUseContext(world, null, stack, pos, facing.getOpposite(), 0, 0, 0));
if(cocoa != null && world.isAirBlock(pos)) {
world.setBlockState(pos, cocoa);
stack.shrink(1);
@@ -30,18 +30,18 @@ public class BehaviourSeeds extends BehaviorDefaultDispenseItem {
@Nonnull
@Override
public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) {
EnumFacing facing = par1IBlockSource.getBlockState().get(BlockDispenser.FACING);
BlockPos pos = par1IBlockSource.getBlockPos().offset(facing);
World world = par1IBlockSource.getWorld();
public ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
EnumFacing facing = source.getBlockState().get(BlockDispenser.FACING);
BlockPos pos = source.getBlockPos().offset(facing);
World world = source.getWorld();
if(world.isAirBlock(pos) && block.canPlaceBlockAt(world, pos)) {
if(world.isAirBlock(pos) && block.getDefaultState().isValidPosition(world, pos)) {
world.setBlockState(pos, block.getDefaultState());
par2ItemStack.shrink(1);
return par2ItemStack;
stack.shrink(1);
return stack;
}
return super.dispenseStack(par1IBlockSource, par2ItemStack);
return super.dispenseStack(source, stack);
}
}
@@ -30,7 +30,7 @@ public class SeedBehaviours {
BlockDispenser.registerDispenseBehavior(Items.BEETROOT_SEEDS, new BehaviourSeeds(Blocks.BEETROOTS));
BlockDispenser.registerDispenseBehavior(Blocks.CHORUS_FLOWER, new BehaviourSeeds(Blocks.CHORUS_FLOWER));
BlockDispenser.registerDispenseBehavior(Items.COCOA_BEANS, new BehaviourCocoaBeans(BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.getObject(Items.DYE)));
BlockDispenser.registerDispenseBehavior(Items.COCOA_BEANS, new BehaviourCocoaBeans());
}
}
@@ -80,7 +80,7 @@ public class BlockForestDrum extends BlockMod implements IManaTrigger, ILexicona
if(burst.isFake())
return;
if(world.isRemote) {
world.spawnParticle(Particles.NOTE, pos.getX() + 0.5, pos.getY() + 1.2, pos.getZ() + 0.5D, 1.0 / 24.0, 0, 0);
world.addParticle(Particles.NOTE, pos.getX() + 0.5, pos.getY() + 1.2, pos.getZ() + 0.5D, 1.0 / 24.0, 0, 0);
return;
}
if(variant == Variant.WILD)
@@ -18,6 +18,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -45,7 +46,7 @@ public class BlockManaVoid extends BlockMod implements ILexiconable, IPoolOverla
@Nonnull
@Override
public TileEntity createTileEntity(@Nonnull World world, @Nonnull IBlockState state) {
public TileEntity createTileEntity(@Nonnull IBlockState state, @Nonnull IBlockReader world) {
return new TileManaVoid();
}
@@ -42,7 +42,6 @@ public class BlockRuneAltar extends BlockMod implements IWandable, ILexiconable
public BlockRuneAltar(Properties builder) {
super(builder);
BotaniaAPI.blacklistBlockFromMagnet(this, Short.MAX_VALUE);
}
@Nonnull
@@ -46,13 +46,13 @@ public class SubTileJadedAmaranthus extends SubTileFunctional {
for(int i = 0; i < RANGE * 2; i++) {
IBlockState stateAbove = supertile.getWorld().getBlockState(up);
Block blockAbove = stateAbove.getBlock();
if((supertile.getWorld().isAirBlock(up) || blockAbove.isReplaceable(supertile.getWorld(), up)) && stateAbove.getMaterial() != Material.WATER && ModBlocks.flower.canPlaceBlockAt(supertile.getWorld(), up)) {
EnumDyeColor color = EnumDyeColor.byId(supertile.getWorld().rand.nextInt(16));
IBlockState state = ModBlocks.getFlower(color).getDefaultState();
EnumDyeColor color = EnumDyeColor.byId(supertile.getWorld().rand.nextInt(16));
IBlockState flower = ModBlocks.getFlower(color).getDefaultState();
if((supertile.getWorld().isAirBlock(up) || stateAbove.getMaterial() != Material.WATER && flower.isValidPosition(supertile.getWorld(), up))) {
if(ConfigHandler.COMMON.blockBreakParticles.get())
supertile.getWorld().playEvent(2001, up, Block.getStateId(state));
supertile.getWorld().setBlockState(up, state, 1 | 2);
supertile.getWorld().playEvent(2001, up, Block.getStateId(flower));
supertile.getWorld().setBlockState(up, flower);
mana -= COST;
sync();
@@ -92,10 +92,11 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary,
return true;
}
boolean hasFluidCapability = stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
boolean hasFluidCapability = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY).isPresent();
if(!hasWater() && !hasLava()) {
if(hasFluidCapability) {
/* todo 1.13
IFluidHandlerItem fluidHandler = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
FluidStack drainWater = fluidHandler.drain(new FluidStack(FluidRegistry.WATER, Fluid.BUCKET_VOLUME), false);
@@ -114,6 +115,7 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary,
item.setItem(fluidHandler.getContainer());
return true;
}
*/
}
return false;
@@ -19,6 +19,7 @@ import javax.annotation.Nonnull;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.item.EntityEnderPearl;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
@@ -49,6 +50,7 @@ import vazkii.botania.common.core.handler.ModSounds;
import vazkii.botania.common.core.helper.PlayerHelper;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.lib.LibBlockNames;
import vazkii.botania.common.lib.LibEntityNames;
import vazkii.botania.common.lib.LibMisc;
public class TileLightRelay extends TileMod implements ITickable, IWandBindable {
@@ -243,7 +245,8 @@ public class TileLightRelay extends TileMod implements ITickable, IWandBindable
}
public static class EntityPlayerMover extends Entity {
@ObjectHolder(LibMisc.MOD_ID + ":player_mover")
public static EntityType<EntityPlayerMover> TYPE;
private static final String TAG_EXIT_X = "exitX";
private static final String TAG_EXIT_Y = "exitY";
private static final String TAG_EXIT_Z = "exitZ";
@@ -251,7 +254,7 @@ public class TileLightRelay extends TileMod implements ITickable, IWandBindable
public EntityPlayerMover(World world) {
super(world);
super(TYPE, world);
setSize(0F, 0F);
noClip = true;
}
@@ -13,6 +13,7 @@ package vazkii.botania.common.block.tile;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.init.Particles;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.MobSpawnerBaseLogic;
@@ -49,29 +50,29 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, ITickable
TileEntityMobSpawner spawner = (TileEntityMobSpawner) tileBelow;
MobSpawnerBaseLogic logic = spawner.getSpawnerBaseLogic();
BlockPos blockpos = logic.getSpawnerPosition();
// Directly drawn from MobSpawnerBaseLogic, with inverted isActivated check and mana consumption
if(!logic.isActivated()) {
if(!world.isRemote)
mana -= 6;
if(logic.getWorld().isRemote) {
if(logic.spawnDelay > 0) {
--logic.spawnDelay;
}
// [VanillaCopy] MobSpawnBaseLogic.tick, edits noted
if (!logic.isActivated()) { // Botania - invert activated check
BlockPos blockpos = logic.getSpawnerPosition();
if (this.getWorld().isRemote) {
// Botania - use own particles
if(Math.random() > 0.5)
Botania.proxy.wispFX(getPos().getX() + 0.3 + Math.random() * 0.5, getPos().getY() - 0.3 + Math.random() * 0.25, getPos().getZ() + Math.random(), 0.6F - (float) Math.random() * 0.3F, 0.1F, 0.6F - (float) Math.random() * 0.3F, (float) Math.random() / 3F, -0.025F - 0.005F * (float) Math.random(), 2F);
if (logic.spawnDelay > 0) {
--logic.spawnDelay;
}
logic.prevMobRotation = logic.mobRotation;
logic.mobRotation = (logic.mobRotation + (double) (1000.0F / ((float) logic.spawnDelay + 200.0F))) % 360.0D;
logic.mobRotation = (logic.mobRotation + (double)(1000.0F / ((float)logic.spawnDelay + 200.0F))) % 360.0D;
} else {
if(logic.spawnDelay == -1) {
// Botania - consume mana
this.mana -= 6;
if (logic.spawnDelay == -1) {
logic.resetTimer();
}
if(logic.spawnDelay > 0) {
if (logic.spawnDelay > 0) {
--logic.spawnDelay;
return;
}
@@ -80,38 +81,35 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, ITickable
for(int i = 0; i < logic.spawnCount; ++i) {
NBTTagCompound nbttagcompound = logic.spawnData.getNbt();
NBTTagList nbttaglist = nbttagcompound.getTagList("Pos", 6);
World world = logic.getSpawnerWorld();
int j = nbttaglist.tagCount();
double d0 = j >= 1 ? nbttaglist.getDoubleAt(0) : (double) blockpos.getX() + (world.rand.nextDouble() - world.rand.nextDouble()) * (double) logic.spawnRange + 0.5D;
double d1 = j >= 2 ? nbttaglist.getDoubleAt(1) : (double) (blockpos.getY() + world.rand.nextInt(3) - 1);
double d2 = j >= 3 ? nbttaglist.getDoubleAt(2) : (double) blockpos.getZ() + (world.rand.nextDouble() - world.rand.nextDouble()) * (double) logic.spawnRange + 0.5D;
NBTTagList nbttaglist = nbttagcompound.getList("Pos", 6);
World world = logic.getWorld();
int j = nbttaglist.size();
double d0 = j >= 1 ? nbttaglist.getDouble(0) : (double)blockpos.getX() + (world.rand.nextDouble() - world.rand.nextDouble()) * (double)logic.spawnRange + 0.5D;
double d1 = j >= 2 ? nbttaglist.getDouble(1) : (double)(blockpos.getY() + world.rand.nextInt(3) - 1);
double d2 = j >= 3 ? nbttaglist.getDouble(2) : (double)blockpos.getZ() + (world.rand.nextDouble() - world.rand.nextDouble()) * (double)logic.spawnRange + 0.5D;
Entity entity = AnvilChunkLoader.readWorldEntityPos(nbttagcompound, world, d0, d1, d2, false);
if(entity == null) {
return;
}
int k = world.getEntitiesWithinAABB(entity.getClass(), (new AxisAlignedBB((double) blockpos.getX(), (double) blockpos.getY(), (double) blockpos.getZ(), (double) (blockpos.getX() + 1), (double) (blockpos.getY() + 1), (double) (blockpos.getZ() + 1))).grow((double) logic.spawnRange)).size();
if(k >= logic.maxNearbyEntities) {
if (entity == null) {
logic.resetTimer();
return;
}
EntityLiving entityliving = entity instanceof EntityLiving ? (EntityLiving) entity : null;
entity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, world.rand.nextFloat() * 360.0F, 0.0F);
int k = world.getEntitiesWithinAABB(entity.getClass(), (new AxisAlignedBB((double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ(), (double)(blockpos.getX() + 1), (double)(blockpos.getY() + 1), (double)(blockpos.getZ() + 1))).grow((double)logic.spawnRange)).size();
if (k >= logic.maxNearbyEntities) {
logic.resetTimer();
return;
}
if(entityliving == null || net.minecraftforge.event.ForgeEventFactory.canEntitySpawnSpawner(entityliving, world, (float) entity.posX, (float) entity.posY, (float) entity.posZ)) {
if(logic.spawnData.getNbt().getSize() == 1 && logic.spawnData.getNbt().hasKey("id", 8) && entity instanceof EntityLiving) {
if(!net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(entityliving, logic.getSpawnerWorld(), (float) entity.posX, (float) entity.posY, (float) entity.posZ))
((EntityLiving) entity).onInitialSpawn(world.getDifficultyForLocation(new BlockPos(entity)), (IEntityLivingData) null);
EntityLiving entityliving = entity instanceof EntityLiving ? (EntityLiving)entity : null;
entity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, world.rand.nextFloat() * 360.0F, 0.0F);
if (entityliving == null || net.minecraftforge.event.ForgeEventFactory.canEntitySpawnSpawner(entityliving, getWorld(), (float)entity.posX, (float)entity.posY, (float)entity.posZ, logic)) {
if (logic.spawnData.getNbt().size() == 1 && logic.spawnData.getNbt().contains("id", 8) && entity instanceof EntityLiving) {
if (!net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(entityliving, logic.getWorld(), (float)entity.posX, (float)entity.posY, (float)entity.posZ, logic))
((EntityLiving)entity).onInitialSpawn(world.getDifficultyForLocation(new BlockPos(entity)), (IEntityLivingData)null, (NBTTagCompound)null);
}
AnvilChunkLoader.spawnEntity(entity, world);
world.playEvent(2004, blockpos, 0);
if(entityliving != null) {
if (entityliving != null) {
entityliving.spawnExplosionParticle();
}
@@ -119,7 +117,7 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, ITickable
}
}
if(flag) {
if (flag) {
logic.resetTimer();
}
}
@@ -129,7 +127,7 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, ITickable
@Override
public void writePacketNBT(NBTTagCompound cmp) {
cmp.setInt(TAG_MANA, mana);
cmp.putInt(TAG_MANA, mana);
}
@Override
@@ -56,7 +56,7 @@ public class TileBellows extends TileMod implements ITickable {
TilePool pool = (TilePool) tile;
boolean transfer = pool.isDoingTransfer;
if(transfer) {
if(pool.ticksDoingTransfer >= getBlockMetadata() * 2 - 2)
if(pool.ticksDoingTransfer > 0)
setActive(true);
disable = false;
}
@@ -87,9 +87,9 @@ public class TilePrism extends TileSimpleInventory {
if(world != null && !world.isRemote) {
IBlockState state = world.getBlockState(pos);
boolean hasLens = !itemHandler.getStackInSlot(0).isEmpty();
if (state.getBlock() != ModBlocks.prism || state.getValue(BotaniaStateProps.HAS_LENS) != hasLens) {
if (state.getBlock() != ModBlocks.prism || state.get(BotaniaStateProps.HAS_LENS) != hasLens) {
IBlockState base = state.getBlock() == ModBlocks.prism ? state : ModBlocks.prism.getDefaultState();
world.setBlockState(pos, base.withProperty(BotaniaStateProps.HAS_LENS, hasLens));
world.setBlockState(pos, base.with(BotaniaStateProps.HAS_LENS, hasLens));
}
}
}
@@ -525,11 +525,11 @@ public final class BotaniaCreativeTab extends ItemGroup {
}
private void addItem(Item item) {
item.getSubItems(this, list);
item.fillItemGroup(this, list);
}
private void addBlock(Block block) {
block.getSubBlocks(this, list);
block.fillItemGroup(this, list);
}
}
@@ -27,15 +27,15 @@ public class ModElvenTradeRecipes {
elementiumRecipes = new ArrayList<>();
elementiumRecipes.add(BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModItems.elementium), LibOreDict.MANA_STEEL, LibOreDict.MANA_STEEL));
elementiumRecipes.add(BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModBlocks.elementiumBlock), new ItemStack(ModBlocks.manasteelBlock), new ItemStack(ModBlocks.manasteelBlock)));
elementiumRecipes.add(BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModBlocks.elementiumBlock), Ingredient.fromItems(ModBlocks.manasteelBlock), Ingredient.fromItems(ModBlocks.manasteelBlock)));
pixieDustRecipe = BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModItems.pixieDust), LibOreDict.MANA_PEARL);
dragonstoneRecipes = new ArrayList<>();
dragonstoneRecipes.add(BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModItems.dragonstone), LibOreDict.MANA_DIAMOND));
dragonstoneRecipes.add(BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModBlocks.dragonstoneBlock), new ItemStack(ModBlocks.manaDiamondBlock)));
dragonstoneRecipes.add(BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModBlocks.dragonstoneBlock), Ingredient.fromItems(ModBlocks.manaDiamondBlock)));
elvenQuartzRecipe = BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModItems.elfQuartz), new ItemStack(Items.QUARTZ));
alfglassRecipe = BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModBlocks.elfGlass), new ItemStack(ModBlocks.manaGlass));
elvenQuartzRecipe = BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModItems.elfQuartz), Ingredient.fromItems(Items.QUARTZ));
alfglassRecipe = BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModBlocks.elfGlass), Ingredient.fromItems(ModBlocks.manaGlass));
BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Items.IRON_INGOT), Ingredient.fromItems(Items.IRON_INGOT));
BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Blocks.IRON_BLOCK), Ingredient.fromItems(Blocks.IRON_BLOCK));
@@ -14,8 +14,11 @@ import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.IRegistry;
import net.minecraftforge.common.Tags;
import net.minecraftforge.registries.ForgeRegistries;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.recipe.RecipeManaInfusion;
import vazkii.botania.common.Botania;
@@ -46,47 +49,47 @@ public final class ModManaInfusionRecipes {
public static void init() {
manasteelRecipes = new ArrayList<>();
manasteelRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaSteel), "ingotIron", 3000));
manasteelRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModBlocks.manasteelBlock), new ItemStack(Blocks.IRON_BLOCK), 27000));
manasteelRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaSteel), Ingredient.fromTag(Tags.Items.INGOTS_IRON), 3000));
manasteelRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModBlocks.manasteelBlock), Ingredient.fromItems(Blocks.IRON_BLOCK), 27000));
manaPearlRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaPearl), new ItemStack(Items.ENDER_PEARL), 6000);
manaPearlRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaPearl), Ingredient.fromItems(Items.ENDER_PEARL), 6000);
manaDiamondRecipes = new ArrayList<>();
manaDiamondRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaDiamond), "gemDiamond", 10000));
manaDiamondRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModBlocks.manaDiamondBlock), new ItemStack(Blocks.DIAMOND_BLOCK), 90000));
manaDiamondRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaDiamond), Ingredient.fromTag(Tags.Items.GEMS_DIAMOND), 10000));
manaDiamondRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModBlocks.manaDiamondBlock), Ingredient.fromItems(Blocks.DIAMOND_BLOCK), 90000));
manaPowderRecipes = new ArrayList<>();
manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaPowder), new ItemStack(Items.GUNPOWDER), 500));
manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaPowder), new ItemStack(Items.REDSTONE), 500));
manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaPowder), new ItemStack(Items.GLOWSTONE_DUST), 500));
manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaPowder), new ItemStack(Items.SUGAR), 500));
manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaPowder), Ingredient.fromItems(Items.GUNPOWDER), 500));
manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaPowder), Ingredient.fromItems(Items.REDSTONE), 500));
manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaPowder), Ingredient.fromItems(Items.GLOWSTONE_DUST), 500));
manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaPowder), Ingredient.fromItems(Items.SUGAR), 500));
for(Item dye : ModItems.dyes.values())
manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaPowder), new ItemStack(dye), 400));
manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaPowder), Ingredient.fromItems(dye), 400));
pistonRelayRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModBlocks.pistonRelay), new ItemStack(Blocks.PISTON), 15000);
manaCookieRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaCookie), new ItemStack(Items.COOKIE), 20000);
grassSeedsRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.grassSeeds), new ItemStack(Blocks.GRASS), 2500);
podzolSeedsRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.podzolSeeds), new ItemStack(Blocks.DEAD_BUSH), 2500);
pistonRelayRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModBlocks.pistonRelay), Ingredient.fromItems(Blocks.PISTON), 15000);
manaCookieRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaCookie), Ingredient.fromItems(Items.COOKIE), 20000);
grassSeedsRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.grassSeeds), Ingredient.fromItems(Blocks.GRASS), 2500);
podzolSeedsRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.podzolSeeds), Ingredient.fromItems(Blocks.DEAD_BUSH), 2500);
mycelSeedsRecipes = new ArrayList<>();
mycelSeedsRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.mycelSeeds), new ItemStack(Blocks.RED_MUSHROOM), 6500));
mycelSeedsRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.mycelSeeds), new ItemStack(Blocks.BROWN_MUSHROOM), 6500));
mycelSeedsRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.mycelSeeds), Ingredient.fromItems(Blocks.RED_MUSHROOM), 6500));
mycelSeedsRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.mycelSeeds), Ingredient.fromItems(Blocks.BROWN_MUSHROOM), 6500));
manaQuartzRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaQuartz), new ItemStack(Items.QUARTZ), 250);
tinyPotatoRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModBlocks.tinyPotato), new ItemStack(Items.POTATO), 1337);
manaQuartzRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaQuartz), Ingredient.fromItems(Items.QUARTZ), 250);
tinyPotatoRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModBlocks.tinyPotato), Ingredient.fromItems(Items.POTATO), 1337);
if(Botania.thaumcraftLoaded) {
Item inkwell = IRegistry.ITEM.get(new ResourceLocation("thaumcraft", "scribing_tools"));
manaInkwellRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaInkwell), new ItemStack(inkwell), 35000);
Item inkwell = ForgeRegistries.ITEMS.getValue(new ResourceLocation("thaumcraft", "scribing_tools"));
manaInkwellRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaInkwell), Ingredient.fromItems(inkwell), 35000);
}
managlassRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModBlocks.manaGlass), new ItemStack(Blocks.GLASS), 150);
manaStringRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaString), new ItemStack(Items.STRING), 5000);
managlassRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModBlocks.manaGlass), Ingredient.fromItems(Blocks.GLASS), 150);
manaStringRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaString), Ingredient.fromItems(Items.STRING), 5000);
if(Botania.gardenOfGlassLoaded)
sugarCaneRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(Blocks.SUGAR_CANE), new ItemStack(Blocks.HAY_BLOCK), 2000);
sugarCaneRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(Blocks.SUGAR_CANE), Ingredient.fromItems(Blocks.HAY_BLOCK), 2000);
BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaBottle), new ItemStack(Items.GLASS_BOTTLE), 5000);
BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaBottle), Ingredient.fromItems(Items.GLASS_BOTTLE), 5000);
}
}
@@ -12,6 +12,7 @@ package vazkii.botania.common.crafting.recipe;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraftforge.items.IItemHandler;
import vazkii.botania.api.recipe.RecipeRuneAltar;
@@ -21,7 +22,7 @@ public class HeadRecipe extends RecipeRuneAltar {
private String name = "";
public HeadRecipe(ItemStack output, int mana, Object... inputs) {
public HeadRecipe(ItemStack output, int mana, Ingredient... inputs) {
super(output, mana, inputs);
}
@@ -93,7 +93,7 @@ public class SpecialFloatingFlowerRecipe extends IRecipeHidden {
@Nonnull
@Override
public SpecialFloatingFlowerRecipe read(@Nonnull ResourceLocation recipeId, @Nonnull JsonObject json) {
ResourceLocation flowerType = new ResourceLocation(JsonUtils.getString(json, "type"));
ResourceLocation flowerType = new ResourceLocation(JsonUtils.getString(json, "flower_type"));
return new SpecialFloatingFlowerRecipe(recipeId, flowerType);
}
@@ -191,8 +191,7 @@ public class ItemAstrolabe extends ItemMod {
if(rtr != null) {
BlockPos pos = rtr.getBlockPos();
IBlockState state = player.world.getBlockState(pos);
Block block = state.getBlock();
if(block.isReplaceable(player.world, pos))
if(state.getMaterial().isReplaceable())
pos = pos.down();
int range = (getSize(stack) ^ 1) / 2;
@@ -39,6 +39,7 @@ import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.tile.TileCacophonium;
@@ -73,7 +74,7 @@ public class ItemCacophonium extends ItemMod {
sound = ((EntitySlime) living).isSmallSlime() ? SoundEvents.ENTITY_SLIME_SQUISH_SMALL : SoundEvents.ENTITY_SLIME_SQUISH;
else {
try {
sound = (SoundEvent) ReflectionHelper.findMethod(EntityLiving.class, LibObfuscation.GET_LIVING_SOUND[0], LibObfuscation.GET_LIVING_SOUND[1]).invoke(living);
sound = (SoundEvent) ObfuscationReflectionHelper.findMethod(EntityLiving.class, LibObfuscation.GET_LIVING_SOUND).invoke(living);
} catch (InvocationTargetException | IllegalAccessException ignored) {
Botania.LOGGER.debug("Couldn't get living sound");
}
@@ -585,6 +585,6 @@ public class ItemCraftingHalo extends ItemMod {
yoff += 12;
}
mc.fontRenderer.drawStringWithShadow(label, mc.mainWindow.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(label.getString()) / 2, mc.mainWindow.getScaledHeight() / 2 - yoff, 0xFFFFFF);
mc.fontRenderer.drawStringWithShadow(label.getFormattedText(), mc.mainWindow.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(label.getString()) / 2, mc.mainWindow.getScaledHeight() / 2 - yoff, 0xFFFFFF);
}
}
@@ -11,13 +11,16 @@
package vazkii.botania.common.item;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.IItemPropertyGetter;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
@@ -42,12 +45,14 @@ import net.minecraft.world.WorldServer;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.DistExecutor;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.ILexicon;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.KnowledgeType;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.recipe.IElvenItem;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
import vazkii.botania.common.Botania;
import vazkii.botania.common.advancements.UseItemSuccessTrigger;
import vazkii.botania.common.core.handler.ModSounds;
@@ -60,6 +65,7 @@ import vazkii.botania.common.lib.LibItemNames;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
@@ -72,6 +78,7 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
public ItemLexicon(Properties props) {
super(props);
addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "elven"), (stack, world, living) -> isElvenItem(stack) ? 1 : 0);
}
@Nonnull
@@ -183,7 +190,7 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
}
Botania.proxy.setLexiconStack(stack);
player.openGui(Botania.instance, LibGuiIDs.LEXICON, world, 0, 0, 0);
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> Minecraft.getInstance().displayGuiScreen(GuiLexicon.currentOpenLexicon));
if(!world.isRemote) {
if(!skipSound)
world.playSound(null, player.posX, player.posY, player.posZ, ModSounds.lexiconOpen, SoundCategory.PLAYERS, 0.5F, 1F);
@@ -261,20 +268,4 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
public boolean isElvenItem(ItemStack stack) {
return isKnowledgeUnlocked(stack, BotaniaAPI.elvenKnowledge);
}
@OnlyIn(Dist.CLIENT)
@Override
public void registerModels() {
// Load and bake the 2D models
ModelBakery.registerItemVariants(this,
new ModelResourceLocation("botania:lexicon_default", "inventory"),
new ModelResourceLocation("botania:lexicon_elven", "inventory"));
ModelResourceLocation default3dPath = new ModelResourceLocation("botania:lexicon_3d_default", "inventory");
ModelResourceLocation elven3dPath = new ModelResourceLocation("botania:lexicon_3d_elven", "inventory");
// smart model will dispatch between 2d/3d appropriately, see LexiconModel
ModelLoader.setCustomMeshDefinition(this, stack -> isElvenItem(stack) ? elven3dPath : default3dPath);
}
}
@@ -72,7 +72,7 @@ public class ItemSpawnerMover extends ItemMod {
if(tag != null && tag.contains(TAG_SPAWN_DATA)) {
tag = tag.getCompound(TAG_SPAWN_DATA);
if(tag.contains(TAG_ID)) {
return ResourceLocation.makeResourceLocation(tag.getString(TAG_ID));
return ResourceLocation.tryCreate(tag.getString(TAG_ID));
}
}
@@ -90,7 +90,7 @@ public class ItemSpawnerMover extends ItemMod {
if (id != null) {
EntityType<?> type = ForgeRegistries.ENTITIES.getValue(id);
if (type != null) {
infoList.add(type.func_212546_e());
infoList.add(type.getName());
}
}
}
@@ -83,7 +83,7 @@ public class ItemManasteelArmor extends ItemArmor implements IManaUsingItem, IPh
stack.setDamage(stack.getDamage() - 1);
}
@Override
// todo 1.13
public void damageArmor(EntityLivingBase entity, @Nonnull ItemStack stack, DamageSource source, int damage, int slot) {
ToolCommons.damageItem(stack, damage, entity, MANA_PER_DAMAGE);
}
@@ -57,7 +57,8 @@ public class ItemTerrasteelArmor extends ItemManasteelArmor {
Multimap<String, AttributeModifier> multimap = super.getAttributeModifiers(slot, stack);
UUID uuid = new UUID((getTranslationKey(stack) + slot.toString()).hashCode(), 0);
if (slot == armorType) {
multimap.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getName(), new AttributeModifier(uuid, "Terrasteel modifier " + type, (double) getArmorDisplay(null, new ItemStack(this), type.getIndex()) / 20, 0));
int reduction = material.getDamageReductionAmount(slot);
multimap.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getName(), new AttributeModifier(uuid, "Terrasteel modifier " + type, (double) reduction / 20, 0));
}
return multimap;
}
@@ -28,7 +28,7 @@ public class LensPiston extends Lens {
if(!entity.world.isRemote && pos.getBlockPos() != null && !coords.equals(pos.getBlockPos()) && !burst.isFake() && !isManaBlock) {
BlockPos pos_ = pos.getBlockPos().offset(pos.sideHit.getOpposite());
if(entity.world.isAirBlock(pos_) || entity.world.getBlockState(pos_).getBlock().isReplaceable(entity.world, pos_)) {
if(entity.world.isAirBlock(pos_) || entity.world.getBlockState(pos_).getMaterial().isReplaceable()) {
IBlockState state = entity.world.getBlockState(pos.getBlockPos());
TileEntity tile = entity.world.getTileEntity(pos.getBlockPos());
@@ -35,6 +35,7 @@ import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -238,6 +239,11 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
return !getState(stack).isAir();
}
public static ItemStack removeFromInventory(EntityPlayer player, LazyOptional<IItemHandler> inv, ItemStack stack, Block block, boolean doit) {
return inv.map(handler -> removeFromInventory(player, handler, stack, block, doit)).orElse(ItemStack.EMPTY);
}
public static ItemStack removeFromInventory(EntityPlayer player, IItemHandler inv, ItemStack stack, Block block, boolean doit) {
List<ItemStack> providers = new ArrayList<>();
for(int i = inv.getSlots() - 1; i >= 0; i--) {
@@ -286,6 +292,10 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
return count+baubleCount;
}
public static int getInventoryItemCount(EntityPlayer player, LazyOptional<IItemHandler> inv, ItemStack stack, Block block) {
return inv.map(handler -> getInventoryItemCount(player, handler, stack, block)).orElse(0);
}
public static int getInventoryItemCount(EntityPlayer player, IItemHandler inv, ItemStack stack, Block block) {
if(player.abilities.isCreativeMode)
return -1;
@@ -116,7 +116,7 @@ public class ItemTerraformRod extends ItemMod implements IManaUsingItem, IBlockP
BlockPos pos_ = pos.offset(dir);
IBlockState state_ = world.getBlockState(pos_);
Block block_ = state_.getBlock();
if(state_.isAir(world, pos_) || block_.isReplaceable(state_, world, pos_)
if(state_.isAir(world, pos_) || state_.getMaterial().isReplaceable()
|| block_ instanceof BlockFlower && !(block_ instanceof ISpecialFlower)
|| block_ instanceof BlockDoublePlant) {
airBlocks.add(pos_);
@@ -127,7 +127,7 @@ public class ItemTerraformRod extends ItemMod implements IManaUsingItem, IBlockP
if(pos.getY() > startCenter.getY())
blocks.add(new CoordsWithBlock(pos, Blocks.AIR));
else for(BlockPos coords : airBlocks) {
if(world.getBlockState(coords.down()).getBlock() != Blocks.AIR)
if(!world.isAirBlock(coords.down()))
blocks.add(new CoordsWithBlock(coords, Blocks.DIRT));
}
}
@@ -14,6 +14,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -51,11 +52,8 @@ public class PageBrew extends PageRecipe implements ITwoNamedPage {
Brew brew = recipe.getBrew();
FontRenderer renderer = Minecraft.getInstance().fontRenderer;
boolean unicode = renderer.getUnicodeFlag();
renderer.setUnicodeFlag(true);
String s = TextFormatting.BOLD + I18n.format("botaniamisc.brewOf", I18n.format(brew.getUnlocalizedName()));
renderer.drawString(s, gui.getLeft() + gui.getWidth() / 2 - renderer.getStringWidth(s) / 2, y, 0x222222);
renderer.setUnicodeFlag(unicode);
PageText.renderText(x, y + 22, width, height, text);
ItemStack book = PlayerHelper.getFirstHeldItemClass(Minecraft.getInstance().player, ILexicon.class);
@@ -66,14 +64,11 @@ public class PageBrew extends PageRecipe implements ITwoNamedPage {
int i = 0;
y = gui.getTop() + gui.getHeight() - 54;
List<Object> inputs = new ArrayList<>(recipe.getInputs());
List<Ingredient> inputs = new ArrayList<>(recipe.getInputs());
int offset = gui.getWidth() / 2 - inputs.size() * 9;
for(Object input : inputs) {
if(input instanceof String)
input = OreDictionary.getOres((String) input).get(0);
renderItemAtLinePos(gui, offset, i, y, (ItemStack) input);
for(Ingredient input : inputs) {
renderItemAtLinePos(gui, offset, i, y, input.getMatchingStacks()[0]);
i++;
}
@@ -14,6 +14,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.item.crafting.Ingredient;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
@@ -69,20 +70,18 @@ public class PagePetalRecipe<T extends RecipePetals> extends PageRecipe {
renderItemAtGridPos(gui, 3, 0, recipe.getOutput(), false);
renderItemAtGridPos(gui, 2, 1, getMiddleStack(), false);
List<Object> inputs = recipe.getInputs();
List<Ingredient> inputs = recipe.getInputs();
int degreePerInput = (int) (360F / inputs.size());
float currentDegree = ConfigHandler.CLIENT.lexiconRotatingItems.get() ? GuiScreen.isShiftKeyDown() ? ticksElapsed : ticksElapsed + ClientTickHandler.partialTicks : 0;
int inputIndex = ticksElapsed / 40;
for(Object obj : inputs) {
Object input = obj;
if(input instanceof String) {
NonNullList<ItemStack> list = OreDictionary.getOres((String) input);
int size = list.size();
input = list.get(size - inputIndex % size - 1);
}
for(Ingredient input : inputs) {
ItemStack[] stacks = input.getMatchingStacks();
int size = stacks.length;
ItemStack stack = stacks[size - inputIndex % size - 1];
// todo 1.13 can't we just use inputIndex % size?
renderItemAtAngle(gui, currentDegree, (ItemStack) input);
renderItemAtAngle(gui, currentDegree, stack);
currentDegree += degreePerInput;
}
@@ -11,6 +11,6 @@
package vazkii.botania.common.lib;
public final class LibObfuscation {
// Entityliving
public static final String[] GET_LIVING_SOUND = { "getAmbientSound", "func_184639_G", "G" };
// EntityLiving
public static final String GET_LIVING_SOUND = "func_184639_G";
}