Skip to content

Commit

Permalink
Merge branch 'master' into weapon
Browse files Browse the repository at this point in the history
  • Loading branch information
jimchen5209 committed Jan 7, 2024
2 parents a8b9043 + cf17e70 commit a933b0a
Show file tree
Hide file tree
Showing 58 changed files with 777 additions and 2,273 deletions.
14 changes: 7 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
// "maven-publish"
kotlin("jvm") version "1.9.10"
id("fabric-loom") version "1.3-SNAPSHOT"
kotlin("jvm") version "1.9.22"
id("fabric-loom") version "1.4-SNAPSHOT"
}

val version = "0.0.1"
val group = "one.oktw"

val fabricVersion = "0.88.1+1.20.1"
val galaxyLibVersion = "adc1ed90"
val fabricVersion = "0.92.0+1.20.4"
val galaxyLibVersion = "9a964eaf"

repositories {
mavenCentral()
Expand Down Expand Up @@ -40,9 +40,9 @@ loom {

dependencies {
// Core
minecraft(group = "com.mojang", name = "minecraft", version = "1.20.1")
mappings(group = "net.fabricmc", name = "yarn", version = "1.20.1+build.10", classifier = "v2")
modImplementation(group = "net.fabricmc", name = "fabric-loader", version = "0.14.22")
minecraft(group = "com.mojang", name = "minecraft", version = "1.20.4")
mappings(group = "net.fabricmc", name = "yarn", version = "1.20.4+build.3", classifier = "v2")
modImplementation(group = "net.fabricmc", name = "fabric-loader", version = "0.15.3")

// fabric api
modImplementation(group = "net.fabricmc.fabric-api", name = "fabric-api", version = fabricVersion) {
Expand Down
2 changes: 1 addition & 1 deletion docker
Submodule docker updated 1 files
+12 −10 Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* OKTW Galaxy Project
* Copyright (C) 2018-2022
* Copyright (C) 2018-2023
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
Expand All @@ -18,29 +18,31 @@

package one.oktw.galaxy.mixin.event;

import net.minecraft.network.ClientConnection;
import net.minecraft.network.message.MessageType;
import net.minecraft.network.message.SignedMessage;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.PlayerManager;
import net.minecraft.server.network.ConnectedClientData;
import net.minecraft.server.network.ServerCommonNetworkHandler;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import one.oktw.galaxy.event.EventManager;
import one.oktw.galaxy.event.type.PlayerChatEvent;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(ServerPlayNetworkHandler.class)
public class MixinPlayerChat_NetworkHandler {
public abstract class MixinPlayerChat_NetworkHandler extends ServerCommonNetworkHandler {
@Shadow
public ServerPlayerEntity player;

@Shadow
@Final
private MinecraftServer server;
public MixinPlayerChat_NetworkHandler(MinecraftServer server, ClientConnection connection, ConnectedClientData clientData) {
super(server, connection, clientData);
}

@Redirect(method = "handleDecoratedMessage", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/PlayerManager;broadcast(Lnet/minecraft/network/message/SignedMessage;Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/network/message/MessageType$Parameters;)V"))
private void onChat(PlayerManager playerManager, SignedMessage message, ServerPlayerEntity sender, MessageType.Parameters messageType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@

package one.oktw.galaxy.mixin.event;

import net.minecraft.entity.EntityStatuses;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket;
import net.minecraft.network.packet.s2c.play.BlockUpdateS2CPacket;
import net.minecraft.network.packet.s2c.play.EntityStatusS2CPacket;
import net.minecraft.network.packet.s2c.play.HealthUpdateS2CPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ConnectedClientData;
import net.minecraft.server.network.ServerCommonNetworkHandler;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
Expand All @@ -33,10 +40,14 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ServerPlayNetworkHandler.class)
public class MixinPlayerInteractBlock_NetworkHandler {
public abstract class MixinPlayerInteractBlock_NetworkHandler extends ServerCommonNetworkHandler {
@Shadow
public ServerPlayerEntity player;

public MixinPlayerInteractBlock_NetworkHandler(MinecraftServer server, ClientConnection connection, ConnectedClientData clientData) {
super(server, connection, clientData);
}

@Inject(method = "onPlayerInteractBlock", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/network/ServerPlayerInteractionManager;interactBlock(Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/Hand;Lnet/minecraft/util/hit/BlockHitResult;)Lnet/minecraft/util/ActionResult;"
Expand All @@ -49,8 +60,10 @@ private void onPlayerInteractBlock(PlayerInteractBlockC2SPacket packet, Callback
// Re-sync block & inventory
ServerWorld world = player.getServerWorld();
BlockPos blockPos = packet.getBlockHitResult().getBlockPos();
player.networkHandler.sendPacket(new BlockUpdateS2CPacket(world, blockPos));
player.networkHandler.sendPacket(new BlockUpdateS2CPacket(world, blockPos.offset(packet.getBlockHitResult().getSide())));
sendPacket(new EntityStatusS2CPacket(player, EntityStatuses.CONSUME_ITEM));
sendPacket(new HealthUpdateS2CPacket(player.getHealth(), player.getHungerManager().getFoodLevel(), player.getHungerManager().getSaturationLevel()));
sendPacket(new BlockUpdateS2CPacket(world, blockPos));
sendPacket(new BlockUpdateS2CPacket(world, blockPos.offset(packet.getBlockHitResult().getSide())));
player.currentScreenHandler.syncState();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@

package one.oktw.galaxy.mixin.event;

import net.minecraft.network.packet.Packet;
import net.minecraft.entity.EntityStatuses;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket;
import net.minecraft.network.packet.s2c.play.EntityStatusS2CPacket;
import net.minecraft.network.packet.s2c.play.HealthUpdateS2CPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ConnectedClientData;
import net.minecraft.server.network.ServerCommonNetworkHandler;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import one.oktw.galaxy.event.EventManager;
Expand All @@ -32,12 +37,13 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ServerPlayNetworkHandler.class)
public abstract class MixinPlayerInteractItem_NetworkHandler {
public abstract class MixinPlayerInteractItem_NetworkHandler extends ServerCommonNetworkHandler {
@Shadow
public ServerPlayerEntity player;

@Shadow
public abstract void sendPacket(Packet<?> packet);
public MixinPlayerInteractItem_NetworkHandler(MinecraftServer server, ClientConnection connection, ConnectedClientData clientData) {
super(server, connection, clientData);
}

@Inject(method = "onPlayerInteractItem", at = @At(
value = "INVOKE",
Expand All @@ -47,7 +53,8 @@ private void onPlayerInteractItem(PlayerInteractItemC2SPacket packet, CallbackIn
PlayerInteractItemEvent event = EventManager.safeEmit(new PlayerInteractItemEvent(packet, player));
if (event.getCancel()) {
info.cancel();
sendPacket(new EntityStatusS2CPacket(player, (byte) 9));
sendPacket(new EntityStatusS2CPacket(player, EntityStatuses.CONSUME_ITEM));
sendPacket(new HealthUpdateS2CPacket(player.getHealth(), player.getHungerManager().getFoodLevel(), player.getHungerManager().getSaturationLevel()));
player.currentScreenHandler.syncState();
}
if (event.getSwing()) this.player.swingHand(packet.getHand(), true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* OKTW Galaxy Project
* Copyright (C) 2018-2020
* Copyright (C) 2018-2023
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
Expand All @@ -19,15 +19,16 @@
package one.oktw.galaxy.mixin.interfaces;

import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeEntry;
import net.minecraft.recipe.RecipeType;
import net.minecraft.util.Identifier;

import java.util.HashMap;

public interface CustomRecipeManager {
HashMap<RecipeType<?>, HashMap<Identifier, Recipe<?>>> customRecipes = new HashMap<>();
HashMap<RecipeType<?>, HashMap<Identifier, RecipeEntry<?>>> customRecipes = new HashMap<>();

static void addRecipe(RecipeType<?> type, Recipe<?> recipe) {
customRecipes.computeIfAbsent(type, k -> new HashMap<>()).putIfAbsent(recipe.getId(), recipe);
static void addRecipe(RecipeType<?> type, Identifier id, Recipe<?> recipe) {
customRecipes.computeIfAbsent(type, k -> new HashMap<>()).put(id, new RecipeEntry<Recipe<?>>(id, recipe));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import com.google.common.collect.ImmutableMap;
import com.google.gson.JsonElement;
import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeEntry;
import net.minecraft.recipe.RecipeManager;
import net.minecraft.recipe.RecipeType;
import net.minecraft.resource.ResourceManager;
Expand All @@ -37,8 +37,9 @@

@Mixin(RecipeManager.class)
public class MixinCustomRecipe_RecipeManager implements CustomRecipeManager {
@Inject(method = "apply(Ljava/util/Map;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/profiler/Profiler;)V", at = @At(value = "INVOKE", target = "Ljava/util/Map;entrySet()Ljava/util/Set;", ordinal = 1), locals = LocalCapture.CAPTURE_FAILSOFT)
private void recipeLoad(Map<Identifier, JsonElement> map, ResourceManager resourceManager, Profiler profiler, CallbackInfo ci, Map<RecipeType<?>, ImmutableMap.Builder<Identifier, Recipe<?>>> map2) {
@Inject(method = "apply(Ljava/util/Map;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/profiler/Profiler;)V", at = @At(value = "INVOKE", target = "Ljava/util/Map;entrySet()Ljava/util/Set;", ordinal = 0), locals = LocalCapture.CAPTURE_FAILSOFT)
private void recipeLoad(Map<Identifier, JsonElement> map, ResourceManager resourceManager, Profiler profiler, CallbackInfo ci, Map<RecipeType<?>, ImmutableMap.Builder<Identifier, RecipeEntry<?>>> map2, ImmutableMap.Builder<Identifier, RecipeEntry<?>> builder) {
customRecipes.forEach((i, v) -> map2.computeIfAbsent(i, k -> ImmutableMap.builder()).putAll(v));
customRecipes.forEach((i, v) -> builder.putAll(v));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* OKTW Galaxy Project
* Copyright (C) 2018-2024
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package one.oktw.galaxy.mixin.tweak;

import net.minecraft.resource.VanillaDataPackProvider;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;

import java.nio.file.Path;

@Mixin(VanillaDataPackProvider.class)
public class MixinGlobalDataPack_VanillaDataPackProvider {
@ModifyArg(method = "createManager(Lnet/minecraft/world/level/storage/LevelStorage$Session;)Lnet/minecraft/resource/ResourcePackManager;", at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/VanillaDataPackProvider;createManager(Ljava/nio/file/Path;Lnet/minecraft/util/path/SymlinkFinder;)Lnet/minecraft/resource/ResourcePackManager;"), index = 0)
private static Path moveDataPackPath(Path dataPacksPath) {
return Path.of("datapacks");
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* OKTW Galaxy Project
* Copyright (C) 2018-2021
* Copyright (C) 2018-2023
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
Expand Down Expand Up @@ -30,13 +30,13 @@
@Mixin(LootableContainerBlockEntity.class)
public abstract class MixinOptimizeContainer_LootableContainerBlockEntity {
@Shadow
protected abstract DefaultedList<ItemStack> getInvStackList();
protected abstract DefaultedList<ItemStack> method_11282();

@Inject(method = "isEmpty",
at = @At(value = "INVOKE", target = "Lnet/minecraft/block/entity/LootableContainerBlockEntity;checkLootInteraction(Lnet/minecraft/entity/player/PlayerEntity;)V", shift = At.Shift.AFTER),
at = @At(value = "INVOKE", target = "Lnet/minecraft/block/entity/LootableContainerBlockEntity;generateLoot(Lnet/minecraft/entity/player/PlayerEntity;)V", shift = At.Shift.AFTER),
cancellable = true)
private void replaceStream(CallbackInfoReturnable<Boolean> cir) {
for (ItemStack itemStack : getInvStackList()) {
for (ItemStack itemStack : method_11282()) {
if (!itemStack.isEmpty()) {
cir.setReturnValue(false);
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* OKTW Galaxy Project
* Copyright (C) 2018-2019
* Copyright (C) 2018-2023
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
Expand Down Expand Up @@ -42,28 +42,31 @@
*/
package org.spongepowered.common.mixin.realtime.server.network;

import net.minecraft.network.ClientConnection;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ConnectedClientData;
import net.minecraft.server.network.ServerCommonNetworkHandler;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.common.bridge.RealTimeTrackingBridge;

@Mixin(ServerPlayNetworkHandler.class)
public abstract class ServerPlayNetworkHandlerMixin_RealTime {
public abstract class ServerPlayNetworkHandlerMixin_RealTime extends ServerCommonNetworkHandler {
@Shadow
public ServerPlayerEntity player;
@Shadow
private int messageCooldown;
@Shadow
private int creativeItemDropThreshold;
@Shadow
@Final
private MinecraftServer server;

public ServerPlayNetworkHandlerMixin_RealTime(MinecraftServer server, ClientConnection connection, ConnectedClientData clientData) {
super(server, connection, clientData);
}

@Redirect(
method = "tick",
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/one/oktw/galaxy/block/CustomBlock.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ open class CustomBlock(final override val identifier: Identifier, val baseBlock:
val TELEPORTER_CORE_ADVANCE = registry.register(ModelCustomBlock("teleporter_core_advance", CustomBlockItem.TELEPORTER_CORE_ADVANCE.createItemStack()))
val TELEPORTER_FRAME = registry.register(ModelCustomBlock("teleporter_frame", CustomBlockItem.TELEPORTER_FRAME.createItemStack()))
val TEST_GUI = registry.register(TestGuiBlock())
val HARVEST = registry.register(HarvestBlock())
}

open fun toItem(): CustomBlockItem? = null
Expand Down
Loading

0 comments on commit a933b0a

Please sign in to comment.