forked from cravxx/unfm2jg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RadicalMod.java
320 lines (299 loc) · 8.35 KB
/
RadicalMod.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
//package nfm.territories.music;
// Credits to DragShot
// for his shit
import ds.nfm.Module;
import ds.nfm.ModuleLoader;
import ds.nfm.ModuleSlayer;
//import nfm.territories.GameSparker;
import java.net.URL;
/**
* The Class RadicalMod.
*/
public class RadicalMod implements RadicalMusic {
private static String name = "";
SuperClip sClip;
boolean playing;
int loaded;
int rvol;
String imod;
String pmod;
/**
* Instantiates a new radical mod.
*/
public RadicalMod() {
playing = false;
loaded = 0;
rvol = 0;
imod = "";
pmod = "";
loaded = 0;
System.gc();
}
/**
* Instantiates a new radical mod.
*
* @param string the string
* @param i the i
* @param i_0 the i_0
* @param i_1 the i_1
* @param bool the bool
* @param bool_2 the bool_2
*/
public RadicalMod(String string, int i, int i_0, final int i_1, final boolean bool, final boolean bool_2) {
playing = false;
loaded = 0;
rvol = 0;
imod = "";
pmod = "";
final int i_3 = 22000;
i_0 = (int) (i_0 / 8000F * 2.0F * i_3);
i = (int) (i * 0.8F);
try {
Module module;
if (!bool_2) {
module = ModuleLoader.loadMod(string);
} else {
string = string.replace(' ', '_');
final URL url = new URL("http://multiplayer.needformadness.com/tracks/music/" + string + ".zip");
module = ModuleLoader.loadMod(url);
}
if (module.isLoaded()) {
name = module.getName();
if (name.trim().equals("")) {
name = "Untitled";
}
final ModuleSlayer moduleslayer = ModuleLoader.prepareSlayer(module, i_0, i, i_1);
final byte is[] = moduleslayer.turnbytesNorm(bool);
if (bool) {
rvol = moduleslayer.olav;
}
sClip = new SuperClip(is, moduleslayer.oln, i_3);
sClip.rollBackPos = moduleslayer.rollBackPos;
sClip.rollBackTrig = moduleslayer.oln - moduleslayer.rollBackTrig;
loaded = 2;
}
} catch (final Exception exception) {
exception.printStackTrace();
if (GameSparker.DEBUG) {
System.out.println("Error downloading and making Mod: " + exception);
}
loaded = 0;
}
System.runFinalization();
System.gc();
}
/**
* Instantiates a new radical mod.
*
* @param string the string
*/
public RadicalMod(final String string) {
playing = false;
loaded = 0;
rvol = 0;
imod = "";
pmod = "";
loaded = 1;
imod = string;
loadimod(false);
}
/**
* Instantiates a new radical mod.
*
* @param string the string
* @param bool the bool
*/
public RadicalMod(final String string, final boolean bool) {
playing = false;
loaded = 0;
rvol = 0;
imod = "";
pmod = "";
loaded = 1;
pmod = string;
loadpmod(true);
}
/**
* Loadimod.
*
* @param bool the bool
*/
private void loadimod(final boolean bool) {
if (loaded == 1) {
final int i = 44000;
int i_6 = 160;
if (bool) {
i_6 = 300;
}
final int i_7 = 125;
try {
final Module module = ModuleLoader.loadMod(imod);
if (module.isLoaded()) {
name = module.getName();
if (name.trim().equals("")) {
name = "Untitled";
}
final ModuleSlayer moduleslayer = ModuleLoader.prepareSlayer(module, i, i_6, i_7);
final byte is[] = moduleslayer.turnbytesNorm(bool);
if (bool) {
rvol = moduleslayer.olav;
}
sClip = new SuperClip(is, moduleslayer.oln, 22000);
sClip.rollBackPos = moduleslayer.rollBackPos;
sClip.rollBackTrig = moduleslayer.oln - moduleslayer.rollBackTrig;
loaded = 2;
}
} catch (final Exception exception) {
if (GameSparker.DEBUG) {
System.out.println("Error making a imod: " + exception);
}
loaded = 0;
}
System.runFinalization();
System.gc();
}
}
/**
* Loadpmod.
*
* @param bool the bool
*/
private void loadpmod(final boolean bool) {
if (loaded == 1) {
final int i = 44000;
int i_10 = 160;
if (bool) {
i_10 = 300;
}
final int i_11 = 125;
try {
final Module module = ModuleLoader.loadMod(pmod);
if (module.isLoaded()) {
name = module.getName();
if (name.trim().equals("")) {
name = "Untitled";
}
final ModuleSlayer moduleslayer = ModuleLoader.prepareSlayer(module, i, i_10, i_11);
final byte is[] = moduleslayer.turnbytesNorm(bool);
if (bool) {
rvol = moduleslayer.olav;
}
sClip = new SuperClip(is, moduleslayer.oln, 22000);
sClip.rollBackPos = moduleslayer.rollBackPos;
sClip.rollBackTrig = moduleslayer.oln - moduleslayer.rollBackTrig;
loaded = 2;
}
} catch (final Exception exception) {
if (GameSparker.DEBUG) {
System.out.println("Error making a imod: " + exception);
}
loaded = 0;
}
System.runFinalization();
System.gc();
}
}
/*
* (non-Javadoc)
*
* @see com.trashers.skyline.singleplayer.RadicalMusic#play()
*/
@Override
public void play() {
if (!playing && loaded == 2) {
sClip.play();
if (sClip.stoped == 0) {
playing = true;
}
}
}
/*
* (non-Javadoc)
*
* @see com.trashers.skyline.singleplayer.RadicalMusic#unload()
*/
@Override
public void unload() {
if (playing && loaded == 2) {
sClip.stop();
playing = false;
}
try {
sClip.close();
sClip = null;
} catch (final Exception exception) {
}
try {
imod = null;
} catch (final Exception exception) {
}
System.gc();
loaded = 0;
}
/*
* (non-Javadoc)
*
* @see com.trashers.skyline.singleplayer.RadicalMusic#resume()
*/
@Override
@Deprecated
public void resume() {
if (!playing && loaded == 2) {
sClip.resume();
if (sClip.stoped == 0) {
playing = true;
}
}
}
/*
* (non-Javadoc)
*
* @see com.trashers.skyline.singleplayer.RadicalMusic#stop()
*/
@Override
@Deprecated
public void stop() {
if (playing && loaded == 2) {
sClip.stop();
playing = false;
}
}
/*
* (non-Javadoc)
*
* @see com.trashers.skyline.singleplayer.RadicalMusic#isPaused()
*/
@Override
public boolean isPaused() {
return !playing;
}
/*
* (non-Javadoc)
*
* @see com.trashers.skyline.singleplayer.RadicalMusic#setPaused(boolean)
*/
@Override
public void setPaused(final boolean pause) {
if (pause)
if (playing && loaded == 2) {
sClip.stop();
playing = false;
} else {
}
else if (!playing && loaded == 2) {
sClip.resume();
if (sClip.stoped == 0) {
playing = true;
}
}
}
/*
* (non-Javadoc)
*
* @see com.trashers.skyline.singleplayer.RadicalMusic#getType()
*/
@Override
public Type getType() {
return Type.TYPE_MOD;
}
}