Actually port

This commit is contained in:
grimmauld 2021-02-16 20:52:26 +01:00
parent 08562d2689
commit 716f79872c
8 changed files with 31 additions and 30 deletions

View file

@ -77,10 +77,6 @@ public class AssemblyException extends Exception {
return new AssemblyException("noPistonPoles"); return new AssemblyException("noPistonPoles");
} }
public String getFormattedText() {
return component.getFormattedText();
}
public boolean hasPosition() { public boolean hasPosition() {
return position != null; return position != null;
} }

View file

@ -1,7 +1,10 @@
package com.simibubi.create.content.contraptions.components.structureMovement; package com.simibubi.create.content.contraptions.components.structureMovement;
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation; import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
import com.simibubi.create.foundation.item.TooltipHelper;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import java.util.Arrays; import java.util.Arrays;
@ -9,17 +12,17 @@ import java.util.List;
public interface IDisplayAssemblyExceptions { public interface IDisplayAssemblyExceptions {
default boolean addExceptionToTooltip(List<String> tooltip) { default boolean addExceptionToTooltip(List<ITextComponent> tooltip) {
AssemblyException e = getLastAssemblyException(); AssemblyException e = getLastAssemblyException();
if (e == null) if (e == null)
return false; return false;
if (!tooltip.isEmpty()) if (!tooltip.isEmpty())
tooltip.add(""); tooltip.add(StringTextComponent.EMPTY);
tooltip.add(IHaveGoggleInformation.spacing + TextFormatting.GOLD + Lang.translate("gui.assembly.exception")); tooltip.add(IHaveGoggleInformation.componentSpacing.copy().append(Lang.translate("gui.assembly.exception").formatted(TextFormatting.GOLD)));
String text = e.getFormattedText(); String text = TooltipHelper.getUnformattedDeepText(e.component);
Arrays.stream(text.split("\n")).forEach(l -> tooltip.add(IHaveGoggleInformation.spacing + TextFormatting.GRAY + l)); Arrays.stream(text.split("\n")).forEach(l -> tooltip.add(IHaveGoggleInformation.componentSpacing.copy().append(new StringTextComponent(l).setStyle(e.component.getStyle()).formatted(TextFormatting.GRAY))));
return true; return true;
} }

View file

@ -183,10 +183,10 @@ public class SailBlock extends ProperDirectionalBlock {
} }
private void bounce(Entity p_226860_1_) { private void bounce(Entity p_226860_1_) {
Vector3d vec3d = p_226860_1_.getMotion(); Vector3d Vector3d = p_226860_1_.getMotion();
if (vec3d.y < 0.0D) { if (Vector3d.y < 0.0D) {
double d0 = p_226860_1_ instanceof LivingEntity ? 1.0D : 0.8D; double d0 = p_226860_1_ instanceof LivingEntity ? 1.0D : 0.8D;
p_226860_1_.setMotion(vec3d.x, -vec3d.y * (double) 0.26F * d0, vec3d.z); p_226860_1_.setMotion(Vector3d.x, -Vector3d.y * (double) 0.26F * d0, Vector3d.z);
} }
} }

View file

@ -109,9 +109,9 @@ public class GantryPinionTileEntity extends KineticTileEntity implements IDispla
} }
@Override @Override
protected void read(CompoundNBT compound, boolean clientPacket) { protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) {
lastException = AssemblyException.read(compound); lastException = AssemblyException.read(compound);
super.read(compound, clientPacket); super.fromTag(state, compound, clientPacket);
} }
@Override @Override

View file

@ -12,6 +12,7 @@ import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollOpt
import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BlockState;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.state.properties.RailShape; import net.minecraft.state.properties.RailShape;
import net.minecraft.tileentity.TileEntityType; import net.minecraft.tileentity.TileEntityType;
@ -55,9 +56,9 @@ public class CartAssemblerTileEntity extends SmartTileEntity implements IDisplay
} }
@Override @Override
protected void read(CompoundNBT compound, boolean clientPacket) { protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) {
lastException = AssemblyException.read(compound); lastException = AssemblyException.read(compound);
super.read(compound, clientPacket); super.fromTag(state, compound, clientPacket);
} }
@Override @Override

View file

@ -424,12 +424,12 @@ public class PipeConnection {
// if (inbound) // if (inbound)
// return; // return;
// //
// Vec3d directionVec = new Vec3d(side.getDirectionVec()); // Vector3d directionVec = new Vector3d(side.getDirectionVec());
// Vec3d scaleVec = directionVec.scale(-.25f * side.getAxisDirection() // Vector3d scaleVec = directionVec.scale(-.25f * side.getAxisDirection()
// .getOffset()); // .getOffset());
// directionVec = directionVec.scale(inbound ? .35f : .45f); // directionVec = directionVec.scale(inbound ? .35f : .45f);
// CreateClient.outliner.chaseAABB("pressure" + pos.toShortString() + side.getName() + String.valueOf(inbound), // CreateClient.outliner.chaseAABB("pressure" + pos.toShortString() + side.getName() + String.valueOf(inbound),
// FluidPropagator.smallCenter.offset(directionVec.add(new Vec3d(pos))) // FluidPropagator.smallCenter.offset(directionVec.add(new Vector3d(pos)))
// .grow(scaleVec.x, scaleVec.y, scaleVec.z) // .grow(scaleVec.x, scaleVec.y, scaleVec.z)
// .expand(0, pressure / 64f, 0) // .expand(0, pressure / 64f, 0)
// .grow(1 / 64f)); // .grow(1 / 64f));
@ -440,7 +440,7 @@ public class PipeConnection {
// if (!hasFlow()) // if (!hasFlow())
// return; // return;
// //
// Vec3d directionVec = new Vec3d(side.getDirectionVec()); // Vector3d directionVec = new Vector3d(side.getDirectionVec());
// float size = 1 / 4f; // float size = 1 / 4f;
// float length = .5f; // float length = .5f;
// Flow flow = this.flow.get(); // Flow flow = this.flow.get();
@ -450,11 +450,11 @@ public class PipeConnection {
// if (flow.progress == null) // if (flow.progress == null)
// return; // return;
// float value = flow.progress.getValue(); // float value = flow.progress.getValue();
// Vec3d start = directionVec.scale(inbound ? .5 : .5f - length); // Vector3d start = directionVec.scale(inbound ? .5 : .5f - length);
// Vec3d offset = directionVec.scale(length * (inbound ? -1 : 1)) // Vector3d offset = directionVec.scale(length * (inbound ? -1 : 1))
// .scale(value); // .scale(value);
// //
// Vec3d scale = new Vec3d(1, 1, 1).subtract(directionVec.scale(side.getAxisDirection() // Vector3d scale = new Vector3d(1, 1, 1).subtract(directionVec.scale(side.getAxisDirection()
// .getOffset())) // .getOffset()))
// .scale(size); // .scale(size);
// AxisAlignedBB bb = new AxisAlignedBB(start, start.add(offset)).offset(VecHelper.getCenterOf(pos)) // AxisAlignedBB bb = new AxisAlignedBB(start, start.add(offset)).offset(VecHelper.getCenterOf(pos))

View file

@ -48,7 +48,7 @@ public class FunnelFilterSlotPositioning extends ValueBoxTransform.Sided {
// if (!funnelFacing.getAxis() // if (!funnelFacing.getAxis()
// .isHorizontal()) { // .isHorizontal()) {
// Vec3d southLocation = VecHelper.voxelSpace(8, funnelFacing == Direction.DOWN ? 3 : 13, 15.5f); // Vector3d southLocation = VecHelper.voxelSpace(8, funnelFacing == Direction.DOWN ? 3 : 13, 15.5f);
// return VecHelper.rotateCentered(southLocation, horizontalAngle, Axis.Y); // return VecHelper.rotateCentered(southLocation, horizontalAngle, Axis.Y);
// } // }
// //
@ -61,7 +61,7 @@ public class FunnelFilterSlotPositioning extends ValueBoxTransform.Sided {
// boolean alongX = funnelFacing.getAxis() == Axis.X; // boolean alongX = funnelFacing.getAxis() == Axis.X;
// float zRotLast = alongX ^ funnelFacing.getAxisDirection() == AxisDirection.POSITIVE ? 180 : 0; // float zRotLast = alongX ^ funnelFacing.getAxisDirection() == AxisDirection.POSITIVE ? 180 : 0;
// //
// Vec3d vec = VecHelper.voxelSpace(8, 13, .5f); // Vector3d vec = VecHelper.voxelSpace(8, 13, .5f);
// vec = vec.subtract(.5, .5, .5); // vec = vec.subtract(.5, .5, .5);
// vec = VecHelper.rotate(vec, zRotLast, Axis.Z); // vec = VecHelper.rotate(vec, zRotLast, Axis.Z);
// vec = VecHelper.rotate(vec, yRot, Axis.Y); // vec = VecHelper.rotate(vec, yRot, Axis.Y);

View file

@ -9,12 +9,13 @@ import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands; import net.minecraft.command.Commands;
import net.minecraft.command.arguments.BlockPosArgument; import net.minecraft.command.arguments.BlockPosArgument;
import net.minecraft.command.arguments.EntityArgument; import net.minecraft.command.arguments.EntityArgument;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.*; import net.minecraft.util.math.*;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeMod;
import net.minecraftforge.fml.network.PacketDistributor; import net.minecraftforge.fml.network.PacketDistributor;
import java.util.Collection; import java.util.Collection;
@ -65,10 +66,10 @@ public class HighlightCommand {
} }
private static int highlightAssemblyExceptionFor(ServerPlayerEntity player, CommandSource source) { private static int highlightAssemblyExceptionFor(ServerPlayerEntity player, CommandSource source) {
double distance = player.getAttribute(PlayerEntity.REACH_DISTANCE).getValue(); double distance = player.getAttribute(ForgeMod.REACH_DISTANCE.get()).getValue();
Vec3d start = player.getEyePosition(1); Vector3d start = player.getEyePosition(1);
Vec3d look = player.getLook(1); Vector3d look = player.getLook(1);
Vec3d end = start.add(look.x * distance, look.y * distance, look.z * distance); Vector3d end = start.add(look.x * distance, look.y * distance, look.z * distance);
World world = player.world; World world = player.world;
BlockRayTraceResult ray = world.rayTraceBlocks(new RayTraceContext(start, end, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, player)); BlockRayTraceResult ray = world.rayTraceBlocks(new RayTraceContext(start, end, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, player));