net.minecraft.entity.item.EntityArmorStand Java Examples

The following examples show how to use net.minecraft.entity.item.EntityArmorStand. 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: NPCUtils.java    From SkyblockAddons with MIT License 6 votes vote down vote up
/**
 * Checks if the given entity is an NPC
 *
 * @param entity the entity to check
 * @return {@code true} if the entity is an NPC, {@code false} otherwise
 */
public static boolean isNPC(Entity entity) {
    if (entity instanceof EntityOtherPlayerMP) {
        EntityOtherPlayerMP player = (EntityOtherPlayerMP) entity;
        ScorePlayerTeam playerTeam = (ScorePlayerTeam) player.getTeam();

        // If it doesn't have a team, it's likely not a player.
        if (player.getTeam() == null) {
            return false;
        }

        // If it doesn't have a color prefix, it's not a player.
        return playerTeam.getColorPrefix().equals("");
    } else if (entity instanceof EntityArmorStand) {
        return entity.isInvisible();
    } else {
        return false;
    }
}
 
Example #2
Source File: GTUtility.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Pushes entities away from target within an area, code adapted from
 * EE/ProjectE.
 */
public static void repelEntitiesInAABBFromPoint(World world, AxisAlignedBB boundingbox, double x, double y,
		double z) {
	List<Entity> list = world.getEntitiesWithinAABB(Entity.class, boundingbox);
	if (list.isEmpty()) {
		return;
	}
	for (Entity entity : list) {
		if ((entity instanceof EntityLiving) || (entity instanceof IProjectile)) {
			if (entity instanceof EntityArrow && ((EntityArrow) entity).onGround) {
				continue;
			}
			if (entity instanceof EntityArmorStand) {
				continue;
			}
			Vec3d p = new Vec3d(x, y, z);
			Vec3d t = new Vec3d(entity.posX, entity.posY, entity.posZ);
			double distance = p.distanceTo(t) + 0.1D;
			Vec3d r = new Vec3d(t.x - p.x, t.y - p.y, t.z - p.z);
			entity.motionX += r.x / 1.5D / distance;
			entity.motionY += r.y / 1.5D / distance;
			entity.motionZ += r.z / 1.5D / distance;
		}
	}
}
 
Example #3
Source File: EventsCommon.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onEntityJoinWorldEvent(EntityJoinWorldEvent event) {
    Entity entity = event.getEntity();

    World world = entity.world;
    BlockPos posAt = new BlockPos(entity);

    Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysicsObject(world, posAt);
    if (!event.getWorld().isRemote && physicsObject.isPresent()
        && !(entity instanceof EntityFallingBlock)) {
        if (entity instanceof EntityArmorStand
            || entity instanceof EntityPig || entity instanceof EntityBoat) {
            EntityMountable entityMountable = new EntityMountable(world,
                entity.getPositionVector(), CoordinateSpaceType.SUBSPACE_COORDINATES, posAt);
            world.spawnEntity(entityMountable);
            entity.startRiding(entityMountable);
        }
        physicsObject.get()
            .getShipTransformationManager()
            .getCurrentTickTransform().transform(entity,
            TransformType.SUBSPACE_TO_GLOBAL);
        // TODO: This should work but it doesn't because of sponge. Instead we have to rely on MixinChunk.preAddEntity() to fix this
        // event.setCanceled(true);
        // event.getWorld().spawnEntity(entity);
    }
}
 
Example #4
Source File: RenderManagerHook.java    From SkyblockAddons with MIT License 5 votes vote down vote up
public static void shouldRender(Entity entityIn, ReturnValue<Boolean> returnValue) {
    SkyblockAddons main = SkyblockAddons.getInstance();

    if (main.getUtils().isOnSkyblock()) {
        Location currentLocation = main.getUtils().getLocation();

        if (entityIn instanceof EntityItem &&
                entityIn.ridingEntity instanceof EntityArmorStand && entityIn.ridingEntity.isInvisible()) { // Conditions for skeleton helmet flying bones
            if (main.getConfigValues().isEnabled(Feature.HIDE_BONES)) {
                returnValue.cancel();
            }
        }
        if (main.getConfigValues().isEnabled(Feature.HIDE_PLAYERS_NEAR_NPCS)) {
            if (entityIn instanceof EntityOtherPlayerMP && NPCUtils.isNearAnyNPCWithTag(entityIn, Tag.IMPORTANT) && !NPCUtils.isNPC(entityIn)) {
                returnValue.cancel();
            }
        }
        if (main.getConfigValues().isEnabled(Feature.HIDE_PLAYERS_IN_LOBBY)) {
            if (currentLocation == Location.VILLAGE || currentLocation == Location.AUCTION_HOUSE ||
                    currentLocation == Location.BANK) {
                if ((entityIn instanceof EntityOtherPlayerMP || entityIn instanceof EntityFX || entityIn instanceof EntityItemFrame) &&
                        entityIn.getDistanceToEntity(Minecraft.getMinecraft().thePlayer) > 7) {
                    returnValue.cancel();
                }
            }
        }
        if(main.getConfigValues().isEnabled(Feature.HIDE_SVEN_PUP_NAMETAGS)) {
            if (entityIn instanceof EntityArmorStand && entityIn.hasCustomName()) {
                String customNameTag = entityIn.getCustomNameTag();

                if (customNameTag.contains("Sven Pup")) {
                    returnValue.cancel();
                }
            }
        }
    }
}
 
Example #5
Source File: RenderListener.java    From SkyblockAddons with MIT License 5 votes vote down vote up
/**
 * This renders a bar for the skeleton hat bones bar.
 */
public void drawSkeletonBar(Minecraft mc, float scale, ButtonLocation buttonLocation) {
    float x = main.getConfigValues().getActualX(Feature.SKELETON_BAR);
    float y = main.getConfigValues().getActualY(Feature.SKELETON_BAR);
    int bones = 0;
    if (!(mc.currentScreen instanceof LocationEditGui)) {
        for (Entity listEntity : mc.theWorld.loadedEntityList) {
            if (listEntity instanceof EntityItem &&
                    listEntity.ridingEntity instanceof EntityArmorStand && listEntity.ridingEntity.isInvisible() && listEntity.getDistanceToEntity(mc.thePlayer) <= 8) {
                bones++;
            }
        }
    } else {
        bones = 3;
    }
    if (bones > 3) bones = 3;

    int height = 16;
    int width = 3 * 16;
    x -= width * scale / 2F;
    y -= height * scale / 2F;
    x /= scale;
    y /= scale;
    if (buttonLocation != null) {
        buttonLocation.checkHoveredAndDrawBox(x, x+width, y, y+height, scale);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    }

    main.getUtils().enableStandardGLOptions();

    for (int boneCounter = 0; boneCounter < bones; boneCounter++) {
        renderItem(BONE_ITEM, x + boneCounter * 16, y);
    }

    main.getUtils().restoreGLOptions();
}
 
Example #6
Source File: PlayerListener.java    From SkyblockAddons with MIT License 5 votes vote down vote up
public boolean isZealot(Entity enderman) {
    List<EntityArmorStand> stands = Minecraft.getMinecraft().theWorld.getEntitiesWithinAABB(EntityArmorStand.class,
            new AxisAlignedBB(enderman.posX - 1, enderman.posY, enderman.posZ - 1, enderman.posX + 1, enderman.posY + 5, enderman.posZ + 1));
    if (stands.isEmpty()) return false;

    EntityArmorStand armorStand = stands.get(0);
    return armorStand.hasCustomName() && armorStand.getCustomNameTag().contains("Zealot");
}
 
Example #7
Source File: ModelCustomArmor.java    From Sakura_mod with MIT License 5 votes vote down vote up
public void setRotationAnglesStand(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)
{
  if ((entityIn instanceof EntityArmorStand))
  {
    EntityArmorStand entityarmorstand = (EntityArmorStand)entityIn;
    this.bipedHead.rotateAngleX = (0.017453292F * entityarmorstand.getHeadRotation().getX());
    this.bipedHead.rotateAngleY = (0.017453292F * entityarmorstand.getHeadRotation().getY());
    this.bipedHead.rotateAngleZ = (0.017453292F * entityarmorstand.getHeadRotation().getZ());
    this.bipedHead.setRotationPoint(0.0F, 1.0F, 0.0F);
    this.bipedBody.rotateAngleX = (0.017453292F * entityarmorstand.getBodyRotation().getX());
    this.bipedBody.rotateAngleY = (0.017453292F * entityarmorstand.getBodyRotation().getY());
    this.bipedBody.rotateAngleZ = (0.017453292F * entityarmorstand.getBodyRotation().getZ());
    this.bipedLeftArm.rotateAngleX = (0.017453292F * entityarmorstand.getLeftArmRotation().getX());
    this.bipedLeftArm.rotateAngleY = (0.017453292F * entityarmorstand.getLeftArmRotation().getY());
    this.bipedLeftArm.rotateAngleZ = (0.017453292F * entityarmorstand.getLeftArmRotation().getZ());
    this.bipedRightArm.rotateAngleX = (0.017453292F * entityarmorstand.getRightArmRotation().getX());
    this.bipedRightArm.rotateAngleY = (0.017453292F * entityarmorstand.getRightArmRotation().getY());
    this.bipedRightArm.rotateAngleZ = (0.017453292F * entityarmorstand.getRightArmRotation().getZ());
    this.bipedLeftLeg.rotateAngleX = (0.017453292F * entityarmorstand.getLeftLegRotation().getX());
    this.bipedLeftLeg.rotateAngleY = (0.017453292F * entityarmorstand.getLeftLegRotation().getY());
    this.bipedLeftLeg.rotateAngleZ = (0.017453292F * entityarmorstand.getLeftLegRotation().getZ());
    this.bipedLeftLeg.setRotationPoint(1.9F, 11.0F, 0.0F);
    this.bipedRightLeg.rotateAngleX = (0.017453292F * entityarmorstand.getRightLegRotation().getX());
    this.bipedRightLeg.rotateAngleY = (0.017453292F * entityarmorstand.getRightLegRotation().getY());
    this.bipedRightLeg.rotateAngleZ = (0.017453292F * entityarmorstand.getRightLegRotation().getZ());
    this.bipedRightLeg.setRotationPoint(-1.9F, 11.0F, 0.0F);
    copyModelAngles(this.bipedHead, this.bipedHeadwear);
  }
}
 
Example #8
Source File: ModelStrawHat.java    From Sakura_mod with MIT License 5 votes vote down vote up
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) {

        if (entityIn instanceof EntityArmorStand) {
            EntityArmorStand entityarmorstand = (EntityArmorStand) entityIn;

            this.bipedHead.rotateAngleX = 0.017453292F * entityarmorstand.getHeadRotation().getX();
            this.bipedHead.rotateAngleY = 0.017453292F * entityarmorstand.getHeadRotation().getY();
            this.bipedHead.rotateAngleZ = 0.017453292F * entityarmorstand.getHeadRotation().getZ();
            this.bipedHead.setRotationPoint(0.0F, 1.0F, 0.0F);

            copyModelAngles(this.bipedHead, this.bipedHeadwear);
        } else {
            super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
        }
    }
 
Example #9
Source File: MixinRendererLivingEntity.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Inject(method = "doRender", at = @At("HEAD"), cancellable = true)
private void doRender(T entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) {
    if (Settings.DISABLE_ARMORSTANDS && entity instanceof EntityArmorStand) ci.cancel();

    final EntityRenderEvent event = new EntityRenderEvent(entity, (float) x, (float) y, (float) z, entity.rotationPitch, entityYaw, 1.0F);
    EventBus.INSTANCE.post(event);

    if (event.isCancelled()) {
        ci.cancel();
    }
}
 
Example #10
Source File: CraftLivingEntity.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public CraftLivingEntity(final CraftServer server, final EntityLivingBase entity) {
    super(server, entity);

    if (entity instanceof EntityLiving || entity instanceof EntityArmorStand) {
        equipment = new CraftEntityEquipment(this);
    }
    this.entityName = EntityRegistry.getCustomEntityTypeName(entity.getClass());
    if (entityName == null) {
        entityName = entity.getName();
    }
}
 
Example #11
Source File: VillageHandlerBarracks.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected boolean specialBlockHandling(World world, String c, int x, int y, int z) {
	if (!c.equals("xx")) {
		return false;
	}
	
	setBlockState(world, Blocks.AIR.getDefaultState(), x, y, z, boundingBox);

	int j = this.getXWithOffset(x, z);
	int k = this.getYWithOffset(y);
	int l = this.getZWithOffset(x, z);

	/*
	 * if (!structurebb.isVecInside(new BlockPos(j, k, l))) { return; }
	 */

	EntityArmorStand stand = new EntityArmorStand(world);
	stand.setLocationAndAngles((double) j + 0.5D, (double) k, (double) l + 0.5D, 90F, 0.0F);
	world.spawnEntity(stand);

	List<String> entities = new ArrayList<String>();
	entities.add(ToroQuest.MODID + ":" + EntityGuard.NAME);
	specialHandlingForSpawner(world, "xx", c, x, y, z, entities);

	return true;

}
 
Example #12
Source File: ItemArmorCyberware.java    From Cyberware with MIT License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, net.minecraft.client.model.ModelBiped _default)
{
	ClientUtils.trench.setModelAttributes(_default);
	ClientUtils.armor.setModelAttributes(_default);
	ClientUtils.trench.bipedRightArm.isHidden = !(entityLiving instanceof EntityPlayer) && !(entityLiving instanceof EntityArmorStand);
	ClientUtils.trench.bipedLeftArm.isHidden = !(entityLiving instanceof EntityPlayer) && !(entityLiving instanceof EntityArmorStand);
	ClientUtils.armor.bipedRightArm.isHidden = ClientUtils.trench.bipedRightArm.isHidden;
	ClientUtils.armor.bipedLeftArm.isHidden = ClientUtils.trench.bipedLeftArm.isHidden;

	if (itemStack != null && itemStack.getItem() == CyberwareContent.trenchcoat) return ClientUtils.trench;
	
	return ClientUtils.armor;
}
 
Example #13
Source File: VSWorldEventListener.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public void onEntityAdded(Entity entity) {
    if (entity instanceof PhysicsWrapperEntity) {
        ValkyrienSkiesMod.VS_PHYSICS_MANAGER.onShipLoad((PhysicsWrapperEntity) entity);
    } else {
        // This is really only here because Sponge doesn't call the entity join event for some reason :/
        // So I basically just copied the event code here as well.
        World world = worldObj;
        BlockPos posAt = new BlockPos(entity);
        Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysicsObject(world, posAt);

        if (!worldObj.isRemote && physicsObject.isPresent()
            && !(entity instanceof EntityFallingBlock)) {
            if (entity instanceof EntityArmorStand
                || entity instanceof EntityPig || entity instanceof EntityBoat) {
                EntityMountable entityMountable = new EntityMountable(world,
                    entity.getPositionVector(), CoordinateSpaceType.SUBSPACE_COORDINATES,
                    posAt);
                world.spawnEntity(entityMountable);
                entity.startRiding(entityMountable);
            }
            world.getChunk(entity.getPosition().getX() >> 4, entity.getPosition().getZ() >> 4)
                .removeEntity(entity);
            physicsObject.get()
                .getShipTransformationManager()
                .getCurrentTickTransform().transform(entity,
                TransformType.SUBSPACE_TO_GLOBAL);
            world.getChunk(entity.getPosition().getX() >> 4, entity.getPosition().getZ() >> 4)
                .addEntity(entity);
        }
    }
}
 
Example #14
Source File: CraftArmorStand.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftArmorStand(CraftServer server, EntityArmorStand entity) {
    super(server, entity);
}
 
Example #15
Source File: CraftArmorStand.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EntityArmorStand getHandle() {
    return (EntityArmorStand) super.getHandle();
}