More fixes
This commit is contained in:
@@ -31,10 +31,10 @@ import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.util.math.AffineTransformation;
|
||||
import net.minecraft.client.render.model.BakedQuad;
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.Material;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
@@ -53,10 +53,10 @@ import appeng.fluids.items.FluidDummyItem;
|
||||
* Override List is used to accomplish this.
|
||||
*/
|
||||
public class DummyFluidDispatcherBakedModel extends DelegateBakedModel {
|
||||
private final Function<Material, Sprite> bakedTextureGetter;
|
||||
private final Function<SpriteIdentifier, Sprite> bakedTextureGetter;
|
||||
|
||||
public DummyFluidDispatcherBakedModel(BakedModel baseModel,
|
||||
Function<Material, Sprite> bakedTextureGetter) {
|
||||
Function<SpriteIdentifier, Sprite> bakedTextureGetter) {
|
||||
super(baseModel);
|
||||
this.bakedTextureGetter = bakedTextureGetter;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class DummyFluidDispatcherBakedModel extends DelegateBakedModel {
|
||||
|
||||
FluidAttributes attributes = fluidStack.getFluidKey().getAttributes();
|
||||
Identifier stillTexture = attributes.getStillTexture(fluidStack);
|
||||
Material stillMaterial = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX, stillTexture);
|
||||
SpriteIdentifier stillMaterial = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, stillTexture);
|
||||
Sprite sprite = DummyFluidDispatcherBakedModel.this.bakedTextureGetter.apply(stillMaterial);
|
||||
if (sprite == null) {
|
||||
return new DummyFluidBakedModel(ImmutableList.of());
|
||||
|
||||
@@ -29,7 +29,7 @@ import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.IModelTransform;
|
||||
import net.minecraft.client.render.model.IUnbakedModel;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.render.model.Material;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.render.model.ModelLoader;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.util.Identifier;
|
||||
@@ -49,7 +49,7 @@ public class DummyFluidItemModel implements IModelGeometry<DummyFluidItemModel>
|
||||
|
||||
@Override
|
||||
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
|
||||
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
ModelOverrideList overrides, Identifier modelLocation) {
|
||||
BakedModel bakedBaseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter);
|
||||
|
||||
@@ -57,8 +57,8 @@ public class DummyFluidItemModel implements IModelGeometry<DummyFluidItemModel>
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Material> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.client.render.model.*;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraftforge.client.model.IModelConfiguration;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
@@ -45,7 +46,7 @@ public class FacadeItemModel implements IModelGeometry<FacadeItemModel> {
|
||||
|
||||
@Override
|
||||
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
|
||||
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
ModelOverrideList overrides, Identifier modelLocation) {
|
||||
BakedModel bakedBaseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter);
|
||||
FacadeBuilder facadeBuilder = new FacadeBuilder();
|
||||
@@ -54,8 +55,8 @@ public class FacadeItemModel implements IModelGeometry<FacadeItemModel> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Material> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return modelGetter.apply(MODEL_BASE).getTextures(modelGetter, missingTextureErrors);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.render;
|
||||
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
import net.minecraft.client.renderer.Quaternion;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.client.renderer.Vector4f;
|
||||
import net.minecraft.util.StringIdentifiable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
|
||||
/**
|
||||
* TODO: Removed useless stuff.
|
||||
*/
|
||||
public enum FacingToRotation implements StringIdentifiable {
|
||||
|
||||
// DUNSWE
|
||||
// @formatter:off
|
||||
DOWN_DOWN(new Vector3f(0, 0, 0)), // NOOP
|
||||
DOWN_UP(new Vector3f(0, 0, 0)), // NOOP
|
||||
DOWN_NORTH(new Vector3f(-90, 0, 0)), DOWN_SOUTH(new Vector3f(-90, 0, 180)), DOWN_WEST(new Vector3f(-90, 0, 90)),
|
||||
DOWN_EAST(new Vector3f(-90, 0, -90)), UP_DOWN(new Vector3f(0, 0, 0)), // NOOP
|
||||
UP_UP(new Vector3f(0, 0, 0)), // NOOP
|
||||
UP_NORTH(new Vector3f(90, 0, 180)), UP_SOUTH(new Vector3f(90, 0, 0)), UP_WEST(new Vector3f(90, 0, 90)),
|
||||
UP_EAST(new Vector3f(90, 0, -90)), NORTH_DOWN(new Vector3f(0, 0, 180)), NORTH_UP(new Vector3f(0, 0, 0)),
|
||||
NORTH_NORTH(new Vector3f(0, 0, 0)), // NOOP
|
||||
NORTH_SOUTH(new Vector3f(0, 0, 0)), // NOOP
|
||||
NORTH_WEST(new Vector3f(0, 0, 90)), NORTH_EAST(new Vector3f(0, 0, -90)), SOUTH_DOWN(new Vector3f(0, 180, 180)),
|
||||
SOUTH_UP(new Vector3f(0, 180, 0)), SOUTH_NORTH(new Vector3f(0, 0, 0)), // NOOP
|
||||
SOUTH_SOUTH(new Vector3f(0, 0, 0)), // NOOP
|
||||
SOUTH_WEST(new Vector3f(0, 180, -90)), SOUTH_EAST(new Vector3f(0, 180, 90)), WEST_DOWN(new Vector3f(0, 90, 180)),
|
||||
WEST_UP(new Vector3f(0, 90, 0)), WEST_NORTH(new Vector3f(0, 90, -90)), WEST_SOUTH(new Vector3f(0, 90, 90)),
|
||||
WEST_WEST(new Vector3f(0, 0, 0)), // NOOP
|
||||
WEST_EAST(new Vector3f(0, 0, 0)), // NOOP
|
||||
EAST_DOWN(new Vector3f(0, -90, 180)), EAST_UP(new Vector3f(0, -90, 0)), EAST_NORTH(new Vector3f(0, -90, 90)),
|
||||
EAST_SOUTH(new Vector3f(0, -90, -90)), EAST_WEST(new Vector3f(0, 0, 0)), // NOOP
|
||||
EAST_EAST(new Vector3f(0, 0, 0)); // NOOP
|
||||
// @formatter:on
|
||||
|
||||
private final Vector3f rot;
|
||||
private final Quaternion xRot;
|
||||
private final Quaternion yRot;
|
||||
private final Quaternion zRot;
|
||||
private final Matrix4f mat;
|
||||
|
||||
private FacingToRotation(Vector3f rot) {
|
||||
this.rot = rot;
|
||||
this.mat = new Matrix4f();
|
||||
this.mat.setIdentity();
|
||||
this.mat.mul(xRot = Vector3f.POSITIVE_X.getDegreesQuaternion(rot.getX()));
|
||||
this.mat.mul(yRot = Vector3f.POSITIVE_Y.getDegreesQuaternion(rot.getY()));
|
||||
this.mat.mul(zRot = Vector3f.POSITIVE_Z.getDegreesQuaternion(rot.getZ()));
|
||||
}
|
||||
|
||||
public boolean isRedundant() {
|
||||
return rot.getX() == 0 && rot.getY() == 0 && rot.getZ() == 0;
|
||||
}
|
||||
|
||||
public Vector3f getRot() {
|
||||
return this.rot;
|
||||
}
|
||||
|
||||
public Matrix4f getMat() {
|
||||
return new Matrix4f(this.mat);
|
||||
}
|
||||
|
||||
public void push(MatrixStack mStack) {
|
||||
mStack.multiply(xRot);
|
||||
mStack.multiply(yRot);
|
||||
mStack.multiply(zRot);
|
||||
}
|
||||
|
||||
public Direction rotate(Direction facing) {
|
||||
Vec3i dir = facing.getDirectionVec();
|
||||
Vector4f vec = new Vector4f(dir.getX(), dir.getY(), dir.getZ(), 1);
|
||||
vec.transform(mat);
|
||||
return Direction.getFacingFromVector(vec.getX(), vec.getY(), vec.getZ());
|
||||
}
|
||||
|
||||
public Direction resultingRotate(Direction facing) {
|
||||
for (Direction face : Direction.values()) {
|
||||
if (this.rotate(face) == facing) {
|
||||
return face;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static FacingToRotation get(Direction forward, Direction up) {
|
||||
return values()[forward.ordinal() * 6 + up.ordinal()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asString() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.Quaternion;
|
||||
import net.minecraft.util.math.Quaternion;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
|
||||
@@ -127,7 +127,7 @@ public class TesrRenderHelper {
|
||||
matrixStack.scale(1.0f / 62.0f, -1.0f / 62.0f, 1.0f / 62.0f);
|
||||
matrixStack.scale(0.5f, 0.5f, 0);
|
||||
matrixStack.translate(-0.5f * width, 0.0f, 0.5f);
|
||||
fr.renderString(renderedStackSize, 0, 0, -1, false, matrixStack.getLast().getMatrix(), buffers, false, 0,
|
||||
fr.renderString(renderedStackSize, 0, 0, -1, false, matrixStack.peek().getMatrix(), buffers, false, 0,
|
||||
15728880);
|
||||
matrixStack.pop();
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.client.render.model.BakedQuad;
|
||||
import net.minecraft.client.render.model.Material;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.util.math.Direction;
|
||||
@@ -49,7 +49,7 @@ class CableBuilder {
|
||||
|
||||
private final SmartCableTextures smartCableTextures;
|
||||
|
||||
CableBuilder(Function<Material, Sprite> bakedTextureGetter) {
|
||||
CableBuilder(Function<SpriteIdentifier, Sprite> bakedTextureGetter) {
|
||||
this.coreTextures = new EnumMap<>(CableCoreType.class);
|
||||
|
||||
for (CableCoreType type : CableCoreType.values()) {
|
||||
@@ -77,7 +77,7 @@ class CableBuilder {
|
||||
this.smartCableTextures = new SmartCableTextures(bakedTextureGetter);
|
||||
}
|
||||
|
||||
static Material getConnectionTexture(AECableType cableType, AEColor color) {
|
||||
static SpriteIdentifier getConnectionTexture(AECableType cableType, AEColor color) {
|
||||
String textureFolder;
|
||||
switch (cableType) {
|
||||
case GLASS:
|
||||
@@ -99,7 +99,7 @@ class CableBuilder {
|
||||
throw new IllegalStateException("Cable type " + cableType + " does not support connections.");
|
||||
}
|
||||
|
||||
return new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
return new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
new Identifier(AppEng.MOD_ID, textureFolder + color.name().toLowerCase()));
|
||||
}
|
||||
|
||||
@@ -701,8 +701,8 @@ class CableBuilder {
|
||||
}
|
||||
|
||||
// Get all textures needed for building the actual cable quads
|
||||
public static List<Material> getTextures() {
|
||||
List<Material> locations = new ArrayList<>();
|
||||
public static List<SpriteIdentifier> getTextures() {
|
||||
List<SpriteIdentifier> locations = new ArrayList<>();
|
||||
|
||||
for (CableCoreType coreType : CableCoreType.values()) {
|
||||
for (AEColor color : AEColor.values()) {
|
||||
|
||||
@@ -31,7 +31,7 @@ import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.IModelTransform;
|
||||
import net.minecraft.client.render.model.IUnbakedModel;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.render.model.Material;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.render.model.ModelLoader;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.util.Identifier;
|
||||
@@ -55,7 +55,7 @@ public class CableBusModel implements IModelGeometry<CableBusModel> {
|
||||
|
||||
@Override
|
||||
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
|
||||
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
ModelOverrideList overrides, Identifier modelLocation) {
|
||||
Map<Identifier, BakedModel> partModels = this.loadPartModels(bakery, spriteGetter, modelTransform);
|
||||
|
||||
@@ -71,13 +71,13 @@ public class CableBusModel implements IModelGeometry<CableBusModel> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Material> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return Collections.unmodifiableList(CableBuilder.getTextures());
|
||||
}
|
||||
|
||||
private Map<Identifier, BakedModel> loadPartModels(ModelLoader bakery,
|
||||
Function<Material, Sprite> spriteGetterIn, IModelTransform transformIn) {
|
||||
Function<SpriteIdentifier, Sprite> spriteGetterIn, IModelTransform transformIn) {
|
||||
ImmutableMap.Builder<Identifier, BakedModel> result = ImmutableMap.builder();
|
||||
|
||||
for (Identifier location : this.partModels.getModels()) {
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.Map;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.client.render.model.Material;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
@@ -72,8 +72,8 @@ public enum CableCoreType {
|
||||
return cableMapping.get(cableType);
|
||||
}
|
||||
|
||||
public Material getTexture(AEColor color) {
|
||||
return new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
public SpriteIdentifier getTexture(AEColor color) {
|
||||
return new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
new Identifier(AppEng.MOD_ID, this.textureFolder + "/" + color.name().toLowerCase()));
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.List;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.client.renderer.Vector4f;
|
||||
import net.minecraft.client.util.math.Vector4f;
|
||||
import net.minecraft.client.render.model.BakedQuad;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.IModelTransform;
|
||||
import net.minecraft.client.render.model.IUnbakedModel;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.render.model.Material;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.render.model.ModelLoader;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
@@ -22,12 +22,12 @@ import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public class P2PTunnelFrequencyModel implements IModelGeometry<P2PTunnelFrequencyModel> {
|
||||
private static final Material TEXTURE = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
private static final SpriteIdentifier TEXTURE = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
new Identifier(AppEng.MOD_ID, "parts/p2p_tunnel_frequency"));
|
||||
|
||||
@Override
|
||||
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
|
||||
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
ModelOverrideList overrides, Identifier modelLocation) {
|
||||
try {
|
||||
final Sprite texture = spriteGetter.apply(TEXTURE);
|
||||
@@ -38,8 +38,8 @@ public class P2PTunnelFrequencyModel implements IModelGeometry<P2PTunnelFrequenc
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Material> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return Collections.singleton(TEXTURE);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ package appeng.client.render.cablebus;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.client.render.model.Material;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.util.Identifier;
|
||||
@@ -33,7 +33,7 @@ import appeng.core.AppEng;
|
||||
*/
|
||||
public class SmartCableTextures {
|
||||
|
||||
public static final Material[] SMART_CHANNELS_TEXTURES = Arrays
|
||||
public static final SpriteIdentifier[] SMART_CHANNELS_TEXTURES = Arrays
|
||||
.stream(new Identifier[] { new Identifier(AppEng.MOD_ID, "parts/cable/smart/channels_00"), //
|
||||
new Identifier(AppEng.MOD_ID, "parts/cable/smart/channels_01"), //
|
||||
new Identifier(AppEng.MOD_ID, "parts/cable/smart/channels_02"), //
|
||||
@@ -44,14 +44,14 @@ public class SmartCableTextures {
|
||||
new Identifier(AppEng.MOD_ID, "parts/cable/smart/channels_12"), //
|
||||
new Identifier(AppEng.MOD_ID, "parts/cable/smart/channels_13"), //
|
||||
new Identifier(AppEng.MOD_ID, "parts/cable/smart/channels_14")//
|
||||
}).map(e -> new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX, e)).toArray(Material[]::new);
|
||||
}).map(e -> new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, e)).toArray(SpriteIdentifier[]::new);
|
||||
|
||||
// Textures used to display channels on smart cables. There's two sets of 5
|
||||
// textures each, and
|
||||
// one of each set are composed together to get even/odd colored channels
|
||||
private final Sprite[] textures;
|
||||
|
||||
public SmartCableTextures(Function<Material, Sprite> bakedTextureGetter) {
|
||||
public SmartCableTextures(Function<SpriteIdentifier, Sprite> bakedTextureGetter) {
|
||||
this.textures = Arrays.stream(SMART_CHANNELS_TEXTURES)//
|
||||
.map(bakedTextureGetter)//
|
||||
.toArray(Sprite[]::new);
|
||||
|
||||
@@ -29,7 +29,7 @@ import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.IModelTransform;
|
||||
import net.minecraft.client.render.model.IUnbakedModel;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.render.model.Material;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.render.model.ModelLoader;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
@@ -45,20 +45,20 @@ import appeng.core.AppEng;
|
||||
*/
|
||||
class CraftingCubeModel implements IModelGeometry<CraftingCubeModel> {
|
||||
|
||||
private final static Material RING_CORNER = texture("ring_corner");
|
||||
private final static Material RING_SIDE_HOR = texture("ring_side_hor");
|
||||
private final static Material RING_SIDE_VER = texture("ring_side_ver");
|
||||
private final static Material UNIT_BASE = texture("unit_base");
|
||||
private final static Material LIGHT_BASE = texture("light_base");
|
||||
private final static Material ACCELERATOR_LIGHT = texture("accelerator_light");
|
||||
private final static Material STORAGE_1K_LIGHT = texture("1k_storage_light");
|
||||
private final static Material STORAGE_4K_LIGHT = texture("4k_storage_light");
|
||||
private final static Material STORAGE_16K_LIGHT = texture("16k_storage_light");
|
||||
private final static Material STORAGE_64K_LIGHT = texture("64k_storage_light");
|
||||
private final static Material MONITOR_BASE = texture("monitor_base");
|
||||
private final static Material MONITOR_LIGHT_DARK = texture("monitor_light_dark");
|
||||
private final static Material MONITOR_LIGHT_MEDIUM = texture("monitor_light_medium");
|
||||
private final static Material MONITOR_LIGHT_BRIGHT = texture("monitor_light_bright");
|
||||
private final static SpriteIdentifier RING_CORNER = texture("ring_corner");
|
||||
private final static SpriteIdentifier RING_SIDE_HOR = texture("ring_side_hor");
|
||||
private final static SpriteIdentifier RING_SIDE_VER = texture("ring_side_ver");
|
||||
private final static SpriteIdentifier UNIT_BASE = texture("unit_base");
|
||||
private final static SpriteIdentifier LIGHT_BASE = texture("light_base");
|
||||
private final static SpriteIdentifier ACCELERATOR_LIGHT = texture("accelerator_light");
|
||||
private final static SpriteIdentifier STORAGE_1K_LIGHT = texture("1k_storage_light");
|
||||
private final static SpriteIdentifier STORAGE_4K_LIGHT = texture("4k_storage_light");
|
||||
private final static SpriteIdentifier STORAGE_16K_LIGHT = texture("16k_storage_light");
|
||||
private final static SpriteIdentifier STORAGE_64K_LIGHT = texture("64k_storage_light");
|
||||
private final static SpriteIdentifier MONITOR_BASE = texture("monitor_base");
|
||||
private final static SpriteIdentifier MONITOR_LIGHT_DARK = texture("monitor_light_dark");
|
||||
private final static SpriteIdentifier MONITOR_LIGHT_MEDIUM = texture("monitor_light_medium");
|
||||
private final static SpriteIdentifier MONITOR_LIGHT_BRIGHT = texture("monitor_light_bright");
|
||||
|
||||
private final AbstractCraftingUnitBlock.CraftingUnitType type;
|
||||
|
||||
@@ -67,8 +67,8 @@ class CraftingCubeModel implements IModelGeometry<CraftingCubeModel> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Material> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return ImmutableList.of(RING_CORNER, RING_SIDE_HOR, RING_SIDE_VER, UNIT_BASE, LIGHT_BASE, ACCELERATOR_LIGHT,
|
||||
STORAGE_1K_LIGHT, STORAGE_4K_LIGHT, STORAGE_16K_LIGHT, STORAGE_64K_LIGHT, MONITOR_BASE,
|
||||
MONITOR_LIGHT_DARK, MONITOR_LIGHT_MEDIUM, MONITOR_LIGHT_BRIGHT);
|
||||
@@ -76,7 +76,7 @@ class CraftingCubeModel implements IModelGeometry<CraftingCubeModel> {
|
||||
|
||||
@Override
|
||||
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
|
||||
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
ModelOverrideList overrides, Identifier modelLocation) {
|
||||
// Retrieve our textures and pass them on to the baked model
|
||||
Sprite ringCorner = spriteGetter.apply(RING_CORNER);
|
||||
@@ -102,7 +102,7 @@ class CraftingCubeModel implements IModelGeometry<CraftingCubeModel> {
|
||||
}
|
||||
}
|
||||
|
||||
private static Sprite getLightTexture(Function<Material, Sprite> textureGetter,
|
||||
private static Sprite getLightTexture(Function<SpriteIdentifier, Sprite> textureGetter,
|
||||
AbstractCraftingUnitBlock.CraftingUnitType type) {
|
||||
switch (type) {
|
||||
case ACCELERATOR:
|
||||
@@ -120,8 +120,8 @@ class CraftingCubeModel implements IModelGeometry<CraftingCubeModel> {
|
||||
}
|
||||
}
|
||||
|
||||
private static Material texture(String name) {
|
||||
return new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
private static SpriteIdentifier texture(String name) {
|
||||
return new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
new Identifier(AppEng.MOD_ID, "block/crafting/" + name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.IModelTransform;
|
||||
import net.minecraft.client.render.model.IUnbakedModel;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.render.model.Material;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.render.model.ModelLoader;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.util.Identifier;
|
||||
@@ -29,14 +29,14 @@ public class EncodedPatternModel implements IModelGeometry<EncodedPatternModel>
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Material> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return modelGetter.apply(baseModel).getTextures(modelGetter, missingTextureErrors);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
|
||||
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
ModelOverrideList overrides, Identifier modelLocation) {
|
||||
BakedModel baseModel = bakery.getBakedModel(this.baseModel, modelTransform, spriteGetter);
|
||||
return new EncodedPatternBakedModel(baseModel);
|
||||
|
||||
@@ -34,7 +34,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.json.ModelTransformation;
|
||||
import net.minecraft.client.renderer.Vector4f;
|
||||
import net.minecraft.client.util.math.Vector4f;
|
||||
import net.minecraft.client.render.model.BakedQuad;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
@@ -262,11 +262,11 @@ public class AutoRotatingBakedModel implements BakedModel {
|
||||
} else {
|
||||
switch (fs.length) {
|
||||
case 3:
|
||||
Vec3i vec = this.f2r.rotate(this.face).getDirectionVec();
|
||||
Vec3i vec = this.f2r.rotate(this.face).getVector();
|
||||
return new float[] { vec.getX(), vec.getY(), vec.getZ() };
|
||||
case 4:
|
||||
Vector4f veccc = new Vector4f(fs[0], fs[1], fs[2], fs[3]);
|
||||
Vec3i vecc = this.f2r.rotate(this.face).getDirectionVec();
|
||||
Vec3i vecc = this.f2r.rotate(this.face).getVector();
|
||||
return new float[] { vecc.getX(), vecc.getY(), vecc.getZ(), veccc.getW() };
|
||||
|
||||
default:
|
||||
|
||||
@@ -13,7 +13,7 @@ import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.IModelTransform;
|
||||
import net.minecraft.client.render.model.IUnbakedModel;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.render.model.Material;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.render.model.ModelLoader;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
@@ -30,19 +30,19 @@ import appeng.core.AppEng;
|
||||
public class BiometricCardModel implements IModelGeometry<BiometricCardModel> {
|
||||
|
||||
public static final Identifier MODEL_BASE = new Identifier(AppEng.MOD_ID, "item/biometric_card_base");
|
||||
private static final Material TEXTURE = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
private static final SpriteIdentifier TEXTURE = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
new Identifier(AppEng.MOD_ID, "item/biometric_card_hash"));
|
||||
|
||||
@Override
|
||||
public Collection<Material> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return Collections.singleton(TEXTURE);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
|
||||
Function<Material, Sprite> spriteGetter, IModelTransform transformIn,
|
||||
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform transformIn,
|
||||
ModelOverrideList overrides, Identifier locationIn) {
|
||||
Sprite texture = spriteGetter.apply(TEXTURE);
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.IModelTransform;
|
||||
import net.minecraft.client.render.model.IUnbakedModel;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.render.model.Material;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.render.model.ModelLoader;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
@@ -30,22 +30,22 @@ public class ColorApplicatorModel implements IModelGeometry<ColorApplicatorModel
|
||||
private static final Identifier MODEL_BASE = new Identifier(AppEng.MOD_ID,
|
||||
"item/color_applicator_colored");
|
||||
|
||||
private static final Material TEXTURE_DARK = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
private static final SpriteIdentifier TEXTURE_DARK = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
new Identifier(AppEng.MOD_ID, "item/color_applicator_tip_dark"));
|
||||
private static final Material TEXTURE_MEDIUM = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
private static final SpriteIdentifier TEXTURE_MEDIUM = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
new Identifier(AppEng.MOD_ID, "item/color_applicator_tip_medium"));
|
||||
private static final Material TEXTURE_BRIGHT = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
private static final SpriteIdentifier TEXTURE_BRIGHT = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
new Identifier(AppEng.MOD_ID, "item/color_applicator_tip_bright"));
|
||||
|
||||
@Override
|
||||
public Collection<Material> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return Arrays.asList(TEXTURE_DARK, TEXTURE_MEDIUM, TEXTURE_DARK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
|
||||
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
ModelOverrideList overrides, Identifier modelLocation) {
|
||||
BakedModel baseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter);
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.IModelTransform;
|
||||
import net.minecraft.client.render.model.IUnbakedModel;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.render.model.Material;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.render.model.ModelLoader;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.util.Identifier;
|
||||
@@ -57,7 +57,7 @@ public class DriveModel implements IModelGeometry<DriveModel> {
|
||||
|
||||
@Override
|
||||
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
|
||||
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
ModelOverrideList overrides, Identifier modelLocation) {
|
||||
EnumMap<DriveSlotCellType, BakedModel> cellModels = new EnumMap<>(DriveSlotCellType.class);
|
||||
|
||||
@@ -72,8 +72,8 @@ public class DriveModel implements IModelGeometry<DriveModel> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Material> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ import com.google.common.base.Strings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.render.model.BakedQuad;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.render.model.Material;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
@@ -64,30 +64,30 @@ class GlassBakedModel implements IDynamicBakedModel {
|
||||
private static final byte[][][] OFFSETS = generateOffsets();
|
||||
|
||||
// Alternating textures based on position
|
||||
static final Material TEXTURE_A = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
static final SpriteIdentifier TEXTURE_A = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
new Identifier("appliedenergistics2:block/glass/quartz_glass_a"));
|
||||
static final Material TEXTURE_B = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
static final SpriteIdentifier TEXTURE_B = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
new Identifier("appliedenergistics2:block/glass/quartz_glass_b"));
|
||||
static final Material TEXTURE_C = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
static final SpriteIdentifier TEXTURE_C = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
new Identifier("appliedenergistics2:block/glass/quartz_glass_c"));
|
||||
static final Material TEXTURE_D = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
static final SpriteIdentifier TEXTURE_D = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
new Identifier("appliedenergistics2:block/glass/quartz_glass_d"));
|
||||
|
||||
// Frame texture
|
||||
static final Material[] TEXTURES_FRAME = generateTexturesFrame();
|
||||
static final SpriteIdentifier[] TEXTURES_FRAME = generateTexturesFrame();
|
||||
|
||||
// Generates the required textures for the frame
|
||||
private static Material[] generateTexturesFrame() {
|
||||
private static SpriteIdentifier[] generateTexturesFrame() {
|
||||
return IntStream.range(1, 16).mapToObj(Integer::toBinaryString).map(s -> Strings.padStart(s, 4, '0'))
|
||||
.map(s -> new Identifier("appliedenergistics2:block/glass/quartz_glass_frame" + s))
|
||||
.map(rl -> new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX, rl)).toArray(Material[]::new);
|
||||
.map(rl -> new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, rl)).toArray(SpriteIdentifier[]::new);
|
||||
}
|
||||
|
||||
private final Sprite[] glassTextures;
|
||||
|
||||
private final Sprite[] frameTextures;
|
||||
|
||||
public GlassBakedModel(Function<Material, Sprite> bakedTextureGetter) {
|
||||
public GlassBakedModel(Function<SpriteIdentifier, Sprite> bakedTextureGetter) {
|
||||
this.glassTextures = new Sprite[] { bakedTextureGetter.apply(TEXTURE_A),
|
||||
bakedTextureGetter.apply(TEXTURE_B), bakedTextureGetter.apply(TEXTURE_C),
|
||||
bakedTextureGetter.apply(TEXTURE_D) };
|
||||
@@ -212,7 +212,7 @@ class GlassBakedModel implements IDynamicBakedModel {
|
||||
|
||||
private BakedQuad createQuad(Direction side, Vec3d c1, Vec3d c2, Vec3d c3, Vec3d c4, Sprite sprite,
|
||||
float uOffset, float vOffset) {
|
||||
Vec3d normal = new Vec3d(side.getDirectionVec());
|
||||
Vec3d normal = new Vec3d(side.getVector());
|
||||
|
||||
// Apply the u,v shift.
|
||||
// This mirrors the logic from OffsetIcon from 1.7
|
||||
|
||||
@@ -29,7 +29,7 @@ import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.IModelTransform;
|
||||
import net.minecraft.client.render.model.IUnbakedModel;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.render.model.Material;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.render.model.ModelLoader;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.util.Identifier;
|
||||
@@ -43,16 +43,16 @@ public class GlassModel implements IModelGeometry<GlassModel> {
|
||||
|
||||
@Override
|
||||
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
|
||||
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
ModelOverrideList overrides, Identifier modelLocation) {
|
||||
return new GlassBakedModel(spriteGetter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Material> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return ImmutableSet
|
||||
.<Material>builder().add(GlassBakedModel.TEXTURE_A, GlassBakedModel.TEXTURE_B,
|
||||
.<SpriteIdentifier>builder().add(GlassBakedModel.TEXTURE_A, GlassBakedModel.TEXTURE_B,
|
||||
GlassBakedModel.TEXTURE_C, GlassBakedModel.TEXTURE_D)
|
||||
.add(GlassBakedModel.TEXTURES_FRAME).build();
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ package appeng.client.render.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.math.Vector4f;
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
import net.minecraft.client.renderer.Vector4f;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
|
||||
@@ -13,7 +13,7 @@ import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.IModelTransform;
|
||||
import net.minecraft.client.render.model.IUnbakedModel;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.render.model.Material;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.render.model.ModelLoader;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
@@ -30,19 +30,19 @@ import appeng.core.AppEng;
|
||||
public class MemoryCardModel implements IModelGeometry<MemoryCardModel> {
|
||||
|
||||
public static final Identifier MODEL_BASE = new Identifier(AppEng.MOD_ID, "item/memory_card_base");
|
||||
private static final Material TEXTURE = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
private static final SpriteIdentifier TEXTURE = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
new Identifier(AppEng.MOD_ID, "item/memory_card_hash"));
|
||||
|
||||
@Override
|
||||
public Collection<Material> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return Collections.singleton(TEXTURE);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
|
||||
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
ModelOverrideList overrides, Identifier modelLocation) {
|
||||
Sprite texture = spriteGetter.apply(TEXTURE);
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.json.ModelTransformation;
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
import net.minecraft.client.renderer.Quaternion;
|
||||
import net.minecraft.util.math.Quaternion;
|
||||
import net.minecraft.client.render.model.BakedQuad;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
@@ -89,8 +89,8 @@ public class SkyCompassBakedModel implements IDynamicBakedModel {
|
||||
if (side == null) {
|
||||
// Set up the rotation around the Y-axis for the pointer
|
||||
Matrix4f matrix = new Matrix4f();
|
||||
matrix.setIdentity();
|
||||
matrix.mul(new Quaternion(0, rotation, 0, false));
|
||||
matrix.loadIdentity();
|
||||
matrix.multiply(new Quaternion(0, rotation, 0, false));
|
||||
|
||||
MatrixVertexTransformer transformer = new MatrixVertexTransformer(matrix);
|
||||
for (BakedQuad bakedQuad : this.pointer.getQuads(state, side, rand, extraData)) {
|
||||
|
||||
@@ -31,7 +31,7 @@ import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.IModelTransform;
|
||||
import net.minecraft.client.render.model.IUnbakedModel;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.render.model.Material;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.render.model.ModelLoader;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.util.Identifier;
|
||||
@@ -54,7 +54,7 @@ public class SkyCompassModel implements IModelGeometry<SkyCompassModel> {
|
||||
|
||||
@Override
|
||||
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
|
||||
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
ModelOverrideList overrides, Identifier modelLocation) {
|
||||
BakedModel baseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter);
|
||||
BakedModel pointerModel = bakery.getBakedModel(MODEL_POINTER, modelTransform, spriteGetter);
|
||||
@@ -62,8 +62,8 @@ public class SkyCompassModel implements IModelGeometry<SkyCompassModel> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Material> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ import net.minecraft.client.render.model.IUnbakedModel;
|
||||
import net.minecraft.client.render.model.ItemOverride;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.render.model.ItemTransformVec3f;
|
||||
import net.minecraft.client.render.model.Material;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
@@ -143,7 +143,7 @@ public class UVLModelLoader implements IModelLoader<UVLModelLoader.UVLModelWrapp
|
||||
|
||||
@Override
|
||||
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
|
||||
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
ModelOverrideList overrides, Identifier modelLocation) {
|
||||
Sprite particle = spriteGetter.apply(owner.resolveTexture("particle"));
|
||||
|
||||
@@ -199,9 +199,9 @@ public class UVLModelLoader implements IModelLoader<UVLModelLoader.UVLModelWrapp
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Material> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter,
|
||||
Set<com.mojang.datafixers.util.Pair<String, String>> missingTextureErrors) {
|
||||
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter,
|
||||
Set<com.mojang.datafixers.util.Pair<String, String>> missingTextureErrors) {
|
||||
return parent.getTextures(modelGetter, missingTextureErrors);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.IModelTransform;
|
||||
import net.minecraft.client.render.model.IUnbakedModel;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.render.model.Material;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.render.model.ModelLoader;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
@@ -46,7 +46,7 @@ public class SpatialPylonModel implements IModelGeometry<SpatialPylonModel> {
|
||||
|
||||
@Override
|
||||
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
|
||||
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
ModelOverrideList overrides, Identifier modelLocation) {
|
||||
Map<SpatialPylonTextureType, Sprite> textures = new EnumMap<>(SpatialPylonTextureType.class);
|
||||
|
||||
@@ -58,14 +58,14 @@ public class SpatialPylonModel implements IModelGeometry<SpatialPylonModel> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Material> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return Arrays.stream(SpatialPylonTextureType.values()).map(SpatialPylonModel::getTexturePath)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static Material getTexturePath(SpatialPylonTextureType type) {
|
||||
return new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
private static SpriteIdentifier getTexturePath(SpatialPylonTextureType type) {
|
||||
return new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
new Identifier(AppEng.MOD_ID, "block/spatial_pylon/" + type.name().toLowerCase()));
|
||||
}
|
||||
|
||||
|
||||
@@ -27,9 +27,9 @@ import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.Atlases;
|
||||
import net.minecraft.client.render.TexturedRenderLayers;
|
||||
import net.minecraft.client.render.block.BlockRenderManager;
|
||||
import net.minecraft.client.renderer.Quaternion;
|
||||
import net.minecraft.util.math.Quaternion;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
||||
|
||||
@@ -62,8 +62,8 @@ public class CrankTESR extends BlockEntityRenderer<CrankBlockEntity> {
|
||||
BlockState blockState = te.getCachedState();
|
||||
BlockRenderManager dispatcher = MinecraftClient.getInstance().getBlockRenderManager();
|
||||
BakedModel model = dispatcher.getModelForState(blockState);
|
||||
VertexConsumer buffer = buffers.getBuffer(Atlases.getTranslucentBlockType());
|
||||
dispatcher.getBlockModelRenderer().renderModelBrightnessColor(ms.getLast(), buffer, null, model, 1, 1, 1,
|
||||
VertexConsumer buffer = buffers.getBuffer(TexturedRenderLayers.getEntityTranslucentCull());
|
||||
dispatcher.getModelRenderer().renderModelBrightnessColor(ms.peek(), buffer, null, model, 1, 1, 1,
|
||||
combinedLightIn, combinedOverlayIn);
|
||||
ms.pop();
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ public class DriveLedTileEntityRenderer extends BlockEntityRenderer<DriveBlockEn
|
||||
float x = LED_QUADS[i];
|
||||
float y = LED_QUADS[i + 1];
|
||||
float z = LED_QUADS[i + 2];
|
||||
buffer.pos(ms.getLast().getMatrix(), x, y, z).color(color.getX(), color.getY(), color.getZ(), 1.f)
|
||||
buffer.pos(ms.peek().getMatrix(), x, y, z).color(color.getX(), color.getY(), color.getZ(), 1.f)
|
||||
.endVertex();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@ import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.model.json.ModelTransformation;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.Quaternion;
|
||||
import net.minecraft.util.math.Quaternion;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.model.Material;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.inventory.container.PlayerContainer;
|
||||
@@ -35,7 +35,7 @@ public final class InscriberTESR extends BlockEntityRenderer<InscriberBlockEntit
|
||||
|
||||
private static final float ITEM_RENDER_SCALE = 1.0f / 1.2f;
|
||||
|
||||
private static final Material TEXTURE_INSIDE = new Material(PlayerContainer.LOCATION_BLOCKS_TEXTURE,
|
||||
private static final SpriteIdentifier TEXTURE_INSIDE = new SpriteIdentifier(PlayerContainer.LOCATION_BLOCKS_TEXTURE,
|
||||
new Identifier(AppEng.MOD_ID, "block/inscriber_inside"));
|
||||
|
||||
public InscriberTESR(BlockEntityRenderDispatcher rendererDispatcherIn) {
|
||||
@@ -173,12 +173,12 @@ public final class InscriberTESR extends BlockEntityRenderer<InscriberBlockEntit
|
||||
|
||||
private static void addVertex(VertexConsumer vb, MatrixStack ms, Sprite sprite, float x, float y,
|
||||
float z, double texU, double texV, int overlayUV, int lightmapUV, Direction front) {
|
||||
vb.pos(ms.getLast().getMatrix(), x, y, z);
|
||||
vb.pos(ms.peek().getMatrix(), x, y, z);
|
||||
vb.color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
vb.tex(sprite.getInterpolatedU(texU), sprite.getInterpolatedV(texV));
|
||||
vb.overlay(overlayUV);
|
||||
vb.lightmap(lightmapUV);
|
||||
vb.normal(ms.getLast().getNormal(), front.getOffsetX(), front.getOffsetY(), front.getOffsetZ());
|
||||
vb.normal(ms.peek().getNormal(), front.getOffsetX(), front.getOffsetY(), front.getOffsetZ());
|
||||
vb.endVertex();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.render.tesr;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.Atlases;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.client.render.model.Material;
|
||||
import net.minecraft.client.render.model.ModelRenderer;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
|
||||
import appeng.block.storage.SkyChestBlock;
|
||||
import appeng.block.storage.SkyChestBlock.SkyChestType;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.storage.SkyChestBlockEntity;
|
||||
|
||||
// This is mostly a copy&paste job of the vanilla chest TESR
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class SkyChestTESR extends BlockEntityRenderer<SkyChestBlockEntity> {
|
||||
|
||||
public static final Material TEXTURE_STONE = new Material(Atlases.CHEST_ATLAS,
|
||||
new Identifier(AppEng.MOD_ID, "models/skychest"));
|
||||
public static final Material TEXTURE_BLOCK = new Material(Atlases.CHEST_ATLAS,
|
||||
new Identifier(AppEng.MOD_ID, "models/skyblockchest"));
|
||||
|
||||
private final ModelRenderer singleLid;
|
||||
private final ModelRenderer singleBottom;
|
||||
private final ModelRenderer singleLatch;
|
||||
|
||||
public SkyChestTESR(BlockEntityRenderDispatcher rendererDispatcherIn) {
|
||||
super(rendererDispatcherIn);
|
||||
|
||||
this.singleBottom = new ModelRenderer(64, 64, 0, 19);
|
||||
this.singleBottom.addBox(1.0F, 0.0F, 1.0F, 14.0F, 10.0F, 14.0F, 0.0F);
|
||||
this.singleLid = new ModelRenderer(64, 64, 0, 0);
|
||||
this.singleLid.addBox(1.0F, 0.0F, 0.0F, 14.0F, 5.0F, 14.0F, 0.0F);
|
||||
this.singleLid.rotationPointY = 9.0F;
|
||||
this.singleLid.rotationPointZ = 1.0F;
|
||||
this.singleLatch = new ModelRenderer(64, 64, 0, 0);
|
||||
this.singleLatch.addBox(7.0F, -1.0F, 15.0F, 2.0F, 4.0F, 1.0F, 0.0F);
|
||||
this.singleLatch.rotationPointY = 8.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(SkyChestBlockEntity tileEntityIn, float partialTicks, MatrixStack matrixStackIn,
|
||||
VertexConsumerProvider bufferIn, int combinedLightIn, int combinedOverlayIn) {
|
||||
matrixStackIn.push();
|
||||
float f = tileEntityIn.getForward().getHorizontalAngle();
|
||||
matrixStackIn.translate(0.5D, 0.5D, 0.5D);
|
||||
matrixStackIn.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-f));
|
||||
matrixStackIn.translate(-0.5D, -0.5D, -0.5D);
|
||||
|
||||
float f1 = tileEntityIn.getLidAngle(partialTicks);
|
||||
f1 = 1.0F - f1;
|
||||
f1 = 1.0F - f1 * f1 * f1;
|
||||
Material material = this.getMaterial(tileEntityIn);
|
||||
VertexConsumer ivertexbuilder = material.getBuffer(bufferIn, RenderLayer::getEntityCutout);
|
||||
this.renderModels(matrixStackIn, ivertexbuilder, this.singleLid, this.singleLatch, this.singleBottom, f1,
|
||||
combinedLightIn, combinedOverlayIn);
|
||||
|
||||
matrixStackIn.pop();
|
||||
}
|
||||
|
||||
private void renderModels(MatrixStack matrixStackIn, VertexConsumer bufferIn, ModelRenderer chestLid,
|
||||
ModelRenderer chestLatch, ModelRenderer chestBottom, float lidAngle, int combinedLightIn,
|
||||
int combinedOverlayIn) {
|
||||
chestLid.rotateAngleX = -(lidAngle * 1.5707964F);
|
||||
chestLatch.rotateAngleX = chestLid.rotateAngleX;
|
||||
chestLid.render(matrixStackIn, bufferIn, combinedLightIn, combinedOverlayIn);
|
||||
chestLatch.render(matrixStackIn, bufferIn, combinedLightIn, combinedOverlayIn);
|
||||
chestBottom.render(matrixStackIn, bufferIn, combinedLightIn, combinedOverlayIn);
|
||||
}
|
||||
|
||||
protected Material getMaterial(SkyChestBlockEntity tileEntity) {
|
||||
SkyChestType type = SkyChestType.BLOCK;
|
||||
if (tileEntity.getWorld() != null) {
|
||||
Block blockType = tileEntity.getCachedState().getBlock();
|
||||
|
||||
if (blockType instanceof SkyChestBlock) {
|
||||
type = ((SkyChestBlock) blockType).type;
|
||||
}
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case STONE:
|
||||
return TEXTURE_STONE;
|
||||
default:
|
||||
case BLOCK:
|
||||
return TEXTURE_BLOCK;
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerTextures(TextureStitchEvent.Pre evt) {
|
||||
if (evt.getMap().getTextureLocation().equals(Atlases.CHEST_ATLAS)) {
|
||||
evt.addSprite(TEXTURE_STONE.getTextureLocation());
|
||||
evt.addSprite(TEXTURE_BLOCK.getTextureLocation());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.render.tesr;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.renderer.Atlases;
|
||||
import net.minecraft.client.render.block.BlockRenderManager;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
|
||||
import appeng.client.render.FacingToRotation;
|
||||
import appeng.client.render.model.SkyCompassBakedModel;
|
||||
import appeng.tile.misc.SkyCompassBlockEntity;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class SkyCompassTESR extends BlockEntityRenderer<SkyCompassBlockEntity> {
|
||||
|
||||
private static BlockRenderManager blockRenderer;
|
||||
|
||||
public SkyCompassTESR(BlockEntityRenderDispatcher rendererDispatcherIn) {
|
||||
super(rendererDispatcherIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(SkyCompassBlockEntity te, float partialTicks, MatrixStack ms, VertexConsumerProvider buffers,
|
||||
int combinedLightIn, int combinedOverlayIn) {
|
||||
|
||||
if (blockRenderer == null) {
|
||||
blockRenderer = MinecraftClient.getInstance().getBlockRenderManager();
|
||||
}
|
||||
|
||||
VertexConsumer buffer = buffers.getBuffer(Atlases.getTranslucentBlockType());
|
||||
|
||||
BlockState blockState = te.getCachedState();
|
||||
BakedModel model = blockRenderer.getBlockModelShapes().getModel(blockState);
|
||||
|
||||
// FIXME: Rotation was previously handled by an auto rotating model I think, but
|
||||
// FIXME: Should be handled using matrices instead
|
||||
Direction forward = te.getForward();
|
||||
Direction up = te.getUp();
|
||||
// This ensures the needle isn't flipped by the model rotator. Since the model
|
||||
// is symmetrical, this should
|
||||
// not affect the appearance
|
||||
if (forward == Direction.UP || forward == Direction.DOWN) {
|
||||
up = Direction.NORTH;
|
||||
}
|
||||
// Flip forward/up for rendering, the base model is facing up without any
|
||||
// rotation
|
||||
ms.push();
|
||||
ms.translate(0.5D, 0.5D, 0.5D);
|
||||
FacingToRotation.get(up, forward).push(ms);
|
||||
ms.translate(-0.5D, -0.5D, -0.5D);
|
||||
|
||||
ModelDataMap modelData = new ModelDataMap.Builder().withInitial(SkyCompassBakedModel.ROTATION, getRotation(te))
|
||||
.build();
|
||||
|
||||
blockRenderer.getBlockModelRenderer().renderModel(ms.getLast(), buffer, null, model, 1, 1, 1, combinedLightIn,
|
||||
combinedOverlayIn, modelData);
|
||||
ms.pop();
|
||||
|
||||
}
|
||||
|
||||
private static float getRotation(SkyCompassBlockEntity skyCompass) {
|
||||
float rotation;
|
||||
|
||||
if (skyCompass.getForward() == Direction.UP || skyCompass.getForward() == Direction.DOWN) {
|
||||
rotation = SkyCompassBakedModel.getAnimatedRotation(skyCompass.getPos(), false);
|
||||
} else {
|
||||
rotation = SkyCompassBakedModel.getAnimatedRotation(null, false);
|
||||
}
|
||||
|
||||
if (skyCompass.getForward() == Direction.DOWN) {
|
||||
rotation = flipidiy(rotation);
|
||||
}
|
||||
|
||||
return rotation;
|
||||
}
|
||||
|
||||
private static float flipidiy(float rad) {
|
||||
float x = (float) Math.cos(rad);
|
||||
float y = (float) Math.sin(rad);
|
||||
return (float) Math.atan2(-y, x);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user