Search in sources :

Example 1 with StoneGolemEntity

use of party.lemons.biomemakeover.entity.StoneGolemEntity in project Biome-Makeover by Lemonszz.

the class StoneGolemPhase method onEnterPhase.

@Override
public void onEnterPhase() {
    super.onEnterPhase();
    adjudicator.setState(AdjudicatorState.FIGHTING);
    StoneGolemEntity golem = BMEntities.STONE_GOLEM.create(world);
    ((LootBlocker) golem).setLootBlocked(true);
    golem.setStackInHand(Hand.MAIN_HAND, new ItemStack(Items.CROSSBOW));
    golem.updatePositionAndAngles(adjudicator.getX(), adjudicator.getY(), adjudicator.getZ(), adjudicator.yaw, adjudicator.pitch);
    world.spawnEntity(golem);
    adjudicator.startRiding(golem, true);
    adjudicator.clearArea(golem);
    ItemStack stack = new ItemStack(Items.BOW);
    stack.addEnchantment(Enchantments.PUNCH, 1);
    adjudicator.setStackInHand(Hand.MAIN_HAND, stack);
    adjudicator.playSound(BMEffects.ADJUDICATOR_SPELL_GRUNT, 1F, 1F);
}
Also used : LootBlocker(party.lemons.biomemakeover.util.extensions.LootBlocker) StoneGolemEntity(party.lemons.biomemakeover.entity.StoneGolemEntity) ItemStack(net.minecraft.item.ItemStack)

Example 2 with StoneGolemEntity

use of party.lemons.biomemakeover.entity.StoneGolemEntity in project Biome-Makeover by Lemonszz.

the class BMWorldEvents method init.

public static void init() {
    DispenserBlock.registerBehavior(Items.CROSSBOW, new FallibleItemDispenserBehavior() {

        public ItemStack dispenseSilently(BlockPointer pointer, ItemStack stack) {
            BlockPos blockPos = pointer.getBlockPos().offset(pointer.getBlockState().get(DispenserBlock.FACING));
            List<StoneGolemEntity> list = pointer.getWorld().getEntitiesByClass(StoneGolemEntity.class, new Box(blockPos), (golem) -> !golem.isHolding(Items.CROSSBOW) && golem.isPlayerCreated() && golem.isAlive());
            if (!list.isEmpty()) {
                list.get(0).equipStack(EquipmentSlot.MAINHAND, stack.copy());
                stack.decrement(1);
                this.setSuccess(true);
                return stack;
            } else {
                return super.dispenseSilently(pointer, stack);
            }
        }
    });
    // Adjudicator Drop Illunite Shard
    ServerEntityCombatEvents.AFTER_KILLED_OTHER_ENTITY.register((world, entity, killedEntity) -> {
        if (!world.isClient() && entity instanceof PlayerEntity && killedEntity instanceof EvokerEntity) {
            if (!LootBlocker.isBlocked(killedEntity)) {
                if (world.random.nextFloat() < 0.15F) {
                    killedEntity.dropStack(new ItemStack(BMItems.ILLUNITE_SHARD, 1 + world.random.nextInt(2)));
                }
            }
        }
    });
}
Also used : CarvedPumpkinBlockAccess(party.lemons.biomemakeover.util.access.CarvedPumpkinBlockAccess) StoneGolemEntity(party.lemons.biomemakeover.entity.StoneGolemEntity) ServerWorld(net.minecraft.server.world.ServerWorld) BlockPointer(net.minecraft.util.math.BlockPointer) EvokerEntity(net.minecraft.entity.mob.EvokerEntity) Random(java.util.Random) ItemStack(net.minecraft.item.ItemStack) net.minecraft.block(net.minecraft.block) BlockPlacer(net.minecraft.world.gen.placer.BlockPlacer) LootBlocker(party.lemons.biomemakeover.util.extensions.LootBlocker) SmallLilyPadBlock(party.lemons.biomemakeover.block.SmallLilyPadBlock) EquipmentSlot(net.minecraft.entity.EquipmentSlot) DoublePlantPlacer(net.minecraft.world.gen.placer.DoublePlantPlacer) FallibleItemDispenserBehavior(net.minecraft.block.dispenser.FallibleItemDispenserBehavior) PlayerEntity(net.minecraft.entity.player.PlayerEntity) World(net.minecraft.world.World) Box(net.minecraft.util.math.Box) BlockPos(net.minecraft.util.math.BlockPos) Items(net.minecraft.item.Items) BlockPatternBuilder(net.minecraft.block.pattern.BlockPatternBuilder) BlockPattern(net.minecraft.block.pattern.BlockPattern) SimpleBlockPlacer(net.minecraft.world.gen.placer.SimpleBlockPlacer) List(java.util.List) BMBlocks(party.lemons.biomemakeover.init.BMBlocks) MaterialPredicate(net.minecraft.util.function.MaterialPredicate) ServerEntityCombatEvents(net.fabricmc.fabric.api.entity.event.v1.ServerEntityCombatEvents) BlockStatePredicate(net.minecraft.predicate.block.BlockStatePredicate) CachedBlockPosition(net.minecraft.block.pattern.CachedBlockPosition) BMItems(party.lemons.biomemakeover.init.BMItems) StoneGolemEntity(party.lemons.biomemakeover.entity.StoneGolemEntity) EvokerEntity(net.minecraft.entity.mob.EvokerEntity) BlockPos(net.minecraft.util.math.BlockPos) List(java.util.List) Box(net.minecraft.util.math.Box) BlockPointer(net.minecraft.util.math.BlockPointer) ItemStack(net.minecraft.item.ItemStack) FallibleItemDispenserBehavior(net.minecraft.block.dispenser.FallibleItemDispenserBehavior) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 3 with StoneGolemEntity

use of party.lemons.biomemakeover.entity.StoneGolemEntity in project Biome-Makeover by Lemonszz.

the class CarvedPumpkinBlockMixin method trySpawnEntity.

// TODO: make more general system for golems to allow this to be easier to add later?
@Inject(at = @At("HEAD"), method = "trySpawnEntity", cancellable = true)
private void trySpawnEntity(World world, BlockPos pos, CallbackInfo cbi) {
    BlockPattern pattern = BMWorldEvents.getStoneGolemPattern();
    BlockPattern.Result result = pattern.searchAround(world, pos);
    if (result != null) {
        for (int x = 0; x < pattern.getWidth(); ++x) {
            for (int y = 0; y < pattern.getHeight(); ++y) {
                CachedBlockPosition golPos = result.translate(x, y, 0);
                world.setBlockState(golPos.getBlockPos(), Blocks.AIR.getDefaultState(), 2);
                world.syncWorldEvent(2001, golPos.getBlockPos(), Block.getRawIdFromState(golPos.getBlockState()));
            }
        }
        BlockPos spawnPos = result.translate(1, 2, 0).getBlockPos();
        StoneGolemEntity stoneGolem = BMEntities.STONE_GOLEM.create(world);
        stoneGolem.setPlayerCreated(true);
        stoneGolem.refreshPositionAndAngles((double) spawnPos.getX() + 0.5D, (double) spawnPos.getY() + 0.05D, (double) spawnPos.getZ() + 0.5D, 0.0F, 0.0F);
        world.spawnEntity(stoneGolem);
        Iterator<ServerPlayerEntity> playersNearby = world.getNonSpectatingEntities(ServerPlayerEntity.class, stoneGolem.getBoundingBox().expand(5.0D)).iterator();
        while (playersNearby.hasNext()) {
            ServerPlayerEntity pl = playersNearby.next();
            Criteria.SUMMONED_ENTITY.trigger(pl, stoneGolem);
        }
        for (int x = 0; x < pattern.getWidth(); ++x) {
            for (int y = 0; y < pattern.getHeight(); ++y) {
                CachedBlockPosition golemPos = result.translate(x, y, 0);
                world.updateNeighbors(golemPos.getBlockPos(), Blocks.AIR);
            }
        }
    }
}
Also used : CachedBlockPosition(net.minecraft.block.pattern.CachedBlockPosition) StoneGolemEntity(party.lemons.biomemakeover.entity.StoneGolemEntity) BlockPattern(net.minecraft.block.pattern.BlockPattern) BlockPos(net.minecraft.util.math.BlockPos) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 4 with StoneGolemEntity

use of party.lemons.biomemakeover.entity.StoneGolemEntity in project Biome-Makeover by Lemonszz.

the class StoneGolemPhase method onExitPhase.

@Override
public void onExitPhase() {
    adjudicator.setStackInHand(Hand.MAIN_HAND, ItemStack.EMPTY);
    if (adjudicator.getVehicle() instanceof StoneGolemEntity) {
        StoneGolemEntity golem = (StoneGolemEntity) adjudicator.getVehicle();
        adjudicator.stopRiding();
        golem.remove();
    }
}
Also used : StoneGolemEntity(party.lemons.biomemakeover.entity.StoneGolemEntity)

Aggregations

StoneGolemEntity (party.lemons.biomemakeover.entity.StoneGolemEntity)4 BlockPattern (net.minecraft.block.pattern.BlockPattern)2 CachedBlockPosition (net.minecraft.block.pattern.CachedBlockPosition)2 ItemStack (net.minecraft.item.ItemStack)2 BlockPos (net.minecraft.util.math.BlockPos)2 LootBlocker (party.lemons.biomemakeover.util.extensions.LootBlocker)2 List (java.util.List)1 Random (java.util.Random)1 ServerEntityCombatEvents (net.fabricmc.fabric.api.entity.event.v1.ServerEntityCombatEvents)1 net.minecraft.block (net.minecraft.block)1 FallibleItemDispenserBehavior (net.minecraft.block.dispenser.FallibleItemDispenserBehavior)1 BlockPatternBuilder (net.minecraft.block.pattern.BlockPatternBuilder)1 EquipmentSlot (net.minecraft.entity.EquipmentSlot)1 EvokerEntity (net.minecraft.entity.mob.EvokerEntity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 Items (net.minecraft.item.Items)1 BlockStatePredicate (net.minecraft.predicate.block.BlockStatePredicate)1 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)1 ServerWorld (net.minecraft.server.world.ServerWorld)1 MaterialPredicate (net.minecraft.util.function.MaterialPredicate)1