Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.19.2/main' into 1.19.2/update
Browse files Browse the repository at this point in the history
# Conflicts:
#	common/build.gradle
#	common/src/main/java/org/valkyrienskies/mod/mixin/client/multiplayer/MixinClientPacketListener.java
#	common/src/main/java/org/valkyrienskies/mod/mixin/client/renderer/MixinLevelRenderer.java
#	common/src/main/java/org/valkyrienskies/mod/mixin/server/MixinPlayerList.java
#	common/src/main/java/org/valkyrienskies/mod/mixin/server/command/MixinCommands.java
#	common/src/main/java/org/valkyrienskies/mod/mixin/server/network/MixinServerGamePacketListenerImpl.java
#	common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java
#	common/src/main/kotlin/org/valkyrienskies/mod/client/audio/SimpleSoundInstanceOnShip.kt
#	common/src/main/kotlin/org/valkyrienskies/mod/common/command/RelativeVector3Argument.kt
#	common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgument.kt
#	common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt
#	common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipAssemblerItem.kt
#	common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipCreatorItem.kt
#	common/src/main/kotlin/org/valkyrienskies/mod/compat/clothconfig/VSClothConfig.kt
#	fabric/build.gradle
#	fabric/gradle.properties
#	fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/world/level/block/FireMixin.java
#	fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/common/ValkyrienSkiesModFabric.kt
#	fabric/src/main/resources/valkyrienskies-fabric.mixins.json
#	forge/build.gradle
#	forge/gradle.properties
#	forge/src/main/java/org/valkyrienskies/mod/forge/mixin/world/level/block/FireMixin.java
#	forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/ValkyrienSkiesModForge.kt
#	gradle.properties
  • Loading branch information
mrsterner committed Nov 17, 2023
2 parents 47d4fcc + b2de01d commit b6d2101
Show file tree
Hide file tree
Showing 22 changed files with 480 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
- discord/status:
success_message: ${DISCORD_MSG}
success_only: true
webhook: ${VS2_118_WEBHOOK}
webhook: ${VS2_1192_WEBHOOK}

# Invoke jobs via workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- '1.18.x/*'
- '1.19.2/*'
pull_request:
types: [ opened, synchronize, reopened ]
jobs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
public class ValkyrienMixinErrorHandler implements IMixinErrorHandler {

private final Set<String> warnList = new HashSet<>(Arrays.asList(
"org.valkyrienskies.mod.mixin.feature.water_in_ships_entity.MixinEntity"
"org.valkyrienskies.mod.mixin.feature.water_in_ships_entity.MixinEntity",
"org.valkyrienskies.mod.mixin.mod_compat.create_big_cannons.MixinAbstractCannonProjectile",
"org.valkyrienskies.mod.mixin.mod_compat.create_big_cannons.MixinPitchOrientedContraptionEntity"
));

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.ReportedException;
import net.minecraft.core.BlockPos;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.ClipContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,17 @@ private void preGetSquaredCameraDistance(final CallbackInfoReturnable<Double> ci
cir.setReturnValue(relDistanceSq);
}
}

// This fixes ship blocks not rendering for some reason...
@Inject(method = "hasAllNeighbors", at = @At("HEAD"), cancellable = true)
private void preHasAllNeighbors(final CallbackInfoReturnable<Boolean> cir) {
final ClientLevel world = Minecraft.getInstance().level;
if (world == null) {
return;
}

if (VSGameUtilsKt.isBlockInShipyard(world, origin)) {
cir.setReturnValue(true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.valkyrienskies.mod.common.VSGameUtilsKt;
import org.valkyrienskies.mod.mixinducks.mod_compat.sodium.RegionChunkRendererDuck;

@Mixin(value = RegionChunkRenderer.class, remap = false)
@Mixin(value = RegionChunkRenderer.class, remap = false, priority = 1101)
public class MixinRegionChunkRenderer implements RegionChunkRendererDuck {

@Unique
Expand All @@ -27,28 +27,29 @@ public class MixinRegionChunkRenderer implements RegionChunkRendererDuck {
@Unique
private final Vector3d camInShip = new Vector3d();

@Redirect(
@WrapOperation(
at = @At(
value = "INVOKE",
target = "Lme/jellysquid/mods/sodium/client/render/chunk/RenderSection;getBounds()Lme/jellysquid/mods/sodium/client/render/chunk/data/ChunkRenderBounds;"
),
method = "buildDrawBatches"
)
private ChunkRenderBounds injectBuildDrawBatches(final RenderSection section, final List<RenderSection> sections,
final BlockRenderPass pass, final ChunkCameraContext c) {

private ChunkRenderBounds injectBuildDrawBatches(
final RenderSection section, final Operation<ChunkRenderBounds> getBounds, final List<RenderSection> sections,
final BlockRenderPass pass, final ChunkCameraContext c
) {
final ClientShip ship = VSGameUtilsKt.getShipObjectManagingPos(Minecraft.getInstance().level,
section.getChunkX(), section.getChunkZ());

if (ship != null) {
ship.getRenderTransform().getWorldToShip().transformPosition(camInWorld, camInShip);
final ChunkRenderBounds originalBounds = section.getBounds();
final ChunkRenderBounds originalBounds = getBounds.call(section);
return new ChunkRenderBounds(originalBounds.x1 - 1.9f, originalBounds.y1 - 1.9f,
originalBounds.z1 - 1.9f, originalBounds.x2 + 1.9f, originalBounds.y2 + 1.9f,
originalBounds.z2 + 1.9f);
} else {
camInShip.set(camInWorld);
return section.getBounds();
return getBounds.call(section);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.valkyrienskies.mod.common.VSGameUtilsKt;

@Pseudo
@Mixin(targets = "com.sonicether.soundphysics.SoundPhysics")
@Mixin(targets = "com.sonicether.soundphysics.SoundPhysics", remap = false)
public abstract class MixinSoundPhysics {

@Shadow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.function.Supplier;
import net.minecraft.server.level.ChunkMap;
import net.minecraft.server.level.ServerLevel;
Expand Down Expand Up @@ -32,6 +33,9 @@ public abstract class MixinChunkMap {
@Final
private Supplier<DimensionDataStorage> overworldDataStorage;

@Shadow
protected abstract CompoundTag upgradeChunkTag(CompoundTag compoundTag);

/**
* Force the game to generate empty chunks in the shipyard.
*
Expand All @@ -42,28 +46,28 @@ public abstract class MixinChunkMap {
*/
/*
@Inject(method = "readChunk", at = @At("HEAD"), cancellable = true)
private void preReadChunk(final ChunkPos chunkPos, final CallbackInfoReturnable<CompoundTag> cir)
throws IOException {
private void preReadChunk(final ChunkPos chunkPos,
final CallbackInfoReturnable<CompletableFuture<Optional<CompoundTag>>> cir) {
final ChunkMap self = ChunkMap.class.cast(this);
final CompoundTag compoundTag = self.read(chunkPos);
final CompoundTag originalToReturn = compoundTag == null ? null :
self.upgradeChunkTag(this.level.dimension(), this.overworldDataStorage, compoundTag, Optional.empty());
cir.setReturnValue(originalToReturn);
if (originalToReturn == null) {
final ServerShip ship = VSGameUtilsKt.getShipManagingPos(level, chunkPos.x, chunkPos.z);
// If its in a ship and it shouldn't generate chunks OR if there is no ship but its happening in the shipyard
if ((ship == null && VSGameUtilsKt.isChunkInShipyard(level, chunkPos.x, chunkPos.z)) ||
(ship != null && !ShipSettingsKt.getSettings(ship).getShouldGenerateChunks())) {
// The chunk doesn't yet exist and is in the shipyard. Make a new empty chunk
// Generate the chunk to be nothing
final LevelChunk generatedChunk = new LevelChunk(level,
new ProtoChunk(chunkPos, UpgradeData.EMPTY, level,
level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null), null);
// Its wasteful to serialize just for this to be deserialized, but it will work for now.
cir.setReturnValue(ChunkSerializer.write(level, generatedChunk));
cir.setReturnValue(self.read(chunkPos).thenApplyAsync(compoundTag -> {
if (compoundTag.isEmpty()) {
final ServerShip ship = VSGameUtilsKt.getShipManagingPos(level, chunkPos.x, chunkPos.z);
// If its in a ship and it shouldn't generate chunks OR if there is no ship but its happening in the shipyard
if ((ship == null && VSGameUtilsKt.isChunkInShipyard(level, chunkPos.x, chunkPos.z)) ||
(ship != null && !ShipSettingsKt.getSettings(ship).getShouldGenerateChunks())) {
// The chunk doesn't yet exist and is in the shipyard. Make a new empty chunk
// Generate the chunk to be nothing
final LevelChunk generatedChunk = new LevelChunk(level,
new ProtoChunk(chunkPos, UpgradeData.EMPTY, level,
level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null), null);
// Its wasteful to serialize just for this to be deserialized, but it will work for now.
return Optional.of(ChunkSerializer.write(level, generatedChunk));
}
}
}
return compoundTag.map(this::upgradeChunkTag);
}));
}
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@ object VSKeyBindings {
fun clientSetup(registerar: Consumer<KeyMapping>) {
toBeRegistered.forEach { it.accept(registerar) }
}

fun isKeyMappingFromVS2(keyMapping: KeyMapping): Boolean {
return keyMapping.name.startsWith("key.valkyrienskies")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.valkyrienskies.mod.common.item

import net.minecraft.Util
import net.minecraft.network.chat.Component
import net.minecraft.network.chat.Component
import net.minecraft.server.level.ServerLevel
import net.minecraft.world.InteractionResult
import net.minecraft.world.item.Item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"feature.shipyard_entities.MixinTransientEntitySectionManager",
"feature.spawn_player_on_ship.MixinServerGamePacketListenerImpl",
"feature.tick_ship_chunks.MixinChunkMap",
"feature.water_in_ships_entity.MixinEntity",
"feature.world_border.MixinLevel",
"feature.world_border.MixinWorldBorder",
"mod_compat.create.IMixinDeployerHandler",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package org.valkyrienskies.mod.fabric.mixin.client.render;

import static org.valkyrienskies.mod.common.VSClientGameUtils.transformRenderWithShip;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.SheetedDecalTextureGenerator;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Matrix3f;
import com.mojang.math.Matrix4f;
import net.minecraft.client.Camera;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.valkyrienskies.core.api.ships.ClientShip;
import org.valkyrienskies.core.api.ships.properties.ShipTransform;
import org.valkyrienskies.mod.common.VSGameUtilsKt;
import org.valkyrienskies.mod.mixin.accessors.client.render.OverlayVertexConsumerAccessor;

@Mixin(LevelRenderer.class)
public abstract class MixinLevelRenderer {
@Shadow
private ClientLevel level;

/**
* This mixin makes block damage render on ships.
*/
@WrapOperation(method = "renderLevel", at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/renderer/block/BlockRenderDispatcher;renderBreakingTexture(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/BlockAndTintGetter;Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;)V"))
private void renderBlockDamage(final BlockRenderDispatcher blockRenderManager, final BlockState state,
final BlockPos blockPos, final BlockAndTintGetter blockRenderWorld, final PoseStack matrix,
final VertexConsumer vertexConsumer, final Operation<Void> renderBreakingTexture, final PoseStack matrixStack,
final float methodTickDelta, final long methodLimitTime, final boolean methodRenderBlockOutline,
final Camera methodCamera, final GameRenderer methodGameRenderer,
final LightTexture methodLightmapTextureManager, final Matrix4f methodMatrix4f) {

final ClientShip ship = VSGameUtilsKt.getShipObjectManagingPos(level, blockPos);
if (ship != null) {
// Remove the vanilla render transform
matrixStack.popPose();

// Add the VS render transform
matrixStack.pushPose();

final ShipTransform renderTransform = ship.getRenderTransform();
final Vec3 cameraPos = methodCamera.getPosition();

transformRenderWithShip(renderTransform, matrixStack, blockPos, cameraPos.x, cameraPos.y, cameraPos.z);

final Matrix3f newNormalMatrix = matrixStack.last().normal().copy();
final Matrix4f newModelMatrix = matrixStack.last().pose().copy();

// Then update the matrices in vertexConsumer (I'm guessing vertexConsumer is responsible for mapping
// textures, so we need to update its matrices otherwise the block damage texture looks wrong)
final SheetedDecalTextureGenerator newVertexConsumer =
new SheetedDecalTextureGenerator(((OverlayVertexConsumerAccessor) vertexConsumer).getDelegate(),
newModelMatrix, newNormalMatrix);

// Finally, invoke the render damage function.
renderBreakingTexture.call(blockRenderManager, state, blockPos, blockRenderWorld, matrix,
newVertexConsumer);
} else {
// Vanilla behavior
renderBreakingTexture.call(blockRenderManager, state, blockPos, blockRenderWorld, matrix, vertexConsumer);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.valkyrienskies.mod.fabric.mixin.feature.duplicate_keybindings;

import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.client.KeyMapping;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(KeyMapping.class)
public interface KeyMappingAccessor {
@Accessor
InputConstants.Key getKey();

@Accessor
int getClickCount();

@Accessor
void setClickCount(int clickCount);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package org.valkyrienskies.mod.fabric.mixin.feature.duplicate_keybindings;

import com.google.common.collect.Maps;
import com.mojang.blaze3d.platform.InputConstants;
import com.mojang.blaze3d.platform.InputConstants.Key;
import java.util.Map;
import net.minecraft.client.KeyMapping;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
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.config.VSKeyBindings;

/**
* This Mixin makes it so VS2 keybindings are pressed even when there exists another keybinding bound to the set same
* key.
*/
@Mixin(KeyMapping.class)
public class MixinKeyMapping {
@Unique
private static final Map<Key, KeyMapping> VS2_KEYMAP = Maps.newHashMap();

@Shadow
@Final
private static Map<InputConstants.Key, KeyMapping> MAP;

@Shadow
@Final
private static Map<String, KeyMapping> ALL;

@Shadow
private InputConstants.Key key;

@Inject(method = "click", at = @At("HEAD"))
private static void preClick(final InputConstants.Key key, final CallbackInfo callbackInfo) {
final KeyMapping originalKeyMapping = MAP.get(key);
final KeyMapping vs2KeyMapping = VS2_KEYMAP.get(key);
if (vs2KeyMapping != null && originalKeyMapping != vs2KeyMapping) {
final KeyMappingAccessor keyMappingAccessor = (KeyMappingAccessor) vs2KeyMapping;
keyMappingAccessor.setClickCount(keyMappingAccessor.getClickCount() + 1);
}
}

@Inject(method = "set", at = @At("HEAD"))
private static void preSet(final InputConstants.Key key, final boolean bl, final CallbackInfo callbackInfo) {
final KeyMapping originalKeyMapping = MAP.get(key);
final KeyMapping vs2KeyMapping = VS2_KEYMAP.get(key);
if (vs2KeyMapping != null && originalKeyMapping != vs2KeyMapping) {
vs2KeyMapping.setDown(bl);
}
}

@Inject(method = "resetMapping", at = @At("HEAD"))
private static void preResetMapping(final CallbackInfo callbackInfo) {
VS2_KEYMAP.clear();
for (final KeyMapping keyMapping : ALL.values()) {
if (VSKeyBindings.INSTANCE.isKeyMappingFromVS2(keyMapping)) {
final KeyMappingAccessor keyMappingAccessor = (KeyMappingAccessor) keyMapping;
VS2_KEYMAP.put(keyMappingAccessor.getKey(), keyMapping);
}
}
}

@Inject(method = "<init>", at = @At("RETURN"), remap = false)
private void postInit(final CallbackInfo callbackInfo) {
final KeyMapping thisAsKeyMapping = KeyMapping.class.cast(this);
if (VSKeyBindings.INSTANCE.isKeyMappingFromVS2(thisAsKeyMapping)) {
VS2_KEYMAP.put(this.key, thisAsKeyMapping);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.valkyrienskies.mod.mixin.feature.water_in_ships_entity;
package org.valkyrienskies.mod.fabric.mixin.feature.water_in_ships_entity;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class ValkyrienSkiesModFabric : ModInitializer {
ValkyrienSkiesMod.TEST_HINGE_BLOCK_ENTITY_TYPE
)

CommandRegistrationCallback.EVENT.register { dispatcher ,d, _ ->
CommandRegistrationCallback.EVENT.register { dispatcher, _, _ ->
VSCommands.registerServerCommands(dispatcher)
}

Expand Down
4 changes: 2 additions & 2 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
],
"accessWidener": "valkyrienskies-common.accesswidener",
"depends": {
"fabricloader": ">=0.14.6",
"minecraft": ">=1.18.2",
"fabricloader": ">=0.14.9",
"minecraft": "1.19.2",
"fabric": "*"
},
"breaks": {
Expand Down
Loading

0 comments on commit b6d2101

Please sign in to comment.