Update to latest Fabric/yarn

This commit is contained in:
Shadowfacts 2018-12-29 13:36:29 -05:00
parent 9f2f8ddf9e
commit 6ade580e85
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
13 changed files with 42 additions and 44 deletions

View File

@ -1,5 +1,5 @@
plugins { plugins {
id 'fabric-loom' version '0.1.0-SNAPSHOT' id 'fabric-loom' version '0.2.0-SNAPSHOT'
} }
sourceCompatibility = 1.8 sourceCompatibility = 1.8
@ -14,10 +14,9 @@ minecraft {
dependencies { dependencies {
minecraft "com.mojang:minecraft:18w50a" minecraft "com.mojang:minecraft:18w50a"
mappings "net.fabricmc:yarn:18w50a.63" mappings "net.fabricmc:yarn:18w50a.80"
modCompile "net.fabricmc:fabric-loader:0.3.0.73" modCompile "net.fabricmc:fabric-loader:0.3.1.80"
// Fabric API. This is technically optional, but you probably want it anyway. // Fabric API. This is technically optional, but you probably want it anyway.
// modCompile "net.fabricmc:fabric:0.1.2.62" modCompile "net.fabricmc:fabric:0.1.3.68"
modCompile files("fabric-0.1.2.local.jar") // temporary, until fabric-api #39 is merged
} }

View File

@ -75,7 +75,7 @@ public class MultipartContainerBakedModel implements BakedModel {
} }
@Override @Override
public ModelTransformation getTransformations() { public ModelTransformation getTransformation() {
return ModelTransformation.ORIGIN; return ModelTransformation.ORIGIN;
} }

View File

@ -1,10 +1,10 @@
package net.shadowfacts.simplemultipart.client; package net.shadowfacts.simplemultipart.client;
import net.fabricmc.fabric.api.client.model.ModelProvider; import net.fabricmc.fabric.api.client.model.ModelProviderContext;
import net.fabricmc.fabric.api.client.model.ModelProviderException; import net.fabricmc.fabric.api.client.model.ModelProviderException;
import net.minecraft.class_816; import net.fabricmc.fabric.api.client.model.ModelVariantProvider;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.block.BlockModels; import net.minecraft.client.render.block.BlockModels;
import net.minecraft.client.render.model.MultipartUnbakedModel;
import net.minecraft.client.render.model.UnbakedModel; import net.minecraft.client.render.model.UnbakedModel;
import net.minecraft.client.render.model.json.ModelVariantMap; import net.minecraft.client.render.model.json.ModelVariantMap;
import net.minecraft.client.render.model.json.WeightedUnbakedModel; import net.minecraft.client.render.model.json.WeightedUnbakedModel;
@ -29,10 +29,11 @@ import java.util.function.Consumer;
/** /**
* @author shadowfacts * @author shadowfacts
*/ */
public class MultipartModelProvider implements ModelProvider { public class MultipartVariantProvider implements ModelVariantProvider {
private static final Set<ModelIdentifier> multipartModels = new HashSet<>(); private static final Set<ModelIdentifier> multipartModels = new HashSet<>();
private final ResourceManager resourceManager;
private final Map<ModelIdentifier, UnbakedModel> unbakedModels = new HashMap<>(); private final Map<ModelIdentifier, UnbakedModel> unbakedModels = new HashMap<>();
static void registerMultipartModels(ResourceManager resourceManager, Consumer<ModelIdentifier> adder) { static void registerMultipartModels(ResourceManager resourceManager, Consumer<ModelIdentifier> adder) {
@ -50,22 +51,20 @@ public class MultipartModelProvider implements ModelProvider {
} }
} }
@Override public MultipartVariantProvider(ResourceManager resourceManager) {
public UnbakedModel load(Identifier id, Context context) throws ModelProviderException { this.resourceManager = resourceManager;
if (!(id instanceof ModelIdentifier)) {
return null;
} }
ModelIdentifier modelId = (ModelIdentifier)id;
@Override
if (!multipartModels.contains(modelId)) { public UnbakedModel loadModelVariant(ModelIdentifier id, ModelProviderContext context) throws ModelProviderException {
if (!multipartModels.contains(id)) {
return null; return null;
} }
try { try {
return getOrLoadPartModel(modelId); return getOrLoadPartModel(id);
} catch (IOException e) { } catch (IOException e) {
throw new ModelProviderException("Exception encountered while loading model " + id, e); throw new ModelProviderException("Exception encountered while loading multipart model " + id, e);
} }
} }
@ -87,14 +86,14 @@ public class MultipartModelProvider implements ModelProvider {
ModelVariantMap variantMap = loadPartVariantMap(blockAdapter, partStateDefId); ModelVariantMap variantMap = loadPartVariantMap(blockAdapter, partStateDefId);
if (variantMap.method_3422()) { if (variantMap.hasMultipartModel()) {
class_816 multipartUnbakedModel = variantMap.method_3421(); MultipartUnbakedModel multipartUnbakedModel = variantMap.getMultipartMdoel();
part.getStateFactory().getStates().forEach(state -> { part.getStateFactory().getStates().forEach(state -> {
ModelIdentifier stateModelId = new ModelIdentifier(partId, BlockModels.propertyMapToString(state.getEntries())); ModelIdentifier stateModelId = new ModelIdentifier(partId, BlockModels.propertyMapToString(state.getEntries()));
unbakedModels.put(stateModelId, multipartUnbakedModel); unbakedModels.put(stateModelId, multipartUnbakedModel);
}); });
} else { } else {
Map<String, WeightedUnbakedModel> variants = variantMap.method_3423(); Map<String, WeightedUnbakedModel> variants = variantMap.getVariantMap();
variants.forEach((variant, model) -> { variants.forEach((variant, model) -> {
unbakedModels.put(new ModelIdentifier(partId, variant), model); unbakedModels.put(new ModelIdentifier(partId, variant), model);
}); });
@ -111,12 +110,12 @@ public class MultipartModelProvider implements ModelProvider {
Resource resource = null; Resource resource = null;
Reader reader = null; Reader reader = null;
try { try {
resource = MinecraftClient.getInstance().getResourceManager().getResource(partStateDefId); resource = resourceManager.getResource(partStateDefId);
reader = new InputStreamReader(resource.getInputStream()); reader = new InputStreamReader(resource.getInputStream());
ModelVariantMap.class_791 context = new ModelVariantMap.class_791(); ModelVariantMap.DeserializationContext context = new ModelVariantMap.DeserializationContext();
context.method_3426(blockAdapter.getStateFactory()); context.setStateFactory(blockAdapter.getStateFactory());
return ModelVariantMap.method_3424(context, reader); return ModelVariantMap.deserialize(context, reader);
} finally { } finally {
IOUtils.closeQuietly(reader); IOUtils.closeQuietly(reader);
IOUtils.closeQuietly(resource); IOUtils.closeQuietly(resource);

View File

@ -10,8 +10,8 @@ public class SimpleMultipartClient implements ClientModInitializer {
@Override @Override
public void onInitializeClient() { public void onInitializeClient() {
ModelLoadingRegistryImpl.INSTANCE.registerAppender(MultipartModelProvider::registerMultipartModels); ModelLoadingRegistryImpl.INSTANCE.registerAppender(MultipartVariantProvider::registerMultipartModels);
ModelLoadingRegistryImpl.INSTANCE.registerProvider(resourceManager -> new MultipartModelProvider()); ModelLoadingRegistryImpl.INSTANCE.registerVariantProvider(MultipartVariantProvider::new);
} }
} }

View File

@ -22,7 +22,7 @@ public class SlabMultipart extends Multipart {
private static final VoxelShape UPPER_BOX = VoxelShapes.cube(0, 0.5f, 0, 1, 1, 1); private static final VoxelShape UPPER_BOX = VoxelShapes.cube(0, 0.5f, 0, 1, 1, 1);
public SlabMultipart() { public SlabMultipart() {
setDefaultState(getDefaultState().with(HALF, BlockHalf.LOWER)); setDefaultState(getDefaultState().with(HALF, BlockHalf.BOTTOM));
} }
@Override @Override
@ -37,11 +37,11 @@ public class SlabMultipart extends Multipart {
BlockHalf half; BlockHalf half;
if (hitSide == Direction.DOWN) { if (hitSide == Direction.DOWN) {
half = context.getHitY() >= 0.5f ? BlockHalf.LOWER : BlockHalf.UPPER; half = context.getHitY() >= 0.5f ? BlockHalf.BOTTOM : BlockHalf.TOP;
} else if (hitSide == Direction.UP) { } else if (hitSide == Direction.UP) {
half = 0.5f <= context.getHitY() && context.getHitY() < 1 ? BlockHalf.UPPER : BlockHalf.LOWER; half = 0.5f <= context.getHitY() && context.getHitY() < 1 ? BlockHalf.TOP : BlockHalf.BOTTOM;
} else { } else {
half = context.getHitY() >= 0.5f ? BlockHalf.UPPER : BlockHalf.LOWER; half = context.getHitY() >= 0.5f ? BlockHalf.TOP : BlockHalf.BOTTOM;
} }
return getDefaultState().with(HALF, half); return getDefaultState().with(HALF, half);
@ -50,6 +50,6 @@ public class SlabMultipart extends Multipart {
@Override @Override
@Deprecated @Deprecated
public VoxelShape getBoundingShape(MultipartState state, MultipartView view) { public VoxelShape getBoundingShape(MultipartState state, MultipartView view) {
return state.get(HALF) == BlockHalf.UPPER ? UPPER_BOX : LOWER_BOX; return state.get(HALF) == BlockHalf.TOP ? UPPER_BOX : LOWER_BOX;
} }
} }

View File

@ -1,5 +1,5 @@
{ {
"parent": "multipart_test:multipart/slab/upper", "parent": "multipart_test:multipart/slab/bottom",
"textures": { "textures": {
"texture": "block/gold_block" "texture": "block/gold_block"
} }

View File

@ -1,5 +1,5 @@
{ {
"parent": "multipart_test:multipart/slab/lower", "parent": "multipart_test:multipart/slab/top",
"textures": { "textures": {
"texture": "block/gold_block" "texture": "block/gold_block"
} }

View File

@ -1,5 +1,5 @@
{ {
"parent": "multipart_test:multipart/slab/lower", "parent": "multipart_test:multipart/slab/bottom",
"textures": { "textures": {
"texture": "block/iron_block" "texture": "block/iron_block"
} }

View File

@ -1,5 +1,5 @@
{ {
"parent": "multipart_test:multipart/slab/upper", "parent": "multipart_test:multipart/slab/top",
"textures": { "textures": {
"texture": "block/iron_block" "texture": "block/iron_block"
} }

View File

@ -1,7 +1,7 @@
{ {
"variants": { "variants": {
"half=upper": { "model": "multipart_test:multipart/slab/gold/upper" }, "half=top": { "model": "multipart_test:multipart/slab/gold/top" },
"half=lower": { "model": "multipart_test:multipart/slab/gold/lower" }, "half=bottom": { "model": "multipart_test:multipart/slab/gold/bottom" },
"inventory": { "model": "multipart_test:multipart/slab/gold/lower" } "inventory": { "model": "multipart_test:multipart/slab/gold/bottom" }
} }
} }

View File

@ -1,7 +1,7 @@
{ {
"variants": { "variants": {
"half=upper": { "model": "multipart_test:multipart/slab/iron/upper" }, "half=top": { "model": "multipart_test:multipart/slab/iron/top" },
"half=lower": { "model": "multipart_test:multipart/slab/iron/lower" }, "half=bottom": { "model": "multipart_test:multipart/slab/iron/bottom" },
"inventory": { "model": "multipart_test:multipart/slab/iron/lower" } "inventory": { "model": "multipart_test:multipart/slab/iron/bottom" }
} }
} }