@Override public Optional<?> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { return Assets.getTextureRegion(json.getAsString()); } }
@Override public TextureRegion deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { String uri = json.getAsString(); return Assets.getTextureRegion(uri).orElse(null); } }
@Override public TextureRegion getFromString(String representation) { Optional<TextureRegionAsset> region = Assets.getTextureRegion(representation); if (region.isPresent()) { return region.get(); } else { logger.error("Failed to resolve texture region '" + representation + "'"); return Assets.getTextureRegion("engine:default").get(); } } }
@Override public Collection<FlowRenderable> create(Attributes attributes, Font font, Color color, String hyperlink) { String src = HTMLUtils.findAttribute(attributes, "src"); if (src == null) { throw new HTMLParseException("Expected src attribute"); } Integer width = null; Integer height = null; String widthStr = HTMLUtils.findAttribute(attributes, "width"); if (widthStr != null) { width = Integer.parseInt(widthStr); } String heightStr = HTMLUtils.findAttribute(attributes, "height"); if (heightStr != null) { height = Integer.parseInt(heightStr); } return Collections.singleton(new ImageFlowRenderable(Assets.getTextureRegion(src).get(), width, height, hyperlink)); } }
@Override public TextureRegion get() { if (getItem().exists()) { ItemComponent itemComp = getItem().getComponent(ItemComponent.class); if (itemComp != null) { return itemComp.icon; } BlockItemComponent blockItemComp = getItem().getComponent(BlockItemComponent.class); if (blockItemComp == null || blockItemComp.blockFamily == null) { return Assets.getTextureRegion("engine:items#questionMark").orElse(null); } } return null; } });
@Override public TextureRegion get() { if (getTargetItem().exists()) { ItemComponent itemComp = getTargetItem().getComponent(ItemComponent.class); if (itemComp != null && itemComp.icon != null) { return itemComp.icon; } BlockItemComponent blockItemComp = getTargetItem().getComponent(BlockItemComponent.class); if (blockItemComp == null || blockItemComp.blockFamily == null) { return Assets.getTextureRegion("engine:items#questionMark").get(); } } return null; } });
@Override public void renderOverlay() { if (blockSelectionRenderer == null) { Texture texture = Assets.getTextureRegion("core:blockdamageeffects#1").get().getTexture(); blockSelectionRenderer = new BlockSelectionRenderer(texture); Optional<TextureRegionAsset> texture = Assets.getTextureRegion("core:blockdamageeffects#" + effectsNumber); if (texture.isPresent()) { blockSelectionRenderer.setEffectsTexture(texture.get());