net.minecraft.entity.LightningEntity Java Examples

The following examples show how to use net.minecraft.entity.LightningEntity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SkeletonEntityMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void onStruckByLightning(LightningEntity lightning)
{
    if (!this.world.isClient && !this.removed && CarpetExtraSettings.renewableWitherSkeletons)
    {
        WitherSkeletonEntity witherSkelly = new WitherSkeletonEntity(EntityType.WITHER_SKELETON, this.world);
        witherSkelly.refreshPositionAndAngles(this.getX(), this.getY(), this.getZ(), this.yaw, this.pitch);
        witherSkelly.initialize(this.world, this.world.getLocalDifficulty(new BlockPos(witherSkelly)), SpawnType.CONVERSION, (EntityData) null, (CompoundTag) null);
        witherSkelly.setAiDisabled(this.isAiDisabled());
        
        if (this.hasCustomName())
        {
            witherSkelly.setCustomName(this.getCustomName());
            witherSkelly.setCustomNameVisible(this.isCustomNameVisible());
        }
        
        this.world.spawnEntity(witherSkelly);
        this.remove();
    }
    else
    {
        super.onStruckByLightning(lightning);
    }
}
 
Example #2
Source File: GuardianEntityMixin.java    From fabric-carpet with MIT License 6 votes vote down vote up
@Override
public void onStruckByLightning(LightningEntity lightning)
{
    if (!this.world.isClient && !this.removed && CarpetSettings.renewableSponges && !((Object)this instanceof ElderGuardianEntity))
    {
        ElderGuardianEntity elderGuardian = new ElderGuardianEntity(EntityType.ELDER_GUARDIAN ,this.world);
        elderGuardian.refreshPositionAndAngles(this.getX(), this.getY(), this.getZ(), this.yaw, this.pitch);
        elderGuardian.initialize(this.world ,this.world.getLocalDifficulty(elderGuardian.getBlockPos()), SpawnType.CONVERSION, (EntityData)null, (CompoundTag)null);
        elderGuardian.setAiDisabled(this.isAiDisabled());
        
        if (this.hasCustomName())
        {
            elderGuardian.setCustomName(this.getCustomName());
            elderGuardian.setCustomNameVisible(this.isCustomNameVisible());
        }
        
        this.world.spawnEntity(elderGuardian);
        this.remove();
    }
    else
    {
        super.onStruckByLightning(lightning);
    }
}
 
Example #3
Source File: EntitySpawnGlobalS2CPacket_1_15_2.java    From multiconnect with MIT License 5 votes vote down vote up
@Override
public void apply(ClientPlayPacketListener listener) {
    NetworkThreadUtils.forceMainThread(this, listener, MinecraftClient.getInstance());
    if (entityTypeId == 1) {
        LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(MinecraftClient.getInstance().world);
        if (lightning == null) {
            return;
        }
        lightning.setPos(x, y, z);
        listener.onEntitySpawn(new EntitySpawnS2CPacket(lightning));
    }
}