mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-28 16:06:48 +01:00
Cleanup
This commit is contained in:
parent
c9718b0a1b
commit
9be5a3ec2a
21 changed files with 135 additions and 204 deletions
|
@ -2,12 +2,12 @@ package com.simibubi.create.content.contraptions.goggles;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.foundation.block.render.WrappedBakedModel;
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
import net.minecraft.client.renderer.model.IBakedModel;
|
||||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||||
|
import net.minecraftforge.client.model.BakedModelWrapper;
|
||||||
|
|
||||||
public class GogglesModel extends WrappedBakedModel {
|
public class GogglesModel extends BakedModelWrapper<IBakedModel> {
|
||||||
|
|
||||||
public GogglesModel(IBakedModel template) {
|
public GogglesModel(IBakedModel template) {
|
||||||
super(template);
|
super(template);
|
||||||
|
|
|
@ -3,12 +3,12 @@ package com.simibubi.create.content.contraptions.relays.belt;
|
||||||
import static com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity.CASING_PROPERTY;
|
import static com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity.CASING_PROPERTY;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import com.simibubi.create.AllSpriteShifts;
|
import com.simibubi.create.AllSpriteShifts;
|
||||||
import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity.CasingType;
|
import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity.CasingType;
|
||||||
|
import com.simibubi.create.foundation.block.render.QuadHelper;
|
||||||
import com.simibubi.create.foundation.block.render.SpriteShiftEntry;
|
import com.simibubi.create.foundation.block.render.SpriteShiftEntry;
|
||||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||||
|
|
||||||
|
@ -30,14 +30,16 @@ public class BeltModel extends BakedModelWrapper<IBakedModel> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BakedQuad> getQuads(BlockState state, Direction side, Random rand, IModelData extraData) {
|
public List<BakedQuad> getQuads(BlockState state, Direction side, Random rand, IModelData extraData) {
|
||||||
List<BakedQuad> quads = new ArrayList<>(super.getQuads(state, side, rand, extraData));
|
List<BakedQuad> quads = super.getQuads(state, side, rand, extraData);
|
||||||
if (!extraData.hasProperty(CASING_PROPERTY))
|
if (!extraData.hasProperty(CASING_PROPERTY))
|
||||||
return quads;
|
return quads;
|
||||||
CasingType type = extraData.getData(CASING_PROPERTY);
|
CasingType type = extraData.getData(CASING_PROPERTY);
|
||||||
if (type == CasingType.NONE || type == CasingType.BRASS)
|
if (type == CasingType.NONE || type == CasingType.BRASS)
|
||||||
return quads;
|
return quads;
|
||||||
|
quads = new ArrayList<>(quads);
|
||||||
|
|
||||||
SpriteShiftEntry spriteShift = AllSpriteShifts.ANDESIDE_BELT_CASING;
|
SpriteShiftEntry spriteShift = AllSpriteShifts.ANDESIDE_BELT_CASING;
|
||||||
|
VertexFormat format = DefaultVertexFormats.BLOCK;
|
||||||
|
|
||||||
for (int i = 0; i < quads.size(); i++) {
|
for (int i = 0; i < quads.size(); i++) {
|
||||||
BakedQuad quad = quads.get(i);
|
BakedQuad quad = quads.get(i);
|
||||||
|
@ -48,10 +50,7 @@ public class BeltModel extends BakedModelWrapper<IBakedModel> {
|
||||||
|
|
||||||
TextureAtlasSprite original = quad.getSprite();
|
TextureAtlasSprite original = quad.getSprite();
|
||||||
TextureAtlasSprite target = spriteShift.getTarget();
|
TextureAtlasSprite target = spriteShift.getTarget();
|
||||||
BakedQuad newQuad = new BakedQuad(Arrays.copyOf(quad.getVertexData(), quad.getVertexData().length),
|
BakedQuad newQuad = QuadHelper.clone(quad);
|
||||||
quad.getTintIndex(), quad.getFace(), target, quad.hasShade());
|
|
||||||
|
|
||||||
VertexFormat format = DefaultVertexFormats.BLOCK;
|
|
||||||
int[] vertexData = newQuad.getVertexData();
|
int[] vertexData = newQuad.getVertexData();
|
||||||
|
|
||||||
for (int vertex = 0; vertex < vertexData.length; vertex += format.getIntegerSize()) {
|
for (int vertex = 0; vertex < vertexData.length; vertex += format.getIntegerSize()) {
|
||||||
|
@ -61,9 +60,9 @@ public class BeltModel extends BakedModelWrapper<IBakedModel> {
|
||||||
float u = Float.intBitsToFloat(vertexData[uIndex]);
|
float u = Float.intBitsToFloat(vertexData[uIndex]);
|
||||||
float v = Float.intBitsToFloat(vertexData[vIndex]);
|
float v = Float.intBitsToFloat(vertexData[vIndex]);
|
||||||
vertexData[uIndex] =
|
vertexData[uIndex] =
|
||||||
Float.floatToRawIntBits(target.getInterpolatedU((SuperByteBuffer.getUnInterpolatedU(original, u))));
|
Float.floatToRawIntBits(target.getInterpolatedU(SuperByteBuffer.getUnInterpolatedU(original, u)));
|
||||||
vertexData[vIndex] =
|
vertexData[vIndex] =
|
||||||
Float.floatToRawIntBits(target.getInterpolatedV((SuperByteBuffer.getUnInterpolatedV(original, v))));
|
Float.floatToRawIntBits(target.getInterpolatedV(SuperByteBuffer.getUnInterpolatedV(original, v)));
|
||||||
}
|
}
|
||||||
|
|
||||||
quads.set(i, newQuad);
|
quads.set(i, newQuad);
|
||||||
|
|
|
@ -495,7 +495,7 @@ public class BeltTileEntity extends KineticTileEntity implements LightUpdateList
|
||||||
return empty;
|
return empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ModelProperty<CasingType> CASING_PROPERTY = new ModelProperty<>();
|
public static final ModelProperty<CasingType> CASING_PROPERTY = new ModelProperty<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IModelData getModelData() {
|
public IModelData getModelData() {
|
||||||
|
|
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import com.simibubi.create.foundation.block.render.WrappedBakedModel;
|
|
||||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||||
import com.simibubi.create.foundation.utility.VirtualEmptyModelData;
|
import com.simibubi.create.foundation.utility.VirtualEmptyModelData;
|
||||||
|
|
||||||
|
@ -15,11 +14,12 @@ import net.minecraft.client.renderer.model.IBakedModel;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockDisplayReader;
|
import net.minecraft.world.IBlockDisplayReader;
|
||||||
|
import net.minecraftforge.client.model.BakedModelWrapper;
|
||||||
import net.minecraftforge.client.model.data.IModelData;
|
import net.minecraftforge.client.model.data.IModelData;
|
||||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||||
import net.minecraftforge.client.model.data.ModelProperty;
|
import net.minecraftforge.client.model.data.ModelProperty;
|
||||||
|
|
||||||
public class BracketedKineticBlockModel extends WrappedBakedModel {
|
public class BracketedKineticBlockModel extends BakedModelWrapper<IBakedModel> {
|
||||||
|
|
||||||
private static ModelProperty<BracketedModelData> BRACKET_PROPERTY = new ModelProperty<>();
|
private static ModelProperty<BracketedModelData> BRACKET_PROPERTY = new ModelProperty<>();
|
||||||
|
|
||||||
|
|
|
@ -7,22 +7,23 @@ import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollVal
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
|
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
import net.minecraft.util.math.vector.Vector3f;
|
||||||
|
|
||||||
public class WrenchItemRenderer extends CustomRenderedItemModelRenderer<WrenchModel> {
|
public class WrenchItemRenderer extends CustomRenderedItemModelRenderer<WrenchModel> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void render(ItemStack stack, WrenchModel model, PartialItemModelRenderer renderer, MatrixStack ms,
|
protected void render(ItemStack stack, WrenchModel model, PartialItemModelRenderer renderer, ItemCameraTransforms.TransformType transformType,
|
||||||
IRenderTypeBuffer buffer, int light, int overlay) {
|
MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
|
||||||
renderer.render(model.getBakedModel(), light);
|
renderer.render(model.getOriginalModel(), light);
|
||||||
|
|
||||||
float xOffset = -1/16f;
|
float xOffset = -1/16f;
|
||||||
ms.translate(-xOffset, 0, 0);
|
ms.translate(-xOffset, 0, 0);
|
||||||
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(ScrollValueHandler.getScroll(AnimationTickHolder.getPartialTicks())));
|
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(ScrollValueHandler.getScroll(AnimationTickHolder.getPartialTicks())));
|
||||||
ms.translate(xOffset, 0, 0);
|
ms.translate(xOffset, 0, 0);
|
||||||
|
|
||||||
renderer.render(model.getPartial("gear"), light);
|
renderer.render(model.getPartial("gear"), light);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.simibubi.create.foundation.item.PartialItemModelRenderer;
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
|
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
import net.minecraft.util.math.vector.Vector3f;
|
||||||
|
@ -13,21 +14,21 @@ import net.minecraft.util.math.vector.Vector3f;
|
||||||
public class SymmetryWandItemRenderer extends CustomRenderedItemModelRenderer<SymmetryWandModel> {
|
public class SymmetryWandItemRenderer extends CustomRenderedItemModelRenderer<SymmetryWandModel> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void render(ItemStack stack, SymmetryWandModel model, PartialItemModelRenderer renderer, MatrixStack ms,
|
protected void render(ItemStack stack, SymmetryWandModel model, PartialItemModelRenderer renderer, ItemCameraTransforms.TransformType transformType,
|
||||||
IRenderTypeBuffer buffer, int light, int overlay) {
|
MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
|
||||||
float worldTime = AnimationTickHolder.getRenderTime() / 20;
|
float worldTime = AnimationTickHolder.getRenderTime() / 20;
|
||||||
int maxLight = 0xF000F0;
|
int maxLight = 0xF000F0;
|
||||||
|
|
||||||
renderer.render(model.getBakedModel(), light);
|
renderer.render(model.getOriginalModel(), light);
|
||||||
renderer.renderSolidGlowing(model.getPartial("core"), maxLight);
|
renderer.renderSolidGlowing(model.getPartial("core"), maxLight);
|
||||||
renderer.renderGlowing(model.getPartial("core_glow"), maxLight);
|
renderer.renderGlowing(model.getPartial("core_glow"), maxLight);
|
||||||
|
|
||||||
float floating = MathHelper.sin(worldTime) * .05f;
|
float floating = MathHelper.sin(worldTime) * .05f;
|
||||||
float angle = worldTime * -10 % 360;
|
float angle = worldTime * -10 % 360;
|
||||||
|
|
||||||
ms.translate(0, floating, 0);
|
ms.translate(0, floating, 0);
|
||||||
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(angle));
|
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(angle));
|
||||||
|
|
||||||
renderer.renderGlowing(model.getPartial("bits"), maxLight);
|
renderer.renderGlowing(model.getPartial("bits"), maxLight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,25 +6,25 @@ import com.simibubi.create.foundation.item.PartialItemModelRenderer;
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
|
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
import net.minecraft.util.math.vector.Vector3f;
|
||||||
|
|
||||||
public class DeforesterItemRenderer extends CustomRenderedItemModelRenderer<DeforesterModel> {
|
public class DeforesterItemRenderer extends CustomRenderedItemModelRenderer<DeforesterModel> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void render(ItemStack stack, DeforesterModel model, PartialItemModelRenderer renderer,
|
protected void render(ItemStack stack, DeforesterModel model, PartialItemModelRenderer renderer, ItemCameraTransforms.TransformType transformType,
|
||||||
MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
|
MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
|
||||||
int maxLight = 0xF000F0;
|
int maxLight = 0xF000F0;
|
||||||
float worldTime = AnimationTickHolder.getRenderTime();
|
float worldTime = AnimationTickHolder.getRenderTime();
|
||||||
|
|
||||||
renderer.renderSolid(model.getBakedModel(), light);
|
renderer.renderSolid(model.getOriginalModel(), light);
|
||||||
renderer.renderSolidGlowing(model.getPartial("core"), maxLight);
|
renderer.renderSolidGlowing(model.getPartial("core"), maxLight);
|
||||||
renderer.renderGlowing(model.getPartial("core_glow"), maxLight);
|
renderer.renderGlowing(model.getPartial("core_glow"), maxLight);
|
||||||
|
|
||||||
float angle = worldTime * -.5f % 360;
|
float angle = worldTime * -.5f % 360;
|
||||||
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(angle));
|
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(angle));
|
||||||
renderer.renderSolid(model.getPartial("gear"), light);
|
renderer.renderSolid(model.getPartial("gear"), light);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,12 @@ public class ExtendoGripItemRenderer extends CustomRenderedItemModelRenderer<Ext
|
||||||
private static final Vector3d cogRotationOffset = new Vector3d(0, 1 / 16f, 0);
|
private static final Vector3d cogRotationOffset = new Vector3d(0, 1 / 16f, 0);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void render(ItemStack stack, ExtendoGripModel model, PartialItemModelRenderer renderer, MatrixStack ms,
|
protected void render(ItemStack stack, ExtendoGripModel model, PartialItemModelRenderer renderer, TransformType transformType,
|
||||||
IRenderTypeBuffer buffer, int light, int overlay) {
|
MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
|
||||||
MatrixStacker stacker = MatrixStacker.of(ms);
|
MatrixStacker stacker = MatrixStacker.of(ms);
|
||||||
float animation = 0.25f;
|
float animation = 0.25f;
|
||||||
TransformType perspective = model.getCurrentPerspective();
|
boolean leftHand = transformType == TransformType.FIRST_PERSON_LEFT_HAND;
|
||||||
boolean leftHand = perspective == TransformType.FIRST_PERSON_LEFT_HAND;
|
boolean rightHand = transformType == TransformType.FIRST_PERSON_RIGHT_HAND;
|
||||||
boolean rightHand = perspective == TransformType.FIRST_PERSON_RIGHT_HAND;
|
|
||||||
if (leftHand || rightHand)
|
if (leftHand || rightHand)
|
||||||
animation = MathHelper.lerp(AnimationTickHolder.getPartialTicks(),
|
animation = MathHelper.lerp(AnimationTickHolder.getPartialTicks(),
|
||||||
ExtendoGripRenderHandler.lastMainHandAnimation,
|
ExtendoGripRenderHandler.lastMainHandAnimation,
|
||||||
|
@ -37,7 +36,7 @@ public class ExtendoGripItemRenderer extends CustomRenderedItemModelRenderer<Ext
|
||||||
float oppositeAngle = 180 - extensionAngle;
|
float oppositeAngle = 180 - extensionAngle;
|
||||||
|
|
||||||
// grip
|
// grip
|
||||||
renderer.renderSolid(model.getBakedModel(), light);
|
renderer.renderSolid(model.getOriginalModel(), light);
|
||||||
|
|
||||||
// bits
|
// bits
|
||||||
ms.push();
|
ms.push();
|
||||||
|
|
|
@ -35,12 +35,10 @@ public class ExtendoGripRenderHandler {
|
||||||
lastMainHandAnimation = mainHandAnimation;
|
lastMainHandAnimation = mainHandAnimation;
|
||||||
mainHandAnimation *= MathHelper.clamp(mainHandAnimation, 0.8f, 0.99f);
|
mainHandAnimation *= MathHelper.clamp(mainHandAnimation, 0.8f, 0.99f);
|
||||||
|
|
||||||
Minecraft mc = Minecraft.getInstance();
|
|
||||||
ClientPlayerEntity player = mc.player;
|
|
||||||
pose = AllBlockPartials.DEPLOYER_HAND_PUNCHING;
|
pose = AllBlockPartials.DEPLOYER_HAND_PUNCHING;
|
||||||
if (!AllItems.EXTENDO_GRIP.isIn(player.getHeldItemOffhand()))
|
if (!AllItems.EXTENDO_GRIP.isIn(getRenderedOffHandStack()))
|
||||||
return;
|
return;
|
||||||
ItemStack main = player.getHeldItemMainhand();
|
ItemStack main = getRenderedMainHandStack();
|
||||||
if (main.isEmpty())
|
if (main.isEmpty())
|
||||||
return;
|
return;
|
||||||
if (!(main.getItem() instanceof BlockItem))
|
if (!(main.getItem() instanceof BlockItem))
|
||||||
|
@ -60,7 +58,7 @@ public class ExtendoGripRenderHandler {
|
||||||
ClientPlayerEntity player = mc.player;
|
ClientPlayerEntity player = mc.player;
|
||||||
boolean rightHand = event.getHand() == Hand.MAIN_HAND ^ player.getPrimaryHand() == HandSide.LEFT;
|
boolean rightHand = event.getHand() == Hand.MAIN_HAND ^ player.getPrimaryHand() == HandSide.LEFT;
|
||||||
|
|
||||||
ItemStack offhandItem = player.getHeldItemOffhand();
|
ItemStack offhandItem = getRenderedOffHandStack();
|
||||||
boolean notInOffhand = !AllItems.EXTENDO_GRIP.isIn(offhandItem);
|
boolean notInOffhand = !AllItems.EXTENDO_GRIP.isIn(offhandItem);
|
||||||
if (notInOffhand && !AllItems.EXTENDO_GRIP.isIn(heldItem))
|
if (notInOffhand && !AllItems.EXTENDO_GRIP.isIn(heldItem))
|
||||||
return;
|
return;
|
||||||
|
@ -138,4 +136,12 @@ public class ExtendoGripRenderHandler {
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ItemStack getRenderedMainHandStack() {
|
||||||
|
return Minecraft.getInstance().getFirstPersonRenderer().itemStackMainHand;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ItemStack getRenderedOffHandStack() {
|
||||||
|
return Minecraft.getInstance().getFirstPersonRenderer().itemStackOffHand;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
import net.minecraft.client.renderer.ItemRenderer;
|
import net.minecraft.client.renderer.ItemRenderer;
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
import net.minecraft.client.renderer.model.IBakedModel;
|
||||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
|
||||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||||
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
|
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -20,15 +19,14 @@ import net.minecraft.util.math.vector.Vector3f;
|
||||||
public class SandPaperItemRenderer extends ItemStackTileEntityRenderer {
|
public class SandPaperItemRenderer extends ItemStackTileEntityRenderer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(ItemStack stack, ItemCameraTransforms.TransformType p_239207_2_, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
|
public void render(ItemStack stack, TransformType transformType, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
|
||||||
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
|
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
|
||||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
ClientPlayerEntity player = Minecraft.getInstance().player;
|
||||||
SandPaperModel mainModel = (SandPaperModel) itemRenderer.getItemModelWithOverrides(stack, Minecraft.getInstance().world, null);
|
SandPaperModel mainModel = (SandPaperModel) itemRenderer.getItemModelWithOverrides(stack, Minecraft.getInstance().world, null);
|
||||||
TransformType perspective = mainModel.getCurrentPerspective();
|
|
||||||
float partialTicks = AnimationTickHolder.getPartialTicks();
|
float partialTicks = AnimationTickHolder.getPartialTicks();
|
||||||
|
|
||||||
boolean leftHand = perspective == TransformType.FIRST_PERSON_LEFT_HAND;
|
boolean leftHand = transformType == TransformType.FIRST_PERSON_LEFT_HAND;
|
||||||
boolean firstPerson = leftHand || perspective == TransformType.FIRST_PERSON_RIGHT_HAND;
|
boolean firstPerson = leftHand || transformType == TransformType.FIRST_PERSON_RIGHT_HAND;
|
||||||
|
|
||||||
ms.push();
|
ms.push();
|
||||||
ms.translate(.5f, .5f, .5f);
|
ms.translate(.5f, .5f, .5f);
|
||||||
|
@ -39,7 +37,7 @@ public class SandPaperItemRenderer extends ItemStackTileEntityRenderer {
|
||||||
if (tag.contains("Polishing")) {
|
if (tag.contains("Polishing")) {
|
||||||
ms.push();
|
ms.push();
|
||||||
|
|
||||||
if (perspective == TransformType.GUI) {
|
if (transformType == TransformType.GUI) {
|
||||||
ms.translate(0.0F, .2f, 1.0F);
|
ms.translate(0.0F, .2f, 1.0F);
|
||||||
ms.scale(.75f, .75f, .75f);
|
ms.scale(.75f, .75f, .75f);
|
||||||
} else {
|
} else {
|
||||||
|
@ -53,7 +51,7 @@ public class SandPaperItemRenderer extends ItemStackTileEntityRenderer {
|
||||||
if (time / (float) stack.getUseDuration() < 0.8F) {
|
if (time / (float) stack.getUseDuration() < 0.8F) {
|
||||||
float bobbing = -MathHelper.abs(MathHelper.cos(time / 4.0F * (float) Math.PI) * 0.1F);
|
float bobbing = -MathHelper.abs(MathHelper.cos(time / 4.0F * (float) Math.PI) * 0.1F);
|
||||||
|
|
||||||
if (perspective == TransformType.GUI)
|
if (transformType == TransformType.GUI)
|
||||||
ms.translate(bobbing, bobbing, 0.0F);
|
ms.translate(bobbing, bobbing, 0.0F);
|
||||||
else
|
else
|
||||||
ms.translate(0.0f, bobbing, 0.0F);
|
ms.translate(0.0f, bobbing, 0.0F);
|
||||||
|
@ -76,7 +74,7 @@ public class SandPaperItemRenderer extends ItemStackTileEntityRenderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, light, overlay, mainModel.getBakedModel());
|
itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, light, overlay, mainModel.getOriginalModel());
|
||||||
|
|
||||||
ms.pop();
|
ms.pop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,10 @@ import net.minecraft.util.math.MathHelper;
|
||||||
public abstract class ZapperItemRenderer<M extends CustomRenderedItemModel> extends CustomRenderedItemModelRenderer<M> {
|
public abstract class ZapperItemRenderer<M extends CustomRenderedItemModel> extends CustomRenderedItemModelRenderer<M> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void render(ItemStack stack, M model, PartialItemModelRenderer renderer, MatrixStack ms,
|
protected void render(ItemStack stack, M model, PartialItemModelRenderer renderer, TransformType transformType,
|
||||||
IRenderTypeBuffer buffer, int light, int overlay) {
|
MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
|
||||||
// Block indicator
|
// Block indicator
|
||||||
if (model.getCurrentPerspective() == TransformType.GUI && stack.hasTag() && stack.getTag()
|
if (transformType == TransformType.GUI && stack.hasTag() && stack.getTag()
|
||||||
.contains("BlockUsed"))
|
.contains("BlockUsed"))
|
||||||
renderBlockUsed(stack, ms, buffer, light, overlay);
|
renderBlockUsed(stack, ms, buffer, light, overlay);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
import net.minecraft.client.renderer.LightTexture;
|
import net.minecraft.client.renderer.LightTexture;
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
import net.minecraft.client.renderer.model.IBakedModel;
|
||||||
|
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.HandSide;
|
import net.minecraft.util.HandSide;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
@ -28,14 +29,14 @@ import net.minecraft.util.math.vector.Vector3f;
|
||||||
public class BlockzapperItemRenderer extends ZapperItemRenderer<BlockzapperModel> {
|
public class BlockzapperItemRenderer extends ZapperItemRenderer<BlockzapperModel> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void render(ItemStack stack, BlockzapperModel model, PartialItemModelRenderer renderer, MatrixStack ms,
|
protected void render(ItemStack stack, BlockzapperModel model, PartialItemModelRenderer renderer, ItemCameraTransforms.TransformType transformType,
|
||||||
IRenderTypeBuffer buffer, int light, int overlay) {
|
MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
|
||||||
super.render(stack, model, renderer, ms, buffer, light, overlay);
|
super.render(stack, model, renderer, transformType, ms, buffer, light, overlay);
|
||||||
|
|
||||||
float pt = AnimationTickHolder.getPartialTicks();
|
float pt = AnimationTickHolder.getPartialTicks();
|
||||||
float worldTime = AnimationTickHolder.getRenderTime() / 20;
|
float worldTime = AnimationTickHolder.getRenderTime() / 20;
|
||||||
|
|
||||||
renderer.render(model.getBakedModel(), light);
|
renderer.render(model.getOriginalModel(), light);
|
||||||
renderComponent(stack, model, Body, renderer, light);
|
renderComponent(stack, model, Body, renderer, light);
|
||||||
renderComponent(stack, model, Amplifier, renderer, light);
|
renderComponent(stack, model, Amplifier, renderer, light);
|
||||||
renderComponent(stack, model, Retriever, renderer, light);
|
renderComponent(stack, model, Retriever, renderer, light);
|
||||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
import net.minecraft.client.renderer.LightTexture;
|
import net.minecraft.client.renderer.LightTexture;
|
||||||
|
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.HandSide;
|
import net.minecraft.util.HandSide;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
@ -20,14 +21,14 @@ import net.minecraft.util.math.vector.Vector3f;
|
||||||
public class WorldshaperItemRenderer extends ZapperItemRenderer<WorldshaperModel> {
|
public class WorldshaperItemRenderer extends ZapperItemRenderer<WorldshaperModel> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void render(ItemStack stack, WorldshaperModel model, PartialItemModelRenderer renderer, MatrixStack ms,
|
protected void render(ItemStack stack, WorldshaperModel model, PartialItemModelRenderer renderer, ItemCameraTransforms.TransformType transformType,
|
||||||
IRenderTypeBuffer buffer, int light, int overlay) {
|
MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
|
||||||
super.render(stack, model, renderer, ms, buffer, light, overlay);
|
super.render(stack, model, renderer, transformType, ms, buffer, light, overlay);
|
||||||
|
|
||||||
float pt = AnimationTickHolder.getPartialTicks();
|
float pt = AnimationTickHolder.getPartialTicks();
|
||||||
float worldTime = AnimationTickHolder.getRenderTime() / 20;
|
float worldTime = AnimationTickHolder.getRenderTime() / 20;
|
||||||
|
|
||||||
renderer.renderSolid(model.getBakedModel(), light);
|
renderer.renderSolid(model.getOriginalModel(), light);
|
||||||
|
|
||||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
ClientPlayerEntity player = Minecraft.getInstance().player;
|
||||||
boolean leftHanded = player.getPrimaryHand() == HandSide.LEFT;
|
boolean leftHanded = player.getPrimaryHand() == HandSide.LEFT;
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour.CTContext;
|
import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour.CTContext;
|
||||||
|
import com.simibubi.create.foundation.block.render.QuadHelper;
|
||||||
import com.simibubi.create.foundation.utility.Iterate;
|
import com.simibubi.create.foundation.utility.Iterate;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -23,7 +24,7 @@ import net.minecraftforge.client.model.data.ModelProperty;
|
||||||
|
|
||||||
public class CTModel extends BakedModelWrapperWithData {
|
public class CTModel extends BakedModelWrapperWithData {
|
||||||
|
|
||||||
protected static ModelProperty<CTData> CT_PROPERTY = new ModelProperty<>();
|
protected static final ModelProperty<CTData> CT_PROPERTY = new ModelProperty<>();
|
||||||
private ConnectedTextureBehaviour behaviour;
|
private ConnectedTextureBehaviour behaviour;
|
||||||
|
|
||||||
private class CTData {
|
private class CTData {
|
||||||
|
@ -42,7 +43,7 @@ public class CTModel extends BakedModelWrapperWithData {
|
||||||
return indices[face.getIndex()];
|
return indices[face.getIndex()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CTModel(IBakedModel originalModel, ConnectedTextureBehaviour behaviour) {
|
public CTModel(IBakedModel originalModel, ConnectedTextureBehaviour behaviour) {
|
||||||
super(originalModel);
|
super(originalModel);
|
||||||
this.behaviour = behaviour;
|
this.behaviour = behaviour;
|
||||||
|
@ -69,10 +70,13 @@ public class CTModel extends BakedModelWrapperWithData {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BakedQuad> getQuads(BlockState state, Direction side, Random rand, IModelData extraData) {
|
public List<BakedQuad> getQuads(BlockState state, Direction side, Random rand, IModelData extraData) {
|
||||||
List<BakedQuad> quads = new ArrayList<>(super.getQuads(state, side, rand, extraData));
|
List<BakedQuad> quads = super.getQuads(state, side, rand, extraData);
|
||||||
if (!extraData.hasProperty(CT_PROPERTY))
|
if (!extraData.hasProperty(CT_PROPERTY))
|
||||||
return quads;
|
return quads;
|
||||||
CTData data = extraData.getData(CT_PROPERTY);
|
CTData data = extraData.getData(CT_PROPERTY);
|
||||||
|
quads = new ArrayList<>(quads);
|
||||||
|
|
||||||
|
VertexFormat format = DefaultVertexFormats.BLOCK;
|
||||||
|
|
||||||
for (int i = 0; i < quads.size(); i++) {
|
for (int i = 0; i < quads.size(); i++) {
|
||||||
BakedQuad quad = quads.get(i);
|
BakedQuad quad = quads.get(i);
|
||||||
|
@ -86,9 +90,7 @@ public class CTModel extends BakedModelWrapperWithData {
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BakedQuad newQuad = new BakedQuad(Arrays.copyOf(quad.getVertexData(), quad.getVertexData().length),
|
BakedQuad newQuad = QuadHelper.clone(quad);
|
||||||
quad.getTintIndex(), quad.getFace(), quad.getSprite(), quad.hasShade());
|
|
||||||
VertexFormat format = DefaultVertexFormats.BLOCK;
|
|
||||||
int[] vertexData = newQuad.getVertexData();
|
int[] vertexData = newQuad.getVertexData();
|
||||||
|
|
||||||
for (int vertex = 0; vertex < vertexData.length; vertex += format.getIntegerSize()) {
|
for (int vertex = 0; vertex < vertexData.length; vertex += format.getIntegerSize()) {
|
||||||
|
@ -100,6 +102,7 @@ public class CTModel extends BakedModelWrapperWithData {
|
||||||
vertexData[uIndex] = Float.floatToRawIntBits(spriteShift.getTargetU(u, index));
|
vertexData[uIndex] = Float.floatToRawIntBits(spriteShift.getTargetU(u, index));
|
||||||
vertexData[vIndex] = Float.floatToRawIntBits(spriteShift.getTargetV(v, index));
|
vertexData[vIndex] = Float.floatToRawIntBits(spriteShift.getTargetV(v, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
quads.set(i, newQuad);
|
quads.set(i, newQuad);
|
||||||
}
|
}
|
||||||
return quads;
|
return quads;
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
package com.simibubi.create.foundation.block.render;
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
|
||||||
|
|
||||||
public class BakedModelBuiltInRenderer extends WrappedBakedModel {
|
|
||||||
|
|
||||||
public BakedModelBuiltInRenderer(IBakedModel template) {
|
|
||||||
super(template);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isBuiltInRenderer() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.simibubi.create.foundation.block.render;
|
package com.simibubi.create.foundation.block.render;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
@ -23,8 +22,8 @@ import net.minecraftforge.client.model.data.ModelProperty;
|
||||||
|
|
||||||
public class ColoredVertexModel extends BakedModelWrapper<IBakedModel> {
|
public class ColoredVertexModel extends BakedModelWrapper<IBakedModel> {
|
||||||
|
|
||||||
|
private static final ModelProperty<BlockPos> POSITION_PROPERTY = new ModelProperty<>();
|
||||||
private IBlockVertexColor color;
|
private IBlockVertexColor color;
|
||||||
private static ModelProperty<BlockPos> POSITION_PROPERTY = new ModelProperty<>();
|
|
||||||
|
|
||||||
public ColoredVertexModel(IBakedModel originalModel, IBlockVertexColor color) {
|
public ColoredVertexModel(IBakedModel originalModel, IBlockVertexColor color) {
|
||||||
super(originalModel);
|
super(originalModel);
|
||||||
|
@ -38,27 +37,28 @@ public class ColoredVertexModel extends BakedModelWrapper<IBakedModel> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BakedQuad> getQuads(BlockState state, Direction side, Random rand, IModelData extraData) {
|
public List<BakedQuad> getQuads(BlockState state, Direction side, Random rand, IModelData extraData) {
|
||||||
List<BakedQuad> quads = new ArrayList<>(super.getQuads(state, side, rand, extraData));
|
List<BakedQuad> quads = super.getQuads(state, side, rand, extraData);
|
||||||
if (!extraData.hasProperty(POSITION_PROPERTY))
|
|
||||||
return quads;
|
|
||||||
if (quads.isEmpty())
|
if (quads.isEmpty())
|
||||||
return quads;
|
return quads;
|
||||||
|
if (!extraData.hasProperty(POSITION_PROPERTY))
|
||||||
|
return quads;
|
||||||
|
BlockPos data = extraData.getData(POSITION_PROPERTY);
|
||||||
|
quads = new ArrayList<>(quads);
|
||||||
|
|
||||||
// Optifine might've rejigged vertex data
|
// Optifine might've rejigged vertex data
|
||||||
VertexFormat format = DefaultVertexFormats.BLOCK;
|
VertexFormat format = DefaultVertexFormats.BLOCK;
|
||||||
int colorIndex = 0;
|
int colorIndex = 0;
|
||||||
for (int j = 0; j < format.getElements().size(); j++) {
|
for (int elementId = 0; elementId < format.getElements().size(); elementId++) {
|
||||||
VertexFormatElement e = format.getElements().get(j);
|
VertexFormatElement element = format.getElements().get(elementId);
|
||||||
if (e.getUsage() == VertexFormatElement.Usage.COLOR)
|
if (element.getUsage() == VertexFormatElement.Usage.COLOR)
|
||||||
colorIndex = j;
|
colorIndex = elementId;
|
||||||
}
|
}
|
||||||
int colorOffset = format.getOffset(colorIndex) / 4;
|
int colorOffset = format.getOffset(colorIndex) / 4;
|
||||||
BlockPos data = extraData.getData(POSITION_PROPERTY);
|
|
||||||
|
|
||||||
for (int i = 0; i < quads.size(); i++) {
|
for (int i = 0; i < quads.size(); i++) {
|
||||||
BakedQuad quad = quads.get(i);
|
BakedQuad quad = quads.get(i);
|
||||||
BakedQuad newQuad = new BakedQuad(Arrays.copyOf(quad.getVertexData(), quad.getVertexData().length),
|
|
||||||
quad.getTintIndex(), quad.getFace(), quad.getSprite(), quad.hasShade());
|
BakedQuad newQuad = QuadHelper.clone(quad);
|
||||||
int[] vertexData = newQuad.getVertexData();
|
int[] vertexData = newQuad.getVertexData();
|
||||||
|
|
||||||
for (int vertex = 0; vertex < vertexData.length; vertex += format.getIntegerSize()) {
|
for (int vertex = 0; vertex < vertexData.length; vertex += format.getIntegerSize()) {
|
||||||
|
|
|
@ -9,18 +9,18 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.Create;
|
import com.simibubi.create.Create;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
import net.minecraft.client.renderer.model.IBakedModel;
|
||||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||||
import net.minecraft.client.renderer.model.ModelRotation;
|
import net.minecraft.client.renderer.model.ModelRotation;
|
||||||
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
|
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||||
|
import net.minecraftforge.client.model.BakedModelWrapper;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public abstract class CustomRenderedItemModel extends WrappedBakedModel {
|
public abstract class CustomRenderedItemModel extends BakedModelWrapper<IBakedModel> {
|
||||||
|
|
||||||
protected String basePath;
|
protected String basePath;
|
||||||
protected Map<String, IBakedModel> partials = new HashMap<>();
|
protected Map<String, IBakedModel> partials = new HashMap<>();
|
||||||
protected TransformType currentPerspective;
|
|
||||||
protected ItemStackTileEntityRenderer renderer;
|
protected ItemStackTileEntityRenderer renderer;
|
||||||
|
|
||||||
public CustomRenderedItemModel(IBakedModel template, String basePath) {
|
public CustomRenderedItemModel(IBakedModel template, String basePath) {
|
||||||
|
@ -29,25 +29,30 @@ public abstract class CustomRenderedItemModel extends WrappedBakedModel {
|
||||||
this.renderer = createRenderer();
|
this.renderer = createRenderer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final List<ResourceLocation> getModelLocations() {
|
|
||||||
return partials.keySet().stream().map(this::getPartialModelLocation).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStackTileEntityRenderer getRenderer() {
|
|
||||||
return renderer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract ItemStackTileEntityRenderer createRenderer();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBuiltInRenderer() {
|
public boolean isBuiltInRenderer() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBakedModel handlePerspective(TransformType cameraTransformType, MatrixStack mat) {
|
public IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat) {
|
||||||
currentPerspective = cameraTransformType;
|
// Super call returns originalModel, but we want to return this, else ISTER won't be used.
|
||||||
return super.handlePerspective(cameraTransformType, mat);
|
super.handlePerspective(cameraTransformType, mat);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final IBakedModel getOriginalModel() {
|
||||||
|
return originalModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackTileEntityRenderer getRenderer() {
|
||||||
|
return renderer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract ItemStackTileEntityRenderer createRenderer();
|
||||||
|
|
||||||
|
public final List<ResourceLocation> getModelLocations() {
|
||||||
|
return partials.keySet().stream().map(this::getPartialModelLocation).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addPartials(String... partials) {
|
protected void addPartials(String... partials) {
|
||||||
|
@ -70,10 +75,6 @@ public abstract class CustomRenderedItemModel extends WrappedBakedModel {
|
||||||
return new ResourceLocation(Create.ID, "item/" + basePath + "/" + name);
|
return new ResourceLocation(Create.ID, "item/" + basePath + "/" + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TransformType getCurrentPerspective() {
|
|
||||||
return currentPerspective;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IBakedModel getPartial(String name) {
|
public IBakedModel getPartial(String name) {
|
||||||
return partials.get(name);
|
return partials.get(name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,25 +9,23 @@ import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||||
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
|
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class CustomRenderedItemModelRenderer<M extends CustomRenderedItemModel> extends ItemStackTileEntityRenderer {
|
public abstract class CustomRenderedItemModelRenderer<M extends CustomRenderedItemModel> extends ItemStackTileEntityRenderer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void render(ItemStack stack, ItemCameraTransforms.TransformType p_239207_2_, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
|
public void render(ItemStack stack, ItemCameraTransforms.TransformType transformType, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
|
||||||
M mainModel = ((M) Minecraft.getInstance()
|
M mainModel = ((M) Minecraft.getInstance()
|
||||||
.getItemRenderer()
|
.getItemRenderer()
|
||||||
.getItemModelWithOverrides(stack, null, null));
|
.getItemModelWithOverrides(stack, null, null));
|
||||||
PartialItemModelRenderer renderer = PartialItemModelRenderer.of(stack, p_239207_2_, ms, buffer, overlay);
|
PartialItemModelRenderer renderer = PartialItemModelRenderer.of(stack, transformType, ms, buffer, overlay);
|
||||||
|
|
||||||
ms.push();
|
ms.push();
|
||||||
ms.translate(0.5F, 0.5F, 0.5F);
|
ms.translate(0.5F, 0.5F, 0.5F);
|
||||||
render(stack, mainModel, renderer, ms, buffer, light, overlay);
|
render(stack, mainModel, renderer, transformType, ms, buffer, light, overlay);
|
||||||
ms.pop();
|
ms.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void render(ItemStack stack, M model, PartialItemModelRenderer renderer, MatrixStack ms,
|
protected abstract void render(ItemStack stack, M model, PartialItemModelRenderer renderer, ItemCameraTransforms.TransformType transformType,
|
||||||
IRenderTypeBuffer buffer, int light, int overlay) {
|
MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.simibubi.create.foundation.block.render;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.model.BakedQuad;
|
||||||
|
|
||||||
|
public final class QuadHelper {
|
||||||
|
|
||||||
|
private QuadHelper() {}
|
||||||
|
|
||||||
|
public static BakedQuad clone(BakedQuad quad) {
|
||||||
|
return new BakedQuad(Arrays.copyOf(quad.getVertexData(), quad.getVertexData().length),
|
||||||
|
quad.getTintIndex(), quad.getFace(), quad.getSprite(), quad.hasShade());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,81 +0,0 @@
|
||||||
package com.simibubi.create.foundation.block.render;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.client.renderer.model.BakedQuad;
|
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
|
||||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
|
||||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
|
||||||
import net.minecraftforge.client.model.data.IModelData;
|
|
||||||
|
|
||||||
public class WrappedBakedModel implements IBakedModel {
|
|
||||||
|
|
||||||
protected IBakedModel template;
|
|
||||||
|
|
||||||
public WrappedBakedModel(IBakedModel template) {
|
|
||||||
this.template = template;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBakedModel getBakedModel() {
|
|
||||||
return template;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAmbientOcclusion() {
|
|
||||||
return template.isAmbientOcclusion();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isGui3d() {
|
|
||||||
return template.isGui3d();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isBuiltInRenderer() {
|
|
||||||
return template.isBuiltInRenderer();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TextureAtlasSprite getParticleTexture(IModelData data) {
|
|
||||||
return template.getParticleTexture(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemOverrideList getOverrides() {
|
|
||||||
return template.getOverrides();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBakedModel handlePerspective(TransformType cameraTransformType, MatrixStack mat) {
|
|
||||||
template.handlePerspective(cameraTransformType, mat);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<BakedQuad> getQuads(BlockState state, Direction side, Random rand) {
|
|
||||||
return getQuads(state, side, rand, EmptyModelData.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<BakedQuad> getQuads(BlockState state, Direction side, Random rand, IModelData data) {
|
|
||||||
return template.getQuads(state, side, rand, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TextureAtlasSprite getParticleTexture() {
|
|
||||||
return getParticleTexture(EmptyModelData.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSideLit() {
|
|
||||||
return template.isSideLit();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -51,6 +51,10 @@ public com.mojang.blaze3d.platform.GlStateManager$BooleanState field_179201_b #f
|
||||||
# GameRenderer
|
# GameRenderer
|
||||||
public net.minecraft.client.renderer.GameRenderer func_215311_a(Lnet/minecraft/client/renderer/ActiveRenderInfo;FZ)D #getFOVModifier
|
public net.minecraft.client.renderer.GameRenderer func_215311_a(Lnet/minecraft/client/renderer/ActiveRenderInfo;FZ)D #getFOVModifier
|
||||||
|
|
||||||
|
# FirstPersonRenderer
|
||||||
|
public net.minecraft.client.renderer.FirstPersonRenderer field_187467_d # itemStackMainHand
|
||||||
|
public net.minecraft.client.renderer.FirstPersonRenderer field_187468_e # itemStackOffHand
|
||||||
|
|
||||||
# IResizeCallback
|
# IResizeCallback
|
||||||
public net.minecraft.util.palette.IResizeCallback
|
public net.minecraft.util.palette.IResizeCallback
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue