[Feature] Particle Effects for the Eternal Portal
This commit is contained in:
parent
2cf510b160
commit
55985d0660
5 changed files with 271 additions and 38 deletions
|
@ -0,0 +1,73 @@
|
|||
package org.betterx.betterend.network;
|
||||
|
||||
import org.betterx.bclib.api.v2.dataexchange.BaseDataHandler;
|
||||
import org.betterx.bclib.api.v2.dataexchange.DataHandler;
|
||||
import org.betterx.bclib.api.v2.dataexchange.DataHandlerDescriptor;
|
||||
import org.betterx.betterend.BetterEnd;
|
||||
import org.betterx.betterend.rituals.EternalRitual;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketSender;
|
||||
|
||||
public class RitualUpdate extends DataHandler.FromServer {
|
||||
public static final DataHandlerDescriptor DESCRIPTOR = new DataHandlerDescriptor(
|
||||
BetterEnd.makeID("ritual_update"),
|
||||
RitualUpdate::new,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
public RitualUpdate() {
|
||||
super(DESCRIPTOR.IDENTIFIER);
|
||||
}
|
||||
|
||||
private static final byte ACTIVE_FLAG = 1;
|
||||
private static final byte WILL_ACTIVATE_FLAG = 2;
|
||||
|
||||
public RitualUpdate(EternalRitual ritual) {
|
||||
this();
|
||||
this.center = ritual.getCenter();
|
||||
this.axis = ritual.getAxis();
|
||||
|
||||
if (ritual.isActive()) {
|
||||
this.flags |= ACTIVE_FLAG;
|
||||
}
|
||||
if (ritual.willActivate()) {
|
||||
this.flags |= WILL_ACTIVATE_FLAG;
|
||||
}
|
||||
}
|
||||
|
||||
byte flags;
|
||||
BlockPos center;
|
||||
Direction.Axis axis;
|
||||
|
||||
@Override
|
||||
protected void serializeDataOnServer(FriendlyByteBuf buf) {
|
||||
buf.writeBlockPos(center);
|
||||
BaseDataHandler.writeString(buf, axis.getName());
|
||||
buf.writeByte(flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deserializeIncomingDataOnClient(FriendlyByteBuf buf, PacketSender responseSender) {
|
||||
center = buf.readBlockPos();
|
||||
axis = Direction.Axis.byName(BaseDataHandler.readString(buf));
|
||||
flags = buf.readByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runOnClientGameThread(Minecraft client) {
|
||||
EternalRitual.updateActiveStateOnPedestals(
|
||||
center,
|
||||
axis,
|
||||
(flags & ACTIVE_FLAG) != 0,
|
||||
(flags & WILL_ACTIVATE_FLAG) != 0,
|
||||
client.level,
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue