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 May 27, 2024
2 parents dbf6ba8 + 802eeda commit 28d3838
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 18 deletions.
5 changes: 5 additions & 0 deletions src/main/java/twilightforest/TFCommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.client.model.ModelBiped;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;

import cpw.mods.fml.common.network.IGuiHandler;
Expand Down Expand Up @@ -160,4 +161,8 @@ public ModelBiped getCritterArmorModel(int boss) {

public void doBlockAnnihilateEffect(World worldObj, int blockX, int blockY, int blockZ) {}

public boolean checkForSound(ChunkCoordinates chunkcoordinates) {
return true;
}

}
12 changes: 9 additions & 3 deletions src/main/java/twilightforest/TwilightForestMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
import twilightforest.item.TFItems;
import twilightforest.item.TFRecipes;
import twilightforest.structures.StructureTFMajorFeatureStart;
import twilightforest.tileentity.TileEntityTFAlphaYetiSpawner;
import twilightforest.tileentity.TileEntityTFCReactorActive;
import twilightforest.tileentity.TileEntityTFCake;
import twilightforest.tileentity.TileEntityTFChest;
import twilightforest.tileentity.TileEntityTFCicada;
import twilightforest.tileentity.TileEntityTFCinderFurnace;
import twilightforest.tileentity.TileEntityTFFirefly;
Expand All @@ -50,6 +52,7 @@
import twilightforest.tileentity.TileEntityTFHydraSpawner;
import twilightforest.tileentity.TileEntityTFKnightPhantomsSpawner;
import twilightforest.tileentity.TileEntityTFLichSpawner;
import twilightforest.tileentity.TileEntityTFMinoshroomSpawner;
import twilightforest.tileentity.TileEntityTFMoonworm;
import twilightforest.tileentity.TileEntityTFNagaSpawner;
import twilightforest.tileentity.TileEntityTFNagastone;
Expand Down Expand Up @@ -886,21 +889,24 @@ private void registerTileEntities() {
GameRegistry.registerTileEntity(TileEntityTFCicada.class, "Cicada");
GameRegistry.registerTileEntity(TileEntityTFNagaSpawner.class, "Naga Spawner");
GameRegistry.registerTileEntity(TileEntityTFLichSpawner.class, "Lich Spawner");
GameRegistry.registerTileEntity(TileEntityTFMinoshroomSpawner.class, "Minoshroom Spawner");
GameRegistry.registerTileEntity(TileEntityTFHydraSpawner.class, "Hydra Spawner");
GameRegistry.registerTileEntity(TileEntityTFKnightPhantomsSpawner.class, "Knight Phantom Spawner");
GameRegistry.registerTileEntity(TileEntityTFTowerBossSpawner.class, "Tower Boss Spawner");
GameRegistry.registerTileEntity(TileEntityTFAlphaYetiSpawner.class, "Alpha Yeti Spawner");
GameRegistry.registerTileEntity(TileEntityTFSnowQueenSpawner.class, "Snow Queen Spawner");
GameRegistry.registerTileEntity(TileEntityTFSmoker.class, "Swamp Smoker");
GameRegistry.registerTileEntity(TileEntityTFPoppingJet.class, "Popping Flame Jet");
GameRegistry.registerTileEntity(TileEntityTFFlameJet.class, "Lit Flame Jet");
GameRegistry.registerTileEntity(TileEntityTFMoonworm.class, "Moonworm");
GameRegistry.registerTileEntity(TileEntityTFTowerBuilder.class, "Tower Builder");
GameRegistry.registerTileEntity(TileEntityTFReverter.class, "Tower Reverter");
GameRegistry.registerTileEntity(TileEntityTFTrophy.class, "TF Trophy");
GameRegistry.registerTileEntity(TileEntityTFTowerBossSpawner.class, "Tower Boss Spawner");
GameRegistry.registerTileEntity(TileEntityTFGhastTrapInactive.class, "Inactive Ghast Trap");
GameRegistry.registerTileEntity(TileEntityTFGhastTrapActive.class, "Active Ghast Trap");
GameRegistry.registerTileEntity(TileEntityTFCReactorActive.class, "Active Carminite Reactor");
GameRegistry.registerTileEntity(TileEntityTFKnightPhantomsSpawner.class, "Knight Phantom Spawner");
GameRegistry.registerTileEntity(TileEntityTFSnowQueenSpawner.class, "Snow Queen Spawner");
GameRegistry.registerTileEntity(TileEntityTFCinderFurnace.class, "Cinder Furnace");
GameRegistry.registerTileEntity(TileEntityTFChest.class, "TF Chest");
}

/**
Expand Down
19 changes: 10 additions & 9 deletions src/main/java/twilightforest/block/BlockTFCicada.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import net.minecraft.world.Explosion;
import net.minecraft.world.World;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import twilightforest.tileentity.TileEntityTFCicada;

public class BlockTFCicada extends BlockTFCritter {
Expand Down Expand Up @@ -78,17 +80,16 @@ public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer
return false;
}

@SideOnly(Side.CLIENT)
public void stopSinging(World worldIn, int x, int y, int z) {
if (worldIn.isRemote) {
ChunkCoordinates chunkcoordinates = new ChunkCoordinates(x, y, z);
Minecraft mc = Minecraft.getMinecraft();
ISound isound = (ISound) mc.renderGlobal.mapSoundPositions.get(chunkcoordinates);
ChunkCoordinates chunkcoordinates = new ChunkCoordinates(x, y, z);
Minecraft mc = Minecraft.getMinecraft();
ISound isound = (ISound) mc.renderGlobal.mapSoundPositions.get(chunkcoordinates);

while (isound != null) {
mc.getSoundHandler().stopSound(isound);
mc.renderGlobal.mapSoundPositions.remove(chunkcoordinates);
isound = (ISound) mc.renderGlobal.mapSoundPositions.get(chunkcoordinates);
}
while (isound != null) {
mc.getSoundHandler().stopSound(isound);
mc.renderGlobal.mapSoundPositions.remove(chunkcoordinates);
isound = (ISound) mc.renderGlobal.mapSoundPositions.get(chunkcoordinates);
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/twilightforest/client/TFClientProxy.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package twilightforest.client;

import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.ISound;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.model.ModelPig;
import net.minecraft.client.model.ModelSilverfish;
Expand All @@ -12,6 +13,7 @@
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;
Expand Down Expand Up @@ -856,4 +858,9 @@ public void doBlockAnnihilateEffect(World worldObj, int blockX, int blockY, int
}
}

public boolean checkForSound(ChunkCoordinates chunkcoordinates) {
ISound isound = (ISound) Minecraft.getMinecraft().renderGlobal.mapSoundPositions.get(chunkcoordinates);
return isound != null;
}

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

import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.ISound;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.ResourceLocation;
Expand Down Expand Up @@ -96,19 +95,18 @@ public void doSingAnimation() {
}

public void playSong() {
if (!TwilightForestMod.silentCicadas && worldObj.isRemote) {
ResourceLocation resource = new ResourceLocation(TwilightForestMod.ID + ":mob.cicada");
if (!TwilightForestMod.silentCicadas) {
ChunkCoordinates chunkcoordinates = new ChunkCoordinates(xCoord, yCoord, zCoord);
Minecraft mc = Minecraft.getMinecraft();
ISound isound = (ISound) mc.renderGlobal.mapSoundPositions.get(chunkcoordinates);
if (isound == null) {
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,
(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 28d3838

Please sign in to comment.