Java 类net.minecraft.entity.item.EntityPainting.EnumArt 实例源码

项目:TaleCraft    文件:CustomPaintingRender.java   
@Override
public void render(Item item, ItemStack stack, Tessellator tessellator, BufferBuilder buffer, double partialTick, BlockPos playerPos, EntityPlayerSP player, WorldClient world) {
    EnumArt painting = EnumArt.valueOf(stack.getTagCompound().getString("art"));
    RayTraceResult result = player.rayTrace(5, (float)partialTick);
    if(result.typeOfHit == Type.BLOCK){
        BlockPos pos = result.getBlockPos();
        EnumFacing facing = result.sideHit;
        if(!facing.getAxis().isHorizontal())return;
        EntityPainting ent = new EntityPainting(world, pos.offset(facing.getOpposite(), 1), facing);
        ent.art = painting;
        GlStateManager.enableBlend();
        GL11.glColor4f(1f, 1f, 1f, 0.5f);
        double xMove = 0;
        if(facing.getFrontOffsetX() == 0)xMove = (painting.sizeX != 32 ?  painting.sizeX >= 48 ? -painting.sizeX/16/8 : 0.5 : 0);
        double zMove = 0;
        if(facing.getFrontOffsetZ() == 0)zMove = (painting.sizeX != 32 ?  painting.sizeX >= 48 ? -painting.sizeX/16/8 : 0.5 : 0);
        if(painting.sizeX == 16){
            if(facing.getOpposite() == EnumFacing.EAST)zMove -= 1;
            if(facing.getOpposite() == EnumFacing.NORTH)xMove -= 1;
        }
        double yMove = (painting.sizeY == 16  || painting.sizeY == 16*3 ? 0 : 0.5);
        RENDER.doRender(ent, ent.posX + facing.getFrontOffsetX()*2 + xMove, ent.posY + yMove, ent.posZ + facing.getFrontOffsetZ()*2 + zMove, ent.rotationYaw, (float)partialTick);
    }
}
项目:TaleCraft    文件:CustomPaintingItem.java   
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack stack = player.getHeldItem(hand);
    BlockPos blockpos = pos.offset(facing);
    if (facing != EnumFacing.DOWN && facing != EnumFacing.UP && player.canPlayerEdit(blockpos, facing, stack)){
        EntityPainting painting = new EntityPainting(worldIn, blockpos, facing);

        if (painting != null && painting.onValidSurface()){
            if (!worldIn.isRemote){
                painting.playPlaceSound();
                painting.art = EnumArt.valueOf(stack.getTagCompound().getString("art"));
                worldIn.spawnEntity(painting);
            }
        }

        return EnumActionResult.SUCCESS;
    }
    else{
        return EnumActionResult.FAIL;
    }
}
项目:StructureGenerationAPI    文件:GenHelper.java   
/**
 * Sets the art for a painting at location x/y/z and sends a packet to update players.
 * @param direction Use the value returned from the setHangingEntity method
 * @return false if 'name' didn't match any EnumArt values.
 */
public static final boolean setPaintingArt(World world, String name, int x, int y, int z, int direction) {
    List<EntityPainting> paintings = world.getEntitiesWithinAABB(EntityPainting.class, getHangingEntityAxisAligned(x, y, z, direction));
    if (paintings != null && !paintings.isEmpty() && name.length() > 0) {
        for (EntityPainting toEdit : paintings) {
            EnumArt[] aenumart = EnumArt.values();
            int i1 = aenumart.length;
            for (int j1 = 0; j1 < i1; ++j1) {
                EnumArt enumart = aenumart[j1];
                if (enumart.title.equals(name)) {
                    toEdit.art = enumart;
                    // TODO PacketDispatcher.sendPacketToAllAround(x, y, z, 64, world.provider.dimensionId, new Packet25EntityPainting(toEdit));
                    return true;
                }
            }
            LogHelper.warning(name + " does not match any values in EnumArt; unable to set painting art.");
        }
    }
    LogHelper.warning("No EntityPainting was found at " + x + "/" + y + "/" + z);
    return false;
}
项目:PaintingSelectionGui    文件:ClientProxy.java   
@Override
public void onClientPacket(EntityPlayer player, PaintingPacket packet) { 
    if(packet.id == -1) { //What painting is selected?
        MovingObjectPosition pos = Minecraft.getMinecraft().objectMouseOver;
        if (pos != null && pos.entityHit instanceof EntityPainting) 
            PaintingSelectionMod.DISPATCHER.sendToServer(new PaintingPacket(pos.entityHit.getEntityId(), new String[0]));
        else
            player.addChatMessage(new ChatComponentText(PaintingSelectionMod.COLOR + "cError - No painting selected"));
    }
    else if (packet.art.length == 1) { //Set Painting
        EnumArt enumArt = getEnumArt(packet.art[0]);
        Entity e = player.worldObj.getEntityByID(packet.id);
        if (e instanceof EntityPainting)
            setPaintingArt((EntityPainting)e, enumArt);
    }
    else { //Show art GUI
        Minecraft mc = Minecraft.getMinecraft();
        if (mc.currentScreen == null)
            mc.displayGuiScreen(new PaintingSelectionScreen(packet.art, packet.id));
    }
}
项目:PacketControl    文件:MixinPacketSpawnPainting.java   
@Override
public Art getArt() {
    for(EnumArt art : EnumArt.values()) {
        if(art.title.equals(title)) return (Art)(Object)art;
    }
    return Arts.KEBAB;
}
项目:TaleCraft    文件:CustomPaintingItem.java   
@Override
public void addInformation(ItemStack stack, World player, List<String> tooltip, ITooltipFlag advanced) {
    if(!stack.hasTagCompound())return;
    EnumArt painting = EnumArt.valueOf(stack.getTagCompound().getString("art"));
    tooltip.add("Painting: " + painting.title);
    tooltip.add("Size: " + painting.sizeX/16 + "x" + painting.sizeY/16);
}
项目:TaleCraft    文件:CustomPaintingItem.java   
@Override
public void onUpdate(ItemStack stack, World world, Entity entityIn, int itemSlot, boolean isSelected) {
    if(world.isRemote)return;
    if(stack.hasTagCompound())return;
    NBTTagCompound tag = new NBTTagCompound();
    tag.setString("art", EnumArt.KEBAB.name());
    stack.setTagCompound(tag);
}
项目:TaleCraft    文件:CustomPaintingItem.java   
@Override
public void trigger(World world, EntityPlayerMP player, ItemStack stack) {
    if(world.isRemote) return;
    int current = EnumArt.valueOf(stack.getTagCompound().getString("art")).ordinal();
    current++;
    if(current >= EnumArt.values().length)current = 0;
    EnumArt art = EnumArt.values()[current];
    stack.getTagCompound().setString("art", art.name());
    player.sendMessage(new TextComponentString("Changed painting to " + TextFormatting.GOLD + art.title + TextFormatting.GREEN + " (" + art.sizeX/16 + "x" + art.sizeY/16 + ")"));
}
项目:morecommands    文件:CommandCyclepainting.java   
@Override
public String execute(CommandSender sender, String[] params) throws CommandException {
    Entity entity = getSenderAsEntity(sender.getMinecraftISender(), Entity.class);

    boolean sneaking = entity.isSneaking();
    Entity hit = EntityUtils.traceEntity(entity, 128.0D);

    if (!(hit instanceof EntityPainting) || hit.isDead)
        throw new CommandException("command.cyclepainting.noPainting", sender);

    EntityPainting picture = (EntityPainting) hit;
    EntityPainting newPicture = new EntityPainting(picture.world, picture.getHangingPosition(), picture.facingDirection);

    EnumArt oldArt = picture.art;
    int current = 0;

    List<EnumArt> arts = new ArrayList<EnumArt>();
    EnumArt[] all = EnumArt.values();

    for (int i = 0; i < all.length; ++i) {
        arts.add(all[i]);
        if (oldArt == all[i]) current = i;
    }

    if (arts.size() <= 1) {
        newPicture.art = oldArt;
        entity.world.removeEntity(picture);
        entity.world.spawnEntity(newPicture);
        throw new CommandException("command.cyclepainting.noMoreArts", sender);
    }

    int newArt = sneaking ? (current == 0 ? arts.size() - 1 : current - 1) : (current == arts.size() - 1 ? 0 : current + 1);

    newPicture.art = arts.get(newArt);
    entity.world.removeEntity(picture);
    entity.world.spawnEntity(newPicture);

    return null;
}
项目:PaintingSelectionGui    文件:ArtComparator.java   
@Override
public int compare(EnumArt a, EnumArt b) {
    if (a.sizeY > b.sizeY)
        return -1;
    if (a.sizeY < b.sizeY)
        return 1;
    return b.sizeX - a.sizeX;
}
项目:PaintingSelectionGui    文件:PaintingSelectionScreen.java   
@Override
protected void createGui() {
    scrollbar = new ScrollbarVanilla(10);
    paintingContainer = new Container(scrollbar, 0, 4);
    container = new Container();
    title = new Label("Select a Painting");
    back = new ButtonVanilla("Cancel", new CloseHandler());

    EnumArt[] enumArts = EnumArt.values();
    ArrayList<EnumArt> validArts = new ArrayList<EnumArt>();
    for (String s : art)
        for (EnumArt enumArt : enumArts)
            if (enumArt.title.equals(s)){
                validArts.add(enumArt);
                break;
            }

    EnumArt[] validArtsArray = validArts.toArray(new EnumArt[0]);
    buttons = new PaintingButton[validArtsArray.length];
    for (int i = 0; i < validArtsArray.length; ++i)
        buttons[i] = new PaintingButton(validArtsArray[i], this);

    container.addWidgets(title, back);
    paintingContainer.addWidgets(buttons);

    containers.add(paintingContainer);
    containers.add(container);
    selectedContainer = paintingContainer;
}
项目:PacketControl    文件:MixinPacketSpawnPainting.java   
@Override
public void setArt(Art art) {
    title = ((EnumArt)(Object)art).title;
}
项目:CustomWorldGen    文件:EnumHelper.java   
public static EnumArt addArt(String name, String tile, int sizeX, int sizeY, int offsetX, int offsetY)
{
    return addEnum(EnumArt.class, name, tile, sizeX, sizeY, offsetX, offsetY);
}
项目:TRHS_Club_Mod_2016    文件:EnumHelper.java   
public static EnumArt addArt(String name, String tile, int sizeX, int sizeY, int offsetX, int offsetY)
{
    return addEnum(EnumArt.class, name, tile, sizeX, sizeY, offsetX, offsetY);
}
项目:CauldronGit    文件:EnumHelper.java   
public static EnumArt addArt(String name, String tile, int sizeX, int sizeY, int offsetX, int offsetY)
{
    return addEnum(EnumArt.class, name, tile, sizeX, sizeY, offsetX, offsetY);
}
项目:Cauldron    文件:EnumHelper.java   
public static EnumArt addArt(String name, String tile, int sizeX, int sizeY, int offsetX, int offsetY)
{
    return addEnum(EnumArt.class, name, tile, sizeX, sizeY, offsetX, offsetY);
}
项目:Cauldron    文件:EnumHelper.java   
public static EnumArt addArt(String name, String tile, int sizeX, int sizeY, int offsetX, int offsetY)
{
    return addEnum(EnumArt.class, name, tile, sizeX, sizeY, offsetX, offsetY);
}
项目:Cauldron    文件:EnumHelper.java   
public static EnumArt addArt(String name, String tile, int sizeX, int sizeY, int offsetX, int offsetY)
{
    return addEnum(EnumArt.class, name, tile, sizeX, sizeY, offsetX, offsetY);
}
项目:PaintingSelectionGui    文件:NetProxy.java   
protected EnumArt getEnumArt(String artName) {
    for (EnumArt art : EnumArt.values())
        if (art.title.equals(artName))
            return art;
    return EnumArt.Kebab;
}
项目:PaintingSelectionGui    文件:NetProxy.java   
protected void setPaintingArt(EntityPainting p, EnumArt art) {
    p.art = art;
    p.setDirection(p.hangingDirection);
}
项目:PaintingSelectionGui    文件:PaintingButton.java   
public PaintingButton(EnumArt art, ButtonHandler handler) {
    super(art.sizeX, art.sizeY, handler);

    this.art = art;
}