Merge branch '1.12' of github.com:Vazkii/Botania into 1.12

This commit is contained in:
Vincent Lee committed 2017-08-15 15:10:50 -05:00
commit 679ebb19be
49 files changed
+214 -64

No files matched your search

@@ -8,34 +8,21 @@
*/
package vazkii.botania.client.core.handler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.launchwrapper.Launch;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.event.entity.player.ArrowLooseEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.client.model.FloatingFlowerModel;
import vazkii.botania.client.model.GunModel;
import vazkii.botania.client.model.LexiconModel;
import vazkii.botania.client.model.PlatformModel;
import vazkii.botania.common.Botania;
import vazkii.botania.common.item.ItemSparkUpgrade;
import vazkii.botania.common.item.equipment.bauble.ItemFlightTiara;
import vazkii.botania.common.item.relic.ItemKingKey;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.nio.IntBuffer;
import vazkii.botania.common.lib.LibMisc;
public class MiscellaneousIcons {
@@ -98,7 +85,10 @@ public class MiscellaneousIcons {
evt.getModelRegistry().putObject(new ModelResourceLocation("botania:platform", "normal"), new PlatformModel());
// Lexicon
evt.getModelRegistry().putObject(new ModelResourceLocation("botania:lexicon", "inventory"), new LexiconModel());
evt.getModelRegistry().putObject(new ModelResourceLocation("botania:lexicon_3d_default", "inventory"),
new LexiconModel(new ModelResourceLocation("botania:lexicon_default", "inventory")));
evt.getModelRegistry().putObject(new ModelResourceLocation("botania:lexicon_3d_elven", "inventory"),
new LexiconModel(new ModelResourceLocation("botania:lexicon_elven", "inventory")));
// Mana Blaster
ModelResourceLocation key = new ModelResourceLocation("botania:manaGun", "inventory");
@@ -21,6 +21,7 @@ import net.minecraftforge.client.model.obj.OBJLoader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.registries.IRegistryDelegate;
import vazkii.botania.api.BotaniaAPIClient;
import vazkii.botania.api.item.IFloatingFlower;
@@ -48,7 +49,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.function.IntFunction;
@Mod.EventBusSubscriber
@Mod.EventBusSubscriber(Side.CLIENT)
public final class ModelHandler {
@SubscribeEvent
public static void registerModels(ModelRegistryEvent evt) {
@@ -28,7 +28,8 @@ import vazkii.botania.common.lexicon.page.PageText;
@Mod.EventBusSubscriber(Side.CLIENT)
public class RenderLexicon {
private static final ModelBook model = new ModelBook();
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_LEXICA);
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_LEXICA_DEFAULT);
private static final ResourceLocation elvenTexture = new ResourceLocation(LibResources.MODEL_LEXICA_ELVEN);
private static final String[] QUOTES = new String[] {
"\"Neat!\" - Direwolf20",
@@ -78,7 +79,7 @@ public class RenderLexicon {
Minecraft mc = Minecraft.getMinecraft();
GlStateManager.pushMatrix();
mc.renderEngine.bindTexture(texture);
mc.renderEngine.bindTexture(((ItemLexicon) ModItems.lexicon).isElvenItem(stack) ? elvenTexture : texture);
float opening;
float pageFlip;
@@ -10,7 +10,9 @@
*/
package vazkii.botania.client.core.helper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.resources.SimpleReloadableResourceManager;
import org.lwjgl.opengl.ARBFragmentShader;
import org.lwjgl.opengl.ARBShaderObjects;
import org.lwjgl.opengl.ARBVertexShader;
@@ -43,6 +45,32 @@ public final class ShaderHelper {
public static int categoryButton = 0;
public static int alpha = 0;
private static void deleteShader(int id) {
if (id != 0) {
ARBShaderObjects.glDeleteObjectARB(id);
}
}
public static void registerReloadListener() {
if (Minecraft.getMinecraft().getResourceManager() instanceof SimpleReloadableResourceManager) {
((SimpleReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(manager -> {
deleteShader(pylonGlow); pylonGlow = 0;
deleteShader(enchanterRune); enchanterRune = 0;
deleteShader(manaPool); manaPool = 0;
deleteShader(doppleganger); doppleganger = 0;
deleteShader(halo); halo = 0;
deleteShader(dopplegangerBar); dopplegangerBar = 0;
deleteShader(terraPlateRune); terraPlateRune = 0;
deleteShader(filmGrain); filmGrain = 0;
deleteShader(gold); gold = 0;
deleteShader(categoryButton); categoryButton = 0;
deleteShader(alpha); alpha = 0;
initShaders();
});
}
}
public static void initShaders() {
if(!useShaders())
return;
@@ -236,6 +236,7 @@ public class ClientProxy implements IProxy {
RenderingRegistry.registerEntityRenderingHandler(EntityEnderAirBottle.class, renderManager -> new RenderSnowballStack<>(renderManager, ModItems.manaResource, Minecraft.getMinecraft().getRenderItem(), entity -> new ItemStack(ModItems.manaResource, 1, 15)));
ShaderHelper.initShaders();
ShaderHelper.registerReloadListener();
}
private void initAuxiliaryRender() {
@@ -210,22 +210,26 @@ public class FXSparkle extends Particle {
float f = rand.nextFloat() * 0.05F + 0.025F; // Botania - made multiplier and add both smaller
float f1 = enumfacing.getAxisDirection().getOffset();
float secondary = (rand.nextFloat() - rand.nextFloat()) * 0.1F; // Botania - Make and use a secondary movement variable below
float secondary = (rand.nextFloat() - rand.nextFloat()) * 0.1F; // Botania - Make and use secondary movement variables below
float secondary2 = (rand.nextFloat() - rand.nextFloat()) * 0.1F;
if (enumfacing.getAxis() == EnumFacing.Axis.X)
{
motionX = f1 * f;
motionY = motionZ = secondary;
motionY = secondary;
motionZ = secondary2;
}
else if (enumfacing.getAxis() == EnumFacing.Axis.Y)
{
motionY = f1 * f;
motionX = motionZ = secondary;
motionX = secondary;
motionZ = secondary2;
}
else if (enumfacing.getAxis() == EnumFacing.Axis.Z)
{
motionZ = f1 * f;
motionX = motionY = secondary;
motionX = secondary;
motionY = secondary2;
}
return true;
@@ -77,7 +77,8 @@ public final class LibResources {
public static final String MODEL_PYLON_GREEN = PREFIX_MODEL + "pylon1.png";
public static final String MODEL_PYLON_PINK_OLD = PREFIX_MODEL + "pylonOld2.png";
public static final String MODEL_PYLON_PINK = PREFIX_MODEL + "pylon2.png";
public static final String MODEL_LEXICA = PREFIX_MODEL + "lexica.png";
public static final String MODEL_LEXICA_DEFAULT = PREFIX_MODEL + "lexica0.png";
public static final String MODEL_LEXICA_ELVEN = PREFIX_MODEL + "lexica1.png";
public static final String MODEL_MANASTEEL_0 = PREFIX_MODEL + "manasteel0.png";
public static final String MODEL_MANASTEEL_1 = PREFIX_MODEL + "manasteel1.png";
public static final String MODEL_MANASTEEL_2 = PREFIX_MODEL + "manasteel2.png";
@@ -17,18 +17,21 @@ import javax.annotation.Nonnull;
import javax.vecmath.Matrix4f;
import java.util.List;
@SuppressWarnings("deprecation")
public class LexiconModel implements IBakedModel {
private final ModelResourceLocation path2D;
private static final ModelResourceLocation path = new ModelResourceLocation("botania:lexicon_default", "inventory");
public LexiconModel(ModelResourceLocation path) {
this.path2D = path;
}
@Nonnull
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) {
IBakedModel original = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelManager().getModel(path);
if((cameraTransformType == ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND
|| cameraTransformType == ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND)
&& ConfigHandler.lexicon3dModel)
return Pair.of(this, null);
IBakedModel original = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelManager().getModel(path2D);
return original.handlePerspective(cameraTransformType);
}
@@ -37,6 +40,6 @@ public class LexiconModel implements IBakedModel {
@Override public boolean isGui3d() { return false; }
@Override public boolean isBuiltInRenderer() { return false; }
@Nonnull @Override public TextureAtlasSprite getParticleTexture() { return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("botania:items/lexicon"); }
@Nonnull @Override public ItemCameraTransforms getItemCameraTransforms() { return ItemCameraTransforms.DEFAULT; }
@SuppressWarnings("deprecation") @Nonnull @Override public ItemCameraTransforms getItemCameraTransforms() { return ItemCameraTransforms.DEFAULT; }
@Nonnull @Override public ItemOverrideList getOverrides() { return ItemOverrideList.NONE; }
}
@@ -10,7 +10,6 @@
*/
package vazkii.botania.common.block.decor;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
@@ -32,11 +31,6 @@ public class BlockElfGlass extends BlockManaGlass implements IElvenItem, ILexico
return true;
}
@Override
public boolean isFullBlock(IBlockState state) {
return true;
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, EntityPlayer player, ItemStack lexicon) {
return LexiconData.elvenResources;
@@ -50,8 +50,8 @@ public class BlockManaGlass extends BlockMod implements ILexiconable {
}
@Override
public boolean isFullBlock(IBlockState state) {
return true;
public boolean isFullCube(IBlockState state) {
return false;
}
@SideOnly(Side.CLIENT)
@@ -132,11 +132,11 @@ public class TileTerraPlate extends TileMod implements ISparkAttachable {
return false;
int meta = stack.getItemDamage();
if(meta == 0)
if(meta == 17)
ingot = stack;
else if(meta == 1)
else if(meta == 24)
pearl = stack;
else if(meta == 2)
else if(meta == 25)
diamond = stack;
else return false;
}
@@ -259,7 +259,7 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
@Override
public boolean processInitialInteract(EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if(!stack.isEmpty()) {
if(!isDead && !stack.isEmpty()) {
if(player.world.isRemote) {
boolean valid = stack.getItem() == ModItems.twigWand || stack.getItem() == ModItems.dye || stack.getItem() == ModItems.phantomInk;
if(valid)
@@ -239,7 +239,7 @@ public class EntitySpark extends Entity implements ISparkEntity {
@Override
public boolean processInitialInteract(EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if(!stack.isEmpty()) {
if(!isDead && !stack.isEmpty()) {
if(world.isRemote) {
boolean valid = stack.getItem() == ModItems.twigWand || stack.getItem() == ModItems.sparkUpgrade
|| stack.getItem() == ModItems.phantomInk;
@@ -263,8 +263,16 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
@SideOnly(Side.CLIENT)
@Override
public void registerModels() {
ModelBakery.registerItemVariants(this, new ModelResourceLocation("botania:lexicon_default", "inventory"));
ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(getRegistryName(), "inventory"));
// 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);
}
}
@@ -445,6 +445,8 @@ public final class ModItems {
OreDictionary.registerOre(LibOreDict.PEBBLE, new ItemStack(manaResource, 1, 21));
OreDictionary.registerOre(LibOreDict.MANAWEAVE_CLOTH, new ItemStack(manaResource, 1, 22));
OreDictionary.registerOre(LibOreDict.MANA_POWDER, new ItemStack(manaResource, 1, 23));
OreDictionary.registerOre(LibOreDict.MANA_PEARL_SHARD, new ItemStack(manaResource, 1, 24));
OreDictionary.registerOre(LibOreDict.MANA_DIAMOND_CHUNK, new ItemStack(manaResource, 1, 25));
OreDictionary.registerOre(LibOreDict.VIAL, new ItemStack(vial, 1, 0));
OreDictionary.registerOre(LibOreDict.FLASK, new ItemStack(vial, 1, 1));
@@ -10,6 +10,7 @@
*/
package vazkii.botania.common.item.material;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
@@ -23,6 +24,7 @@ import net.minecraft.util.NonNullList;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@@ -38,13 +40,12 @@ import vazkii.botania.common.entity.EntityDoppleganger;
import vazkii.botania.common.entity.EntityEnderAirBottle;
import vazkii.botania.common.item.ItemMod;
import vazkii.botania.common.lib.LibItemNames;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class ItemManaResource extends ItemMod implements IFlowerComponent, IElvenItem {
final int types = 24;
public ItemManaResource() {
super(LibItemNames.MANA_RESOURCE);
setHasSubtypes(true);
@@ -117,7 +118,7 @@ public class ItemManaResource extends ItemMod implements IFlowerComponent, IElve
@Override
public void getSubItems(@Nonnull CreativeTabs tab, @Nonnull NonNullList<ItemStack> stacks) {
if(isInCreativeTab(tab)) {
for(int i = 0; i < types; i++) {
for(int i = 0; i < LibItemNames.MANA_RESOURCE_NAMES.length; i++) {
if("UNUSED".equals(LibItemNames.MANA_RESOURCE_NAMES[i]))
continue;
if(Botania.gardenOfGlassLoaded || i != 20 && i != 21)
@@ -129,7 +130,7 @@ public class ItemManaResource extends ItemMod implements IFlowerComponent, IElve
@Nonnull
@Override
public String getUnlocalizedName(ItemStack par1ItemStack) {
return "item." + LibItemNames.MANA_RESOURCE_NAMES[Math.min(types - 1, par1ItemStack.getItemDamage())];
return "item." + LibItemNames.MANA_RESOURCE_NAMES[Math.min(LibItemNames.MANA_RESOURCE_NAMES.length - 1, par1ItemStack.getItemDamage())];
}
@Override
@@ -158,7 +159,14 @@ public class ItemManaResource extends ItemMod implements IFlowerComponent, IElve
@SideOnly(Side.CLIENT)
@Override
public void registerModels() {
ModelHandler.registerItemMetas(this, LibItemNames.MANA_RESOURCE_NAMES.length, i -> LibItemNames.MANA_RESOURCE_NAMES[i]);
for(int i = 0; i < LibItemNames.MANA_RESOURCE_NAMES.length; i++) {
if("UNUSED".equals(LibItemNames.MANA_RESOURCE_NAMES[i]))
continue;
ModelLoader.setCustomModelResourceLocation(
this, i,
new ModelResourceLocation(LibMisc.MOD_ID + ":" + LibItemNames.MANA_RESOURCE_NAMES[i], "inventory")
);
}
}
}
@@ -68,10 +68,10 @@ public class PageTerrasteel extends PageRecipe {
renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8, gui.getTop() + 102, new ItemStack(block3), false);
GlStateManager.translate(0F, 0F, -10F);
renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8, gui.getTop() + 30, new ItemStack(ModItems.manaResource, 1, 4), false);
renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8, gui.getTop() + 80, new ItemStack(ModItems.manaResource, 1, 0), false);
renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 - 20, gui.getTop() + 86, new ItemStack(ModItems.manaResource, 1, 1), false);
renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 + 19, gui.getTop() + 86, new ItemStack(ModItems.manaResource, 1, 2), false);
renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8, gui.getTop() + 30, new ItemStack(ModItems.manaResource, 1, 18), false);
renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8, gui.getTop() + 80, new ItemStack(ModItems.manaResource, 1, 17), false);
renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 - 20, gui.getTop() + 86, new ItemStack(ModItems.manaResource, 1, 24), false);
renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 + 19, gui.getTop() + 86, new ItemStack(ModItems.manaResource, 1, 25), false);
Minecraft.getMinecraft().renderEngine.bindTexture(terrasteelOverlay);
@@ -84,13 +84,13 @@ public class PageTerrasteel extends PageRecipe {
@Override
public void onPageAdded(LexiconEntry entry, int index) {
LexiconRecipeMappings.map(new ItemStack(ModItems.manaResource, 1, 4), entry, index);
LexiconRecipeMappings.map(new ItemStack(ModItems.manaResource, 1, 18), entry, index);
}
@Override
public List<ItemStack> getDisplayedRecipes() {
ArrayList<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(ModItems.manaResource, 1, 4));
list.add(new ItemStack(ModItems.manaResource, 1, 18));
return list;
}
@@ -218,6 +218,8 @@ public final class LibItemNames {
"livingRoot",
"pebble",
"manaweaveCloth",
"manaPowder"
"manaPowder",
"manaPearlShard",
"manaDiamondChunk"
};
}
@@ -41,11 +41,12 @@ public final class LibOreDict {
public static final String PEBBLE = "pebble";
public static final String MANAWEAVE_CLOTH = "clothManaweave";
public static final String MANA_POWDER = "powderMana";
public static final String MANA_PEARL_SHARD = "shardManaPearl";
public static final String MANA_DIAMOND_CHUNK = "nuggetManaDiamond";
public static final String VIAL = "bVial";
public static final String FLASK = "bFlask";
public static final String PRISMARINE_BLOCK = "blockPrismarine";
public static final String BLAZE_BLOCK = "blockBlaze";
public static final String DYE_WILDCARD = "dye";