Remove voxelcommon

This commit is contained in:
Matthew Messinger 2016-01-26 03:16:11 -05:00
parent 45f408cf1b
commit 90352517d4
111 changed files with 528 additions and 8239 deletions

View file

@ -19,8 +19,7 @@ plugins {
id 'mnm.gradle.ap-ide' version '1.0.2'
}
ext.voxellib = project ':voxellib'
ext.revision = 186
ext.revision = 200
apply plugin: 'net.minecraftforge.gradle.tweaker-client'
apply plugin: 'org.spongepowered.mixin'
@ -41,34 +40,22 @@ sourceSets {
def deps = [
configurations.forgeGradleMcDeps,
configurations.forgeGradleMc,
configurations.provided
configurations.compile,
]
main {
refMap = 'mixin.minelp.refmap.json'
}
common {
compileClasspath += files deps
}
hdskins {
compileClasspath += files deps
refMap = 'mixin.hdskins.refmap.json'
}
}
project('forge') {
apply plugin: 'net.minecraftforge.gradle.forge'
version = '0.0'
minecraft {
version = '1.8-11.14.3.1543'
mappings = rootProject.minecraft.mappings
runDir = rootProject.minecraft.runDir
replace '@VERSION@',project.version
main {
refMap = 'mixin.minelp.refmap.json'
compileClasspath += hdskins.output
}
dependencies {
provided rootProject
forge {
compileClasspath += deps
compileClasspath += [main.output, api.output]
}
}
project('LiteLoader'){
apply plugin: 'mnm.gradle.ap-ide'
mcMappings = rootProject.minecraft.mappings
}
processResources {
@ -86,47 +73,26 @@ processResources {
exclude 'litemod.json'
}
}
allprojects {
repositories{
repositories{
maven {
name 'sponge'
url 'http://repo.spongepowered.org/maven'
}
}
}
dependencies {
provided project('LiteLoader')
provided voxellib
compile sourceSets.common.output
compile sourceSets.hdskins.output
hdskinsCompile sourceSets.common.output
dependencies {
compile project('LiteLoader')
}
jar {
manifest.attributes.remove 'TweakClass'
}
task standaloneJar(type: Jar, dependsOn: [{voxellib.reobfObfJar}, {project('forge').compileJava}]) {
from sourceSets.findAll{it.name != "api"}*.output
extension 'litemod'
from sourceSets*.output
from {project('forge').sourceSets.main.output}
// voxellib
from {voxellib.obfJar.archivePath}
classifier 'standalone'
}
artifacts {
archives standaloneJar
}
reobf {
jar.task.enabled = false
standaloneJar{}
}
sourceSets.main.refMap = 'mixin.minelp.refmap.json'
mixin {
defaultObfuscationEnv notch
}
task installMod(type: Copy, dependsOn: build) {
from standaloneJar.archivePath
task deploy(type: Copy, dependsOn: build) {
from jar.archivePath
into file("$System.env.APPDATA/.minecraft/mods")
}

View file

@ -1,3 +1,3 @@
rootProject.name = 'MineLittlePony'
include 'voxellib', 'forge', 'LiteLoader'
include 'LiteLoader'

View file

@ -0,0 +1,18 @@
package net.minecraftforge.client;
import net.minecraft.client.model.ModelBase;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
// stub
public class ForgeHooksClient {
public static String getArmorTexture(EntityLivingBase entity, ItemStack armor, String def, int slot, String type) {
return def;
}
public static ModelBase getArmorModel(EntityLivingBase entity, ItemStack item, int slot, ModelBase def) {
return def;
}
}

View file

@ -0,0 +1,17 @@
package net.minecraftforge.fml.common;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
// stub
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Mod {
String modid();
String name() default "";
String version() default "";
}

View file

@ -0,0 +1,4 @@
package net.minecraftforge.fml.common.event;
// stub
public class FMLPostInitializationEvent {}

View file

@ -1,12 +0,0 @@
package com.mumfrey.liteloader.core;
import com.mumfrey.liteloader.LiteMod;
import com.mumfrey.liteloader.core.LiteLoader;
import com.mumfrey.liteloader.core.api.LoadableModFileFriend;
import java.io.File;
public abstract class LiteLoaderFriend {
public static void loadMod(String identifier, Class<? extends LiteMod> mod, File jarFile) throws InstantiationException, IllegalAccessException {
LiteLoader.getInstance().mods.loadMod(identifier, mod, LoadableModFileFriend.getLoadableModFile(jarFile));
}
}

View file

@ -1,11 +0,0 @@
package com.mumfrey.liteloader.core.api;
import com.mumfrey.liteloader.core.api.LoadableModFile;
import com.mumfrey.liteloader.interfaces.LoadableMod;
import java.io.File;
public class LoadableModFileFriend {
public static LoadableMod<?> getLoadableModFile(File jarFile) {
return new LoadableModFile(jarFile, (String)null);
}
}

View file

@ -1,124 +0,0 @@
package com.voxelmodpack.common;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import com.google.common.io.ByteSink;
import com.google.common.io.Files;
import com.mumfrey.liteloader.Configurable;
import com.mumfrey.liteloader.LiteMod;
import com.mumfrey.liteloader.core.LiteLoader;
import com.mumfrey.liteloader.core.LiteLoaderFriend;
import com.mumfrey.liteloader.launch.ClassPathUtilities;
import com.mumfrey.liteloader.modconfig.ConfigManager;
import com.mumfrey.liteloader.modconfig.ConfigPanel;
import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
import net.minecraft.launchwrapper.Launch;
public abstract class VoxelCommonLiteMod implements LiteMod, Configurable {
private String bundledJarName = "voxelcommon-2.4.0.jar";
private final String voxelCommonClassName = "com.voxelmodpack.common.LiteModVoxelCommon";
private final String modClassName;
private LiteMod mod;
public VoxelCommonLiteMod(String modClassName) {
this.bundledJarName = LiteLoader.getInstance().getModMetaData(this, "voxelCommonJarName", this.bundledJarName);
this.modClassName = modClassName;
}
@Override
public void init(File configPath) {
try {
this.getClass();
Class.forName(voxelCommonClassName, false, Launch.class.getClassLoader());
} catch (Throwable var4) {
this.getClass();
if (!this.extractAndInjectMod("VoxelLib", voxelCommonClassName, this.bundledJarName,
Files.createTempDir())) {
return;
}
}
try {
Class<?> th = Class.forName(this.modClassName);
this.mod = (LiteMod) th.newInstance();
this.mod.init(configPath);
if (this.mod instanceof Configurable && ((Configurable) this.mod).getConfigPanelClass() != null) {
this.registerConfigurable();
}
LiteLoader.getInterfaceManager().registerListener(this.mod);
} catch (Throwable var3) {
var3.printStackTrace();
}
}
public void registerConfigurable() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
Field configManagerField = LiteLoader.class.getDeclaredField("configManager");
configManagerField.setAccessible(true);
ConfigManager mgr = (ConfigManager) configManagerField.get(LiteLoader.getInstance());
mgr.registerMod(this);
}
@Override
public Class<? extends ConfigPanel> getConfigPanelClass() {
return this.mod != null && this.mod instanceof Configurable ? ((Configurable) this.mod).getConfigPanelClass() : null;
}
@Override
public void upgradeSettings(String version, File configPath, File oldConfigPath) {
if (this.mod != null) {
this.mod.upgradeSettings(version, configPath, oldConfigPath);
}
}
@SuppressWarnings("unchecked")
private boolean extractAndInjectMod(String libraryName, String className, String resourceName, File libPath) {
if ("true".equals(System.getProperty("VoxelCommon.Injected"))) {
LiteLoaderLogger.warning("%s jar was already injected, skipping injection.", libraryName);
return true;
}
File jarFile = new File(libPath, resourceName);
if (!jarFile.exists()) {
LiteLoaderLogger.info("%s jar does not exist, attempting to extract to %s", libraryName, libPath.getAbsolutePath());
if (!extractFile("/" + resourceName, jarFile)) {
LiteLoaderLogger.warning("%s jar could not be extracted, %s may not function correctly (or at all)", libraryName, this.getName());
return false;
}
}
if (jarFile.exists()) {
LiteLoaderLogger.info("%s jar exists, attempting to inject into classpath", libraryName);
try {
ClassPathUtilities.injectIntoClassPath(Launch.classLoader, jarFile.toURI().toURL());
LiteLoaderFriend.loadMod(libraryName, (Class<? extends LiteMod>) Class.forName(className), jarFile);
} catch (Exception var7) {
var7.printStackTrace();
return false;
}
System.setProperty("VoxelCommon.Injected", "true");
LiteLoaderLogger.info("%s jar was successfully extracted", libraryName);
return true;
}
LiteLoaderLogger.warning("%s jar was not detected, %s may not function correctly (or at all)", libraryName, this.getName());
return false;
}
private static boolean extractFile(String resourceName, File outputFile) {
try {
InputStream ex = VoxelCommonLiteMod.class.getResourceAsStream(resourceName);
ByteSink sink = Files.asByteSink(outputFile);
sink.writeFrom(ex);
return true;
} catch (NullPointerException var4) {
return false;
} catch (IOException var5) {
return false;
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

View file

@ -5,19 +5,18 @@ import com.brohoof.minelittlepony.forge.IPonyArmor;
import net.minecraft.client.model.ModelBase;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.ForgeHooksClient;
public class PonyArmors implements IPonyArmor {
@Override
public String getArmorTexture(EntityLivingBase entity, ItemStack armor, String def, int slot, String type) {
String result = armor.getItem().getArmorTexture(armor, entity, slot, type);
return result == null ? def : result;
return ForgeHooksClient.getArmorTexture(entity, armor, def, slot, type);
}
@Override
public ModelBase getArmorModel(EntityLivingBase entity, ItemStack item, int slot, ModelBase def) {
ModelBase result = item.getItem().getArmorModel(entity, item, slot);
return result == null ? def : result;
return ForgeHooksClient.getArmorModel(entity, item, slot, def);
}
}

View file

@ -70,7 +70,17 @@ public final class HDSkinManager {
private void loadTexture(GameProfile profile, final Type type, final SkinAvailableCallback callback) {
if (profile != null && profile.getId() != null) {
String uuid = UUIDTypeAdapter.fromUUID(profile.getId());
String url = getCustomSkinURLForId(uuid, true);
String url;
switch (type) {
case SKIN:
url = getCustomSkinURLForId(uuid, false);
break;
case CAPE:
url = getCustomCloakURLForId(uuid);
break;
default:
throw new NullPointerException("Skin type was null.");
}
// TODO use cache
final MinecraftProfileTexture texture = new MinecraftProfileTexture(url, null);
final ResourceLocation skin = new ResourceLocation("skins/" + texture.getHash());
@ -149,16 +159,13 @@ public final class HDSkinManager {
public static PreviewTexture getPreviewTexture(ResourceLocation skinResource, GameProfile profile) {
TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
ITextureObject skinTexture = textureManager.getTexture(skinResource);
if (skinTexture == null) {
Map<Type, MinecraftProfileTexture> textures = getTexturesForProfile(profile);
MinecraftProfileTexture skin = textures.get(Type.SKIN);
if (skin != null) {
String url = skin.getUrl();
String url = INSTANCE.getCustomSkinURLForId(UUIDTypeAdapter.fromUUID(profile.getId()), true);
skinTexture = new PreviewTexture(url, DefaultPlayerSkin.getDefaultSkin(profile.getId()), new ImageBufferDownloadHD());
textureManager.loadTexture(skinResource, skinTexture);
}
}
return (PreviewTexture) skinTexture;
}

View file

@ -2,18 +2,25 @@ package com.voxelmodpack.hdskins;
import java.io.File;
import com.voxelmodpack.common.runtime.PrivateFields;
import net.minecraft.client.renderer.IImageBuffer;
import net.minecraft.client.renderer.ThreadDownloadImageData;
import net.minecraft.util.ResourceLocation;
public class PreviewTexture extends ThreadDownloadImageData {
private boolean uploaded;
public PreviewTexture(String url, ResourceLocation fallbackTexture, IImageBuffer imageBuffer) {
super((File) null, url, fallbackTexture, imageBuffer);
}
public boolean isTextureUploaded() {
return PrivateFields.downloadedImage.get(this) != null && this.getGlTextureId() > -1;
return uploaded && this.getGlTextureId() > -1;
}
@Override
public void deleteGlTexture() {
super.deleteGlTexture();
this.uploaded = true;
}
}

View file

@ -7,8 +7,8 @@ import java.io.IOException;
import javax.imageio.ImageIO;
import com.mojang.authlib.GameProfile;
import com.voxelmodpack.common.gl.TextureHelper;
import com.voxelmodpack.hdskins.HDSkinManager;
import com.voxelmodpack.hdskins.ImageBufferDownloadHD;
import com.voxelmodpack.hdskins.PreviewTexture;
import net.minecraft.client.Minecraft;
@ -37,13 +37,13 @@ public class EntityPlayerModel extends EntityLiving {
this.textureManager = Minecraft.getMinecraft().getTextureManager();
this.remoteSkinResource = new ResourceLocation("skins/preview_" + this.profile.getName() + ".png");
this.localSkinResource = NOSKIN;
TextureHelper.releaseTexture(this.remoteSkinResource);
this.textureManager.deleteTexture(this.remoteSkinResource);
}
public void setRemoteSkin() {
public void reloadRemoteSkin() {
this.remoteSkin = true;
if (this.remoteSkinTexture != null) {
TextureHelper.releaseTexture(this.remoteSkinResource);
this.textureManager.deleteTexture(this.remoteSkinResource);
}
this.remoteSkinTexture = HDSkinManager.getPreviewTexture(this.remoteSkinResource, this.profile);
@ -53,13 +53,14 @@ public class EntityPlayerModel extends EntityLiving {
if (skinTextureFile.exists()) {
this.remoteSkin = false;
if (this.localSkinTexture != null) {
TextureHelper.releaseTexture(this.localSkinResource);
this.textureManager.deleteTexture(this.localSkinResource);
this.localSkinTexture = null;
}
BufferedImage bufferedImage;
try {
bufferedImage = ImageIO.read(skinTextureFile);
BufferedImage image = ImageIO.read(skinTextureFile);
bufferedImage = new ImageBufferDownloadHD().parseUserSkin(image);
} catch (IOException var4) {
this.localSkinResource = NOSKIN;
var4.printStackTrace();
@ -67,8 +68,7 @@ public class EntityPlayerModel extends EntityLiving {
}
this.localSkinTexture = new DynamicTexture(bufferedImage);
this.localSkinResource = this.textureManager.getDynamicTextureLocation("localSkinPreview",
this.localSkinTexture);
this.localSkinResource = this.textureManager.getDynamicTextureLocation("localSkinPreview", this.localSkinTexture);
this.hasLocalTexture = true;
}
@ -93,12 +93,11 @@ public class EntityPlayerModel extends EntityLiving {
public void releaseTextures() {
if (this.localSkinTexture != null) {
TextureHelper.releaseTexture(this.localSkinResource);
this.textureManager.deleteTexture(this.localSkinResource);
this.localSkinTexture = null;
this.localSkinResource = NOSKIN;
this.hasLocalTexture = false;
}
}
public ResourceLocation getSkinTexture() {
@ -106,10 +105,6 @@ public class EntityPlayerModel extends EntityLiving {
: DefaultPlayerSkin.getDefaultSkin(entityUniqueID)) : this.localSkinResource;
}
public boolean hasCloak() {
return false;
}
public void swingArm() {
if (!this.isSwinging || this.swingProgressInt >= 4 || this.swingProgressInt < 0) {
this.swingProgressInt = -1;

View file

@ -37,12 +37,12 @@ import com.mojang.authlib.minecraft.MinecraftSessionService;
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
import com.mumfrey.liteloader.gl.GL;
import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
import com.voxelmodpack.common.net.upload.IUploadCompleteCallback;
import com.voxelmodpack.common.net.upload.ThreadMultipartPostUpload;
import com.voxelmodpack.common.net.upload.awt.IOpenFileCallback;
import com.voxelmodpack.common.net.upload.awt.ThreadOpenFilePNG;
import com.voxelmodpack.hdskins.gui.EntityPlayerModel;
import com.voxelmodpack.hdskins.mod.HDSkinsModCore;
import com.voxelmodpack.hdskins.mod.LiteModHDSkinsMod;
import com.voxelmodpack.hdskins.upload.IUploadCompleteCallback;
import com.voxelmodpack.hdskins.upload.ThreadMultipartPostUpload;
import com.voxelmodpack.hdskins.upload.awt.IOpenFileCallback;
import com.voxelmodpack.hdskins.upload.awt.ThreadOpenFilePNG;
import com.voxelmodpack.voxelmenu.IPanoramaRenderer;
import net.minecraft.client.Minecraft;
@ -127,9 +127,9 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
rm.renderEngine = minecraft.getTextureManager();
rm.options = minecraft.gameSettings;
rm.livingPlayer = this.localPlayer;
this.setRemoteSkin();
this.reloadRemoteSkin();
this.fetchingSkin = true;
this.panoramaRenderer = HDSkinsModCore.getPanoramaRenderer(this);
this.panoramaRenderer = LiteModHDSkinsMod.getPanoramaRenderer(this);
}
protected EntityPlayerModel getModel(GameProfile profile) {
@ -162,7 +162,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
this.pendingRemoteSkinRefresh = false;
this.fetchingSkin = true;
this.btnClear.enabled = false;
this.setRemoteSkin();
this.reloadRemoteSkin();
this.onSetRemoteSkin();
}
@ -174,7 +174,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
} else {
this.refreshCounter = -1;
this.throttledByMojang = false;
this.setRemoteSkin();
this.reloadRemoteSkin();
}
}
@ -187,9 +187,9 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
*/
protected void onSetLocalSkin(BufferedImage skin) {}
private void setRemoteSkin() {
private void reloadRemoteSkin() {
try {
this.remotePlayer.setRemoteSkin();
this.remotePlayer.reloadRemoteSkin();
} catch (Exception var2) {
var2.printStackTrace();
this.throttledByMojang = true;
@ -249,7 +249,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
fileDrop.setResizable(false);
fileDrop.setTitle("Skin Drop");
fileDrop.setSize(256, 256);
fileDrop.setAlwaysOnTop(true);
// fileDrop.setAlwaysOnTop(true);
fileDrop.getContentPane().setLayout(null);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.GRAY));

View file

@ -1,14 +1,32 @@
package com.voxelmodpack.hdskins.gui;
import com.voxelmodpack.common.properties.VoxelPropertyToggleButton;
import com.voxelmodpack.common.properties.gui.GuiVoxelBoxSettingsPanel;
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProviderBoolean;
import com.mumfrey.liteloader.modconfig.ConfigPanel;
import com.mumfrey.liteloader.modconfig.ConfigPanelHost;
import com.voxelmodpack.hdskins.HDSkinManager;
public class HDSkinsConfigPanel extends GuiVoxelBoxSettingsPanel implements IVoxelPropertyProviderBoolean {
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
public HDSkinsConfigPanel() {
this.properties.add(new VoxelPropertyToggleButton(this, "clear", "Clear local skin cache", 72, 8, 120, 70, 16));
public class HDSkinsConfigPanel implements ConfigPanel {
private GuiButton button;
@Override
public void onPanelShown(ConfigPanelHost host) {
this.button = new GuiButton(0, 72, 120, 70, 16, "Clear Skin Cache");
}
@Override
public void drawPanel(ConfigPanelHost host, int mouseX, int mouseY, float partialTicks) {
this.button.drawButton(Minecraft.getMinecraft(), mouseX, mouseY);
}
@Override
public void mousePressed(ConfigPanelHost host, int mouseX, int mouseY, int mouseButton) {
if (button.mousePressed(Minecraft.getMinecraft(), mouseX, mouseY)) {
HDSkinManager.clearSkinCache();
}
}
@Override
@ -17,30 +35,25 @@ public class HDSkinsConfigPanel extends GuiVoxelBoxSettingsPanel implements IVox
}
@Override
public String getStringProperty(String propertyName) {
return null;
public int getContentHeight() {
return 0;
}
@Override
public String getOptionDisplayString(String propertyName) {
return "Clear now";
}
public void keyPressed(ConfigPanelHost host, char keyChar, int keyCode) {}
@Override
public void toggleOption(String propertyName) {
HDSkinManager.clearSkinCache();
}
public void mouseMoved(ConfigPanelHost host, int mouseX, int mouseY) {}
@Override
public String getDefaultPropertyValue(String propertyName) {
return null;
}
public void mouseReleased(ConfigPanelHost host, int mouseX, int mouseY, int mouseButton) {}
@Override
public void setProperty(String propertyName, boolean value) {}
public void onPanelHidden() {}
@Override
public boolean getBoolProperty(String propertyName) {
return true;
}
public void onPanelResize(ConfigPanelHost host) {}
@Override
public void onTick(ConfigPanelHost host) {}
}

View file

@ -19,13 +19,12 @@ import net.minecraft.client.renderer.ImageBufferDownload;
public abstract class MixinImageBufferDownload implements IImageBuffer {
@Inject(method = "parseUserSkin",
require = 1,
locals = LocalCapture.CAPTURE_FAILHARD,
at = @At(value = "INVOKE",
shift = Shift.BEFORE,
target = "Ljava/awt/Graphics;dispose()V") )
private void update(BufferedImage image, CallbackInfo ci, BufferedImage image2, Graphics graphics) {
// convert skins from legacy server
// convert skins from mojang server
if (image.getHeight() == 32) {
HDSkinManager.INSTANCE.convertSkin(image2, graphics);
}

View file

@ -19,7 +19,6 @@ import net.minecraft.util.ResourceLocation;
public abstract class MixinSkullRenderer extends TileEntitySpecialRenderer {
@Inject(method = "renderSkull",
require = 1,
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/tileentity/TileEntitySkullRenderer;bindTexture(Lnet/minecraft/util/ResourceLocation;)V",

View file

@ -1,19 +0,0 @@
package com.voxelmodpack.hdskins.mod;
import com.voxelmodpack.common.VoxelCommonLiteMod;
public class LiteModHDSkins extends VoxelCommonLiteMod {
public LiteModHDSkins() {
super("com.voxelmodpack.hdskins.mod.HDSkinsModCore");
}
@Override
public String getVersion() {
return "4.0.1";
}
@Override
public String getName() {
return "HDSkins";
}
}

View file

@ -15,7 +15,7 @@ import com.voxelmodpack.voxelmenu.IPanoramaRenderer;
import net.minecraft.client.Minecraft;
public class HDSkinsModCore implements HDSkinsMod {
public class LiteModHDSkinsMod implements HDSkinsMod {
@Override
public String getName() {
return "HD Skins";
@ -30,11 +30,10 @@ public class HDSkinsModCore implements HDSkinsMod {
public void init(File configPath) {
try {
Class<?> ex = Class.forName("com.thevoxelbox.voxelmenu.GuiMainMenuVoxelBox");
Method mRegisterCustomScreen = ex.getDeclaredMethod("registerCustomScreen",
new Class[] { Class.class, String.class });
Method mRegisterCustomScreen = ex.getDeclaredMethod("registerCustomScreen", Class.class, String.class);
mRegisterCustomScreen.invoke(null, GuiSkins.class, "HD Skins Manager");
} catch (ClassNotFoundException var4) {
// voxelmenu's not here, man
} catch (Exception var5) {
var5.printStackTrace();
}
@ -62,9 +61,8 @@ public class HDSkinsModCore implements HDSkinsMod {
public static IPanoramaRenderer getPanoramaRenderer(IPanoramaRenderer fallbackRenderer) {
try {
Class<?> ex = Class.forName("com.thevoxelbox.voxelmenu.VoxelMenuModCore");
Method mGetPanoramaRenderer = ex.getDeclaredMethod("getPanoramaRenderer", new Class[0]);
IPanoramaRenderer panoramaRenderer = (IPanoramaRenderer) mGetPanoramaRenderer.invoke((Object) null,
new Object[0]);
Method mGetPanoramaRenderer = ex.getDeclaredMethod("getPanoramaRenderer");
IPanoramaRenderer panoramaRenderer = (IPanoramaRenderer) mGetPanoramaRenderer.invoke(null);
if (panoramaRenderer != null) {
return panoramaRenderer;
}

View file

@ -1,4 +1,4 @@
package com.voxelmodpack.common.net.upload;
package com.voxelmodpack.hdskins.upload;
public interface IUploadCompleteCallback {
public abstract void onUploadComplete(String response);

View file

@ -1,4 +1,4 @@
package com.voxelmodpack.common.net.upload;
package com.voxelmodpack.hdskins.upload;
import java.io.BufferedReader;
import java.io.DataOutputStream;

View file

@ -1,4 +1,4 @@
package com.voxelmodpack.common.net.upload.awt;
package com.voxelmodpack.hdskins.upload.awt;
import javax.swing.JFileChooser;

View file

@ -1,4 +1,4 @@
package com.voxelmodpack.common.net.upload.awt;
package com.voxelmodpack.hdskins.upload.awt;
import java.awt.Frame;

View file

@ -1,4 +1,4 @@
package com.voxelmodpack.common.net.upload.awt;
package com.voxelmodpack.hdskins.upload.awt;
import java.io.File;

View file

@ -1,20 +1,122 @@
package com.brohoof.minelittlepony;
import com.voxelmodpack.common.VoxelCommonLiteMod;
import java.io.File;
public class LiteModMineLittlePony extends VoxelCommonLiteMod {
import org.lwjgl.input.Keyboard;
public LiteModMineLittlePony() {
super("com.brohoof.minelittlepony.MineLittlePony");
import com.brohoof.minelittlepony.gui.PonySettingPanel;
import com.brohoof.minelittlepony.hdskins.gui.EntityPonyModel;
import com.brohoof.minelittlepony.hdskins.gui.GuiSkinsMineLP;
import com.brohoof.minelittlepony.hdskins.gui.RenderPonyModel;
import com.brohoof.minelittlepony.renderer.RenderPonySkeleton;
import com.brohoof.minelittlepony.renderer.RenderPonyVillager;
import com.brohoof.minelittlepony.renderer.RenderPonyZombie;
import com.brohoof.minelittlepony.util.MineLPLogger;
import com.mumfrey.liteloader.InitCompleteListener;
import com.mumfrey.liteloader.core.LiteLoader;
import com.mumfrey.liteloader.util.ModUtilities;
import com.voxelmodpack.hdskins.HDSkinManager;
import com.voxelmodpack.hdskins.gui.GuiSkins;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiMainMenu;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.monster.EntityPigZombie;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityVillager;
public class LiteModMineLittlePony implements InitCompleteListener {
public static final String MOD_VERSION = "@VERSION@";
public static final String MOD_NAME = "Mine Little Pony";
public static final String SKIN_SERVER_URL = "minelpskins.voxelmodpack.com";
public static final String GATEWAY_URL = "minelpskinmanager.voxelmodpack.com";
public static final String UPLOAD_URL = "http://minelpskinmanager.voxelmodpack.com/";
private static final KeyBinding guiKeybinding = new KeyBinding("Settings", Keyboard.KEY_F9, "Mine Little Pony");
private static final KeyBinding skinKeybinding = new KeyBinding("Skin Manager", Keyboard.KEY_F1, "Mine Little Pony");
private PonyConfig config;
private PonyManager ponyManager;
@Override
public String getName() {
return MOD_NAME;
}
@Override
public String getVersion() {
return MineLittlePony.MOD_VERSION;
return MOD_VERSION;
}
@Override
public String getName() {
return MineLittlePony.MOD_NAME;
public void upgradeSettings(String version, File configPath, File oldConfigPath) {}
@Override
public void init(File configPath) {
LiteLoader.getInput().registerKeyBinding(guiKeybinding);
LiteLoader.getInput().registerKeyBinding(skinKeybinding);
// SettingsPanelManager.addSettingsPanel("Pony",
// MineLittlePonyGUI.class);
// SettingsPanelManager.addSettingsPanel("Pony Mobs",
// MineLittlePonyGUIMob.class);
this.config = MineLittlePony.getConfig();
this.ponyManager = MineLittlePony.getInstance().getManager();
LiteLoader.getInstance().registerExposable(config, null);
}
@Override
public void onInitCompleted(Minecraft minecraft, LiteLoader loader) {
HDSkinManager.clearSkinCache();
HDSkinManager manager = HDSkinManager.INSTANCE;
manager.setSkinUrl(config.skinfix ? GATEWAY_URL : SKIN_SERVER_URL);
manager.setGatewayURL(GATEWAY_URL);
manager.addSkinModifier(new PonySkinModifier());
MineLPLogger.info("Set MineLP skin server URL.");
RenderManager rm = minecraft.getRenderManager();
ModUtilities.addRenderer(EntityPonyModel.class, new RenderPonyModel(rm));
if (this.config.villagers) {
ModUtilities.addRenderer(EntityVillager.class, new RenderPonyVillager(rm));
MineLPLogger.info("Villagers are now ponies.");
}
if (this.config.zombies) {
ModUtilities.addRenderer(EntityZombie.class, new RenderPonyZombie(rm));
MineLPLogger.info("Zombies are now ponies.");
}
if (this.config.pigzombies) {
ModUtilities.addRenderer(EntityPigZombie.class, new RenderPonyZombie(rm));
MineLPLogger.info("Zombie pigmen are now ponies.");
}
if (this.config.skeletons) {
ModUtilities.addRenderer(EntitySkeleton.class, new RenderPonySkeleton(rm));
MineLPLogger.info("Skeletons are now ponies.");
}
}
@Override
public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) {
if (inGame && minecraft.currentScreen == null && guiKeybinding.isPressed()) {
minecraft.displayGuiScreen(new PonySettingPanel());
}
boolean pressed = minecraft.currentScreen instanceof GuiMainMenu
&& Keyboard.isKeyDown(skinKeybinding.getKeyCode());
boolean skins = minecraft.currentScreen instanceof GuiSkins
&& !(minecraft.currentScreen instanceof GuiSkinsMineLP);
if (pressed || skins) {
minecraft.displayGuiScreen(new GuiSkinsMineLP(ponyManager));
}
HDSkinManager.INSTANCE.setEnabled(config.hd);
}
}

View file

@ -1,43 +1,8 @@
package com.brohoof.minelittlepony;
import java.io.File;
import org.lwjgl.input.Keyboard;
import com.brohoof.minelittlepony.gui.MineLittlePonyGUI;
import com.brohoof.minelittlepony.gui.MineLittlePonyGUIMob;
import com.brohoof.minelittlepony.hdskins.gui.EntityPonyModel;
import com.brohoof.minelittlepony.hdskins.gui.GuiSkinsMineLP;
import com.brohoof.minelittlepony.hdskins.gui.RenderPonyModel;
import com.brohoof.minelittlepony.renderer.RenderPonySkeleton;
import com.brohoof.minelittlepony.renderer.RenderPonyVillager;
import com.brohoof.minelittlepony.renderer.RenderPonyZombie;
import com.brohoof.minelittlepony.util.MineLPLogger;
import com.mumfrey.liteloader.InitCompleteListener;
import com.mumfrey.liteloader.core.LiteLoader;
import com.mumfrey.liteloader.util.ModUtilities;
import com.voxelmodpack.common.properties.gui.SettingsPanelManager;
import com.voxelmodpack.hdskins.HDSkinManager;
import com.voxelmodpack.hdskins.gui.GuiSkins;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiMainMenu;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.monster.EntityPigZombie;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityVillager;
public class MineLittlePony implements InitCompleteListener {
public static final String MOD_VERSION = "@VERSION@";
public static final String MOD_NAME = "Mine Little Pony";
public static final String SKIN_SERVER_URL = "minelpskins.voxelmodpack.com";
public static final String GATEWAY_URL = "minelpskinmanager.voxelmodpack.com";
public static final String UPLOAD_URL = "http://minelpskinmanager.voxelmodpack.com/";
private static final KeyBinding guiKeybinding = new KeyBinding("Settings", Keyboard.KEY_F9, "Mine Little Pony");
private static final KeyBinding skinKeybinding = new KeyBinding("Skin Manager", Keyboard.KEY_F1, "Mine Little Pony");
public class MineLittlePony {
private static MineLittlePony instance;
@ -45,90 +10,17 @@ public class MineLittlePony implements InitCompleteListener {
private PonyManager ponyManager;
private ProxyContainer proxy;
public MineLittlePony() {
instance = this;
}
public static MineLittlePony getInstance() {
return instance;
}
@Override
public String getName() {
return MOD_NAME;
}
@Override
public String getVersion() {
return MOD_VERSION;
}
@Override
public void upgradeSettings(String version, File configPath, File oldConfigPath) {}
@Override
public void init(File configPath) {
LiteLoader.getInput().registerKeyBinding(guiKeybinding);
LiteLoader.getInput().registerKeyBinding(skinKeybinding);
SettingsPanelManager.addSettingsPanel("Pony", MineLittlePonyGUI.class);
SettingsPanelManager.addSettingsPanel("Pony Mobs", MineLittlePonyGUIMob.class);
private MineLittlePony() {
this.config = new PonyConfig();
this.ponyManager = new PonyManager(config);
this.proxy = new ProxyContainer();
LiteLoader.getInstance().registerExposable(config, null);
}
@Override
public void onInitCompleted(Minecraft minecraft, LiteLoader loader) {
HDSkinManager.clearSkinCache();
HDSkinManager manager = HDSkinManager.INSTANCE;
manager.setSkinUrl(config.skinfix ? GATEWAY_URL : SKIN_SERVER_URL);
manager.setGatewayURL(GATEWAY_URL);
manager.addSkinModifier(new PonySkinModifier());
MineLPLogger.info("Set MineLP skin server URL.");
RenderManager rm = minecraft.getRenderManager();
ModUtilities.addRenderer(EntityPonyModel.class, new RenderPonyModel(rm));
if (this.config.getVillagers().get()) {
ModUtilities.addRenderer(EntityVillager.class, new RenderPonyVillager(rm));
MineLPLogger.info("Villagers are now ponies.");
}
if (this.config.getZombies().get()) {
ModUtilities.addRenderer(EntityZombie.class, new RenderPonyZombie(rm));
MineLPLogger.info("Zombies are now ponies.");
}
if (this.config.getPigZombies().get()) {
ModUtilities.addRenderer(EntityPigZombie.class, new RenderPonyZombie(rm));
MineLPLogger.info("Zombie pigmen are now ponies.");
}
if (this.config.getSkeletons().get()) {
ModUtilities.addRenderer(EntitySkeleton.class, new RenderPonySkeleton(rm));
MineLPLogger.info("Skeletons are now ponies.");
}
}
@Override
public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) {
if (inGame && minecraft.currentScreen == null && guiKeybinding.isPressed()) {
minecraft.displayGuiScreen(new MineLittlePonyGUI());
}
boolean pressed = minecraft.currentScreen instanceof GuiMainMenu
&& Keyboard.isKeyDown(skinKeybinding.getKeyCode());
boolean skins = minecraft.currentScreen instanceof GuiSkins
&& !(minecraft.currentScreen instanceof GuiSkinsMineLP);
if (pressed || skins) {
minecraft.displayGuiScreen(new GuiSkinsMineLP(ponyManager));
}
HDSkinManager.INSTANCE.setEnabled(config.getHd().get());
public static MineLittlePony getInstance() {
if (instance == null)
instance = new MineLittlePony();
return instance;
}
public PonyManager getManager() {
@ -146,5 +38,4 @@ public class MineLittlePony implements InitCompleteListener {
public static String getSPUsername() {
return Minecraft.getMinecraft().getSession().getUsername();
}
}

View file

@ -1,13 +1,14 @@
package com.brohoof.minelittlepony;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import com.brohoof.minelittlepony.model.PMAPI;
import com.brohoof.minelittlepony.model.PlayerModel;
import com.brohoof.minelittlepony.util.MineLPLogger;
import com.voxelmodpack.common.runtime.PrivateFields;
import com.brohoof.minelittlepony.util.PonyFields;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer;
@ -66,17 +67,18 @@ public class Pony {
BufferedImage skinImage = null;
try {
skinImage = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(textureResourceLocation)
.getInputStream());
skinImage = ImageIO.read(Minecraft.getMinecraft().getResourceManager()
.getResource(textureResourceLocation).getInputStream());
MineLPLogger.debug("Obtained skin from resource location %s", textureResourceLocation);
// this.checkSkin(skinImage);
} catch (Exception var6) {
} catch (IOException var6) {
Exception e = var6;
try {
ITextureObject e2 = Minecraft.getMinecraft().getTextureManager().getTexture(textureResourceLocation);
if (e2 instanceof ThreadDownloadImageData) {
skinImage = PrivateFields.downloadedImage.get((ThreadDownloadImageData) e2);
skinImage = PonyFields.downloadedImage.get((ThreadDownloadImageData) e2);
if (skinImage != null) {
MineLPLogger.debug(e, "Successfully reflected downloadedImage from texture object");
// this.checkSkin(skinImage);
@ -105,7 +107,7 @@ public class Pony {
public PlayerModel getModel(boolean ignorePony, boolean smallArms) {
boolean is_a_pony = false;
switch (ignorePony ? PonyLevel.BOTH : config.getPonyLevel().get()) {
switch (ignorePony ? PonyLevel.BOTH : config.getPonyLevel()) {
case HUMANS:
is_a_pony = false;
break;

View file

@ -1,86 +1,41 @@
package com.brohoof.minelittlepony;
import java.io.File;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.Expose;
import com.mumfrey.liteloader.modconfig.AdvancedExposable;
import com.mumfrey.liteloader.modconfig.ConfigStrategy;
import com.mumfrey.liteloader.modconfig.Exposable;
import com.mumfrey.liteloader.modconfig.ExposableOptions;
import net.minecraft.util.EnumTypeAdapterFactory;
@ExposableOptions(filename = "minelittlepony", strategy = ConfigStrategy.Unversioned)
public class PonyConfig implements AdvancedExposable {
public class PonyConfig implements Exposable {
@Expose
private Value<PonyLevel> ponylevel = new Value<PonyLevel>(PonyLevel.PONIES);
private PonyLevel ponylevel = PonyLevel.PONIES;
@Expose
private Value<Boolean> sizes = new Value<Boolean>(true);
public boolean sizes = true;
@Expose
private Value<Boolean> snuzzles = new Value<Boolean>(true);
public boolean snuzzles = true;
@Expose
private Value<Boolean> hd = new Value<Boolean>(true);
public boolean hd = true;
@Expose
private Value<Boolean> showscale = new Value<Boolean>(true);
public boolean showscale = true;
@Expose
private Value<Boolean> villagers = new Value<Boolean>(true);
public boolean villagers = true;
@Expose
private Value<Boolean> zombies = new Value<Boolean>(true);
public boolean zombies = true;
@Expose
private Value<Boolean> pigzombies = new Value<Boolean>(true);
public boolean pigzombies = true;
@Expose
private Value<Boolean> skeletons = new Value<Boolean>(true);
@Expose
public boolean skinfix = true;
public boolean skeletons = true;
public Value<PonyLevel> getPonyLevel() {
if (ponylevel.get() == null)
ponylevel.set(PonyLevel.PONIES);
public PonyLevel getPonyLevel() {
if (ponylevel == null)
ponylevel = PonyLevel.PONIES;
return ponylevel;
}
public Value<Boolean> getSizes() {
return sizes;
public void setPonyLevel(PonyLevel ponylevel) {
if (ponylevel == null)
ponylevel = PonyLevel.PONIES;
this.ponylevel = ponylevel;
}
public Value<Boolean> getSnuzzles() {
return snuzzles;
}
public Value<Boolean> getHd() {
return hd;
}
public Value<Boolean> getShowScale() {
return showscale;
}
public Value<Boolean> getVillagers() {
return villagers;
}
public Value<Boolean> getZombies() {
return zombies;
}
public Value<Boolean> getPigZombies() {
return pigzombies;
}
public Value<Boolean> getSkeletons() {
return skeletons;
}
@Override
public void setupGsonSerialiser(GsonBuilder gsonBuilder) {
gsonBuilder.registerTypeAdapterFactory(new EnumTypeAdapterFactory())
.registerTypeAdapter(Value.class, new Value.Serializer());
}
@Override
public File getConfigFile(File configFile, File configFileLocation, String defaultFileName) {
return null;
}
}

View file

@ -61,7 +61,7 @@ public class PonyData {
}
public PonySize getSize() {
return MineLittlePony.getConfig().getSizes().get() ? size : PonySize.NORMAL;
return MineLittlePony.getConfig().sizes ? size : PonySize.NORMAL;
}
public void setSize(PonySize size) {

View file

@ -2,6 +2,7 @@ package com.brohoof.minelittlepony;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import com.brohoof.minelittlepony.model.PMAPI;
import com.brohoof.minelittlepony.util.MineLPLogger;
@ -83,7 +84,7 @@ public class PonyManager {
public Pony getPonyFromResourceRegistry(AbstractClientPlayer player) {
Pony myLittlePony = this.getPonyFromResourceRegistry(player.getLocationSkin(), player);
if (config.getPonyLevel().get() == PonyLevel.PONIES && myLittlePony.metadata.getRace() == null) {
if (config.getPonyLevel() == PonyLevel.PONIES && myLittlePony.metadata.getRace() == null) {
myLittlePony = this.getPonyFromBackgroundResourceRegistry(player);
}
@ -105,9 +106,9 @@ public class PonyManager {
return myLittlePony;
}
private ResourceLocation getBackgroundPonyResource(AbstractClientPlayer player) {
public ResourceLocation getBackgroundPonyResource(UUID id) {
if (getNumberOfPonies() > 0) {
int backgroundIndex = player.getUniqueID().hashCode() % this.getNumberOfPonies();
int backgroundIndex = id.hashCode() % this.getNumberOfPonies();
if (backgroundIndex < 0) {
backgroundIndex += this.getNumberOfPonies();
}
@ -120,9 +121,9 @@ public class PonyManager {
public Pony getPonyFromBackgroundResourceRegistry(AbstractClientPlayer player) {
ResourceLocation textureResourceLocation;
if (player.isUser()) {
textureResourceLocation = (player.getUniqueID().hashCode() & 1) == 0 ? STEVE : ALEX;
textureResourceLocation = getDefaultSkin(player.getUniqueID());
} else {
textureResourceLocation = this.getBackgroundPonyResource(player);
textureResourceLocation = this.getBackgroundPonyResource(player.getUniqueID());
}
Pony myLittlePony;
@ -136,6 +137,10 @@ public class PonyManager {
return myLittlePony;
}
public static ResourceLocation getDefaultSkin(UUID uuid) {
return (uuid.hashCode() & 1) == 0 ? STEVE : ALEX;
}
public int getNumberOfPonies() {
return backgroundPonyList.size();
}

View file

@ -1,45 +0,0 @@
package com.brohoof.minelittlepony;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.mumfrey.liteloader.core.LiteLoader;
public class Value<T> {
private T value;
public Value(T value) {
this.value = value;
}
public T get() {
return value;
}
public void set(T val) {
this.value = val;
LiteLoader.getInstance().writeConfig(MineLittlePony.getConfig());
}
public static class Serializer implements JsonSerializer<Value<?>>, JsonDeserializer<Value<?>> {
@Override
public Value<?> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
Type type = ((ParameterizedType) typeOfT).getActualTypeArguments()[0];
return new Value<Object>(context.deserialize(json, type));
}
@Override
public JsonElement serialize(Value<?> src, Type typeOfSrc, JsonSerializationContext context) {
return context.serialize(src.get());
}
}
}

View file

@ -1,49 +0,0 @@
package com.brohoof.minelittlepony.gui;
import com.brohoof.minelittlepony.Value;
import com.voxelmodpack.common.LiteModVoxelCommon;
import com.voxelmodpack.common.gui.interfaces.IExtendedGui;
import com.voxelmodpack.common.properties.VoxelProperty;
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProviderInteger;
import net.minecraft.client.resources.I18n;
public class FakeVoxelPropertyToggleBox extends VoxelProperty<IVoxelPropertyProviderInteger> {
private Value<Boolean> value;
private int width = 11;
public FakeVoxelPropertyToggleBox(Value<Boolean> value, String text, int xPos,
int yPos) {
super(null, null, text, xPos, yPos);
this.value = value;
this.width = this.fontRenderer.getStringWidth(I18n.format(this.displayText)) + 20;
}
@Override
public void draw(IExtendedGui host, int mouseX, int mouseY) {
this.drawString(this.fontRenderer, I18n.format(this.displayText), this.xPosition + 20, this.yPosition + 2, 16777215);
boolean overButton = this.mouseOver(mouseX, mouseY);
boolean checked = this.value.get();
host.drawTessellatedModalBorderRect(LiteModVoxelCommon.GUIPARTS, 256, this.xPosition, this.yPosition,
this.xPosition + 11, this.yPosition + 11, 0, overButton ? 16 : 0, 16, overButton ? 32 : 16, 4);
host.drawTexturedModalRect(LiteModVoxelCommon.GUIPARTS, this.xPosition, this.yPosition, this.xPosition + 10,
this.yPosition + 10, checked ? 12 : 0, 52, checked ? 23 : 11, 63);
}
@Override
public void mouseClicked(int mouseX, int mouseY) {
if (this.mouseOver(mouseX, mouseY)) {
value.set(!value.get());
}
}
public boolean mouseOver(int mouseX, int mouseY) {
return mouseX > this.xPosition && mouseX < this.xPosition + this.width && mouseY > this.yPosition
&& mouseY < this.yPosition + 11;
}
@Override
public void keyTyped(char keyChar, int keyCode) {}
}

View file

@ -1,10 +0,0 @@
package com.brohoof.minelittlepony.gui;
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProvider;
public interface IPropertyProviderEnum<E extends Enum<E>> extends IVoxelPropertyProvider {
void setProperty(String key, E val);
E getEnumProperty(String key);
}

View file

@ -1,53 +0,0 @@
package com.brohoof.minelittlepony.gui;
import com.brohoof.minelittlepony.MineLittlePony;
import com.brohoof.minelittlepony.PonyConfig;
import com.brohoof.minelittlepony.PonyLevel;
import com.brohoof.minelittlepony.Value;
import com.mumfrey.liteloader.core.LiteLoader;
import com.voxelmodpack.common.properties.VoxelProperty;
import com.voxelmodpack.common.properties.VoxelPropertyLabel;
import com.voxelmodpack.common.properties.gui.GuiVoxelBoxSettingsPanel;
import net.minecraft.client.resources.I18n;
public class MineLittlePonyGUI extends GuiVoxelBoxSettingsPanel {
private static final String _PREFIX = "minelp.options.";
private static final String TITLE = _PREFIX + "title";
private static final String PONY_LEVEL = _PREFIX + "ponylevel";
private static final String OPTIONS = _PREFIX + "options";
private static final String HD = _PREFIX + "hd";
private static final String SIZES = _PREFIX + "sizes";
private static final String SNUZZLES = _PREFIX + "snuzzles";
private static final String SHOW_SCALE = _PREFIX + "showscale";
private PonyConfig config;
public MineLittlePonyGUI() {
this.config = MineLittlePony.getConfig();
final byte col1 = 30;
int row = PANEL_TOP;
this.properties.add(new VoxelPropertyEnum<PonyLevel>(config.getPonyLevel(), PONY_LEVEL, PONY_LEVEL + ".",
PANEL_LEFT, row += 24, PonyLevel.class));
this.properties.add(new VoxelPropertyLabel(I18n.format(OPTIONS), PANEL_LEFT + 15, row += 45));
this.properties.add(check(config.getHd(), HD, PANEL_LEFT + col1, row += 15));
this.properties.add(check(config.getSizes(), SIZES, PANEL_LEFT + col1, row += 15));
this.properties.add(check(config.getSnuzzles(), SNUZZLES, PANEL_LEFT + col1, row += 15));
this.properties.add(check(config.getShowScale(), SHOW_SCALE, PANEL_LEFT + col1, row += 15));
}
private VoxelProperty<?> check(Value<Boolean> config, String text, int xPos, int yPos) {
return new FakeVoxelPropertyToggleBox(config, text, xPos, yPos);
}
@Override
public String getPanelTitle() {
return I18n.format(TITLE);
}
@Override
public void onGuiClosed() {
LiteLoader.getInstance().writeConfig(config);
}
}

View file

@ -1,52 +0,0 @@
package com.brohoof.minelittlepony.gui;
import com.brohoof.minelittlepony.MineLittlePony;
import com.brohoof.minelittlepony.PonyConfig;
import com.brohoof.minelittlepony.Value;
import com.mumfrey.liteloader.core.LiteLoader;
import com.voxelmodpack.common.properties.VoxelProperty;
import com.voxelmodpack.common.properties.VoxelPropertyLabel;
import com.voxelmodpack.common.properties.gui.GuiVoxelBoxSettingsPanel;
import net.minecraft.client.resources.I18n;
public class MineLittlePonyGUIMob extends GuiVoxelBoxSettingsPanel {
private static final String pref = "minelp.mobs.";
private static final String restart1 = "minelp.restart1";
private static final String restart2 = "minelp.restart2";
private static final String title = pref + "title";
private static final String villagers = pref + "villagers";
private static final String zombies = pref + "zombies";
private static final String zombiePigmen = pref + "zombiepigmen";
private static final String skeletons = pref + "skeletons";
private PonyConfig config;
public MineLittlePonyGUIMob() {
this.config = MineLittlePony.getConfig();
byte col1 = 30;
this.properties.add(new VoxelPropertyLabel(I18n.format(restart1), PANEL_LEFT + 15, PANEL_TOP + 11, 0xff6666));
this.properties.add(new VoxelPropertyLabel(I18n.format(restart2), PANEL_LEFT + 15, PANEL_TOP + 23, 0xff6666));
this.properties.add(check(config.getVillagers(), villagers, PANEL_LEFT + col1, PANEL_TOP + 42));
this.properties.add(check(config.getZombies(), zombies, PANEL_LEFT + col1, PANEL_TOP + 60));
this.properties.add(check(config.getPigZombies(), zombiePigmen, PANEL_LEFT + col1, PANEL_TOP + 78));
this.properties.add(check(config.getSkeletons(), skeletons, PANEL_LEFT + col1, PANEL_TOP + 96));
}
private VoxelProperty<?> check(Value<Boolean> config, String text, int xPos, int yPos) {
return new FakeVoxelPropertyToggleBox(config, text, xPos, yPos);
}
@Override
public String getPanelTitle() {
return I18n.format(title);
}
@Override
public void onGuiClosed() {
LiteLoader.getInstance().writeConfig(config);
}
}

View file

@ -0,0 +1,177 @@
package com.brohoof.minelittlepony.gui;
import java.io.IOException;
import com.brohoof.minelittlepony.MineLittlePony;
import com.brohoof.minelittlepony.PonyConfig;
import com.brohoof.minelittlepony.PonyLevel;
import com.mumfrey.liteloader.client.gui.GuiCheckbox;
import com.mumfrey.liteloader.core.LiteLoader;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
public class PonySettingPanel extends GuiScreen {
private static final String _PREFIX = "minelp.options.";
private static final String TITLE = _PREFIX + "title";
private static final String PONY_LEVEL = _PREFIX + "ponylevel";
private static final String PONY = PONY_LEVEL + ".ponies";
private static final String HUMAN = PONY_LEVEL + ".humans";
private static final String BOTH = PONY_LEVEL + ".both";
private static final String OPTIONS = _PREFIX + "options";
private static final String HD = _PREFIX + "hd";
private static final String SIZES = _PREFIX + "sizes";
private static final String SNUZZLES = _PREFIX + "snuzzles";
private static final String SHOW_SCALE = _PREFIX + "showscale";
private static final String MOB_PREFIX = "minelp.mobs.";
private static final String RESTART = "minelp.restart";
private static final String MOB_TITLE = MOB_PREFIX + "title";
private static final String VILLAGERS = MOB_PREFIX + "villagers";
private static final String ZOMBIES = MOB_PREFIX + "zombies";
private static final String ZOMBIE_PIGMEN = MOB_PREFIX + "zombiepigmen";
private static final String SKELETONS = MOB_PREFIX + "skeletons";
private static final int PONY_ID = 0;
private static final int HUMAN_ID = 1;
private static final int BOTH_ID = 2;
private static final int HD_ID = 3;
private static final int SIZES_ID = 4;
private static final int SNUZZLES_ID = 5;
private static final int SHOW_SCALE_ID = 6;
private static final int VILLAGERS_ID = 7;
private static final int ZOMBIES_ID = 8;
private static final int ZOMBIE_PIGMEN_ID = 9;
private static final int SKELETONS_ID = 10;
private PonyConfig config;
private GuiCheckbox ponies;
private GuiCheckbox humans;
private GuiCheckbox both;
public PonySettingPanel() {
config = MineLittlePony.getConfig();
}
@Override
public void initGui() {
final int LEFT = width / 10 + 16;
GuiCheckbox pony, human, both, hd, sizes, snuzzles, showscale, villager, zombie, pigmen, skeleton;
int row = 32;
this.buttonList.add(pony = ponies = new GuiCheckbox(PONY_ID, LEFT, row += 15, I18n.format(PONY)));
this.buttonList.add(human = humans = new GuiCheckbox(HUMAN_ID, LEFT, row += 15, I18n.format(HUMAN)));
this.buttonList.add(both = this.both = new GuiCheckbox(BOTH_ID, LEFT, row += 15, I18n.format(BOTH)));
row += 15;
this.buttonList.add(hd = new GuiCheckbox(HD_ID, LEFT, row += 15, I18n.format(HD)));
this.buttonList.add(sizes = new GuiCheckbox(SIZES_ID, LEFT, row += 15, I18n.format(SIZES)));
this.buttonList.add(snuzzles = new GuiCheckbox(SNUZZLES_ID, LEFT, row += 15, I18n.format(SNUZZLES)));
this.buttonList.add(showscale = new GuiCheckbox(SHOW_SCALE_ID, LEFT, row += 15, I18n.format(SHOW_SCALE)));
final int RIGHT = width - width / 3;
row = 32;
this.buttonList.add(villager = new GuiCheckbox(VILLAGERS_ID, RIGHT, row += 15, I18n.format(VILLAGERS)));
this.buttonList.add(zombie = new GuiCheckbox(ZOMBIES_ID, RIGHT, row += 15, I18n.format(ZOMBIES)));
this.buttonList.add(pigmen = new GuiCheckbox(ZOMBIE_PIGMEN_ID, RIGHT, row += 15, I18n.format(ZOMBIE_PIGMEN)));
this.buttonList.add(skeleton = new GuiCheckbox(SKELETONS_ID, RIGHT, row += 15, I18n.format(SKELETONS)));
switch (config.getPonyLevel()) {
default:
case PONIES:
pony.checked = true;
break;
case HUMANS:
human.checked = true;
break;
case BOTH:
both.checked = true;
break;
}
hd.checked = config.hd;
sizes.checked = config.sizes;
snuzzles.checked = config.snuzzles;
showscale.checked = config.showscale;
villager.checked = config.villagers;
zombie.checked = config.zombies;
pigmen.checked = config.pigzombies;
skeleton.checked = config.skeletons;
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.drawDefaultBackground();
this.drawCenteredString(mc.fontRendererObj, I18n.format(TITLE), width / 2, 12, -1);
this.drawString(mc.fontRendererObj, I18n.format(MOB_TITLE), width - width / 3 - 16, 32, -1);
this.drawString(mc.fontRendererObj, I18n.format(PONY_LEVEL), width / 10, 32, -1);
this.drawString(mc.fontRendererObj, I18n.format(OPTIONS), width / 10, 94, -1);
this.mc.fontRendererObj.drawSplitString(I18n.format(RESTART), width - width / 3, 120, width / 3, 0xFF5555);
super.drawScreen(mouseX, mouseY, partialTicks);
}
@Override
protected void actionPerformed(GuiButton button) throws IOException {
if (button instanceof GuiCheckbox) {
boolean checked = !((GuiCheckbox) button).checked;
((GuiCheckbox) button).checked = checked;
switch (button.id) {
case PONY_ID:
config.setPonyLevel(PonyLevel.PONIES);
ponies.checked = true;
humans.checked = false;
both.checked = false;
break;
case HUMAN_ID:
config.setPonyLevel(PonyLevel.HUMANS);
humans.checked = true;
ponies.checked = false;
both.checked = false;
break;
case BOTH_ID:
config.setPonyLevel(PonyLevel.BOTH);
both.checked = true;
ponies.checked = false;
humans.checked = false;
break;
case HD_ID:
config.hd = checked;
break;
case SIZES_ID:
config.sizes = checked;
break;
case SNUZZLES_ID:
config.snuzzles = checked;
break;
case SHOW_SCALE_ID:
config.showscale = checked;
break;
case VILLAGERS_ID:
config.villagers = checked;
break;
case ZOMBIES_ID:
config.zombies=checked;
break;
case ZOMBIE_PIGMEN_ID:
config.pigzombies = checked;
break;
case SKELETONS_ID:
config.skeletons=checked;
break;
}
}
}
@Override
public void onGuiClosed() {
LiteLoader.getInstance().writeConfig(config);
}
}

View file

@ -1,110 +0,0 @@
package com.brohoof.minelittlepony.gui;
import com.brohoof.minelittlepony.Value;
import com.voxelmodpack.common.LiteModVoxelCommon;
import com.voxelmodpack.common.gui.interfaces.IExtendedGui;
import com.voxelmodpack.common.properties.VoxelProperty;
import net.minecraft.client.resources.I18n;
public class VoxelPropertyEnum<E extends Enum<E>> extends VoxelProperty<IPropertyProviderEnum<E>> {
private Value<E> value;
private E[] possibleValues;
private String i18NPrefix;
private int height = 15;
private int defaultX;
private int defaultW;
public VoxelPropertyEnum(Value<E> value, String displayText, String i18nPrefix, int xPos, int yPos,
Class<E> eclass) {
super(null, null, displayText, xPos, yPos);
this.value = value;
this.i18NPrefix = i18nPrefix;
this.possibleValues = eclass.getEnumConstants();
defaultX = xPosition + 150;
defaultW = 55;
}
@Override
public void draw(IExtendedGui gui, int mouseX, int mouseY) {
boolean overReset = mouseOverReset(mouseX, mouseY);
int outset = overReset ? 1 : 0;
int v = overReset ? 16 : 0;
drawRect(defaultX - outset, this.yPosition + 11 - outset,
defaultX + defaultW + outset - 1, this.yPosition + 26 + outset,
-16777216);
gui.drawTessellatedModalBorderRect(LiteModVoxelCommon.GUIPARTS, 256,
defaultX - 1 - outset, this.yPosition + 10 - outset,
defaultX + outset + defaultW, this.yPosition + 27 + outset,
0, v, 16, 16 + v, 4);
this.drawString(this.mc.fontRendererObj, "Default", defaultX + 8, this.yPosition + 15,
overReset ? 16777215 : 10066329);
if (this.displayText != null) {
this.drawString(this.mc.fontRendererObj, I18n.format(this.displayText), this.xPosition + 15,
this.yPosition - 14, 10079487);
}
for (int i = 0; i < possibleValues.length; i++) {
drawRadio(gui, mouseX, mouseY, i);
}
}
public void drawRadio(IExtendedGui host, int mouseX, int mouseY, int idx) {
boolean overButton = this.mouseOver(mouseX, mouseY, idx);
boolean checked = this.possibleValues[idx] == value.get();
int xPos = xPosition + 30;
int yPos = yPosition + (height * idx);
E e = possibleValues[idx];
String text = I18n.format(i18NPrefix + e.toString().toLowerCase());
this.drawString(this.fontRenderer, text, xPos + 20, yPos + 2, 0xffffff);
// the border
host.drawTessellatedModalBorderRect(LiteModVoxelCommon.GUIPARTS, 256, xPos, yPos,
xPos + 11, yPos + 11, 0, overButton ? 16 : 0, 16, overButton ? 32 : 16, 4);
// the check
host.drawTexturedModalRect(LiteModVoxelCommon.GUIPARTS, xPos, yPos, xPos + 10,
yPos + 10, checked ? 12 : 0, 52, checked ? 23 : 11, 63);
}
protected boolean mouseIn(int mouseX, int mouseY, int x1, int y1, int x2, int y2) {
return mouseX > x1 + 5 && mouseX < x2 + 5 && mouseY > y1 && mouseY < y2;
}
protected boolean mouseOverReset(int mouseX, int mouseY) {
return mouseX > this.defaultX && mouseX < this.defaultX + this.defaultW
&& mouseY > this.yPosition + 10 && mouseY < this.yPosition + 27;
}
@Override
public void mouseClicked(int mouseX, int mouseY) {
if (mouseOverReset(mouseX, mouseY)) {
value.set(possibleValues[0]);
} else {
for (int i = 0; i < possibleValues.length; i++) {
if (mouseOver(mouseX, mouseY, i)) {
value.set(possibleValues[i]);
return;
}
}
}
}
protected boolean mouseOver(int mouseX, int mouseY, int idx) {
E e = possibleValues[idx];
int yPos = yPosition + (height * idx);
int width = 20 + mc.fontRendererObj.getStringWidth(I18n.format(i18NPrefix + e.toString().toLowerCase()));
return mouseX > this.xPosition + 30 && mouseX < this.xPosition + width + 30
&& mouseY > yPos && mouseY < yPos + 11;
}
@Override
public void keyTyped(char keyChar, int keyCode) {}
}

View file

@ -81,7 +81,7 @@ public abstract class MixinRenderPlayer extends RendererLivingEntity implements
this.playerModel.getModel().isSneak = player.isSneaking();
this.playerModel.getModel().isFlying = thePony.isPegasusFlying(player);
if (MineLittlePony.getConfig().getShowScale().get()) {
if (MineLittlePony.getConfig().showscale) {
if (this.playerModel.getModel().metadata.getRace() != null) {
PonySize size = thePony.metadata.getSize();
if (size == PonySize.FOAL)
@ -118,7 +118,7 @@ public abstract class MixinRenderPlayer extends RendererLivingEntity implements
@Inject(method = "renderLivingAt", at = @At("RETURN") )
private void setupPlayerScale(AbstractClientPlayer player, double xPosition, double yPosition, double zPosition, CallbackInfo ci) {
if (MineLittlePony.getConfig().getShowScale().get() && !(playerModel.getModel() instanceof ModelHumanPlayer)) {
if (MineLittlePony.getConfig().showscale && !(playerModel.getModel() instanceof ModelHumanPlayer)) {
PonySize size = thePony.metadata.getSize();
if (size == PonySize.LARGE)
scale(0.9F, 0.9F, 0.9F);

View file

@ -76,7 +76,7 @@ public class PonySnout extends AbstractHeadPart implements PonyModelConstants {
@Override
public void render(PonyData data, float scale) {
super.render(data, scale);
if (MineLittlePony.getConfig().getSnuzzles().get() && data.getGender() != null) {
if (MineLittlePony.getConfig().snuzzles && data.getGender() != null) {
PlaneRenderer[] muzzle = map.get(data.getGender());
for (int i = 0; i < muzzle.length; i++) {
muzzle[i].render(scale);

View file

@ -72,7 +72,7 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
this.playerModel.getModel().metadata.setGender(PonyGender.MARE);
this.playerModel.getModel().metadata.setTail(TailLengths.FULL);
if (MineLittlePony.getConfig().getShowScale().get()) {
if (MineLittlePony.getConfig().showscale) {
this.shadowSize = 0.4F;
}

View file

@ -21,7 +21,7 @@ public class RenderPonyVillager extends RenderPonyMob<EntityVillager> {
if (villager.getGrowingAge() < 0) {
this.shadowSize = 0.25F;
} else {
if (MineLittlePony.getConfig().getShowScale().get()) {
if (MineLittlePony.getConfig().showscale) {
this.shadowSize = 0.4F;
} else {
this.shadowSize = 0.5F;

View file

@ -0,0 +1,32 @@
package com.brohoof.minelittlepony.util;
import java.awt.image.BufferedImage;
import com.mumfrey.liteloader.core.runtime.Obf;
import com.mumfrey.liteloader.util.PrivateFields;
import net.minecraft.client.renderer.ThreadDownloadImageData;
public class PonyFields<P, T> extends PrivateFields<P, T> {
public static final PrivateFields<ThreadDownloadImageData, BufferedImage> downloadedImage = field(ThreadDownloadImageData.class, PonyObf.downloadedImage);
protected PonyFields(Class<P> owner, Obf obf) {
super(owner, obf);
}
private static <P, T> PrivateFields<P, T> field(Class<P> c, Obf o) {
return new PonyFields<P, T>(c, o);
}
private static class PonyObf extends Obf {
public static Obf downloadedImage = new PonyObf("field_110560_d", "l", "bufferedImage");
protected PonyObf(String seargeName, String obfName, String mcpName) {
super(seargeName, obfName, mcpName);
// TODO Auto-generated constructor stub
}
}
}

View file

@ -1,5 +1,4 @@
minelp.restart1=If you make any changes here, you must restart
minelp.restart2=Minecraft before they will take effect!
minelp.restart=If you make any changes here, you must restart Minecraft before they will take effect!
minelp.options.title=Mine Little Pony Settings
minelp.options.ponylevel=Pony Level
@ -12,7 +11,7 @@ minelp.options.sizes=Allow all different sizes of pony
minelp.options.snuzzles=Display snuzzles on ponies
minelp.options.showscale=Use show-accurate scaling
minelp.mobs.title=Mine Little Pony Mob Settings
minelp.mobs.title=Mob Settings
minelp.mobs.villagers=Ponify villagers
minelp.mobs.zombies=Ponify zombies
minelp.mobs.zombiepigmen=Ponify zombie pigmen

View file

@ -1,7 +1,6 @@
# Mine Little Pony fr_FR.lang file
# Provided by Dalfio (PinkishPie)
minelp.restart1=Si vous apportez des modifications ici, vous devez redémarrer
minelp.restart2=Minecraft avant qu'ils prennent effet!
minelp.restart=Si vous apportez des modifications ici, vous devez redémarrer Minecraft avant qu'ils prennent effet!
minelp.options.title=Options Mine Little Pony
minelp.options.ponylevel=Niveau Poney
@ -15,7 +14,7 @@ minelp.options.ponyarmor=Utiliser armure compatible de MineLP
minelp.options.snuzzles=Afficher museau sur les poneys
minelp.options.showscale=Utiliser échelle fidèle à MLP
minelp.mobs.title=Options de mobs Mine Little Pony
minelp.mobs.title=Options de mobs
minelp.mobs.villagers=Ponifier villageois
minelp.mobs.zombies=Ponifier zombies
minelp.mobs.zombiepigmen=Ponifier zombie pigmen

View file

@ -1,5 +1,4 @@
minelp.restart1=Если вы измените эти параметры,
minelp.restart2=то для их активации вы должны перезапустить игру!
minelp.restart=Если вы измените эти параметры, то для их активации вы должны перезапустить игру!
minelp.options.title=Настроайки мода Mine Little Pony
minelp.options.ponylevel=Уровень понификации
minelp.options.ponylevel.ponies=Только пони

View file

@ -4,7 +4,6 @@
"version": "${version}",
"revision": "${revision}",
"author": "Verdana, Rene_Z, Mumfrey, JoyJoy",
"voxelCommonJarName": "voxelcommon-2.4.0.jar",
"mixinConfigs": [ "mixin.minelp.json", "mixin.hdskins.json" ],
"description": "Mine Little Pony turns players and mobs into ponies",
"description.minelittlepony": "Mine Little Pony turns players and mobs into ponies",

View file

@ -1,28 +0,0 @@
apply plugin: 'net.minecraftforge.gradle.tweaker-client'
archivesBaseName = "voxelcommon"
version = "2.4.0"
minecraft {
version = "1.8"
mappings = 'snapshot_20151027'
runDir = '../run'
tweakClass = 'com.mumfrey.liteloader.launch.LiteLoaderTweaker'
}
repositories.flatDir {
dir '../liteloader'
}
dependencies {
compile rootProject.project('LiteLoader')
}
jar {
manifest.attributes.remove 'TweakClass'
classifier 'dev'
}
task obfJar(type:Jar) {
from sourceSets.main.output
}
reobf {
jar.task.enabled = false
obfJar {}
}

View file

@ -1,131 +0,0 @@
package com.voxelmodpack.common;
import java.io.File;
import java.util.LinkedList;
import java.util.List;
import com.google.common.collect.ImmutableList;
import com.mumfrey.liteloader.PacketHandler;
import com.mumfrey.liteloader.Priority;
import com.voxelmodpack.common.interfaces.ITimeHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.network.INetHandler;
import net.minecraft.network.Packet;
import net.minecraft.network.play.INetHandlerPlayClient;
import net.minecraft.network.play.server.S03PacketTimeUpdate;
import net.minecraft.util.ResourceLocation;
/**
* Main mod class for VoxelCommon
*
* @author Adam Mummery-Smith
*/
@Priority(0)
public class LiteModVoxelCommon implements PacketHandler {
public static final String VERSION = "2.4.0";
public static final ResourceLocation GUIPARTS = new ResourceLocation("voxelcommon", "textures/gui/guiparts.png");
private static List<ITimeHandler> timeHandlers = new LinkedList<ITimeHandler>();
/*
* (non-Javadoc)
* @see com.mumfrey.liteloader.LiteMod#getName()
*/
@Override
public String getName() {
return "VoxelLib";
}
/*
* (non-Javadoc)
* @see com.mumfrey.liteloader.LiteMod#getVersion()
*/
@Override
public String getVersion() {
return LiteModVoxelCommon.VERSION;
}
/*
* (non-Javadoc)
* @see com.mumfrey.liteloader.LiteMod#init(java.io.File)
*/
// @SuppressWarnings("unchecked")
@Override
public void init(File configPath) {
/*
* try { Class<? extends LiteMod> voxelPacketListenerClass = (Class<?
* extends LiteMod>)Class.forName(
* "com.voxelmodpack.voxelpacket.client.VoxelPacketListener"); LiteMod
* voxelPacketListener = voxelPacketListenerClass.newInstance();
* voxelPacketListener.init(configPath);
* LiteLoader.getInterfaceManager().registerListener(voxelPacketListener
* ); } catch (Throwable th) { th.printStackTrace(); }
*/
}
/*
* (non-Javadoc)
* @see com.mumfrey.liteloader.LiteMod#upgradeSettings(java.lang.String,
* java.io.File, java.io.File)
*/
@Override
public void upgradeSettings(String version, File configPath, File oldConfigPath) {}
@Override
public List<Class<? extends Packet>> getHandledPackets() {
return ImmutableList.<Class<? extends Packet>> of(
S03PacketTimeUpdate.class);
}
@Override
public boolean handlePacket(INetHandler netHandler, Packet packet) {
S03PacketTimeUpdate timeUpdatePacket = (S03PacketTimeUpdate) packet;
LiteModVoxelCommon.updateTime(netHandler, timeUpdatePacket.getTotalWorldTime(), timeUpdatePacket.getWorldTime());
return false;
}
public static void registerTimeHandler(ITimeHandler timeHandler) {
if (!LiteModVoxelCommon.timeHandlers.contains(timeHandler)) {
LiteModVoxelCommon.timeHandlers.add(timeHandler);
}
}
public static void updateTime(long totalTime, long worldTime) {
Minecraft mc = Minecraft.getMinecraft();
if (mc.thePlayer != null && mc.thePlayer.sendQueue != null) {
LiteModVoxelCommon.updateTime(mc.thePlayer.sendQueue, totalTime, worldTime);
}
}
/**
* @param netHandler
* @param totalTime
* @param worldTime
*/
private static void updateTime(INetHandler netHandler, long totalTime, long worldTime) {
boolean frozen = worldTime < 0L;
worldTime = Math.abs(worldTime);
long inTotalTime = totalTime;
long inWorldTime = worldTime;
for (ITimeHandler timeHandler : LiteModVoxelCommon.timeHandlers) {
timeHandler.onTimeUpdate(totalTime, worldTime);
}
for (ITimeHandler timeHandler : LiteModVoxelCommon.timeHandlers) {
if (timeHandler.isFreezingTime()) {
frozen = true;
totalTime = timeHandler.getFrozenTotalTime(inTotalTime);
worldTime = timeHandler.getFrozenWorldTime(inWorldTime);
break;
}
worldTime += timeHandler.getTimeOffset();
}
((INetHandlerPlayClient) netHandler).handleTimeUpdate(new S03PacketTimeUpdate(totalTime, worldTime, !frozen));
}
}

View file

@ -1,309 +0,0 @@
package com.voxelmodpack.common.gl;
import static com.mumfrey.liteloader.gl.GL.*;
import java.awt.image.BufferedImage;
import org.lwjgl.opengl.ContextCapabilities;
import org.lwjgl.opengl.GLContext;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import static org.lwjgl.opengl.EXTFramebufferObject.*;
import static org.lwjgl.opengl.ARBFramebufferObject.*;
/**
* Object-oriented wrapper for basic OpenGL FBOs with only a colour and depth
* buffer
*
* @author Adam Mummery-Smith
*/
public class FBO {
private static boolean supported = false;
private static boolean useARB = false;
/**
* This FBO is created
*/
private boolean created;
/**
* FBO is bound
*/
private boolean active;
/**
* Handle to the depth buffer resource
*/
private int depthBuffer;
/**
* Handle to the frame buffer resource
*/
private int frameBuffer;
/**
* Handle to the FBOs texture assigned by the renderer
*/
private DynamicTexture texture;
/**
* Width and height for the current frame buffer, used so we know to
* regenerate it if the frame size changes
*/
private int frameBufferWidth, frameBufferHeight;
/**
* Helper function to check that FBOs are supported
*
* @return True if EXT or ARB framebuffer support is available on the
* hardware
*/
public static boolean detectFBOCapabilities() {
ContextCapabilities capabilities = GLContext.getCapabilities();
if (capabilities.GL_ARB_framebuffer_object) {
supported = true;
useARB = true;
return true;
} else if (capabilities.GL_EXT_framebuffer_object) {
supported = true;
return true;
}
supported = false;
return false;
}
/**
* Create a new FBO, the internal FBO itself is not created until the first
* call to Begin() is made
*
* @param renderEngine Minecraft render engine
*/
public FBO() {
detectFBOCapabilities();
}
/**
* Get whether FBO is supported by the graphics hardware
*/
public static boolean isSupported() {
return supported;
}
/**
* Begin
*
* @param width
* @param height
*/
public void begin(int width, int height) {
if (!supported) {
return;
}
if (width < 1 || height < 1) {
throw new IllegalArgumentException("Attempted to create an FBO with zero or negative size");
}
if (this.created && (width != this.frameBufferWidth || height != this.frameBufferHeight)) {
this.dispose();
}
if (!this.created) {
this.created = true;
this.frameBufferWidth = width;
this.frameBufferHeight = height;
BufferedImage textureImage = new BufferedImage(this.frameBufferWidth, this.frameBufferHeight,
BufferedImage.TYPE_INT_RGB);
this.texture = new DynamicTexture(textureImage);
if (useARB) {
this.frameBuffer = glGenFramebuffers();
this.depthBuffer = glGenRenderbuffers();
glBindFramebuffer(GL_FRAMEBUFFER, this.frameBuffer);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
this.texture.getGlTextureId(), 0);
glBindRenderbuffer(GL_RENDERBUFFER, this.depthBuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, this.frameBufferWidth,
this.frameBufferHeight);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, this.depthBuffer);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
} else {
this.frameBuffer = glGenFramebuffersEXT();
this.depthBuffer = glGenRenderbuffersEXT();
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, this.frameBuffer);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D,
this.texture.getGlTextureId(), 0);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, this.depthBuffer);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, this.frameBufferWidth,
this.frameBufferHeight);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT,
this.depthBuffer);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
}
}
this.bind();
}
/**
*
*/
public void bind() {
if (!supported) {
return;
}
if (this.created && this.checkFBO()) {
if (useARB) {
glBindFramebuffer(GL_FRAMEBUFFER, this.frameBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, this.depthBuffer);
} else {
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, this.frameBuffer);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, this.depthBuffer);
}
glPushAttrib(GL_VIEWPORT_BIT);
glViewport(0, 0, this.frameBufferWidth, this.frameBufferHeight);
glClear(GL_COLOR_BUFFER_BIT);
this.active = true;
}
// else
// {
// System.err.println("Bad fbo");
// }
}
public void end() {
if (supported && this.active) {
if (useARB) {
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
} else {
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
}
glPopAttrib();
this.active = false;
}
}
public void dispose() {
if (!supported) {
return;
}
this.end();
if (this.texture != null) {
glDeleteTextures(this.texture.getGlTextureId());
}
if (useARB) {
glDeleteRenderbuffers(this.depthBuffer);
glDeleteFramebuffers(this.frameBuffer);
} else {
glDeleteRenderbuffersEXT(this.depthBuffer);
glDeleteFramebuffersEXT(this.frameBuffer);
}
this.depthBuffer = 0;
this.texture = null;
this.frameBuffer = 0;
this.created = false;
}
/**
* FBO completeness check
*
* @param fboID
* @return
*/
private boolean checkFBO() {
if (useARB) {
glBindFramebuffer(GL_FRAMEBUFFER, this.frameBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, this.depthBuffer);
} else {
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, this.frameBuffer);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, this.depthBuffer);
}
int frameBufferStatus = useARB ? glCheckFramebufferStatus(GL_FRAMEBUFFER)
: glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
// status
switch (frameBufferStatus) {
case GL_FRAMEBUFFER_COMPLETE_EXT:
return true;
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
return false;
default:
throw new RuntimeException("Unexpected reply from glCheckFramebufferStatus: " + frameBufferStatus);
}
}
/**
* Draw this FBO
*
* @param x
* @param y
* @param x2
* @param y2
* @param z
* @param alpha
*/
public void draw(int x, int y, int x2, int y2, int z, float alpha) {
this.draw(x, y, x2, y2, z, alpha, 0.0, 0.0, 1.0, 1.0);
}
/**
* @param x
* @param y
* @param x2
* @param y2
* @param z
* @param alpha
* @param u
* @param v
* @param u2
* @param v2
*/
public void draw(double x, double y, double x2, double y2, double z, float alpha, double u, double v, double u2,
double v2) {
if (supported && this.created) {
glEnableTexture2D();
glBindTexture2D(this.texture.getGlTextureId());
glColor4f(1, 1, 1, alpha);
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldRender = tessellator.getWorldRenderer();
worldRender.startDrawingQuads();
worldRender.addVertexWithUV(x, y2, z, u, v);
worldRender.addVertexWithUV(x2, y2, z, u2, v);
worldRender.addVertexWithUV(x2, y, z, u2, v2);
worldRender.addVertexWithUV(x, y, z, u, v2);
tessellator.draw();
}
}
}

View file

@ -1,28 +0,0 @@
package com.voxelmodpack.common.gl;
import static com.mumfrey.liteloader.gl.GL.*;
import java.util.Map;
import com.voxelmodpack.common.runtime.PrivateFields;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.util.ResourceLocation;
public abstract class TextureHelper {
public static void releaseTexture(ResourceLocation resource) {
TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
ITextureObject textureObject = textureManager.getTexture(resource);
if (textureObject != null) {
int textureName = textureObject.getGlTextureId();
glDeleteTextures(textureName);
Map<ResourceLocation, ? extends ITextureObject> resourceToTextureMap = PrivateFields.resourceToTextureMap
.get(textureManager);
resourceToTextureMap.remove(resource);
}
}
}

View file

@ -1,164 +0,0 @@
package com.voxelmodpack.common.gui;
import static com.mumfrey.liteloader.gl.GL.glColor4f;
import com.voxelmodpack.common.LiteModVoxelCommon;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
/**
* Simple checkbox-like control
*
* @author Adam Mummery-Smith
*/
public class GuiCheckBox extends GuiControl {
public enum DisplayStyle {
Button,
CheckBox,
KeyboardKey
}
public DisplayStyle Style = DisplayStyle.CheckBox;
/**
* True if the checkbox is checked
*/
public boolean checked;
/**
* Make a new check box control, automatically size the control to fit the
* specified text
*
* @param id Control ID
* @param xPosition X location for the control
* @param yPosition Y location for the control
* @param displayText Text to display
* @param checked Initially checked value
*/
public GuiCheckBox(int id, int xPosition, int yPosition, String displayText, boolean checked) {
super(id, xPosition, yPosition, displayText);
this.setWidth(Minecraft.getMinecraft().fontRendererObj.getStringWidth(displayText) + 20);
this.checked = checked;
}
/**
* Make a new check box control, automatically size the control to fit the
* specified text
*
* @param id Control ID
* @param xPosition X location for the control
* @param yPosition Y location for the control
* @param displayText Text to display
* @param checked Initially checked value
*/
public GuiCheckBox(int id, int xPosition, int yPosition, String displayText, boolean checked, DisplayStyle style) {
super(id, xPosition, yPosition, displayText);
this.setWidth(Minecraft.getMinecraft().fontRendererObj.getStringWidth(displayText) + 20);
this.checked = checked;
this.Style = style;
}
/**
* Make a new check box control of the specified size
*
* @param id Control ID
* @param xPosition X location for the control
* @param yPosition Y location for the control
* @param width Width for the control (text may overflow or underflow)
* @param height Height for the control (check box and text will be centered
* vertically within this height)
* @param displayText Text to display
* @param checked Initially checked value
*/
public GuiCheckBox(int id, int xPosition, int yPosition, int width, int height, String displayText,
boolean checked) {
super(id, xPosition, yPosition, width, height, displayText);
this.checked = checked;
}
/**
* Make a new check box control of the specified size
*
* @param id Control ID
* @param xPosition X location for the control
* @param yPosition Y location for the control
* @param width Width for the control (text may overflow or underflow)
* @param height Height for the control (check box and text will be centered
* vertically within this height)
* @param displayText Text to display
* @param checked Initially checked value
*/
public GuiCheckBox(int id, int xPosition, int yPosition, int width, int height, String displayText, boolean checked,
DisplayStyle style) {
super(id, xPosition, yPosition, width, height, displayText);
this.checked = checked;
this.Style = style;
}
public void drawCheckboxAt(Minecraft minecraft, int mouseX, int mouseY, int yPos) {
this.setYPosition(yPos);
this.drawButton(minecraft, mouseX, mouseY);
}
/**
* Draw the control
*
* @param minecraft Minecraft instance
* @param mouseX Mouse x coordinate
* @param mouseY Mouse y coordinate
*/
@Override
public void drawButton(Minecraft minecraft, int mouseX, int mouseY) {
// Control not visible
if (!this.isVisible())
return;
boolean mouseOver = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width
&& mouseY < this.yPosition + this.height;
if (this.Style == DisplayStyle.Button) {
super.drawButton(minecraft, mouseX, mouseY);
} else if (this.Style == DisplayStyle.CheckBox) {
minecraft.getTextureManager().bindTexture(LiteModVoxelCommon.GUIPARTS);
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int u = this.checked ? 12 : 0;
int y = this.yPosition + (this.height - 12) / 2;
this.drawTexturedModalRect(this.xPosition, y, this.xPosition + 12, y + 12, u, 52, u + 12, 64);
this.mouseDragged(minecraft, mouseX, mouseY);
this.drawString(minecraft.fontRendererObj, this.displayString, this.xPosition + 16,
this.yPosition + (this.height - 8) / 2,
this.isEnabled() ? (mouseOver ? 0xa0ffff : 0xe0e0e0) : 0xffa0a0a0);
} else {
Gui.drawRect(this.xPosition, this.yPosition, this.xPosition + this.width, this.yPosition + this.height,
this.checked ? 0xFFFFFF00 : 0xFF808080);
Gui.drawRect(this.xPosition + 1, this.yPosition + 1, this.xPosition + this.width - 1,
this.yPosition + this.height - 1, mouseOver ? 0xFF333333 : 0xFF000000);
this.drawCenteredString(minecraft.fontRendererObj, this.displayString, this.xPosition + (this.width / 2),
this.yPosition + (this.height - 8) / 2,
this.isEnabled() ? (mouseOver ? 0xa0ffff : (this.checked ? 0xFFFFFF00 : 0xe0e0e0)) : 0xffa0a0a0);
}
}
/**
* @param minecraft
* @param mouseX
* @param mouseY
* @return
*/
@Override
public boolean mousePressed(Minecraft minecraft, int mouseX, int mouseY) {
if (super.mousePressed(minecraft, mouseX, mouseY)) {
this.checked = !this.checked;
return true;
}
return false;
}
}

View file

@ -1,104 +0,0 @@
package com.voxelmodpack.common.gui;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
/**
* Vestigial abstraction class, not really required any more since MCP updates
* so quickly but has some handy convenience methods
*
* @author Adam Mummery-Smith
*/
public class GuiControl extends GuiButton {
/**
* Scale factor which translates texture pixel coordinates to relative
* coordinates
*/
protected static float texMapScale = 0.00390625F;
public GuiControl(int id, int xPosition, int yPosition, String displayText) {
super(id, xPosition, yPosition, displayText);
}
public GuiControl(int id, int xPosition, int yPosition, int controlWidth, int controlHeight, String displayText) {
super(id, xPosition, yPosition, controlWidth, controlHeight, displayText);
}
/**
* Draws a textured rectangle with custom UV coordinates
*
* @param x Left edge X coordinate
* @param y Top edge Y coordinate
* @param x2 Right edge X coordinate
* @param y2 Bottom edge Y coordinate
* @param u U coordinate
* @param v V coordinate
* @param u2 Right edge U coordinate
* @param v2 Bottom edge V coordinate
*/
public void drawTexturedModalRect(int x, int y, int x2, int y2, int u, int v, int u2, int v2) {
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldRender = tessellator.getWorldRenderer();
worldRender.startDrawingQuads();
worldRender.addVertexWithUV(x, y2, this.getZLevel(), (u) * texMapScale, (v2) * texMapScale);
worldRender.addVertexWithUV(x2, y2, this.getZLevel(), (u2) * texMapScale, (v2) * texMapScale);
worldRender.addVertexWithUV(x2, y, this.getZLevel(), (u2) * texMapScale, (v) * texMapScale);
worldRender.addVertexWithUV(x, y, this.getZLevel(), (u) * texMapScale, (v) * texMapScale);
tessellator.draw();
}
public final int getID() {
return this.id;
}
public final int getHeight() {
return this.height;
}
public final void setHeight(int newHeight) {
this.height = newHeight;
}
public final int getXPosition() {
return this.xPosition;
}
public final void setXPosition(int newXPosition) {
this.xPosition = newXPosition;
}
public final int getYPosition() {
return this.yPosition;
}
public final void setYPosition(int newYPosition) {
this.yPosition = newYPosition;
}
public final boolean isEnabled() {
return this.enabled;
}
public final void setEnabled(boolean newEnabled) {
this.enabled = newEnabled;
}
public final boolean isVisible() {
return this.visible;
}
public final void setVisible(boolean newVisible) {
this.visible = newVisible;
}
protected final float getZLevel() {
return this.zLevel;
}
@Override
public void drawString(FontRenderer fontRendererIn, String text, int x, int y, int color) {
super.drawString(fontRendererIn, text, x, y, color);
}
}

View file

@ -1,399 +0,0 @@
package com.voxelmodpack.common.gui;
import static com.mumfrey.liteloader.gl.GL.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
/**
* GuiControlEx is the base class for additional controls. It includes some
* advanced drawing methods which are used by several derived classes
*
* @author Adam Mummery-Smith
*/
public abstract class GuiControlEx extends GuiControl {
/**
* Used by some controls to indicate the manner in which they have handled a
* keypress
*/
public enum KeyHandledState {
/**
* The control did not handle the keypress
*/
None,
/**
* The control handled the keypress and the container should do no
* further processing
*/
Handled,
/**
* The control handled the keypress and the container should call
* actionPerformed
*/
ActionPerformed
}
/**
* Set by parent screen to enable cursor flash etc
*/
public int updateCounter;
/**
* Reference to the minecraft game instance
*/
protected Minecraft mc;
/**
* Flag indicating whether an action was performed, to support GuiScreenEx's
* callback mechanism
*/
protected boolean actionPerformed;
/**
* Flag tracking whether an item was double-clicked
*/
protected boolean doubleClicked;
/**
* Constructor, passes through to GuiButton constructor
*
* @param minecraft Minecraft game instance
* @param controlId Control's ID (used for actionPerformed)
* @param xPos Control X position (left)
* @param yPos Control Y position (top)
* @param controlWidth Control width
* @param controlHeight Control height
* @param displayText Control display text
*/
public GuiControlEx(Minecraft minecraft, int controlId, int xPos, int yPos, int controlWidth, int controlHeight,
String displayText) {
super(controlId, xPos, yPos, controlWidth, controlHeight, displayText);
this.mc = minecraft;
}
/**
* Override from GuiButton, handle this call and forward it to DrawControl
* for neatness
*
* @param minecraft Reference to the minecraft game instance
* @param mouseX Mouse X coordinate
* @param mouseY Mouse Y coordinate
*/
@Override
public final void drawButton(Minecraft minecraft, int mouseX, int mouseY) {
this.drawControl(minecraft, mouseX, mouseY);
}
/**
* Draw the control
*
* @param minecraft Reference to the minecraft game instance
* @param mouseX Mouse X coordinate
* @param mouseY Mouse Y coordinate
*/
protected abstract void drawControl(Minecraft minecraft, int mouseX, int mouseY);
/**
* GuiControlEx returns true from mousePressed if the mouse was captured,
* NOT if an action was performed. Containers should call this function
* afterwards to determine whether an action was performed.
*
* @return True if actionPerformed should be dispatched
*/
public boolean getActionPerformed() {
return this.actionPerformed;
}
/**
* Get whether an actionPerformed was a double-click event
*
* @return
*/
public boolean getDoubleClicked(boolean resetDoubleClicked) {
boolean result = this.doubleClicked;
if (resetDoubleClicked)
this.doubleClicked = false;
return result;
}
/**
* Draws a line between two points with the specified width and colour
*
* @param x1 Origin x coordinate
* @param y1 Origin y coordinate
* @param x2 End x coordinate
* @param y2 End y coordinate
* @param width Line width in pixels
* @param colour Line colour
*/
protected void drawLine(int x1, int y1, int x2, int y2, int width, int colour) {
this.drawArrow(x1, y1, x2, y2, width, colour, false, 0);
}
/**
* Draws an arrow between two points with the specified width and colour
*
* @param x1 Origin x coordinate
* @param y1 Origin y coordinate
* @param x2 End x coordinate
* @param y2 End y coordinate
* @param width Line width in pixels
* @param arrowHeadSize Size of the arrow head
* @param colour Colour
*/
protected void drawArrow(int x1, int y1, int x2, int y2, int width, int arrowHeadSize, int colour) {
this.drawArrow(x1, y1, x2, y2, width, colour, true, arrowHeadSize);
}
/**
* Internal function for drawing lines and arrows
*
* @param x1 Origin x coordinate
* @param y1 Origin y coordinate
* @param x2 End x coordinate
* @param y2 End y coordinate
* @param width Line width in pixels
* @param colour Colour
* @param arrowHead True to draw an arrow, otherwise draws a line
* @param arrowHeadSize Size of the arrow head
*/
private void drawArrow(int x1, int y1, int x2, int y2, int width, int colour, boolean arrowHead,
int arrowHeadSize) {
// Calculate the line length and angle defined by the specified points
int length = (int) Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
float angle = (float) Math.toDegrees(Math.atan2(y2 - y1, x2 - x1));
// Local rotation
glPushMatrix();
glTranslatef(x1, y1, 0.0f);
glRotatef(angle, 0.0f, 0.0f, 1.0f);
// Calc coordinates for the line and arrow points
x1 = 0;
x2 = length - (arrowHead ? arrowHeadSize : 0);
y1 = (int) (width * -0.5);
y2 = y1 + width;
// Calc colour components
float f = (colour >> 24 & 0xff) / 255F;
float f1 = (colour >> 16 & 0xff) / 255F;
float f2 = (colour >> 8 & 0xff) / 255F;
float f3 = (colour & 0xff) / 255F;
glEnableBlend();
glDisableTexture2D();
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(f1, f2, f3, f);
// Draw the line
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldRender = tessellator.getWorldRenderer();
worldRender.startDrawingQuads();
worldRender.addVertex(x1, y2, 0.0D);
worldRender.addVertex(x2, y2, 0.0D);
worldRender.addVertex(x2, y1, 0.0D);
worldRender.addVertex(x1, y1, 0.0D);
tessellator.draw();
// If an arrow then draw the arrow head
if (arrowHead && arrowHeadSize > 0) {
worldRender.startDrawing(4);
worldRender.addVertex(x2, 0 - arrowHeadSize / 2, 0);
worldRender.addVertex(x2, arrowHeadSize / 2, 0);
worldRender.addVertex(length, 0, 0);
tessellator.draw();
}
glEnableTexture2D();
glDisableBlend();
glPopMatrix();
}
/**
* Set the texmap scale factor
*
* @param textureSize
*/
public void setTexMapSize(int textureSize) {
texMapScale = 1F / textureSize;
}
/**
* Draws a textured rectangle at 90 degrees
*
* @param x Left edge X coordinate
* @param y Top edge Y coordinate
* @param x2 Right edge X coordinate
* @param y2 Bottom edge Y coordinate
* @param u U coordinate
* @param v V coordinate
* @param u2 Right edge U coordinate
* @param v2 Bottom edge V coordinate
*/
public void drawTexturedModalRectRot(int x, int y, int x2, int y2, int u, int v, int u2, int v2) {
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldRender = tessellator.getWorldRenderer();
worldRender.startDrawingQuads();
worldRender.addVertexWithUV(x2, y2, this.getZLevel(), (u) * texMapScale, (v2) * texMapScale);
worldRender.addVertexWithUV(x2, y, this.getZLevel(), (u2) * texMapScale, (v2) * texMapScale);
worldRender.addVertexWithUV(x, y, this.getZLevel(), (u2) * texMapScale, (v) * texMapScale);
worldRender.addVertexWithUV(x, y2, this.getZLevel(), (u) * texMapScale, (v) * texMapScale);
tessellator.draw();
}
/**
* Draws a textured rectangle at 90 degrees
*
* @param x Left edge X coordinate
* @param y Top edge Y coordinate
* @param u U coordinate
* @param v V coordinate
* @param width Width of texture to draw
* @param height Height of texture to draw
*/
public void drawTexturedModalRectRot(int x, int y, int u, int v, int width, int height) {
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldRender = tessellator.getWorldRenderer();
worldRender.startDrawingQuads();
worldRender.addVertexWithUV(x + height, y + width, this.getZLevel(), (u) * texMapScale,
(v + height) * texMapScale);
worldRender.addVertexWithUV(x + height, y, this.getZLevel(), (u + width) * texMapScale,
(v + height) * texMapScale);
worldRender.addVertexWithUV(x, y, this.getZLevel(), (u + width) * texMapScale, (v) * texMapScale);
worldRender.addVertexWithUV(x, y + width, this.getZLevel(), (u) * texMapScale, (v) * texMapScale);
tessellator.draw();
}
/**
* Draws a tesselated rectangle where the texture is stretched horizontally
* but vertical scaling is achieved by splitting the texture in half and
* repeating the middle pixels
*
* @param x Left edge X coordinate
* @param y Top edge Y coordinate
* @param x2 Right edge X coordinate
* @param y2 Bottom edge Y coordinate
* @param u U coordinate
* @param v V coordinate
* @param u2 Right edge U coordinate
* @param v2 Bottom edge V coordinate
*/
public void drawTessellatedModalRectV(int x, int y, int x2, int y2, int u, int v, int u2, int v2) {
int tileSize = ((v2 - v) / 2);
int vMidTop = v + tileSize;
int vMidBtm = vMidTop + 1;
this.drawTexturedModalRect(x, y, x2, y + tileSize, u, v, u2, vMidTop);
this.drawTexturedModalRect(x, y + tileSize, x2, y2 - tileSize + 1, u, vMidTop, u2, vMidBtm);
this.drawTexturedModalRect(x, y2 - tileSize + 1, x2, y2, u, vMidBtm, u2, v2);
}
/**
* Draws a tesselated rectangle where the texture is stretched vertically
* but horizontal scaling is achieved by splitting the texture in half and
* repeating the middle pixels
*
* @param x Left edge X coordinate
* @param y Top edge Y coordinate
* @param x2 Right edge X coordinate
* @param y2 Bottom edge Y coordinate
* @param u U coordinate
* @param v V coordinate
* @param u2 Right edge U coordinate
* @param v2 Bottom edge V coordinate
*/
public void drawTessellatedModalRectH(int x, int y, int x2, int y2, int u, int v, int u2, int v2) {
int tileSize = ((u2 - u) / 2);
int uMidLeft = u + tileSize;
int uMidRight = uMidLeft + 1;
this.drawTexturedModalRect(x, y, x + tileSize, y2, u, v, uMidLeft, v2);
this.drawTexturedModalRect(x + tileSize, y, x2 - tileSize + 1, y2, uMidLeft, v, uMidRight, v2);
this.drawTexturedModalRect(x2 - tileSize + 1, y, x2, y2, uMidRight, v, u2, v2);
}
/**
* Draws a tesselated rectangle where the texture is stretched vertically
* and horizontally but the middle pixels are repeated whilst the joining
* pixels are stretched.
*
* @param x Left edge X coordinate
* @param y Top edge Y coordinate
* @param x2 Right edge X coordinate
* @param y2 Bottom edge Y coordinate
* @param u U coordinate
* @param v V coordinate
* @param u2 Right edge U coordinate
* @param v2 Bottom edge V coordinate
*/
public void drawTessellatedModalBorderRect(int x, int y, int x2, int y2, int u, int v, int u2, int v2) {
this.drawTessellatedModalBorderRect(x, y, x2, y2, u, v, u2, v2,
Math.min(((x2 - x) / 2) - 1, ((y2 - y) / 2) - 1));
}
/**
* Draws a tesselated rectangle where the texture is stretched vertically
* and horizontally but the middle pixels are repeated whilst the joining
* pixels are stretched. Bordersize specifies the portion of the texture
* which will remain unstretched.
*
* @param x Left edge X coordinate
* @param y Top edge Y coordinate
* @param x2 Right edge X coordinate
* @param y2 Bottom edge Y coordinate
* @param u U coordinate
* @param v V coordinate
* @param u2 Right edge U coordinate
* @param v2 Bottom edge V coordinate
* @param borderSize Number of pixels to leave unstretched, must be less
* than half of the width or height (whichever is smallest)
*/
public void drawTessellatedModalBorderRect(int x, int y, int x2, int y2, int u, int v, int u2, int v2,
int borderSize) {
int tileSize = Math.min(((u2 - u) / 2) - 1, ((v2 - v) / 2) - 1);
int ul = u + tileSize, ur = u2 - tileSize, vt = v + tileSize, vb = v2 - tileSize;
int xl = x + borderSize, xr = x2 - borderSize, yt = y + borderSize, yb = y2 - borderSize;
this.drawTexturedModalRect(x, y, xl, yt, u, v, ul, vt);
this.drawTexturedModalRect(xl, y, xr, yt, ul, v, ur, vt);
this.drawTexturedModalRect(xr, y, x2, yt, ur, v, u2, vt);
this.drawTexturedModalRect(x, yb, xl, y2, u, vb, ul, v2);
this.drawTexturedModalRect(xl, yb, xr, y2, ul, vb, ur, v2);
this.drawTexturedModalRect(xr, yb, x2, y2, ur, vb, u2, v2);
this.drawTexturedModalRect(x, yt, xl, yb, u, vt, ul, vb);
this.drawTexturedModalRect(xr, yt, x2, yb, ur, vt, u2, vb);
this.drawTexturedModalRect(xl, yt, xr, yb, ul, vt, ur, vb);
}
/**
* Draw a string but cut it off if it's too long to fit in the specified
* width
*
* @param fontrenderer
* @param s
* @param x
* @param y
* @param width
* @param colour
*/
public static void drawStringWithEllipsis(FontRenderer fontrenderer, String s, int x, int y, int width,
int colour) {
if (fontrenderer.getStringWidth(s) <= width) {
fontrenderer.drawStringWithShadow(s, x, y, colour);
} else if (width < 8) {
fontrenderer.drawStringWithShadow("..", x, y, colour);
} else {
String trimmedText = s;
while (fontrenderer.getStringWidth(trimmedText) > width - 8 && trimmedText.length() > 0)
trimmedText = trimmedText.substring(0, trimmedText.length() - 1);
fontrenderer.drawStringWithShadow(trimmedText + "...", x, y, colour);
}
}
}

View file

@ -1,366 +0,0 @@
package com.voxelmodpack.common.gui;
import java.awt.Point;
import java.io.IOException;
import org.lwjgl.input.Keyboard;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
/**
* Base class for GUI Screens which behave like dialog boxes
*
* @author Adam Mummery-Smith
*/
public abstract class GuiDialogBox extends GuiScreenEx {
public static int lastScreenWidth, lastScreenHeight;
public enum DialogResult {
/**
* No result (maybe the dialog was not closed yet?)
*/
None,
/**
* Dialog result OK (user clicked OK or pressed RETURN)
*/
OK,
/**
* Dialog result Cancel (user clicked Cancel or pressed ESCAPE)
*/
Cancel,
Yes,
No
}
private GuiScreen parentScreen;
/**
* Parent screen which will be notified when this dialog is closed
*/
// protected GuiScreenEx parentScreenEx;
/**
* Dialog box buttons
*/
protected GuiButton btnOk, btnCancel;
/**
* Dialog box position and size
*/
protected int dialogX, dialogY, dialogWidth, dialogHeight;
/**
* Title to display at the top of the dialog box
*/
protected String dialogTitle;
/**
* True to centre the title
*/
protected boolean centreTitle = true;
/**
* Colour for the window title
*/
protected int dialogTitleColour = 0xFFFFFF00;
/**
* Dialog result based on the user's action
*/
public DialogResult dialogResult = DialogResult.None;
/**
* This dialog box can be moved
*/
protected boolean movable = false;
protected boolean dragging = false;
protected Point dragOffset = new Point(0, 0);
@SuppressWarnings("unused")
private boolean generateMouseDragEvents;
/**
* Constructor, create a new GuiDialogBox
*
* @param parentScreen Screen which owns this dialog
* @param width
* @param height
* @param windowTitle
*/
public GuiDialogBox(GuiScreen parentScreen, int width, int height, String windowTitle) {
this.parentScreen = parentScreen;
this.dialogWidth = width;
this.dialogHeight = height;
this.dialogTitle = windowTitle;
this.generateMouseDragEvents = true;
}
/**
* Close the dialog box and display the parent screen (if it is available,
* otherwise clear the gui)
*/
protected void closeDialog() {
this.mc.displayGuiScreen(this.getParentScreen());
}
/**
* Handle a button event
*
* @param guibutton Button or control which sourced the event
*/
@Override
protected void actionPerformed(GuiButton guibutton) {
if (guibutton.id == this.btnCancel.id) {
this.dialogResult = DialogResult.Cancel;
this.closeDialog();
}
if (guibutton.id == this.btnOk.id) {
if (this.validateDialog()) {
this.dialogResult = DialogResult.OK;
this.onSubmit();
this.closeDialog();
}
}
}
/**
* Handle a keyboard event
*/
@Override
protected final void keyTyped(char keyChar, int keyCode) {
if (keyCode == Keyboard.KEY_ESCAPE) {
this.actionPerformed(this.btnCancel);
} else if (keyCode == Keyboard.KEY_RETURN) {
this.actionPerformed(this.btnOk);
} else {
this.onKeyTyped(keyChar, keyCode);
}
}
/*
* (non-Javadoc)
* @see net.eq2online.macros.gui.shared.GuiScreenEx#mouseClicked(int, int,
* int)
*/
@Override
protected final void mouseClicked(int mouseX, int mouseY, int button) throws IOException {
if (button == 0 && this.movable && mouseX > this.dialogX && mouseX < this.dialogX + this.dialogWidth
&& mouseY > this.dialogY - 18 && mouseY < this.dialogY) {
this.dragOffset = new Point(mouseX - this.dialogX, mouseY - this.dialogY);
this.dragging = true;
} else {
this.mouseClickedEx(mouseX, mouseY, button);
}
}
/**
* @param mouseX
* @param mouseY
* @param button
* @throws IOException
*/
protected void mouseClickedEx(int mouseX, int mouseY, int button) throws IOException {
super.mouseClicked(mouseX, mouseY, button);
}
/*
* (non-Javadoc)
* @see net.minecraft.client.gui.GuiScreen#mouseReleased(int, int, int)
*/
@Override
protected void mouseReleased(int mouseX, int mouseY, int button) {
if (this.dragging) {
this.dialogX = mouseX - this.dragOffset.x;
this.dialogY = mouseY - this.dragOffset.y;
this.initGui();
}
if (button == 0 && this.dragging) {
if (this.dialogX < 0)
this.dialogX = 0;
if (this.dialogX > this.width)
this.dialogX = this.width - this.dialogWidth;
if (this.dialogY < 9)
this.dialogY = 18;
if (this.dialogY > this.height)
this.dialogY = this.height - this.dialogHeight;
this.initGui();
this.dragging = false;
return;
}
super.mouseReleased(mouseX, mouseY, button);
}
/**
* Initialise the dialog box
*/
@Override
public final void initGui() {
super.initGui();
Keyboard.enableRepeatEvents(true);
// Call to owner since the owner is still drawn whilst we are being
// displayed
if (this.getParentScreen() != null)
this.getParentScreen().initGui();
if (!this.dragging) {
// Draw the dialog centered unless moved by the parent
this.dialogX = (this.width - this.dialogWidth) / 2;
this.dialogY = (this.height - this.dialogHeight) / 2;
}
this.btnOk = new GuiButton(-1, this.dialogX + this.dialogWidth - 62, this.dialogY + this.dialogHeight - 22, 60,
20, I18n.format("gui.done"));
this.btnCancel = new GuiButton(-2, this.dialogX + this.dialogWidth - 124, this.dialogY + this.dialogHeight - 22,
60, 20, I18n.format("gui.cancel"));
this.buttonList.clear();
this.buttonList.add(this.btnOk);
this.buttonList.add(this.btnCancel);
lastScreenWidth = this.width;
lastScreenHeight = this.height;
this.onInitDialog();
}
@Override
public final void onGuiClosed() {
this.onDialogClosed();
Keyboard.enableRepeatEvents(false);
super.onGuiClosed();
}
@Override
public void setWorldAndResolution(Minecraft minecraft, int width, int height) {
super.setWorldAndResolution(minecraft, width, height);
if (this.getParentScreen() != null) {
this.getParentScreen().setWorldAndResolution(minecraft, width, height);
}
}
@Override
public final void drawScreen(int mouseX, int mouseY, float partialTick) {
this.drawParentScreen(mouseX, mouseY, partialTick);
int backColour = 0xAA000000;
int backColour2 = 0xCC333333;
// Header
drawRect(this.dialogX, this.dialogY - 18, this.dialogX + this.dialogWidth, this.dialogY, backColour2);
if (this.centreTitle)
this.drawCenteredString(this.mc.fontRendererObj, this.dialogTitle, this.dialogX + (this.dialogWidth / 2),
this.dialogY - 13, this.dialogTitleColour);
else
this.drawString(this.mc.fontRendererObj, this.dialogTitle, this.dialogX + 5, this.dialogY - 13,
this.dialogTitleColour);
// Dialog body
drawRect(this.dialogX, this.dialogY, this.dialogX + this.dialogWidth, this.dialogY + this.dialogHeight,
backColour);
// Subclasses
this.drawDialog(mouseX, mouseY, partialTick);
// Superclass (buttons etc.)
super.drawScreen(mouseX, mouseY, partialTick);
this.postRender(mouseX, mouseY, partialTick);
}
@Override
public void updateScreen() {
if (this.getParentScreen() != null) {
this.getParentScreen().updateScreen();
}
super.updateScreen();
}
/**
* @param partialTick
*/
public void drawParentScreen(int mouseX, int mouseY, float partialTick) {
if (this.getParentScreen() != null) {
this.getParentScreen().drawScreen(0, 0, partialTick);
drawRect(0, 0, this.width, this.height, 0xAA000000);
} else if (this.mc.theWorld == null) {
this.drawDefaultBackground();
}
}
/**
* Stub for subclasses, draw any additional dialog features
*
* @param mouseX Mouse X coordinate
* @param mouseY Mouse Y coordinate
* @param f
*/
protected void drawDialog(int mouseX, int mouseY, float f) {
}
/**
* Stub for subclasses, draw any additional dialog features
*
* @param mouseX Mouse X coordinate
* @param mouseY Mouse Y coordinate
* @param f
*/
protected void postRender(int mouseX, int mouseY, float f) {
}
/**
* Stub for subclasses, perform any tasks required when the dialog is
* validated and about to be submitted
*/
public abstract void onSubmit();
/**
* Stub for subclasses, return true if the dialog can be submitted in its
* current state, or false to prevent submission
*
* @return
*/
public abstract boolean validateDialog();
/**
* Stub for subclasses, handle a key typed event
*
* @param keyChar
* @param keyCode
*/
protected void onKeyTyped(char keyChar, int keyCode) {}
/**
* Stub for subclasses, perform any required initialisation
*/
protected void onInitDialog() {}
/**
* Stub for subclasses, the gui was closed
*/
protected void onDialogClosed() {}
public GuiScreen getParentScreen() {
return this.parentScreen;
}
}

View file

@ -1,97 +0,0 @@
package com.voxelmodpack.common.gui;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
/**
* Confirmation dialog box, displays a message and yes/no buttons
*
* @author Adam Mummery-Smith
* @param <T>
*/
public class GuiDialogBoxConfirm<T> extends GuiDialogBox {
/**
* Message text to display
*/
private String messageText1, messageText2;
/**
* Metadata for this confirmation, so that the calling class knows what's
* being confirmed!
*/
private T metaData;
/**
* Constructor with metadata
*
* @param parentScreen Screen which owns this dialog
* @param windowTitle Dialog title
* @param line1 Label line 1
* @param line2 Label line 2
* @param metaData Metadata supplied by the owning gui
*/
public GuiDialogBoxConfirm(GuiScreen parentScreen, String windowTitle, String line1, String line2, T metaData) {
this(parentScreen, windowTitle, line1, line2);
this.metaData = metaData;
}
/**
* Constructor with no metadata
*
* @param parentScreen Screen which owns this dialog
* @param windowTitle Dialog title
* @param line1 Label line 1
* @param line2 Label line 2
*/
public GuiDialogBoxConfirm(GuiScreen parentScreen, String windowTitle, String line1, String line2) {
super(parentScreen, 320, 80, windowTitle);
// Set local labels
this.messageText1 = line1;
this.messageText2 = line2;
}
/**
* Get the meta data passed to this dialog when it was created
*
* @return Meta data (if any)
*/
public T GetMetaData() {
return this.metaData;
}
@Override
protected void onInitDialog() {
this.btnOk.displayString = I18n.format("gui.yes");
this.btnCancel.displayString = I18n.format("gui.no");
}
@Override
public void onSubmit() {}
@Override
public boolean validateDialog() {
return true;
}
@Override
protected void drawDialog(int mouseX, int mouseY, float f) {
// Label
drawCenteredString(this.fontRendererObj, this.messageText1, this.dialogX + (this.dialogWidth / 2),
this.dialogY + 18, 0xFFFFAA00);
drawCenteredString(this.fontRendererObj, this.messageText2, this.dialogX + (this.dialogWidth / 2),
this.dialogY + 32, 0xFFFFAA00);
}
/*
* (non-Javadoc)
* @see net.eq2online.macros.gui.shared.GuiDialogBox#KeyTyped(char, int)
*/
@Override
protected void onKeyTyped(char keyChar, int keyCode) {
if (keyChar == 'y' || keyChar == 'Y')
actionPerformed(this.btnOk);
if (keyChar == 'n' || keyChar == 'N')
actionPerformed(this.btnCancel);
}
}

View file

@ -1,138 +0,0 @@
package com.voxelmodpack.common.gui;
import static com.mumfrey.liteloader.gl.GL.*;
import com.voxelmodpack.common.gui.interfaces.IExtendedGui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.util.ResourceLocation;
/**
* Class with many extra ways of drawing rectangular images
*/
public abstract class GuiScreenEx extends GuiScreen implements IExtendedGui {
public static float texMapScale = 1F / 256F;
/*
* (non-Javadoc)
* @see
* com.voxelmodpack.common.gui.IExtendedGui#drawTessellatedModalBorderRect(
* net.minecraft.src.ResourceLocation, int, int, int, int, int, int, int,
* int, int, int)
*/
@Override
public void drawTessellatedModalBorderRect(ResourceLocation texture, int textureSize, int x, int y, int x2, int y2,
int u, int v, int u2, int v2, int borderSize) {
this.drawTessellatedModalBorderRect(texture, textureSize, x, y, x2, y2, u, v, u2, v2, borderSize, true);
}
/*
* (non-Javadoc)
* @see
* com.voxelmodpack.common.gui.IExtendedGui#drawTessellatedModalBorderRect(
* net.minecraft.src.ResourceLocation, int, int, int, int, int, int, int,
* int, int, int, boolean)
*/
@Override
public void drawTessellatedModalBorderRect(ResourceLocation texture, int textureSize, int x, int y, int x2, int y2,
int u, int v, int u2, int v2, int borderSize, boolean setcolor) {
int tileSize = Math.min(((u2 - u) / 2) - 1, ((v2 - v) / 2) - 1);
int ul = u + tileSize, ur = u2 - tileSize, vt = v + tileSize, vb = v2 - tileSize;
int xl = x + borderSize, xr = x2 - borderSize, yt = y + borderSize, yb = y2 - borderSize;
this.setTexMapSize(textureSize);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
if (setcolor)
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.drawTexturedModalRect(x, y, xl, yt, u, v, ul, vt);
this.drawTexturedModalRect(xl, y, xr, yt, ul, v, ur, vt);
this.drawTexturedModalRect(xr, y, x2, yt, ur, v, u2, vt);
this.drawTexturedModalRect(x, yb, xl, y2, u, vb, ul, v2);
this.drawTexturedModalRect(xl, yb, xr, y2, ul, vb, ur, v2);
this.drawTexturedModalRect(xr, yb, x2, y2, ur, vb, u2, v2);
this.drawTexturedModalRect(x, yt, xl, yb, u, vt, ul, vb);
this.drawTexturedModalRect(xr, yt, x2, yb, ur, vt, u2, vb);
this.drawTexturedModalRect(xl, yt, xr, yb, ul, vt, ur, vb);
}
/*
* (non-Javadoc)
* @see com.voxelmodpack.common.gui.IExtendedGui#drawTexturedModalRect(net.
* minecraft.src.ResourceLocation, int, int, int, int, int, int, int, int)
*/
@Override
public void drawTexturedModalRect(ResourceLocation texture, int x, int y, int x2, int y2, int u, int v, int u2,
int v2) {
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
this.drawTexturedModalRect(x, y, x2, y2, u, v, u2, v2);
}
/*
* (non-Javadoc)
* @see com.voxelmodpack.common.gui.IExtendedGui#drawTexturedModalRect(int,
* int, int, int, int, int, int, int)
*/
@Override
public void drawTexturedModalRect(int x, int y, int x2, int y2, int u, int v, int u2, int v2) {
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldRender = tessellator.getWorldRenderer();
worldRender.startDrawingQuads();
worldRender.addVertexWithUV(x, y2, this.zLevel, u * texMapScale, v2 * texMapScale);
worldRender.addVertexWithUV(x2, y2, this.zLevel, u2 * texMapScale, v2 * texMapScale);
worldRender.addVertexWithUV(x2, y, this.zLevel, u2 * texMapScale, v * texMapScale);
worldRender.addVertexWithUV(x, y, this.zLevel, u * texMapScale, v * texMapScale);
tessellator.draw();
}
/**
* Draws a solid color rectangle with the specified coordinates and color.
*/
public void drawDepthRect(int x1, int y1, int x2, int y2, int color) {
if (x1 < x2) {
int xTemp = x1;
x1 = x2;
x2 = xTemp;
}
if (y1 < y2) {
int yTemp = y1;
y1 = y2;
y2 = yTemp;
}
float alpha = (color >> 24 & 255) / 255.0F;
float red = (color >> 16 & 255) / 255.0F;
float green = (color >> 8 & 255) / 255.0F;
float blue = (color & 255) / 255.0F;
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldRender = tessellator.getWorldRenderer();
glEnableBlend();
glDisableTexture2D();
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(red, green, blue, alpha);
worldRender.startDrawingQuads();
worldRender.addVertex(x1, y2, this.zLevel);
worldRender.addVertex(x2, y2, this.zLevel);
worldRender.addVertex(x2, y1, this.zLevel);
worldRender.addVertex(x1, y1, this.zLevel);
tessellator.draw();
glEnableTexture2D();
glDisableBlend();
}
/**
* @param textureSize
*/
protected void setTexMapSize(int textureSize) {
GuiScreenEx.texMapScale = 1F / textureSize;
}
}

View file

@ -1,386 +0,0 @@
package com.voxelmodpack.common.gui;
import static com.mumfrey.liteloader.gl.GL.*;
import net.minecraft.client.Minecraft;
import com.voxelmodpack.common.LiteModVoxelCommon;
/**
* General-purpose scrollbar control
*
* @author Adam Mummery-Smith
*/
public class GuiScrollBar extends GuiControlEx {
public enum ScrollBarOrientation {
Vertical,
Horizontal
}
protected ScrollBarOrientation orientation;
/**
* Scroll bar minimum value
*/
protected int min;
/**
* Scroll bar maximum value
*/
protected int max;
/**
* Scroll bar current value
*/
protected int value;
/**
* Current visual position of the scroll button relative to the scroll tray
*/
protected int buttonPos = 0;
/**
* Size of the scroll button
*/
protected int scrollButtonSize = 20;
/**
* Total scrollable distance
*/
protected int traySize;
/**
* Mousedown offset relative to the scroll button, used for mouse drag delta
* calculations
*/
protected int dragOffset;
/**
* Mousedown state, track whether holding down the drag button, up button,
* or down button
*/
protected int mouseDownState = 0;
/**
* Used to track a small delay before activating scroll on the up/down
* buttons
*/
protected int mouseDownTime = 0;
/**
* Make a new scrollbar control
*
* @param minecraft Reference to the minecraft game instance
* @param controlId Control ID, used for handling actionPerformed dispatches
* @param xPos Control's X position
* @param yPos Control's Y position
* @param controlWidth Width of the control (also the height of the buttons)
* @param controlHeight Height of the control
* @param minValue Minimum scroll value
* @param maxValue Maximum scroll value
*/
public GuiScrollBar(Minecraft minecraft, int controlId, int xPos, int yPos, int controlWidth, int controlHeight,
int minValue, int maxValue, ScrollBarOrientation orientation) {
super(minecraft, controlId, xPos, yPos, controlWidth, controlHeight, "");
this.orientation = orientation;
this.value = this.min = minValue;
this.max = Math.max(this.min, maxValue);
this.traySize = this.getLargeDimension() - (this.getSmallDimension() * 2) - this.scrollButtonSize;
}
protected int getLargeDimension() {
return (this.orientation == ScrollBarOrientation.Vertical) ? this.height : this.width;
}
protected int getSmallDimension() {
return (this.orientation == ScrollBarOrientation.Vertical) ? this.width : this.height;
}
/**
* Get the current value of the control
*
* @return current value
*/
public int getValue() {
return this.value;
}
/**
* Set the current control value
*
* @param value New value (will be clamped within current min and max values
*/
public void setValue(int value) {
this.value = value;
this.updateValue();
}
/**
* Set the minimum value for the control, the current value will be clamped
* between min and max
*
* @param value
*/
public void setMin(int value) {
this.min = value;
this.max = Math.max(this.min, this.max);
this.updateValue();
}
/**
* Set the maximum value for the control, the current value will be clamped
* between min and max.
*
* @param value
*/
public void setMax(int value) {
this.max = value;
this.min = Math.min(this.max, this.min);
this.updateValue();
}
/**
* Set the control's position
*
* @param left New left, X coordinate
* @param top New top, Y coordinate
*/
public void setPosition(int left, int top) {
this.setXPosition(left);
this.setYPosition(top);
}
/**
* Set the size of the control
*
* @param controlWidth New width for the control. Minimum 60 pixels
* @param controlHeight New height for the control. Minimum 8 pixels
*/
public void setSize(int controlWidth, int controlHeight) {
this.setWidth(controlWidth);
this.setHeight(controlHeight);
this.traySize = this.getLargeDimension() - (this.getSmallDimension() * 2) - this.scrollButtonSize;
this.updateValue();
}
/**
* Set the size and position of the control
*
* @param left New left, X coordinate
* @param top New top, Y coordinate
* @param controlWidth New width for the control. Minimum 60 pixels
* @param controlHeight New height for the control. Minimum 8 pixels
*/
public void setSizeAndPosition(int left, int top, int controlWidth, int controlHeight) {
this.setPosition(left, top);
this.setSize(controlWidth, controlHeight);
}
/**
* Clamp the value between max and min and update the button position
*/
private void updateValue() {
if (this.value < this.min)
this.value = this.min;
if (this.value > this.max)
this.value = this.max;
this.buttonPos = (int) (((float) (this.value - this.min) / (float) (this.max - this.min)) * this.traySize);
}
/**
* Draw the control
*
* @param minecraft Minecraft game instance
* @param mouseX Mouse X coordinate
* @param mouseY Mouse Y coordinate
*/
@Override
protected void drawControl(Minecraft minecraft, int mouseX, int mouseY) {
if (!this.isVisible())
return;
float opacity = this.isEnabled() ? 1.0F : 0.3F;
glColor4f(opacity, opacity, opacity, opacity);
// Calc mouseover state of buttons
boolean mouseOverUpButton = this.mouseDownState == 3 || this.mouseIsOverButton(3, mouseX, mouseY);
boolean mouseOverDownButton = this.mouseDownState == 2 || this.mouseIsOverButton(2, mouseX, mouseY);
boolean mouseOverButton = this.mouseDownState == 1 || this.mouseIsOverButton(1, mouseX, mouseY);
// V coordinates based on button hover states
int upButtonHoverState = 0 + (this.getHoverState(mouseOverUpButton) * 16);
int downButtonHoverState = 0 + (this.getHoverState(mouseOverDownButton) * 16);
int buttonHoverState = 0 + (this.getHoverState(mouseOverButton) * 16);
if (this.orientation == ScrollBarOrientation.Vertical) {
minecraft.getTextureManager().bindTexture(LiteModVoxelCommon.GUIPARTS);
this.setTexMapSize(256);
this.drawTessellatedModalBorderRect(this.xPosition, this.yPosition, this.xPosition + this.width,
this.yPosition + this.width, 0, upButtonHoverState, 16, upButtonHoverState + 16, 4);
this.drawTessellatedModalBorderRect(this.xPosition, this.yPosition + this.height - this.width,
this.xPosition + this.width, this.yPosition + this.height, 0, downButtonHoverState, 16,
downButtonHoverState + 16, 4);
// Slider tray
this.drawTessellatedModalBorderRect(this.xPosition + 1, this.yPosition + this.width,
this.xPosition + this.width - 1, this.yPosition + this.height - this.width, 0, 0, 16, 16, 4);
// Button icons
this.drawTexturedModalRect(this.xPosition + 1, this.yPosition + 1, this.xPosition + this.width - 2,
this.yPosition + this.width - 2, 36, 0, 54, 18);
this.drawTexturedModalRect(this.xPosition + 1, this.yPosition + this.height - this.width + 1,
this.xPosition + this.width - 2, this.yPosition + this.height - 1, 18, 0, 36, 18);
}
// Handle mouse dragged event
this.mouseDragged(minecraft, mouseX, mouseY);
minecraft.getTextureManager().bindTexture(LiteModVoxelCommon.GUIPARTS);
if (this.orientation == ScrollBarOrientation.Vertical) {
this.drawTessellatedModalBorderRect(this.xPosition, this.yPosition + this.width + this.buttonPos,
this.xPosition + this.width, this.yPosition + this.width + this.buttonPos + this.scrollButtonSize,
0, buttonHoverState, 16, buttonHoverState + 16, 4);
}
}
protected boolean mouseIsOverButton(int button, int mouseX, int mouseY) {
int buttonX = 0, buttonY = 0, buttonWidth = this.getSmallDimension(), buttonHeight = this.getSmallDimension();
mouseX -= this.xPosition;
mouseY -= this.yPosition;
if (mouseX < 0 || mouseY < 0 || mouseX > this.width || mouseY > this.height)
return false;
if (button == 2) // down button
{
if (this.orientation == ScrollBarOrientation.Vertical)
buttonY = this.getLargeDimension() - this.getSmallDimension();
if (this.orientation == ScrollBarOrientation.Horizontal)
buttonX = this.getLargeDimension() - this.getSmallDimension();
} else if (button == 1) // drag button
{
if (this.orientation == ScrollBarOrientation.Vertical) {
buttonY = this.getSmallDimension() + this.buttonPos;
buttonHeight = this.scrollButtonSize;
}
if (this.orientation == ScrollBarOrientation.Horizontal) {
buttonX = this.getSmallDimension() + this.buttonPos;
buttonWidth = this.scrollButtonSize;
}
}
return (mouseX >= buttonX && mouseY >= buttonY && mouseX < buttonX + buttonWidth
&& mouseY < buttonY + buttonHeight);
}
/**
* Handle mouse dragged event
*
* @param minecraft Minecraft game instance
* @param mouseX Mouse X coordinate
* @param mouseY Mouse Y coordinate
*/
@Override
protected void mouseDragged(Minecraft minecraft, int mouseX, int mouseY) {
if (!this.isVisible())
return;
if (this.mouseDownState > 0) {
int mouseDownTicks = this.updateCounter - this.mouseDownTime;
if (this.mouseDownState == 1) {
int mPos = (this.orientation == ScrollBarOrientation.Vertical) ? mouseY - this.yPosition
: mouseX - this.xPosition;
this.value = (int) (((float) (mPos - this.dragOffset - this.getSmallDimension())
/ (float) this.traySize) * (this.max - this.min)) + this.min;
} else if (this.mouseDownState == 2 && mouseDownTicks > 6) {
this.value += 4;
} else if (this.mouseDownState == 3 && mouseDownTicks > 6) {
this.value -= 4;
}
this.updateValue();
}
}
/**
* Handle mouse released event
*
* @param mouseX Mouse X coordinate
* @param mouseY Mouse Y coordinate
*/
@Override
public void mouseReleased(int mouseX, int mouseY) {
this.mouseDownState = 0;
}
/**
* Mouse pressed event
*
* @param minecraft Minecraft game instance
* @param mouseX Mouse X coordinate
* @param mouseY Mouse Y coordinate
*/
@Override
public boolean mousePressed(Minecraft minecraft, int mouseX, int mouseY) {
this.actionPerformed = false;
boolean returnValue = false;
if (super.mousePressed(minecraft, mouseX, mouseY)) {
// Adjust coords relative to control
mouseX -= this.xPosition;
mouseY -= this.yPosition;
if (this.orientation == ScrollBarOrientation.Horizontal) {
int mouseT = mouseY;
mouseY = mouseX;
mouseX = mouseT;
}
// Counter starts now and we wait 10 seconds for mousedown effects
// to kick in
this.mouseDownTime = this.updateCounter;
if (mouseY < this.getSmallDimension()) // up button
{
this.mouseDownState = 3;
this.value -= 4;
this.actionPerformed = true;
} else if (mouseY > this.getLargeDimension() - this.getSmallDimension()) // down
// button
{
this.mouseDownState = 2;
this.value += 4;
this.actionPerformed = true;
} else if (mouseY > this.buttonPos + this.getSmallDimension()
&& mouseY < this.buttonPos + this.getSmallDimension() + this.scrollButtonSize) // drag
// button
{
this.mouseDownState = 1;
this.dragOffset = mouseY - this.buttonPos - this.getSmallDimension();
returnValue = true;
} else if (mouseY < this.buttonPos + this.getSmallDimension()) // upper
// tray
{
this.value -= 40;
this.actionPerformed = true;
} else if (mouseY > this.buttonPos + this.getSmallDimension() + this.scrollButtonSize) // lower
// tray
{
this.value += 40;
this.actionPerformed = true;
}
// Clamp value and update slider position
this.updateValue();
}
return this.actionPerformed || returnValue;
}
}

View file

@ -1,176 +0,0 @@
package com.voxelmodpack.common.gui;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiTextField;
import org.lwjgl.input.Keyboard;
import com.mumfrey.liteloader.client.overlays.IGuiTextField;
/**
* 'Dynamic' text field which supports resizing and moving and also syntax
* highlight
*
* @author Adam Mummery-Smith
*/
public class GuiTextFieldEx extends GuiTextField {
/**
* Width member is private in the superclass
*/
protected int xPos, yPos, width, height;
/**
* Allowed character filter for this text box
*/
public String allowedCharacters;
public int minStringLength = 0;
protected FontRenderer fontRenderer;
/**
* Constructor
*
* @param parentScreen Parent screen
* @param fontrenderer Font renderer
* @param xPos X location
* @param yPos Y location
* @param width Control width
* @param height Control height
* @param initialText Text to initially set
*/
public GuiTextFieldEx(int id, FontRenderer fontrenderer, int xPos, int yPos, int width, int height,
String initialText, String allowedCharacters, int maxStringLength) {
super(id, fontrenderer, xPos, yPos, width, height);
this.allowedCharacters = allowedCharacters;
this.setMaxStringLength(maxStringLength);
this.setText(initialText);
this.width = width;
}
/**
* Constructor
*
* @param parentScreen Parent screen
* @param fontrenderer Font renderer
* @param xPos X location
* @param yPos Y location
* @param width Control width
* @param height Control height
* @param initialText Text to initially set
*/
public GuiTextFieldEx(int id, FontRenderer fontrenderer, int xPos, int yPos, int width, int height,
String initialText) {
super(id, fontrenderer, xPos, yPos, width, height);
this.setMaxStringLength(65536);
this.setText(initialText);
this.width = width;
}
/**
* Constructor
*
* @param parentScreen Parent screen
* @param fontrenderer Font renderer
* @param xPos X location
* @param yPos Y location
* @param width Control width
* @param height Control height
* @param initialText Text to initially set
*/
public GuiTextFieldEx(int id, FontRenderer fontrenderer, int xPos, int yPos, int width, int height,
int initialValue, int digits) {
super(id, fontrenderer, xPos, yPos, width, height);
this.setMaxStringLength(digits);
this.setText(String.valueOf(initialValue));
this.allowedCharacters = "0123456789";
this.width = width;
}
@Override
public boolean textboxKeyTyped(char keyChar, int keyCode) {
if ((this.allowedCharacters == null || this.allowedCharacters.indexOf(keyChar) >= 0) ||
keyCode == Keyboard.KEY_LEFT || keyCode == Keyboard.KEY_RIGHT ||
keyCode == Keyboard.KEY_HOME || keyCode == Keyboard.KEY_END ||
keyCode == Keyboard.KEY_DELETE || keyCode == Keyboard.KEY_BACK) {
return super.textboxKeyTyped(keyChar, keyCode);
}
return false;
}
/*
* (non-Javadoc)
* @see net.minecraft.src.GuiTextField#func_50038_e()
*/
@Override
public void setCursorPositionEnd() {
try {
super.setCursorPositionEnd();
} catch (Exception ex) {}
}
public void setSizeAndPosition(int xPos, int yPos, int width, int height) {
this.setPosition(xPos, yPos);
this.setSize(width, height);
}
public void setSize(int width, int height) {
((IGuiTextField) this).setInternalWidth(width);
((IGuiTextField) this).setHeight(height);
this.width = width;
this.height = height;
}
public void setPosition(int xPos, int yPos) {
((IGuiTextField) this).setXPosition(xPos);
((IGuiTextField) this).setYPosition(yPos);
this.xPos = xPos;
this.yPos = yPos;
}
public void scrollToEnd() {
this.setCursorPosition(0);
this.setCursorPosition(this.getText().length());
}
/*
* (non-Javadoc)
* @see net.minecraft.src.GuiTextField#func_50032_g(int)
*/
@Override
public void setCursorPosition(int cursorPos) {
super.setCursorPosition(cursorPos);
super.setCursorPosition(cursorPos);
}
/**
* Synchronise private members from the superclass using reflection
*/
protected void syncMembers() {
this.xPos = ((IGuiTextField) this).getXPosition();
this.yPos = ((IGuiTextField) this).getYPosition();
this.width = ((IGuiTextField) this).getInternalWidth();
this.height = ((IGuiTextField) this).getHeight();
}
public void drawTextBoxAt(int yPos) {
try {
((IGuiTextField) this).setYPosition(yPos);
this.yPos = yPos;
this.drawTextBox();
} catch (Exception ex) {}
}
public int getIntValue(int defaultValue) {
try {
return Integer.parseInt(this.getText());
} catch (Exception ex) {
return defaultValue;
}
}
}

View file

@ -1,66 +0,0 @@
package com.voxelmodpack.common.gui.interfaces;
/**
* Interface for controls or other objects which support drag/drop sourcing and
* destination capabilities
*
* @author Adam Mummery-Smith
*/
public interface IDragDrop {
/**
* Get whether this object is a valid drag target
*
* @return true if the object can have draggable items dropped into it
*/
public abstract boolean getIsValidDragTarget();
/**
* Get whether this object is a valid drag source
*
* @return true if this object can source drag events
*/
public abstract boolean getIsValidDragSource();
/**
* Add the specified target to this object's list of targets
*
* @param target DragTarget to add, the object MUST support drag targets
*/
public abstract void addDragTarget(IDragDrop target);
/**
* Add the specified target to this object's list of targets and create a
* mutual (bi-directional) linkage if specified
*
* @param target Target to add
* @param mutual Set true to create a mutual (bi-directional) linkage
*/
public abstract void addDragTarget(IDragDrop target, boolean mutual);
/**
* Remove the specified object from this object's list of targets
*
* @param target Drag Target object to remove
*/
public abstract void removeDragTarget(IDragDrop target);
/**
* Remove the specified object from this object's list of targets and this
* object from the other object's list of targets if specified
*
* @param target Drag Target object to remove
* @param mutual Set true to break the link mutually
*/
public abstract void removeDragTarget(IDragDrop target, boolean mutual);
/**
* Perform a drag operation to this object
*
* @param source Object sourcing the drag event
* @param object Object being dragged
* @param mouseX Mouse X coordinate
* @param mouseY Mouse Y coordinate
* @return True if the object was accepted
*/
public abstract boolean dragDrop(IDragDrop source, IListObject object, int mouseX, int mouseY);
}

View file

@ -1,81 +0,0 @@
package com.voxelmodpack.common.gui.interfaces;
import net.minecraft.util.ResourceLocation;
public interface IExtendedGui {
/**
* Draws a tesselated rectangle where the texture is stretched vertically
* and horizontally but the middle pixels are repeated whilst the joining
* pixels are stretched. Bordersize specifies the portion of the texture
* which will remain unstretched.
*
* @param texture Texture to use
* @param textureSize Size of the texture
* @param x Left edge X coordinate
* @param y Top edge Y coordinate
* @param x2 Right edge X coordinate
* @param y2 Bottom edge Y coordinate
* @param u U coordinate
* @param v V coordinate
* @param u2 Right edge U coordinate
* @param v2 Bottom edge V coordinate
* @param borderSize Number of pixels to leave unstretched, must be less
* than half of the width or height (whichever is smallest)
*/
public abstract void drawTessellatedModalBorderRect(ResourceLocation texture, int textureSize, int x, int y, int x2,
int y2, int u, int v, int u2, int v2, int borderSize);
/**
* Draws a tesselated rectangle where the texture is stretched vertically
* and horizontally but the middle pixels are repeated whilst the joining
* pixels are stretched. Bordersize specifies the portion of the texture
* which will remain unstretched.
*
* @param texture Texture to use
* @param textureSize Size of the texture
* @param x Left edge X coordinate
* @param y Top edge Y coordinate
* @param x2 Right edge X coordinate
* @param y2 Bottom edge Y coordinate
* @param u U coordinate
* @param v V coordinate
* @param u2 Right edge U coordinate
* @param v2 Bottom edge V coordinate
* @param borderSize Number of pixels to leave unstretched, must be less
* than half of the width or height (whichever is smallest)
*/
public abstract void drawTessellatedModalBorderRect(ResourceLocation texture, int textureSize, int x, int y, int x2,
int y2, int u, int v, int u2, int v2, int borderSize, boolean setcolor);
/**
* Advanced version of drawTexturedModalRect which supports separating the
* UV coordinates from the drawn width/height
*
* @param texture Texture to draw
* @param x Left edge X coordinate
* @param y Top edge Y coordinate
* @param x2 Right edge X coordinate
* @param y2 Bottom edge Y coordinate
* @param u U coordinate
* @param v V coordinate
* @param u2 Right edge U coordinate
* @param v2 Bottom edge V coordinate
*/
public abstract void drawTexturedModalRect(ResourceLocation texture, int x, int y, int x2, int y2, int u, int v,
int u2, int v2);
/**
* Advanced version of drawTexturedModalRect which supports separating the
* UV coordinates from the drawn width/height
*
* @param x Left edge X coordinate
* @param y Top edge Y coordinate
* @param x2 Right edge X coordinate
* @param y2 Bottom edge Y coordinate
* @param u U coordinate
* @param v V coordinate
* @param u2 Right edge U coordinate
* @param v2 Bottom edge V coordinate
*/
public abstract void drawTexturedModalRect(int x, int y, int x2, int y2, int u, int v, int u2, int v2);
}

View file

@ -1,256 +0,0 @@
package com.voxelmodpack.common.gui.interfaces;
import net.minecraft.client.Minecraft;
import com.mumfrey.liteloader.util.render.Icon;
/**
* Interface for items that can be added to listboxes
*
* @author Adam Mummery-Smith
*/
public interface IListObject {
/**
* Custom draw behaviours
*/
public enum CustomDrawBehaviour {
/**
* Don't custom draw, this object is completely owner-drawn
*/
NoCustomDraw,
/**
* Combined custom draw, custom draw is called AFTER owner draw
*/
CustomDrawExtra,
/**
* Custom draw only, no owner draw is performed and the item draws
* itself
*/
FullCustomDraw
}
/**
* Get the custom draw behaviour for this object
*
* @return custom draw behaviour
*/
public abstract CustomDrawBehaviour getCustomDrawBehaviour();
/**
* Callback which is called if GetCustomDrawBegaviour returns
* CustomDrawExtra or FullCustomDraw
*
* @param iconEnabled True if icons are enabled in the container (owner)
* @param minecraft Minecraft game instance
* @param mouseX Mouse X coordinate
* @param mouseY Mouse Y coordinate
* @param XPosition() X location of the control
* @param yPosition Y location of the control
* @param width control width
* @param height control height
*/
public abstract void drawCustom(boolean iconEnabled, Minecraft minecraft, int mouseX, int mouseY, int xPosition,
int yPosition, int width, int height, int updateCounter);
/**
* @param iconEnabled True if icons are enabled in the container
* @param minecraft Minecraft game instance
* @param mouseX Mouse X coordinate
* @param mouseY Mouse Y coordinate
* @param XPosition() X location of the control
* @param yPosition Y location of the control
* @param width control width
* @param height control height
* @return true if a custom action was performed
*/
public abstract boolean mousePressed(boolean iconEnabled, Minecraft minecraft, int mouseX, int mouseY,
int xPosition, int yPosition, int width, int height);
/**
* Called when the mouse is released after a MousePressed event
*
* @param mouseX
* @param mouseY
*/
public abstract void mouseReleased(int mouseX, int mouseY);
/**
* If a custom action was flagged after calling MousePressed, this function
* is called to retrieve the custom action
*
* @param bClear Set true to clear the custom action after it is read
* @return Custom action which was performed
*/
public abstract String getCustomAction(boolean bClear);
/**
* True if the object has an icon
*
* @return True if the object has an icon
*/
public abstract boolean hasIcon();
/**
* Bind the icon texture for this object
*/
public abstract void bindIconTexture();
/**
* Get the icon ID for this object
*
* @return icon id
*/
public abstract Icon getIcon();
/**
* Get the icon's size on the texture
*
* @return
*/
public abstract int getIconSize();
/**
* Get the size of the texture map used for the object's icons
*
* @return
*/
public abstract int getIconTexmapSize();
/**
* Get the display text for the object
*
* @return Display text
*/
public abstract String getText();
/**
* Display name if different to text
*
* @return
*/
public abstract String getDisplayName();
/**
* Get the object's ID, object-specific identifier
*
* @return
*/
public abstract int getID();
/**
* Get the arbitrary data associated with the object
*
* @return object's data or NULL if no data
*/
public abstract Object getData();
/**
* Return true if this item is draggable
*
* @return true if this item is draggable
*/
public abstract boolean getDraggable();
/**
* True if this object supports in-place editing
*
* @return
*/
public abstract boolean getCanEditInPlace();
/**
* True if this object is currently in-place editing
*
* @return
*/
public abstract boolean getEditingInPlace();
/**
* Tell this object to begin editing in-place
*/
public abstract void beginEditInPlace();
/**
* Tell this object to end editing in-place
*/
public abstract void endEditInPlace();
/**
* Key typed handler for editing in-place
*
* @param keyChar Key character that was entered
* @param keyCode Key scan code
* @return
*/
public abstract boolean editInPlaceKeyTyped(char keyChar, int keyCode);
/**
* @param iconEnabled True if icons are enabled in the container
* @param minecraft Minecraft game instance
* @param mouseX Mouse X coordinate
* @param mouseY Mouse Y coordinate
* @param XPosition() X location of the control
* @param yPosition Y location of the control
* @param width control width
* @param height control height
* @return true if the mouse was captured
*/
public abstract boolean editInPlaceMousePressed(boolean iconEnabled, Minecraft minecraft, int mouseX, int mouseY,
int xPosition, int yPosition, int width, int height);
/**
* Callback which is called if GetEditingInPlace is true
*
* @param iconEnabled True if icons are enabled in the container (owner)
* @param minecraft Minecraft game instance
* @param mouseX Mouse X coordinate
* @param mouseY Mouse Y coordinate
* @param XPosition() X location of the control
* @param yPosition Y location of the control
* @param width control width
* @param height control height
*/
public abstract void editInPlaceDraw(boolean iconEnabled, Minecraft minecraft, int mouseX, int mouseY,
int xPosition, int yPosition, int width, int height, int updateCounter);
/**
* Set the texture name of the icon for this object.
*/
public abstract void setIconTexture(String newTexture);
/**
* Set the icon ID for this object
*/
public abstract void setIconID(int newIconId);
/**
* Set the display text for the object
*/
public abstract void setText(String newText);
/**
* Set the display name for this object
*
* @param newDisplayName
*/
public abstract void setDisplayName(String newDisplayName);
/**
* Set the object's ID, object-specific identifier
*/
public abstract void setID(int newId);
/**
* Set the arbitrary data associated with the object
*/
public abstract void setData(Object newData);
/**
* Get the serialised representation of this list entry
*
* @return
*/
public abstract String serialise();
}

View file

@ -1,33 +0,0 @@
package com.voxelmodpack.common.gui.interfaces;
public interface IMouseEventListener {
/**
* Called when a mouse button is pressed
*
* @param provider
* @param mouseX
* @param mouseY
* @param mouseButton
*/
public abstract void mousePressed(IMouseEventProvider provider, int mouseX, int mouseY, int mouseButton);
/**
* Called when a mouse button is released
*
* @param provider
* @param mouseX
* @param mouseY
* @param mouseButton
*/
public abstract void mouseReleased(IMouseEventProvider provider, int mouseX, int mouseY, int mouseButton);
/**
* Called when the mouse is moved
*
* @param provider
* @param mouseX
* @param mouseY
*/
public abstract void mouseMoved(IMouseEventProvider provider, int mouseX, int mouseY);
}

View file

@ -1,13 +0,0 @@
package com.voxelmodpack.common.gui.interfaces;
/**
* Interface for screens which can provide mouse events to multiple clients
*
* @author Adam Mummery-Smith
*/
public interface IMouseEventProvider {
/**
* Register a new mouse event listener for this provider instance
*/
public abstract void registerMouseListener(IMouseEventListener listener);
}

View file

@ -1,12 +0,0 @@
package com.voxelmodpack.common.interfaces;
/**
* @author Adam Mummery-Smith
*/
public interface INotifyable {
/**
* @param message
* @param params
*/
public abstract void notify(String message, Object... params);
}

View file

@ -1,23 +0,0 @@
package com.voxelmodpack.common.interfaces;
public interface IRegionRenderer {
/**
* Render a 3-dimensional region using the currently bound texture
*
* @param x1 First x coordinate
* @param y1 First y coordinate
* @param z1 First z coordinate
* @param x2 Second x coordinate
* @param y2 Second y coordinate
* @param z2 Second z coordinate
*/
public abstract void renderRegion3D(int x1, int y1, int z1, int x2, int y2, int z2);
/**
* @param red
* @param green
* @param blue
* @param alpha
*/
public abstract void glColor4f(float red, float green, float blue, float alpha);
}

View file

@ -1,48 +0,0 @@
package com.voxelmodpack.common.interfaces;
/**
* Interface for mods which want to interact with inbound time
*
* @author Adam Mummery-Smith
*/
public interface ITimeHandler {
/**
* Called for every registered handler when a new time packet is received,
* lets each handler note the REAL (server) time
*
* @param totalTime
* @param worldTime
*/
public abstract void onTimeUpdate(long totalTime, long worldTime);
/**
* Called for every registered handler until a handler returns TRUE. If a
* handler returns true then getFrozenTotalTime and getFrozenWorldTime are
* called and the frozen time overrides all other time adjustments
*/
public abstract boolean isFreezingTime();
/**
* If this handler returns TRUE in isFreezingTime then this method must
* return the frozen time
*
* @param totalTime
* @return
*/
public abstract long getFrozenTotalTime(long totalTime);
/**
* If this handler returns TRUE in isFreezingTime then this method must
* return the frozen time
*
* @param worldTime
* @return
*/
public abstract long getFrozenWorldTime(long worldTime);
/**
* If time is not frozen, this method should return the amount of time
* offset this handler wishes to apply
*/
public abstract long getTimeOffset();
}

View file

@ -1,224 +0,0 @@
package com.voxelmodpack.common.net;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.Map;
import java.util.Map.Entry;
/**
* Object which retrieves files from a remote server using http
*
* @author Adam Mummery-Smith
*/
public class HttpFileRetriever extends Thread {
/**
* Callback which receives progress notifications
*/
private final IDownloadProgressWatcher progressWatcher;
/**
* Callback which receives succeeded/failed notifications
*/
private final IDownloadCompletedWatcher completedWatcher;
/**
* Source URL for the resource to download
*/
private final String sourceUrl;
/**
* Additional headers to send with the request
*/
private final Map<String, String> requestHeaders;
/**
* File to download to
*/
private final File localFile;
/**
* Maximum file size allowed for this resource
*/
private final int maxFileSize;
/**
* Flag which can be set to cancel the download
*/
private volatile boolean cancelled;
/**
* @param sourceUrl
* @param headers
* @param destinationFile
* @param maxFileSize
* @param progressWatcher
* @param completedWatcher
*/
private HttpFileRetriever(String sourceUrl, Map<String, String> headers, File destinationFile, int maxFileSize,
IDownloadProgressWatcher progressWatcher, IDownloadCompletedWatcher completedWatcher) {
this.setDaemon(true);
this.sourceUrl = sourceUrl;
this.requestHeaders = headers;
this.localFile = destinationFile;
this.maxFileSize = maxFileSize;
this.progressWatcher = progressWatcher;
this.completedWatcher = completedWatcher;
}
/**
* Cancel this download
*/
public synchronized void cancel() {
this.cancelled = true;
}
/*
* (non-Javadoc)
* @see java.lang.Thread#run()
*/
@Override
public void run() {
URLConnection http = null;
InputStream httpInputStream = null;
DataOutputStream fileOutputStream = null;
if (this.progressWatcher != null) {
this.progressWatcher.resetProgressAndMessage("Downloading File");
this.progressWatcher.resetProgressAndWorkingMessage("Making Request...");
}
try {
try {
byte[] buffer = new byte[4096];
http = new URL(this.sourceUrl).openConnection();
http.addRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"); // For
// CloudFlare
float progress = 0.0F;
float progressMax = this.requestHeaders.entrySet().size();
for (Entry<String, String> header : this.requestHeaders.entrySet()) {
http.setRequestProperty(header.getKey(), header.getValue());
if (this.progressWatcher != null) {
this.progressWatcher.setProgress((int) (++progress / progressMax * 100.0F));
}
}
if (this.cancelled) {
if (this.progressWatcher != null)
this.progressWatcher.onCompleted();
this.completedWatcher.onFailure(this.localFile);
return;
}
httpInputStream = http.getInputStream();
progressMax = http.getContentLength();
int contentLength = http.getContentLength();
if (this.progressWatcher != null)
this.progressWatcher.resetProgressAndWorkingMessage(String.format("Downloading file (%.2f MB)...",
new Object[] { Float.valueOf(progressMax / 1000.0F / 1000.0F) }));
if (this.localFile.exists()) {
long receivedBytes = this.localFile.length();
if (receivedBytes == contentLength) {
this.completedWatcher.onSuccess(this.localFile);
if (this.progressWatcher != null)
this.progressWatcher.onCompleted();
return;
}
System.out.println("Deleting " + this.localFile + " as it does not match what we currently have ("
+ contentLength + " vs our " + receivedBytes + ").");
this.localFile.delete();
}
fileOutputStream = new DataOutputStream(new FileOutputStream(this.localFile));
if (this.maxFileSize > 0 && progressMax > this.maxFileSize) {
if (this.progressWatcher != null)
this.progressWatcher.onCompleted();
throw new IOException("Filesize is bigger than maximum allowed (file is " + progress + ", limit is "
+ this.maxFileSize + ")");
}
int readBytes;
while ((readBytes = httpInputStream.read(buffer)) >= 0 && !this.cancelled) {
progress += readBytes;
if (this.progressWatcher != null)
this.progressWatcher.setProgress((int) (progress / progressMax * 100.0F));
if (this.maxFileSize > 0 && progress > this.maxFileSize) {
if (this.progressWatcher != null)
this.progressWatcher.onCompleted();
throw new IOException("Filesize was bigger than maximum allowed (got >= " + progress
+ ", limit was " + this.maxFileSize + ")");
}
fileOutputStream.write(buffer, 0, readBytes);
}
if (this.cancelled) {
try {
fileOutputStream.close();
this.localFile.delete();
} catch (IOException ex) {}
if (this.progressWatcher != null)
this.progressWatcher.onCompleted();
this.completedWatcher.onFailure(this.localFile);
return;
}
this.completedWatcher.onSuccess(this.localFile);
if (this.progressWatcher != null) {
this.progressWatcher.onCompleted();
return;
}
} catch (Throwable th) {
// th.printStackTrace();
}
} finally {
try {
if (httpInputStream != null)
httpInputStream.close();
} catch (IOException ex) {}
try {
if (fileOutputStream != null)
fileOutputStream.close();
} catch (IOException ex) {}
}
}
/**
* @param sourceUrl
* @param headers
* @param destFile
* @param maxFileSize
* @param progressWatcher
* @param completedWatcher
* @return
*/
public static HttpFileRetriever beginDownloading(String sourceUrl, Map<String, String> headers, File destFile,
int maxFileSize, IDownloadProgressWatcher progressWatcher, IDownloadCompletedWatcher completedWatcher) {
HttpFileRetriever downloadThread = new HttpFileRetriever(sourceUrl, headers, destFile, maxFileSize,
progressWatcher, completedWatcher);
downloadThread.start();
return downloadThread;
}
}

View file

@ -1,25 +0,0 @@
package com.voxelmodpack.common.net;
import java.io.File;
/**
* Interface for objects which want a callback on the success/failure of file
* downloads
*
* @author Adam Mummery-Smith
*/
public interface IDownloadCompletedWatcher {
/**
* Called if the download succeeds
*
* @param destFile
*/
public abstract void onSuccess(File destFile);
/**
* Called if the download fails
*
* @param destFile
*/
public abstract void onFailure(File destFile);
}

View file

@ -1,34 +0,0 @@
package com.voxelmodpack.common.net;
/**
* Interface for objects which want a callback to monitor the progress of file
* downloads
*
* @author Adam Mummery-Smith
*/
public interface IDownloadProgressWatcher {
/**
* @param message
*/
public abstract void setMessage(String message);
/**
* @param message
*/
public abstract void resetProgressAndMessage(String message);
/**
* @param message
*/
public abstract void resetProgressAndWorkingMessage(String message);
/**
* @param progress
*/
public abstract void setProgress(int progress);
/**
*
*/
public abstract void onCompleted();
}

View file

@ -1,250 +0,0 @@
package com.voxelmodpack.common.properties;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.util.Properties;
import com.mumfrey.liteloader.core.LiteLoader;
import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProviderBoolean;
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProviderFloat;
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProviderInteger;
/**
* Configuration file for VoxelMods
*/
public abstract class ModConfig
implements IVoxelPropertyProviderFloat, IVoxelPropertyProviderInteger, IVoxelPropertyProviderBoolean {
/**
* Set of default properties Set these in setDefaults
*/
protected final Properties defaults = new Properties();
/**
* The runtime configuration
*/
protected Properties config;
/**
* name of the mod that this belongs to
*/
protected final String modName;
/**
* String path to the config file
*/
protected final String propertiesFileName;
/**
* File that the configuration is held in
*/
protected File propertiesFile;
/**
* @param modName Name of the mod that this will belong to
* @param propertiesFileName string path to the file that this uses
*/
public ModConfig(String modName, String propertiesFileName) {
this.modName = modName;
this.propertiesFileName = propertiesFileName;
this.setDefaults();
LiteLoaderLogger.info("%s> Attempting to load/create the configuration.", this.modName);
this.loadConfig();
}
/**
* Use this to set the defaults in a config
*/
protected abstract void setDefaults();
/**
* Attemps to load the saved config file If the file cannot load the
* defaults are used If the file does not exist one is created with the
* defaults saved to it
*/
protected void loadConfig() {
this.config = new Properties(this.defaults);
try {
this.propertiesFile = new File(LiteLoader.getCommonConfigFolder(), this.propertiesFileName);
if (this.propertiesFile.exists()) {
LiteLoaderLogger.info("%s> Config file found, loading...", this.modName);
this.config.load(new FileInputStream(this.propertiesFile));
} else {
LiteLoaderLogger.info("%s> No config file found, creating...", this.modName);
this.createConfig();
}
} catch (Exception ex) {
LiteLoaderLogger.warning("%s> ERROR: %s", this.modName, ex.toString());
}
}
/**
* Create the config Only used to generate a new config file
*/
protected void createConfig() {
try {
this.config.putAll(this.defaults);
this.config.store(new FileWriter(this.propertiesFile), null);
} catch (Exception ex) {
LiteLoaderLogger.warning("%s> ERROR: %s", this.modName, ex.toString());
}
}
/**
* Set the given property to a float
*
* @param propertyName The property to change
* @param s The float value to set it to
*/
@Override
public void setProperty(String propertyName, float value) {
this.config.setProperty(propertyName, String.valueOf(value));
this.saveConfig();
}
/**
* Set the given property to a int
*
* @param propertyName The property to change
* @param s The int value to set it to
*/
@Override
public void setProperty(String propertyName, int value) {
this.config.setProperty(propertyName, String.valueOf(value));
this.saveConfig();
}
/**
* Set the given property to a boolean
*
* @param propertyName The property to change
* @param s The boolean value to set it to
*/
@Override
public void setProperty(String propertyName, boolean value) {
this.config.setProperty(propertyName, String.valueOf(value));
this.saveConfig();
}
/**
* Set the given property to a string
*
* @param propertyName The property to change
* @param value The String to set it to
*/
public void setProperty(String propertyName, String value) {
this.config.setProperty(propertyName, value);
this.saveConfig();
}
/**
* @param propertyName The property that gets it's value returned
* @return A string value of the given property
*/
@Override
public String getStringProperty(String propertyName) {
return this.config.getProperty(propertyName);
}
/**
* @param propertyName The property that gets it's value returned
* @return A float value of the given property
*/
@Override
public float getFloatProperty(String propertyName) {
return Float.parseFloat(this.config.getProperty(propertyName));
}
/**
* @param propertyName Name of the Property to get
* @param min the minimum that the property can be
* @param max the maximum that the property can be
* @return a float representation of the property that is within the min and
* max
*/
public float getClampedFloatProperty(String propertyName, float min, float max) {
float value = this.getFloatProperty(propertyName);
return Math.min(Math.max(value, min), max);
}
/**
* @param propertyName The property that gets it's value returned
* @return A int value of the given property
*/
@Override
public int getIntProperty(String propertyName) {
return Integer.parseInt(this.config.getProperty(propertyName));
}
/**
* @param propertyName The property that gets it's value returned
* @return A boolean value of the given property
*/
@Override
public boolean getBoolProperty(String propertyName) {
return Boolean.parseBoolean(this.config.getProperty(propertyName));
}
/**
* @param propertyName The property that gets it's value returned
* @return A int value of the default for the given property
*/
@Override
public String getDefaultPropertyValue(String propertyName) {
return this.defaults.getProperty(propertyName);
}
/**
* @param propertyName The property that gets it's value returned
* @return A float value of the default for the given property
*/
public float getDefaultFloatProperty(String propertyName) {
return Float.parseFloat(this.defaults.getProperty(propertyName));
}
/**
* @param propertyName The property that gets it's value returned
* @return A int value of the default for the given property
*/
public int getDefaultIntProperty(String propertyName) {
return Integer.parseInt(this.defaults.getProperty(propertyName));
}
/**
* @param propertyName The property that gets it's value returned
* @return A boolean value of the default for the given property
*/
public boolean getDefaultBoolProperty(String propertyName) {
return Boolean.parseBoolean(this.defaults.getProperty(propertyName));
}
/**
* Saves the configuration to file
*/
public void saveConfig() {
try {
this.config.store(new FileWriter(this.propertiesFile), null);
} catch (Exception e) {
LiteLoaderLogger.warning("%s> ERROR: %s", this.modName, e.toString());
}
}
/**
* Swaps the state of a boolean option
*/
@Override
public void toggleOption(String propertyName) {
this.setProperty(propertyName, !this.getBoolProperty(propertyName));
}
/**
*
*/
@Override
public String getOptionDisplayString(String propertyName) {
return "";
}
}

View file

@ -1,177 +0,0 @@
package com.voxelmodpack.common.properties;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.audio.SoundHandler;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.util.ResourceLocation;
import com.voxelmodpack.common.gui.interfaces.IExtendedGui;
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProvider;
/**
* Property superclass
*
* @author Adam Mummery-Smith
*/
public abstract class VoxelProperty<PropertyType extends IVoxelPropertyProvider> extends Gui {
/**
* Font renderer reference
*/
protected FontRenderer fontRenderer;
/**
* Underlying property provider for this property
*/
protected PropertyType propertyProvider;
/**
* Name of the property this control is bound to
*/
protected String propertyBinding;
/**
* Minecraft reference
*/
protected Minecraft mc = Minecraft.getMinecraft();
/**
* Display text (if any) for this property
*/
protected String displayText;
/**
* X position
*/
protected int xPosition;
/**
* Y position
*/
protected int yPosition;
/**
* Cursor flash counter
*/
protected int cursorCounter;
/**
* True if this control is has focus
*/
protected boolean focused;
/**
* True if this control is visible
*/
protected boolean visible = true;
/**
* @param propertyProvider
* @param binding
* @param displayText
* @param xPos
* @param yPos
*/
@SuppressWarnings("unchecked")
public VoxelProperty(IVoxelPropertyProvider propertyProvider, String binding, String displayText, int xPos,
int yPos) {
try {
this.propertyProvider = (PropertyType) propertyProvider;
} catch (ClassCastException ex) {
throw new RuntimeException(String.format("Can't create VoxelProperty for binding %s for panel %s", binding,
propertyProvider.getClass().getSimpleName()));
}
this.fontRenderer = this.mc.fontRendererObj;
this.propertyBinding = binding;
this.displayText = displayText;
this.xPosition = xPos;
this.yPosition = yPos;
}
/**
*
*/
public void updateCursorCounter() {
this.cursorCounter++;
}
/**
* Draw this property
*
* @param host
* @param mouseX
* @param mouseY
*/
public abstract void draw(IExtendedGui host, int mouseX, int mouseY);
/**
* Handle mouse clicks on the property
*
* @param mouseX
* @param mouseY
*/
public abstract void mouseClicked(int mouseX, int mouseY);
/**
* Handle keystrokes
*
* @param keyChar
* @param keyCode
*/
public abstract void keyTyped(char keyChar, int keyCode);
/**
* Called when the containing GUI is closed
*/
public void onClosed() {
// stub
}
/**
* Get whether this property is visible
*/
public boolean isVisible() {
return this.visible;
}
/**
* Set whether this property is visible
*/
public void setVisible(boolean visible) {
this.visible = visible;
}
/**
* @return
*/
public boolean isFocusable() {
return false;
}
/**
* @return
*/
public boolean isFocused() {
return false;
}
/**
* @param focus
*/
public void setFocused(boolean focus) {}
/**
* @param soundHandler
*/
public void playClickSound(SoundHandler soundHandler) {
soundHandler.playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
}
@Override
public void drawString(FontRenderer fontRendererIn, String text, int x, int y, int color) {
super.drawString(fontRendererIn, text, x, y, color);
}
}

View file

@ -1,69 +0,0 @@
package com.voxelmodpack.common.properties;
import com.voxelmodpack.common.LiteModVoxelCommon;
import com.voxelmodpack.common.gui.interfaces.IExtendedGui;
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProvider;
public abstract class VoxelPropertyAbstractButton<PropertyType extends IVoxelPropertyProvider>
extends VoxelProperty<PropertyType> {
private int buttonOffset = 60;
private int buttonWidth = 70;
private int buttonHeight = 16;
public VoxelPropertyAbstractButton(IVoxelPropertyProvider propertyProvider, String binding, String displayText,
int xPos, int yPos) {
this(propertyProvider, binding, displayText, xPos, yPos, 60, 70, 16);
}
public VoxelPropertyAbstractButton(IVoxelPropertyProvider propertyProvider, String binding, String displayText,
int xPos, int yPos, int buttonOffset, int buttonWidth, int buttonHeight) {
super(propertyProvider, binding, displayText, xPos, yPos);
this.buttonOffset = buttonOffset;
this.buttonWidth = buttonWidth;
this.buttonHeight = buttonHeight;
}
@Override
public void draw(IExtendedGui host, int mouseX, int mouseY) {
boolean overButton = this.mouseOver(mouseX, mouseY);
int outset = overButton ? 1 : 0;
int v = overButton ? 16 : 0;
int colour = overButton ? 0xFFFFFF : 0x999999;
drawRect(this.xPosition + this.buttonOffset + this.buttonWidth - 1, this.yPosition + this.buttonHeight,
this.xPosition + this.buttonOffset + 1, this.yPosition, 0xFF000000);
host.drawTessellatedModalBorderRect(LiteModVoxelCommon.GUIPARTS, 256,
this.xPosition + this.buttonOffset - outset, this.yPosition - 1 - outset,
this.xPosition + this.buttonOffset + this.buttonWidth + outset,
this.yPosition + 1 + this.buttonHeight + outset, 0, v, 16, v + 16, 4);
this.drawString(this.fontRenderer, this.displayText,
(this.xPosition + this.buttonOffset + (this.buttonWidth / 2))
- (this.fontRenderer.getStringWidth(this.displayText) / 2),
this.yPosition + 4, colour);
}
@Override
public void mouseClicked(int mouseX, int mouseY) {
if (this.mouseOver(mouseX, mouseY)) {
this.onClick();
}
}
protected abstract void onClick();
/**
* @param mouseX
* @param mouseY
* @return
*/
public boolean mouseOver(int mouseX, int mouseY) {
return mouseX > this.xPosition + this.buttonOffset
&& mouseX < this.xPosition + this.buttonOffset + this.buttonWidth && mouseY >= this.yPosition
&& mouseY <= this.yPosition + this.buttonHeight;
}
@Override
public void keyTyped(char keyChar, int keyCode) {}
}

View file

@ -1,148 +0,0 @@
package com.voxelmodpack.common.properties;
import org.lwjgl.input.Keyboard;
import com.voxelmodpack.common.gui.interfaces.IExtendedGui;
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProvider;
/**
* Adapted from xTiming's text field code
*
* @author Adam Mummery-Smith
*/
public abstract class VoxelPropertyAbstractTextField<PropertyType extends IVoxelPropertyProvider>
extends VoxelProperty<PropertyType> {
protected String allowedCharacters = "0123456789";
protected String fieldValue = "0";
protected String defaultFieldValue = "0";
protected int fieldOffset = 74;
protected int fieldWidth = 52;
protected int fieldHeight = 16;
public VoxelPropertyAbstractTextField(IVoxelPropertyProvider propertyProvider, String binding, String displayText,
int xPos, int yPos, int fieldOffset) {
super(propertyProvider, binding, displayText, xPos, yPos);
this.fieldValue = this.propertyProvider.getStringProperty(binding);
this.defaultFieldValue = this.propertyProvider.getDefaultPropertyValue(this.propertyBinding);
this.fieldOffset = fieldOffset;
}
/**
* @param mouseX
* @param mouseY
* @param fieldValue
* @param focused
* @param field_146128_h
* @param field_146129_i
* @return
*/
@Override
public void draw(IExtendedGui host, int mouseX, int mouseY) {
drawRect(this.xPosition + this.fieldOffset + this.fieldWidth, this.yPosition + this.fieldHeight,
this.xPosition + this.fieldOffset, this.yPosition - 1, this.focused ? 0xFFFFFFFF : 0xFF999999);
drawRect(this.xPosition + this.fieldOffset + this.fieldWidth - 1, this.yPosition + this.fieldHeight - 1,
this.xPosition + this.fieldOffset + 1, this.yPosition, 0xFF000000);
boolean optionCursor = this.focused && (this.cursorCounter / 6) % 2 == 0;
this.drawString(this.fontRenderer, this.displayText, this.xPosition, this.yPosition + 4, 0xFFFFFF);
this.drawString(this.fontRenderer, this.fieldValue + (optionCursor ? "_" : ""),
this.fieldValue.length() > 0
? (this.xPosition + this.fieldOffset + (this.fieldWidth / 2))
- (this.fontRenderer.getStringWidth(this.fieldValue) / 2)
: this.xPosition + this.fieldOffset + (this.fieldWidth / 2) - 3,
this.yPosition + 4, 0xFFFFFF);
}
/**
* @param keyChar
* @param keyCode
*/
@Override
public void keyTyped(char keyChar, int keyCode) {
if (this.focused) {
if (keyCode == Keyboard.KEY_RETURN || keyCode == Keyboard.KEY_NUMPADENTER || keyCode == Keyboard.KEY_ESCAPE)
this.onLostFocus();
if (keyCode == Keyboard.KEY_BACK && this.fieldValue.length() > 0)
this.fieldValue = this.fieldValue.substring(0, this.fieldValue.length() - 1);
if (keyCode == Keyboard.KEY_PERIOD && this.allowedCharacters.indexOf('.') >= 0) {
if (this.fieldValue.indexOf(keyChar) >= 0)
return;
if (this.fieldValue.length() == 0)
this.fieldValue += "0";
}
if (this.allowedCharacters.indexOf(keyChar) >= 0 && this.fieldValue.length() < 4)
this.fieldValue += keyChar;
if (this.checkInvalidValue())
this.fieldValue = this.defaultFieldValue;
}
}
/**
* @return
*/
protected abstract boolean checkInvalidValue();
/**
* @param mouseX
* @param mouseY
*/
@Override
public void mouseClicked(int mouseX, int mouseY) {
boolean mouseOver = this.mouseOver(mouseX, mouseY);
if (!this.focused && mouseOver) {
this.playClickSound(this.mc.getSoundHandler());
this.fieldValue = this.propertyProvider.getStringProperty(this.propertyBinding);
} else if (this.focused && !mouseOver) {
this.onLostFocus();
}
this.focused = mouseOver;
}
@Override
public void onClosed() {
this.onLostFocus();
}
protected abstract void onLostFocus();
/**
* @param mouseX
* @param mouseY
* @return
*/
public boolean mouseOver(int mouseX, int mouseY) {
return mouseX > this.xPosition + this.fieldOffset
&& mouseX < this.xPosition + this.fieldOffset + this.fieldWidth && mouseY > this.yPosition
&& mouseY < this.yPosition + 15;
}
public void update() {
this.fieldValue = this.propertyProvider.getStringProperty(this.propertyBinding);
}
@Override
public boolean isFocusable() {
return true;
}
@Override
public void setFocused(boolean focus) {
if (this.focused && !focus) {
this.onLostFocus();
}
this.focused = focus;
}
@Override
public boolean isFocused() {
return this.focused;
}
}

View file

@ -1,67 +0,0 @@
package com.voxelmodpack.common.properties;
import com.voxelmodpack.common.LiteModVoxelCommon;
import com.voxelmodpack.common.gui.interfaces.IExtendedGui;
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProviderBoolean;
/**
* Adapted from xTiming's checkbox code
*
* @author Adam Mummery-Smith
*/
public class VoxelPropertyCheckBox extends VoxelPropertyToggleButton {
private int width = 11;
private final VoxelPropertyCheckBox parent;
public VoxelPropertyCheckBox(IVoxelPropertyProviderBoolean propertyProvider, String binding, String text, int xPos,
int yPos) {
this(propertyProvider, binding, text, xPos, yPos, null);
}
public VoxelPropertyCheckBox(IVoxelPropertyProviderBoolean propertyProvider, String binding, String text, int xPos,
int yPos, VoxelPropertyCheckBox parent) {
super(propertyProvider, binding, text, xPos, yPos);
this.width = this.fontRenderer.getStringWidth(this.displayText) + 20;
this.parent = parent;
}
public VoxelPropertyCheckBox getParent() {
return this.parent;
}
@Override
public void draw(IExtendedGui host, int mouseX, int mouseY) {
this.drawString(this.fontRenderer, this.displayText, this.xPosition + 20, this.yPosition + 2,
this.isParentChecked() ? 0xFFFFFF : 0x666666);
boolean overButton = this.mouseOver(mouseX, mouseY);
boolean checked = this.isChecked();
host.drawTessellatedModalBorderRect(LiteModVoxelCommon.GUIPARTS, 256, this.xPosition, this.yPosition,
this.xPosition + 11, this.yPosition + 11, 0, overButton ? 16 : 0, 16, overButton ? 32 : 16, 4);
host.drawTexturedModalRect(LiteModVoxelCommon.GUIPARTS, this.xPosition, this.yPosition, this.xPosition + 10,
this.yPosition + 10, checked ? 12 : 0, 52, checked ? 23 : 11, 63);
}
/**
* @return
*/
boolean isChecked() {
return this.isParentChecked() && this.propertyProvider.getBoolProperty(this.propertyBinding);
}
/**
* @return
*/
boolean isParentChecked() {
return this.parent == null || this.parent.isChecked();
}
@Override
public boolean mouseOver(int mouseX, int mouseY) {
return this.isParentChecked() && mouseX > this.xPosition && mouseX < this.xPosition + this.width
&& mouseY > this.yPosition && mouseY < this.yPosition + 11;
}
}

View file

@ -1,40 +0,0 @@
package com.voxelmodpack.common.properties;
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProvider;
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProviderFloat;
/**
* Adapted from xTiming's text field code
*
* @author Adam Mummery-Smith
*/
public class VoxelPropertyFloatField extends VoxelPropertyAbstractTextField<IVoxelPropertyProviderFloat> {
private float minFieldValue = 0.1F;
private float maxFieldValue = 10.0F;
public VoxelPropertyFloatField(IVoxelPropertyProvider propertyProvider, String binding, String text, int xPos,
int yPos, int fieldOffset) {
super(propertyProvider, binding, text, xPos, yPos, fieldOffset);
this.allowedCharacters = "0123456789.";
}
@Override
protected void onLostFocus() {
if (this.fieldValue.length() == 0)
this.fieldValue = this.propertyProvider.getDefaultPropertyValue(this.propertyBinding);
if (Float.valueOf(this.fieldValue) < this.minFieldValue)
this.fieldValue = String.valueOf(this.minFieldValue);
this.propertyProvider.setProperty(this.propertyBinding, Float.parseFloat(this.fieldValue));
this.fieldValue = this.propertyProvider.getStringProperty(this.propertyBinding);
this.focused = false;
}
/**
* @return
*/
@Override
protected boolean checkInvalidValue() {
return this.fieldValue.length() > 0 && Float.valueOf(this.fieldValue) > this.maxFieldValue;
}
}

View file

@ -1,55 +0,0 @@
package com.voxelmodpack.common.properties;
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProvider;
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProviderInteger;
/**
* Adapted from xTiming's text field code
*
* @author Adam Mummery-Smith
*/
public class VoxelPropertyIntField extends VoxelPropertyAbstractTextField<IVoxelPropertyProviderInteger> {
private int minFieldValue = 1;
private int maxFieldValue = 60;
public VoxelPropertyIntField(IVoxelPropertyProvider propertyProvider, String binding, String text, int xPos,
int yPos, int fieldOffset) {
super(propertyProvider, binding, text, xPos, yPos, fieldOffset);
}
@Override
protected void onLostFocus() {
if (this.fieldValue.length() == 0)
this.fieldValue = this.propertyProvider.getDefaultPropertyValue(this.propertyBinding);
if (Integer.valueOf(this.fieldValue) < this.minFieldValue)
this.fieldValue = String.valueOf(this.minFieldValue);
this.propertyProvider.setProperty(this.propertyBinding, Integer.parseInt(this.fieldValue));
this.fieldValue = this.propertyProvider.getStringProperty(this.propertyBinding);
this.focused = false;
}
/**
* @return
*/
@Override
protected boolean checkInvalidValue() {
return this.fieldValue.length() > 0 && Integer.valueOf(this.fieldValue) > this.maxFieldValue;
}
public int getMinFieldValue() {
return this.minFieldValue;
}
public void setMinFieldValue(int minFieldValue) {
this.minFieldValue = minFieldValue;
}
public int getMaxFieldValue() {
return this.maxFieldValue;
}
public void setMaxFieldValue(int maxFieldValue) {
this.maxFieldValue = maxFieldValue;
}
}

View file

@ -1,102 +0,0 @@
package com.voxelmodpack.common.properties;
import org.lwjgl.input.Keyboard;
import com.voxelmodpack.common.LiteModVoxelCommon;
import com.voxelmodpack.common.gui.interfaces.IExtendedGui;
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProvider;
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProviderInteger;
/**
* Adapted from xTiming's key bind button code
*
* @author Adam Mummery-Smith
*/
public class VoxelPropertyKeyBinding extends VoxelProperty<IVoxelPropertyProviderInteger> {
private int buttonOffset = 60;
private int buttonWidth = 70;
private int buttonHeight = 16;
/**
* @param parent
* @param binding
* @param displayText
* @param xPos
* @param yPos
*/
public VoxelPropertyKeyBinding(IVoxelPropertyProvider propertyProvider, String binding, String displayText,
int xPos, int yPos) {
super(propertyProvider, binding, displayText, xPos, yPos);
}
/**
* @param mouseX
* @param mouseY
* @param displayText
* @param keyCode
* @param bindActive
* @param field_146128_h
* @param field_146129_i
* @return
*/
@Override
public void draw(IExtendedGui host, int mouseX, int mouseY) {
boolean overKey = this.focused || this.mouseOver(mouseX, mouseY);
int outset = overKey ? 1 : 0;
int v = overKey ? 16 : 0;
int keyCode = this.propertyProvider.getIntProperty(this.propertyBinding);
this.drawString(this.fontRenderer, this.displayText, this.xPosition, this.yPosition + 4, 0xFFFFFF);
String fKey = this.focused ? "Press a key" : Keyboard.getKeyName(keyCode);
drawRect(this.xPosition + this.buttonOffset + this.buttonWidth - 1, this.yPosition + this.buttonHeight,
this.xPosition + this.buttonOffset + 1, this.yPosition, 0xFF000000);
host.drawTessellatedModalBorderRect(LiteModVoxelCommon.GUIPARTS, 256,
this.xPosition + this.buttonOffset - outset, this.yPosition - 1 - outset,
this.xPosition + this.buttonOffset + this.buttonWidth + outset,
this.yPosition + 1 + this.buttonHeight + outset, 0, v, 16, v + 16, 4);
this.drawString(this.fontRenderer, fKey,
(this.xPosition + this.buttonOffset + (this.buttonWidth / 2))
- (this.fontRenderer.getStringWidth(fKey) / 2),
this.yPosition + 4, overKey || this.focused ? 0xFFFFFF : 0x999999);
}
/*
* (non-Javadoc)
* @see
* com.voxelbox.voxelflight.VoxelFlightGUI.VoxelProperty#MouseClicked(int,
* int)
*/
@Override
public void mouseClicked(int mouseX, int mouseY) {
boolean mouseOver = this.mouseOver(mouseX, mouseY);
if (!this.focused && mouseOver)
this.playClickSound(this.mc.getSoundHandler());
this.focused = mouseOver;
}
/**
* @param mouseX
* @param mouseY
* @return
*/
public boolean mouseOver(int mouseX, int mouseY) {
return mouseX > this.xPosition + this.buttonOffset
&& mouseX < this.xPosition + this.buttonOffset + this.buttonWidth && mouseY >= this.yPosition
&& mouseY <= this.yPosition + this.buttonHeight;
}
/*
* (non-Javadoc)
* @see com.voxelbox.voxelflight.VoxelFlightGUI.VoxelProperty#KeyTyped(char,
* int)
*/
@Override
public void keyTyped(char keyChar, int keyCode) {
if (this.focused) {
this.propertyProvider.setProperty(this.propertyBinding, keyCode);
this.focused = false;
}
}
}

View file

@ -1,33 +0,0 @@
package com.voxelmodpack.common.properties;
import com.voxelmodpack.common.gui.interfaces.IExtendedGui;
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProvider;
/**
* Label
*
* @author Adam Mummery-Smith
*/
public class VoxelPropertyLabel extends VoxelProperty<IVoxelPropertyProvider> {
private int colour = 0x99CCFF;
public VoxelPropertyLabel(String displayText, int xPos, int yPos) {
this(displayText, xPos, yPos, 0x99CCFF);
}
public VoxelPropertyLabel(String displayText, int xPos, int yPos, int colour) {
super(null, null, displayText, xPos, yPos);
this.colour = colour;
}
@Override
public void draw(IExtendedGui host, int mouseX, int mouseY) {
this.drawString(this.mc.fontRendererObj, this.displayText, this.xPosition, this.yPosition, this.colour);
}
@Override
public void mouseClicked(int mouseX, int mouseY) {}
@Override
public void keyTyped(char keyChar, int keyCode) {}
}

View file

@ -1,279 +0,0 @@
package com.voxelmodpack.common.properties;
import org.lwjgl.input.Mouse;
import com.voxelmodpack.common.LiteModVoxelCommon;
import com.voxelmodpack.common.gui.interfaces.IExtendedGui;
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProvider;
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProviderFloat;
/**
* Rebuilt by anangrybeaver
*
* @author anangrybeaver
*/
public class VoxelPropertySlider extends VoxelProperty<IVoxelPropertyProviderFloat> {
private float value = 0;
private float valueMin = -1;
private float valueMax = 1;
private float valueShift = -1;
private float valueScale;
private float indicatorValue = 0;
private int sliderHeight;
private int sliderWidth;
private int handleXPos;
private int handleXPosMin;
private int handleXPosMax;
private int handleWidth;
private int handleHeight;
private boolean snap = false;
private boolean indicatorShow = false;
private String minText = "Min";
private String maxText = "Max";
@SuppressWarnings("unused")
private String labelText;
public VoxelPropertySlider(IVoxelPropertyProvider propertyProvider, String binding, String text, int xPos, int yPos,
int w, int h, float minValue, float maxValue, boolean snap) {
this(propertyProvider, binding, text, xPos, yPos, w, h, snap);
this.valueMax = maxValue;
this.valueMin = minValue;
if (this.valueMax < this.valueMin || this.valueMax == this.valueMin)
this.valueMax = this.valueMin + 1;
this.valueShift = this.valueMin;
this.value = this.propertyProvider.getFloatProperty(binding) - this.valueShift;
this.valueScale = (this.handleXPosMax - this.handleXPosMin) / (this.valueMax - this.valueMin);
if (this.propertyProvider.getFloatProperty(binding) < this.valueMin)
this.propertyProvider.setProperty(binding, this.valueMin);
else if (this.propertyProvider.getFloatProperty(binding) > this.valueMax)
this.propertyProvider.setProperty(binding, this.valueMax);
}
/**
* Creates a more defined Slider with given specifications.
*
* @param parent The GUI Element, "this"
* @param binding The numeral binding to be linked to.
* @param text Name of the slider.
* @param xPos x Coordinate
* @param yPos y coordinate
* @param w Width of the slider
* @param h Height of the slider
* @param minValue minimum value of the slider
* @param maxValue max value of the slider
* @param snap If it snaps to whole numbers.
*/
public VoxelPropertySlider(IVoxelPropertyProvider propertyProvider, String binding, String text, int xPos, int yPos,
int w, int h, float minValue, float maxValue, float indicatorValue, boolean snap) {
this(propertyProvider, binding, text, xPos, yPos, w, h, indicatorValue, snap);
this.valueMax = maxValue;
this.valueMin = minValue;
if (this.valueMax < this.valueMin || this.valueMax == this.valueMin)
this.valueMax = this.valueMin + 1;
this.valueShift = this.valueMin;
this.value = this.propertyProvider.getFloatProperty(binding) - this.valueShift;
this.valueScale = (this.handleXPosMax - this.handleXPosMin) / (this.valueMax - this.valueMin);
if (this.propertyProvider.getFloatProperty(binding) < this.valueMin)
this.propertyProvider.setProperty(binding, this.valueMin);
else if (this.propertyProvider.getFloatProperty(binding) > this.valueMax)
this.propertyProvider.setProperty(binding, this.valueMax);
}
/**
* Creates a generic Slider with given specifications.
*
* @param parent The GUI Element, "this"
* @param binding The numeral binding to be linked to.
* @param text Name of the slider.
* @param xPos x Coordinate
* @param yPos y coordinate
* @param w Width of the slider
* @param h Height of the slider
* @param indicatorValue The value of a visible indicator on the slider.
* @param snap If it snaps to whole numbers.
*/
public VoxelPropertySlider(IVoxelPropertyProvider propertyProvider, String binding, String text, int xPos, int yPos,
int w, int h, float indicatorValue, boolean snap) {
this(propertyProvider, binding, text, xPos, yPos, w, h, snap);
this.indicatorValue = indicatorValue;
this.indicatorShow = true;
}
/**
* Creates a generic Slider with given specifications.
*
* @param parent The GUI Element, "this"
* @param binding The numeral binding to be linked to.
* @param displayText Name of the slider.
* @param xPos x Coordinate
* @param yPos y coordinate
* @param w Width of the slider
* @param h Height of the slider
* @param snap If it snaps to whole numbers.
*/
public VoxelPropertySlider(IVoxelPropertyProvider propertyProvider, String binding, String displayText, int xPos,
int yPos, int w, int h, boolean snap) {
super(propertyProvider, binding, displayText, xPos, yPos);
this.sliderHeight = h;
this.sliderWidth = w;
this.handleWidth = this.sliderHeight - 2;
this.handleHeight = this.sliderHeight + 4;
this.handleXPos = this.xPosition;
this.handleXPosMin = this.xPosition + 2;
this.handleXPosMax = this.xPosition + this.sliderWidth - this.handleWidth - 2;
this.value = this.propertyProvider.getFloatProperty(binding) - this.valueShift;
this.valueScale = (this.handleXPosMax - this.handleXPosMin) / (this.valueMax - this.valueMin);
this.snap = snap;
}
public VoxelPropertySlider(IVoxelPropertyProvider propertyProvider, String binding, String displayText,
String minText, String maxText, int xPos, int yPos, float min, float max) {
this(propertyProvider, binding, displayText, xPos, yPos, min, max);
this.minText = minText;
this.maxText = maxText;
}
public VoxelPropertySlider(IVoxelPropertyProvider propertyProvider, String binding, String displayText, int xPos,
int yPos, float min, float max) {
this(propertyProvider, binding, displayText, xPos, yPos);
this.valueMin = min;
this.valueMax = max;
if (this.valueMax < this.valueMin || this.valueMax == this.valueMin)
this.valueMax = this.valueMin + 1;
this.valueShift = this.valueMin;
this.value = this.propertyProvider.getFloatProperty(binding) - this.valueShift;
this.valueScale = (this.handleXPosMax - this.handleXPosMin) / (this.valueMax - this.valueMin);
}
public VoxelPropertySlider(IVoxelPropertyProvider propertyProvider, String binding, String displayText,
String minText, String maxText, int xPos, int yPos) {
this(propertyProvider, binding, displayText, xPos, yPos);
this.minText = minText;
this.maxText = maxText;
}
public VoxelPropertySlider(IVoxelPropertyProvider propertyProvider, String binding, String displayText, int xPos,
int yPos) {
this(propertyProvider, binding, displayText, xPos, yPos, 100, 8, false);
}
@Override
public void draw(IExtendedGui host, int mouseX, int mouseY) {
if (Mouse.isButtonDown(0)) {
if (this.focused) {
this.moveHandle(mouseX);
}
} else {
this.focused = false;
}
this.handleXPos = (int) (this.handleXPosMin + (this.value * this.valueScale));
int mintextX = this.fontRenderer.getStringWidth(this.minText);
this.fontRenderer.drawStringWithShadow(this.displayText, this.xPosition, this.yPosition - 12, 0xFFFFFF);
this.fontRenderer.drawStringWithShadow(this.minText, this.xPosition - mintextX - 2, this.yPosition, 0xFFFFFF);
this.fontRenderer.drawStringWithShadow(this.maxText, this.xPosition + this.sliderWidth + 2, this.yPosition,
0xFFFFFF);
host.drawTessellatedModalBorderRect(LiteModVoxelCommon.GUIPARTS, 256, this.xPosition, this.yPosition,
this.xPosition + this.sliderWidth, this.yPosition + this.sliderHeight, 1, 114, 127, 119, 2);
if (this.indicatorShow)
this.drawIndicator(host);
this.drawHandle(host);
}
/**
* Draws an indicator for a value on the slider.
*/
private void drawIndicator(IExtendedGui host) {
int xPosZero = (int) (this.handleXPosMin + ((this.indicatorValue + Math.abs(this.valueMin)) * this.valueScale));
host.drawTessellatedModalBorderRect(LiteModVoxelCommon.GUIPARTS, 256, xPosZero - 1, this.yPosition + 1,
xPosZero + this.handleWidth + 1, this.yPosition + this.sliderHeight - 1, 1, 33, 15, 47, 3);
host.drawTessellatedModalBorderRect(LiteModVoxelCommon.GUIPARTS, 256, xPosZero, this.yPosition + 1,
xPosZero + this.handleWidth, this.yPosition + this.sliderHeight - 1, 0, 121, 128, 128, 2);
}
/**
* Draws the handle for the slider.
*/
private void drawHandle(IExtendedGui host) {
host.drawTessellatedModalBorderRect(LiteModVoxelCommon.GUIPARTS, 256, this.handleXPos - 1, this.yPosition - 2,
this.handleXPos + this.handleWidth + 1, this.yPosition + this.handleHeight - 2, 17, 33, 31, 47, 3);
host.drawTessellatedModalBorderRect(LiteModVoxelCommon.GUIPARTS, 256, this.handleXPos, this.yPosition - 2,
this.handleXPos + this.handleWidth, this.yPosition + this.handleHeight - 2, 0, 121, 128, 128, 3);
}
/**
* @param mouseX
* @param mouseY
* @param x1
* @param y1
* @param x2
* @param y2
*/
protected boolean mouseIn(int mouseX, int mouseY, int x1, int y1, int x2, int y2) {
return mouseX > x1 && mouseX < x2 && mouseY > y1 && mouseY < y2;
}
@SuppressWarnings("cast")
public void moveHandle(int mouseX) {
mouseX -= (this.handleWidth / 2);
if (mouseX < this.handleXPosMin || ((mouseX - this.handleXPosMin) / this.valueScale) < 0)
this.value = 0;
else if (mouseX > this.handleXPosMin + (this.handleXPosMax - this.handleXPosMin)
|| ((mouseX - this.handleXPosMin) / this.valueScale) > (this.valueMax - this.valueMin))
this.value = (this.valueMax - this.valueMin);
else if (this.snap)
this.value = (int) ((mouseX - this.handleXPosMin) / this.valueScale);
else
this.value = (float) ((mouseX - this.handleXPosMin) / this.valueScale);
this.propertyProvider.setProperty(this.propertyBinding, this.value + this.valueShift);
}
@Override
public void mouseClicked(int mouseX, int mouseY) {
this.focused = this.mouseIn(mouseX, mouseY, this.xPosition, this.yPosition, this.xPosition + this.sliderWidth,
this.yPosition + this.sliderHeight);
}
@Override
public void keyTyped(char keyChar, int keyCode) {}
}

View file

@ -1,188 +0,0 @@
package com.voxelmodpack.common.properties;
import net.minecraft.util.MathHelper;
import org.lwjgl.input.Mouse;
import com.voxelmodpack.common.LiteModVoxelCommon;
import com.voxelmodpack.common.gui.interfaces.IExtendedGui;
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProvider;
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProviderFloat;
/**
* @author xTiming
*/
public class VoxelPropertySliderOld extends VoxelProperty<IVoxelPropertyProviderFloat> {
float minValue = -1.0F;
float maxValue = 1.0F;
float value = 0F;
boolean overReset = false;
boolean overSlide = false;
boolean overBar = false;
boolean setBar = false;
boolean dragging = false;
int offset = 0;
String minText = "Min";
String maxText = "Max";
String labelText;
public VoxelPropertySliderOld(IVoxelPropertyProvider propertyProvider, String binding, String displayText,
String minText, String maxText, int xPos, int yPos, float min, float max) {
this(propertyProvider, binding, displayText, minText, maxText, xPos, yPos);
this.minValue = min;
this.maxValue = max;
}
public VoxelPropertySliderOld(IVoxelPropertyProvider propertyProvider, String binding, String displayText, int xPos,
int yPos, float min, float max) {
this(propertyProvider, binding, displayText, xPos, yPos);
}
public VoxelPropertySliderOld(IVoxelPropertyProvider propertyProvider, String binding, String displayText,
String minText, String maxText, int xPos, int yPos) {
this(propertyProvider, binding, displayText, xPos, yPos);
this.minText = minText;
this.maxText = maxText;
}
public VoxelPropertySliderOld(IVoxelPropertyProvider propertyProvider, String binding, String displayText, int xPos,
int yPos) {
super(propertyProvider, binding, displayText, xPos, yPos);
}
@Override
public void draw(IExtendedGui host, int mouseX, int mouseY) {
if (this.displayText != null) {
this.drawString(this.mc.fontRendererObj, this.displayText, this.xPosition + 18, this.yPosition, 0x99CCFF);
}
this.drawString(this.mc.fontRendererObj, this.minText, this.xPosition + 30, this.yPosition + 15, 0xFFFFFF);
if (this.maxText != null) {
this.drawString(this.mc.fontRendererObj, this.maxText, this.xPosition + 130, this.yPosition + 15, 0xFFFFFF);
} else {
float scale = (this.value + 1.0F) / 2.0F;
int displayValue = MathHelper
.ceiling_float_int((this.minValue + ((this.maxValue - this.minValue) * scale)) * 100F);
this.drawString(this.mc.fontRendererObj, displayValue + "%", this.xPosition + 130, this.yPosition + 15,
0xFFFFFF);
}
this.overReset = this.mouseOverReset(mouseX, mouseY);
int outset = this.overReset ? 1 : 0;
int v = this.overReset ? 16 : 0;
drawRect(this.xPosition + 160 - outset, this.yPosition + 11 - outset, this.xPosition + 212 + outset,
this.yPosition + 26 + outset, 0xFF000000);
host.drawTessellatedModalBorderRect(LiteModVoxelCommon.GUIPARTS, 256, this.xPosition + 159 - outset,
this.yPosition + 10 - outset, this.xPosition + 213 + outset, this.yPosition + 27 + outset, 0, v, 16,
16 + v, 4);
this.drawString(this.mc.fontRendererObj, "Default", this.xPosition + 169, this.yPosition + 15,
this.overReset ? 0xFFFFFF : 0x999999);
int sliderLeft = this.xPosition + 48;
int sliderRight = this.xPosition + 124;
int sliderXPos = sliderLeft + 32;
int sliderXPos2 = sliderLeft + 45;
int sliderYPos = this.yPosition + 12;
int sliderYPos2 = this.yPosition + 25;
int sliderMinX = sliderLeft - ((sliderXPos + sliderXPos2) / 2) + 5;
int sliderMaxX = sliderRight - ((sliderXPos + sliderXPos2) / 2) - 5;
this.drawHorizontalLine(sliderLeft, sliderRight, this.yPosition + 18, 0xFF999999);
this.drawVerticalLine(this.xPosition + 86, this.yPosition + 14, this.yPosition + 22, 0xFF999999);
this.drawVerticalLine(sliderLeft, this.yPosition + 14, this.yPosition + 22, 0xFF999999);
this.drawVerticalLine(sliderRight, this.yPosition + 14, this.yPosition + 22, 0xFF999999);
this.overSlide = this.mouseIn(mouseX, mouseY, sliderXPos, sliderYPos, sliderXPos2, sliderYPos2);
this.overBar = this.mouseIn(mouseX, mouseY, sliderLeft, sliderYPos, sliderRight, sliderYPos2)
&& !this.overSlide;
if (this.dragging) {
if (Mouse.isButtonDown(0)) {
this.offset = Math.min(Math.max(mouseX - (sliderXPos + sliderXPos2) / 2, sliderMinX), sliderMaxX);
this.value = ((float) this.offset / (float) sliderMaxX);
} else {
this.value = ((float) this.offset / (float) sliderMaxX);
this.propertyProvider.setProperty(this.propertyBinding, this.value);
this.dragging = false;
}
} else {
this.offset = (int) ((this.propertyProvider.getFloatProperty(this.propertyBinding)) * sliderMaxX);
this.value = ((float) this.offset / (float) sliderMaxX);
}
if (this.setBar) {
this.offset = mouseX - (sliderXPos + sliderXPos2) / 2;
this.value = ((float) this.offset / (float) sliderMaxX);
this.propertyProvider.setProperty(this.propertyBinding, this.value);
this.setBar = false;
this.dragging = true;
}
if (this.offset > sliderMaxX)
this.offset = sliderMaxX;
if (this.offset < sliderMinX)
this.offset = sliderMinX;
drawRect(sliderXPos2 - 1 + this.offset, sliderYPos2 - 1, sliderXPos + 1 + this.offset, sliderYPos + 1,
0xFF000000);
host.drawTessellatedModalBorderRect(LiteModVoxelCommon.GUIPARTS, 256, (sliderXPos + this.offset), sliderYPos,
(sliderXPos2 + this.offset), sliderYPos2, 0, (this.overSlide || this.dragging) ? 16 : 0, 16,
(this.overSlide || this.dragging) ? 32 : 16, 4);
}
/**
* @param mouseX
* @param mouseY
* @param x1
* @param y1
* @param x2
* @param y2
*/
protected boolean mouseIn(int mouseX, int mouseY, int x1, int y1, int x2, int y2) {
return mouseX > x1 + this.offset && mouseX < x2 + this.offset && mouseY > y1 && mouseY < y2;
}
/**
* @param mouseX
* @param mouseY
* @return
*/
protected boolean mouseOverReset(int mouseX, int mouseY) {
return mouseX > this.xPosition + 159 && mouseX < this.xPosition + 213 && mouseY > this.yPosition + 10
&& mouseY < this.yPosition + 27;
}
@Override
public void mouseClicked(int mouseX, int mouseY) {
if (this.overSlide) {
this.dragging = true;
this.playClickSound(this.mc.getSoundHandler());
return;
}
if (this.overBar) {
this.setBar = true;
this.playClickSound(this.mc.getSoundHandler());
return;
}
if (this.overReset) {
this.propertyProvider.setProperty(this.propertyBinding, 0.0F);
this.playClickSound(this.mc.getSoundHandler());
}
}
@Override
public void keyTyped(char keyChar, int keyCode) {}
}

View file

@ -1,104 +0,0 @@
package com.voxelmodpack.common.properties;
import com.voxelmodpack.common.LiteModVoxelCommon;
import com.voxelmodpack.common.gui.interfaces.IExtendedGui;
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProviderBoolean;
/**
* Adapted from xTiming's button code
*
* @author Adam Mummery-Smith
*/
public class VoxelPropertyToggleButton extends VoxelProperty<IVoxelPropertyProviderBoolean> {
private int buttonOffset = 60;
private int buttonWidth = 70;
private int buttonHeight = 16;
private String status;
/**
* @param propertyProvider
* @param binding
* @param displayText
* @param xPos
* @param yPos
*/
public VoxelPropertyToggleButton(IVoxelPropertyProviderBoolean propertyProvider, String binding, String displayText,
int xPos, int yPos) {
this(propertyProvider, binding, displayText, xPos, yPos, 60, 70, 16);
}
/**
* @param propertyProvider
* @param binding
* @param displayText
* @param xPos
* @param yPos
* @param buttonOffset
* @param buttonWidth
* @param buttonHeight
*/
public VoxelPropertyToggleButton(IVoxelPropertyProviderBoolean propertyProvider, String binding, String displayText,
int xPos, int yPos, int buttonOffset, int buttonWidth, int buttonHeight) {
super(propertyProvider, binding, displayText, xPos, yPos);
this.buttonOffset = buttonOffset;
this.buttonWidth = buttonWidth;
this.buttonHeight = buttonHeight;
this.status = this.propertyProvider.getOptionDisplayString(this.propertyBinding);
}
/*
* (non-Javadoc)
* @see
* com.voxelmodpack.common.properties.VoxelProperty#draw(com.voxelmodpack.
* common.gui.IExtendedGui, int, int)
*/
@Override
public void draw(IExtendedGui host, int mouseX, int mouseY) {
boolean overButton = this.mouseOver(mouseX, mouseY);
int outset = overButton ? 1 : 0;
int v = overButton ? 16 : 0;
int colour = overButton ? 0xFFFFFF : 0x999999;
this.drawString(this.fontRenderer, this.displayText, this.xPosition, this.yPosition + 4, 0xFFFFFF);
drawRect(this.xPosition + this.buttonOffset + this.buttonWidth - 1, this.yPosition + this.buttonHeight,
this.xPosition + this.buttonOffset + 1, this.yPosition, 0xFF000000);
host.drawTessellatedModalBorderRect(LiteModVoxelCommon.GUIPARTS, 256,
this.xPosition + this.buttonOffset - outset, this.yPosition - outset,
this.xPosition + this.buttonOffset + this.buttonWidth + outset,
this.yPosition + this.buttonHeight + outset, 0, v, 16, v + 16, 4);
this.drawString(this.fontRenderer, this.status, (this.xPosition + this.buttonOffset + (this.buttonWidth / 2))
- (this.fontRenderer.getStringWidth(this.status) / 2), this.yPosition + 4, colour);
}
/*
* (non-Javadoc)
* @see com.voxelmodpack.common.properties.VoxelProperty#mouseClicked(int,
* int)
*/
@Override
public void mouseClicked(int mouseX, int mouseY) {
if (this.mouseOver(mouseX, mouseY)) {
this.propertyProvider.toggleOption(this.propertyBinding);
this.status = this.propertyProvider.getOptionDisplayString(this.propertyBinding);
}
}
/**
* @param mouseX
* @param mouseY
* @return
*/
public boolean mouseOver(int mouseX, int mouseY) {
return mouseX > this.xPosition + this.buttonOffset
&& mouseX < this.xPosition + this.buttonOffset + this.buttonWidth && mouseY >= this.yPosition
&& mouseY <= this.yPosition + this.buttonHeight;
}
/*
* (non-Javadoc)
* @see com.voxelmodpack.common.properties.VoxelProperty#keyTyped(char, int)
*/
@Override
public void keyTyped(char keyChar, int keyCode) {}
}

View file

@ -1,301 +0,0 @@
package com.voxelmodpack.common.properties.gui;
import static com.mumfrey.liteloader.gl.GL.*;
import java.io.IOException;
import java.util.ArrayList;
import net.minecraft.client.Minecraft;
import org.lwjgl.input.Keyboard;
import com.mumfrey.liteloader.modconfig.ConfigPanel;
import com.mumfrey.liteloader.modconfig.ConfigPanelHost;
import com.voxelmodpack.common.LiteModVoxelCommon;
import com.voxelmodpack.common.gui.GuiScreenEx;
import com.voxelmodpack.common.properties.ModConfig;
import com.voxelmodpack.common.properties.VoxelProperty;
/**
* Base class for voxelmod gui config screens
*
* @author Adam Mummery-Smith
*/
public abstract class GuiVoxelBoxSettingsPanel extends GuiScreenEx implements ConfigPanel {
/**
* Mod config
*/
protected ModConfig config;
/**
* Property widgets to display
*/
protected ArrayList<VoxelProperty<?>> properties = new ArrayList<VoxelProperty<?>>();
/**
* Shared panel width, calculated from the width of the tabs
*/
protected static int PANEL_WIDTH = 330;
/**
* Panel left edge position
*/
protected static int PANEL_LEFT = 97;
/**
* Panel top edge position
*/
protected static int PANEL_TOP = 0;
/**
*
*/
protected static int PANEL_HEIGHT = 220;
/**
* Pixel spacing between tabs
*/
protected static int TAB_SPACING = 2;
protected boolean overCloseButton = false;
protected SettingsPanelManager panelManager = SettingsPanelManager.getInstance();
protected boolean isPanel = false;
protected int contentHeight = 240;
public ModConfig getConfig() {
return this.config;
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
this.setTexMapSize(256);
glColor4f(1.0F, 1.0F, 1.0F, 0.5F);
glEnableBlend();
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
int right = PANEL_LEFT + PANEL_WIDTH;
int bottom = PANEL_TOP + PANEL_HEIGHT;
this.zLevel = -50;
this.drawTabs(mouseX, mouseY, partialTicks, true);
this.drawPanel(right, bottom);
this.drawTabs(mouseX, mouseY, partialTicks, false);
this.zLevel = 0;
this.drawCloseButton(mouseX, mouseY, right - 4, PANEL_TOP + 20);
for (VoxelProperty<?> property : this.properties) {
if (property.isVisible()) {
property.draw(this, mouseX, mouseY);
}
}
}
/**
* @param right
* @param bottom
*/
protected void drawPanel(int right, int bottom) {
PANEL_HEIGHT = Math.max(220, this.height - PANEL_TOP - 2);
this.zLevel = -100;
glEnableDepthTest();
this.drawTessellatedModalBorderRect(LiteModVoxelCommon.GUIPARTS, 256, PANEL_LEFT, PANEL_TOP, right, bottom, 0,
16, 16, 32, 4);
this.zDrop();
this.drawDepthRect(PANEL_LEFT + 1, PANEL_TOP + 1, right - 1, bottom - 1, 0x80000000);
glDisableDepthTest();
}
/**
* @param mouseX
* @param mouseY
* @param partialTicks
*/
protected void drawTabs(int mouseX, int mouseY, float partialTicks, boolean mask) {
this.zDrop();
this.panelManager.renderTabs(this, mouseX, mouseY, partialTicks, PANEL_LEFT, PANEL_TOP, TAB_SPACING, mask);
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int button) throws IOException {
if (this.overCloseButton) // mouseIn(mouseX, mouseY, 315, 5, 330, 20))
{
this.onClosed();
this.mc.displayGuiScreen(null);
return;
}
if (!this.panelManager.mouseClicked(this, mouseX, mouseY, button, PANEL_LEFT, PANEL_TOP, TAB_SPACING)) {
super.mouseClicked(mouseX, mouseY, button);
for (VoxelProperty<?> property : this.properties) {
if (property.isVisible()) {
property.mouseClicked(mouseX, mouseY);
}
}
}
}
protected void onClosed() {
for (VoxelProperty<?> property : this.properties) {
property.onClosed();
}
}
@Override
protected void keyTyped(char keyChar, int keyCode) throws IOException {
super.keyTyped(keyChar, keyCode);
this.keyPressed(null, keyChar, keyCode);
}
@Override
public void updateScreen() {
super.updateScreen();
for (VoxelProperty<?> property : this.properties) {
property.updateCursorCounter();
}
}
/**
* @return
*/
public void zDrop() {
this.zLevel--;
}
protected boolean mouseIn(int mouseX, int mouseY, int x, int y, int x2, int y2) {
return (mouseX > x && mouseX < x2 && mouseY > y && mouseY < y2);
}
/**
* @param mouseX
* @param mouseY
* @param right
* @param top
*/
protected void drawCloseButton(int mouseX, int mouseY, int right, int top) {
this.overCloseButton = this.mouseIn(mouseX, mouseY, right - 15, top - 16, right, top - 1);
int v = this.overCloseButton ? 32 : 0;
this.drawDepthRect(right - 1, top - 2, right - 14, top - 15, 0x80000000);
this.drawTessellatedModalBorderRect(LiteModVoxelCommon.GUIPARTS, 256,
this.overCloseButton ? right - 16 : right - 15, this.overCloseButton ? top - 17 : top - 16,
this.overCloseButton ? right + 1 : right, this.overCloseButton ? top : top - 1, 0, v, 16, 16 + v, 4);
this.drawString(this.mc.fontRendererObj, "x", right - 10, top - 13, this.overCloseButton ? 0x55FFFF : 0xAAAAAA);
}
@Override
public int getContentHeight() {
return this.contentHeight;
}
@Override
public void onPanelShown(ConfigPanelHost host) {
this.mc = Minecraft.getMinecraft();
this.isPanel = true;
this.initGui();
}
@Override
public void onPanelResize(ConfigPanelHost host) {
this.initGui();
}
@Override
public void onPanelHidden() {}
@Override
public void onTick(ConfigPanelHost host) {
this.updateScreen();
}
@Override
public void drawPanel(ConfigPanelHost host, int mouseX, int mouseY, float partialTicks) {
glTranslatef(-PANEL_LEFT, 0.0F, 0.0F);
for (VoxelProperty<?> property : this.properties) {
if (property.isVisible()) {
property.draw(this, mouseX + PANEL_LEFT, mouseY);
}
}
}
@Override
public void mousePressed(ConfigPanelHost host, int mouseX, int mouseY, int mouseButton) {
try {
super.mouseClicked(mouseX + PANEL_LEFT, mouseY, mouseButton);
} catch (IOException ex) {}
for (VoxelProperty<?> property : this.properties) {
if (property.isVisible()) {
property.mouseClicked(mouseX + PANEL_LEFT, mouseY);
}
}
}
@Override
public void mouseReleased(ConfigPanelHost host, int mouseX, int mouseY, int mouseButton) {
super.mouseClickMove(mouseX + PANEL_LEFT, mouseY, mouseButton, 0L);
}
@Override
public void mouseMoved(ConfigPanelHost host, int mouseX, int mouseY) {
super.mouseClickMove(mouseX + PANEL_LEFT, mouseY, -1, 0L);
}
@Override
public void keyPressed(ConfigPanelHost host, char keyChar, int keyCode) {
if (keyCode == Keyboard.KEY_ESCAPE && host != null) {
host.close();
return;
}
if (keyCode == Keyboard.KEY_TAB) {
VoxelProperty<?> focused = null; // focused property
VoxelProperty<?> next = null; // next focusable property AFTER the focused property
VoxelProperty<?> before = null; // first focusable property BEFORE the focused property
// Search through properties to find focus chain
for (VoxelProperty<?> property : this.properties) {
if (property.isFocusable() && next == null)
next = property;
if (property.isFocused() && focused == null) {
focused = property;
before = next;
next = null;
}
}
// If didn't find a focusable property after focused in the chain,
// use the one nearest the start
if (next == null)
next = before;
// If we ARE focused and have a focusable property to switch to,
// then switch
if (focused != null && next != null && next != focused) {
focused.setFocused(false);
next.setFocused(true);
return;
}
}
for (VoxelProperty<?> property : this.properties) {
if (property.isVisible()) {
property.keyTyped(keyChar, keyCode);
}
}
}
}

View file

@ -1,317 +0,0 @@
package com.voxelmodpack.common.properties.gui;
import static com.mumfrey.liteloader.gl.GL.*;
import java.io.File;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
import java.util.TreeSet;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import org.lwjgl.input.Keyboard;
import com.mumfrey.liteloader.Tickable;
import com.mumfrey.liteloader.core.LiteLoader;
/**
* Manager object that keeps track of the settings panels and manages the tab
* display and switching between panels
*
* @author Adam Mummery-Smith
*/
public class SettingsPanelManager implements Tickable {
// Consts
private static int TAB_WIDTH = 72;
private static final int TAB_HEIGHT = 16;
/**
* Singleton
*/
private static SettingsPanelManager instance;
/**
* Minecraft game instance
*/
private Minecraft mc;
/**
* Settings panels
*/
private Map<String, Class<? extends GuiVoxelBoxSettingsPanel>> panels = new TreeMap<String, Class<? extends GuiVoxelBoxSettingsPanel>>();
/**
* Sorted tabs
*/
private TreeSet<SettingsPanelMenuTab> tabs = new TreeSet<SettingsPanelMenuTab>();
/**
* Scroll bar to display when there are too many tabs
*/
private SettingsPanelScrollBar scrollbar = new SettingsPanelScrollBar(6, 4, 10, 220, 0);
/**
* First panel which was added, this becomes the default panel
*/
private Class<? extends GuiVoxelBoxSettingsPanel> firstPanel = null;
/**
* Key binding used to display the GUI
*/
public static KeyBinding guiKeyBinding = new KeyBinding("VoxelMods Config", Keyboard.KEY_NONE, "VoxelLib");
/**
* Get the singleton instance of the tab manager
*
* @return
*/
public static SettingsPanelManager getInstance() {
if (instance == null) {
instance = new SettingsPanelManager();
LiteLoader.getInterfaceManager().registerListener(instance);
LiteLoader.getInput().registerKeyBinding(guiKeyBinding);
}
return instance;
}
/**
* Private ctor
*/
private SettingsPanelManager() {
this.mc = Minecraft.getMinecraft();
}
/**
* Add a settings panel to the tab list
*
* @param panelName
* @param panel
*/
public static void addSettingsPanel(String panelName, Class<? extends GuiVoxelBoxSettingsPanel> panel) {
SettingsPanelManager.getInstance().addPanel(panelName, panel);
}
/**
* Remove a settings panel from the tab list
*
* @param panelName
*/
public static void removeSettingsPanel(String panelName) {
SettingsPanelManager.getInstance().removePanel(panelName);
}
public static void displaySettings() {
SettingsPanelManager.getInstance().displaySettings(Minecraft.getMinecraft());
}
public static boolean hasOptions() {
return SettingsPanelManager.getInstance().panels.size() > 0;
}
/**
* Add a settings panel to the panel pool
*
* @param panelName
* @param panel
*/
public void addPanel(String panelName, Class<? extends GuiVoxelBoxSettingsPanel> panel) {
// Add the panel to the pool
if (panel != null) {
this.panels.put(panelName, panel);
this.tabs.add(new SettingsPanelMenuTab(panelName, GuiVoxelBoxSettingsPanel.PANEL_LEFT, 0));
}
this.updateTabs();
}
public void addPanel(String panelName, Class<? extends GuiVoxelBoxSettingsPanel> panel, int priority) {
// Add the panel to the pool
if (panel != null) {
this.panels.put(panelName, panel);
this.tabs.add(new SettingsPanelMenuTab(panelName, 62, priority));
}
this.updateTabs();
}
/**
* Remove a settings panel from the tabs set
*
* @param panelName
*/
public void removePanel(String panelName) {
this.panels.remove(panelName);
this.updateTabs();
}
/**
*
*/
protected void updateTabs() {
Iterator<String> iter = this.panels.keySet().iterator();
if (iter.hasNext())
this.firstPanel = this.panels.get(iter.next());
int largest = 0;
for (SettingsPanelMenuTab tab : this.tabs)
if (this.mc.fontRendererObj.getStringWidth(tab.getLabel()) > largest)
largest = this.mc.fontRendererObj.getStringWidth(tab.getLabel());
if (SettingsPanelManager.TAB_HEIGHT * this.tabs.size() < GuiVoxelBoxSettingsPanel.PANEL_HEIGHT)
SettingsPanelManager.TAB_WIDTH = largest + 6;
else
SettingsPanelManager.TAB_WIDTH = largest + 18 + this.scrollbar.getWidth();
for (SettingsPanelMenuTab tab : this.tabs)
tab.setXPos(SettingsPanelManager.TAB_WIDTH);
GuiVoxelBoxSettingsPanel.PANEL_LEFT = SettingsPanelManager.TAB_WIDTH;
}
/*
* (non-Javadoc)
* @see com.mumfrey.liteloader.Tickable#onTick(net.minecraft.src.Minecraft,
* float, boolean, boolean)
*/
@Override
public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) {
// Handle GUI key being pressed
if (minecraft.currentScreen == null && guiKeyBinding.isKeyDown() && this.firstPanel != null) {
this.displaySettings(minecraft);
}
}
/**
* @param minecraft
*/
public void displaySettings(Minecraft minecraft) {
try {
// If it was pressed display the default panel
GuiVoxelBoxSettingsPanel panel = this.firstPanel.newInstance();
minecraft.displayGuiScreen(panel);
} catch (InstantiationException ex) {} catch (IllegalAccessException ex) {}
}
/**
* Callback from the panel, checks whether a tab was clicked, returns true
* if a tab click was handled
*
* @param panel Source panel
* @param mouseX
* @param mouseY
* @param button
* @param xPos tab x pos
* @param yPos tab y pos
* @param spacing tab spacing
* @return
*/
public boolean mouseClicked(GuiVoxelBoxSettingsPanel panel, int mouseX, int mouseY, int button, int xPos, int yPos,
int spacing) {
if (button == 0) {
int newWidth = SettingsPanelManager.TAB_WIDTH;
if (SettingsPanelManager.TAB_HEIGHT * this.tabs.size() > GuiVoxelBoxSettingsPanel.PANEL_HEIGHT)
newWidth -= 18 + this.scrollbar.getWidth();
for (SettingsPanelMenuTab tab : this.tabs)
if (tab.isMouseOver(newWidth, mouseX, mouseY)) {
try {
GuiVoxelBoxSettingsPanel newPanel = this.panels.get(tab.getLabel()).newInstance();
this.mc.displayGuiScreen(newPanel);
return true;
} catch (InstantiationException e) {} catch (IllegalAccessException e) {}
}
boolean intersects = this.scrollbar.mouseIn(mouseX, mouseY);
if (intersects) {
this.scrollbar.mouseHeld = true;
return true;
}
this.scrollbar.mouseHeld = false;
return false;
}
return false;
}
/**
* Callback from the panel, renders the tabs
*
* @param panel
* @param mouseX
* @param mouseY
* @param partialTicks
* @param xPos
* @param tabYPosition
* @param spacing
*/
public void renderTabs(GuiVoxelBoxSettingsPanel panel, int mouseX, int mouseY, float partialTicks, int xPos,
int yPos, int spacing, boolean mask) {
int tabYPosition = yPos;
glEnableDepthTest();
this.updateTabs();
int newWidth = SettingsPanelManager.TAB_WIDTH;
int newY = 0;
if (TAB_HEIGHT * this.tabs.size() > GuiVoxelBoxSettingsPanel.PANEL_HEIGHT) {
newWidth -= 12 + this.scrollbar.getWidth();
newY = (int) (TAB_HEIGHT * this.tabs.size() * this.scrollbar.getValue());
}
tabYPosition += 8;
tabYPosition -= newY;
for (SettingsPanelMenuTab tab : this.tabs) {
tab.setActive(panel.getClass().equals(this.panels.get(tab.getLabel())));
tab.renderTab(panel, newWidth, mouseX, mouseY, tabYPosition, mask);
tabYPosition += TAB_HEIGHT;
}
if (TAB_HEIGHT * this.tabs.size() > GuiVoxelBoxSettingsPanel.PANEL_HEIGHT) {
this.scrollbar.setHeight(GuiVoxelBoxSettingsPanel.PANEL_HEIGHT - 8);
this.scrollbar.render(panel, mouseY);
}
glDisableDepthTest();
}
/*
* (non-Javadoc)
* @see com.mumfrey.liteloader.LiteMod#init()
*/
@Override
public void init(File f) {}
/*
* (non-Javadoc)
* @see com.mumfrey.liteloader.LiteMod#getName()
*/
@Override
public String getName() {
return null;
}
/*
* (non-Javadoc)
* @see com.mumfrey.liteloader.LiteMod#getVersion()
*/
@Override
public String getVersion() {
return null;
}
@Override
public void upgradeSettings(String version, File configPath, File oldConfigPath) {}
}

View file

@ -1,94 +0,0 @@
package com.voxelmodpack.common.properties.gui;
import net.minecraft.client.Minecraft;
import com.voxelmodpack.common.LiteModVoxelCommon;
/**
* @author anangrybeaver
*/
public class SettingsPanelMenuTab implements Comparable<SettingsPanelMenuTab> {
private Minecraft mc;
private final int priority;
private final int width;
private int xPos;
private int yPos;
private final String label;
private boolean active = false;
public SettingsPanelMenuTab(String label, int xPosition, int priority) {
this.mc = Minecraft.getMinecraft();
this.label = label;
this.priority = priority;
this.width = this.mc.fontRendererObj.getStringWidth(label);
this.xPos = xPosition - this.width - 2;
}
public boolean isActive() {
return this.active;
}
public void setActive(boolean active) {
this.active = active;
}
public void setXPos(int xPos) {
this.xPos = xPos - this.width - 3;
}
public boolean isMouseOver(int tabMenuWidth, int mouseX, int mouseY) {
int newX = GuiVoxelBoxSettingsPanel.PANEL_LEFT - tabMenuWidth;
return mouseX > newX && mouseX < newX + tabMenuWidth && mouseY > this.yPos - 4 && mouseY < this.yPos + 12;
}
public String getLabel() {
return this.label;
}
public void renderTab(GuiVoxelBoxSettingsPanel panel, int tabMenuWidth, int mouseX, int mouseY, int y,
boolean mask) {
this.yPos = y;
int tabX = GuiVoxelBoxSettingsPanel.PANEL_LEFT - tabMenuWidth;
int tabY = this.yPos - 4;
int tabRight = GuiVoxelBoxSettingsPanel.PANEL_LEFT + 4;
int tabBottom = this.yPos + 12;
if (mask) {
// Draw the tab mask over the window border so it looks like this
// tab "flows" into the window
if (this.active) {
this.renderTabMask(panel, tabY, tabRight, tabBottom);
}
} else {
// Draw the actual tab
boolean mouseOver = this.isMouseOver(tabMenuWidth, mouseX, mouseY);
int v = mouseOver ? 32 : (this.active ? 16 : 0);
panel.drawTessellatedModalBorderRect(LiteModVoxelCommon.GUIPARTS, 256, tabX, tabY, tabRight, tabBottom, 0,
0 + v, 16, 16 + v, 4);
panel.zDrop();
panel.drawDepthRect(tabX + 1, tabY + 1, tabRight - 1, tabBottom - 1, 0x80000000);
this.mc.fontRendererObj.drawString(this.label, this.xPos, y,
this.isMouseOver(tabMenuWidth, mouseX, mouseY) ? 0x55FFFF : (this.active ? 0xFFFF55 : 0xAAAAAA));
}
}
private void renderTabMask(GuiVoxelBoxSettingsPanel panel, int tabY, int tabRight, int tabBottom) {
panel.drawDepthRect(tabRight - 4, tabY + 1, tabRight - 3, tabBottom - 1, 0x80000000);
panel.drawDepthRect(tabRight - 3, tabY, tabRight - 2, tabBottom, 0x80000000);
}
@Override
public int compareTo(SettingsPanelMenuTab other) {
if (other == null)
return 0;
return (this.priority == other.priority) ? -1 : this.priority - other.priority;
}
}

View file

@ -1,89 +0,0 @@
package com.voxelmodpack.common.properties.gui;
import static com.mumfrey.liteloader.gl.GL.*;
import org.lwjgl.input.Mouse;
import com.voxelmodpack.common.LiteModVoxelCommon;
/**
* @author anangrybeaver
*/
public class SettingsPanelScrollBar {
public boolean mouseHeld = false;
private final int xPos, yPos;
private final int width;
private int height;
private int handleY;
public SettingsPanelScrollBar(int x, int y, int width, int height, int startingValue) {
this.xPos = x;
this.yPos = y;
this.width = width;
this.height = height;
this.moveHandle(startingValue);
}
@SuppressWarnings("cast")
public double getValue() {
return ((double) this.handleY - (double) this.yPos - 3) / (double) this.height;
}
public void setHeight(int height) {
this.height = height;
}
public int getWidth() {
return this.width;
}
public void moveHandle(int mouseY) {
this.handleY = mouseY - this.width / 2;
if (this.handleY < this.yPos + 3)
this.handleY = this.yPos + 3;
if (this.handleY > this.yPos + this.height - this.width - 3)
this.handleY = this.yPos + this.height - this.width - 3;
}
public boolean mouseIn(int mouseX, int mouseY) {
return mouseX > this.xPos && mouseX < this.xPos + this.width && mouseY > this.yPos
&& mouseY < this.yPos + this.height;
}
private void renderHandle(GuiVoxelBoxSettingsPanel panel) {
panel.drawTessellatedModalBorderRect(LiteModVoxelCommon.GUIPARTS, 256, this.xPos - 2, this.handleY - 1,
this.xPos + this.width + 2, this.handleY + this.width + 1, 17, 33, 31, 47, 3);
panel.drawTessellatedModalBorderRect(LiteModVoxelCommon.GUIPARTS, 256, this.xPos - 2, this.handleY,
this.xPos + this.width + 2, this.handleY + this.width, 0, 121, 128, 128, 3);
}
private void renderBar(GuiVoxelBoxSettingsPanel panel) {
glEnableDepthTest();
panel.drawTessellatedModalBorderRect(LiteModVoxelCommon.GUIPARTS, 256, this.xPos, this.yPos,
this.xPos + this.width, this.yPos + this.height, 0, 16, 16, 32, 4);
panel.zDrop();
panel.drawDepthRect(this.xPos + 1, this.yPos + 1, this.xPos + this.width - 1, this.yPos + this.height - 1,
0x80000000);
glDisableDepthTest();
}
public void render(GuiVoxelBoxSettingsPanel panel, int mouseY) {
if (Mouse.isButtonDown(0)) {
if (this.mouseHeld)
this.moveHandle(mouseY);
} else
this.mouseHeld = false;
this.renderBar(panel);
this.renderHandle(panel);
}
}

View file

@ -1,39 +0,0 @@
package com.voxelmodpack.common.properties.interfaces;
/**
* Base interface for property providers
*
* @author Adam Mummery-Smith
*/
public interface IVoxelPropertyProvider {
/**
* Get the value of a property as a string
*
* @param propertyName
* @return
*/
public abstract String getStringProperty(String propertyName);
/**
* Get the name of this property for display
*
* @param propertyName
* @return
*/
public abstract String getOptionDisplayString(String propertyName);
/**
* Toggle the value of this option
*
* @param propertyName
*/
public abstract void toggleOption(String propertyName);
/**
* Get the default value of the property as a string
*
* @param propertyName
* @return
*/
public abstract String getDefaultPropertyValue(String propertyName);
}

View file

@ -1,25 +0,0 @@
package com.voxelmodpack.common.properties.interfaces;
/**
* Interface for property providers that can provide boolean values
*
* @author Adam Mummery-Smith
*/
public interface IVoxelPropertyProviderBoolean extends IVoxelPropertyProvider {
/**
* Set the specified property to the boolean value specified
*
* @param propertyName
* @param value
*/
public abstract void setProperty(String propertyName, boolean value);
/**
* Attempts to parse the value of the property specified by calling
* Boolean.parseBoolean on the underlying string value
*
* @param propertyName
* @return
*/
public abstract boolean getBoolProperty(String propertyName);
}

View file

@ -1,25 +0,0 @@
package com.voxelmodpack.common.properties.interfaces;
/**
* Interface for property providers that can provide storage for float values
*
* @author Adam Mummery-Smith
*/
public interface IVoxelPropertyProviderFloat extends IVoxelPropertyProvider {
/**
* Set the specified property to the value specified
*
* @param propertyName
* @param value
*/
public abstract void setProperty(String propertyName, float value);
/**
* Attempts to retrieve the specified value as a float by calling
* Float.parseFloat on the underlying string value
*
* @param propertyName
* @return
*/
public abstract float getFloatProperty(String propertyName);
}

View file

@ -1,25 +0,0 @@
package com.voxelmodpack.common.properties.interfaces;
/**
* Interface for property providers that can provide storage for integer values
*
* @author Adam Mummery-Smith
*/
public interface IVoxelPropertyProviderInteger extends IVoxelPropertyProvider {
/**
* Set the specified property to the integer value specified
*
* @param propertyName
* @param value
*/
public abstract void setProperty(String propertyName, int value);
/**
* Attempts to return the specified property as an integer by calling
* Integer.parseInt on the underlying string value
*
* @param propertyName
* @return
*/
public abstract int getIntProperty(String propertyName);
}

View file

@ -1,59 +0,0 @@
package com.voxelmodpack.common.runtime;
import com.mumfrey.liteloader.core.runtime.Obf;
/**
* Central list of obfuscation mappings used throughout macros, coalesced here
* instead of being spread throughout the different reflection mechanisms
*
* @author Adam Mummery-Smith TODO Obfuscation - updated 1.8
*/
public class ObfMap extends Obf {
public static final ObfMap currentLocale = new ObfMap("field_135054_a", "a", "i18nLocale");
public static final ObfMap downloadedImage = new ObfMap("field_110560_d", "l", "bufferedImage");
public static final ObfMap renderZoom = new ObfMap("field_78503_V", "X", "cameraZoom");
public static final ObfMap renderOfsetX = new ObfMap("field_78502_W", "Y", "cameraYaw");
public static final ObfMap renderOfsetY = new ObfMap("field_78509_X", "Z", "cameraPitch");
public static final ObfMap guiScreenSelectedButton = new ObfMap("field_146290_a", "h", "selectedButton");
public static final ObfMap worldType = new ObfMap("field_76098_b", "c", "terrainType");
public static final ObfMap soundSystemThread = new ObfMap("field_148620_e", "e", "sndSystem");
public static final ObfMap lastClicked = new ObfMap("field_148167_s", "p", "lastClicked");
public static final ObfMap imageUrl = new ObfMap("field_110562_b", "j", "imageUrl");
public static final ObfMap imageThread = new ObfMap("field_110561_e", "m", "imageThread");
public static final ObfMap imageBuffer = new ObfMap("field_110563_c", "k", "imageBuffer");
public static final ObfMap imageFile = new ObfMap("field_152434_e", "i");
public static final ObfMap resourceToTextureMap = new ObfMap("field_110585_a", "b", "mapTextureObjects");
public static final ObfMap optionsBackground = new ObfMap("field_110325_k", "b", "optionsBackground");
public static final ObfMap rainingStrength = new ObfMap("field_73004_o", "p", "rainingStrength");
public static final ObfMap thunderingStrength = new ObfMap("field_73017_q", "r", "thunderingStrength");
public static final ObfMap internetServerList = new ObfMap("field_146804_i", "i", "savedServerList");
public static final ObfMap serverSelectionList = new ObfMap("field_146803_h", "h", "serverListSelector");
public static final ObfMap guiResourcePacksParentScreen = new ObfMap("field_146965_f", "f");
public static final ObfMap abstractResourcePackFile = new ObfMap("field_110597_b", "a", "resourcePackFile");
public static final ObfMap mcFramebuffer = new ObfMap("field_147124_at", "aB", "framebufferMc");
public static final ObfMap eventSounds = new ObfMap("field_148736_a", "a", "soundPool");
public static final ObfMap getSlotAtPosition = new ObfMap("func_146975_c", "c", "getSlotAtPosition");
public static final ObfMap handleMouseClick = new ObfMap("func_146984_a", "a", "handleMouseClick");
public static final ObfMap selectTab = new ObfMap("func_147050_b", "b", "setCurrentCreativeTab");
public static final ObfMap scrollTo = new ObfMap("func_148329_a", "a", "scrollTo");
public static final ObfMap renderSkyBox = new ObfMap("func_73971_c", "c", "renderSkybox");
public static final ObfMap guiScreenMouseClicked = new ObfMap("func_73864_a", "a", "mouseClicked");
public static final ObfMap guiScreenMouseMovedOrUp = new ObfMap("func_146286_b", "b", "mouseReleased");
public static final ObfMap guiScreenKeyTyped = new ObfMap("func_73869_a", "a", "keyTyped");
public static final ObfMap createPlayer = new ObfMap("func_178892_a", "a");
public static final ObfMap ContainerCreative = new ObfMap("net.minecraft.client.gui.inventory.GuiContainerCreative$ContainerCreative", "bza");
public static final ObfMap SlotCreativeInventory = new ObfMap("net.minecraft.client.gui.inventory.GuiContainerCreative$CreativeSlot", "bzb");
public static final ObfMap PlayerControllerMP = new ObfMap("net.minecraft.client.multiplayer.PlayerControllerMP", "cem");
public static final ObfMap StatFileWriter = new ObfMap("net.minecraft.stats.StatFileWriter", "tz");
public static final ObfMap World = new ObfMap("net.minecraft.world.World", "aqu");
private ObfMap(String seargeName, String obfuscatedName, String mcpName) {
super(seargeName, obfuscatedName, mcpName);
}
private ObfMap(String seargeName, String obfuscatedName) {
super(seargeName, obfuscatedName, seargeName);
}
}

View file

@ -1,47 +0,0 @@
package com.voxelmodpack.common.runtime;
import com.mumfrey.liteloader.core.runtime.Obf;
import com.mumfrey.liteloader.util.ObfuscationUtilities;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
/**
* Wrapper for obf/mcp reflection-accessed private (or default) classes, added
* to centralise the locations I have to update the obfuscated names and also
* make referencing the hidden classes more straightforward
*
* @author Adam Mummery-Smith
* @param <C> Parent class type
*/
public class PrivateClasses<C> {
/**
* Class to which this field belongs
*/
public final Class<? extends C> Class;
/**
* Name used to access the field, determined at init
*/
private final String className;
@SuppressWarnings("unchecked")
private PrivateClasses(Obf mapping) {
this.className = ObfuscationUtilities.getObfuscatedFieldName(mapping);
Class<? extends C> reflectedClass = null;
try {
reflectedClass = (Class<? extends C>) java.lang.Class.forName(this.className);
} catch (Exception ex) {
ex.printStackTrace();
}
this.Class = reflectedClass;
}
public static final PrivateClasses<Slot> SlotCreativeInventory = new PrivateClasses<Slot>(
ObfMap.SlotCreativeInventory);
public static final PrivateClasses<Container> ContainerCreative = new PrivateClasses<Container>(
ObfMap.ContainerCreative);
}

View file

@ -1,163 +0,0 @@
package com.voxelmodpack.common.runtime;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.List;
import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.ISoundEventAccessor;
import net.minecraft.client.audio.SoundEventAccessorComposite;
import net.minecraft.client.audio.SoundManager;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiMultiplayer;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiScreenResourcePacks;
import net.minecraft.client.gui.GuiSlot;
import net.minecraft.client.gui.ServerSelectionList;
import net.minecraft.client.multiplayer.ServerList;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.renderer.IImageBuffer;
import net.minecraft.client.renderer.ThreadDownloadImageData;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.AbstractResourcePack;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.resources.Locale;
import net.minecraft.client.shader.Framebuffer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraft.world.WorldType;
import net.minecraft.world.storage.WorldInfo;
import paulscode.sound.SoundSystem;
import com.mumfrey.liteloader.core.runtime.Obf;
import com.mumfrey.liteloader.util.ObfuscationUtilities;
/**
* Wrapper for obf/mcp reflection-accessed private fields, mainly added to
* centralise the locations I have to update the obfuscated field names
*
* @author Adam Mummery-Smith
* @param
* <P>
* Parent class type, the type of the class that owns the field
* @param <T> Field type, the type of the field value
*/
public class PrivateFields<P, T> {
/**
* Class to which this field belongs
*/
public final Class<P> parentClass;
/**
* Name used to access the field, determined at init
*/
private final String fieldName;
private boolean errorReported;
/**
* Creates a new private field entry
*
* @param owner
* @param mcpName
* @param name
*/
private PrivateFields(Class<P> owner, Obf mapping) {
this.parentClass = owner;
this.fieldName = ObfuscationUtilities.getObfuscatedFieldName(mapping);
}
/**
* Get the current value of this field on the instance class supplied
*
* @param instance Class to get the value of
* @return field value or null if errors occur
*/
@SuppressWarnings("unchecked")
public T get(P instance) {
try {
return (T) Reflection.getPrivateValue(this.parentClass, instance, this.fieldName);
} catch (Exception ex) {
if (!this.errorReported) {
this.errorReported = true;
ex.printStackTrace();
}
return null;
}
}
/**
* Set the value of this field on the instance class supplied
*
* @param instance Object to set the value of the field on
* @param value value to set
* @return value
*/
public T set(P instance, T value) {
try {
Reflection.setPrivateValue(this.parentClass, instance, this.fieldName, value);
} catch (Exception ex) {
if (!this.errorReported) {
this.errorReported = true;
ex.printStackTrace();
}
}
return value;
}
/**
* Static private fields
*
* @param
* <P>
* Parent class type, the type of the class that owns the field
* @param <T> Field type, the type of the field value
*/
public static final class StaticFields<P, T> extends PrivateFields<P, T> {
@SuppressWarnings("synthetic-access")
public StaticFields(Class<P> owner, ObfMap mapping) {
super(owner, mapping);
}
public T get() {
return this.get(null);
}
public void set(T value) {
this.set(null, value);
}
public static final StaticFields<I18n, Locale> locale = new StaticFields<I18n, Locale>(I18n.class, ObfMap.currentLocale);
public static final StaticFields<Gui, ResourceLocation> optionsBackground = new StaticFields<Gui, ResourceLocation>(Gui.class, ObfMap.optionsBackground);
}
// If anyone screws up the formatting of this table again I will have them
// fed to a shark
public static final PrivateFields<GuiScreen, GuiButton> guiScreenSelectedButton = new PrivateFields<GuiScreen, GuiButton>(GuiScreen.class, ObfMap.guiScreenSelectedButton);
public static final PrivateFields<WorldInfo, WorldType> worldType = new PrivateFields<WorldInfo, WorldType>(WorldInfo.class, ObfMap.worldType);
public static final PrivateFields<SoundManager, SoundSystem> soundSystem = new PrivateFields<SoundManager, SoundSystem>(SoundManager.class, ObfMap.soundSystemThread);
public static final PrivateFields<GuiSlot, Long> lastClicked = new PrivateFields<GuiSlot, Long>(GuiSlot.class, ObfMap.lastClicked);
public static final PrivateFields<EntityRenderer, Double> renderZoom = new PrivateFields<EntityRenderer, Double>(EntityRenderer.class, ObfMap.renderZoom);
public static final PrivateFields<EntityRenderer, Double> renderOfsetX = new PrivateFields<EntityRenderer, Double>(EntityRenderer.class, ObfMap.renderOfsetX);
public static final PrivateFields<EntityRenderer, Double> renderOfsetY = new PrivateFields<EntityRenderer, Double>(EntityRenderer.class, ObfMap.renderOfsetY);
public static final PrivateFields<World, Float> rainingStrength = new PrivateFields<World, Float>(World.class, ObfMap.rainingStrength);
public static final PrivateFields<World, Float> thunderingStrength = new PrivateFields<World, Float>(World.class, ObfMap.thunderingStrength);
public static final PrivateFields<ThreadDownloadImageData, BufferedImage> downloadedImage = new PrivateFields<ThreadDownloadImageData, BufferedImage>(ThreadDownloadImageData.class, ObfMap.downloadedImage);
public static final PrivateFields<GuiMultiplayer, ServerList> internetServerList = new PrivateFields<GuiMultiplayer, ServerList>(GuiMultiplayer.class, ObfMap.internetServerList);
public static final PrivateFields<GuiMultiplayer, ServerSelectionList> serverSelectionList = new PrivateFields<GuiMultiplayer, ServerSelectionList>(GuiMultiplayer.class, ObfMap.serverSelectionList);
public static final PrivateFields<GuiScreenResourcePacks, GuiScreen> guiResourcePacksParentScreen = new PrivateFields<GuiScreenResourcePacks, GuiScreen>(GuiScreenResourcePacks.class, ObfMap.guiResourcePacksParentScreen);
public static final PrivateFields<AbstractResourcePack, File> abstractResourcePackFile = new PrivateFields<AbstractResourcePack, File>(AbstractResourcePack.class, ObfMap.abstractResourcePackFile);
public static final PrivateFields<Minecraft, Framebuffer> mcFramebuffer = new PrivateFields<Minecraft, Framebuffer>(Minecraft.class, ObfMap.mcFramebuffer);
public static final PrivateFields<ThreadDownloadImageData, String> imageUrl = new PrivateFields<ThreadDownloadImageData, String>(ThreadDownloadImageData.class, ObfMap.imageUrl);
public static final PrivateFields<ThreadDownloadImageData, Thread> imageThread = new PrivateFields<ThreadDownloadImageData, Thread>(ThreadDownloadImageData.class, ObfMap.imageThread);
public static final PrivateFields<ThreadDownloadImageData, IImageBuffer> imageBuffer = new PrivateFields<ThreadDownloadImageData, IImageBuffer>(ThreadDownloadImageData.class, ObfMap.imageBuffer);
public static final PrivateFields<ThreadDownloadImageData, File> imageFile = new PrivateFields<ThreadDownloadImageData, File>(ThreadDownloadImageData.class, ObfMap.imageFile);
public static final PrivateFields<SoundEventAccessorComposite, List<ISoundEventAccessor>> eventSounds = new PrivateFields<SoundEventAccessorComposite, List<ISoundEventAccessor>>(SoundEventAccessorComposite.class, ObfMap.eventSounds);
public static final PrivateFields<TextureManager, Map<ResourceLocation, ? extends ITextureObject>> resourceToTextureMap = new PrivateFields<TextureManager, Map<ResourceLocation, ? extends ITextureObject>>(
TextureManager.class, ObfMap.resourceToTextureMap);
}

View file

@ -1,136 +0,0 @@
package com.voxelmodpack.common.runtime;
import java.lang.reflect.Method;
import net.minecraft.client.gui.GuiMainMenu;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiContainerCreative;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import com.mumfrey.liteloader.core.runtime.Obf;
import com.mumfrey.liteloader.util.ObfuscationUtilities;
/**
* Wrapper for obf/mcp reflection-accessed private methods, added to centralise
* the locations I have to update the obfuscated method names
*
* @author Adam Mummery-Smith
* @param
* <P>
* Parent class type
* @param <R> Method return type
*/
public class PrivateMethods<P, R> {
public static class Void {}
/**
* Class to which this field belongs
*/
public final Class<?> parentClass;
/**
* Name used to access the field, determined at init
*/
private final String methodName;
/**
* Method
*/
private final Method method;
/**
* Creates a new private field entry
*
* @param owner
* @param mcpName
* @param name
*/
private PrivateMethods(Class<?> owner, Obf mapping, Class<?>... parameterTypes) {
this.parentClass = owner;
this.methodName = ObfuscationUtilities.getObfuscatedFieldName(mapping);
Method method = null;
try {
method = this.parentClass.getDeclaredMethod(this.methodName, parameterTypes);
method.setAccessible(true);
} catch (SecurityException ex) {
ex.printStackTrace();
} catch (NoSuchMethodException ex) {
ex.printStackTrace();
}
this.method = method;
}
/**
* Invoke the method and return a value
*
* @param instance
* @param args
* @return
*/
@SuppressWarnings("unchecked")
public R invoke(P instance, Object... args) {
try {
return (R) this.method.invoke(instance, args);
} catch (Exception ex) {
return null;
}
}
/**
* Invoke a static method that returns a value
*
* @param args
* @return
*/
@SuppressWarnings("unchecked")
public R invokeStatic(Object... args) {
try {
return (R) this.method.invoke(null, args);
} catch (Exception ex) {
return null;
}
}
/**
* Invoke a method that returns void
*
* @param instance
* @param args
*/
public void invokeVoid(P instance, Object... args) {
try {
this.method.invoke(instance, args);
} catch (Exception ex) {}
}
/**
* Invoke a static method that returns void
*
* @param args
*/
public void invokeStaticVoid(Object... args) {
try {
this.method.invoke(null, args);
} catch (Exception ex) {}
}
// Methods on public classes
public static final PrivateMethods<GuiContainer, Slot> containerGetSlotAtPosition = new PrivateMethods<GuiContainer, Slot>(GuiContainer.class, ObfMap.getSlotAtPosition, int.class, int.class);
public static final PrivateMethods<GuiContainer, Void> containerHandleMouseClick = new PrivateMethods<GuiContainer, Void>(GuiContainer.class, ObfMap.handleMouseClick, Slot.class, int.class, int.class, int.class);
public static final PrivateMethods<GuiContainerCreative, Void> selectTab = new PrivateMethods<GuiContainerCreative, Void>(GuiContainerCreative.class, ObfMap.selectTab, CreativeTabs.class);
public static final PrivateMethods<GuiMainMenu, Void> mainMenuRenderSkyBox = new PrivateMethods<GuiMainMenu, PrivateMethods.Void>(GuiMainMenu.class, ObfMap.renderSkyBox, int.class, int.class, float.class);
public static final PrivateMethods<GuiScreen, Void> guiScreenMouseClicked = new PrivateMethods<GuiScreen, Void>(GuiScreen.class, ObfMap.guiScreenMouseClicked, int.class, int.class, int.class);
public static final PrivateMethods<GuiScreen, Void> guiScreenMouseMovedOrUp = new PrivateMethods<GuiScreen, Void>(GuiScreen.class, ObfMap.guiScreenMouseMovedOrUp, int.class, int.class, int.class);
public static final PrivateMethods<GuiScreen, Void> guiScreenKeyTyped = new PrivateMethods<GuiScreen, Void>(GuiScreen.class, ObfMap.guiScreenKeyTyped, char.class, int.class);
// Methods on dynamic classes below here
@SuppressWarnings({ "unchecked", "rawtypes" })
public static final PrivateMethods<Container, Void> scrollTo = new PrivateMethods(PrivateClasses.ContainerCreative.Class, ObfMap.scrollTo, float.class);
}

View file

@ -1,107 +0,0 @@
package com.voxelmodpack.common.runtime;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import com.mumfrey.liteloader.util.ObfuscationUtilities;
public class Reflection {
private static Field MODIFIERS = null;
static {
try {
Reflection.MODIFIERS = (java.lang.reflect.Field.class).getDeclaredField("modifiers");
Reflection.MODIFIERS.setAccessible(true);
} catch (Exception ex) {
ex.printStackTrace();
}
}
/**
* ModLoader function, set a private value on the specified object
*
* @param instanceClass Class which the member belongs to (may be a
* superclass of the actual instance object's class)
* @param instance Object instance to set the value in
* @param fieldName Name of the field to set
* @param value Value to set for the field
*/
public static void setPrivateValue(Class<?> instanceClass, Object instance, String fieldName,
String obfuscatedFieldName, String seargeName, Object value)
throws IllegalArgumentException, SecurityException, NoSuchFieldException {
Reflection.setPrivateValueRaw(instanceClass, instance,
ObfuscationUtilities.getObfuscatedFieldName(fieldName, obfuscatedFieldName, seargeName), value);
}
/**
* ModLoader function, set a private value on the specified object
*
* @param instanceClass Class which the member belongs to (may be a
* superclass of the actual instance object's class)
* @param instance Object instance to set the value in
* @param fieldName Name of the field to set
* @param value Value to set for the field
*/
public static void setPrivateValue(Class<?> instanceClass, Object instance, String fieldName, Object value)
throws IllegalArgumentException, SecurityException, NoSuchFieldException {
Reflection.setPrivateValueRaw(instanceClass, instance, fieldName, value);
}
/**
* ModLoader function, get a private value from the specified object
*
* @param instanceClass Class which the member belongs to (may be a
* superclass of the actual instance object's class)
* @param instance Object instance to get the value from
* @param fieldName Name of the field to get the value of
* @return Value of the field
*/
@SuppressWarnings("unchecked")
public static <T> T getPrivateValue(Class<?> instanceClass, Object instance, String fieldName,
String obfuscatedFieldName, String seargeName)
throws IllegalArgumentException, SecurityException, NoSuchFieldException {
return (T) Reflection.getPrivateValueRaw(instanceClass, instance,
ObfuscationUtilities.getObfuscatedFieldName(fieldName, obfuscatedFieldName, seargeName));
}
/**
* ModLoader function, get a private value from the specified object
*
* @param instanceClass Class which the member belongs to (may be a
* superclass of the actual instance object's class)
* @param instance Object instance to get the value from
* @param fieldName Name of the field to get the value of
* @return Value of the field
*/
@SuppressWarnings("unchecked")
public static <T> T getPrivateValue(Class<?> instanceClass, Object instance, String fieldName)
throws IllegalArgumentException, SecurityException, NoSuchFieldException {
return (T) Reflection.getPrivateValueRaw(instanceClass, instance, fieldName);
}
private static void setPrivateValueRaw(Class<?> instanceClass, Object instance, String fieldName, Object value)
throws IllegalArgumentException, SecurityException, NoSuchFieldException {
try {
Field field = instanceClass.getDeclaredField(fieldName);
int modifiers = Reflection.MODIFIERS.getInt(field);
if ((modifiers & Modifier.FINAL) != 0) {
Reflection.MODIFIERS.setInt(field, modifiers & 0xffffffef);
}
field.setAccessible(true);
field.set(instance, value);
} catch (IllegalAccessException illegalaccessexception) {}
}
public static Object getPrivateValueRaw(Class<?> instanceClass, Object instance, String fieldName)
throws IllegalArgumentException, SecurityException, NoSuchFieldException {
try {
Field field = instanceClass.getDeclaredField(fieldName);
field.setAccessible(true);
return field.get(instance);
} catch (IllegalAccessException illegalaccessexception) {
return null;
}
}
}

View file

@ -1,19 +0,0 @@
package com.voxelmodpack.common.sound;
import net.minecraft.client.audio.ISound;
import net.minecraft.client.audio.PositionedSound;
import net.minecraft.util.ResourceLocation;
public class SoundEffect extends PositionedSound {
public SoundEffect(ResourceLocation soundLocation, float volume, float pitch) {
super(soundLocation);
this.volume = volume;
this.pitch = pitch;
this.xPosF = 0.0F;
this.yPosF = 0.0F;
this.zPosF = 0.0F;
this.repeat = false;
this.repeatDelay = 0;
this.attenuationType = ISound.AttenuationType.NONE;
}
}

View file

@ -1,157 +0,0 @@
package com.voxelmodpack.common.status;
import java.util.Random;
import net.minecraft.client.gui.FontRenderer;
/**
* A status message instance, this is returned from the manager to a mod to
* allow the mod to control its own status message display
*
* @author anangrybeaver
*/
public class StatusMessage implements Comparable<StatusMessage> {
/**
* Message format
*/
private static final String MESSAGE_FORMAT = "\247%s%s\247f: \247%s%s\247r";
private static final int MESSAGE_HEIGHT = 10;
/**
* Colour for the title text
*/
private char titleColour = 'f';
/**
* Colour for the status text
*/
private char textColour = 'a';
/**
* The label for this particular status message, not displayed
*/
private final String label;
/**
* Status message title
*/
private String title = "";
/**
* Status message text
*/
private String text = "";
/**
* Priority, for choosing display order
*/
private int priority = 0;
/**
* Order the message was added, this is used to order messages which have
* the same priority
*/
private int order = 0;
/**
* Show this message
*/
private boolean visible = false;
public StatusMessage(String label) {
this.label = label;
this.order = new Random().nextInt(Integer.MAX_VALUE);
}
public StatusMessage(String label, int priority, int order) {
this(label);
this.priority = priority;
this.order = order;
}
public StatusMessage setTitleAndText(String title, String text) {
this.title = title;
this.text = text;
return this;
}
public StatusMessage setTitle(String title) {
this.title = title;
return this;
}
public StatusMessage setText(String text) {
this.text = text;
return this;
}
public StatusMessage setPriority(int priority) {
this.priority = priority;
return this;
}
public StatusMessage setVisible(boolean visible) {
this.visible = visible;
return this;
}
public StatusMessage setTextColour(char textColour) {
this.textColour = textColour;
return this;
}
public StatusMessage setTitleColour(char titleColour) {
this.titleColour = titleColour;
return this;
}
public StatusMessage setColours(char textColour, char titleColour) {
this.textColour = textColour;
this.titleColour = titleColour;
return this;
}
public String getTitle() {
return this.title;
}
public String getText() {
return this.text;
}
public String getLabel() {
return this.label;
}
public int getPriority() {
return this.priority;
}
public boolean isVisible() {
return this.visible;
}
public int drawStatus(FontRenderer fontRenderer, int xPos, int yPos) {
if (this.isVisible()) {
fontRenderer.drawStringWithShadow(
String.format(MESSAGE_FORMAT, this.titleColour, this.title, this.textColour, this.text), xPos, yPos,
0xffffff);
return MESSAGE_HEIGHT;
}
return 0;
}
@Override
public int compareTo(StatusMessage other) {
if (other == null)
return 0;
if (this.priority == other.priority)
return this.order - other.order;
return this.priority - other.priority;
}
}

View file

@ -1,40 +0,0 @@
package com.voxelmodpack.common.status;
import java.io.FileWriter;
import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
import com.voxelmodpack.common.properties.ModConfig;
/**
* @author anangrybeaver
*/
public class StatusMessageConfig extends ModConfig {
public StatusMessageConfig() {
super("StatusMessage", "statusmessage.properties");
}
@Override
protected void createConfig() {
try {
this.config.setProperty("showStatuses", "true");
this.config.store(new FileWriter(this.propertiesFile), null);
} catch (Exception e) {
LiteLoaderLogger.warning("%s> ERROR: %s", this.modName, e.toString());
}
}
@Override
public String getOptionDisplayString(String optionName) {
return null;
}
@Override
public void toggleOption(String optionName) {
StatusMessageManager.getInstance().toggleOption(optionName);
}
@Override
protected void setDefaults() {
this.defaults.setProperty("showStatuses", "true");
}
}

View file

@ -1,27 +0,0 @@
package com.voxelmodpack.common.status;
import com.voxelmodpack.common.properties.VoxelPropertyCheckBox;
import com.voxelmodpack.common.properties.VoxelPropertyLabel;
import com.voxelmodpack.common.properties.gui.GuiVoxelBoxSettingsPanel;
/**
* @author anangrybeaver
*/
public class StatusMessageGUI extends GuiVoxelBoxSettingsPanel {
public StatusMessageGUI() {
this.config = StatusMessageManager.getInstance().getConfig();
this.properties.add(new VoxelPropertyLabel("Status Settings", PANEL_LEFT + 15, PANEL_TOP + 10));
this.properties.add(new VoxelPropertyCheckBox(this.config, "showStatuses", "Show Statuses", PANEL_LEFT + 20,
this.getRowYPos(0)));
}
public int getRowYPos(int row) {
return 26 + (row * 20);
}
@Override
public String getPanelTitle() {
return "Voxel Status Message";
}
}

Some files were not shown because too many files have changed in this diff Show more