net.minecraft.client.util.SpriteIdentifier Java Examples

The following examples show how to use net.minecraft.client.util.SpriteIdentifier. 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: ConfigurableElectricMachineBlockEntityRenderer.java    From Galacticraft-Rewoven with MIT License 7 votes vote down vote up
public BakedModel bakeModel(JsonUnbakedModel model, Function<SpriteIdentifier, Sprite> textureGetter, ModelBakeSettings settings, Identifier id, boolean hasDepth) {
    Sprite sprite = textureGetter.apply(model.resolveSprite("particle"));
    if (model.getRootModel() == ModelLoader.BLOCK_ENTITY_MARKER) {
        return new BuiltinBakedModel(model.getTransformations(), ModelOverrideList.EMPTY, sprite, model.getGuiLight().isSide());
    } else {
        BasicBakedModel.Builder builder = (new BasicBakedModel.Builder(model, ModelOverrideList.EMPTY, hasDepth)).setParticle(sprite);

        for (ModelElement modelElement : model.getElements()) {
            for (Direction direction : modelElement.faces.keySet()) {
                ModelElementFace modelElementFace = modelElement.faces.get(direction);
                Sprite sprite2 = textureGetter.apply(model.resolveSprite(modelElementFace.textureId));
                if (modelElementFace.cullFace == null) {
                    builder.addQuad(createQuad(modelElement, modelElementFace, sprite2, direction, settings, id));
                } else {
                    builder.addQuad(Direction.transform(settings.getRotation().getMatrix(), modelElementFace.cullFace), createQuad(modelElement, modelElementFace, sprite2, direction, settings, id));
                }
            }
        }

        return builder.build();
    }
}
 
Example #2
Source File: CoalGeneratorBlockEntityRenderer.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
@Nonnull
@Override
public SpriteIdentifier getDefaultSpriteId(@Nonnull CoalGeneratorBlockEntity entity, @Nonnull Direction direction) {
    if (direction == Direction.NORTH) {
        return new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/coal_generator"));
    }
    return super.getDefaultSpriteId(entity, direction);
}
 
Example #3
Source File: BasicSolarPanelBlockEntityRenderer.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
@Override
@Nonnull
public SpriteIdentifier getDefaultSpriteId(@Nonnull BasicSolarPanelBlockEntity entity, @Nonnull Direction direction) {
    switch (direction) {
        case NORTH:
            return new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/basic_solar_panel"));
        case SOUTH:
            new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine_side"));
        case EAST:
            new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine_side"));
        case WEST:
            new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine_side"));
        case UP:
            new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/solar_panel"));
        case DOWN:
            new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine"));
    }
    return new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine"));
}
 
Example #4
Source File: RefineryBlockEntityRenderer.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
@Nonnull
@Override
public SpriteIdentifier getDefaultSpriteId(@Nonnull RefineryBlockEntity entity, @Nonnull Direction direction) {
    switch (direction) {
        case NORTH:
            return new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/refinery_front"));
        case SOUTH:
            return new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/refinery_side"));
        case EAST:
        case WEST:
            return new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine_side"));
        case UP:
        case DOWN:
            return new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine"));
    }
    return new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine"));
}
 
Example #5
Source File: MixinSpriteIdentifier.java    From MineLittlePony with MIT License 6 votes vote down vote up
@Inject(method = "getVertexConsumer("
            + "Lnet/minecraft/client/render/VertexConsumerProvider;"
            + "Ljava/util/function/Function;"
        + ")"
        + "Lnet/minecraft/client/render/VertexConsumer;",
        at = @At("HEAD"),
        cancellable = true
)
public void onGetBuffer(VertexConsumerProvider provider, Function<Identifier, RenderLayer> layerFunction, CallbackInfoReturnable<VertexConsumer> info) {
    if (LevitatingItemRenderer.usesTransparency()) {
        SpriteIdentifier self = (SpriteIdentifier)(Object)this;

        info.setReturnValue(self.getSprite().getTextureSpecificVertexConsumer(provider.getBuffer(LevitatingItemRenderer.getRenderLayer(self.getAtlasId()))));
    }
}
 
Example #6
Source File: ConfigurableElectricMachineBlockEntityRenderer.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Nonnull
public SpriteIdentifier getDefaultSpriteId(@Nonnull T entity, @Nonnull Direction direction) {
    switch (direction) {
        case NORTH:
        case SOUTH:
        case EAST:
        case WEST:
            return new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine_side"));
        case UP:
        case DOWN:
            return new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine"));
    }
    return new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine"));
}
 
Example #7
Source File: EnergyStorageModuleBlockEntityRenderer.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Nonnull
@Override
public SpriteIdentifier getDefaultSpriteId(@Nonnull EnergyStorageModuleBlockEntity entity, @Nonnull Direction direction) {
    int level = (int) (((float) entity.getCapacitatorComponent().getCurrentEnergy() / (float) entity.getMaxEnergy()) * 8F);
    if (direction == Direction.NORTH || direction == Direction.SOUTH) {
        return new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/energy_storage_module_" + level));
    }
    return super.getDefaultSpriteId(entity, direction);
}
 
Example #8
Source File: CircuitFabricatorBlockEntityRenderer.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Nonnull
@Override
public SpriteIdentifier getDefaultSpriteId(@Nonnull CircuitFabricatorBlockEntity entity, @Nonnull Direction direction) {
    if (direction == Direction.NORTH) {
        return new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/circuit_fabricator"));
    }
    return super.getDefaultSpriteId(entity, direction);
}
 
Example #9
Source File: MixinModelLoader.java    From Sandbox with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Ljava/util/Set;addAll(Ljava/util/Collection;)Z"))
public boolean addAll(Set<SpriteIdentifier> set, Collection<SpriteIdentifier> set2) {
    for (Fluid fluid : Registry.FLUID) {
        if (fluid instanceof FluidWrapper) {
            set.add(new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, WrappingUtil.convert(((FluidWrapper) fluid).fluid.getTexturePath(false))));
            set.add(new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, WrappingUtil.convert(((FluidWrapper) fluid).fluid.getTexturePath(true))));
        }
    }
    return set.addAll(set2);
}
 
Example #10
Source File: ConfigurableElectricMachineBlockEntityRenderer.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
public BakedModel getModelForState(T entity, BlockState state) {
    StringBuilder builder = new StringBuilder();
    for (ConfigurableElectricMachineBlock.BlockFace face : ConfigurableElectricMachineBlock.BlockFace.values()) {
        builder.append(((ConfigurableElectricMachineBlock) state.getBlock()).getOption(state, face).asString());
    }
    if (!MODEL_CACHE.containsKey(builder.toString())) {
        Map<String, Either<SpriteIdentifier, String>> texMap = new HashMap<>();
        texMap.put("particle", Either.left(EMPTY));
        for (Direction direction : Direction.values()) {
            switch (((ConfigurableElectricMachineBlock) state.getBlock()).getOption(state, ConfigurableElectricMachineBlock.BlockFace.toFace(Direction.NORTH, direction))) { //north so that the model doesn't rotate
                case DEFAULT:
                    texMap.put(direction.getName(), Either.left(getDefaultSpriteId(entity, direction)));
                    break;
                case POWER_INPUT:
                    texMap.put(direction.getName(), Either.left(new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine_power_input"))));
                    break;
                case POWER_OUTPUT:
                    texMap.put(direction.getName(), Either.left(new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine_power_output"))));
                    break;
                case OXYGEN_INPUT:
                    texMap.put(direction.getName(), Either.left(new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine_oxygen_input"))));
                    break;
                case OXYGEN_OUTPUT:
                    texMap.put(direction.getName(), Either.left(new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine_oxygen_output"))));
                    break;
                case FLUID_INPUT:
                    texMap.put(direction.getName(), Either.left(new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine_fluid_input"))));
                    break;
                case FLUID_OUTPUT:
                    texMap.put(direction.getName(), Either.left(new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine_fluid_output"))));
                    break;
            }
        }

        BakedModel model = this.bakeModel(new JsonUnbakedModel(null, element, texMap, true,
                        JsonUnbakedModel.GuiLight.field_21859, ModelTransformation.NONE, new ArrayList<>()),
                spriteIdentifier -> MinecraftClient.getInstance().getSpriteAtlas(spriteIdentifier.getAtlasId()).apply(spriteIdentifier.getTextureId()),
                ModelRotation.X0_Y0, new Identifier(Constants.MOD_ID, builder.toString()), true);
        MODEL_CACHE.put(builder.toString(), model);

        return model;
    } else {
        return MODEL_CACHE.get(builder.toString());
    }
}
 
Example #11
Source File: OxygenCollectorBlockEntityRenderer.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
@Nonnull
@Override
public SpriteIdentifier getDefaultSpriteId(@Nonnull OxygenCollectorBlockEntity entity, @Nonnull Direction direction) {
    return new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine")); // particle
}
 
Example #12
Source File: TexturedRenderLayersMixin.java    From the-hallow with MIT License 4 votes vote down vote up
@Inject(method = "addDefaultTextures", at = @At("RETURN"))
private static void injectCustomSigns(Consumer<SpriteIdentifier> consumer, CallbackInfo info) {
	consumer.accept(new SpriteIdentifier(TexturedRenderLayers.SIGNS_ATLAS_TEXTURE, ((HallowedSign)HallowedBlocks.DEADWOOD_SIGN).getTexture()));
}
 
Example #13
Source File: SignBlockEntityRendererMixin.java    From the-hallow with MIT License 4 votes vote down vote up
@Inject(method = "getModelTexture(Lnet/minecraft/block/Block;)Lnet/minecraft/client/util/SpriteIdentifier;", at = @At("HEAD"), cancellable = true)
private static void getModelTexture(Block block, CallbackInfoReturnable<SpriteIdentifier> info) {
	if (block instanceof HallowedSign) {
		info.setReturnValue(new SpriteIdentifier(TexturedRenderLayers.SIGNS_ATLAS_TEXTURE, ((HallowedSign) block).getTexture()));
	}
}