Skip to content

Commit

Permalink
Remove mailbox
Browse files Browse the repository at this point in the history
closes #34
  • Loading branch information
TheEpicBlock committed Jul 31, 2024
1 parent 60d12f3 commit e24c0af
Show file tree
Hide file tree
Showing 12 changed files with 4 additions and 1,150 deletions.
44 changes: 0 additions & 44 deletions src/main/java/dev/hephaestus/glowcase/Glowcase.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,19 @@

import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import dev.hephaestus.glowcase.block.HyperlinkBlock;
import dev.hephaestus.glowcase.block.ItemDisplayBlock;
import dev.hephaestus.glowcase.block.MailboxBlock;
import dev.hephaestus.glowcase.block.TextBlock;
import dev.hephaestus.glowcase.block.entity.HyperlinkBlockEntity;
import dev.hephaestus.glowcase.block.entity.ItemDisplayBlockEntity;
import dev.hephaestus.glowcase.block.entity.MailboxBlockEntity;
import dev.hephaestus.glowcase.block.entity.TextBlockEntity;
import dev.hephaestus.glowcase.compat.PolydexCompatibility;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.Block;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.command.argument.BlockPosArgumentType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
Expand All @@ -32,11 +24,8 @@
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;

public class Glowcase implements ModInitializer {
public static final String MODID = "glowcase";
Expand All @@ -53,10 +42,6 @@ public class Glowcase implements ModInitializer {
public static final Supplier<BlockItem> ITEM_DISPLAY_BLOCK_ITEM = registerItem("item_display_block", () -> new BlockItem(ITEM_DISPLAY_BLOCK.get(), new Item.Settings()));
public static final Supplier<BlockEntityType<ItemDisplayBlockEntity>> ITEM_DISPLAY_BLOCK_ENTITY = registerBlockEntity("item_display_block", () -> BlockEntityType.Builder.create(ItemDisplayBlockEntity::new, ITEM_DISPLAY_BLOCK.get()).build(null));

public static final Supplier<MailboxBlock> MAILBOX_BLOCK = registerBlock("mailbox", MailboxBlock::new);
public static final Supplier<BlockItem> MAILBOX_ITEM = registerItem("mailbox", () -> new BlockItem(MAILBOX_BLOCK.get(), new Item.Settings()));
public static final Supplier<BlockEntityType<MailboxBlockEntity>> MAILBOX_BLOCK_ENTITY = registerBlockEntity("mailbox", () -> BlockEntityType.Builder.create(MailboxBlockEntity::new, MAILBOX_BLOCK.get()).build(null));

public static final Supplier<TextBlock> TEXT_BLOCK = registerBlock("text_block", TextBlock::new);
public static final Supplier<BlockItem> TEXT_BLOCK_ITEM = registerItem("text_block", () -> new BlockItem(TEXT_BLOCK.get(), new Item.Settings()));
public static final Supplier<BlockEntityType<TextBlockEntity>> TEXT_BLOCK_ENTITY = registerBlockEntity("text_block", () -> BlockEntityType.Builder.create(TextBlockEntity::new, TEXT_BLOCK.get()).build(null));
Expand All @@ -67,7 +52,6 @@ public class Glowcase implements ModInitializer {
.entries((displayContext, entries) -> {
entries.add(HYPERLINK_BLOCK_ITEM.get());
entries.add(ITEM_DISPLAY_BLOCK_ITEM.get());
entries.add(MAILBOX_ITEM.get());
entries.add(TEXT_BLOCK_ITEM.get());
})
.build()
Expand Down Expand Up @@ -97,36 +81,8 @@ public static <T extends BlockEntity> Supplier<BlockEntityType<T>> registerBlock
public void onInitialize() {
GlowcaseNetworking.init();

CommandRegistrationCallback.EVENT.register((dispatcher, access, environment) -> {
dispatcher.register(
LiteralArgumentBuilder.<ServerCommandSource>literal("mail")
.then(CommandManager.argument("pos", new BlockPosArgumentType())
.then(CommandManager.argument("message", StringArgumentType.greedyString()).executes(this::sendMessage)))
);
});

if (FabricLoader.getInstance().isModLoaded("polydex2")) {
PolydexCompatibility.onInitialize();
}
}

private int sendMessage(CommandContext<ServerCommandSource> ctx) {
BlockPos pos = BlockPosArgumentType.getBlockPos(ctx, "pos");
String message = ctx.getArgument("message", String.class);
PlayerEntity sender = ctx.getSource().getPlayer();

if (sender != null) {
if (sender.getWorld().getBlockEntity(pos) instanceof MailboxBlockEntity mailbox) {
mailbox.addMessage(new MailboxBlockEntity.Message(sender.getUuid(), sender.getNameForScoreboard(), message));
ctx.getSource().sendFeedback(() -> Text.translatable("command.glowcase.message_sent"), false);
return 0;
} else {
ctx.getSource().sendError(Text.translatable("command.glowcase.failed.no_mailbox"));
return 100;
}
} else {
ctx.getSource().sendError(Text.translatable("command.glowcase.failed.no_world"));
return 100;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ public void openItemDisplayBlockEditScreen(BlockPos pos) {
//No-op
}

public void prefillMailboxChat(BlockPos pos) {
//No-op
}

public void openTextBlockEditScreen(BlockPos pos) {
//No-op
}
}
}
93 changes: 0 additions & 93 deletions src/main/java/dev/hephaestus/glowcase/block/MailboxBlock.java

This file was deleted.

This file was deleted.

Loading

0 comments on commit e24c0af

Please sign in to comment.