Skip to content

Commit

Permalink
Update to 1.20.5
Browse files Browse the repository at this point in the history
  • Loading branch information
senseiwells committed Apr 24, 2024
1 parent 96f5efd commit d7d0a5e
Show file tree
Hide file tree
Showing 34 changed files with 292 additions and 664 deletions.
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id "maven-publish"
id "fabric-loom" version "1.5-SNAPSHOT"
id 'me.modmuss50.mod-publish-plugin' version '0.3.4'
id "fabric-loom" version "1.6-SNAPSHOT"
id 'me.modmuss50.mod-publish-plugin' version '0.5.1'
}

repositories {
Expand All @@ -18,7 +18,7 @@ repositories {
}
}

version = minecraft_version + "-" + mod_version
version = "${mod_version}+mc${minecraft_version}"
group = maven_group

dependencies {
Expand All @@ -27,8 +27,8 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"

modImplementation "com.github.gnembon:fabric-carpet:${carpet_version}"
modImplementation("com.github.CaffeineMC:lithium-fabric:mc1.20.4-0.12.1") {
modImplementation "com.github.senseiwells:fabric-carpet:${carpet_version}"
modImplementation("com.github.CaffeineMC:lithium-fabric:${lithium_version}") {
exclude group: 'com.github.2No2Name', module: 'McTester'
}
include modImplementation("me.lucko:fabric-permissions-api:0.2-SNAPSHOT")
Expand All @@ -40,7 +40,7 @@ processResources {
filesMatching("fabric.mod.json") {
def map = [
"version" : mod_version,
"carpet_dependency" : ">=" + carpet_version,
// "carpet_dependency" : ">=" + carpet_version,
"minecraft_dependency": minecraft_dependency
]
expand map
Expand Down
15 changes: 8 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx6G
# Fabric Properties
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.1
loader_version=0.15.0
minecraft_version=1.20.5
yarn_mappings=1.20.5+build.1
loader_version=0.15.10
# Mod Properties
mod_version = 1.3.4
mod_version = 1.4.0
maven_group = essentialaddons
# Dependencies
carpet_version=1.4.128
fabric_version=0.91.1+1.20.4
mixin_extras_version=0.2.0
carpet_version=8639fa9d957bc41d205280017ffe325093c924ad
lithium_version=98a10fbeeaf72a1b1162f5fe6ec8315df3e9caa5
fabric_version=0.97.6+1.20.5
minecraft_dependency=1.20.x

2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
23 changes: 5 additions & 18 deletions src/main/java/essentialaddons/EssentialAddons.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@

import carpet.CarpetExtension;
import carpet.CarpetServer;
import carpet.script.CarpetExpression;
import com.mojang.brigadier.CommandDispatcher;
import essentialaddons.commands.*;
import essentialaddons.feature.GameRuleNetworkHandler;
import essentialaddons.feature.ReloadFakePlayers;
import essentialaddons.feature.script.PacketEvent;
import essentialaddons.feature.script.ScriptPacketHandler;
import essentialaddons.logging.EssentialAddonsLoggerRegistry;
import essentialaddons.utils.*;
import essentialaddons.utils.network.NetworkHandler;
import net.fabricmc.api.ModInitializer;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.server.MinecraftServer;
Expand All @@ -26,7 +22,6 @@
public class EssentialAddons implements CarpetExtension, ModInitializer {
public static final Logger LOGGER;
public static final Set<Config> CONFIG_SET;
public static final Set<NetworkHandler> NETWORK_HANDLERS;
public static MinecraftServer server;

static {
Expand All @@ -37,16 +32,14 @@ public class EssentialAddons implements CarpetExtension, ModInitializer {
ConfigFakePlayerData.INSTANCE,
ConfigTeamTeleportBlacklist.INSTANCE
);
NETWORK_HANDLERS = Set.of(
GameRuleNetworkHandler.INSTANCE,
ScriptPacketHandler.INSTANCE
);
}

@Override
public void onInitialize() {
CarpetServer.manageExtension(this);
ConfigCamera.INSTANCE.readConfig();

GameRuleNetworkHandler.INSTANCE.registerGameRulePayloads();
}

@Override
Expand All @@ -64,11 +57,6 @@ public void registerLoggers() {
EssentialAddonsLoggerRegistry.registerLoggers();
}

@Override
public void scarpetApi(CarpetExpression expression) {
ScriptPacketHandler.INSTANCE.addScarpetExpression(expression.getExpr());
}

@Override
public void onServerLoaded(MinecraftServer server) {
EssentialAddons.server = server;
Expand All @@ -82,7 +70,6 @@ public void onServerLoadedWorlds(MinecraftServer server) {
if (EssentialSettings.reloadFakePlayers) {
ReloadFakePlayers.loadFakePlayers(server);
}
PacketEvent.noop();
}

@Override
Expand All @@ -93,7 +80,7 @@ public void onServerClosed(MinecraftServer server) {
}

@Override
public void registerCommands(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess commandBuildContext) {
public void registerCommands(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess access) {
CommandFly.register(dispatcher);
CommandHat.register(dispatcher);
CommandRepair.register(dispatcher);
Expand All @@ -117,7 +104,7 @@ public void registerCommands(CommandDispatcher<ServerCommandSource> dispatcher,
CommandTop.register(dispatcher);
CommandNear.register(dispatcher);
CommandLagSpike.register(dispatcher);
CommandRename.register(dispatcher);
CommandRename.register(dispatcher, access);
CommandMods.register(dispatcher);
CommandGhostPlayer.register(dispatcher);
CommandConfig.register(dispatcher);
Expand All @@ -126,7 +113,7 @@ public void registerCommands(CommandDispatcher<ServerCommandSource> dispatcher,

@Override
public void onPlayerLoggedIn(ServerPlayerEntity player) {
NETWORK_HANDLERS.forEach(networkHandler -> networkHandler.sayHello(player));
GameRuleNetworkHandler.INSTANCE.sayHello(player);
}

@Override
Expand Down
21 changes: 0 additions & 21 deletions src/main/java/essentialaddons/EssentialUtils.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package essentialaddons;

import carpet.helpers.InventoryHelper;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import essentialaddons.utils.Subscription;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.BlockState;
import net.minecraft.block.ShulkerBoxBlock;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.damage.DamageSource;
Expand All @@ -28,7 +25,6 @@
import net.minecraft.text.Text;
import net.minecraft.util.ItemScatterer;
import net.minecraft.util.WorldSavePath;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.GameRules;
import net.minecraft.world.World;
import org.apache.commons.io.IOUtils;
Expand All @@ -44,8 +40,6 @@

import static carpet.utils.CommandHelper.canUseCommand;
import static essentialaddons.EssentialAddons.server;
import static net.minecraft.block.Block.dropStack;
import static net.minecraft.block.Block.getDroppedStacks;

public class EssentialUtils {
public static final Random RANDOM = new Random();
Expand Down Expand Up @@ -93,24 +87,9 @@ public static void breakVehicleStorage(
}
}

public static void placeItemInInventory(BlockState state, World world, BlockPos pos, BlockEntity blockEntity, ServerPlayerEntity player, ItemStack stack){
if (world instanceof ServerWorld serverWorld) {
getDroppedStacks(state, serverWorld, pos, blockEntity, player, stack).forEach((itemStack) -> {
if (!placeItemInInventory(player, itemStack)) {
dropStack(serverWorld, pos, itemStack);
}
});
state.onStacksDropped(serverWorld, pos, stack, true);
}
}

public static boolean placeItemInInventory(ServerPlayerEntity player, ItemStack itemStack) {
Item item = itemStack.getItem();
int itemAmount = itemStack.getCount();
if (EssentialSettings.stackableShulkersInPlayerInventories && !InventoryHelper.shulkerBoxHasItems(itemStack) && isItemShulkerBox(itemStack.getItem())) {
itemStack.removeSubNbt("BlockEntityTag");
item = itemStack.getItem();
}
if (player.getInventory().insertStack(itemStack)) {
player.getWorld().playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2f, (RANDOM.nextFloat() - RANDOM.nextFloat()) * 1.4F + 2.0F);
player.increaseStat(Stats.PICKED_UP.getOrCreateStat(item), itemAmount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private static boolean isInDanger(ServerPlayerEntity player) {
}

for (StatusEffectInstance effect : player.getStatusEffects()) {
if (effect.getEffectType().getCategory() == StatusEffectCategory.HARMFUL) {
if (effect.getEffectType().value().getCategory() == StatusEffectCategory.HARMFUL) {
EssentialUtils.sendToActionBar(player, "§cYou cannot enter spectator because you have a negative status effect");
return true;
}
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/essentialaddons/commands/CommandRename.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package essentialaddons.commands;

import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import essentialaddons.EssentialSettings;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.command.argument.TextArgumentType;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.item.ItemStack;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.Text;
Expand All @@ -17,24 +20,24 @@
public class CommandRename {
private static final SimpleCommandExceptionType ITEM_IS_AIR = new SimpleCommandExceptionType(Text.literal("Cannot rename air!"));

public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
public static void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess access) {
// We let them handle /rename command
if (FabricLoader.getInstance().isModLoaded("itemrename")) {
return;
}

dispatcher.register(literal("rename").requires(enabled(() -> EssentialSettings.commandRename, "essentialaddons.command.rename"))
.then(literal("json")
.then(argument("name", TextArgumentType.text())
.then(argument("name", TextArgumentType.text(access))
.executes(context -> {
ItemStack stack = context.getSource().getPlayerOrThrow().getMainHandStack();
if (!stack.isEmpty()) {
Text text = TextArgumentType.getTextArgument(context, "name");
context.getSource().sendFeedback(() -> {
return Text.literal("Item name set to: ").append(text);
}, false);
stack.setCustomName(text);
return 0;
stack.set(DataComponentTypes.CUSTOM_NAME, text);
return Command.SINGLE_SUCCESS;
}
throw ITEM_IS_AIR.create();
})
Expand All @@ -49,8 +52,8 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
context.getSource().sendFeedback(() -> {
return Text.literal("Item name set to: ").append(name);
}, false);
itemStack.setCustomName(Text.literal(name).styled(s -> s.withItalic(false)));
return 0;
itemStack.set(DataComponentTypes.CUSTOM_NAME, Text.literal(name).styled(s -> s.withItalic(false)));
return Command.SINGLE_SUCCESS;
}
throw ITEM_IS_AIR.create();
})
Expand Down
Loading

0 comments on commit d7d0a5e

Please sign in to comment.