Skip to content

Commit

Permalink
0.8.17
Browse files Browse the repository at this point in the history
  • Loading branch information
burningtnt committed Jan 6, 2025
1 parent 3860cf2 commit c71c16b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 32 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mod_name=Area Control
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=BSD-3-Clause
# The mod version. See https://semver.org/
mod_version=0.8.16
mod_version=0.8.17
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/teacon/areacontrol/AreaControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
@Mod("area_control")
@EventBusSubscriber(modid = "area_control")
public final class AreaControl {
public static String VERSION = "<not_initialized>";

private static final Logger LOGGER = LoggerFactory.getLogger("AreaControl");

Expand All @@ -42,6 +43,8 @@ public final class AreaControl {
public static Predicate<MinecraftServer> singlePlayerServerChecker;

public AreaControl(ModContainer container, IEventBus modBus) {
VERSION = container.getModInfo().getVersion().toString();

AreaRepositoryManager.init();
container.registerConfig(ModConfig.Type.SERVER, AreaControlConfig.setup(new ModConfigSpec.Builder()));
singlePlayerServerChecker = switch (FMLEnvironment.dist) {
Expand Down
20 changes: 1 addition & 19 deletions src/main/java/org/teacon/areacontrol/AreaControlCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.SectionPos;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.Style;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.AABB;
Expand Down Expand Up @@ -81,7 +78,6 @@ public AreaControlCommand(CommandDispatcher<CommandSourceStack> dispatcher) {
dispatcher.register(Commands.literal("ac")
.redirect(dispatcher.register(Commands.literal("areacontrol")
.then(Commands.literal("about").executes(AreaControlCommand::about))
.then(Commands.literal("help").executes(AreaControlCommand::help))
.then(Commands.literal("admin").requires(ADMIN)
.then(Commands.literal("rebuild").executes(AreaControlCommand::rebuildAreaModel))
)
Expand Down Expand Up @@ -211,21 +207,7 @@ private static int openConfiscatedItemInv(CommandContext<CommandSourceStack> con
}

private static int about(CommandContext<CommandSourceStack> context) {
context.getSource().sendSuccess(() -> Component.literal("AreaControl 0.8.16"), false);
return Command.SINGLE_SUCCESS;
}

private static int help(CommandContext<CommandSourceStack> context) {
var markerTool = new ItemStack(BuiltInRegistries.ITEM.get(ResourceLocation.parse(AreaControlConfig.areaClaimTool.get())));
var markerToolName = markerTool.getDisplayName();
var displayName = markerToolName.copy()
.withStyle(Style.EMPTY
.withColor(ChatFormatting.BLUE)
.withUnderlined(Boolean.TRUE)
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, markerTool.getHoverName().copy()
.append(Component.translatable("area_control.claim.how_to.give_item").withStyle(ChatFormatting.GRAY))))
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/give @s " + AreaControlConfig.areaClaimTool.get())));
context.getSource().sendSuccess(() -> Component.translatable("area_control.claim.how_to", displayName), false);
context.getSource().sendSuccess(() -> Component.literal("AreaControl " + AreaControl.VERSION), false);
return Command.SINGLE_SUCCESS;
}

Expand Down
18 changes: 11 additions & 7 deletions src/main/java/org/teacon/areacontrol/impl/AreaChecks.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.teacon.areacontrol.impl.seizer.ConfiscationInv;

import java.util.List;
import java.util.Optional;
import java.util.function.Supplier;

public class AreaChecks {
Expand Down Expand Up @@ -111,14 +112,17 @@ public static void checkInv(IItemHandler inv, Area currentArea, Player player) {
// This is a separate method because area.allow_possess currently has a different logic
public static boolean checkPossess(Area area, Item item) {
var targetId = BuiltInRegistries.ITEM.getKey(item);
if (targetId != null) {
var objSpecific = AreaProperties.getBoolOptional(area, AreaProperties.ALLOW_POSSESS + "." + targetId);
if (objSpecific.isPresent()) {
return objSpecific.get();
var objSpecific = AreaProperties.getBoolOptional(area, AreaProperties.ALLOW_POSSESS + "." + targetId);
if (objSpecific.isPresent()) {
return objSpecific.get();
} else {
var modSpecific = AreaProperties.getBoolOptional(area, AreaProperties.ALLOW_POSSESS + "." + targetId.getNamespace());
if (modSpecific.isPresent()) {
return modSpecific.get();
} else {
var modSpecific = AreaProperties.getBoolOptional(area, AreaProperties.ALLOW_POSSESS + "." + targetId.getNamespace());
if (modSpecific.isPresent()) {
return modSpecific.get();
Optional<Boolean> globalSpecific = AreaProperties.getBoolOptional(area, AreaProperties.ALLOW_POSSESS);
if (globalSpecific.isPresent()) {
return globalSpecific.get();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import net.minecraft.server.level.ServerPlayer;
import net.neoforged.neoforge.network.PacketDistributor;
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
import net.neoforged.neoforge.network.registration.HandlerThread;
import net.neoforged.neoforge.network.registration.PayloadRegistrar;
import org.jetbrains.annotations.Nullable;
import org.teacon.areacontrol.AreaControl;

public class ACNetworking {
public static void init(RegisterPayloadHandlersEvent event) {
PayloadRegistrar registrar = event.registrar("area_control")
.versioned("0.8.16")
.optional();
PayloadRegistrar registrar = event.registrar(AreaControl.VERSION).executesOn(HandlerThread.NETWORK).optional();

registrar.playToServer(ACPingServer.TYPE, ACPingServer.STREAM_CODEC, ACPingServer::handle);
registrar.playToClient(ACSendNearbyArea.TYPE, ACSendNearbyArea.STREAM_CODEC, ACSendNearbyArea::handle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ public void encode(@NotNull ByteBuf o, @NotNull ACPingServer instance) {
};

public void handle(IPayloadContext context) {
var player = context.player();
AreaControlPlayerTracker.getFrom(player).clientExtensionEnabled = true;
context.enqueueWork(() -> {
var player = context.player();
AreaControlPlayerTracker.getFrom(player).clientExtensionEnabled = true;
});
}

@Override
Expand Down

0 comments on commit c71c16b

Please sign in to comment.