use of net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket in project LevelZ by Globox1997.
the class PlayerStatsServerPacket method writeS2CListPacket.
public static void writeS2CListPacket(ServerPlayerEntity serverPlayerEntity) {
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
for (int i = 0; i < LevelLists.getListNames().size(); i++) {
String listName = LevelLists.getListNames().get(i);
ArrayList<Object> list = LevelLists.getList(listName);
for (int u = 0; u < list.size(); u++) {
buf.writeString(list.get(u).toString());
}
}
for (int k = 0; k < LevelLists.miningLevelList.size(); k++) {
buf.writeString("mining:level");
buf.writeString(LevelLists.miningLevelList.get(k).toString());
for (int u = 0; u < LevelLists.miningBlockList.get(k).size(); u++) {
buf.writeString(LevelLists.miningBlockList.get(k).get(u).toString());
}
}
for (int k = 0; k < LevelLists.brewingLevelList.size(); k++) {
buf.writeString("brewing:level");
buf.writeString(LevelLists.brewingLevelList.get(k).toString());
for (int u = 0; u < LevelLists.brewingItemList.get(k).size(); u++) {
buf.writeString(LevelLists.brewingItemList.get(k).get(u).toString());
}
}
CustomPayloadS2CPacket packet = new CustomPayloadS2CPacket(LIST_PACKET, buf);
serverPlayerEntity.networkHandler.sendPacket(packet);
}
use of net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket in project LevelZ by Globox1997.
the class PlayerStatsServerPacket method writeS2CStrengthPacket.
public static void writeS2CStrengthPacket(ServerPlayerEntity serverPlayerEntity) {
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
buf.writeDouble(serverPlayerEntity.getAttributeInstance(EntityAttributes.GENERIC_ATTACK_DAMAGE).getBaseValue());
CustomPayloadS2CPacket packet = new CustomPayloadS2CPacket(STRENGTH_PACKET, buf);
serverPlayerEntity.networkHandler.sendPacket(packet);
}
use of net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket in project LevelZ by Globox1997.
the class PlayerStatsServerPacket method writeS2CResetSkillPacket.
public static void writeS2CResetSkillPacket(ServerPlayerEntity serverPlayerEntity, String skill) {
// Sync attributes on server
PlayerStatsManager playerStatsManager = ((PlayerStatsManagerAccess) serverPlayerEntity).getPlayerStatsManager(serverPlayerEntity);
if (skill.equals("health")) {
serverPlayerEntity.getAttributeInstance(EntityAttributes.GENERIC_MAX_HEALTH).setBaseValue(ConfigInit.CONFIG.healthBase + (double) playerStatsManager.getLevel("health") * ConfigInit.CONFIG.healthBonus);
serverPlayerEntity.setHealth(serverPlayerEntity.getMaxHealth());
} else if (skill.equals("strength")) {
serverPlayerEntity.getAttributeInstance(EntityAttributes.GENERIC_ATTACK_DAMAGE).setBaseValue(ConfigInit.CONFIG.attackBase + (double) playerStatsManager.getLevel("strength") * ConfigInit.CONFIG.attackBonus);
} else if (skill.equals("agility")) {
serverPlayerEntity.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED).setBaseValue(ConfigInit.CONFIG.movementBase + (double) playerStatsManager.getLevel("agility") * ConfigInit.CONFIG.movementBonus);
} else if (skill.equals("defense")) {
serverPlayerEntity.getAttributeInstance(EntityAttributes.GENERIC_ARMOR).setBaseValue(ConfigInit.CONFIG.defenseBase + (double) playerStatsManager.getLevel("defense") * ConfigInit.CONFIG.defenseBonus);
} else if (skill.equals("luck")) {
serverPlayerEntity.getAttributeInstance(EntityAttributes.GENERIC_LUCK).setBaseValue(ConfigInit.CONFIG.luckBase + (double) playerStatsManager.getLevel("luck") * ConfigInit.CONFIG.luckBonus);
}
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
buf.writeString(skill);
CustomPayloadS2CPacket packet = new CustomPayloadS2CPacket(RESET_PACKET, buf);
serverPlayerEntity.networkHandler.sendPacket(packet);
}
use of net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket in project FallingAttackFabric by hamusuke0323.
the class ServerPlayerEntityMixin method sendFallingAttackPacket.
public void sendFallingAttackPacket(boolean start) {
PacketByteBuf packetByteBuf = PacketByteBufs.create();
packetByteBuf.writeVarInt(this.getId());
packetByteBuf.writeBoolean(start);
this.server.getPlayerManager().getPlayerList().forEach(serverPlayerEntity -> {
serverPlayerEntity.networkHandler.sendPacket(new CustomPayloadS2CPacket(NetworkManager.FALLING_ATTACK_S2C_PACKET_ID, packetByteBuf));
});
}
use of net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket in project FallingAttackFabric by hamusuke0323.
the class ServerPlayerEntityMixin method sendSynchronizeFallingAttackPacket.
public void sendSynchronizeFallingAttackPacket() {
PacketByteBuf packetByteBuf = PacketByteBufs.create();
packetByteBuf.writeBoolean(this.fallingAttack);
packetByteBuf.writeFloat(this.yPosWhenStartFallingAttack);
packetByteBuf.writeInt(this.fallingAttackProgress);
packetByteBuf.writeFloat(this.storeYaw);
this.networkHandler.sendPacket(new CustomPayloadS2CPacket(NetworkManager.SYNCHRONIZE_FALLING_ATTACK_S2C_PACKET_ID, packetByteBuf));
}
Aggregations