mirror of
https://github.com/lukasabbe/bookshelf-inspector.git
synced 2026-04-30 10:40:53 +00:00
Small changes
This commit is contained in:
@@ -15,19 +15,20 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Bookshelfinspector implements ModInitializer {
|
||||
|
||||
public static MinecraftServer serverInstance;
|
||||
public final static String MOD_ID = "bookshelfinspector";
|
||||
|
||||
public static Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
//Registers request types
|
||||
//Registers client-to-server payloads
|
||||
PayloadTypeRegistry.playC2S().register(BookShelfInventoryRequestPayload.ID,BookShelfInventoryRequestPayload.CODEC);
|
||||
PayloadTypeRegistry.playC2S().register(LecternInventoryRequestPayload.ID, LecternInventoryRequestPayload.CODEC);
|
||||
PayloadTypeRegistry.playS2C().register(BookShelfInventoryPayload.ID,BookShelfInventoryPayload.CODEC);
|
||||
PayloadTypeRegistry.playS2C().register(ModCheckPayload.ID, ModCheckPayload.CODEC);
|
||||
|
||||
//Registers server-to-client receivers
|
||||
ServerPlayNetworking.registerGlobalReceiver(BookShelfInventoryRequestPayload.ID, new BookShelfInventoryRequestPayloadHandler());
|
||||
ServerPlayNetworking.registerGlobalReceiver(LecternInventoryRequestPayload.ID, new LecternInventoryRequestPayloadHandler());
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ public class BookshelfinspectorClient implements ClientModInitializer {
|
||||
|
||||
config.loadConfig();
|
||||
|
||||
//Registers server-to-client receivers
|
||||
ClientPlayNetworking.registerGlobalReceiver(BookShelfInventoryPayload.ID, new BookShelfInventoryHandler());
|
||||
ClientPlayNetworking.registerGlobalReceiver(ModCheckPayload.ID,new ModPayloadHandler());
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
public class ModPayloadHandler implements ClientPlayNetworking.PlayPayloadHandler<ModCheckPayload> {
|
||||
@Override
|
||||
public void receive(ModCheckPayload modCheckPayload, ClientPlayNetworking.Context context) {
|
||||
context.client().execute(() ->{
|
||||
Bookshelfinspector.LOGGER.info("[bookshelfinspector] Connected to server");
|
||||
context.client().execute(() -> {
|
||||
Bookshelfinspector.LOGGER.info("[bookshelfinspector] Connected to server [{}]", context.client().getServer().getVersion());
|
||||
BookshelfinspectorClient.modAvailable = true;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.lukasabbe.bookshelfinspector.util;
|
||||
|
||||
import me.lukasabbe.bookshelfinspector.Bookshelfinspector;
|
||||
import me.lukasabbe.bookshelfinspector.BookshelfinspectorClient;
|
||||
import me.lukasabbe.bookshelfinspector.data.BookData;
|
||||
import me.lukasabbe.bookshelfinspector.mixin.BookshelfInvoker;
|
||||
@@ -8,12 +9,10 @@ import me.lukasabbe.bookshelfinspector.network.packets.LecternInventoryRequestPa
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.fabricmc.fabric.api.tag.convention.v2.ConventionalBlockTags;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.ChiseledBookshelfBlock;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.registry.tag.BlockTags;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -29,10 +28,10 @@ public class Inspector {
|
||||
|
||||
if(client.cameraEntity == null || client.player == null) return;
|
||||
|
||||
//Send raycast max 5 blocks
|
||||
//Send ray-cast max 5 blocks
|
||||
HitResult hit = client.cameraEntity.raycast(5f,0f,false);
|
||||
|
||||
//find block hit, if not found block returns
|
||||
//Find block hit, if not found block returns
|
||||
final HitResult.Type type = hit.getType();
|
||||
if(type != HitResult.Type.BLOCK) {
|
||||
resetBookShelfData();
|
||||
@@ -42,6 +41,7 @@ public class Inspector {
|
||||
final BlockHitResult blockHitResult = (BlockHitResult) hit;
|
||||
BlockPos pos = blockHitResult.getBlockPos();
|
||||
|
||||
|
||||
if(bookShelfData.latestPos == null)
|
||||
bookShelfData.latestPos = pos;
|
||||
|
||||
|
||||
@@ -11,14 +11,14 @@ import java.util.Optional;
|
||||
|
||||
public class LecternTools {
|
||||
public static ItemStack getItemStack(BlockPos pos, PlayerEntity player){
|
||||
final World world = player.getWorld();
|
||||
|
||||
final World world = player.getWorld();
|
||||
if(world == null) return null;
|
||||
|
||||
Optional<LecternBlockEntity> blockEntityOptional = world.getBlockEntity(pos, BlockEntityType.LECTERN);
|
||||
if(blockEntityOptional.isEmpty()) return null;
|
||||
|
||||
LecternBlockEntity lecternBlock = blockEntityOptional.get();
|
||||
|
||||
return lecternBlock.getBook();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@ import java.util.TreeMap;
|
||||
|
||||
//https://stackoverflow.com/questions/12967896/converting-integers-to-roman-numerals-java
|
||||
public class RomanNumerals {
|
||||
|
||||
private final static TreeMap<Integer, String> map = new TreeMap<>();
|
||||
|
||||
static {
|
||||
map.put(1000, "M");
|
||||
map.put(900, "CM");
|
||||
@@ -21,7 +23,6 @@ public class RomanNumerals {
|
||||
map.put(1, "I");
|
||||
}
|
||||
|
||||
|
||||
public static String toRoman(int number){
|
||||
int key = map.floorKey(number);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user