net.minecraft.entity.item.EntityPainting Java Examples

The following examples show how to use net.minecraft.entity.item.EntityPainting. 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: TrackingRange.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets the range an entity should be 'tracked' by players and visible in
 * the client.
 *
 * @param entity
 * @param defaultRange Default range defined by Mojang
 * @return
 */
public static int getEntityTrackingRange(Entity entity, int defaultRange) {
    SpigotWorldConfig config = entity.world.spigotConfig;
    if (entity instanceof EntityPlayer) {
        return config.playerTrackingRange;
    } else if (entity.activationType == 1) {
        return config.monsterTrackingRange;
    } else if (entity instanceof EntityGhast) {
        if (config.monsterTrackingRange > config.monsterActivationRange) {
            return config.monsterTrackingRange;
        } else {
            return config.monsterActivationRange;
        }
    } else if (entity.activationType == 2) {
        return config.animalTrackingRange;
    } else if (entity instanceof EntityItemFrame || entity instanceof EntityPainting || entity instanceof EntityItem || entity instanceof EntityXPOrb) {
        return config.miscTrackingRange;
    } else {
        return config.otherTrackingRange;
    }
}
 
Example #2
Source File: MixinTileEntityMobSpawnerRenderer.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@Inject(method = "renderMob", cancellable = true, at = @At("HEAD"))
private static void injectPaintingSpawnerFix(MobSpawnerBaseLogic mobSpawnerLogic, double posX, double posY, double posZ, float partialTicks, CallbackInfo ci) {
    Entity entity = mobSpawnerLogic.func_180612_a(mobSpawnerLogic.getSpawnerWorld());

    if (entity == null || entity instanceof EntityPainting)
        ci.cancel();
}
 
Example #3
Source File: MixinTileEntityMobSpawnerRenderer.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@Inject(method = "renderMob", cancellable = true, at = @At("HEAD"))
private static void injectPaintingSpawnerFix(MobSpawnerBaseLogic mobSpawnerLogic, double posX, double posY, double posZ, float partialTicks, CallbackInfo ci) {
    Entity entity = mobSpawnerLogic.func_180612_a(mobSpawnerLogic.getSpawnerWorld());

    if (entity == null || entity instanceof EntityPainting)
        ci.cancel();
}
 
Example #4
Source File: CraftPainting.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public boolean setArt(Art art, boolean force) {
    EntityPainting painting = this.getHandle();
    EnumArt oldArt = painting.art;
    painting.art = CraftArt.BukkitToNotch(art);
    painting.updateFacingWithBoundingBox(painting.facingDirection);
    if (!force && !painting.onValidSurface()) {
        // Revert painting since it doesn't fit
        painting.art = oldArt;
        painting.updateFacingWithBoundingBox(painting.facingDirection);
        return false;
    }
    this.update();
    return true;
}
 
Example #5
Source File: CraftPainting.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
private void update() {
    WorldServer world = ((CraftWorld) getWorld()).getHandle();
    EntityPainting painting = new EntityPainting(world);
    painting.hangingPosition = getHandle().getHangingPosition();
    painting.art = getHandle().art;
    painting.updateFacingWithBoundingBox(getHandle().facingDirection);
    getHandle().setDead();
    getHandle().velocityChanged = true; // because this occurs when the painting is broken, so it might be important
    world.spawnEntity(painting);
    this.entity = painting;
}
 
Example #6
Source File: TrackingRange.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets the range an entity should be 'tracked' by players and visible in
 * the client.
 *
 * @param entity
 * @param defaultRange Default range defined by Mojang
 * @return
 */
public static int getEntityTrackingRange(Entity entity, int defaultRange)
{
    SpigotWorldConfig config = entity.worldObj.getSpigotConfig(); // Cauldron
    int range = defaultRange;
    if ( entity instanceof EntityPlayerMP )
    {
        range = config.playerTrackingRange;
    } else if ( entity.defaultActivationState || entity instanceof EntityGhast )
    {
        range = defaultRange;
    } else if ( entity.activationType == 1 )
    {
        range = config.monsterTrackingRange;
    } else if ( entity.activationType == 2 )
    {
        range = config.animalTrackingRange;
    } else if ( entity instanceof EntityItemFrame || entity instanceof EntityPainting || entity instanceof EntityItem || entity instanceof EntityXPOrb )
    {
        range = config.miscTrackingRange;
    }
    // Cauldron start - allow for 0 to disable tracking ranges
    if (range == 0)
    {
        return defaultRange;
    }
    // Cauldron end

    return Math.min( config.maxTrackingRange, range );
}
 
Example #7
Source File: PaintingMetaProvider.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@Override
public Object getMeta(EntityPainting target, Vec3 relativePos) {
	Map<String, Object> result = Maps.newHashMap();
	result.put("title", target.art.title);
	result.put("width", target.art.sizeX / 16);
	result.put("height", target.art.sizeY / 16);
	return result;
}
 
Example #8
Source File: CraftPainting.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftPainting(CraftServer server, EntityPainting entity) {
    super(server, entity);
}
 
Example #9
Source File: CraftPainting.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EntityPainting getHandle() {
    return (EntityPainting) entity;
}
 
Example #10
Source File: Entity.java    From TickDynamic with MIT License 4 votes vote down vote up
/**
 * Called when a user uses the creative pick block button on this entity.
 *
 * @param target The full target the player is looking at
 * @return A ItemStack to add to the player's inventory, Null if nothing should be added.
 */
public ItemStack getPickedResult(MovingObjectPosition target)
{
    if (this instanceof EntityPainting)
    {
        return new ItemStack(Items.painting);
    }
    else if (this instanceof EntityLeashKnot)
    {
        return new ItemStack(Items.lead);
    }
    else if (this instanceof EntityItemFrame)
    {
        ItemStack held = ((EntityItemFrame)this).getDisplayedItem();
        if (held == null)
        {
            return new ItemStack(Items.item_frame);
        }
        else
        {
            return held.copy();
        }
    }
    else if (this instanceof EntityMinecart)
    {
        return ((EntityMinecart)this).getCartItem();
    }
    else if (this instanceof EntityBoat)
    {
        return new ItemStack(Items.boat);
    }
    else
    {
        int id = EntityList.getEntityID(this);
        if (id > 0 && EntityList.entityEggs.containsKey(id))
        {
            return new ItemStack(Items.spawn_egg, 1, id);
        }
    }
    return null;
}
 
Example #11
Source File: TemplateEnderUtilities.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void addEntitiesToWorld(World world, BlockPos posStart)
{
    if (this.placement.getIgnoreEntities())
    {
        return;
    }

    Mirror mirror = this.placement.getMirror();
    Rotation rotation = this.placement.getRotation();

    BlockPos posEnd = posStart.add(PositionUtils.getRelativeEndPositionFromAreaSize(this.size));
    BlockPos pos1 = PositionUtils.getMinCorner(posStart, posEnd);
    BlockPos pos2 = PositionUtils.getMaxCorner(posStart, posEnd).add(1, 1, 1);
    List<Entity> existingEntities = world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(pos1, pos2));

    for (TemplateEnderUtilities.TemplateEntityInfo entityInfo : this.entities)
    {
        BlockPos pos = transformedBlockPos(this.placement, entityInfo.blockPos).add(posStart);

        NBTTagCompound nbt = entityInfo.entityData;
        UUID uuidOriginal = nbt.getUniqueId("UUID");
        Vec3d vec3d = PositionUtils.transformedVec3d(entityInfo.pos, mirror, rotation);
        Vec3d vec3d1 = vec3d.add((double)posStart.getX(), (double)posStart.getY(), (double)posStart.getZ());
        NBTTagList tagList = new NBTTagList();
        tagList.appendTag(new NBTTagDouble(vec3d1.x));
        tagList.appendTag(new NBTTagDouble(vec3d1.y));
        tagList.appendTag(new NBTTagDouble(vec3d1.z));
        nbt.setTag("Pos", tagList);
        nbt.setUniqueId("UUID", UUID.randomUUID());
        Entity entity;

        try
        {
            entity = EntityList.createEntityFromNBT(nbt, world);
        }
        catch (Exception e)
        {
            entity = null;
        }

        if (entity != null)
        {
            if (entity instanceof EntityPainting)
            {
                entity.getMirroredYaw(mirror);
                entity.getRotatedYaw(rotation);
                entity.setPosition(pos.getX(), pos.getY(), pos.getZ());
                entity.setLocationAndAngles(vec3d1.x, vec3d1.y, vec3d1.z, entity.rotationYaw, entity.rotationPitch);
            }
            else
            {
                float f = entity.getMirroredYaw(mirror);
                f = f + (entity.rotationYaw - entity.getRotatedYaw(rotation));
                entity.setLocationAndAngles(vec3d1.x, vec3d1.y, vec3d1.z, f, entity.rotationPitch);
                // FIXME should call updateFacingWithBoundingBox(EnumFacing) for EntityHanging, otherwise a world reload is needed
                // for ItemFrames for example to visually update to the correct facing
            }

            // Use the original UUID if possible. If there is an entity with the same UUID within the pasted area,
            // then the old one will be killed. Otherwise if there is no entity currently in the world with
            // the same UUID, then the original UUID will be used.
            Entity existing = EntityUtils.findEntityByUUID(existingEntities, uuidOriginal);
            if (existing != null)
            {
                world.removeEntityDangerously(existing);
                entity.setUniqueId(uuidOriginal);
            }
            else if (world instanceof WorldServer && ((WorldServer) world).getEntityFromUuid(uuidOriginal) == null)
            {
                entity.setUniqueId(uuidOriginal);
            }

            world.spawnEntity(entity);
        }
    }
}