com.parzivail.util.client.model.ModelRegistry Maven / Gradle / Ivy
/*******************************************************************************
* Copyright 2019 grondag
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
******************************************************************************/
package com.parzivail.util.client.model;
import net.fabricmc.fabric.api.client.model.ModelProviderContext;
import net.fabricmc.fabric.api.client.model.ModelVariantProvider;
import net.minecraft.class_1091;
import net.minecraft.class_1100;
import net.minecraft.class_1723;
import net.minecraft.class_2248;
import net.minecraft.class_2350;
import net.minecraft.class_2429;
import net.minecraft.class_2680;
import net.minecraft.class_2960;
import net.minecraft.class_4730;
import net.minecraft.class_773;
import net.minecraft.class_7923;
import java.util.EnumSet;
import java.util.HashMap;
public enum ModelRegistry implements ModelVariantProvider
{
INSTANCE;
private static final HashMap models = new HashMap<>();
public static void registerConnected(class_2429 block)
{
registerConnected(block, true, true, true, null);
}
public static void registerConnected(class_2429 block, boolean hConnect, boolean vConnect, boolean lConnect, class_2960 capTexture)
{
var id = class_7923.field_41175.method_10221(block);
registerConnected(
block, hConnect, vConnect, lConnect, capTexture,
new class_2960(id.method_12836(), "block/" + id.method_12832()),
new class_2960(id.method_12836(), "block/" + id.method_12832() + "_border")
);
}
public static void registerConnected(class_2429 block, boolean hConnect, boolean vConnect, boolean lConnect, class_2960 capTexture, class_2960 centerTexture)
{
var id = class_7923.field_41175.method_10221(block);
registerConnected(
block, hConnect, vConnect, lConnect, capTexture,
centerTexture,
new class_2960(id.method_12836(), "block/" + id.method_12832())
);
}
public static void registerConnected(class_2429 block, boolean hConnect, boolean vConnect, boolean lConnect, class_2960 capTexture, class_2960 centerTexture, class_2960 borderTexture)
{
registerConnected(block, hConnect, vConnect, lConnect, capTexture, centerTexture, borderTexture, EnumSet.of(class_2350.field_11036, class_2350.field_11033));
}
public static void registerConnected(class_2429 block, boolean hConnect, boolean vConnect, boolean lConnect, class_2960 capTexture, class_2960 centerTexture, class_2960 borderTexture, EnumSet capDirections)
{
register(block, true, new ConnectedTextureModel.Unbaked(
hConnect, vConnect, lConnect, capDirections,
new class_4730(class_1723.field_21668, centerTexture),
new class_4730(class_1723.field_21668, borderTexture),
capTexture == null ? null : new class_4730(class_1723.field_21668, capTexture)
));
}
public static void register(class_2248 block, boolean registerInventoryModel, ClonableUnbakedModel unbakedModel)
{
if (registerInventoryModel)
registerInventory(block, unbakedModel);
for (var state : block.method_9595().method_11662())
{
var id = new class_1091(class_7923.field_41175.method_10221(block), class_773.method_3338(state.method_11656()));
models.put(id, unbakedModel.copy());
}
}
public static void registerInventory(class_2248 block, ClonableUnbakedModel unbakedModel)
{
models.put(new class_1091(class_7923.field_41175.method_10221(block), "inventory"), unbakedModel.copy());
}
@Override
public class_1100 loadModelVariant(class_1091 modelId, ModelProviderContext context)
{
return models.get(modelId);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy