Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
Starting support for room upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
robotgryphon committed Mar 24, 2024
1 parent 77917dc commit c841025
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.storage.DimensionDataStorage;
import net.minecraft.world.level.storage.LevelResource;
import net.minecraft.world.level.storage.LevelStorageSource;
import org.jetbrains.annotations.NotNull;

import java.nio.file.Path;

import static dev.compactmods.machines.api.Constants.MOD_ID;

public abstract class CompactDimension {
Expand All @@ -32,6 +35,14 @@ public static ServerLevel forServer(MinecraftServer server) throws MissingDimens
return level;
}

public static Path getDataDirectory(@NotNull MinecraftServer server) {
return DimensionType.getStorageFolder(CompactDimension.LEVEL_KEY, server.getWorldPath(LevelResource.ROOT));
}

public static Path getDataDirectory(@NotNull LevelStorageSource.LevelDirectory levelDir) {
return DimensionType.getStorageFolder(CompactDimension.LEVEL_KEY, levelDir.path());
}

@NotNull
public static DimensionDataStorage getDataStorage(@NotNull LevelStorageSource.LevelDirectory levelDir) {
final var dimPath = DimensionType.getStorageFolder(CompactDimension.LEVEL_KEY, levelDir.path());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package dev.compactmods.machines.api.room.upgrade;

public interface IRoomUpgradeInventory {
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package dev.compactmods.machines.api.room.upgrade;

import com.mojang.serialization.Codec;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;

import static dev.compactmods.machines.api.Constants.MOD_ID;

public interface RoomUpgrade {

ResourceKey<Registry<RoomUpgrade>> REGISTRY_KEY = ResourceKey.createRegistryKey(new ResourceLocation(MOD_ID, "room_upgrades"));
TagKey<Item> ITEM_TAG = TagKey.create(Registries.ITEM, new ResourceLocation(MOD_ID, "room_upgrade"));

Codec<? extends RoomUpgrade> codec();
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package dev.compactmods.machines.api.room.upgrade.components;

public interface AfterUsedUpgradeComponent {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package dev.compactmods.machines.api.room.upgrade.components;

public class ItemDamageUpgradeComponent implements AfterUsedUpgradeComponent {
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package dev.compactmods.machines.api.room.upgrade;
package dev.compactmods.machines.api.room.upgrade.events;

import dev.compactmods.machines.api.room.RoomInstance;
import dev.compactmods.machines.api.room.upgrade.RoomUpgrade;
import net.minecraft.server.level.ServerLevel;

public interface LevelLoadedUpgradeEventListener extends RoomUpgrade {
@FunctionalInterface
public interface LevelLoadedUpgradeEventListener {

/**
* Called when a level is loaded, typically when the server first boots up.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package dev.compactmods.machines.api.room.upgrade;
package dev.compactmods.machines.api.room.upgrade.events;

import dev.compactmods.machines.api.room.RoomInstance;
import dev.compactmods.machines.api.room.upgrade.RoomUpgrade;
import net.minecraft.server.level.ServerLevel;

public interface LevelUnloadedUpgradeEventListener extends RoomUpgrade {
@FunctionalInterface
public interface LevelUnloadedUpgradeEventListener {

/**
* Called when a level is unloaded.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package dev.compactmods.machines.api.room.upgrade.events;

import dev.compactmods.machines.api.room.RoomInstance;
import dev.compactmods.machines.api.room.upgrade.RoomUpgrade;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.item.ItemStack;

@FunctionalInterface
public interface UpgradeAppliedEventListener {

/**
* Called when an upgrade is first applied to a room.
*/
void onAdded(ServerLevel level, RoomInstance room, ItemStack upgradeItem);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package dev.compactmods.machines.api.room.upgrade.events;

import dev.compactmods.machines.api.room.RoomInstance;
import dev.compactmods.machines.api.room.upgrade.RoomUpgrade;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.item.ItemStack;

@FunctionalInterface
public interface UpgradeRemovedEventListener {

/**
* Called when an update is removed from a room.
*/
void onRemoved(ServerLevel level, RoomInstance room, ItemStack upgradeItem);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package dev.compactmods.machines.api.room.upgrade.events;

import dev.compactmods.machines.api.room.RoomInstance;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.item.ItemStack;

@FunctionalInterface
public interface UpgradeTickedEventListener {

void onRemoved(ServerLevel level, RoomInstance room, ItemStack upgradeItem);
}

0 comments on commit c841025

Please sign in to comment.