aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--class.js139
-rw-r--r--featureManager.js384
-rw-r--r--features/cosmetics/dragonWings.js32
-rw-r--r--features/cosmetics/index.js22
-rw-r--r--features/globalSettings/firstLoadPages.js2
-rw-r--r--features/globalSettings/index.js13
-rw-r--r--features/settings/settingThings/textSetting.js2
-rw-r--r--forgeEvents.js93
-rw-r--r--utils/renderLib2d.js12
9 files changed, 61 insertions, 638 deletions
diff --git a/class.js b/class.js
deleted file mode 100644
index 1cfdd8b..0000000
--- a/class.js
+++ /dev/null
@@ -1,139 +0,0 @@
-/// <reference types="../../CTAutocomplete" />
-
-import logger from "../logger"
-
-/// <reference lib="es2015" />
-
-class Feature {
- constructor(){
- this.FeatureManager = undefined
- this.events = {}
- this.customEvents = {}
- this.forgeEvents = {}
- this.soopyEvents = {}
-
- this.id = undefined
-
- this.enabled = false
- }
-
- setId(id){
- this.id = id
- }
- getId(){
- return this.id
- }
-
- _onDisable(){
- Object.values(this.events).forEach(e=>this.FeatureManager.unregisterEvent(e)) //calling parent unregister to avoid the set in unregister event
- Object.values(this.customEvents).forEach(e=>this.FeatureManager.unregisterCustom(e)) //calling parent unregister to avoid the set in unregister event
-
- this.onDisable()
-
- this.events = {}
- this.customEvents = {}
- this.enabled = false
- }
-
- _onEnable(parent){
- this.FeatureManager = parent
-
- this.enabled = true
-
- this.onEnable()
- }
-
- onDisable(){}
- onEnable(){}
-
- registerEvent(event, func){
- let theEvent = this.FeatureManager.registerEvent(event, func, this)
-
- this.events[theEvent.id] = theEvent
-
- return theEvent
- }
-
- unregisterEvent(event){
- this.FeatureManager.unregisterEvent(event)
-
- delete this.events[event.id]
- }
- registerSoopy(event, func){
- let theEvent = this.FeatureManager.registerSoopy(event, func, this)
-
- this.soopyEvents[theEvent.id] = theEvent
-
- return theEvent
- }
-
- unregisterSoopy(event){
- this.FeatureManager.unregisterSoopy(event)
-
- delete this.soopyEvents[event.id]
- }
-
- registerForge(event, func){
- let theEvent = this.FeatureManager.registerForge(event, func, this)
-
- this.forgeEvents[theEvent.id] = theEvent
-
- return theEvent
- }
-
- unregisterForge(event){
- this.FeatureManager.unregisterForge(event)
-
- delete this.forgeEvents[event.id]
- }
-
- registerChat(criteria, func){
- let theEvent = this.FeatureManager.registerChat(criteria, func, this)
-
- this.customEvents[theEvent.id] = theEvent
-
- return theEvent
- }
- registerStep(isFps, interval, func){
- let theEvent = this.FeatureManager.registerStep(isFps, interval, func, this)
-
- this.customEvents[theEvent.id] = theEvent
-
- return theEvent
- }
-
- registerCustom(event, func){
- let theEvent = this.FeatureManager.registerCustom(event, func, this)
-
- this.customEvents[theEvent.id] = theEvent
-
- return theEvent
- }
-
- registerCommand(name, func){
- this.FeatureManager.commandFuncs[name] = func
-
- this.FeatureManager.registerCommand(name, (...args)=>{
- if(this.FeatureManager.commandFuncs[name]){
- this.FeatureManager.commandFuncs[name].call(this, ...(args || []))
- }else{
- ChatLib.chat("&cThis command is not available atm")
- }
- }, this)
- }
- unregisterCommand(name){
- delete this.FeatureManager.commandFuncs[name]
- }
-
- unregisterCustom(event){
- this.FeatureManager.unregisterCustom(event)
-
- delete this.customEvents[event.id]
- }
-
- createCustomEvent(eventId){
- return this.FeatureManager.createCustomEvent(eventId)
- }
-}
-
-export default Feature \ No newline at end of file
diff --git a/featureManager.js b/featureManager.js
deleted file mode 100644
index 92b9cd8..0000000
--- a/featureManager.js
+++ /dev/null
@@ -1,384 +0,0 @@
-/// <reference types="../../CTAutocomplete" />
-/// <reference lib="es2015" />
-import LocationSetting from "../features/settings/settingThings/location";
-import logger from "../logger";
-const File = Java.type("java.io.File")
-import metadata from "../metadata.js"
-import { registerForge as registerForgeBase, unregisterForge as unregisterForgeBase} from "./forgeEvents.js"
-
-class FeatureManager {
- constructor(){
-
- this.enabled = true //make triggers work with this context
-
- this.features = {};
- this.events = {}
- this.eventObjects = {}
- this.soopyEventHandlers = {}
-
- this.parent = undefined
-
- this.commandFuncs = {}
-
- this.lastEventId = 0
-
- this.customEvents = {}
- this.lastChatEventId = 0
-
- this.forgeEvents = {}
- this.lastForgeEventId = 0
-
- this.lastSoopyEventId = 0
-
- this.featureSettingsDataLastUpdated = false
-
- this.featureMetas = {}
-
- this.featureSettingsData = {}
-
- new Thread(()=>{
- this.loadFeatureMetas()
-
- this.loadFeatureSettings()
-
- Object.keys(this.featureMetas).forEach((feature)=>{
- if(this.featureSettingsData[feature] && this.featureSettingsData[feature].enabled){
- this.loadFeature(feature)
- }
- })
- }).start()
-
- this.registerStep(false, 30, ()=>{
- if(this.featureSettingsDataLastUpdated){
- new Thread(()=>{
- this.saveFeatureSettings()
- }).start()
- }
- }, this)
-
- this.registerEvent("worldUnload", this.saveFeatureSettings, this)
- this.registerEvent("gameUnload", this.saveFeatureSettings, this)
-
- this.registerCommand("soopyunloadfeature", (args)=>{
- new Thread(()=>{
- this.unloadFeature(args)
- }).start()
- }, this)
- this.registerCommand("soopyloadfeature", (args)=>{
- new Thread(()=>{
- this.loadFeature(args)
- }).start()
- }, this)
- this.registerCommand("soopyreloadfeature", (args)=>{
- new Thread(()=>{
- this.unloadFeature(args)
-
- this.loadFeature(args)
- }).start()
- }, this)
- }
-
- loadFeatureSettings(){
- logger.logMessage("Loading settings", 4)
-
- let data = FileLib.read("soopyAddonsData", "soopyaddonsbetafeaturesdata.json")
-
- if(!data){
- this.loadDefaultFeatureSettings();
- return;
- }
-
- data = JSON.parse(data)
-
- this.featureSettingsData = data
-
- this.ensureNewSettingsExist()
- }
-
- saveFeatureSettings(){
- if(!this.featureSettingsDataLastUpdated) return
-
- FileLib.write("soopyAddonsData", "soopyaddonsbetafeaturesdata.json", JSON.stringify(this.featureSettingsData))
-
- this.featureSettingsDataLastUpdated = false
-
- logger.logMessage("Saved settings", 4)
- }
-
- loadDefaultFeatureSettings(){
- Object.keys(this.featureMetas).forEach((feature)=>{
- this.featureSettingsData[feature] = {
- enabled: this.featureMetas[feature].defaultEnabled,
- subSettings: {}
- }
- })
-
- this.featureSettingsDataLastUpdated= true
-
- logger.logMessage("Loaded default settings", 4)
- }
-
- ensureNewSettingsExist(){
- Object.keys(this.featureMetas).forEach((feature)=>{
- if(!this.featureSettingsData[feature]){
- this.featureSettingsData[feature] = {
- enabled: this.featureMetas[feature].defaultEnabled,
- subSettings: {}
- }
- this.featureSettingsDataLastUpdated= true
- logger.logMessage("Loaded default settings for " + feature, 4)
- }
- })
- }
-
- startCatchingEvent(event){
- if(this.eventObjects[event]) return
-
- //SBA compatability or something (removed)
- // if(event === "renderOverlay"){
- // let lastPartialTick = undefined
- // this.eventObjects[event] = register(event, (...args)=>{
- // let pTicks = Tessellator.getPartialTicks()
- // if(pTicks !== lastPartialTick){
- // lastPartialTick = pTicks
- // this.triggerEvent(event, args)
- // }
- // })
- // }else{
- this.eventObjects[event] = register(event, (...args)=>{
- this.triggerEvent(event, args)
- })
- //}
-
- logger.logMessage("Registered " + event + " event", 4)
- }
-
- triggerEvent(event, args){
- if(this.events[event])
- try{
- for(Event of Object.values(this.events[event])){
- if(Event.context.enabled) Event.func.call(Event.context, ...args)
- }
- }catch(e){
- logger.logMessage("Error in " + event + " event: " + JSON.stringify(e, undefined, 2), 2)
- }
- }
- triggerSoopy(event, args){
- if(this.soopyEventHandlers[event])
- try{
- for(Event of Object.values(this.soopyEventHandlers[event])){
- if(Event.context.enabled) Event.func.call(Event.context, ...args)
- }
- }catch(e){
- logger.logMessage("Error in soopy " + event + " event: " + JSON.stringify(e, undefined, 2), 2)
- }
- }
-
- stopCatchingEvent(event){
- if(!this.eventObjects[event]) return
-
- this.eventObjects[event].unregister()
- delete this.eventObjects[event]
- delete this.events[event]
- logger.logMessage("Unregistered " + event + " event", 4)
- }
-
- registerEvent(event, func, context){
- if(!this.events[event]){
- this.events[event] = []
- this.startCatchingEvent(event)
- }
-
- let theEvent = {
- func: func,
- context: context,
- id: this.lastEventId++,
- event: event
- }
- this.events[event].push(theEvent)
-
- return theEvent
- }
- registerSoopy(event, func, context){
- if(!this.soopyEventHandlers[event]){
- this.soopyEventHandlers[event] = []
- }
-
- let theEvent = {
- func: func,
- context: context,
- id: this.lastSoopyEventId++,
- event: event
- }
- this.soopyEventHandlers[event].push(theEvent)
-
- return theEvent
- }
-
- registerChat(criteria, func, context){
-
- let event = this.registerCustom("chat", func, context)
-
- event.trigger.setChatCriteria(criteria)
-
- return event
- }
- registerCommand(commandName, func, context){
-
- let event = this.registerCustom("command", func, context)
-
- event.trigger.setName(commandName)
-
- return event
- }
- registerStep(isFps, interval, func, context){
-
- let event = this.registerCustom("step", func, context)
-
- event.trigger[isFps?"setFps":"setDelay"](interval) //TODO: make this group events similar to registerEvent()
-
- return event
- }
-
- registerCustom(type, func, context){
-
- let id = this.lastChatEventId++
-
- this.customEvents[id] = {
- func: func,
- context: context,
- trigger: register(type, (...args)=>{
- try{
- if(context.enabled) func.call(context, ...(args || []))
- }catch(e){
- logger.logMessage("Error in " + type + " event: " + JSON.stringify(e, undefined, 2), 2)
- }
- }),
- id: id
- }
-
- return this.customEvents[id]
- }
-
- registerForge(event, func, context){
- let id = this.lastForgeEventId++
-
- this.forgeEvents[id] = {
- func: func,
- context: context,
- trigger: registerForgeBase(event, (...args)=>{
- try{
- if(context.enabled) func.call(context, ...args)
- }catch(e){
- logger.logMessage("Error in " + event.class.toString() + " (forge) event: " + JSON.stringify(e, undefined, 2), 2)
- }
- }),
- id: id
- }
-
- return this.forgeEvents[id]
- }
-
- unregisterForge(event){
- unregisterForgeBase(this.forgeEvents[event.id].trigger)
- delete this.forgeEvents[event.id]
- }
-
- unregisterCustom(event){
- event.trigger.unregister()
-
- delete this.customEvents[event.id]
- }
-
- unregisterEvent(event){
- if(!this.events[event.event]) return
-
- this.events[event.event] = this.events[event.event].filter((e)=>{
- return e.id !== event.id
- })
-
- if(this.events[event.event].length === 0){
- this.stopCatchingEvent(event.event)
- delete this.events[event.event]
- }
- }
-
- unregisterSoopy(event){
- if(!this.soopyEventHandlers[event.event]) return
-
- this.soopyEventHandlers[event.event] = this.soopyEventHandlers[event.event].filter((e)=>{
- return e.id !== event.id
- })
-
- if(this.soopyEventHandlers[event.event].length === 0){
- delete this.events[event.event]
- }
- }
-
- loadFeatureMetas(){
- featuresDir = new File("./config/ChatTriggers/modules/" + metadata.name + "/features")
-
- featuresDir.list().forEach((pathName)=>{
- if(pathName.includes(".")) return;
-
- try{
- let data = JSON.parse(FileLib.read( metadata.name + "/features/" + pathName,"metadata.json"))
- if(data === null){
- return;
- }
- data.id = pathName
- this.featureMetas[pathName] = data
- }catch(_){}
- })
- }
-
- loadFeature(feature){ //run in seperate thread so onenable can do network requests
- if(this.features[feature]) return
-
- let LoadedFeature = require("../features/" + feature + "/index.js")
-
- this.features[feature] = LoadedFeature
-
- LoadedFeature.class.setId(feature)
-
- LoadedFeature.class._onEnable(this)
-
- logger.logMessage("Loaded feature " + feature, 3)
-
- return this
- }
-
- unloadFeature(feature){ //run in seperate thread so ondisable can do network requests
- if(!this.features[feature]) return
-
- this.features[feature].class._onDisable()
-
- delete this.features[feature]
-
- logger.logMessage("Unloaded feature " + feature, 3)
-
- return this
- }
-
- isFeatureLoaded(feature){
- return !!this.features[feature]
- }
-
- getLoadedFeatures(){
- return Object.keys(this.features)
- }
-
- createCustomEvent(eventId){
- logger.logMessage("Registered custom " + eventId + " event", 4)
-
- return {
- trigger: (...args)=>{
- this.triggerSoopy(eventId, args)
- }
- }
- }
-}
-
-const featureManager = new FeatureManager();
-
-export default featureManager; \ No newline at end of file
diff --git a/features/cosmetics/dragonWings.js b/features/cosmetics/dragonWings.js
index d9e8a1c..d523a46 100644
--- a/features/cosmetics/dragonWings.js
+++ b/features/cosmetics/dragonWings.js
@@ -4,6 +4,8 @@ const ModelDragon = Java.type("net.minecraft.client.model.ModelDragon")
const ResourceLocation = Java.type("net.minecraft.util.ResourceLocation")
const GlStateManager = Java.type("net.minecraft.client.renderer.GlStateManager");
+const Essential = Java.type("gg.essential.Essential")
+const EssentialCosmeticSlot = Java.type("gg.essential.cosmetics.CosmeticSlot")
const FACING = Java.type("net.minecraft.block.BlockDirectional").field_176387_N
let dragon = new ModelDragon(0) //too lazy to make my own model so i just yoink it from modelDragon lmfao
@@ -24,10 +26,6 @@ class DragonWings extends Cosmetic {
}
onRender(ticks){
- if(this.settings.disableWithNoChestplate && this.player.getPlayer().func_82169_q(2) === null && !(this.player === Player && Client.getMinecraft().field_71474_y.field_74320_O === 0)){
- return
- }
-
if(this.player.getPlayer().func_98034_c(Player.getPlayer())){
return
}
@@ -157,7 +155,7 @@ class DragonWings extends Cosmetic {
let dist = Math.sqrt((Player.getX()-this.player.getX())**2+(Player.getY()-this.player.getY())**2+(Player.getZ()-this.player.getZ())**2)+1
- World.playSound("mob.enderdragon.wings", (this.settings.scale*15)*Math.min(1, 50/(dist*dist)), 1)
+ World.playSound("mob.enderdragon.wings", (Math.max(0.005,this.settings.scale-0.005)*25)*Math.min(1, 50/Math.min(1,dist*dist))/50, 1-(Math.max(0.005,this.settings.scale-0.005)*25))
this.lastFlapSound = 2*Math.PI+(this.animOffset)-this.animOffset%(Math.PI*2)
}
this.animOffset += 2*timeSince*Math.min(1,(amt/(1*Math.PI))*2)
@@ -261,20 +259,34 @@ class DragonWings extends Cosmetic {
wingTip.field_78808_h = -((Math.sin((this.animOffset))*0.5 + 0.3))
}
-
Tessellator.translate(0.1, 0, 0)
- wing.func_78791_b(this.settings.scale) //render left wing
+ Tessellator.scale(this.settings.scale, this.settings.scale, this.settings.scale)
+ wing.func_78791_b(1) //render left wing
- Tessellator.translate(-0.2, 0, 0)
+ Tessellator.translate(-0.2/this.settings.scale, 0, 0)
Tessellator.scale(-1, 1, 1)
- wing.func_78791_b(this.settings.scale) //render right wing
+ wing.func_78791_b(1) //render right wing
GlStateManager.func_179121_F(); // popMatrix
}
onTick(){
- // this.scale += 0.001
+ if(!this.player.getPlayer().getEssentialCosmetics()) return
+
+ let wingCosmetic = this.player.getPlayer().getEssentialCosmetics().get(EssentialCosmeticSlot.WINGS)
+ if(wingCosmetic !== null){
+ this.player.getPlayer().getEssentialCosmeticModels().get(Essential.instance.getConnectionManager().getCosmeticsManager().getCosmetic(wingCosmetic)).getModel().getModel().boneList.forEach(b=>{
+ b.isHidden = true
+ })
+ }else{
+ let fullBodyCosmetic = this.player.getPlayer().getEssentialCosmetics().get(EssentialCosmeticSlot.FULL_BODY)
+ if(fullBodyCosmetic === "DRAGON_ONESIE_2"){
+ this.player.getPlayer().getEssentialCosmeticModels().get(Essential.instance.getConnectionManager().getCosmeticsManager().getCosmetic(fullBodyCosmetic)).getModel().getModel().boneList.forEach(b=>{
+ if(b.boxName === "wing_left_1" || b.boxName === "wing_right_1")b.isHidden = true
+ })
+ }
+ }
}
}
diff --git a/features/cosmetics/index.js b/features/cosmetics/index.js
index 11d9f47..c2bd10d 100644
--- a/features/cosmetics/index.js
+++ b/features/cosmetics/index.js
@@ -3,6 +3,8 @@
import Feature from "../../featureClass/class";
import DragonWings from "./dragonWings"
import Toggle from "../settings/settingThings/toggle"
+const Essential = Java.type("gg.essential.Essential")
+const EssentialCosmeticSlot = Java.type("gg.essential.cosmetics.CosmeticSlot")
class Cosmetics extends Feature {
constructor() {
@@ -34,6 +36,8 @@ class Cosmetics extends Feature {
this.registerStep(false, 60*10, ()=>{
new Thread(()=>{this.loadCosmeticsData.call(this)}).start()
})
+
+
}
loadCosmeticsData(){
@@ -126,6 +130,24 @@ class Cosmetics extends Feature {
}
tick(){
+ World.getAllPlayers().forEach(p=>{
+ if(!p.getPlayer().getEssentialCosmetics()) return
+
+ let wingCosmetic = p.getPlayer().getEssentialCosmetics().get(EssentialCosmeticSlot.WINGS)
+ if(wingCosmetic !== null){
+ p.getPlayer().getEssentialCosmeticModels().get(Essential.instance.getConnectionManager().getCosmeticsManager().getCosmetic(wingCosmetic)).getModel().getModel().boneList.forEach(b=>{
+ b.isHidden = false
+ })
+ }else{
+ let fullBodyCosmetic = p.getPlayer().getEssentialCosmetics().get(EssentialCosmeticSlot.FULL_BODY)
+ if(fullBodyCosmetic === "DRAGON_ONESIE_2"){
+ p.getPlayer().getEssentialCosmeticModels().get(Essential.instance.getConnectionManager().getCosmeticsManager().getCosmetic(fullBodyCosmetic)).getModel().getModel().boneList.forEach(b=>{
+ if(b.boxName === "wing_left_1" || b.boxName === "wing_right_1")b.isHidden = false
+ })
+ }
+ }
+ })
+
this.filterUnloadedCosmetics(true)
}
diff --git a/features/globalSettings/firstLoadPages.js b/features/globalSettings/firstLoadPages.js
index e395afe..eebd5be 100644
--- a/features/globalSettings/firstLoadPages.js
+++ b/features/globalSettings/firstLoadPages.js
@@ -68,7 +68,7 @@ class HowToOpenMenuPage extends FirstLoadPage{
this.addChild(new SoopyTextElement().setText("§0Your all set!").setLocation(0.1, 0.1,0.8,0.3).setMaxTextScale(10));
- this.addChild(new SoopyTextElement().setText("§7To change any settings, or to access this menu again run §2/soopyaddons§7.").setLocation(0.1, 0.3,0.8,0.1).setMaxTextScale(10));
+ this.addChild(new SoopyTextElement().setText("§7To change any settings, or to access this menu again run §2/soopyv2§7.").setLocation(0.1, 0.3,0.8,0.1).setMaxTextScale(10));
let openSettingsButton = new ButtonWithArrow().setText("§0Open settings").setLocation(0.1, 0.5,0.3,0.2).setDirectionRight(false)
diff --git a/features/globalSettings/index.js b/features/globalSettings/index.js
index 18a70a3..dd3d922 100644
--- a/features/globalSettings/index.js
+++ b/features/globalSettings/index.js
@@ -40,14 +40,14 @@ class Hud extends Feature {
this.privacySettings = [this.reportErrorsSetting, this.sendChatSetting]
- this.GuiPage = new FirstLoadingPage(this)
+ // this.GuiPage = new FirstLoadingPage(this)
this.registerChat("&aYour new API key is &r&b${key}&r", this.newKey)
- new Thread(()=>{
- Thread.sleep(1000) //TODO: DO ON WORLDLOAD
- ChatLib.command("soopyv2 first_load_thing", true)//TODO: ONLY RUN ON FIRST INSTALL
- }).start()
+ // new Thread(()=>{
+ // Thread.sleep(1000) //TODO: DO ON WORLDLOAD
+ // ChatLib.command("soopyv2 first_load_thing", true)//TODO: ONLY RUN ON FIRST INSTALL
+ // }).start()
}
findKey(){
@@ -149,6 +149,9 @@ class Hud extends Feature {
}
}
}catch(_){}
+
+
+ new Notification("§cUnable to find api key", [])
}).start()
}
diff --git a/features/settings/settingThings/textSetting.js b/features/settings/settingThings/textSetting.js
index 4960461..4666fbf 100644
--- a/features/settings/settingThings/textSetting.js
+++ b/features/settings/settingThings/textSetting.js
@@ -15,7 +15,7 @@ class TextSetting extends SettingBase {
this.guiObject.text.setLocation(0, 0, 0.6, 0.6)
this.guiObject.description.setLocation(0, 0.6, 0.55, 0.4)
- this.textObject.addEvent(new SoopyContentChangeEvent().setHandler((newVal, oldVal, resetFun)=>{
+ this.textObject.text.addEvent(new SoopyContentChangeEvent().setHandler((newVal, oldVal, resetFun)=>{
this.setValue(newVal)
}))
diff --git a/forgeEvents.js b/forgeEvents.js
deleted file mode 100644
index e852c49..0000000
--- a/forgeEvents.js
+++ /dev/null
@@ -1,93 +0,0 @@
-importClass(net.minecraftforge.common.MinecraftForge) //i would have used the ct module but it is broken (line 78) (this is fixed verison)
-importPackage(net.minecraftforge.fml.common.eventhandler)
-importPackage(org.objectweb.asm)
-importClass(java.lang.ClassLoader)
-importClass(org.apache.commons.lang3.RandomStringUtils)
-importClass(java.util.function.Consumer)
-
-const L = s => `L${s};`
-
-const LoadedInsts = []
-
-function defineClassBytes(name, bytes) {
- const classLoader = Packages.com.chattriggers.ctjs.CTJS.class.getClassLoader()
-
- const defClass = ClassLoader.class.getDeclaredMethods()[23] // defineClass()
-
- defClass.setAccessible(true)
-
- const n = new java.lang.String(name)
- const o = new java.lang.Integer(0)
- const s = new java.lang.Integer(bytes.length)
- return defClass.invoke(classLoader, n, bytes, o, s)
-}
-
-const registerForge = (e, cb) => {
- const cw = new ClassWriter(0)
-
- const event = Type.getType(e.class).internalName
- const name = RandomStringUtils.randomAlphabetic(7)
-
- const consumer = Type.getType(Consumer.class).internalName
- const mcForge = Type.getType(MinecraftForge.class).internalName
- const eventBus = Type.getType(EventBus.class).internalName
- const subscribeEvent = Type.getType(SubscribeEvent.class).internalName
- const obj = Type.getType(java.lang.Object.class).internalName
-
- cw.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC, name, null, obj, null)
- // cw.visitInnerClass("net/minecraftforge/event/entity/player/PlayerEvent$BreakSpeed", "net/minecraftforge/event/entity/player/PlayerEvent", "BreakSpeed", ACC_PUBLIC + ACC_STATIC);
- {
- cw.visitField(Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL, "callback", L(consumer), L(consumer + "<" + L(event) + ">"), null).visitEnd()
- }
- {
- const con = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "(" + L(consumer) + ")V", "(" + L(consumer + "<" + L(event) + ">") + ")V", null)
- con.visitCode()
- con.visitVarInsn(Opcodes.ALOAD, 0)
- con.visitMethodInsn(Opcodes.INVOKESPECIAL, obj, "<init>", "()V", false)
-
- con.visitVarInsn(Opcodes.ALOAD, 0)
- con.visitVarInsn(Opcodes.ALOAD, 1)
- con.visitFieldInsn(Opcodes.PUTFIELD, name, "callback", L(consumer))
- con.visitFieldInsn(Opcodes.GETSTATIC, mcForge, "EVENT_BUS", L(eventBus))
- con.visitVarInsn(Opcodes.ALOAD, 0)
- con.visitMethodInsn(Opcodes.INVOKEVIRTUAL, eventBus, "register", "(" + L(obj) + ")V", false)
- con.visitInsn(Opcodes.RETURN)
- con.visitMaxs(2, 2)
- con.visitEnd()
- }
- {
- const mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "on", "(" + L(event) + ")V", null, null)
- {
- const av = mv.visitAnnotation(L(subscribeEvent), true)
- av.visitEnd()
- }
- mv.visitCode()
- mv.visitVarInsn(Opcodes.ALOAD, 0)
- mv.visitFieldInsn(Opcodes.GETFIELD, name, "callback", L(consumer))
- mv.visitVarInsn(Opcodes.ALOAD, 1)
- mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, consumer, "accept", "(" + L(obj) + ")V", true)
- mv.visitInsn(Opcodes.RETURN)
- mv.visitMaxs(2, 2)
- mv.visitEnd()
- }
- cw.visitEnd()
-
- const inst = defineClassBytes(name, cw.toByteArray())
- .getDeclaredConstructor(Consumer.class)
- .newInstance(new java.util.function.Consumer({
- accept: function (t) { cb(t) }
- }))
- LoadedInsts.push(inst)
- return inst;
-}
-
-const unregisterForge = inst => {
- MinecraftForge.EVENT_BUS.unregister(inst)
-}
-
-register("gameUnload", () => {
- LoadedInsts.forEach(unregisterForge)
- LoadedInsts.length = 0
-})
-
-export { registerForge, unregisterForge }
diff --git a/utils/renderLib2d.js b/utils/renderLib2d.js
index b2defd1..e9769b7 100644
--- a/utils/renderLib2d.js
+++ b/utils/renderLib2d.js
@@ -8,6 +8,8 @@
//TODO: just require the module when ct 2.0 comes out
+const GL11 = Java.type("org.lwjgl.opengl.GL11");
+const GlStateManager = Java.type("net.minecraft.client.renderer.GlStateManager");
const BufferUtils = org.lwjgl.BufferUtils;
const Project = org.lwjgl.util.glu.Project;
@@ -19,18 +21,18 @@ const viewportDims = BufferUtils.createIntBuffer(16);
const ScaledResolution = net.minecraft.client.gui.ScaledResolution;
register('renderWorld', () => {
- Tessellator.pushMatrix();
+ GlStateManager.func_179094_E();
- let x = Player.getRenderX();
- let y = Player.getRenderY();
- let z = Player.getRenderZ();
+ let x = Player.getX();
+ let y = Player.getY();
+ let z = Player.getZ();
Tessellator.translate(-x, -y, -z);
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelViewMatrix);
GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projectionMatrix);
- Tessellator.popMatrix();
+ GlStateManager.func_179121_F();
GL11.glGetInteger(GL11.GL_VIEWPORT, viewportDims);
});