use of com.simibubi.create.content.contraptions.base.IRotate in project Create by Creators-of-Create.
the class EncasedCogRenderer method renderSafe.
@Override
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
if (Backend.canUseInstancing(te.getLevel()))
return;
BlockState blockState = te.getBlockState();
Block block = blockState.getBlock();
if (!(block instanceof IRotate))
return;
IRotate def = (IRotate) block;
for (Direction d : Iterate.directionsInAxis(getRotationAxisOf(te))) {
if (!def.hasShaftTowards(te.getLevel(), te.getBlockPos(), blockState, d))
continue;
renderRotatingBuffer(te, CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), d), ms, buffer.getBuffer(RenderType.solid()), light);
}
}
use of com.simibubi.create.content.contraptions.base.IRotate in project Create by Creators-of-Create.
the class SplitShaftInstance method update.
@Override
public void update() {
Block block = blockState.getBlock();
final Direction.Axis boxAxis = ((IRotate) block).getRotationAxis(blockState);
Direction[] directions = Iterate.directionsInAxis(boxAxis);
for (int i : Iterate.zeroAndOne) {
updateRotation(keys.get(i), blockEntity.getSpeed() * blockEntity.getRotationSpeedModifier(directions[i]));
}
}
use of com.simibubi.create.content.contraptions.base.IRotate in project Create by Creators-of-Create.
the class SplitShaftRenderer method renderSafe.
@Override
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
if (Backend.canUseInstancing(te.getLevel()))
return;
Block block = te.getBlockState().getBlock();
final Axis boxAxis = ((IRotate) block).getRotationAxis(te.getBlockState());
final BlockPos pos = te.getBlockPos();
float time = AnimationTickHolder.getRenderTime(te.getLevel());
for (Direction direction : Iterate.directions) {
Axis axis = direction.getAxis();
if (boxAxis != axis)
continue;
float offset = getRotationOffsetForPosition(te, pos, axis);
float angle = (time * te.getSpeed() * 3f / 10) % 360;
float modifier = 1;
if (te instanceof SplitShaftTileEntity)
modifier = ((SplitShaftTileEntity) te).getRotationSpeedModifier(direction);
angle *= modifier;
angle += offset;
angle = angle / 180f * (float) Math.PI;
SuperByteBuffer superByteBuffer = CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction);
kineticRotationTransform(superByteBuffer, te, axis, angle, light);
superByteBuffer.renderInto(ms, buffer.getBuffer(RenderType.solid()));
}
}
use of com.simibubi.create.content.contraptions.base.IRotate in project Create by Creators-of-Create.
the class DeployerRenderer method renderInContraption.
public static void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld, ContraptionMatrices matrices, MultiBufferSource buffer) {
VertexConsumer builder = buffer.getBuffer(RenderType.solid());
BlockState blockState = context.state;
Mode mode = NBTHelper.readEnum(context.tileData, "Mode", Mode.class);
PartialModel handPose = getHandPose(mode);
float speed = (float) context.getAnimationSpeed();
if (context.contraption.stalled)
speed = 0;
SuperByteBuffer shaft = CachedBufferer.block(AllBlocks.SHAFT.getDefaultState());
SuperByteBuffer pole = CachedBufferer.partial(AllBlockPartials.DEPLOYER_POLE, blockState);
SuperByteBuffer hand = CachedBufferer.partial(handPose, blockState);
double factor;
if (context.contraption.stalled || context.position == null || context.data.contains("StationaryTimer")) {
factor = Mth.sin(AnimationTickHolder.getRenderTime() * .5f) * .25f + .25f;
} else {
Vec3 center = VecHelper.getCenterOf(new BlockPos(context.position));
double distance = context.position.distanceTo(center);
double nextDistance = context.position.add(context.motion).distanceTo(center);
factor = .5f - Mth.clamp(Mth.lerp(AnimationTickHolder.getPartialTicks(), distance, nextDistance), 0, 1);
}
Vec3 offset = Vec3.atLowerCornerOf(blockState.getValue(FACING).getNormal()).scale(factor);
PoseStack m = matrices.getModel();
m.pushPose();
m.pushPose();
Axis axis = Axis.Y;
if (context.state.getBlock() instanceof IRotate) {
IRotate def = (IRotate) context.state.getBlock();
axis = def.getRotationAxis(context.state);
}
float time = AnimationTickHolder.getRenderTime(context.world) / 20;
float angle = (time * speed) % 360;
TransformStack.cast(m).centre().rotateY(axis == Axis.Z ? 90 : 0).rotateZ(axis.isHorizontal() ? 90 : 0).unCentre();
shaft.transform(m);
shaft.rotateCentered(Direction.get(AxisDirection.POSITIVE, Axis.Y), angle);
m.popPose();
m.translate(offset.x, offset.y, offset.z);
pole.transform(m);
hand.transform(m);
transform(pole, blockState, true);
transform(hand, blockState, false);
shaft.light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)).renderInto(matrices.getViewProjection(), builder);
pole.light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)).renderInto(matrices.getViewProjection(), builder);
hand.light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)).renderInto(matrices.getViewProjection(), builder);
m.popPose();
}
use of com.simibubi.create.content.contraptions.base.IRotate in project Create by Creators-of-Create.
the class ClientEvents method addToItemTooltip.
@SubscribeEvent
public static void addToItemTooltip(ItemTooltipEvent event) {
if (!AllConfigs.CLIENT.tooltips.get())
return;
if (event.getPlayer() == null)
return;
ItemStack stack = event.getItemStack();
String translationKey = stack.getItem().getDescriptionId(stack);
if (translationKey.startsWith(ITEM_PREFIX) || translationKey.startsWith(BLOCK_PREFIX))
if (TooltipHelper.hasTooltip(stack, event.getPlayer())) {
List<Component> itemTooltip = event.getToolTip();
List<Component> toolTip = new ArrayList<>();
toolTip.add(itemTooltip.remove(0));
TooltipHelper.getTooltip(stack).addInformation(toolTip);
itemTooltip.addAll(0, toolTip);
}
if (stack.getItem() instanceof BlockItem) {
BlockItem item = (BlockItem) stack.getItem();
if (item.getBlock() instanceof IRotate || item.getBlock() instanceof EngineBlock) {
List<Component> kineticStats = ItemDescription.getKineticStats(item.getBlock());
if (!kineticStats.isEmpty()) {
event.getToolTip().add(new TextComponent(""));
event.getToolTip().addAll(kineticStats);
}
}
}
PonderTooltipHandler.addToTooltip(event.getToolTip(), stack);
SequencedAssemblyRecipe.addToTooltip(event.getToolTip(), stack);
}
Aggregations