server fix
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
package dev.tggamesyt.szar.client;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.client.sound.PositionedSoundInstance;
|
||||
import net.minecraft.client.sound.SoundInstance;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.Identifier;
|
||||
@@ -106,7 +106,7 @@ public class VideoManager {
|
||||
ClientWorld world = client.world;
|
||||
if (world == null) return;
|
||||
|
||||
ClientPlayerEntity player = (ClientPlayerEntity) world.getPlayerByUuid(playerUuid);
|
||||
PlayerEntity player = world.getPlayerByUuid(playerUuid);
|
||||
if (player == null) return;
|
||||
|
||||
Identifier soundId = new Identifier(MOD_ID, "firtana");
|
||||
|
||||
@@ -123,7 +123,7 @@ public class FaszItem extends BlockItem {
|
||||
if (e.getBoundingBox().contains(px, py, pz)) {
|
||||
if (e instanceof LivingEntity living) {
|
||||
// Always deal half a heart
|
||||
RegistryEntry<DamageType> radiationEntry = SERVER.getRegistryManager()
|
||||
RegistryEntry<DamageType> radiationEntry = living.getServer().getRegistryManager()
|
||||
.get(RegistryKeys.DAMAGE_TYPE)
|
||||
.getEntry(FCK_DAMAGE)
|
||||
.orElseThrow(() -> new IllegalStateException("FCK DamageType not registered!"));
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
@@ -290,9 +291,13 @@ public class PlaneEntity extends Entity {
|
||||
}
|
||||
private void playServerAnimation(PlaneAnimation anim) {
|
||||
if (this.currentServerAnimation == anim) return;
|
||||
if (this.getWorld().isClient) return;
|
||||
|
||||
MinecraftServer server = this.getWorld().getServer();
|
||||
if (server == null) return;
|
||||
|
||||
this.currentServerAnimation = anim;
|
||||
Szar.playPlaneAnimation(anim, this.getId());
|
||||
Szar.playPlaneAnimation(anim, this.getId(), server);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
|
||||
@@ -29,18 +29,14 @@ public class RadiationStatusEffect extends StatusEffect {
|
||||
@Override
|
||||
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
|
||||
int level = amplifier + 1;
|
||||
|
||||
float damage = (float) getInterpolatedDamage(level);
|
||||
|
||||
RegistryEntry<DamageType> radiationEntry = SERVER.getRegistryManager()
|
||||
RegistryEntry<DamageType> radiationEntry = entity.getWorld().getRegistryManager()
|
||||
.get(RegistryKeys.DAMAGE_TYPE)
|
||||
.getEntry(RADIATION_DAMAGE)
|
||||
.orElseThrow(() -> new IllegalStateException("Radiation DamageType not registered!"));
|
||||
|
||||
entity.damage(
|
||||
new DamageSource(radiationEntry),
|
||||
damage
|
||||
);
|
||||
entity.damage(new DamageSource(radiationEntry), damage);
|
||||
}
|
||||
|
||||
/* ========================= */
|
||||
|
||||
@@ -101,7 +101,6 @@ import static dev.tggamesyt.szar.ServerCosmetics.sync;
|
||||
public class Szar implements ModInitializer {
|
||||
public static final String MOD_ID = "szar";
|
||||
public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
|
||||
public static MinecraftServer SERVER;
|
||||
public static int april = 4;
|
||||
public static int fools = 1;
|
||||
public static final Identifier DRUNK_TYPE_PACKET = new Identifier(MOD_ID, "drunk_type");
|
||||
@@ -570,7 +569,7 @@ public class Szar implements ModInitializer {
|
||||
SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.PLAYERS, 0.5f, 1.8f);
|
||||
|
||||
if (isHeadshot) {
|
||||
RegistryEntry<DamageType> bullet_damage = SERVER.getRegistryManager()
|
||||
RegistryEntry<DamageType> bullet_damage = server.getRegistryManager()
|
||||
.get(RegistryKeys.DAMAGE_TYPE)
|
||||
.getEntry(BULLET_DAMAGE)
|
||||
.orElseThrow(() -> new IllegalStateException("Bullet DamageType not registered!"));
|
||||
@@ -643,13 +642,6 @@ public class Szar implements ModInitializer {
|
||||
}
|
||||
}
|
||||
});
|
||||
ServerLifecycleEvents.SERVER_STARTED.register(server -> {
|
||||
SERVER = server;
|
||||
});
|
||||
|
||||
ServerLifecycleEvents.SERVER_STOPPED.register(server -> {
|
||||
SERVER = null;
|
||||
});
|
||||
// register block
|
||||
Registry.register(
|
||||
Registries.BLOCK,
|
||||
@@ -2313,8 +2305,8 @@ public class Szar implements ModInitializer {
|
||||
|
||||
return Text.literal(filtered);
|
||||
}
|
||||
public static void playPlaneAnimation(PlaneAnimation animation, int entityId) {
|
||||
for (ServerWorld world : SERVER.getWorlds()) {
|
||||
public static void playPlaneAnimation(PlaneAnimation animation, int entityId, MinecraftServer server) {
|
||||
for (ServerWorld world : server.getWorlds()) {
|
||||
for (ServerPlayerEntity player : world.getPlayers()) {
|
||||
PacketByteBuf buf = PacketByteBufs.create();
|
||||
buf.writeInt(entityId); // <-- important change
|
||||
|
||||
@@ -17,16 +17,13 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import static dev.tggamesyt.szar.Szar.RADIATION_DAMAGE;
|
||||
import static dev.tggamesyt.szar.Szar.SERVER;
|
||||
|
||||
@Mixin(Item.class)
|
||||
public abstract class RadiatedItemMixin {
|
||||
@Inject(method = "use", at = @At("RETURN"))
|
||||
private void onUse(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> cir) {
|
||||
ItemStack stack = cir.getReturnValue().getValue();
|
||||
if (!world.isClient && stack.hasNbt() && stack.getNbt().getBoolean("Radiated")) {
|
||||
RegistryEntry<DamageType> radiationEntry = Szar.SERVER.getRegistryManager()
|
||||
RegistryEntry<DamageType> radiationEntry = world.getRegistryManager()
|
||||
.get(RegistryKeys.DAMAGE_TYPE)
|
||||
.getEntry(Szar.RADIATION_DAMAGE)
|
||||
.orElseThrow();
|
||||
|
||||
Reference in New Issue
Block a user