forked from GTNewHorizons/GT5-Unofficial
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Electric jukebox (GTNewHorizons#2827)
* GT music system * Minor fix for some glitches when switching dimensions with P2Ps on both sides * Most features implemented except headphones * Implement wireless headphones * Disable debug mode * Spotless --------- Co-authored-by: Martin Robertz <[email protected]>
- Loading branch information
1 parent
799d5ed
commit 5decfda
Showing
38 changed files
with
2,090 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/main/java/gregtech/api/net/GT_Packet_MusicSystemData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package gregtech.api.net; | ||
|
||
import net.minecraft.world.IBlockAccess; | ||
|
||
import com.google.common.io.ByteArrayDataInput; | ||
|
||
import gregtech.api.util.GT_MusicSystem; | ||
import io.netty.buffer.ByteBuf; | ||
import io.netty.buffer.Unpooled; | ||
|
||
public class GT_Packet_MusicSystemData extends GT_Packet_New { | ||
|
||
ByteBuf storedData; | ||
|
||
public GT_Packet_MusicSystemData() { | ||
super(true); | ||
} | ||
|
||
public GT_Packet_MusicSystemData(ByteBuf data) { | ||
super(false); | ||
this.storedData = data; | ||
} | ||
|
||
@Override | ||
public byte getPacketID() { | ||
return GT_PacketTypes.MUSIC_SYSTEM_DATA.id; | ||
} | ||
|
||
@Override | ||
public void encode(ByteBuf aOut) { | ||
if (storedData == null) { | ||
return; | ||
} | ||
storedData.markReaderIndex(); | ||
final int len = storedData.readableBytes(); | ||
aOut.writeInt(len); | ||
aOut.writeBytes(storedData); | ||
storedData.resetReaderIndex(); | ||
} | ||
|
||
@Override | ||
public GT_Packet_New decode(ByteArrayDataInput aData) { | ||
final int len = aData.readInt(); | ||
final byte[] fullData = new byte[len]; | ||
aData.readFully(fullData); | ||
return new GT_Packet_MusicSystemData(Unpooled.wrappedBuffer(fullData)); | ||
} | ||
|
||
@Override | ||
public void process(IBlockAccess aWorld) { | ||
if (aWorld == null || storedData == null) { | ||
return; | ||
} | ||
storedData.markReaderIndex(); | ||
GT_MusicSystem.ClientSystem.loadUpdatedSources(storedData); | ||
storedData.resetReaderIndex(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.