Streamline Chromatics
- Crafters no longer display item sprites vertically flipped - Crafters now arrange overlapping items less randomly - Chromatic Compound can now absorb light emitting blocks from belts & depots
This commit is contained in:
parent
aecd988384
commit
31c951be65
3 changed files with 91 additions and 25 deletions
|
@ -17,6 +17,7 @@ import com.simibubi.create.foundation.render.SuperByteBuffer;
|
|||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.Pointing;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -43,14 +44,16 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
|
|||
ms.pushPose();
|
||||
Direction facing = te.getBlockState()
|
||||
.getValue(HORIZONTAL_FACING);
|
||||
Vector3d vec = Vector3d.atLowerCornerOf(facing.getNormal()).scale(.58)
|
||||
Vector3d vec = Vector3d.atLowerCornerOf(facing.getNormal())
|
||||
.scale(.58)
|
||||
.add(.5, .5, .5);
|
||||
|
||||
if (te.phase == Phase.EXPORTING) {
|
||||
Direction targetDirection = MechanicalCrafterBlock.getTargetDirection(te.getBlockState());
|
||||
float progress =
|
||||
MathHelper.clamp((1000 - te.countDown + te.getCountDownSpeed() * partialTicks) / 1000f, 0, 1);
|
||||
vec = vec.add(Vector3d.atLowerCornerOf(targetDirection.getNormal()).scale(progress * .75f));
|
||||
vec = vec.add(Vector3d.atLowerCornerOf(targetDirection.getNormal())
|
||||
.scale(progress * .75f));
|
||||
}
|
||||
|
||||
ms.translate(vec.x, vec.y, vec.z);
|
||||
|
@ -66,10 +69,12 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
|
|||
public void renderItems(MechanicalCrafterTileEntity te, float partialTicks, MatrixStack ms,
|
||||
IRenderTypeBuffer buffer, int light, int overlay) {
|
||||
if (te.phase == Phase.IDLE) {
|
||||
ItemStack stack = te.getInventory().getItem(0);
|
||||
ItemStack stack = te.getInventory()
|
||||
.getItem(0);
|
||||
if (!stack.isEmpty()) {
|
||||
ms.pushPose();
|
||||
ms.translate(0, 0, -1 / 256f);
|
||||
ms.mulPose(Vector3f.YP.rotationDegrees(180));
|
||||
Minecraft.getInstance()
|
||||
.getItemRenderer()
|
||||
.renderStatic(stack, TransformType.FIXED, light, overlay, ms, buffer);
|
||||
|
@ -111,9 +116,16 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
|
|||
Integer x = pair.getKey();
|
||||
Integer y = pair.getValue();
|
||||
ms.translate(x * spacing, y * spacing, 0);
|
||||
|
||||
int offset = 0;
|
||||
if (te.phase == Phase.EXPORTING && te.getBlockState().hasProperty(MechanicalCrafterBlock.POINTING)) {
|
||||
Pointing value = te.getBlockState().getValue(MechanicalCrafterBlock.POINTING);
|
||||
offset = value == Pointing.UP ? -1 : value == Pointing.LEFT ? 2 : value == Pointing.RIGHT ? -2 : 1;
|
||||
}
|
||||
|
||||
MatrixTransformStack.of(ms)
|
||||
.nudge(x * 13 + y + te.getBlockPos()
|
||||
.hashCode());
|
||||
.rotateY(180)
|
||||
.translate(0, 0, (x + y * 3 + offset * 9) / 1024f );
|
||||
Minecraft.getInstance()
|
||||
.getItemRenderer()
|
||||
.renderStatic(stack, TransformType.FIXED, light, overlay, ms, buffer);
|
||||
|
@ -141,9 +153,12 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
|
|||
|| pair.getRight()
|
||||
.intValue() != 0)
|
||||
return;
|
||||
ms.pushPose();
|
||||
ms.mulPose(Vector3f.YP.rotationDegrees(180));
|
||||
Minecraft.getInstance()
|
||||
.getItemRenderer()
|
||||
.renderStatic(stack, TransformType.FIXED, light, overlay, ms, buffer);
|
||||
ms.popPose();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -155,10 +170,12 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
|
|||
BlockState blockState = te.getBlockState();
|
||||
IVertexBuilder vb = buffer.getBuffer(RenderType.solid());
|
||||
|
||||
if (!Backend.getInstance().canUseInstancing(te.getLevel())) {
|
||||
if (!Backend.getInstance()
|
||||
.canUseInstancing(te.getLevel())) {
|
||||
SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState);
|
||||
standardKineticRotationTransform(superBuffer, te, light);
|
||||
superBuffer.rotateCentered(Direction.UP, (float) (blockState.getValue(HORIZONTAL_FACING).getAxis() != Direction.Axis.X ? 0 : Math.PI / 2));
|
||||
superBuffer.rotateCentered(Direction.UP, (float) (blockState.getValue(HORIZONTAL_FACING)
|
||||
.getAxis() != Direction.Axis.X ? 0 : Math.PI / 2));
|
||||
superBuffer.rotateCentered(Direction.EAST, (float) (Math.PI / 2));
|
||||
superBuffer.renderInto(ms, vb);
|
||||
}
|
||||
|
@ -167,14 +184,13 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
|
|||
BlockPos pos = te.getBlockPos();
|
||||
|
||||
if ((te.covered || te.phase != Phase.IDLE) && te.phase != Phase.CRAFTING && te.phase != Phase.INSERTING) {
|
||||
SuperByteBuffer lidBuffer =
|
||||
renderAndTransform(AllBlockPartials.MECHANICAL_CRAFTER_LID, blockState);
|
||||
lidBuffer.light(light).renderInto(ms, vb);
|
||||
SuperByteBuffer lidBuffer = renderAndTransform(AllBlockPartials.MECHANICAL_CRAFTER_LID, blockState);
|
||||
lidBuffer.light(light)
|
||||
.renderInto(ms, vb);
|
||||
}
|
||||
|
||||
if (MechanicalCrafterBlock.isValidTarget(te.getLevel(), pos.relative(targetDirection), blockState)) {
|
||||
SuperByteBuffer beltBuffer =
|
||||
renderAndTransform(AllBlockPartials.MECHANICAL_CRAFTER_BELT, blockState);
|
||||
SuperByteBuffer beltBuffer = renderAndTransform(AllBlockPartials.MECHANICAL_CRAFTER_BELT, blockState);
|
||||
SuperByteBuffer beltFrameBuffer =
|
||||
renderAndTransform(AllBlockPartials.MECHANICAL_CRAFTER_BELT_FRAME, blockState);
|
||||
|
||||
|
@ -183,13 +199,15 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
|
|||
beltBuffer.shiftUVtoSheet(AllSpriteShifts.CRAFTER_THINGIES, (textureIndex % 4) / 4f, 0, 1);
|
||||
}
|
||||
|
||||
beltBuffer.light(light).renderInto(ms, vb);
|
||||
beltFrameBuffer.light(light).renderInto(ms, vb);
|
||||
beltBuffer.light(light)
|
||||
.renderInto(ms, vb);
|
||||
beltFrameBuffer.light(light)
|
||||
.renderInto(ms, vb);
|
||||
|
||||
} else {
|
||||
SuperByteBuffer arrowBuffer =
|
||||
renderAndTransform(AllBlockPartials.MECHANICAL_CRAFTER_ARROW, blockState);
|
||||
arrowBuffer.light(light).renderInto(ms, vb);
|
||||
SuperByteBuffer arrowBuffer = renderAndTransform(AllBlockPartials.MECHANICAL_CRAFTER_ARROW, blockState);
|
||||
arrowBuffer.light(light)
|
||||
.renderInto(ms, vb);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -197,7 +215,7 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
|
|||
private SuperByteBuffer renderAndTransform(PartialModel renderBlock, BlockState crafterState) {
|
||||
SuperByteBuffer buffer = PartialBufferer.get(renderBlock, crafterState);
|
||||
float xRot = crafterState.getValue(MechanicalCrafterBlock.POINTING)
|
||||
.getXRotation();
|
||||
.getXRotation();
|
||||
float yRot = AngleHelper.horizontalAngle(crafterState.getValue(HORIZONTAL_FACING));
|
||||
buffer.rotateCentered(Direction.UP, (float) ((yRot + 90) / 180 * Math.PI));
|
||||
buffer.rotateCentered(Direction.EAST, (float) ((xRot) / 180 * Math.PI));
|
||||
|
|
|
@ -2,15 +2,22 @@ package com.simibubi.create.content.curiosities;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.lang3.mutable.MutableBoolean;
|
||||
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.config.CRecipes;
|
||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult;
|
||||
import com.simibubi.create.foundation.utility.Color;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
|
@ -159,6 +166,50 @@ public class ChromaticCompoundItem extends Item {
|
|||
|
||||
BlockPos randomOffset = new BlockPos(VecHelper.offsetRandomly(positionVec, r, range));
|
||||
BlockState state = world.getBlockState(randomOffset);
|
||||
|
||||
TransportedItemStackHandlerBehaviour behaviour =
|
||||
TileEntityBehaviour.get(world, randomOffset, TransportedItemStackHandlerBehaviour.TYPE);
|
||||
|
||||
// Find a placed light source
|
||||
if (behaviour == null) {
|
||||
if (checkLight(stack, entity, world, itemData, positionVec, randomOffset, state))
|
||||
world.destroyBlock(randomOffset, false);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Find a light source from a depot/belt (chunk rebuild safe)
|
||||
MutableBoolean success = new MutableBoolean(false);
|
||||
behaviour.handleProcessingOnAllItems(ts -> {
|
||||
|
||||
ItemStack heldStack = ts.stack;
|
||||
if (!(heldStack.getItem() instanceof BlockItem))
|
||||
return TransportedResult.doNothing();
|
||||
|
||||
BlockItem blockItem = (BlockItem) heldStack.getItem();
|
||||
if (blockItem.getBlock() == null)
|
||||
return TransportedResult.doNothing();
|
||||
|
||||
BlockState stateToCheck = blockItem.getBlock()
|
||||
.defaultBlockState();
|
||||
|
||||
if (!success.getValue()
|
||||
&& checkLight(stack, entity, world, itemData, positionVec, randomOffset, stateToCheck)) {
|
||||
success.setTrue();
|
||||
if (ts.stack.getCount() == 1)
|
||||
return TransportedResult.removeItem();
|
||||
TransportedItemStack left = ts.copy();
|
||||
left.stack.shrink(1);
|
||||
return TransportedResult.convertTo(left);
|
||||
}
|
||||
|
||||
return TransportedResult.doNothing();
|
||||
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkLight(ItemStack stack, ItemEntity entity, World world, CompoundNBT itemData,
|
||||
Vector3d positionVec, BlockPos randomOffset, BlockState state) {
|
||||
if (state.getLightValue(world, randomOffset) == 0)
|
||||
return false;
|
||||
if (state.getDestroySpeed(world, randomOffset) == -1)
|
||||
|
@ -166,14 +217,12 @@ public class ChromaticCompoundItem extends Item {
|
|||
if (state.getBlock() == Blocks.BEACON)
|
||||
return false;
|
||||
|
||||
RayTraceContext context = new RayTraceContext(positionVec, VecHelper.getCenterOf(randomOffset),
|
||||
BlockMode.COLLIDER, FluidMode.NONE, entity);
|
||||
RayTraceContext context = new RayTraceContext(positionVec.add(new Vector3d(0, 0.5, 0)),
|
||||
VecHelper.getCenterOf(randomOffset), BlockMode.COLLIDER, FluidMode.NONE, entity);
|
||||
if (!randomOffset.equals(world.clip(context)
|
||||
.getBlockPos()))
|
||||
return false;
|
||||
|
||||
world.destroyBlock(randomOffset, false);
|
||||
|
||||
ItemStack newStack = stack.split(1);
|
||||
newStack.getOrCreateTag()
|
||||
.putInt("CollectingLight", itemData.getInt("CollectingLight") + 1);
|
||||
|
@ -184,8 +233,7 @@ public class ChromaticCompoundItem extends Item {
|
|||
entity.lifespan = 6000;
|
||||
if (stack.isEmpty())
|
||||
entity.remove();
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public class RefinedRadianceItem extends NoGravMagicalDohickyItem {
|
|||
protected void onCreated(ItemEntity entity, CompoundNBT persistentData) {
|
||||
super.onCreated(entity, persistentData);
|
||||
entity.setDeltaMovement(entity.getDeltaMovement()
|
||||
.add(0, .15f, 0));
|
||||
.add(0, .25f, 0));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue