working on DataIO
DataIO ist fertig; viele kleinigkeiten wurden sonst auch ncoh hinzugefügt
This commit is contained in:
parent
e6acd9460d
commit
7319724efa
|
@ -1,19 +1,18 @@
|
|||
package modchest;
|
||||
|
||||
import modchest.networking.modNetworkingClient;
|
||||
import modchest.util.clientInitializer;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import modchest.util.initializer;
|
||||
|
||||
public class REServerModClient implements ClientModInitializer {
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger("modchest"); // Erster Error Logger
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
// This entrypoint is suitable for setting up client-specific logic, such as rendering.
|
||||
initializer.networking();
|
||||
initializer.renderer();
|
||||
|
||||
clientInitializer.renderer();
|
||||
clientInitializer.networking();
|
||||
|
||||
LOGGER.info("Modchest-Client successfully loaded!");
|
||||
}
|
||||
|
|
|
@ -9,7 +9,8 @@ public class modNetworkingClient { //Identifier werden eingeführt
|
|||
public static final Identifier request_respawn = new Identifier(REServerMod.MOD_ID, "request_respawn"); //alle Identifier muessen leider IMMER auf Client und Server (doppelt) eingefuehrt werden
|
||||
public static final Identifier start_sleeping_call_buttons = new Identifier(REServerMod.MOD_ID, "start_sleeping_call_buttons");
|
||||
public static final Identifier death_multi_respawn_buttons = new Identifier(REServerMod.MOD_ID, "death_call_respawn_buttons");
|
||||
public static void registerC2SPackets() { //Identifier fuer packets werden registriert (Identifier die der Server aufruft um beim CLient was auszufuehren)
|
||||
|
||||
public static void registerS2CPackets() { //Identifier fuer packets werden registriert (Identifier die der Server aufruft um beim Client was auszufuehren)
|
||||
ClientPlayNetworking.registerGlobalReceiver(request_respawn, respawnRequestS2CPacket::receive); //was der Client dann machen soll steht in der receive Methode
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
package modchest.util;
|
||||
|
||||
import modchest.block.entity.modBlockEntities;
|
||||
import modchest.block.modBlocks;
|
||||
import modchest.item.modItemGroup;
|
||||
import modchest.item.modItems;
|
||||
import modchest.networking.modNetworkingClient;
|
||||
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
|
||||
public class initializer {
|
||||
public class clientInitializer {
|
||||
public static void itemGroups() {
|
||||
//modItemGroup.modchest(); // Item Gruppe fürs Creative-Inventar wird erstellt; In dieser Gruppe sollen
|
||||
// dann alle Items und Blöcke dieser Mod angezeigt werden
|
||||
|
@ -24,7 +21,7 @@ public class initializer {
|
|||
}
|
||||
|
||||
public static void networking() { //Identifier unter denen der Server zuhoert werden registriert
|
||||
modNetworkingClient.registerC2SPackets(); //Identifier unter denen der Client zuhoert werden registriert
|
||||
modNetworkingClient.registerS2CPackets(); //Identifier unter denen der Client zuhoert werden registriert
|
||||
}
|
||||
|
||||
public static void renderer() { //Grafikrenderer werden aufgerufen
|
|
@ -1,25 +1,34 @@
|
|||
package modchest.block.custom;
|
||||
|
||||
import modchest.util.denkMalBlockUtil;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.BlockWithEntity;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.explosion.Explosion;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class denkMalBlock extends BlockWithEntity { //Item soll nciht craftable sein
|
||||
import static modchest.block.modBlocks.denk_mal_block_placeholder;
|
||||
|
||||
public class denkMalBlock extends BlockWithEntity { //Item soll nicht craftable sein
|
||||
public static BooleanProperty POWERED = BooleanProperty.of("powered"); //speichert ob der Block ein Redstonesignal erhaelt
|
||||
|
||||
public denkMalBlock(FabricBlockSettings fabricBlockSettings) {
|
||||
super(fabricBlockSettings);
|
||||
setDefaultState(getDefaultState().with(POWERED, false)); //Block ist beim platzieren immer aus
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) { //ruft auf, die Grafik zu rendern
|
||||
return BlockRenderType.MODEL;
|
||||
|
@ -32,14 +41,101 @@ public class denkMalBlock extends BlockWithEntity { //Item soll nciht crafta
|
|||
return SHAPE;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override //Später relevant für das Interface
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override //Block soll nicht gedroped werden; Nur mit Silktouch
|
||||
@Override
|
||||
public boolean isTranslucent(BlockState state, BlockView world, BlockPos pos) { //damit man durch den Glasteil des blockes sehen kann
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override //Block soll nicht gedroped werden
|
||||
public boolean shouldDropItemsOnExplosion(Explosion explosion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) { //platziert den placeholder block oben drauf, weil es in miencraft keine 2 hohen Bloecke gibt
|
||||
super.onPlaced(world, pos, state, placer, itemStack);
|
||||
if (!world.isClient) {
|
||||
world.setBlockState(pos.up(1), denk_mal_block_placeholder.getDefaultState(), Block.NOTIFY_ALL); //platziert den placeholder Block ueber sich selbst
|
||||
world.updateNeighbors(pos, Blocks.AIR);
|
||||
state.updateNeighbors(world, pos, Block.NOTIFY_ALL);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBroken(WorldAccess world, BlockPos pos, BlockState state) { //entfernt sich aus der Liste der zu ueberpruefenden bloecke
|
||||
denkMalBlockUtil data = new denkMalBlockUtil();
|
||||
world.setBlockState(pos.up(1), Blocks.AIR.getDefaultState(), Block.NOTIFY_ALL); //entfernt den Placeholder block ueber sich
|
||||
int[] temp = new int[3];
|
||||
temp[0] = pos.getX();
|
||||
temp[1] = pos.getY();
|
||||
temp[2] = pos.getZ();
|
||||
data.removeBlock(temp); //entfernt sich aus der liste der Abbauverhindernden Bloecke
|
||||
|
||||
}
|
||||
|
||||
//CODE ZUM UEBERPREUFEN OB MIT REDSTONE GEPOWERED
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||
return (BlockState) this.getDefaultState().with(POWERED, ctx.getWorld().isReceivingRedstonePower(ctx.getBlockPos()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) {
|
||||
if (world.isClient) {
|
||||
return;
|
||||
}
|
||||
boolean bl = state.get(POWERED);
|
||||
|
||||
if (bl != world.isReceivingRedstonePower(pos)) {
|
||||
if (bl) {
|
||||
world.createAndScheduleBlockTick(pos, this, 4);
|
||||
} else {
|
||||
world.setBlockState(pos, (BlockState) state.cycle(POWERED), Block.NOTIFY_LISTENERS);
|
||||
changePositionList(state, world, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
|
||||
if (state.get(POWERED).booleanValue() && !world.isReceivingRedstonePower(pos)) {
|
||||
world.setBlockState(pos, (BlockState) state.cycle(POWERED), Block.NOTIFY_LISTENERS);
|
||||
changePositionList(state, world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
builder.add(POWERED);
|
||||
}
|
||||
|
||||
//CODE ZUM UEBERÜREUFEN OB MIT REDSTONE GEPOWERED ZUENDE
|
||||
|
||||
private void changePositionList(BlockState state, World world, BlockPos pos) { //aendert ob der Block in der Liste der Bloecke steht, die das abbauen verhindern
|
||||
denkMalBlockUtil data = new denkMalBlockUtil();
|
||||
if (!world.isClient) {
|
||||
int[] temp = new int[3];
|
||||
temp[0] = pos.getX();
|
||||
temp[1] = pos.getY();
|
||||
temp[2] = pos.getZ();
|
||||
int[] range = new int[3]; //noch ist die range auf 20 Bloecke, soll aber spaeter via ein Entity vom Spieler veraendert werden koenneny
|
||||
range[0] = 20;
|
||||
range[1] = 20;
|
||||
range[2] = 20;
|
||||
if (!state.get(POWERED)) {
|
||||
data.addBlock(temp, range);
|
||||
} else {
|
||||
data.removeBlock(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package modchest.block.custom;
|
||||
|
||||
import modchest.REServerMod;
|
||||
import modchest.util.denkMalBlockUtil;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static modchest.block.modBlocks.denk_mal_block_placeholder;
|
||||
|
||||
public class denkMalBlockPlaceholder extends Block { //Block der simuliert, dass der DenkMalBLock 2 Bloecke hoch waere
|
||||
public denkMalBlockPlaceholder(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) { //Grafik kommt vom DenkMalBLock, dieser Block muss also unsichtbar sein
|
||||
return BlockRenderType.INVISIBLE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBroken(WorldAccess world, BlockPos pos, BlockState state) { //Loescht den eigentlichen DenkMalBlock
|
||||
denkMalBlockUtil data = new denkMalBlockUtil(); //denkMalBLockUtil holt sich alle infos von der static dataSaverIO Klasse
|
||||
world.setBlockState(pos.down(1), Blocks.AIR.getDefaultState(), Block.NOTIFY_ALL); //unter diesem Block wird Luft platziert
|
||||
int[] temp = new int[3];
|
||||
temp[0] = pos.getX();
|
||||
temp[1] = (pos.getY()-1);
|
||||
temp[2] = pos.getZ();
|
||||
data.removeBlock(temp); //Loescht den denkMalBLock aus der Liste der abbauverhindernden Bloecke
|
||||
}
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package modchest.block;
|
||||
|
||||
import modchest.block.custom.denkMalBlock;
|
||||
import modchest.block.custom.denkMalBlockPlaceholder;
|
||||
import modchest.block.custom.steeringWheelBlock;
|
||||
import modchest.item.modItemGroup;
|
||||
import modchest.REServerMod;
|
||||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
|
@ -18,6 +18,7 @@ import net.minecraft.util.registry.Registry;
|
|||
public class modBlocks {
|
||||
public static Block steering_wheel; // Block wird erstellt
|
||||
public static Block denk_mal_block;
|
||||
public static Block denk_mal_block_placeholder;
|
||||
|
||||
public static void setBlocks() {// Block wird definiert
|
||||
steering_wheel = registerBlock("steering_wheel",
|
||||
|
@ -25,19 +26,24 @@ public class modBlocks {
|
|||
modItemGroup.modchest);
|
||||
|
||||
denk_mal_block = registerBlock("denk_mal_block",
|
||||
new denkMalBlock(FabricBlockSettings.copyOf(Blocks.GLASS).nonOpaque()),
|
||||
new denkMalBlock(FabricBlockSettings.of(Material.METAL).strength(4.0f).requiresTool().luminance((state) -> state.get(denkMalBlock.POWERED) ? 5 : 0).nonOpaque()),
|
||||
modItemGroup.modchest);
|
||||
|
||||
denk_mal_block_placeholder = registerBlockWithoutItem("denk_mal_block_placeholder",
|
||||
new denkMalBlockPlaceholder(FabricBlockSettings.of(Material.METAL).strength(4.0f).requiresTool().nonOpaque()));
|
||||
|
||||
}
|
||||
|
||||
private static Block registerBlock(String name, Block block, ItemGroup group) { // Nicht verändern! Fügt die oben
|
||||
// definierten Blöcke dem Register
|
||||
// hinzu
|
||||
private static Block registerBlock(String name, Block block, ItemGroup group) { // Nicht verändern! Fügt die oben definierten Blöcke dem Register hinzu
|
||||
Registry.register(Registry.ITEM, new Identifier(REServerMod.MOD_ID, name),
|
||||
new BlockItem(block, new FabricItemSettings().group(group)));
|
||||
return Registry.register(Registry.BLOCK, new Identifier(REServerMod.MOD_ID, name), block);
|
||||
}
|
||||
|
||||
private static Block registerBlockWithoutItem(String name, Block block) { // Nicht verändern! Fügt die oben definierten Blöcke dem Register hinzu
|
||||
return Registry.register(Registry.BLOCK, new Identifier(REServerMod.MOD_ID, name), block);
|
||||
}
|
||||
|
||||
public static void registerModBlocks() { // Error Logger halt...
|
||||
REServerMod.LOGGER.info("Registering ModBlocks for " + REServerMod.MOD_ID);
|
||||
}
|
||||
|
|
|
@ -10,11 +10,11 @@ import net.minecraft.util.registry.Registry;
|
|||
|
||||
//Liste der Items die hinzugefügt werden, ausgenommen Blöcke
|
||||
public class modItems {
|
||||
public static Item shipblock; // shipblock wird erstellt, sollte man mal umbenenne. Ist eine Zutat die man für
|
||||
private static Item shipblock; // shipblock wird erstellt, sollte man mal umbenenne. Ist eine Zutat die man für
|
||||
// das steering_wheel braucht zum craften, mehr macht es bisher nicht
|
||||
public static Item pirates_coin; // pirates Coin wird erstellt; definition siehe ./custom/piratesCoinItem da ist
|
||||
private static Item pirates_coin; // pirates Coin wird erstellt; definition siehe ./custom/piratesCoinItem da ist
|
||||
// im detail erklärt was das Item machen soll
|
||||
public static Item denk_mal_item;
|
||||
private static Item denk_mal_item;
|
||||
|
||||
public static void setItems() { // Items werden beschrieben, bzw. dem Register hinzugefügt
|
||||
shipblock = registerItem("shipblock", new Item(new FabricItemSettings().group(modItemGroup.modchest)));
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package modchest.mixin;
|
||||
|
||||
import modchest.REServerMod;
|
||||
import modchest.util.interfaces.LevelStorageInterface;
|
||||
import net.minecraft.world.level.storage.LevelStorage;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import net.minecraft.world.level.storage.LevelStorage.Session;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@Mixin(Session.class)
|
||||
public abstract class LevelStorageMixin implements LevelStorageInterface {
|
||||
|
||||
@Final
|
||||
@Shadow
|
||||
LevelStorage.LevelSave directory;
|
||||
|
||||
public File getFile() { //gibt den Dateipfad zurueck
|
||||
File dateiPfad = null;
|
||||
try {
|
||||
dateiPfad = directory.path().toFile(); //Versucht den Dateipfad einzulesen; weil es sehr frueh kommt besonders abgesichert
|
||||
} catch (Exception e) {
|
||||
REServerMod.LOGGER.info("Error when trying to read File path: {}", e.toString());
|
||||
}
|
||||
return dateiPfad;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package modchest.mixin;
|
||||
|
||||
import modchest.REServerMod;
|
||||
import modchest.util.interfaces.LevelStorageInterface;
|
||||
import modchest.util.dataSaverIO;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.level.storage.LevelStorage;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@Mixin(MinecraftServer.class)
|
||||
public class MinecraftServerMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
protected LevelStorage.Session session;
|
||||
@Unique
|
||||
dataSaverIO dataSaver = new dataSaverIO();
|
||||
|
||||
@Inject(method = "prepareStartRegion", at = @At("TAIL"))
|
||||
private void prepareStartRegion(CallbackInfo ci) { //wird beim Start des Servers aufgerufen
|
||||
dataSaver.resetData(); //stellt sicher, dass keine Daten von einer Welt in eine andere "leaken" in dem es alle Daten loescht
|
||||
LevelStorageInterface levelStorage = (LevelStorageInterface) session; //castet session mit dem Interface, damit custom Methoden verwendet werden koennen
|
||||
try {
|
||||
File file;
|
||||
file = levelStorage.getFile(); //holt sich den Dateipfad
|
||||
if (file != null) {
|
||||
dataSaver.writeFilePath(file); //schreibt den Dateipfad der Welt fuer das dataSaverIO
|
||||
dataSaver.readFile(); //holt die Daten von der Festplatte in den RAM
|
||||
} else {
|
||||
REServerMod.LOGGER.info("file is zero");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
REServerMod.LOGGER.info("file could not be read with Exception: {}", e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "shutdown", at = @At("HEAD"))
|
||||
private void shutdown(CallbackInfo ci) { //is called when server shuts down
|
||||
dataSaver.saveFile(); //Saves the Serverdata
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package modchest.mixin;
|
||||
|
||||
import modchest.REServerMod;
|
||||
import modchest.util.ServerPlayerEntityInterface;
|
||||
import modchest.util.interfaces.ServerPlayerEntityInterface;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -10,8 +10,6 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Mixin(ServerPlayerEntity.class)
|
||||
public abstract class ServerPlayerEntityMixin implements ServerPlayerEntityInterface {
|
||||
@Unique
|
||||
|
@ -39,7 +37,7 @@ public abstract class ServerPlayerEntityMixin implements ServerPlayerEntityInter
|
|||
REServerMod.LOGGER.info("Error while saving custom NBt-Data: " + e);
|
||||
}
|
||||
} else {
|
||||
REServerMod.LOGGER.info("write failed! This probably means, that the player hasn't set a custom spanpoint yet");
|
||||
REServerMod.LOGGER.info("write failed! This probably means, that the player hasn't set a custom spawnpoint yet");
|
||||
}
|
||||
//REServerMod.LOGGER.info("writeCustomDataToNbt called");
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import modchest.util.setAndGetMultiButtonsSpawn;
|
|||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -14,12 +13,11 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Mixin(BedBlock.class)
|
||||
public class bedBlock {
|
||||
public class bedBlockMixin {
|
||||
|
||||
@Inject(method = "onBreak", at = @At("HEAD"))
|
||||
public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player, CallbackInfo ci) { //Ueberprueft, wenn ein Bett zerstoert wird, ob jemand dieses Bett als Spawnpunkt hat
|
|
@ -11,7 +11,7 @@ public class modNetworkingServer { //Identifier werden eingeführt
|
|||
public static final Identifier start_sleeping_call_buttons = new Identifier(REServerMod.MOD_ID, "start_sleeping_call_buttons");
|
||||
public static final Identifier death_multi_respawn_buttons = new Identifier(REServerMod.MOD_ID, "death_call_respawn_buttons");
|
||||
|
||||
public static void registerS2CPackets() { //Identifier fuer packets werden registriert (Identifier die der Client aufruft um beim Server was auszufuehren)
|
||||
public static void registerC2SPackets() { //Identifier fuer packets werden registriert (Identifier die der Client aufruft um beim Server was auszufuehren)
|
||||
ServerPlayNetworking.registerGlobalReceiver(start_sleeping_call_buttons, setNewRespawnsC2SPacket::receive); //was der Server dann machen soll steht in der receive Methode
|
||||
|
||||
ServerPlayNetworking.registerGlobalReceiver(death_multi_respawn_buttons, deathScreenMultiButtonsC2SPacket::receive);
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package modchest.util;
|
||||
|
||||
import modchest.REServerMod;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class dataSaverIO { //Speichert alles mod-relevanten Serverdaten ab
|
||||
private static File reServerFile = null;
|
||||
private static NbtCompound reServerNbt = null;
|
||||
|
||||
public dataSaverIO() {}
|
||||
|
||||
void readFromFile() { //laedt die Daten der Datei; macht der Server bereits automatisch, danke mixin!
|
||||
try {
|
||||
reServerNbt = NbtIo.read(reServerFile); //liest die Datei
|
||||
if (reServerNbt == null) { //sollte der Nbt-Tag noch nciht existieren, wird er erstellt
|
||||
reServerNbt = new NbtCompound();
|
||||
}
|
||||
} catch (IOException e) { //sollte das IO einen Fehler haben, sollte aber nie vorkommen, wird die mod versuchen es zu fixen, indem sie einen neuen NbtTag erstellt und mit dem weiter arbeitet
|
||||
REServerMod.LOGGER.error("Error when trying to read from file: " + String.valueOf(e) + " trying to fix it by making a new Nbt");
|
||||
reServerNbt = new NbtCompound();
|
||||
} catch (Exception e) { //alle anderen exception, versucht er genau so zu fixen. Loescht alle alten Daten, aber besser, als das die Mod garnicht mehr geht
|
||||
reServerNbt = new NbtCompound();
|
||||
}
|
||||
}
|
||||
|
||||
void writeToFile() { //speichert den Nbt-Tag als Datei ab; macht der Server auch automatisch
|
||||
reServerNbt.putInt("NullSafety", 1); //gibt manchmal Probleme wenn nichts im Nbt-Tag steht, deswegen wird hin und wieder mal eine NullSafety abgespeichert
|
||||
try {
|
||||
if (reServerNbt != null) { //stellt sicher, das auch wirklich wirklich was im NbtTag steht vor dem abspeichern
|
||||
NbtIo.write(reServerNbt, reServerFile);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
REServerMod.LOGGER.error("Error when trying to write to file: " + String.valueOf(e));
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNbt(NbtCompound nbt) { //ueberschreibt den ServerNbt-Tag, pass auf, dass du nicht sachen von anderen Teilen der mods vergisst mit zu kopieren!
|
||||
reServerNbt = nbt;
|
||||
}
|
||||
|
||||
public NbtCompound getFromNbt() { //uebergibt den servernbt
|
||||
if (reServerNbt == null) { //sollte der server-nbt-tag noch nciht existieren, wird er neu erstellt
|
||||
REServerMod.LOGGER.error("ServerNbt ist null in getFromNbt!"); //eigentlich sollte es nicht auftreten...
|
||||
reServerNbt = new NbtCompound();
|
||||
}
|
||||
return reServerNbt;
|
||||
}
|
||||
|
||||
public void readFile() { //public version, den servernbt von der Datei einzulesen
|
||||
readFromFile();
|
||||
}
|
||||
|
||||
public void saveFile() { //moeglichkeit, die datei force-abzuspeichern
|
||||
writeToFile();
|
||||
}
|
||||
|
||||
public void writeFilePath(File file) { //setzt den Pfad fuer den Server-Nbt-Tag wird vom server dank mixin automatisch gesetzt
|
||||
reServerFile = new File(file, "REServerMod" + ".dat");
|
||||
}
|
||||
|
||||
public void resetData() { //resets the data of this class
|
||||
reServerFile = null;
|
||||
reServerNbt = new NbtCompound();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package modchest.util;
|
||||
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class denkMalBlockUtil extends dataSaverIO{
|
||||
|
||||
public denkMalBlockUtil() {}
|
||||
|
||||
public void addBlock(int[] pos, int[] range) { //fuegt bloecke der Liste an abbauverhindernden Bloecke hinzu
|
||||
NbtCompound tempNbt = new NbtCompound(); //Nbt in dem die Lockdaten gespeichert werden
|
||||
tempNbt.putIntArray("position", pos);
|
||||
tempNbt.putIntArray("range", range);
|
||||
NbtCompound nbt = returnloadedNbt(); //holt sich den denkmalblock nbt
|
||||
nbt.put(Arrays.toString(pos), tempNbt); //speichert die daten des neuen Blocks ab
|
||||
saveInNbt(nbt); //speichert den editierten denkmalblock-nbt ab
|
||||
}
|
||||
|
||||
public void removeBlock(int[] posString) { //loescht bloecke aus Liste an abbauverhindernden Bloecken
|
||||
NbtCompound nbt = returnloadedNbt(); //holt sich den denkmalblock nbt
|
||||
nbt.remove(Arrays.toString(posString)); //entfernt diesen block
|
||||
saveInNbt(nbt); //speichert den editierten denkmalblock-nbt ab
|
||||
}
|
||||
|
||||
private NbtCompound returnloadedNbt() { //gibt den denkmalblock nbt zurueck
|
||||
NbtCompound nbt = getFromNbt(); //laedt den gesamten reServerNbt
|
||||
nbt = (NbtCompound) nbt.get("denkmalblock"); //nimmt den denkmalblocknbt und laedt diesen
|
||||
if (nbt == null) { //sollte der nbt noch nicht existieren wird er erstellt
|
||||
nbt = new NbtCompound();
|
||||
}
|
||||
return nbt;
|
||||
}
|
||||
|
||||
private void saveInNbt(NbtCompound nbt) { //speichert den denkmalblock nbt im reServerNbt ab
|
||||
NbtCompound reServerNbt = getFromNbt(); //holt den reServerNbt
|
||||
reServerNbt.put("denkmalblock", nbt); //schreibt den denkmalblock nbt ab
|
||||
writeToNbt(reServerNbt); //schreibt den editierten reServerNbt
|
||||
}
|
||||
}
|
|
@ -25,6 +25,11 @@ public class initializer {
|
|||
}
|
||||
|
||||
public static void networking() { //Identifier unter denen der Server zuhoert werden registriert
|
||||
modNetworkingServer.registerS2CPackets();
|
||||
modNetworkingServer.registerC2SPackets();
|
||||
}
|
||||
|
||||
public static void renderer() {
|
||||
//BlockRenderLayerMap.INSTANCE.putBlock(modBlocks.denk_mal_block, RenderLayer.getTranslucent());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package modchest.util.interfaces;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public interface LevelStorageInterface { //Interface, damit der Server den Pfad holen kann
|
||||
File getFile();
|
||||
}
|
|
@ -1,8 +1,6 @@
|
|||
package modchest.util;
|
||||
package modchest.util.interfaces;
|
||||
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
public interface ServerPlayerEntityInterface {
|
||||
NbtCompound getDataSaver();
|
|
@ -1,8 +1,8 @@
|
|||
package modchest.util;
|
||||
|
||||
import modchest.REServerMod;
|
||||
import modchest.util.interfaces.ServerPlayerEntityInterface;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.nbt.NbtElement;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
{
|
||||
"variants": {
|
||||
"": { "model": "modchest:block/denk_mal_block_aus"}
|
||||
"powered=false": {
|
||||
"model": "modchest:block/denk_mal_block_aus"
|
||||
},
|
||||
"powered=true": {
|
||||
"model": "modchest:block/denk_mal_block_an"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"": {
|
||||
"model": "modchest:block/denk_mal_block_placeholder"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,12 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"credit": "Made with Blockbench",
|
||||
"texture_size": [64, 64],
|
||||
"textures": {
|
||||
"1": "modchest:block/denk_mal_block",
|
||||
"2": "modchest:block/denk_mal_block_kern_an",
|
||||
"3": "modchest:block/denk_mal_block_basis",
|
||||
"particle": "modchest:block/denk_mal_block_kern_an"
|
||||
"particle": "modchest:block/denk_mal_block_kern_aus"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
|
@ -35,12 +37,12 @@
|
|||
"from": [3, 18, 3],
|
||||
"to": [13, 29, 13],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 5, 5.5], "texture": "#missing"},
|
||||
"east": {"uv": [5, 0, 10, 5.5], "texture": "#missing"},
|
||||
"south": {"uv": [0, 5.5, 5, 11], "texture": "#missing"},
|
||||
"west": {"uv": [5, 5.5, 10, 11], "texture": "#missing"},
|
||||
"up": {"uv": [15, 5, 10, 0], "texture": "#missing"},
|
||||
"down": {"uv": [15, 5, 10, 10], "texture": "#missing"}
|
||||
"north": {"uv": [0, 0, 5, 5.5], "texture": "#2"},
|
||||
"east": {"uv": [5, 0, 10, 5.5], "texture": "#2"},
|
||||
"south": {"uv": [0, 5.5, 5, 11], "texture": "#2"},
|
||||
"west": {"uv": [5, 5.5, 10, 11], "texture": "#2"},
|
||||
"up": {"uv": [15, 5, 10, 0], "texture": "#2"},
|
||||
"down": {"uv": [15, 5, 10, 10], "texture": "#2"}
|
||||
}
|
||||
}
|
||||
],
|
||||
|
|
|
@ -1,324 +1,89 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"credit": "Made with Blockbench",
|
||||
"texture_size": [
|
||||
64,
|
||||
64
|
||||
],
|
||||
"textures": {
|
||||
"1": "modchest:block/denk_mal_block",
|
||||
"2": "modchest:block/denk_mal_block_kern_aus",
|
||||
"3": "modchest:block/denk_mal_block_basis",
|
||||
"particles": "modchest:block/denk_mal_block_basis"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"to": [
|
||||
16,
|
||||
16,
|
||||
16
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
4,
|
||||
4
|
||||
],
|
||||
"texture": "#3"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
4,
|
||||
4,
|
||||
8
|
||||
],
|
||||
"texture": "#3"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
4,
|
||||
0,
|
||||
8,
|
||||
4
|
||||
],
|
||||
"texture": "#3"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
4,
|
||||
4,
|
||||
8,
|
||||
8
|
||||
],
|
||||
"texture": "#3"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
4,
|
||||
12,
|
||||
0,
|
||||
8
|
||||
],
|
||||
"texture": "#3"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
12,
|
||||
0,
|
||||
8,
|
||||
4
|
||||
],
|
||||
"texture": "#3"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
0,
|
||||
16,
|
||||
0
|
||||
],
|
||||
"to": [
|
||||
16,
|
||||
32,
|
||||
16
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
4,
|
||||
4
|
||||
],
|
||||
"texture": "#1"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
4,
|
||||
4,
|
||||
8
|
||||
],
|
||||
"texture": "#1"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
4,
|
||||
0,
|
||||
8,
|
||||
4
|
||||
],
|
||||
"texture": "#1"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
4,
|
||||
4,
|
||||
8,
|
||||
8
|
||||
],
|
||||
"texture": "#1"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
4,
|
||||
12,
|
||||
0,
|
||||
8
|
||||
],
|
||||
"texture": "#1"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
12,
|
||||
0,
|
||||
8,
|
||||
4
|
||||
],
|
||||
"texture": "#1"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
3,
|
||||
18,
|
||||
3
|
||||
],
|
||||
"to": [
|
||||
13,
|
||||
29,
|
||||
13
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
5,
|
||||
5.5
|
||||
],
|
||||
"texture": "#2"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
5,
|
||||
0,
|
||||
10,
|
||||
5.5
|
||||
],
|
||||
"texture": "#2"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
5.5,
|
||||
5,
|
||||
11
|
||||
],
|
||||
"texture": "#2"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
5,
|
||||
5.5,
|
||||
10,
|
||||
11
|
||||
],
|
||||
"texture": "#2"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
15,
|
||||
5,
|
||||
10,
|
||||
0
|
||||
],
|
||||
"texture": "#2"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
15,
|
||||
5,
|
||||
10,
|
||||
10
|
||||
],
|
||||
"texture": "#2"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"display": {
|
||||
"thirdperson_righthand": {
|
||||
"scale": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.5
|
||||
]
|
||||
},
|
||||
"thirdperson_lefthand": {
|
||||
"scale": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.5
|
||||
]
|
||||
},
|
||||
"firstperson_righthand": {
|
||||
"rotation": [
|
||||
1,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"translation": [
|
||||
2.5,
|
||||
-1.5,
|
||||
0
|
||||
],
|
||||
"scale": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.5
|
||||
]
|
||||
},
|
||||
"firstperson_lefthand": {
|
||||
"translation": [
|
||||
2.5,
|
||||
-1.5,
|
||||
0
|
||||
],
|
||||
"scale": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.5
|
||||
]
|
||||
},
|
||||
"ground": {
|
||||
"scale": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.5
|
||||
]
|
||||
},
|
||||
"gui": {
|
||||
"translation": [
|
||||
0,
|
||||
-3.25,
|
||||
0
|
||||
],
|
||||
"scale": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.5
|
||||
]
|
||||
},
|
||||
"head": {
|
||||
"translation": [
|
||||
0,
|
||||
11.5,
|
||||
0
|
||||
],
|
||||
"scale": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.5
|
||||
]
|
||||
},
|
||||
"fixed": {
|
||||
"translation": [
|
||||
0,
|
||||
-1.75,
|
||||
0
|
||||
],
|
||||
"scale": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.5
|
||||
]
|
||||
}
|
||||
},
|
||||
"groups": [
|
||||
{
|
||||
"name": "VoxelShapes",
|
||||
"origin": [
|
||||
8,
|
||||
8,
|
||||
8
|
||||
],
|
||||
"color": 0,
|
||||
"children": [
|
||||
0,
|
||||
1,
|
||||
2
|
||||
]
|
||||
}
|
||||
]
|
||||
"credit": "Made with Blockbench",
|
||||
"texture_size": [64, 64],
|
||||
"textures": {
|
||||
"1": "modchest:block/denk_mal_block",
|
||||
"2": "modchest:block/denk_mal_block_kern_aus",
|
||||
"3": "modchest:block/denk_mal_block_basis",
|
||||
"particle": "modchest:block/denk_mal_block_kern_aus"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [0, 0, 0],
|
||||
"to": [16, 16, 16],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 4, 4], "texture": "#3"},
|
||||
"east": {"uv": [0, 4, 4, 8], "texture": "#3"},
|
||||
"south": {"uv": [4, 0, 8, 4], "texture": "#3"},
|
||||
"west": {"uv": [4, 4, 8, 8], "texture": "#3"},
|
||||
"up": {"uv": [4, 12, 0, 8], "texture": "#3"},
|
||||
"down": {"uv": [12, 0, 8, 4], "texture": "#3"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [0, 16, 0],
|
||||
"to": [16, 32, 16],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 4, 4], "texture": "#1"},
|
||||
"east": {"uv": [0, 4, 4, 8], "texture": "#1"},
|
||||
"south": {"uv": [4, 0, 8, 4], "texture": "#1"},
|
||||
"west": {"uv": [4, 4, 8, 8], "texture": "#1"},
|
||||
"up": {"uv": [4, 12, 0, 8], "texture": "#1"},
|
||||
"down": {"uv": [12, 0, 8, 4], "texture": "#1"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [3, 18, 3],
|
||||
"to": [13, 29, 13],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 5, 5.5], "texture": "#2"},
|
||||
"east": {"uv": [5, 0, 10, 5.5], "texture": "#2"},
|
||||
"south": {"uv": [0, 5.5, 5, 11], "texture": "#2"},
|
||||
"west": {"uv": [5, 5.5, 10, 11], "texture": "#2"},
|
||||
"up": {"uv": [15, 5, 10, 0], "texture": "#2"},
|
||||
"down": {"uv": [15, 5, 10, 10], "texture": "#2"}
|
||||
}
|
||||
}
|
||||
],
|
||||
"display": {
|
||||
"thirdperson_righthand": {
|
||||
"scale": [0.5, 0.5, 0.5]
|
||||
},
|
||||
"thirdperson_lefthand": {
|
||||
"scale": [0.5, 0.5, 0.5]
|
||||
},
|
||||
"firstperson_righthand": {
|
||||
"rotation": [1, 0, 0],
|
||||
"translation": [2.5, -1.5, 0],
|
||||
"scale": [0.5, 0.5, 0.5]
|
||||
},
|
||||
"firstperson_lefthand": {
|
||||
"translation": [2.5, -1.5, 0],
|
||||
"scale": [0.5, 0.5, 0.5]
|
||||
},
|
||||
"ground": {
|
||||
"scale": [0.5, 0.5, 0.5]
|
||||
},
|
||||
"gui": {
|
||||
"translation": [0, -3.25, 0],
|
||||
"scale": [0.5, 0.5, 0.5]
|
||||
},
|
||||
"head": {
|
||||
"translation": [0, 11.5, 0],
|
||||
"scale": [0.5, 0.5, 0.5]
|
||||
},
|
||||
"fixed": {
|
||||
"translation": [0, -1.75, 0],
|
||||
"scale": [0.5, 0.5, 0.5]
|
||||
}
|
||||
},
|
||||
"groups": [
|
||||
{
|
||||
"name": "VoxelShapes",
|
||||
"origin": [8, 8, 8],
|
||||
"color": 0,
|
||||
"children": [0, 1, 2]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"particle": "modchest:block/denk_mal_block"
|
||||
}
|
||||
}
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"parent": "modchest:block/denk_mal_block"
|
||||
"parent": "modchest:block/denk_mal_block_aus"
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
@ -3,8 +3,10 @@
|
|||
"package": "modchest.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"ServerPlayerEntityMixin",
|
||||
"bedBlock"
|
||||
"bedBlockMixin",
|
||||
"LevelStorageMixin",
|
||||
"MinecraftServerMixin",
|
||||
"ServerPlayerEntityMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
Loading…
Reference in New Issue