Skip to content

Commit

Permalink
Merge incoming changes from 1.18.x/main
Browse files Browse the repository at this point in the history
  • Loading branch information
StewStrong committed Jul 19, 2023
2 parents 2ad8817 + acba7d4 commit b6ba216
Show file tree
Hide file tree
Showing 15 changed files with 268 additions and 26 deletions.
48 changes: 48 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Bug report
description: Let us know about a bug that occurs without other mods
title: '<title>'
labels: bug
assignees: []
body:
- type: checkboxes
attributes:
label: This issue occurs when only Valkyrien Skies and addons are installed and no other mods
options:
- label: I have tested this issue and it occurs when no other mods are installed
required: true
- type: dropdown
attributes:
label: Minecraft Version
description: What Minecraft version does this issue occur on?
options:
- 1.16
- 1.18
- 1.19
validations:
required: true
- type: dropdown
attributes:
label: Mod Loader
description: What mod loader does this issue occur on?
options:
- Forge
- Fabric
- Quilt
validations:
required: true
- type: textarea
attributes:
label: Issue description
description: Describe what happens, and what you expect to happen instead
validations:
required: true
- type: textarea
attributes:
label: Issue reproduction
description: Describe how to reproduce your issue
validations:
required: true
- type: textarea
attributes:
label: Logs
description: Go to `.minecraft/logs` and drag and drop the `latest.log` and `debug.log` file into this text field
59 changes: 59 additions & 0 deletions .github/ISSUE_TEMPLATE/compatibility_issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Compatibility issue
description: Let us know about a bug that occurs when another mod is installed
title: '<title>'
labels: compat
assignees: []
body:
- type: markdown
attributes:
value: |
**Note:** do not report issues with the following mods:
- Optifine
- Magma Server (maybe try Arclight?)
- type: input
attributes:
label: Mod Name
description: The name of the mod that causes the compatibility issue
validations:
required: true
- type: checkboxes
attributes:
label: This issue occurs when only Valkyrien Skies, addons, and the mod I have specified are installed and no other mods
options:
- label: I have tested this issue and it occurs with only Valkyrien Skies, addons, and the mod I have specified
- type: dropdown
attributes:
label: Minecraft Version
description: What Minecraft version does this issue occur on?
options:
- 1.16
- 1.18
- 1.19
validations:
required: true
- type: dropdown
attributes:
label: Mod Loader
description: What mod loader does this issue occur on?
options:
- Forge
- Fabric
- Quilt
validations:
required: true
- type: textarea
attributes:
label: Issue description
description: Describe what happens, and what you expect to happen instead
validations:
required: true
- type: textarea
attributes:
label: Issue reproduction
description: Describe how to reproduce your issue
validations:
required: true
- type: textarea
attributes:
label: Logs
description: Go to `.minecraft/logs` and drag and drop the `latest.log` and `debug.log` file into this text field
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ out
!.idea/codeStyles/
# inspection profile
!.idea/inspectionProfiles/
# saveactions config
!.idea/saveactions_settings.xml
# recommended plugins
!.idea/externalDependencies.xml

Expand Down
3 changes: 1 addition & 2 deletions .idea/externalDependencies.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 0 additions & 19 deletions .idea/saveactions_settings.xml

This file was deleted.

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@ independent code lives in [vs-core](https://github.com/ValkyrienSkies/vs-core).

### Running Forge in dev environment
Occasionally forge will break in strange ways. When this occurs, delete all the `build` folders, delete the `.gradle` folder of the `forge` project, and then refresh gradle.

### Change JVM arguments for small computers
`Error occurred during initialization of VM
Could not reserve enough space for 4194304KB object heap`
For patch the problem go to gradle.properties and change `org.gradle.jvmargs=-Xmx4096M` to `org.gradle.jvmargs=-Xmx1024` or `org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G` to `org.gradle.jvmargs=-Xmx1G -XX:MaxMetaspaceSize=1G`
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.valkyrienskies.mod.mixin.feature.entity_collision;

import net.minecraft.world.entity.MoverType;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.valkyrienskies.mod.common.util.IEntityDraggingInformationProvider;

@Mixin(Player.class)
public abstract class MixinPlayer implements IEntityDraggingInformationProvider {
// Allow players to crouch walk on ships
@Inject(method = "maybeBackOffFromEdge", at = @At("HEAD"), cancellable = true)
private void preMaybeBackOffFromEdge(final Vec3 vec3, final MoverType moverType,
final CallbackInfoReturnable<Vec3> callbackInfoReturnable) {
if (getDraggingInformation().isEntityBeingDraggedByAShip()) {
callbackInfoReturnable.setReturnValue(vec3);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package org.valkyrienskies.mod.mixin.feature.mass_tooltip;

import java.util.List;
import java.util.Objects;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.valkyrienskies.mod.common.BlockStateInfo;
import org.valkyrienskies.mod.common.config.VSGameConfig;
import org.valkyrienskies.mod.mixinducks.feature.mass_tooltip.MassTooltipVisibility;
import oshi.util.tuples.Pair;

@Mixin(BlockItem.class)
public class MixinBlockItem {
@Inject(method = "appendHoverText", at = @At("HEAD"))
private void ValkyrienSkies$addMassToTooltip(final ItemStack itemStack, final Level level,
final List<Component> list, final TooltipFlag tooltipFlag, final CallbackInfo ci) {
final MassTooltipVisibility visibility = VSGameConfig.CLIENT.getTooltip().getMassTooltipVisibility();
if (visibility.isVisible(tooltipFlag)) {
try {
final BlockItem item = (BlockItem) itemStack.getItem();
final Double mass =
Objects.requireNonNull(BlockStateInfo.INSTANCE.get(item.getBlock().defaultBlockState()))
.getFirst();
list.add(new TranslatableComponent("tooltip.valkyrienskies.mass")
.append(VSGameConfig.CLIENT.getTooltip().getUseImperialUnits() ?
getImperialText(mass) : ": " + mass + "kg").withStyle(ChatFormatting.DARK_GRAY));
} catch (final Exception ignored) {
}
}
}

@Unique
private Pair<Integer, Integer> convertToImperial(final double mass) {
final double ounces = mass * 35.274;
final double pounds = Math.floor(ounces / 16);
return new Pair<>(
(int) pounds,
(int) Math.floor((ounces / 16 - pounds) * 16)
);
}

@Unique
private String getImperialText(final double mass) {
String impText = ": ";
final Pair<Integer, Integer> imperial = convertToImperial(mass);
if (imperial.getA() > 0) {
impText = impText + imperial.getA();
if (imperial.getA() == 1) {
impText = impText + "lb. ";
} else {
impText = impText + "lbs. ";
}
}

if (imperial.getB() > 0) {
impText = impText + imperial.getB() + "oz.";
}

return impText;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.valkyrienskies.mod.mixinducks.feature.mass_tooltip;

import net.minecraft.world.item.TooltipFlag;

public enum MassTooltipVisibility {
ALWAYS,
ADVANCED,
DISABLED;

public boolean isVisible(final TooltipFlag flag) {
return this.equals(ALWAYS) ||
(this.equals(ADVANCED) && flag.isAdvanced());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.valkyrienskies.mod.common.command

import com.google.gson.JsonObject
import com.mojang.brigadier.StringReader
import com.mojang.brigadier.arguments.ArgumentType
import com.mojang.brigadier.context.CommandContext
Expand Down Expand Up @@ -87,4 +88,18 @@ class ShipArgument private constructor(val selectorOnly: Boolean) : ArgumentType
}

override fun getExamples(): Collection<String> = EXAMPLES

object Serializer : ArgumentSerializer<ShipArgument> {
override fun serializeToNetwork(arg: ShipArgument, buf: FriendlyByteBuf) {
buf.writeBoolean(arg.selectorOnly)
}

override fun deserializeFromNetwork(buf: FriendlyByteBuf): ShipArgument {
return ShipArgument(buf.readBoolean())
}

override fun serializeToJson(arg: ShipArgument, json: JsonObject) {
json.addProperty("selectorOnly", arg.selectorOnly)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import net.minecraft.commands.CommandSourceStack
import net.minecraft.commands.arguments.EntityArgument
import net.minecraft.commands.arguments.coordinates.BlockPosArgument
import net.minecraft.commands.arguments.coordinates.Vec3Argument
import net.minecraft.network.chat.Component
import net.minecraft.network.chat.TranslatableComponent
import net.minecraft.world.entity.Entity
import net.minecraft.world.phys.BlockHitResult
import org.joml.Vector3d
Expand Down Expand Up @@ -44,6 +44,16 @@ object VSCommands {
private const val TELEPORTED_MULTIPLE_SHIPS_SUCCESS = "command.valkyrienskies.teleport.multiple_ship_success"
private const val TELEPORT_FIRST_ARG_CAN_ONLY_INPUT_1_SHIP = "command.valkyrienskies.mc_teleport.can_only_teleport_to_one_ship"

fun bootstrap() {
ArgumentTypes.register("valkyrienskies:ship",
ShipArgument::class.java,
ShipArgument.Serializer)

ArgumentTypes.register("valkyrienskies:relative_vector",
RelativeVector3Argument::class.java,
EmptyArgumentSerializer(::RelativeVector3Argument))
}

private fun literal(name: String) =
LiteralArgumentBuilder.literal<VSCommandSource>(name)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.valkyrienskies.mod.common.config

import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema
import org.valkyrienskies.mod.mixinducks.feature.mass_tooltip.MassTooltipVisibility

object VSGameConfig {

Expand All @@ -14,13 +15,27 @@ object VSGameConfig {
val COMMON = Common()

class Client {
val Tooltip = TOOLTIP()

@JsonSchema(description = "Renders the VS2 debug HUD with TPS")
var renderDebugText = false

@JsonSchema(
description = "Recommend ship slugs in mc commands where player names could be used ex. /tp ship-name wich could pollute user autocomplete"
)
var recommendSlugsInMcCommands = true

class TOOLTIP {
@JsonSchema(
description = "Set when the Mass Tooltip is Visible"
)
var massTooltipVisibility = MassTooltipVisibility.ADVANCED

@JsonSchema(
description = "Use Imperial Units to show Mass"
)
var useImperialUnits = false
}
}

class Server {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"key.valkyrienskies.ship_cruise": "Cruise",
"key.valkyrienskies.ship_down": "Descend",
"category.valkyrienskies.driving": "Driving",
"block.valkyrienskies.test_chair": "Debug Chair",
Expand All @@ -16,5 +17,6 @@
"command.valkyrienskies.mc_teleport.can_only_teleport_to_one_ship": "Can only teleport to exactly 1 ship",
"command.valkyrienskies.get_ship.success": "Found ship with slug %s",
"command.valkyrienskies.get_ship.fail": "No ship found",
"command.valkyrienskies.get_ship.only_usable_by_entities": "/vs get-ship can only be run by entities!"
"command.valkyrienskies.get_ship.only_usable_by_entities": "/vs get-ship can only be run by entities!",
"tooltip.valkyrienskies.mass": "Mass"
}
3 changes: 3 additions & 0 deletions common/src/main/resources/valkyrienskies-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,21 @@
"feature.block_placement_orientation.MixinBlockItem",
"feature.block_placement_orientation.MixinBlockPlaceContext",
"feature.clip_replace.MixinLevel",
"feature.commands.MixinArgumentTypes",
"feature.commands.MixinArgumentTypeInfos",
"feature.commands.MixinCommandSourceStack",
"feature.conduit_fix.ConduitMixin",
"feature.container_distance_check.MixinRandomizableContainerBlockEntity",
"feature.dispensers.MixinDefaultDispenseItemBehavior",
"feature.distance_replace.MixinEntity",
"feature.entity_collision.MixinEntity",
"feature.entity_collision.MixinPlayer",
"feature.explosions.MixinExplosion",
"feature.fire_between_ship_and_world.LavaFluidMixin",
"feature.fluid_escaping_ship_config.MixinFlowingFluid",
"feature.get_entities.MixinLevel",
"feature.ladders.MixinLivingEntity",
"feature.mass_tooltip.MixinBlockItem",
"feature.mob_spawning.NaturalSpawnerMixin",
"feature.render_pathfinding.MixinDebugPackets",
"feature.screen_distance_check.MixinScreenHandler",
Expand Down
2 changes: 1 addition & 1 deletion vs-core

0 comments on commit b6ba216

Please sign in to comment.