use of net.minecraft.client.renderer.ItemMeshDefinition in project BiomesOPlenty by Glitchfiend.
the class ClientProxy method replaceBOPBucketTexture.
@Override
public void replaceBOPBucketTexture() {
// Use BOP bucket texture
Map<Item, ItemMeshDefinition> meshMapping = ReflectionHelper.getPrivateValue(ItemModelMesher.class, Minecraft.getMinecraft().getRenderItem().getItemModelMesher(), "field_178092_c", "shapers");
final ItemMeshDefinition meshDefinition = meshMapping.get(ForgeModContainer.getInstance().universalBucket);
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ForgeModContainer.getInstance().universalBucket, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
FluidStack fluidStack = FluidUtil.getFluidContained(stack);
if (fluidStack != null && MiscConfigurationHandler.useBoPBucketTexture) {
if (fluidStack.getFluid() == BloodFluid.instance) {
return bucketModelLocations[0];
}
if (fluidStack.getFluid() == HoneyFluid.instance) {
return bucketModelLocations[1];
}
if (fluidStack.getFluid() == HotSpringWaterFluid.instance) {
return bucketModelLocations[2];
}
if (fluidStack.getFluid() == PoisonFluid.instance) {
return bucketModelLocations[3];
}
if (fluidStack.getFluid() == QuicksandFluid.instance) {
return bucketModelLocations[4];
}
}
return meshDefinition == null ? ModelDynBucket.LOCATION : meshDefinition.getModelLocation(stack);
}
});
}
use of net.minecraft.client.renderer.ItemMeshDefinition in project Skree by Skelril.
the class CustomItemSystem method render.
// Invoked via reflection
@SuppressWarnings("unused")
private void render(Object item) {
if (item instanceof Item && item instanceof ICustomItem) {
if (Sponge.getPlatform().getExecutionType().isClient()) {
RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
ItemModelMesher mesher = renderItem.getItemModelMesher();
Optional<ItemMeshDefinition> optMeshDefinition = ((ICustomItem) item).__getCustomMeshDefinition();
if (optMeshDefinition.isPresent()) {
mesher.register((Item) item, optMeshDefinition.get());
}
List<String> variants = ((ICustomItem) item).__getMeshDefinitions();
List<ResourceLocation> modelResources = new ArrayList<>();
for (int i = 0; i < variants.size(); ++i) {
ModelResourceLocation resourceLocation = new ModelResourceLocation("skree:" + variants.get(i), "inventory");
if (!optMeshDefinition.isPresent()) {
mesher.register((Item) item, i, resourceLocation);
}
modelResources.add(resourceLocation);
}
ModelBakery.registerItemVariants((Item) item, modelResources.toArray(new ResourceLocation[modelResources.size()]));
}
} else {
throw new IllegalArgumentException("Invalid custom item!");
}
}
Aggregations