Fixed jukeboxes. Vanila bugs grrr.

This commit is contained in:
chylex committed 2014-08-02 15:47:21 +02:00
1 parent c73c71c71f
commit 9b17048cde
5 files changed
+127 -17

No files matched your search

@@ -22,16 +22,16 @@ public class ItemMusicDisk extends ItemRecord{
private static final List<String[]> musicNames = new ArrayList<>();
static{
musicNames.add(new String[]{ "Banjolic", "dragoncalm_qwertygiy_Banjolic.ogg" });
musicNames.add(new String[]{ "In The End", "dragoncalm_qwertygiy_InTheEnd.ogg" });
musicNames.add(new String[]{ "Asteroid", "dragoncalm_qwertygiy_Asteroid.ogg" });
musicNames.add(new String[]{ "Stewed", "dragoncalm_qwertygiy_Stewed.ogg" });
musicNames.add(new String[]{ "Beat The Dragon", "dragonangry_qwertygiy_BeatTheDragon.ogg" });
musicNames.add(new String[]{ "Granite", "dragonangry_qwertygiy_Granite.ogg" });
musicNames.add(new String[]{ "Remember This", "dragonangry_qwertygiy_RememberThis.ogg" });
musicNames.add(new String[]{ "Spyder", "dragonangry_qwertygiy_Spyder.ogg" });
musicNames.add(new String[]{ "Onion", "random_qwertygiy_Onion.ogg" });
musicNames.add(new String[]{ "Crying Soul", "random_qwertygiy_CryingSoul.ogg" });
musicNames.add(new String[]{ "Banjolic", "records.qwertygiy.banjolic" });
musicNames.add(new String[]{ "In The End", "records.qwertygiy.intheend" });
musicNames.add(new String[]{ "Asteroid", "records.qwertygiy.asteroid" });
musicNames.add(new String[]{ "Stewed", "records.qwertygiy.stewed" });
musicNames.add(new String[]{ "Beat The Dragon", "records.qwertygiy.beatthedragon" });
musicNames.add(new String[]{ "Granite", "records.qwertygiy.granite" });
musicNames.add(new String[]{ "Remember This", "records.qwertygiy.rememberthis" });
musicNames.add(new String[]{ "Spyder", "records.qwertygiy.spyder" });
musicNames.add(new String[]{ "Onion", "records.qwertygiy.onion" });
musicNames.add(new String[]{ "Crying Soul", "records.qwertygiy.cryingsoul" });
}
public static int getRecordCount(){
@@ -11,6 +11,7 @@ import net.minecraft.util.ResourceLocation;
import chylex.hee.item.ItemMusicDisk;
import chylex.hee.packets.AbstractClientPacket;
import chylex.hee.system.ReflectionPublicizer;
import chylex.hee.system.sound.CustomMusicTicker;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -56,11 +57,11 @@ public class C02PlayRecord extends AbstractClientPacket{
mapSoundPositions.remove(coords);
}
mc.ingameGUI.setRecordPlayingMessage("qwertygiy - "+recordData[0]); // TODO records in sounds.json
mc.ingameGUI.setRecordPlayingMessage("qwertygiy - "+recordData[0]);
ResourceLocation resource = new ResourceLocation("hardcoreenderexpansion:"+recordData[1]);
PositionedSoundRecord snd = PositionedSoundRecord.func_147675_a(resource,x,y,z);
mapSoundPositions.put(coords,snd);
//CustomMusicTicker.stopCurrentMusicAndSetTo(snd,true);
mc.getSoundHandler().playSound(snd);
CustomMusicTicker.stopMusicAndPlayJukebox(snd);
}
}
@@ -12,7 +12,24 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class CustomMusicTicker extends MusicTicker{
public final class CustomMusicTicker extends MusicTicker{
private static final CustomMusicTicker instance = new CustomMusicTicker(Minecraft.getMinecraft());
public static CustomMusicTicker getInstance(){
return instance;
}
public static void stopMusicAndPlayJukebox(ISound music){
if (instance.currentMusic != null){
instance.mc.getSoundHandler().stopSound(instance.currentMusic);
instance.timeUntilNextMusic = 100;
}
instance.currentMusic = music;
instance.mc.getSoundHandler().playSound(music);
instance.isJukebox = true;
}
public static final MusicType HEE_END, HEE_END_DRAGON_CALM, HEE_END_DRAGON_ANGRY;
static{
@@ -29,8 +46,9 @@ public class CustomMusicTicker extends MusicTicker{
private final Random rand;
private ISound currentMusic;
private int timeUntilNextMusic = 100;
private boolean isJukebox = false;
public CustomMusicTicker(Minecraft mc){
private CustomMusicTicker(Minecraft mc){
super(mc);
this.mc = mc;
this.rand = new Random();
@@ -41,7 +59,7 @@ public class CustomMusicTicker extends MusicTicker{
MusicType type = getCurrentMusicType();
if (currentMusic != null){
if (!type.getMusicTickerLocation().equals(currentMusic.getPositionedSoundLocation())){
if (!type.getMusicTickerLocation().equals(currentMusic.getPositionedSoundLocation()) && !isJukebox){
mc.getSoundHandler().stopSound(currentMusic);
timeUntilNextMusic = MathHelper.getRandomIntegerInRange(rand,0,type.func_148634_b()/2);
}
@@ -56,6 +74,7 @@ public class CustomMusicTicker extends MusicTicker{
currentMusic = PositionedSoundRecord.func_147673_a(type.getMusicTickerLocation());
mc.getSoundHandler().playSound(currentMusic);
timeUntilNextMusic = Integer.MAX_VALUE;
isJukebox = false;
}
}
@@ -45,7 +45,7 @@ public final class MusicManager{
fields[a].setAccessible(true);
try{
fields[a].set(mc,new CustomMusicTicker(mc));
fields[a].set(mc,CustomMusicTicker.getInstance());
DragonUtil.info("Succesfully replaced MusicTicker.");
}catch(Exception ex){
ex.printStackTrace();
@@ -162,6 +162,96 @@
"random/spatialdash"
]
},
"records.qwertygiy.crysingsoul": {
"category": "record",
"sounds": [
{
"name": "music/random_qwertygiy_CryingSoul",
"stream": "true"
}
]
},
"records.qwertygiy.onion": {
"category": "record",
"sounds": [
{
"name": "music/random_qwertygiy_Onion",
"stream": "true"
}
]
},
"records.qwertygiy.asteroid": {
"category": "record",
"sounds": [
{
"name": "music/dragoncalm_qwertygiy_Asteroid",
"stream": "true"
}
]
},
"records.qwertygiy.banjolic": {
"category": "record",
"sounds": [
{
"name": "music/dragoncalm_qwertygiy_Banjolic",
"stream": "true"
}
]
},
"records.qwertygiy.intheend": {
"category": "record",
"sounds": [
{
"name": "music/dragoncalm_qwertygiy_InTheEnd",
"stream": "true"
}
]
},
"records.qwertygiy.stewed": {
"category": "record",
"sounds": [
{
"name": "music/dragoncalm_qwertygiy_Stewed",
"stream": "true"
}
]
},
"records.qwertygiy.beatthedragon": {
"category": "record",
"sounds": [
{
"name": "music/dragonangry_qwertygiy_BeatTheDragon",
"stream": "true"
}
]
},
"records.qwertygiy.granite": {
"category": "record",
"sounds": [
{
"name": "music/dragonangry_qwertygiy_Granite",
"stream": "true"
}
]
},
"records.qwertygiy.rememberthis": {
"category": "record",
"sounds": [
{
"name": "music/dragonangry_qwertygiy_RememberThis",
"stream": "true"
}
]
},
"records.qwertygiy.spyder": {
"category": "record",
"sounds": [
{
"name": "music/dragonangry_qwertygiy_Spyder",
"stream": "true"
}
]
},
"music.game.end": {
"category": "music",
"sounds": [