WIP with explosions
This commit is contained in:
1 parent
1d3bfc8221
commit
49250c8ad4
1 file changed
+15
-9
@@ -2,13 +2,17 @@ package carpet.mixins;
|
||||
|
||||
import carpet.helpers.OptimizedExplosion;
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.explosion.Explosion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.List;
|
||||
@@ -35,21 +39,23 @@ public abstract class ExplosionMixin
|
||||
cancellable = true)
|
||||
private void onExplosionB(boolean spawnParticles, CallbackInfo ci)
|
||||
{
|
||||
if (CarpetSettings.explosionNoBlockDamage)
|
||||
{
|
||||
affectedBlocks.clear();
|
||||
}
|
||||
if (CarpetSettings.optimizedTNT)
|
||||
{
|
||||
OptimizedExplosion.doExplosionB((Explosion) (Object) this, spawnParticles);
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "collectBlocksAndDamageEntities", at = @At(value = "INVOKE", shift = At.Shift.AFTER,
|
||||
target = "Ljava/util/List;addAll(Ljava/util/Collection;)Z"))
|
||||
private void clearList(CallbackInfo ci)
|
||||
//optional due to Overwrite in Lithium
|
||||
//should kill most checks if no block damage is requested
|
||||
@Redirect(method = "collectBlocksAndDamageEntities", require = 0, at = @At(value = "INVOKE",
|
||||
target ="Lnet/minecraft/world/World;getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;"))
|
||||
private BlockState noBlockCalcsWithNoBLockDamage(World world, BlockPos pos)
|
||||
{
|
||||
if (CarpetSettings.explosionNoBlockDamage)
|
||||
{
|
||||
this.affectedBlocks.clear();
|
||||
}
|
||||
if (CarpetSettings.explosionNoBlockDamage) return Blocks.BEDROCK.getDefaultState();
|
||||
return world.getBlockState(pos);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user