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);
}
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)));
}
}
}
});
}
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);
}
}
}
}
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();
}
}
Aggregations