Search in sources :

Example 1 with BedBlock

use of net.minecraft.block.BedBlock in project meteor-rejects by AntiCope.

the class AntiSpawnpoint method onSendPacket.

@EventHandler
private void onSendPacket(PacketEvent.Send event) {
    if (mc.world == null)
        return;
    if (!(event.packet instanceof PlayerInteractBlockC2SPacket))
        return;
    BlockPos blockPos = ((PlayerInteractBlockC2SPacket) event.packet).getBlockHitResult().getBlockPos();
    boolean IsOverWorld = mc.world.getDimension().isBedWorking();
    boolean IsNetherWorld = mc.world.getDimension().isRespawnAnchorWorking();
    boolean BlockIsBed = mc.world.getBlockState(blockPos).getBlock() instanceof BedBlock;
    boolean BlockIsAnchor = mc.world.getBlockState(blockPos).getBlock().equals(Blocks.RESPAWN_ANCHOR);
    if (fakeUse.get()) {
        if (BlockIsBed && IsOverWorld) {
            mc.player.swingHand(Hand.MAIN_HAND);
            mc.player.updatePosition(blockPos.getX(), blockPos.up().getY(), blockPos.getZ());
        } else if (BlockIsAnchor && IsNetherWorld) {
            mc.player.swingHand(Hand.MAIN_HAND);
        }
    }
    if ((BlockIsBed && IsOverWorld) || (BlockIsAnchor && IsNetherWorld)) {
        event.cancel();
    }
}
Also used : BedBlock(net.minecraft.block.BedBlock) BlockPos(net.minecraft.util.math.BlockPos) PlayerInteractBlockC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket) EventHandler(meteordevelopment.orbit.EventHandler)

Example 2 with BedBlock

use of net.minecraft.block.BedBlock in project meteor-client by MeteorDevelopment.

the class AntiBed method onTick.

@EventHandler
private void onTick(TickEvent.Pre event) {
    if (onlyInHole.get() && !PlayerUtils.isInHole(true))
        return;
    // Checking for and maybe breaking bed
    BlockPos head = mc.player.getBlockPos().up();
    if (mc.world.getBlockState(head).getBlock() instanceof BedBlock && !breaking) {
        Rotations.rotate(Rotations.getYaw(head), Rotations.getPitch(head), 50, () -> sendMinePackets(head));
        breaking = true;
    } else if (breaking) {
        Rotations.rotate(Rotations.getYaw(head), Rotations.getPitch(head), 50, () -> sendStopPackets(head));
        breaking = false;
    }
    // String placement
    if (placeStringTop.get())
        place(mc.player.getBlockPos().up(2));
    if (placeStringMiddle.get())
        place(mc.player.getBlockPos().up(1));
    if (placeStringBottom.get())
        place(mc.player.getBlockPos());
}
Also used : BedBlock(net.minecraft.block.BedBlock) BlockPos(net.minecraft.util.math.BlockPos) EventHandler(meteordevelopment.orbit.EventHandler)

Example 3 with BedBlock

use of net.minecraft.block.BedBlock in project Client by MatHax.

the class SelfProtect method onTick.

@EventHandler
private void onTick(TickEvent.Pre event) {
    if (antiAnchorAura.get() && mc.world.getBlockState(mc.player.getBlockPos().up(2)).getBlock() == Blocks.RESPAWN_ANCHOR && mc.world.getBlockState(mc.player.getBlockPos().up()).getBlock() == Blocks.AIR)
        BlockUtils.place(mc.player.getBlockPos().add(0, 1, 0), InvUtils.findInHotbar(itemStack -> Block.getBlockFromItem(itemStack.getItem()) instanceof SlabBlock), rotate.get(), 15, swing.get(), false, true);
    BlockPos top = mc.player.getBlockPos().up(2);
    if (antiCEVBreaker.get() && mc.world.getBlockState(top).getBlock() == Blocks.OBSIDIAN) {
        Iterator<Entity> iterator = mc.world.getEntities().iterator();
        coder: while (true) {
            while (true) {
                if (!iterator.hasNext())
                    break coder;
                Entity crystal = iterator.next();
                if (crystal instanceof EndCrystalEntity && crystal.getBlockPos().equals(top.up())) {
                    mc.player.networkHandler.sendPacket(PlayerInteractEntityC2SPacket.attack(crystal, mc.player.isSneaking()));
                    ceved = true;
                } else if (ceved) {
                    BlockUtils.place(top.up(), InvUtils.findInHotbar(Items.OBSIDIAN), rotate.get(), 50, true);
                    ceved = false;
                }
            }
        }
    }
    if (antiTNTAura.get()) {
        if (mc.world.getBlockState(top).getBlock().equals(Blocks.TNT)) {
            if (rotate.get())
                Rotations.rotate(Rotations.getYaw(top), Rotations.getPitch(top), () -> mine(top));
            else
                mine(top);
            tntAured = true;
        } else if (tntAured) {
            if (placeObsidian.get())
                BlockUtils.place(top, InvUtils.findInHotbar(Items.OBSIDIAN), rotate.get(), 50, true);
            tntAured = false;
        }
    }
    if (antiBedAura.get()) {
        if (onlyInHole.get() && !PlayerUtils.isInHole2(true))
            return;
        BlockPos head = mc.player.getBlockPos().up();
        if (mc.world.getBlockState(head).getBlock() instanceof BedBlock && !breaking) {
            Rotations.rotate(Rotations.getYaw(head), Rotations.getPitch(head), 50, () -> sendMinePackets(head));
            breaking = true;
        } else if (breaking) {
            Rotations.rotate(Rotations.getYaw(head), Rotations.getPitch(head), 50, () -> sendStopPackets(head));
            breaking = false;
        }
        if (smart.get()) {
            if (mc.world.getBlockState(head).getBlock() instanceof BedBlock)
                bedAured = true;
            else if (bedAured) {
                if (placeStringTop.get())
                    place(mc.player.getBlockPos().up(2));
                if (placeStringMiddle.get())
                    place(mc.player.getBlockPos().up(1));
                if (placeStringBottom.get())
                    place(mc.player.getBlockPos());
                tntAured = false;
            }
        } else if (!smart.get()) {
            if (placeStringTop.get())
                place(mc.player.getBlockPos().up(2));
            if (placeStringMiddle.get())
                place(mc.player.getBlockPos().up(1));
            if (placeStringBottom.get())
                place(mc.player.getBlockPos());
        }
    }
}
Also used : BedBlock(net.minecraft.block.BedBlock) Entity(net.minecraft.entity.Entity) EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) SlabBlock(net.minecraft.block.SlabBlock) BlockPos(net.minecraft.util.math.BlockPos) EventHandler(mathax.client.eventbus.EventHandler)

Example 4 with BedBlock

use of net.minecraft.block.BedBlock in project Client by MatHax.

the class AntiSpawnpoint method onSendPacket.

@EventHandler
private void onSendPacket(PacketEvent.Send event) {
    if (mc.world == null)
        return;
    if (!(event.packet instanceof PlayerInteractBlockC2SPacket))
        return;
    BlockPos blockPos = ((PlayerInteractBlockC2SPacket) event.packet).getBlockHitResult().getBlockPos();
    boolean IsOverWorld = mc.world.getDimension().isBedWorking();
    boolean IsNetherWorld = mc.world.getDimension().isRespawnAnchorWorking();
    boolean BlockIsBed = mc.world.getBlockState(blockPos).getBlock() instanceof BedBlock;
    boolean BlockIsAnchor = mc.world.getBlockState(blockPos).getBlock().equals(Blocks.RESPAWN_ANCHOR);
    if (fakeUse.get()) {
        if (BlockIsBed && IsOverWorld) {
            mc.player.swingHand(Hand.MAIN_HAND);
            mc.player.updatePosition(blockPos.getX(), blockPos.up().getY(), blockPos.getZ());
        } else if (BlockIsAnchor && IsNetherWorld)
            mc.player.swingHand(Hand.MAIN_HAND);
    }
    if ((BlockIsBed && IsOverWorld) || (BlockIsAnchor && IsNetherWorld))
        event.cancel();
}
Also used : BedBlock(net.minecraft.block.BedBlock) BlockPos(net.minecraft.util.math.BlockPos) PlayerInteractBlockC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket) EventHandler(mathax.client.eventbus.EventHandler)

Example 5 with BedBlock

use of net.minecraft.block.BedBlock in project minecolonies by Minecolonies.

the class BuildingHospital method registerBlockPosition.

@Override
public void registerBlockPosition(@NotNull final BlockState blockState, @NotNull final BlockPos pos, @NotNull final World world) {
    super.registerBlockPosition(blockState, pos, world);
    BlockPos registrationPosition = pos;
    if (blockState.getBlock() instanceof BedBlock) {
        if (blockState.getValue(BedBlock.PART) == BedPart.FOOT) {
            registrationPosition = registrationPosition.relative(blockState.getValue(BedBlock.FACING));
        }
        if (!bedMap.containsKey(registrationPosition)) {
            bedMap.put(registrationPosition, 0);
        }
    }
}
Also used : BedBlock(net.minecraft.block.BedBlock) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

BedBlock (net.minecraft.block.BedBlock)6 BlockPos (net.minecraft.util.math.BlockPos)6 EventHandler (mathax.client.eventbus.EventHandler)2 EventHandler (meteordevelopment.orbit.EventHandler)2 PlayerInteractBlockC2SPacket (net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket)2 SlabBlock (net.minecraft.block.SlabBlock)1 Entity (net.minecraft.entity.Entity)1 EndCrystalEntity (net.minecraft.entity.decoration.EndCrystalEntity)1