Skip to content

Commit

Permalink
Merge remote-tracking branch 'Gordon-Frohman/master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Dream-Master committed Jun 1, 2024
2 parents ba128f4 + 9143d32 commit 3d40d46
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
4 changes: 4 additions & 0 deletions src/main/java/twilightforest/TFCommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.minecraft.client.model.ModelBiped;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;

import cpw.mods.fml.common.network.IGuiHandler;
Expand Down Expand Up @@ -167,4 +168,7 @@ public boolean checkForSound(ChunkCoordinates chunkcoordinates) {

public void stopSound(World worldIn, int x, int y, int z) {}

public void playSound(World worldObj, ChunkCoordinates chunkcoordinates, ResourceLocation soundResource,
float xPosition, float yPosition, float zPosition) {}

}
16 changes: 16 additions & 0 deletions src/main/java/twilightforest/client/TFClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.ISound;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.model.ModelPig;
import net.minecraft.client.model.ModelSilverfish;
Expand All @@ -14,6 +15,7 @@
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;
Expand Down Expand Up @@ -875,4 +877,18 @@ public void stopSound(World worldIn, int x, int y, int z) {
}
}

public void playSound(World worldObj, ChunkCoordinates chunkcoordinates, ResourceLocation soundResource,
float xPosition, float yPosition, float zPosition) {
PositionedSoundRecord positionedsoundrecord = new PositionedSoundRecord(
soundResource,
1.0f,
(worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F + 1.0F,
(float) xPosition,
(float) yPosition,
(float) zPosition);
Minecraft mc = Minecraft.getMinecraft();
mc.renderGlobal.mapSoundPositions.put(chunkcoordinates, positionedsoundrecord);
mc.getSoundHandler().playSound(positionedsoundrecord);
}

}
14 changes: 4 additions & 10 deletions src/main/java/twilightforest/tileentity/TileEntityTFCicada.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package twilightforest.tileentity;

import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.ResourceLocation;

Expand Down Expand Up @@ -98,17 +96,13 @@ public void playSong() {
if (!TwilightForestMod.silentCicadas) {
ChunkCoordinates chunkcoordinates = new ChunkCoordinates(xCoord, yCoord, zCoord);
if (!TwilightForestMod.proxy.checkForSound(chunkcoordinates)) {
ResourceLocation resource = new ResourceLocation(TwilightForestMod.ID + ":mob.cicada");
PositionedSoundRecord positionedsoundrecord = new PositionedSoundRecord(
resource,
1.0f,
(worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F + 1.0F,
TwilightForestMod.proxy.playSound(
worldObj,
chunkcoordinates,
new ResourceLocation(TwilightForestMod.ID + ":mob.cicada"),
(float) xCoord,
(float) yCoord,
(float) zCoord);
Minecraft mc = Minecraft.getMinecraft();
mc.renderGlobal.mapSoundPositions.put(chunkcoordinates, positionedsoundrecord);
mc.getSoundHandler().playSound(positionedsoundrecord);
}
}
}
Expand Down

0 comments on commit 3d40d46

Please sign in to comment.