added gravity test block with gui and debug renderer

This commit is contained in:
TechnoDraconic
2026-02-06 22:22:10 -08:00
parent fa41966de4
commit 9356c43ea7
25 changed files with 739 additions and 67 deletions

View File

@@ -0,0 +1,27 @@
package net.xevianlight.aphelion.network;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.neoforged.neoforge.network.handling.IPayloadContext;
import net.xevianlight.aphelion.block.entity.custom.GravityTestBlockEntity;
import net.xevianlight.aphelion.network.packet.UpdateGravityTestBlockPacket;
public class UpdateGravityTestBlockHandler {
public static void handleDataOnMain(UpdateGravityTestBlockPacket packet, IPayloadContext context) {
context.enqueueWork(() -> {
BlockPos pos = packet.pos();
float radius = packet.radius();
float strength = packet.strength();
Level level = context.player().level();
if (level.getBlockEntity(pos) instanceof GravityTestBlockEntity blockEntity) {
blockEntity.setRadius(radius);
blockEntity.setStrength(strength);
blockEntity.sendUpdate();
level.sendBlockUpdated(pos, level.getBlockState(pos), level.getBlockState(pos), Block.UPDATE_ALL);
}
});
}
}

View File

@@ -0,0 +1,30 @@
package net.xevianlight.aphelion.network.packet;
import io.netty.buffer.ByteBuf;
import net.minecraft.core.BlockPos;
import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.resources.ResourceLocation;
import net.xevianlight.aphelion.Aphelion;
public record UpdateGravityTestBlockPacket(BlockPos pos, float radius, float strength) implements CustomPacketPayload {
public static final CustomPacketPayload.Type<UpdateGravityTestBlockPacket> TYPE =
new CustomPacketPayload.Type<>(ResourceLocation.fromNamespaceAndPath(Aphelion.MOD_ID, "update_oxygen_test_block"));
public static final StreamCodec<ByteBuf, UpdateGravityTestBlockPacket> STREAM_CODEC = StreamCodec.composite(
BlockPos.STREAM_CODEC,
UpdateGravityTestBlockPacket::pos,
ByteBufCodecs.FLOAT,
UpdateGravityTestBlockPacket::radius,
ByteBufCodecs.FLOAT,
UpdateGravityTestBlockPacket::strength,
UpdateGravityTestBlockPacket::new
);
@Override
public CustomPacketPayload.Type<? extends CustomPacketPayload> type() {
return TYPE;
}
}