23w45a fixes and unmaintainable optimized TNT rule pseudofix.

This commit is contained in:
gnembon committed 2023-11-08 21:41:49 +01:00
1 parent e1bd03cbef
commit 5c1da81b9f
9 files changed
+53 -20

No files matched your search

+2 -2
View File
@@ -3,10 +3,10 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check https://fabricmc.net/develop/
minecraft_version=23w44a
minecraft_version=23w45a
loader_version=0.14.24
jsr305_version=3.0.2
fabric_version=0.90.6+1.20.3
fabric_version=0.90.8+1.20.3
# Mod Properties
mod_version = 1.4.124
@@ -76,7 +76,7 @@ public class OptimizedExplosion
boolean eventNeeded = EXPLOSION_OUTCOME.isNeeded() && !eAccess.getLevel().isClientSide();
blastCalc(e);
if (!CarpetSettings.explosionNoBlockDamage) {
if (!CarpetSettings.explosionNoBlockDamage && eAccess.getDamageSource() != null) {
rayCalcDone = false;
firstRay = true;
getAffectedPositionsOnPlaneY(e, 0, 0, 15, 0, 15); // bottom
@@ -132,7 +132,7 @@ public class OptimizedExplosion
continue;
}
if (!entity.ignoreExplosion()) {
if (!entity.ignoreExplosion(e)) {
double d12 = Math.sqrt(entity.distanceToSqr(eAccess.getX(), eAccess.getY(), eAccess.getZ())) / (double) f3;
if (d12 <= 1.0D) {
@@ -165,8 +165,11 @@ public class OptimizedExplosion
}
double d10 = (1.0D - d12) * density;
entity.hurt(e.getDamageSource(),
(float) ((int) ((d10 * d10 + d10) / 2.0D * 7.0D * (double) f3 + 1.0D)));
if (eAccess.getDamageSource() != null)
{
entity.hurt(eAccess.getDamageSource(),
(float) ((int) ((d10 * d10 + d10) / 2.0D * 7.0D * (double) f3 + 1.0D)));
}
double d11 = d10;
if (entity instanceof LivingEntity) {
@@ -1,10 +1,10 @@
package carpet.mixins;
import net.minecraft.util.RandomSource;
import net.minecraft.world.damagesource.DamageSource;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.Random;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level;
@@ -39,4 +39,7 @@ public interface ExplosionAccessor {
@Accessor
Entity getSource();
@Accessor
DamageSource getDamageSource();
}
@@ -5,6 +5,11 @@ import carpet.CarpetSettings;
import carpet.logging.LoggerRegistry;
import carpet.logging.logHelpers.ExplosionLogHelper;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.monster.breeze.Breeze;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -32,13 +37,15 @@ public abstract class Explosion_optimizedTntMixin
@Shadow @Final private Level level;
@Shadow @Nullable public abstract LivingEntity getIndirectSourceEntity();
private ExplosionLogHelper eLogger;
@Inject(method = "explode", at = @At("HEAD"),
cancellable = true)
private void onExplosionA(CallbackInfo ci)
{
if (CarpetSettings.optimizedTNT)
if (CarpetSettings.optimizedTNT && !level.isClientSide && !(getIndirectSourceEntity() instanceof Breeze))
{
OptimizedExplosion.doExplosionA((Explosion) (Object) this, eLogger);
ci.cancel();
@@ -58,7 +65,7 @@ public abstract class Explosion_optimizedTntMixin
{
toBlow.clear();
}
if (CarpetSettings.optimizedTNT)
if (CarpetSettings.optimizedTNT && !level.isClientSide && !(getIndirectSourceEntity() instanceof Breeze))
{
OptimizedExplosion.doExplosionB((Explosion) (Object) this, spawnParticles);
ci.cancel();
@@ -74,9 +81,9 @@ public abstract class Explosion_optimizedTntMixin
return world.getBlockState(pos);
}
@Inject(method = "<init>(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;Lnet/minecraft/world/level/ExplosionDamageCalculator;DDDFZLnet/minecraft/world/level/Explosion$BlockInteraction;)V",
@Inject(method = "<init>(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;Lnet/minecraft/world/level/ExplosionDamageCalculator;DDDFZLnet/minecraft/world/level/Explosion$BlockInteraction;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/sounds/SoundEvent;)V",
at = @At(value = "RETURN"))
private void onExplosionCreated(Level world, Entity entity, DamageSource damageSource, ExplosionDamageCalculator explosionBehavior, double x, double y, double z, float power, boolean createFire, Explosion.BlockInteraction destructionType, CallbackInfo ci)
private void onExplosionCreated(Level world, Entity entity, DamageSource damageSource, ExplosionDamageCalculator explosionBehavior, double x, double y, double z, float power, boolean createFire, Explosion.BlockInteraction destructionType, ParticleOptions particleOptions, ParticleOptions particleOptions2, SoundEvent soundEvent, CallbackInfo ci)
{
if (LoggerRegistry.__explosions && ! world.isClientSide)
{
@@ -1,6 +1,8 @@
package carpet.mixins;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.sounds.SoundEvent;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@@ -43,9 +45,9 @@ public abstract class Explosion_scarpetEventMixin
private List<Entity> affectedEntities;
@Inject(method = "<init>(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;Lnet/minecraft/world/level/ExplosionDamageCalculator;DDDFZLnet/minecraft/world/level/Explosion$BlockInteraction;)V",
@Inject(method = "<init>(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;Lnet/minecraft/world/level/ExplosionDamageCalculator;DDDFZLnet/minecraft/world/level/Explosion$BlockInteraction;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/sounds/SoundEvent;)V",
at = @At(value = "RETURN"))
private void onExplosionCreated(Level world, Entity entity, DamageSource damageSource, ExplosionDamageCalculator explosionBehavior, double x, double y, double z, float power, boolean createFire, Explosion.BlockInteraction destructionType, CallbackInfo ci)
private void onExplosionCreated(Level world, Entity entity, DamageSource damageSource, ExplosionDamageCalculator explosionBehavior, double x, double y, double z, float power, boolean createFire, Explosion.BlockInteraction destructionType, ParticleOptions particleOptions, ParticleOptions particleOptions2, SoundEvent soundEvent, CallbackInfo ci)
{
if (EXPLOSION_OUTCOME.isNeeded() && !world.isClientSide())
{
@@ -4,16 +4,16 @@ import carpet.CarpetSettings;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(Explosion.class)
@Mixin(BlockBehaviour.class)
public class Explosion_xpFromBlocksMixin {
@Redirect(method = "finalizeExplosion", at = @At(
@Redirect(method = "onExplosionHit", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/block/state/BlockState;spawnAfterBreak(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/item/ItemStack;Z)V"
))
@@ -4,8 +4,10 @@ import carpet.fakes.ServerWorldInterface;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.damagesource.DamageSource;
@@ -64,7 +66,7 @@ public abstract class ServerLevel_scarpetMixin extends Level implements ServerWo
}
@Inject(method = "explode", at = @At("HEAD"))
private void handleExplosion(/*@Nullable*/ Entity entity, /*@Nullable*/ DamageSource damageSource, /*@Nullable*/ ExplosionDamageCalculator explosionBehavior, double d, double e, double f, float g, boolean bl, Level.ExplosionInteraction explosionInteraction, CallbackInfoReturnable<Explosion> cir)
private void handleExplosion(/*@Nullable*/ Entity entity, /*@Nullable*/ DamageSource damageSource, /*@Nullable*/ ExplosionDamageCalculator explosionBehavior, double d, double e, double f, float g, boolean bl, ExplosionInteraction explosionInteraction, ParticleOptions particleOptions, ParticleOptions particleOptions2, SoundEvent soundEvent, CallbackInfoReturnable<Explosion> cir)
{
if (EXPLOSION.isNeeded()) {
Explosion.BlockInteraction var10000 = switch (explosionInteraction) {
@@ -38,6 +38,7 @@ import net.minecraft.core.Holder;
import net.minecraft.core.HolderSet;
import net.minecraft.core.QuartPos;
import net.minecraft.core.Registry;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
@@ -46,6 +47,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.level.Ticket;
import net.minecraft.server.level.TicketType;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.chunk.PalettedContainer;
@@ -1066,7 +1068,7 @@ public class WorldAccess
float thePowah = powah;
// copy of ServerWorld.createExplosion #TRACK#
Explosion explosion = new Explosion(cc.level(), source, null, null, pos.x, pos.y, pos.z, powah, createFire, mode)
Explosion explosion = new Explosion(cc.level(), source, null, null, pos.x, pos.y, pos.z, powah, createFire, mode, ParticleTypes.EXPLOSION, ParticleTypes.EXPLOSION_EMITTER, SoundEvents.GENERIC_EXPLODE)
{
@Override
@Nullable
@@ -1082,10 +1084,11 @@ public class WorldAccess
{
explosion.clearToBlow();
}
Explosion.BlockInteraction finalMode = mode;
cc.level().players().forEach(spe -> {
if (spe.distanceToSqr(pos) < 4096.0D)
{
spe.connection.send(new ClientboundExplodePacket(pos.x, pos.y, pos.z, thePowah, explosion.getToBlow(), explosion.getHitPlayers().get(spe)));
spe.connection.send(new ClientboundExplodePacket(pos.x, pos.y, pos.z, thePowah, explosion.getToBlow(), explosion.getHitPlayers().get(spe), finalMode, ParticleTypes.EXPLOSION, ParticleTypes.EXPLOSION_EMITTER, SoundEvents.GENERIC_EXPLODE));
}
});
return Value.TRUE;
@@ -12,8 +12,8 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import net.minecraft.commands.CommandRuntimeException;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component;
import net.minecraft.world.level.storage.LevelResource;
import java.io.BufferedWriter;
@@ -473,4 +473,17 @@ public class AppStoreManager
}
CarpetScriptServer.LOG.info("Downloaded app " + target + " from " + contentUrl);
}
public static class CommandRuntimeException extends RuntimeException {
private final Component message;
public CommandRuntimeException(Component message) {
super(message.getString(), null, false, false);
this.message = message;
}
public Component getComponent() {
return message;
}
}
}