Skip to content

Commit

Permalink
Merge branch 'master' into pipe
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/one/oktw/galaxy/mixin/tweak/MixinCustomBlockEntity_BarrierBlock.java
#	src/main/kotlin/one/oktw/galaxy/block/entity/ModelCustomBlockEntity.kt
  • Loading branch information
james58899 committed Jun 14, 2021
2 parents c9a5775 + 30771a0 commit 3b39805
Show file tree
Hide file tree
Showing 53 changed files with 375 additions and 423 deletions.
10 changes: 1 addition & 9 deletions .idea/codeStyles/Project.xml

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

11 changes: 5 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
// "maven-publish"
kotlin("jvm") version "1.5.10"
id("fabric-loom") version "0.6-SNAPSHOT"
id("fabric-loom") version "0.8-SNAPSHOT"
}

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

val galaxyLibVersion = "11f67fd9"
val galaxyLibVersion = "beb0eabb"

repositories {
mavenCentral()
Expand All @@ -34,17 +34,16 @@ tasks.withType<KotlinCompile> {
}

minecraft {
accessWidener("src/main/resources/galaxy-tweak.accesswidener")
}

dependencies {
// Core
minecraft(group = "com.mojang", name = "minecraft", version = "1.16.5")
mappings(group = "net.fabricmc", name = "yarn", version = "1.16.5+build.9", classifier = "v2")
minecraft(group = "com.mojang", name = "minecraft", version = "1.17")
mappings(group = "net.fabricmc", name = "yarn", version = "1.17+build.1", classifier = "v2")
modImplementation(group = "net.fabricmc", name = "fabric-loader", version = "0.11.3")

// fabric api
modImplementation(group = "net.fabricmc.fabric-api", name = "fabric-api", version = "0.34.2+1.16")
modImplementation(group = "net.fabricmc.fabric-api", name = "fabric-api", version = "0.34.9+1.17")

// galaxy api
implementation(group = "one.oktw", name = "galaxy-lib", version = galaxyLibVersion)
Expand Down
2 changes: 1 addition & 1 deletion docker
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* OKTW Galaxy Project
* Copyright (C) 2018-2020
* Copyright (C) 2018-2021
*
* 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 @@ -16,9 +16,14 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package one.oktw.galaxy.event.type
package one.oktw.galaxy.mixin.accessor;

import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket
import net.minecraft.server.network.ServerPlayerEntity
import net.minecraft.block.entity.BeaconBlockEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

class PlayerInteractEntityEvent(val packet: PlayerInteractEntityC2SPacket, val player: ServerPlayerEntity) : Event
@Mixin(BeaconBlockEntity.class)
public interface BeaconLevelAccessor {
@Accessor
int getLevel();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* OKTW Galaxy Project
* Copyright (C) 2018-2021
*
* 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.accessor;

import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.storage.StorageIoWorker;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

import java.util.concurrent.CompletableFuture;

@Mixin(StorageIoWorker.class)
public interface StorageIoWorkerAccessor {
@Invoker
CompletableFuture<NbtCompound> callReadChunkData(ChunkPos chunkPos);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* OKTW Galaxy Project
* Copyright (C) 2018-2020
* Copyright (C) 2018-2021
*
* 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 @@ -34,6 +34,7 @@
import org.spongepowered.asm.mixin.injection.Redirect;

import java.util.UUID;
import java.util.function.Function;

@Mixin(ServerPlayNetworkHandler.class)
public class MixinPlayerChat_NetworkHandler {
Expand All @@ -44,14 +45,14 @@ public class MixinPlayerChat_NetworkHandler {
@Final
private MinecraftServer server;

@Redirect(method = "method_31286", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/PlayerManager;broadcastChatMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/MessageType;Ljava/util/UUID;)V"))
private void onChat(PlayerManager playerManager, Text message, MessageType type, UUID senderUuid) {
@Redirect(method = "handleMessage", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/PlayerManager;broadcast(Lnet/minecraft/text/Text;Ljava/util/function/Function;Lnet/minecraft/network/MessageType;Ljava/util/UUID;)V"))
private void onChat(PlayerManager playerManager, Text serverMessage, Function<ServerPlayerEntity, Text> playerMessageFactory, MessageType playerMessageType, UUID sender) {
Main main = Main.Companion.getMain();

if (main == null || !main.getEventManager().emit(new PlayerChatEvent(player, message)).getCancel()) {
playerManager.broadcastChatMessage(message, type, senderUuid);
if (main == null || !main.getEventManager().emit(new PlayerChatEvent(player, serverMessage)).getCancel()) {
playerManager.broadcastChatMessage(serverMessage, playerMessageType, sender);
} else {
server.sendSystemMessage(((BaseText) message).append(" (Canceled)"), senderUuid);
server.sendSystemMessage(((BaseText) serverMessage).append(" (Canceled)"), sender);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ public class MixinPlayerChat_SayCommand {
cancellable = true,
locals = LocalCapture.CAPTURE_FAILSOFT
)
private static void onCommand(CommandContext<ServerCommandSource> context, CallbackInfoReturnable<Integer> cir, Text text, TranslatableText translatableText, Entity entity) {
private static void onCommand(CommandContext<ServerCommandSource> context, CallbackInfoReturnable<Integer> cir, Text text, Text text1, Entity entity) {
if (!(entity instanceof ServerPlayerEntity)) return;

Main main = Main.Companion.getMain();
ServerPlayerEntity player = (ServerPlayerEntity) entity;

if (main == null || !main.getEventManager().emit(new PlayerChatEvent(player, translatableText)).getCancel()) {
player.server.getPlayerManager().broadcastChatMessage(translatableText, MessageType.CHAT, entity.getUuid());
if (main == null || !main.getEventManager().emit(new PlayerChatEvent(player, text1)).getCancel()) {
player.server.getPlayerManager().broadcastChatMessage(text1, MessageType.CHAT, entity.getUuid());
} else {
cir.setReturnValue(0);
cir.cancel();
player.server.sendSystemMessage(translatableText.append(" (Canceled)"), entity.getUuid());
player.server.sendSystemMessage(((TranslatableText) text1).append(" (Canceled)"), entity.getUuid());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* OKTW Galaxy Project
* Copyright (C) 2018-2020
* Copyright (C) 2018-2021
*
* 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 @@ -51,7 +51,7 @@ private void onPlayerInteractBlock(PlayerInteractBlockC2SPacket packet, Callback
BlockPos blockPos = packet.getBlockHitResult().getBlockPos();
player.networkHandler.sendPacket(new BlockUpdateS2CPacket(world, blockPos));
player.networkHandler.sendPacket(new BlockUpdateS2CPacket(world, blockPos.offset(packet.getBlockHitResult().getSide())));
player.refreshScreenHandler(player.currentScreenHandler);
player.currentScreenHandler.syncState();
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private void onPlayerInteractItem(PlayerInteractItemC2SPacket packet, CallbackIn
PlayerInteractItemEvent event = main.getEventManager().emit(new PlayerInteractItemEvent(packet, player));
if (event.getCancel()) {
info.cancel();
player.refreshScreenHandler(player.currentScreenHandler);
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-2021
*
* 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,7 +42,7 @@ public class MixinPlayerUpdateSign_NetworkHandler {
@Shadow
public ServerPlayerEntity player;

@Inject(method = "method_31282",
@Inject(method = "onSignUpdate(Lnet/minecraft/network/packet/c2s/play/UpdateSignC2SPacket;Ljava/util/List;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/block/entity/SignBlockEntity;isEditable()Z"),
cancellable = true,
locals = LocalCapture.CAPTURE_FAILSOFT)
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-2021
*
* 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 @@ -20,17 +20,20 @@

import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.network.packet.s2c.play.InventoryS2CPacket;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.slot.CraftingResultSlot;
import net.minecraft.server.network.ServerPlayerEntity;
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.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(CraftingResultSlot.class)
public class MixinCustomRecipe_CraftingResultSlot {
@Inject(method = "onTakeItem", at = @At("RETURN"))
private void consumeInput(PlayerEntity player, ItemStack stack, CallbackInfoReturnable<ItemStack> cir) {
((ServerPlayerEntity) player).refreshScreenHandler(player.currentScreenHandler);
private void consumeInput(PlayerEntity player, ItemStack stack, CallbackInfo ci) {
ScreenHandler handler = player.currentScreenHandler;
((ServerPlayerEntity) player).networkHandler.sendPacket(new InventoryS2CPacket(handler.syncId, handler.getStacks()));
}
}

This file was deleted.

Loading

0 comments on commit 3b39805

Please sign in to comment.