mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-24 18:37:38 +00:00
Use Forge's packet methods for sending SoundEvents
Doesn't fix #515 (arguably makes it worse in the sense that it's more likely to throw). However it should provide better error reporting, and make it more clear that it's not CC:T's fault.
This commit is contained in:
@@ -13,10 +13,8 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.fml.network.NetworkEvent;
|
import net.minecraftforge.fml.network.NetworkEvent;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts or stops a record on the client, depending on if {@link #soundEvent} is {@code null}.
|
* Starts or stops a record on the client, depending on if {@link #soundEvent} is {@code null}.
|
||||||
@@ -51,7 +49,7 @@ public class PlayRecordClientMessage implements NetworkMessage
|
|||||||
if( buf.readBoolean() )
|
if( buf.readBoolean() )
|
||||||
{
|
{
|
||||||
name = buf.readString( Short.MAX_VALUE );
|
name = buf.readString( Short.MAX_VALUE );
|
||||||
soundEvent = ForgeRegistries.SOUND_EVENTS.getValue( buf.readResourceLocation() );
|
soundEvent = buf.readRegistryIdSafe( SoundEvent.class );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -72,7 +70,7 @@ public class PlayRecordClientMessage implements NetworkMessage
|
|||||||
{
|
{
|
||||||
buf.writeBoolean( true );
|
buf.writeBoolean( true );
|
||||||
buf.writeString( name );
|
buf.writeString( name );
|
||||||
buf.writeResourceLocation( Objects.requireNonNull( soundEvent.getRegistryName(), "Sound is not registered" ) );
|
buf.writeRegistryId( soundEvent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user