|
1
|
|
|
package de.pewpewproject.lasertag.mixin; |
|
2
|
|
|
|
|
3
|
|
|
import de.pewpewproject.lasertag.worldgen.chunkgen.ArenaChunkGenerator; |
|
4
|
|
|
import net.minecraft.block.BedBlock; |
|
5
|
|
|
import net.minecraft.block.BlockState; |
|
6
|
|
|
import net.minecraft.entity.player.PlayerEntity; |
|
7
|
|
|
import net.minecraft.util.ActionResult; |
|
8
|
|
|
import net.minecraft.util.Hand; |
|
9
|
|
|
import net.minecraft.util.hit.BlockHitResult; |
|
10
|
|
|
import net.minecraft.util.math.BlockPos; |
|
11
|
|
|
import net.minecraft.world.World; |
|
12
|
|
|
import net.minecraft.world.dimension.DimensionOptions; |
|
13
|
|
|
import org.spongepowered.asm.mixin.Mixin; |
|
14
|
|
|
import org.spongepowered.asm.mixin.injection.At; |
|
15
|
|
|
import org.spongepowered.asm.mixin.injection.Inject; |
|
16
|
|
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; |
|
17
|
|
|
|
|
18
|
|
|
import java.util.Objects; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Mixin into the BedBlock.class to disable the bed if it is in an arena world |
|
22
|
|
|
* |
|
23
|
|
|
* @author Étienne Muser |
|
24
|
|
|
*/ |
|
25
|
|
View Code Duplication |
@Mixin(BedBlock.class) |
|
|
|
|
|
|
26
|
|
|
public class BedBlockMixin { |
|
27
|
|
|
|
|
28
|
|
|
@Inject(method = "onUse(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;Lnet/minecraft/util/hit/BlockHitResult;)Lnet/minecraft/util/ActionResult;", at = @At("HEAD"), cancellable = true) |
|
29
|
|
|
private void onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> cir) { |
|
30
|
|
|
|
|
31
|
|
|
// If world is not server |
|
32
|
|
|
if (world.isClient) { |
|
33
|
|
|
return; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
// If is not an arena world |
|
37
|
|
|
if (!(Objects.requireNonNull(Objects.requireNonNull(world.getServer()).getSaveProperties().getGeneratorOptions().getDimensions().get(DimensionOptions.OVERWORLD)) |
|
38
|
|
|
.chunkGenerator instanceof ArenaChunkGenerator)) { |
|
39
|
|
|
return; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
cir.setReturnValue(ActionResult.PASS); |
|
43
|
|
|
} |
|
44
|
|
|
} |
|
45
|
|
|
|