Allow WorldProviders to specify in-game music (#4539)

This commit is contained in:
Vincent Lee 2018-01-18 14:39:14 -06:00 committed by LexManos
parent 2d424ed2e1
commit 3a3883589f
3 changed files with 36 additions and 5 deletions

View File

@ -523,7 +523,17 @@
}
public boolean func_70002_Q()
@@ -3181,11 +3093,11 @@
@@ -3152,6 +3064,9 @@
}
else if (this.field_71439_g != null)
{
+ MusicTicker.MusicType type = this.field_71441_e.field_73011_w.getMusicType();
+ if (type != null) return type;
+
if (this.field_71439_g.field_70170_p.field_73011_w instanceof WorldProviderHell)
{
return MusicTicker.MusicType.NETHER;
@@ -3181,11 +3096,11 @@
{
if (Keyboard.getEventKeyState())
{
@ -537,7 +547,7 @@
{
this.field_71456_v.func_146158_b().func_146227_a(ScreenShotHelper.func_148260_a(this.field_71412_D, this.field_71443_c, this.field_71440_d, this.field_147124_at));
}
@@ -3199,6 +3111,7 @@
@@ -3199,6 +3114,7 @@
}
}
}
@ -545,7 +555,7 @@
}
}
}
@@ -3328,6 +3241,12 @@
@@ -3328,6 +3244,12 @@
return this.field_184127_aH;
}
@ -558,7 +568,7 @@
public boolean func_189648_am()
{
return this.field_71439_g != null && this.field_71439_g.func_175140_cp() || this.field_71474_y.field_178879_v;
@@ -3342,4 +3261,9 @@
@@ -3342,4 +3264,9 @@
{
return this.field_193035_aW;
}

View File

@ -65,7 +65,7 @@
}
@SideOnly(Side.CLIENT)
@@ -241,6 +216,323 @@
@@ -241,6 +216,336 @@
return new WorldBorder();
}
@ -227,6 +227,19 @@
+ public net.minecraftforge.common.capabilities.ICapabilityProvider initCapabilities() {
+ return null;
+ }
+
+ /**
+ * Called on the client to get the music type to play when in this world type.
+ * At the time of calling, the client player and world are guaranteed to be non-null
+ * @return null to use vanilla logic, otherwise a MusicType to play in this world
+ */
+ @Nullable
+ @SideOnly(Side.CLIENT)
+ public net.minecraft.client.audio.MusicTicker.MusicType getMusicType()
+ {
+ return null;
+ }
+
+ /*======================================= Start Moved From World =========================================*/
+
+ public Biome getBiomeForCoords(BlockPos pos)

View File

@ -19,6 +19,8 @@
package net.minecraftforge.client;
import net.minecraft.client.audio.MusicTicker;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.Util.EnumOS;
import net.minecraft.world.GameType;
import net.minecraft.client.settings.GameSettings.Options;
@ -61,6 +63,12 @@ public class EnumHelperClient extends EnumHelper
return addEnum(EnumOS.class, name);
}
@Nullable
public static MusicTicker.MusicType addMusicType(String name, SoundEvent sound, int minDelay, int maxDelay)
{
return addEnum(MusicTicker.MusicType.class, name, sound, minDelay, maxDelay);
}
@Nullable
private static <T extends Enum<? >> T addEnum(Class<T> enumType, String enumName, Object... paramValues)
{