From 683d18b994026ac93b7aef375a1d06e03fc44314 Mon Sep 17 00:00:00 2001 From: zelophed Date: Sun, 28 Mar 2021 04:19:58 +0200 Subject: [PATCH] tick off some todos --- .../base/GeneratingKineticTileEntity.java | 17 ++++++----- .../goggles/IHaveGoggleInformation.java | 2 +- .../sequencer/SequencerInstructions.java | 2 +- .../curiosities/zapper/ZapperScreen.java | 2 +- .../block/SchematicannonScreen.java | 11 +++---- .../foundation/command/FlySpeedCommand.java | 4 ++- .../foundation/ponder/PonderRegistry.java | 2 +- .../create/foundation/ponder/PonderUI.java | 2 +- .../utility/placement/IPlacementHelper.java | 29 +++++++++++++++---- 9 files changed, 47 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/GeneratingKineticTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/base/GeneratingKineticTileEntity.java index 8552f1b80..916b8fe27 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/GeneratingKineticTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/GeneratingKineticTileEntity.java @@ -59,8 +59,8 @@ public abstract class GeneratingKineticTileEntity extends KineticTileEntity { float stressBase = calculateAddedStressCapacity(); if (stressBase != 0 && IRotate.StressImpact.isEnabled()) { - tooltip.add(new StringTextComponent(spacing).append(Lang.translate("gui.goggles.generator_stats"))); - tooltip.add(new StringTextComponent(spacing).append(Lang.translate("tooltip.capacityProvided").formatted(TextFormatting.GRAY))); + tooltip.add(componentSpacing.copy().append(Lang.translate("gui.goggles.generator_stats"))); + tooltip.add(componentSpacing.copy().append(Lang.translate("tooltip.capacityProvided").formatted(TextFormatting.GRAY))); float speed = getTheoreticalSpeed(); if (speed != getGeneratedSpeed() && speed != 0) @@ -69,12 +69,13 @@ public abstract class GeneratingKineticTileEntity extends KineticTileEntity { speed = Math.abs(speed); float stressTotal = stressBase * speed; - // FIXME add colours back - // String stressString = spacing + "%s" + Lang.translate("generic.unit.stress").getUnformattedComponentText() + " %s"; - // tooltip.add(new StringTextComponent(String.format(stressString, IHaveGoggleInformation.format(stressBase), Lang.translate("gui.goggles.base_value").getUnformattedComponentText()))); - // tooltip.add(new StringTextComponent(String.format(stressString, IHaveGoggleInformation.format(stressTotal), Lang.translate("gui.goggles.at_current_speed").getUnformattedComponentText()))); - tooltip.add(componentSpacing.copy().append(new StringTextComponent(" " + IHaveGoggleInformation.format(stressTotal)) - .append(Lang.translate("generic.unit.stress")).append(" ").formatted(TextFormatting.AQUA)).append(Lang.translate("gui.goggles.at_current_speed").formatted(TextFormatting.DARK_GRAY))); + tooltip.add( + componentSpacing.copy() + .append(new StringTextComponent(" " + IHaveGoggleInformation.format(stressTotal)) + .append(Lang.translate("generic.unit.stress")) + .formatted(TextFormatting.AQUA)) + .append(" ") + .append(Lang.translate("gui.goggles.at_current_speed").formatted(TextFormatting.DARK_GRAY))); added = true; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/goggles/IHaveGoggleInformation.java b/src/main/java/com/simibubi/create/content/contraptions/goggles/IHaveGoggleInformation.java index c53e9d192..4e5ac57ab 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/goggles/IHaveGoggleInformation.java +++ b/src/main/java/com/simibubi/create/content/contraptions/goggles/IHaveGoggleInformation.java @@ -85,7 +85,7 @@ public interface IHaveGoggleInformation { return true; ITextComponent capacity = Lang.translate("gui.goggles.fluid_container.capacity").formatted(TextFormatting.GRAY); - ITextComponent amount = new StringTextComponent(format(tank.getTankCapacity(0)) + mb).formatted(TextFormatting.GOLD); + ITextComponent amount = new StringTextComponent(format(tank.getTankCapacity(0))).append(mb).formatted(TextFormatting.GOLD); tooltip.add(indent.copy() .append(capacity) diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencerInstructions.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencerInstructions.java index a24278fab..ce15fe19c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencerInstructions.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencerInstructions.java @@ -54,7 +54,7 @@ public enum SequencerInstructions { String formatValue(int value) { if (this == TURN_ANGLE) - return value + Lang.translate("generic.unit.degrees").getUnformattedComponentText(); // FIXME + return value + Lang.translate("generic.unit.degrees").getString(); if (this == TURN_DISTANCE) return value + "m"; if (this == DELAY) { diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperScreen.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperScreen.java index 613b28cef..bb5a6f3c7 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperScreen.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperScreen.java @@ -133,7 +133,7 @@ public class ZapperScreen extends AbstractSimiScreen { protected void renderZapper(MatrixStack matrixStack) { GuiGameElement.of(zapper) - .at((this.width - this.sWidth) / 2 + 200, this.height / 2 - this.sHeight / 4 + 25, -150)//TODO + .at((this.width - this.sWidth) / 2 + 200, this.height / 2 - this.sHeight / 4 + 25, -150) .scale(4) .render(matrixStack); } diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonScreen.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonScreen.java index b43f2ee71..6d08924a9 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonScreen.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonScreen.java @@ -35,6 +35,7 @@ import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TranslationTextComponent; + public class SchematicannonScreen extends AbstractSimiContainerScreen { private static final AllGuiTextures BG_BOTTOM = AllGuiTextures.SCHEMATICANNON_BOTTOM; @@ -375,12 +376,12 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen ctx, ServerPlayerEntity player, float speed) { SPlayerAbilitiesPacket packet = new SPlayerAbilitiesPacket(player.abilities); - //packet.setFlySpeed(speed);TODO 1.16 + //packet.setFlySpeed(speed); + ObfuscationReflectionHelper.setPrivateValue(SPlayerAbilitiesPacket.class, packet, speed, "field_149116_e"); player.connection.sendPacket(packet); ctx.getSource().sendFeedback(new StringTextComponent("Temporarily set " + player.getName().getString() + "'s Flying Speed to: " + speed), true); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistry.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistry.java index cccb299e7..f349f080b 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistry.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistry.java @@ -86,7 +86,7 @@ public class PonderRegistry { PonderStoryBoardEntry sb = entries.get(i); Template activeTemplate = loadSchematic(sb.getSchematicName()); PonderWorld world = new PonderWorld(BlockPos.ZERO, Minecraft.getInstance().world); - activeTemplate.placeAndNotifyListeners(world, BlockPos.ZERO, new PlacementSettings(), world.rand);//TODO 1.16 crashing + activeTemplate.placeAndNotifyListeners(world, BlockPos.ZERO, new PlacementSettings(), world.rand); world.createBackup(); PonderScene scene = compileScene(i, sb, world); scene.begin(); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java index 9de32f5f2..8eacba7b8 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java @@ -461,7 +461,7 @@ public class PonderUI extends NavigatableSimiScreen { ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(90)); ms.push(); ms.translate(0, 0, bounds.getZSize() * 16); - ms.multiply(Vector3f.NEGATIVE_X.getDegreesQuaternion(-90)); + ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-90)); textRenderer.draw(ms, d.name().substring(0, 1), 0, 0, 0x66FFFFFF); textRenderer.draw(ms, "|", 2, 10, 0x44FFFFFF); textRenderer.draw(ms, ".", 2, 14, 0x22FFFFFF); diff --git a/src/main/java/com/simibubi/create/foundation/utility/placement/IPlacementHelper.java b/src/main/java/com/simibubi/create/foundation/utility/placement/IPlacementHelper.java index cdc56e488..a0b9ba213 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/placement/IPlacementHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/placement/IPlacementHelper.java @@ -14,11 +14,13 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.util.math.vector.Vector3i; import net.minecraft.world.World; import java.util.Arrays; import java.util.Comparator; import java.util.List; +import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -31,20 +33,29 @@ public interface IPlacementHelper { BlockState ID = new BlockState(Blocks.AIR, null, null); /** - * @return a predicate that gets tested with the items held in the players hands, + * @return a predicate that gets tested with the items held in the players hands
* should return true if this placement helper is active with the given item */ Predicate getItemPredicate(); /** - * @return a predicate that gets tested with the blockstate the player is looking at + * @return a predicate that gets tested with the blockstate the player is looking at
* should return true if this placement helper is active with the given blockstate */ Predicate getStatePredicate(); /** - * @return PlacementOffset.fail() if no valid offset could be found. - * PlacementOffset.success(newPos) with newPos being the new position the block should be placed at + * + * @param player the player that activated the placement helper + * @param world the world that the placement helper got activated in + * @param state the Blockstate of the Block that the player is looking at or clicked on + * @param pos the position of the Block the player is looking at or clicked on + * @param ray the exact raytrace result + * + * @return the PlacementOffset object describing where to place the new block.
+ * Use {@link PlacementOffset#fail} when no new position could be found.
+ * Use {@link PlacementOffset#success(Vector3i)} with the new BlockPos to indicate a success + * and call {@link PlacementOffset#withTransform(Function)} if the blocks default state has to be modified before it is placed */ PlacementOffset getOffset(PlayerEntity player, World world, BlockState state, BlockPos pos, BlockRayTraceResult ray); @@ -58,7 +69,15 @@ public interface IPlacementHelper { return offset; } - //only gets called when placementOffset is successful + /** + * overwrite this method if your placement helper needs a different rendering than the default ghost state + * + * @param pos the position of the Block the player is looking at or clicked on + * @param state the Blockstate of the Block that the player is looking at or clicked on + * @param ray the exact raytrace result + * @param offset the PlacementOffset returned by {@link #getOffset(PlayerEntity, World, BlockState, BlockPos, BlockRayTraceResult)}
+ * the offset will always be successful if this method is called + */ default void renderAt(BlockPos pos, BlockState state, BlockRayTraceResult ray, PlacementOffset offset) { displayGhost(offset); }