remove unnecessary stuff
This commit is contained in:
parent
9ce120f521
commit
cca4c0518a
4 changed files with 1 additions and 146 deletions
|
@ -20,8 +20,6 @@ import me.night0721.lilase.utils.Clock;
|
||||||
import me.night0721.lilase.utils.KeyBindingManager;
|
import me.night0721.lilase.utils.KeyBindingManager;
|
||||||
import me.night0721.lilase.utils.ScoreboardUtils;
|
import me.night0721.lilase.utils.ScoreboardUtils;
|
||||||
import me.night0721.lilase.utils.Utils;
|
import me.night0721.lilase.utils.Utils;
|
||||||
import me.night0721.lilase.utils.capes.CapeDatabase;
|
|
||||||
import me.night0721.lilase.utils.capes.CapeManager;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiDisconnected;
|
import net.minecraft.client.gui.GuiDisconnected;
|
||||||
import net.minecraft.client.gui.GuiMainMenu;
|
import net.minecraft.client.gui.GuiMainMenu;
|
||||||
|
@ -53,13 +51,12 @@ public class Lilase {
|
||||||
private int tickAmount;
|
private int tickAmount;
|
||||||
private final Clock clock = new Clock();
|
private final Clock clock = new Clock();
|
||||||
public static RemoteControl remoteControl;
|
public static RemoteControl remoteControl;
|
||||||
public static final CapeDatabase capeDatabase = new CapeDatabase();
|
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void init(FMLInitializationEvent event) {
|
public void init(FMLInitializationEvent event) {
|
||||||
(configHandler = new ConfigHandler()).init();
|
(configHandler = new ConfigHandler()).init();
|
||||||
KeyBindingManager keyBindingManager = new KeyBindingManager();
|
KeyBindingManager keyBindingManager = new KeyBindingManager();
|
||||||
addToEventBus(this, keyBindingManager, new SniperFlipperEvents(), new ChatReceivedEvent(), new GUIRenderer(), new CapeManager());
|
addToEventBus(this, keyBindingManager, new SniperFlipperEvents(), new ChatReceivedEvent(), new GUIRenderer());
|
||||||
EventManager.INSTANCE.register(this);
|
EventManager.INSTANCE.register(this);
|
||||||
// pageFlipper = new PageFlipper();
|
// pageFlipper = new PageFlipper();
|
||||||
keyBindingManager.registerKeyBindings();
|
keyBindingManager.registerKeyBindings();
|
||||||
|
@ -69,7 +66,6 @@ public class Lilase {
|
||||||
webhook.setUsername("Lilase");
|
webhook.setUsername("Lilase");
|
||||||
webhook.setAvatarUrl(icon);
|
webhook.setAvatarUrl(icon);
|
||||||
remoteControl = new RemoteControl();
|
remoteControl = new RemoteControl();
|
||||||
capeDatabase.init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addToEventBus(Object... objects) {
|
private void addToEventBus(Object... objects) {
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
package me.night0721.lilase.utils.capes;
|
|
||||||
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
import me.night0721.lilase.Lilase;
|
|
||||||
import me.night0721.lilase.utils.HWIDUtils;
|
|
||||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Credits: Gabagooooooooooool
|
|
||||||
*/
|
|
||||||
public class CapeDatabase {
|
|
||||||
private final Map<String, ResourceLocation> cachedCapeTextures = new HashMap<>();
|
|
||||||
|
|
||||||
public boolean userHasCape(String username) {
|
|
||||||
return cachedCapeTextures.containsKey(username.toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResourceLocation getUserCape(String username) {
|
|
||||||
return cachedCapeTextures.get(username.toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init() {
|
|
||||||
try {
|
|
||||||
URL url = new URL("https://api.night0721.me/api/v1/wl");
|
|
||||||
StringBuilder result = new StringBuilder();
|
|
||||||
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
|
||||||
connection.setRequestMethod("GET");
|
|
||||||
connection.setRequestProperty("User-Agent", "night0721");
|
|
||||||
connection.setRequestProperty("Content-Type", "application/json");
|
|
||||||
connection.setRequestProperty("Accept", "application/json");
|
|
||||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
|
|
||||||
for (String line; (line = reader.readLine()) != null; ) {
|
|
||||||
result.append(line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
new JsonParser().parse(result.toString()).getAsJsonArray().forEach(jsonElement -> {
|
|
||||||
String id = jsonElement.getAsJsonObject().get("id").getAsString();
|
|
||||||
if (!id.equals(HWIDUtils.getID())) return;
|
|
||||||
String username = jsonElement.getAsJsonObject().get("username").getAsString();
|
|
||||||
String capeUrl = jsonElement.getAsJsonObject().get("url").getAsString();
|
|
||||||
try {
|
|
||||||
BufferedImage image = ImageIO.read(new URL(capeUrl));
|
|
||||||
DynamicTexture texture = new DynamicTexture(image);
|
|
||||||
cachedCapeTextures.put(username.toLowerCase(), Lilase.mc.getTextureManager().getDynamicTextureLocation("Lilas_" + username, texture));
|
|
||||||
} catch (IOException ignored) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (IOException ignored) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,59 +0,0 @@
|
||||||
package me.night0721.lilase.utils.capes;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import me.night0721.lilase.Lilase;
|
|
||||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
|
||||||
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
|
|
||||||
import net.minecraft.entity.player.EnumPlayerModelParts;
|
|
||||||
import net.minecraft.util.MathHelper;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Revxrsal Gabagooooooooooool
|
|
||||||
* @version 1.1
|
|
||||||
* Implemented from github.com/Revxrsal/SimpleCapes under Apache Commons 2.0 License
|
|
||||||
*/
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class CapeLayer implements LayerRenderer<AbstractClientPlayer> {
|
|
||||||
private final RenderPlayer playerRenderer;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doRenderLayer(AbstractClientPlayer entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
|
|
||||||
ResourceLocation capeLoc = Lilase.capeDatabase.getUserCape(entity.getName());
|
|
||||||
if (capeLoc == null) return;
|
|
||||||
if (!entity.isInvisible() && entity.isWearing(EnumPlayerModelParts.CAPE)) {
|
|
||||||
float f9 = entity.isSneaking() ? .1F : .14F;
|
|
||||||
float f10 = entity.isSneaking() ? .09F : 0F;
|
|
||||||
GlStateManager.color(1F, 1F, 1F, 1F);
|
|
||||||
this.playerRenderer.bindTexture(capeLoc);
|
|
||||||
GlStateManager.pushMatrix();
|
|
||||||
GlStateManager.translate(0.0F, f10, f9);
|
|
||||||
double d0 = entity.prevChasingPosX + (entity.chasingPosX - entity.prevChasingPosX) * partialTicks - (entity.prevPosX + (entity.posX - entity.prevPosX) * partialTicks);
|
|
||||||
double d1 = entity.prevChasingPosY + (entity.chasingPosY - entity.prevChasingPosY) * partialTicks - (entity.prevPosY + (entity.posY - entity.prevPosY) * partialTicks);
|
|
||||||
double d2 = entity.prevChasingPosZ + (entity.chasingPosZ - entity.prevChasingPosZ) * partialTicks - (entity.prevPosZ + (entity.posZ - entity.prevPosZ) * partialTicks);
|
|
||||||
float f = entity.prevRenderYawOffset + (entity.renderYawOffset - entity.prevRenderYawOffset) * partialTicks;
|
|
||||||
double d3 = MathHelper.sin(f * .017453292F);
|
|
||||||
double d4 = -MathHelper.cos(f * .017453292F);
|
|
||||||
float f1 = (float) d1 * 10F;
|
|
||||||
f1 = MathHelper.clamp_float(f1, 3F, 32F);
|
|
||||||
float f2 = Math.max((float) (d0 * d3 + d2 * d4) * 100F, 0F);
|
|
||||||
float f3 = (float) (d0 * d4 - d2 * d3) * 100F;
|
|
||||||
float f4 = entity.prevCameraYaw + (entity.cameraYaw - entity.prevCameraYaw) * partialTicks;
|
|
||||||
f1 += MathHelper.sin((entity.prevDistanceWalkedModified + (entity.distanceWalkedModified - entity.prevDistanceWalkedModified) * partialTicks) * 6F) * 32F * f4;
|
|
||||||
if (entity.isSneaking()) f1 += 20F;
|
|
||||||
GlStateManager.rotate(5F + f2 / 2F + f1, 1F, 0F, 0F);
|
|
||||||
GlStateManager.rotate(f3 / 2F, 0F, 0F, 1F);
|
|
||||||
GlStateManager.rotate(-f3 / 2F, 0F, 1F, 0F);
|
|
||||||
GlStateManager.rotate(180F, 0F, 1F, 0F);
|
|
||||||
this.playerRenderer.getMainModel().renderCape(.0625F);
|
|
||||||
GlStateManager.popMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldCombineTextures() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
package me.night0721.lilase.utils.capes;
|
|
||||||
|
|
||||||
import me.night0721.lilase.Lilase;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.entity.player.EnumPlayerModelParts;
|
|
||||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
/**
|
|
||||||
* Credits: Gabagooooooooooool
|
|
||||||
*/
|
|
||||||
public class CapeManager {
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onJoin(EntityJoinWorldEvent event) {
|
|
||||||
if (event.entity instanceof EntityPlayer && Lilase.capeDatabase.userHasCape(event.entity.getName())) {
|
|
||||||
Lilase.mc.gameSettings.setModelPartEnabled(EnumPlayerModelParts.CAPE, true);
|
|
||||||
Lilase.mc.getRenderManager().getSkinMap().values().forEach(p -> p.addLayer(new CapeLayer(p)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue