net.minecraft.entity.EntityData Java Examples

The following examples show how to use net.minecraft.entity.EntityData. 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: MixinSpawnHelper.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Redirect(method = "spawnEntitiesInChunk", at = @At(value = "INVOKE", target = "net/minecraft/entity/mob/MobEntity.initialize(Lnet/minecraft/world/IWorld;Lnet/minecraft/world/LocalDifficulty;Lnet/minecraft/entity/SpawnType;Lnet/minecraft/entity/EntityData;Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/entity/EntityData;"))
private static EntityData hookSpecialSpawn(MobEntity entity, IWorld world, LocalDifficulty localDifficulty, SpawnType spawnType, EntityData data, CompoundTag tag) {
	if (!EntityEvents.doSpecialSpawn(entity, world, entity.x, entity.y, entity.z, null, spawnType)) {
		return entity.initialize(world, localDifficulty, spawnType, data, tag);
	} else {
		return data;
	}
}
 
Example #4
Source File: SpawnHelperMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Redirect(method = "spawnEntitiesInChunk", at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/entity/mob/MobEntity;initialize(Lnet/minecraft/world/IWorld;Lnet/minecraft/world/LocalDifficulty;Lnet/minecraft/entity/SpawnType;Lnet/minecraft/entity/EntityData;Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/entity/EntityData;"
))
private static EntityData spawnEntity(MobEntity mobEntity, IWorld iWorld_1, LocalDifficulty localDifficulty_1, SpawnType spawnType_1, EntityData entityData_1, CompoundTag compoundTag_1)
{
    if (!SpawnReporter.mock_spawns)
        return mobEntity.initialize(iWorld_1, localDifficulty_1, spawnType_1, entityData_1, compoundTag_1);
    return null;
}
 
Example #5
Source File: MobEntityMixin.java    From the-hallow with MIT License 4 votes vote down vote up
@Inject(method = "initialize(Lnet/minecraft/world/IWorld;Lnet/minecraft/world/LocalDifficulty;Lnet/minecraft/entity/SpawnType;Lnet/minecraft/entity/EntityData;Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/entity/EntityData;", at = @At("RETURN"))
public void initialize(IWorld iWorld, LocalDifficulty localDifficulty, SpawnType spawnType, EntityData entityData, CompoundTag compoundTag, CallbackInfoReturnable<EntityData> cir) {
	if (((Object) this) instanceof EndermanEntity && HallowedConfig.PumpkinMobs.endermen && MixinHelpers.RANDOM.nextInt(10) == 0) {
		((EndermanEntity) (Object) this).setCarriedBlock((MixinHelpers.RANDOM.nextBoolean() ? Blocks.PUMPKIN : (MixinHelpers.RANDOM.nextBoolean() ? Blocks.CARVED_PUMPKIN : Blocks.JACK_O_LANTERN)).getDefaultState());
	}
}