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

View File

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

View File

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

View File

@ -10,8 +10,8 @@ public class SimpleMultipartClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
ModelLoadingRegistryImpl.INSTANCE.registerAppender(MultipartModelProvider::registerMultipartModels);
ModelLoadingRegistryImpl.INSTANCE.registerProvider(resourceManager -> new MultipartModelProvider());
ModelLoadingRegistryImpl.INSTANCE.registerAppender(MultipartVariantProvider::registerMultipartModels);
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);
public SlabMultipart() {
setDefaultState(getDefaultState().with(HALF, BlockHalf.LOWER));
setDefaultState(getDefaultState().with(HALF, BlockHalf.BOTTOM));
}
@Override
@ -37,11 +37,11 @@ public class SlabMultipart extends Multipart {
BlockHalf half;
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) {
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 {
half = context.getHitY() >= 0.5f ? BlockHalf.UPPER : BlockHalf.LOWER;
half = context.getHitY() >= 0.5f ? BlockHalf.TOP : BlockHalf.BOTTOM;
}
return getDefaultState().with(HALF, half);
@ -50,6 +50,6 @@ public class SlabMultipart extends Multipart {
@Override
@Deprecated
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": {
"texture": "block/gold_block"
}

View File

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

View File

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

View File

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

View File

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

View File

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