mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-24 22:14:32 +00:00
1.20.6 Initial Update
New Decompiler Runtime Official mappings ItemStacks arnt Capability providers anymore, use Vanilla's system. Co-authored-by: RealMangoRage <[email protected]> Co-authored-by: Paint_Ninja <[email protected]>
This commit is contained in:
1114 files changed
+24245
-28536
No files matched your search
@@ -39,7 +39,7 @@ public record ForgeFaceData(int color, int blockLight, int skyLight, boolean amb
|
||||
|
||||
public static final ForgeFaceData DEFAULT = new ForgeFaceData(0xFFFFFFFF, 0, 0, true, false);
|
||||
|
||||
public static final Codec<Integer> COLOR = ExtraCodecs.either(Codec.INT, Codec.STRING).xmap(
|
||||
public static final Codec<Integer> COLOR = Codec.either(Codec.INT, Codec.STRING).xmap(
|
||||
either -> either.map(Function.identity(), str -> (int) Long.parseLong(str, 16)),
|
||||
color -> Either.right(Integer.toHexString(color)));
|
||||
|
||||
@@ -65,6 +65,6 @@ public record ForgeFaceData(int color, int blockLight, int skyLight, boolean amb
|
||||
{
|
||||
return fallback;
|
||||
}
|
||||
return CODEC.parse(JsonOps.INSTANCE, obj).getOrThrow(false, JsonParseException::new);
|
||||
return CODEC.parse(JsonOps.INSTANCE, obj).getOrThrow(JsonParseException::new);
|
||||
}
|
||||
}
|
||||
@@ -23,43 +23,36 @@ import java.util.Map;
|
||||
/**
|
||||
* Wrapper around {@link ItemModelShaper} that cleans up the internal maps to respect ID remapping.
|
||||
*/
|
||||
public class ForgeItemModelShaper extends ItemModelShaper
|
||||
{
|
||||
public class ForgeItemModelShaper extends ItemModelShaper {
|
||||
private final Map<Holder.Reference<Item>, ModelResourceLocation> locations = Maps.newHashMap();
|
||||
private final Map<Holder.Reference<Item>, BakedModel> models = Maps.newHashMap();
|
||||
|
||||
public ForgeItemModelShaper(ModelManager manager)
|
||||
{
|
||||
public ForgeItemModelShaper(ModelManager manager) {
|
||||
super(manager);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public BakedModel getItemModel(Item item)
|
||||
{
|
||||
public BakedModel getItemModel(Item item) {
|
||||
return models.get(ForgeRegistries.ITEMS.getDelegateOrThrow(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(Item item, ModelResourceLocation location)
|
||||
{
|
||||
public void register(Item item, ModelResourceLocation location) {
|
||||
Holder.Reference<Item> key = ForgeRegistries.ITEMS.getDelegateOrThrow(item);
|
||||
locations.put(key, location);
|
||||
models.put(key, getModelManager().getModel(location));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rebuildCache()
|
||||
{
|
||||
public void rebuildCache() {
|
||||
final ModelManager manager = this.getModelManager();
|
||||
for (Map.Entry<Holder.Reference<Item>, ModelResourceLocation> e : locations.entrySet())
|
||||
{
|
||||
for (Map.Entry<Holder.Reference<Item>, ModelResourceLocation> e : locations.entrySet()) {
|
||||
models.put(e.getKey(), manager.getModel(e.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
public ModelResourceLocation getLocation(@NotNull ItemStack stack)
|
||||
{
|
||||
public ModelResourceLocation getLocation(@NotNull ItemStack stack) {
|
||||
ModelResourceLocation location = locations.get(ForgeRegistries.ITEMS.getDelegateOrThrow(stack.getItem()));
|
||||
return location == null ? ModelBakery.MISSING_MODEL_LOCATION : location;
|
||||
}
|
||||
|
||||
@@ -21,11 +21,9 @@ import java.util.List;
|
||||
/**
|
||||
* Convenience interface with default implementation of {@link IForgeBakedModel#getQuads(BlockState, Direction, RandomSource, ModelData, RenderType)}.
|
||||
*/
|
||||
public interface IDynamicBakedModel extends BakedModel
|
||||
{
|
||||
public interface IDynamicBakedModel extends BakedModel {
|
||||
@Override
|
||||
default @NotNull List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull RandomSource rand)
|
||||
{
|
||||
default @NotNull List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull RandomSource rand) {
|
||||
return getQuads(state, side, rand, ModelData.EMPTY, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ public interface IModelBuilder<T extends IModelBuilder<T>>
|
||||
@Override
|
||||
public BakedModel build()
|
||||
{
|
||||
return builder.build(renderTypes);
|
||||
return builder.renderTypes(renderTypes).build();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -154,7 +154,9 @@ public class ItemLayerModelBuilder<T extends ModelBuilder<T>> extends CustomLoad
|
||||
|
||||
for(Int2ObjectMap.Entry<ForgeFaceData> entry : this.faceData.int2ObjectEntrySet())
|
||||
{
|
||||
layerObj.add(String.valueOf(entry.getIntKey()), ForgeFaceData.CODEC.encodeStart(JsonOps.INSTANCE, entry.getValue()).getOrThrow(false, s -> {}));
|
||||
layerObj.add(String.valueOf(entry.getIntKey()), ForgeFaceData.CODEC.encodeStart(JsonOps.INSTANCE, entry.getValue()).getOrThrow(s -> {
|
||||
return new RuntimeException(); // Perhaps not the best way to deal with this? - MangoRage
|
||||
}));
|
||||
}
|
||||
|
||||
forgeData.add("layers", layerObj);
|
||||
|
||||
@@ -131,7 +131,7 @@ public abstract class QuadLighter
|
||||
}
|
||||
|
||||
var color = quad.isTinted() ? getColorFast(quad.getTintIndex()) : WHITE;
|
||||
consumer.putBulkData(pose, quad, brightness, color[0], color[1], color[2], lightmap, overlay, true);
|
||||
consumer.putBulkData(pose, quad, brightness, color[0], color[1], color[2], 1.0f, lightmap, overlay, true);
|
||||
}
|
||||
|
||||
private float[] getColorFast(int tintIndex)
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
package net.minecraftforge.client.model.obj;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import joptsimple.internal.Strings;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* An OBJ material library (MTL), composed of named {@link Material materials}.
|
||||
@@ -37,7 +37,7 @@ public class ObjMaterialLibrary
|
||||
{
|
||||
case "newmtl":
|
||||
{
|
||||
String name = Strings.join(Arrays.copyOfRange(line, 1, line.length), " ");
|
||||
String name = Arrays.asList(Arrays.copyOfRange(line, 1, line.length)).stream().collect(Collectors.joining(" "));
|
||||
currentMaterial = new Material(name);
|
||||
materials.put(name, currentMaterial);
|
||||
break;
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.mojang.math.Transformation;
|
||||
import joptsimple.internal.Strings;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
@@ -145,7 +144,8 @@ public class ObjModel extends SimpleUnbakedGeometry<ObjModel>
|
||||
|
||||
case "usemtl": // Sets the current material (starts new mesh)
|
||||
{
|
||||
String mat = Strings.join(Arrays.copyOfRange(line, 1, line.length), " ");
|
||||
|
||||
String mat = Arrays.asList(Arrays.copyOfRange(line, 1, line.length)).stream().collect(Collectors.joining(" "));
|
||||
ObjMaterialLibrary.Material newMat = mtllib.getMaterial(mat);
|
||||
if (!Objects.equals(newMat, currentMat))
|
||||
{
|
||||
@@ -201,7 +201,7 @@ public class ObjModel extends SimpleUnbakedGeometry<ObjModel>
|
||||
{
|
||||
String vertexData = line[i + 1];
|
||||
String[] vertexParts = vertexData.split("/");
|
||||
int[] vertex = Arrays.stream(vertexParts).mapToInt(num -> Strings.isNullOrEmpty(num) ? 0 : Integer.parseInt(num)).toArray();
|
||||
int[] vertex = Arrays.stream(vertexParts).mapToInt(num -> num == null || num.isEmpty() ? 0 : Integer.parseInt(num)).toArray();
|
||||
if (vertex[0] < 0) vertex[0] = model.positions.size() + vertex[0];
|
||||
else vertex[0]--;
|
||||
if (vertex.length > 1)
|
||||
|
||||
@@ -60,7 +60,7 @@ public class CompositeRenderable implements IRenderable<CompositeRenderable.Tran
|
||||
if (matrix != null)
|
||||
{
|
||||
poseStack.pushPose();
|
||||
poseStack.mulPoseMatrix(matrix);
|
||||
poseStack.mulPose(matrix);
|
||||
}
|
||||
|
||||
for (var part : children)
|
||||
|
||||
Reference in new issue
Block a user