Compare commits
2 Commits
2.9
...
shader-ref
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f74b107d6 | ||
|
|
b2ee5dbc04 |
@@ -11,7 +11,7 @@ apply plugin: 'net.minecraftforge.gradle.forge'
|
|||||||
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
|
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
|
||||||
|
|
||||||
|
|
||||||
version = "1.12.2-2.9"
|
version = "1.12.2-2.10"
|
||||||
group = "nl.requios.effortlessbuilding" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
group = "nl.requios.effortlessbuilding" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
archivesBaseName = "effortlessbuilding"
|
archivesBaseName = "effortlessbuilding"
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class BuildConfig {
|
|||||||
|
|
||||||
@Comment({"Determines what blocks can be replaced in survival.",
|
@Comment({"Determines what blocks can be replaced in survival.",
|
||||||
"-1: only blocks that can be harvested by hand (default)",
|
"-1: only blocks that can be harvested by hand (default)",
|
||||||
"0: blocks that can be harvested with wooden or gold tools",
|
"0: blocks that can be harvested with wooden oref gold tools",
|
||||||
"1: blocks that can be harvested with stone tools",
|
"1: blocks that can be harvested with stone tools",
|
||||||
"2: blocks that can be harvested with iron tools",
|
"2: blocks that can be harvested with iron tools",
|
||||||
"3: blocks that can be harvested with diamond tools",
|
"3: blocks that can be harvested with diamond tools",
|
||||||
@@ -65,7 +65,7 @@ public class BuildConfig {
|
|||||||
|
|
||||||
@Comment({"How many placements are remembered for the undo functionality."})
|
@Comment({"How many placements are remembered for the undo functionality."})
|
||||||
@RequiresMcRestart
|
@RequiresMcRestart
|
||||||
public int undoStackSize = 5;
|
public int undoStackSize = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Visuals {
|
public static class Visuals {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class EffortlessBuilding
|
|||||||
{
|
{
|
||||||
public static final String MODID = "effortlessbuilding";
|
public static final String MODID = "effortlessbuilding";
|
||||||
public static final String NAME = "Effortless Building";
|
public static final String NAME = "Effortless Building";
|
||||||
public static final String VERSION = "1.12.2-2.9";
|
public static final String VERSION = "1.12.2-2.10";
|
||||||
|
|
||||||
@Mod.Instance(EffortlessBuilding.MODID)
|
@Mod.Instance(EffortlessBuilding.MODID)
|
||||||
public static EffortlessBuilding instance;
|
public static EffortlessBuilding instance;
|
||||||
|
|||||||
@@ -1,16 +1,11 @@
|
|||||||
package nl.requios.effortlessbuilding.buildmode;
|
package nl.requios.effortlessbuilding.buildmode;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.UndoRedo;
|
import nl.requios.effortlessbuilding.buildmodifier.UndoRedo;
|
||||||
import nl.requios.effortlessbuilding.gui.buildmode.RadialMenu;
|
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
||||||
import nl.requios.effortlessbuilding.gui.buildmodifier.ModifierSettingsGui;
|
|
||||||
|
|
||||||
public class ModeOptions {
|
public class ModeOptions {
|
||||||
|
|
||||||
@@ -73,7 +68,6 @@ public class ModeOptions {
|
|||||||
//Called on both client and server
|
//Called on both client and server
|
||||||
public static void performAction(EntityPlayer player, ActionEnum action) {
|
public static void performAction(EntityPlayer player, ActionEnum action) {
|
||||||
if (action == null) return;
|
if (action == null) return;
|
||||||
BuildModes.BuildModeEnum currentBuildMode = ModeSettingsManager.getModeSettings(Minecraft.getMinecraft().player).getBuildMode();
|
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case UNDO:
|
case UNDO:
|
||||||
@@ -90,7 +84,7 @@ public class ModeOptions {
|
|||||||
break;
|
break;
|
||||||
case OPEN_MODIFIER_SETTINGS:
|
case OPEN_MODIFIER_SETTINGS:
|
||||||
if (player.world.isRemote)
|
if (player.world.isRemote)
|
||||||
openModifierSettings();
|
ClientProxy.openModifierSettings();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NORMAL_SPEED:
|
case NORMAL_SPEED:
|
||||||
@@ -132,19 +126,7 @@ public class ModeOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (player.world.isRemote && action != ActionEnum.REPLACE && action != ActionEnum.OPEN_MODIFIER_SETTINGS) {
|
if (player.world.isRemote && action != ActionEnum.REPLACE && action != ActionEnum.OPEN_MODIFIER_SETTINGS) {
|
||||||
logAction(action);
|
ClientProxy.logTranslate(action.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO fix client class import giving error on server (nothing happens, it's just ugly)
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
private static void openModifierSettings() {
|
|
||||||
Minecraft.getMinecraft().displayGuiScreen(new ModifierSettingsGui());
|
|
||||||
RadialMenu.instance.setVisibility(0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
private static void logAction(ActionEnum action) {
|
|
||||||
EffortlessBuilding.log(Minecraft.getMinecraft().player, I18n.format(action.name), true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ package nl.requios.effortlessbuilding.buildmode;
|
|||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
|
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.capability.ModeCapabilityManager;
|
import nl.requios.effortlessbuilding.capability.ModeCapabilityManager;
|
||||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package nl.requios.effortlessbuilding.buildmodifier;
|
package nl.requios.effortlessbuilding.buildmodifier;
|
||||||
|
|
||||||
import mod.chiselsandbits.api.IBitLocation;
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ package nl.requios.effortlessbuilding.buildmodifier;
|
|||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
|
|
||||||
import nl.requios.effortlessbuilding.BuildConfig;
|
import nl.requios.effortlessbuilding.BuildConfig;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.capability.ModifierCapabilityManager;
|
import nl.requios.effortlessbuilding.capability.ModifierCapabilityManager;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import net.minecraft.client.gui.GuiScreen;
|
|||||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
import net.minecraft.client.renderer.texture.TextureMap;
|
import net.minecraft.client.renderer.texture.TextureMap;
|
||||||
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
@@ -80,7 +81,7 @@ public class ClientProxy implements IProxy {
|
|||||||
@Override
|
@Override
|
||||||
public void init(FMLInitializationEvent event) {
|
public void init(FMLInitializationEvent event) {
|
||||||
// register key bindings
|
// register key bindings
|
||||||
keyBindings = new KeyBinding[6];
|
keyBindings = new KeyBinding[7];
|
||||||
|
|
||||||
// instantiate the key bindings
|
// instantiate the key bindings
|
||||||
keyBindings[0] = new KeyBinding("key.effortlessbuilding.hud.desc", KeyConflictContext.UNIVERSAL, Keyboard.KEY_ADD, "key.effortlessbuilding.category");
|
keyBindings[0] = new KeyBinding("key.effortlessbuilding.hud.desc", KeyConflictContext.UNIVERSAL, Keyboard.KEY_ADD, "key.effortlessbuilding.category");
|
||||||
@@ -96,7 +97,7 @@ public class ClientProxy implements IProxy {
|
|||||||
};
|
};
|
||||||
keyBindings[4] = new KeyBinding("key.effortlessbuilding.undo.desc", KeyConflictContext.IN_GAME, KeyModifier.CONTROL, Keyboard.KEY_Z, "key.effortlessbuilding.category");
|
keyBindings[4] = new KeyBinding("key.effortlessbuilding.undo.desc", KeyConflictContext.IN_GAME, KeyModifier.CONTROL, Keyboard.KEY_Z, "key.effortlessbuilding.category");
|
||||||
keyBindings[5] = new KeyBinding("key.effortlessbuilding.redo.desc", KeyConflictContext.IN_GAME, KeyModifier.CONTROL, Keyboard.KEY_Y, "key.effortlessbuilding.category");
|
keyBindings[5] = new KeyBinding("key.effortlessbuilding.redo.desc", KeyConflictContext.IN_GAME, KeyModifier.CONTROL, Keyboard.KEY_Y, "key.effortlessbuilding.category");
|
||||||
// keyBindings[6] = new KeyBinding("Reload shaders", Keyboard.KEY_TAB, "key.effortlessbuilding.category");
|
keyBindings[6] = new KeyBinding("Reload shaders", Keyboard.KEY_TAB, "key.effortlessbuilding.category");
|
||||||
|
|
||||||
// register all the key bindings
|
// register all the key bindings
|
||||||
for (int i = 0; i < keyBindings.length; ++i) {
|
for (int i = 0; i < keyBindings.length; ++i) {
|
||||||
@@ -278,6 +279,7 @@ public class ClientProxy implements IProxy {
|
|||||||
}
|
}
|
||||||
} else if (buildMode == BuildModes.BuildModeEnum.NORMAL_PLUS) {
|
} else if (buildMode == BuildModes.BuildModeEnum.NORMAL_PLUS) {
|
||||||
breakCooldown--;
|
breakCooldown--;
|
||||||
|
if (ModeOptions.getBuildSpeed() == ModeOptions.ActionEnum.FAST_SPEED) breakCooldown = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//EffortlessBuilding.packetHandler.sendToServer(new CancelModeMessage());
|
//EffortlessBuilding.packetHandler.sendToServer(new CancelModeMessage());
|
||||||
@@ -301,16 +303,7 @@ public class ClientProxy implements IProxy {
|
|||||||
//Remember to send packet to server if necessary
|
//Remember to send packet to server if necessary
|
||||||
//Show Modifier Settings GUI
|
//Show Modifier Settings GUI
|
||||||
if (keyBindings[0].isPressed()) {
|
if (keyBindings[0].isPressed()) {
|
||||||
//Disabled if max reach is 0, might be set in the config that way.
|
openModifierSettings();
|
||||||
if (ReachHelper.getMaxReach(player) == 0) {
|
|
||||||
EffortlessBuilding.log(player, "Build modifiers are disabled until your reach has increased. Increase your reach with craftable reach upgrades.");
|
|
||||||
} else {
|
|
||||||
if (Minecraft.getMinecraft().currentScreen == null) {
|
|
||||||
Minecraft.getMinecraft().displayGuiScreen(new ModifierSettingsGui());
|
|
||||||
} else {
|
|
||||||
player.closeScreen();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//QuickReplace toggle
|
//QuickReplace toggle
|
||||||
@@ -353,6 +346,23 @@ public class ClientProxy implements IProxy {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void openModifierSettings() {
|
||||||
|
EntityPlayerSP player = Minecraft.getMinecraft().player;
|
||||||
|
|
||||||
|
RadialMenu.instance.setVisibility(0f);
|
||||||
|
|
||||||
|
//Disabled if max reach is 0, might be set in the config that way.
|
||||||
|
if (ReachHelper.getMaxReach(player) == 0) {
|
||||||
|
EffortlessBuilding.log(player, "Build modifiers are disabled until your reach has increased. Increase your reach with craftable reach upgrades.");
|
||||||
|
} else {
|
||||||
|
if (Minecraft.getMinecraft().currentScreen == null) {
|
||||||
|
Minecraft.getMinecraft().displayGuiScreen(new ModifierSettingsGui());
|
||||||
|
} else {
|
||||||
|
player.closeScreen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onGuiOpen(GuiOpenEvent event) {
|
public static void onGuiOpen(GuiOpenEvent event) {
|
||||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
EntityPlayer player = Minecraft.getMinecraft().player;
|
||||||
@@ -374,4 +384,8 @@ public class ClientProxy implements IProxy {
|
|||||||
return player.rayTrace(raytraceRange, 1f);
|
return player.rayTrace(raytraceRange, 1f);
|
||||||
// return world.rayTraceBlocks(start, end, false, false, false);
|
// return world.rayTraceBlocks(start, end, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void logTranslate(String key) {
|
||||||
|
EffortlessBuilding.log(Minecraft.getMinecraft().player, I18n.format(key), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,13 +5,11 @@ import net.minecraft.block.state.IBlockState;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
import net.minecraft.client.renderer.BlockRendererDispatcher;
|
import net.minecraft.client.renderer.BlockRendererDispatcher;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.client.renderer.OpenGlHelper;
|
import net.minecraft.client.renderer.OpenGlHelper;
|
||||||
import net.minecraft.client.renderer.texture.TextureMap;
|
import net.minecraft.client.renderer.texture.TextureMap;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.util.SoundCategory;
|
import net.minecraft.util.SoundCategory;
|
||||||
import net.minecraft.util.math.*;
|
import net.minecraft.util.math.*;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
@@ -26,14 +24,13 @@ import nl.requios.effortlessbuilding.buildmodifier.BuildModifiers;
|
|||||||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager.ModifierSettings;
|
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager.ModifierSettings;
|
||||||
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
||||||
import nl.requios.effortlessbuilding.helper.InventoryHelper;
|
|
||||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||||
import nl.requios.effortlessbuilding.helper.SurvivalHelper;
|
import nl.requios.effortlessbuilding.helper.SurvivalHelper;
|
||||||
import nl.requios.effortlessbuilding.item.ItemRandomizerBag;
|
import nl.requios.effortlessbuilding.item.ItemRandomizerBag;
|
||||||
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
||||||
import org.lwjgl.opengl.ARBMultitexture;
|
import org.lwjgl.opengl.ARBMultitexture;
|
||||||
import org.lwjgl.opengl.ARBShaderObjects;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
import org.lwjgl.opengl.GL20;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -72,7 +69,8 @@ public class BlockPreviewRenderer {
|
|||||||
|
|
||||||
private static List<PlacedData> placedDataList = new ArrayList<>();
|
private static List<PlacedData> placedDataList = new ArrayList<>();
|
||||||
|
|
||||||
private static final int secondaryTextureUnit = 7;
|
private static final int primaryTextureUnit = 0;
|
||||||
|
private static final int secondaryTextureUnit = 1;
|
||||||
|
|
||||||
public static void render(EntityPlayer player, ModifierSettings modifierSettings, ModeSettings modeSettings) {
|
public static void render(EntityPlayer player, ModifierSettings modifierSettings, ModeSettings modeSettings) {
|
||||||
|
|
||||||
@@ -372,41 +370,40 @@ public class BlockPreviewRenderer {
|
|||||||
final boolean highlight, final boolean red) {
|
final boolean highlight, final boolean red) {
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
Minecraft mc = Minecraft.getMinecraft();
|
||||||
return (Integer shader) -> {
|
return (Integer shader) -> {
|
||||||
int percentileUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "dissolve");
|
int percentileUniform = GL20.glGetUniformLocation(shader, "dissolve");
|
||||||
int highlightUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "highlight");
|
int highlightUniform = GL20.glGetUniformLocation(shader, "highlight");
|
||||||
int redUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "red");
|
int redUniform = GL20.glGetUniformLocation(shader, "red");
|
||||||
int blockposUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "blockpos");
|
int blockposUniform = GL20.glGetUniformLocation(shader, "blockpos");
|
||||||
int firstposUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "firstpos");
|
int firstposUniform = GL20.glGetUniformLocation(shader, "firstpos");
|
||||||
int secondposUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "secondpos");
|
int secondposUniform = GL20.glGetUniformLocation(shader, "secondpos");
|
||||||
int imageUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "image");
|
int imageUniform = GL20.glGetUniformLocation(shader, "image");
|
||||||
int maskUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "mask");
|
int maskUniform = GL20.glGetUniformLocation(shader, "mask");
|
||||||
|
|
||||||
//image
|
//image
|
||||||
OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB);
|
GL20.glUniform1i(imageUniform, primaryTextureUnit);
|
||||||
|
OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + primaryTextureUnit);
|
||||||
|
|
||||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, mc.renderEngine.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).getGlTextureId());
|
GL11.glBindTexture(GL11.GL_TEXTURE_2D, mc.renderEngine.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).getGlTextureId());
|
||||||
ARBShaderObjects.glUniform1iARB(imageUniform, 0);
|
|
||||||
|
|
||||||
OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + secondaryTextureUnit);
|
// GlStateManager.enableTexture2D();
|
||||||
|
// GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
|
||||||
GlStateManager.enableTexture2D();
|
|
||||||
GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
|
|
||||||
|
|
||||||
//mask
|
//mask
|
||||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D,
|
GL20.glUniform1i(maskUniform, secondaryTextureUnit);
|
||||||
mc.renderEngine.getTexture(new ResourceLocation(EffortlessBuilding.MODID, "textures/shader_mask.png")).getGlTextureId());
|
OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + secondaryTextureUnit);
|
||||||
ARBShaderObjects.glUniform1iARB(maskUniform, secondaryTextureUnit);
|
GL11.glBindTexture(GL11.GL_TEXTURE_2D, mc.renderEngine.getTexture(ShaderHandler.shaderMaskTextureLocation).getGlTextureId());
|
||||||
|
|
||||||
//blockpos
|
//blockpos
|
||||||
ARBShaderObjects.glUniform3fARB(blockposUniform, (float) blockpos.x, (float) blockpos.y, (float) blockpos.z);
|
GL20.glUniform3f(blockposUniform, (float) blockpos.x, (float) blockpos.y, (float) blockpos.z);
|
||||||
ARBShaderObjects.glUniform3fARB(firstposUniform, (float) firstpos.x, (float) firstpos.y, (float) firstpos.z);
|
GL20.glUniform3f(firstposUniform, (float) firstpos.x, (float) firstpos.y, (float) firstpos.z);
|
||||||
ARBShaderObjects.glUniform3fARB(secondposUniform, (float) secondpos.x, (float) secondpos.y, (float) secondpos.z);
|
GL20.glUniform3f(secondposUniform, (float) secondpos.x, (float) secondpos.y, (float) secondpos.z);
|
||||||
|
|
||||||
//dissolve
|
//dissolve
|
||||||
ARBShaderObjects.glUniform1fARB(percentileUniform, dissolve);
|
GL20.glUniform1f(percentileUniform, dissolve);
|
||||||
//highlight
|
//highlight
|
||||||
ARBShaderObjects.glUniform1iARB(highlightUniform, highlight ? 1 : 0);
|
GL20.glUniform1i(highlightUniform, highlight ? 1 : 0);
|
||||||
//red
|
//red
|
||||||
ARBShaderObjects.glUniform1iARB(redUniform, red ? 1 : 0);
|
GL20.glUniform1i(redUniform, red ? 1 : 0);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ public class RenderHandler implements IWorldEventListener {
|
|||||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||||
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||||
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(EffortlessBuilding.MODID, "textures/shader_mask.png"));
|
Minecraft.getMinecraft().renderEngine.bindTexture(ShaderHandler.shaderMaskTextureLocation);
|
||||||
|
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
@@ -196,6 +196,7 @@ public class RenderHandler implements IWorldEventListener {
|
|||||||
protected static void endBlockPreviews() {
|
protected static void endBlockPreviews() {
|
||||||
ShaderHandler.releaseShader();
|
ShaderHandler.releaseShader();
|
||||||
GlStateManager.disableBlend();
|
GlStateManager.disableBlend();
|
||||||
|
|
||||||
GL11.glPopAttrib();
|
GL11.glPopAttrib();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
package nl.requios.effortlessbuilding.render;
|
package nl.requios.effortlessbuilding.render;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.OpenGlHelper;
|
import net.minecraft.client.renderer.OpenGlHelper;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import nl.requios.effortlessbuilding.BuildConfig;
|
import nl.requios.effortlessbuilding.BuildConfig;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
||||||
@@ -27,8 +28,9 @@ import java.util.function.Consumer;
|
|||||||
|
|
||||||
public final class ShaderHandler {
|
public final class ShaderHandler {
|
||||||
|
|
||||||
private static final int VERT_ST = ARBVertexShader.GL_VERTEX_SHADER_ARB;
|
|
||||||
private static final int FRAG_ST = ARBFragmentShader.GL_FRAGMENT_SHADER_ARB;
|
private static final int VERT_ST = GL20.GL_VERTEX_SHADER;
|
||||||
|
private static final int FRAG_ST = GL20.GL_FRAGMENT_SHADER;
|
||||||
|
|
||||||
private static final int VERT = 1;
|
private static final int VERT = 1;
|
||||||
private static final int FRAG = 2;
|
private static final int FRAG = 2;
|
||||||
@@ -39,6 +41,8 @@ public final class ShaderHandler {
|
|||||||
public static int rawColor;
|
public static int rawColor;
|
||||||
public static int dissolve;
|
public static int dissolve;
|
||||||
|
|
||||||
|
public static ResourceLocation shaderMaskTextureLocation = new ResourceLocation(EffortlessBuilding.MODID, "textures/shader_mask.png");
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
if(!doUseShaders())
|
if(!doUseShaders())
|
||||||
return;
|
return;
|
||||||
@@ -51,11 +55,11 @@ public final class ShaderHandler {
|
|||||||
if(!doUseShaders())
|
if(!doUseShaders())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ARBShaderObjects.glUseProgramObjectARB(shader);
|
GL20.glUseProgram(shader);
|
||||||
|
|
||||||
if(shader != 0) {
|
if(shader != 0) {
|
||||||
int time = ARBShaderObjects.glGetUniformLocationARB(shader, "time");
|
int time = GL20.glGetUniformLocation(shader, "time");
|
||||||
ARBShaderObjects.glUniform1iARB(time, ClientProxy.ticksInGame);
|
GL20.glUniform1i(time, ClientProxy.ticksInGame);
|
||||||
|
|
||||||
if(callback != null)
|
if(callback != null)
|
||||||
callback.accept(shader);
|
callback.accept(shader);
|
||||||
@@ -71,7 +75,7 @@ public final class ShaderHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean doUseShaders() {
|
public static boolean doUseShaders() {
|
||||||
return BuildConfig.visuals.useShaders && OpenGlHelper.shadersSupported;
|
return BuildConfig.visuals.useShaders && OpenGlHelper.shadersSupported && OpenGlHelper.openGL21; //Only GL2.1 shaders
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int createProgram(String s, int sides) {
|
private static int createProgram(String s, int sides) {
|
||||||
@@ -91,24 +95,24 @@ public final class ShaderHandler {
|
|||||||
if(frag != null)
|
if(frag != null)
|
||||||
fragId = createShader(frag, FRAG_ST);
|
fragId = createShader(frag, FRAG_ST);
|
||||||
|
|
||||||
program = ARBShaderObjects.glCreateProgramObjectARB();
|
program = GL20.glCreateProgram();
|
||||||
if(program == 0)
|
if(program == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(vert != null)
|
if(vert != null)
|
||||||
ARBShaderObjects.glAttachObjectARB(program, vertId);
|
GL20.glAttachShader(program, vertId);
|
||||||
if(frag != null)
|
if(frag != null)
|
||||||
ARBShaderObjects.glAttachObjectARB(program, fragId);
|
GL20.glAttachShader(program, fragId);
|
||||||
|
|
||||||
ARBShaderObjects.glLinkProgramARB(program);
|
GL20.glLinkProgram(program);
|
||||||
if(ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE) {
|
if(GL20.glGetProgrami(program, GL20.GL_LINK_STATUS) == GL11.GL_FALSE) {
|
||||||
EffortlessBuilding.logger.log(Level.ERROR, getLogInfo(program));
|
EffortlessBuilding.logger.log(Level.ERROR, getProgramLogInfo(program));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ARBShaderObjects.glValidateProgramARB(program);
|
GL20.glValidateProgram(program);
|
||||||
if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB) == GL11.GL_FALSE) {
|
if (GL20.glGetProgrami(program, GL20.GL_VALIDATE_STATUS) == GL11.GL_FALSE) {
|
||||||
EffortlessBuilding.logger.log(Level.ERROR, getLogInfo(program));
|
EffortlessBuilding.logger.log(Level.ERROR, getProgramLogInfo(program));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,28 +122,32 @@ public final class ShaderHandler {
|
|||||||
private static int createShader(String filename, int shaderType){
|
private static int createShader(String filename, int shaderType){
|
||||||
int shader = 0;
|
int shader = 0;
|
||||||
try {
|
try {
|
||||||
shader = ARBShaderObjects.glCreateShaderObjectARB(shaderType);
|
shader = GL20.glCreateShader(shaderType);
|
||||||
|
|
||||||
if(shader == 0)
|
if(shader == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ARBShaderObjects.glShaderSourceARB(shader, readFileAsString(filename));
|
GL20.glShaderSource(shader, readFileAsString(filename));
|
||||||
ARBShaderObjects.glCompileShaderARB(shader);
|
GL20.glCompileShader(shader);
|
||||||
|
|
||||||
if (ARBShaderObjects.glGetObjectParameteriARB(shader, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE)
|
if (GL20.glGetShaderi(shader, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE)
|
||||||
throw new RuntimeException("Error creating shader: " + getLogInfo(shader));
|
throw new RuntimeException("Error creating shader: " + getShaderLogInfo(shader));
|
||||||
|
|
||||||
return shader;
|
return shader;
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
ARBShaderObjects.glDeleteObjectARB(shader);
|
GL20.glDeleteShader(shader);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getLogInfo(int obj) {
|
private static String getProgramLogInfo(int program) {
|
||||||
return ARBShaderObjects.glGetInfoLogARB(obj, ARBShaderObjects.glGetObjectParameteriARB(obj, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB));
|
return GL20.glGetProgramInfoLog(program, GL20.glGetProgrami(program, GL20.GL_INFO_LOG_LENGTH));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getShaderLogInfo(int shader) {
|
||||||
|
return GL20.glGetShaderInfoLog(shader, GL20.glGetShaderi(shader, GL20.GL_INFO_LOG_LENGTH));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String readFileAsString(String filename) throws Exception {
|
private static String readFileAsString(String filename) throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user