1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
package wtf.kity.uncrackable.mixin;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.DragonEggBlock;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.border.WorldBorder;
import net.minecraft.world.level.material.PushReaction;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
@Mixin(DragonEggBlock.class)
public class DragonEggBlockMixin {
@ModifyVariable(method = "<init>", at = @At("HEAD"), ordinal = 0, argsOnly = true)
private static BlockBehaviour.Properties init(BlockBehaviour.Properties properties) {
return properties
.pushReaction(PushReaction.NORMAL)
.strength(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY);
}
/**
* @author ashkitten
* @reason fixing MC-2157
*/
@Overwrite
private void teleport(BlockState state, Level level, BlockPos pos) {
if (level instanceof ServerLevel serverLevel) {
WorldBorder worldborder = level.getWorldBorder();
for (int i = 0; i < 1000; i++) {
BlockPos blockpos = pos.offset(
level.random.nextInt(16) - level.random.nextInt(16),
level.random.nextInt(8) - level.random.nextInt(8),
level.random.nextInt(16) - level.random.nextInt(16)
);
if (level.getBlockState(blockpos).isAir() && worldborder.isWithinBounds(blockpos)) {
// slightly different behavior than vanilla, since we send 32x4 particles evenly distributed
// instead of 1x128 randomly distributed, but it actually points in the right fucking direction lol
for (int j = 0; j < 32; j++) {
double d0 = j / 32.0;
double d1 = Mth.lerp(d0, blockpos.getX(), pos.getX()) + (level.random.nextDouble() - 0.5) + 0.5;
double d2 = Mth.lerp(d0, blockpos.getY(), pos.getY()) + level.random.nextDouble() - 0.5;
double d3 = Mth.lerp(d0, blockpos.getZ(), pos.getZ()) + (level.random.nextDouble() - 0.5) + 0.5;
serverLevel.sendParticles(ParticleTypes.PORTAL, d1, d2, d3, 4, 0.1, 0.1, 0.1, 0.0);
}
level.setBlock(blockpos, state, 2);
level.removeBlock(pos, false);
level.playSound(null, pos, SoundEvents.ENDERMAN_TELEPORT, SoundSource.BLOCKS);
return;
}
}
}
}
}
|