forked from Ladysnake/Requiem
-
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.
Bare bones implementation of Colored Sound Particles
- Loading branch information
Showing
17 changed files
with
245 additions
and
54 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
95 changes: 95 additions & 0 deletions
95
src/main/java/ladysnake/requiem/common/particle/RequiemSoundParticleEffect.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,95 @@ | ||
/* | ||
* Requiem | ||
* Copyright (C) 2017-2024 Ladysnake | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses>. | ||
* | ||
* Linking this mod statically or dynamically with other | ||
* modules is making a combined work based on this mod. | ||
* Thus, the terms and conditions of the GNU General Public License cover the whole combination. | ||
* | ||
* In addition, as a special exception, the copyright holders of | ||
* this mod give you permission to combine this mod | ||
* with free software programs or libraries that are released under the GNU LGPL | ||
* and with code included in the standard release of Minecraft under All Rights Reserved (or | ||
* modified versions of such code, with unchanged license). | ||
* You may copy and distribute such a system following the terms of the GNU GPL for this mod | ||
* and the licenses of the other code concerned. | ||
* | ||
* Note that people who make modified versions of this mod are not obligated to grant | ||
* this special exception for their modified versions; it is their choice whether to do so. | ||
* The GNU General Public License gives permission to release a modified version without this exception; | ||
* this exception also makes it possible to release a modified version which carries forward this exception. | ||
*/ | ||
package ladysnake.requiem.common.particle; | ||
|
||
import com.mojang.brigadier.StringReader; | ||
import com.mojang.brigadier.exceptions.CommandSyntaxException; | ||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import net.minecraft.network.PacketByteBuf; | ||
import net.minecraft.particle.ParticleEffect; | ||
import net.minecraft.particle.ParticleType; | ||
import net.minecraft.registry.Registries; | ||
|
||
|
||
public class RequiemSoundParticleEffect implements ParticleEffect { | ||
public RequiemSoundParticleEffect(ParticleType<RequiemSoundParticleEffect> type, int color) { | ||
this.type = type; | ||
this.color = color; | ||
} | ||
|
||
public int color; | ||
private final ParticleType<RequiemSoundParticleEffect> type; | ||
|
||
|
||
public static final Factory<RequiemSoundParticleEffect> PARAMETERS_FACTORY = new Factory<>() { | ||
@Override | ||
public RequiemSoundParticleEffect read(ParticleType<RequiemSoundParticleEffect> particleType, StringReader stringReader) throws CommandSyntaxException { | ||
stringReader.expect(' '); | ||
int color = stringReader.readInt(); | ||
return new RequiemSoundParticleEffect(particleType, color); | ||
} | ||
|
||
@Override | ||
public RequiemSoundParticleEffect read(ParticleType<RequiemSoundParticleEffect> particleType, PacketByteBuf buf) { | ||
return new RequiemSoundParticleEffect(particleType, buf.readInt()); | ||
} | ||
}; | ||
|
||
@Override | ||
public void write(PacketByteBuf buf) { | ||
buf.writeInt(color); | ||
} | ||
|
||
@Override | ||
public String asString() { | ||
return "%s %d".formatted(Registries.PARTICLE_TYPE.getId(this.getType()), this.color); | ||
} | ||
|
||
@Override | ||
public ParticleType<RequiemSoundParticleEffect> getType() { | ||
return this.type; | ||
} | ||
|
||
public int getColor() { | ||
return this.color; | ||
} | ||
|
||
public static Codec<RequiemSoundParticleEffect> codec(ParticleType particleType) { | ||
return RecordCodecBuilder.create(instance -> instance.group( | ||
Codec.INT.fieldOf("color").forGetter(RequiemSoundParticleEffect::getColor) | ||
).apply(instance, color -> new RequiemSoundParticleEffect(particleType, color))); | ||
} | ||
} |
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
Oops, something went wrong.