Add a dedicated builder dimension
This commit is contained in:
parent
2b09531523
commit
5755389cd0
20 changed files with 358 additions and 302 deletions
|
@ -53,7 +53,7 @@ minecraft {
|
|||
// When true, this property will add the folder name of all declared run configurations to generated IDE run configurations.
|
||||
// The folder name can be set on a run configuration using the "folderName" property.
|
||||
// By default, the folder name of a run configuration is the name of the Gradle project containing it.
|
||||
// generateRunFolders = true
|
||||
generateRunFolders = true
|
||||
|
||||
// This property enables access transformers for use in development.
|
||||
// They will be applied to the Minecraft artifact.
|
||||
|
@ -96,7 +96,7 @@ minecraft {
|
|||
|
||||
server {
|
||||
property 'forge.enabledGameTestNamespaces', mod_id
|
||||
args '--nogui'
|
||||
|
||||
}
|
||||
|
||||
// This run config launches GameTestServer and runs all registered gametests, then exits.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
org.gradle.jvmargs=-Xmx3G
|
||||
org.gradle.daemon=false
|
||||
|
||||
libzontreck=1201.11.021624.1537
|
||||
libzontreck=1201.11.021824.0409
|
||||
|
||||
## Environment Properties
|
||||
|
||||
|
@ -48,7 +48,7 @@ mod_name=Thresholds
|
|||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||
mod_license=GPLv3
|
||||
# The mod version. See https://semver.org/
|
||||
mod_version=1201.4.021724.1536
|
||||
mod_version=1201.4.021824.0426
|
||||
# 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
|
||||
|
|
148
run/options.txt
148
run/options.txt
|
@ -1,148 +0,0 @@
|
|||
version:3465
|
||||
autoJump:false
|
||||
operatorItemsTab:false
|
||||
autoSuggestions:true
|
||||
chatColors:true
|
||||
chatLinks:true
|
||||
chatLinksPrompt:true
|
||||
enableVsync:true
|
||||
entityShadows:true
|
||||
forceUnicodeFont:false
|
||||
discrete_mouse_scroll:false
|
||||
invertYMouse:false
|
||||
realmsNotifications:true
|
||||
reducedDebugInfo:false
|
||||
showSubtitles:false
|
||||
directionalAudio:false
|
||||
touchscreen:false
|
||||
fullscreen:false
|
||||
bobView:true
|
||||
toggleCrouch:false
|
||||
toggleSprint:false
|
||||
darkMojangStudiosBackground:false
|
||||
hideLightningFlashes:false
|
||||
mouseSensitivity:0.5
|
||||
fov:0.0
|
||||
screenEffectScale:1.0
|
||||
fovEffectScale:1.0
|
||||
darknessEffectScale:1.0
|
||||
glintSpeed:0.5
|
||||
glintStrength:0.75
|
||||
damageTiltStrength:1.0
|
||||
highContrast:false
|
||||
gamma:0.5
|
||||
renderDistance:12
|
||||
simulationDistance:12
|
||||
entityDistanceScaling:1.0
|
||||
guiScale:2
|
||||
particles:0
|
||||
maxFps:120
|
||||
graphicsMode:1
|
||||
ao:true
|
||||
prioritizeChunkUpdates:0
|
||||
biomeBlendRadius:2
|
||||
renderClouds:"true"
|
||||
resourcePacks:[]
|
||||
incompatibleResourcePacks:[]
|
||||
lastServer:
|
||||
lang:en_us
|
||||
soundDevice:""
|
||||
chatVisibility:0
|
||||
chatOpacity:1.0
|
||||
chatLineSpacing:0.0
|
||||
textBackgroundOpacity:0.5
|
||||
backgroundForChatOnly:true
|
||||
hideServerAddress:false
|
||||
advancedItemTooltips:true
|
||||
pauseOnLostFocus:true
|
||||
overrideWidth:0
|
||||
overrideHeight:0
|
||||
chatHeightFocused:1.0
|
||||
chatDelay:0.0
|
||||
chatHeightUnfocused:0.4375
|
||||
chatScale:1.0
|
||||
chatWidth:1.0
|
||||
notificationDisplayTime:1.0
|
||||
mipmapLevels:4
|
||||
useNativeTransport:true
|
||||
mainHand:"right"
|
||||
attackIndicator:1
|
||||
narrator:0
|
||||
tutorialStep:none
|
||||
mouseWheelSensitivity:1.0
|
||||
rawMouseInput:true
|
||||
glDebugVerbosity:1
|
||||
skipMultiplayerWarning:false
|
||||
skipRealms32bitWarning:false
|
||||
hideMatchedNames:true
|
||||
joinedFirstServer:false
|
||||
hideBundleTutorial:false
|
||||
syncChunkWrites:false
|
||||
showAutosaveIndicator:true
|
||||
allowServerListing:true
|
||||
onlyShowSecureChat:false
|
||||
panoramaScrollSpeed:1.0
|
||||
telemetryOptInExtra:false
|
||||
onboardAccessibility:false
|
||||
key_key.attack:key.mouse.left
|
||||
key_key.use:key.mouse.right
|
||||
key_key.forward:key.keyboard.w
|
||||
key_key.left:key.keyboard.a
|
||||
key_key.back:key.keyboard.s
|
||||
key_key.right:key.keyboard.d
|
||||
key_key.jump:key.keyboard.space
|
||||
key_key.sneak:key.keyboard.left.shift
|
||||
key_key.sprint:key.keyboard.left.control
|
||||
key_key.drop:key.keyboard.q
|
||||
key_key.inventory:key.keyboard.e
|
||||
key_key.chat:key.keyboard.t
|
||||
key_key.playerlist:key.keyboard.tab
|
||||
key_key.pickItem:key.mouse.middle
|
||||
key_key.command:key.keyboard.slash
|
||||
key_key.socialInteractions:key.keyboard.p
|
||||
key_key.screenshot:key.keyboard.f2
|
||||
key_key.togglePerspective:key.keyboard.f5
|
||||
key_key.smoothCamera:key.keyboard.unknown
|
||||
key_key.fullscreen:key.keyboard.f11
|
||||
key_key.spectatorOutlines:key.keyboard.unknown
|
||||
key_key.swapOffhand:key.keyboard.f
|
||||
key_key.saveToolbarActivator:key.keyboard.c
|
||||
key_key.loadToolbarActivator:key.keyboard.x
|
||||
key_key.advancements:key.keyboard.l
|
||||
key_key.hotbar.1:key.keyboard.1
|
||||
key_key.hotbar.2:key.keyboard.2
|
||||
key_key.hotbar.3:key.keyboard.3
|
||||
key_key.hotbar.4:key.keyboard.4
|
||||
key_key.hotbar.5:key.keyboard.5
|
||||
key_key.hotbar.6:key.keyboard.6
|
||||
key_key.hotbar.7:key.keyboard.7
|
||||
key_key.hotbar.8:key.keyboard.8
|
||||
key_key.hotbar.9:key.keyboard.9
|
||||
key_key.mekanism.mode:key.keyboard.n
|
||||
key_key.mekanism.head_mode:key.keyboard.v
|
||||
key_key.mekanism.chest_mode:key.keyboard.g
|
||||
key_key.mekanism.legs_mode:key.keyboard.j
|
||||
key_key.mekanism.feet_mode:key.keyboard.b
|
||||
key_key.mekanism.details:key.keyboard.left.shift
|
||||
key_key.mekanism.description:key.keyboard.n:SHIFT
|
||||
key_key.mekanism.module_tweaker:key.keyboard.backslash
|
||||
key_key.mekanism.key_boost:key.keyboard.left.control
|
||||
key_key.mekanism.key_hud:key.keyboard.h
|
||||
key_key.otemod.open_vault:key.keyboard.v
|
||||
soundCategory_master:1.0
|
||||
soundCategory_music:0.0
|
||||
soundCategory_record:1.0
|
||||
soundCategory_weather:1.0
|
||||
soundCategory_block:1.0
|
||||
soundCategory_hostile:1.0
|
||||
soundCategory_neutral:1.0
|
||||
soundCategory_player:1.0
|
||||
soundCategory_ambient:1.0
|
||||
soundCategory_voice:1.0
|
||||
modelPart_cape:true
|
||||
modelPart_jacket:true
|
||||
modelPart_left_sleeve:true
|
||||
modelPart_right_sleeve:true
|
||||
modelPart_left_pants_leg:true
|
||||
modelPart_right_pants_leg:true
|
||||
modelPart_hat:true
|
|
@ -20,6 +20,7 @@ import dev.zontreck.otemod.blocks.DeprecatedModBlocks;
|
|||
import dev.zontreck.otemod.effects.ModEffects;
|
||||
import dev.zontreck.otemod.enchantments.FlightEnchantment;
|
||||
import dev.zontreck.otemod.enchantments.NightVisionEnchantment;
|
||||
import dev.zontreck.otemod.events.EventHandler;
|
||||
import dev.zontreck.otemod.implementation.CreativeModeTabs;
|
||||
import dev.zontreck.otemod.implementation.InventoryBackup;
|
||||
import dev.zontreck.otemod.implementation.Messages;
|
||||
|
@ -132,6 +133,8 @@ public class OTEMod
|
|||
ModMenuTypes.CONTAINERS.register(bus);
|
||||
MinecraftForge.EVENT_BUS.register(FlightEnchantment.class);
|
||||
MinecraftForge.EVENT_BUS.register(NightVisionEnchantment.class);
|
||||
MinecraftForge.EVENT_BUS.register(new EventHandler());
|
||||
|
||||
|
||||
ModBlocks.register(bus);
|
||||
DeprecatedModBlocks.register(bus);
|
||||
|
@ -153,24 +156,6 @@ public class OTEMod
|
|||
ModMessages.register();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onGameModeChanged(PlayerEvent.PlayerChangeGameModeEvent event)
|
||||
{
|
||||
ServerPlayer player = (ServerPlayer) event.getEntity();
|
||||
|
||||
InventoryBackup backup = new InventoryBackup(player, event.getCurrentGameMode());
|
||||
InventoryBackup restore = new InventoryBackup(player, event.getNewGameMode());
|
||||
|
||||
restore.restore();
|
||||
backup.save();
|
||||
|
||||
if(event.getNewGameMode() == GameType.CREATIVE)
|
||||
{
|
||||
player.getInventory().clearContent();
|
||||
return;
|
||||
}
|
||||
restore.apply();
|
||||
}
|
||||
|
||||
public static void checkFirstJoin(ServerPlayer p){
|
||||
try {
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.commands.dims.BuildCommand;
|
||||
import dev.zontreck.otemod.commands.items.ShareItemInChatCommand;
|
||||
import dev.zontreck.otemod.commands.profilecmds.ChatColorCommand;
|
||||
import dev.zontreck.otemod.commands.profilecmds.NameColorCommand;
|
||||
|
@ -106,5 +107,7 @@ public class CommandRegistry {
|
|||
|
||||
ShareItemInChatCommand.register(ev.getDispatcher());
|
||||
StarterCommand.register(ev.getDispatcher());
|
||||
|
||||
BuildCommand.register(ev.getDispatcher());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package dev.zontreck.otemod.commands.dims;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.libzontreck.vectors.WorldPosition;
|
||||
import dev.zontreck.otemod.implementation.Messages;
|
||||
import dev.zontreck.otemod.registry.ModDimensions;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
|
||||
public class BuildCommand
|
||||
{
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("builder").executes(c->run(c.getSource())));
|
||||
}
|
||||
|
||||
public static int run(CommandSourceStack stack)
|
||||
{
|
||||
if(stack.isPlayer())
|
||||
{
|
||||
return 1;
|
||||
}else {
|
||||
stack.sendFailure(ChatHelpers.macro(Messages.CONSOLE_ERROR));
|
||||
|
||||
WorldPosition pos = new WorldPosition(new Vector3(0, -55, 0), ModDimensions.BUILDER_DIM());
|
||||
|
||||
stack.getPlayer().teleportTo(pos.getActualDimension(), pos.Position.x, pos.Position.y, pos.Position.z, 0, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,10 @@
|
|||
package dev.zontreck.otemod.commands.vaults;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import dev.zontreck.otemod.implementation.Messages;
|
||||
import dev.zontreck.otemod.implementation.PlayerFirstJoinTag;
|
||||
import dev.zontreck.otemod.implementation.vault.NoMoreVaultException;
|
||||
|
@ -20,8 +18,6 @@ import net.minecraft.server.level.ServerPlayer;
|
|||
import net.minecraft.world.SimpleMenuProvider;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
public class StarterCommand
|
||||
{
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
|
@ -78,7 +74,7 @@ public class StarterCommand
|
|||
|
||||
return 0;
|
||||
}
|
||||
ctx.sendFailure(ChatHelpers.macro(Messages.STARTER_FAILURE_CONSOLE));
|
||||
ctx.sendFailure(ChatHelpers.macro(Messages.CONSOLE_ERROR));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
7
src/main/java/dev/zontreck/otemod/data/README.md
Normal file
7
src/main/java/dev/zontreck/otemod/data/README.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
Datagen
|
||||
======
|
||||
____________
|
||||
|
||||
This is the datagen system for Thresholds.
|
||||
|
||||
Please exercise caution when updating this, and test everything.
|
|
@ -7,16 +7,21 @@ import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
|||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.util.ItemUtils;
|
||||
import dev.zontreck.libzontreck.util.heads.HeadUtilities;
|
||||
import dev.zontreck.libzontreck.vectors.WorldPosition;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import dev.zontreck.otemod.enchantments.MobEggEnchantment;
|
||||
import dev.zontreck.otemod.enchantments.ModEnchantments;
|
||||
import dev.zontreck.otemod.implementation.DeathMessages;
|
||||
import dev.zontreck.otemod.implementation.InventoryBackup;
|
||||
import dev.zontreck.otemod.implementation.Messages;
|
||||
import dev.zontreck.otemod.items.tags.ItemStatType;
|
||||
import dev.zontreck.otemod.registry.ModDimensions;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
|
@ -37,12 +42,11 @@ import java.time.Instant;
|
|||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
|
||||
@Mod.EventBusSubscriber(modid=OTEMod.MOD_ID)
|
||||
public class EventHandler {
|
||||
|
||||
|
||||
@SubscribeEvent (priority = EventPriority.HIGHEST)
|
||||
public static void playerDied(LivingDeathEvent event)
|
||||
public void playerDied(LivingDeathEvent event)
|
||||
{
|
||||
if(!(event.getEntity() instanceof Player))return;
|
||||
|
||||
|
@ -146,5 +150,76 @@ public class EventHandler {
|
|||
|
||||
}
|
||||
|
||||
|
||||
private static final ResourceLocation THRESHOLDS_BIMENSION = new ResourceLocation(OTEMod.MOD_ID, "threshold");
|
||||
|
||||
@SubscribeEvent
|
||||
public void onChangeDimension(PlayerEvent.PlayerChangedDimensionEvent ev)
|
||||
{
|
||||
if(ev.getEntity().level().isClientSide) return;
|
||||
|
||||
ServerPlayer player = (ServerPlayer) ev.getEntity();
|
||||
|
||||
if(ev.getTo().location().equals(ModDimensions.BUILDER))
|
||||
{
|
||||
// Store the player's inventory
|
||||
changedGameMode(player, InventoryBackup.GameMode.fromGameType(player.gameMode.getGameModeForPlayer()), InventoryBackup.GameMode.Builder);
|
||||
|
||||
|
||||
player.setGameMode(GameType.CREATIVE);
|
||||
}
|
||||
|
||||
if(ev.getFrom().location().equals(ModDimensions.BUILDER))
|
||||
{
|
||||
// Restore the player's inventory
|
||||
InventoryBackup bkp = new InventoryBackup(player, InventoryBackup.GameMode.Builder);
|
||||
bkp.restore();
|
||||
|
||||
player.setGameMode(bkp.getFormerGameMode().toMinecraft());
|
||||
|
||||
//changedGameMode(player, InventoryBackup.GameMode.Builder, bkp.getFormerGameMode());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void onGameModeChanged(PlayerEvent.PlayerChangeGameModeEvent event)
|
||||
{
|
||||
ServerPlayer player = (ServerPlayer) event.getEntity();
|
||||
|
||||
InventoryBackup.GameMode from = InventoryBackup.GameMode.fromGameType(event.getCurrentGameMode());
|
||||
InventoryBackup.GameMode to = InventoryBackup.GameMode.fromGameType(event.getNewGameMode());
|
||||
|
||||
changedGameMode(player, from, to);
|
||||
}
|
||||
|
||||
private void changedGameMode(ServerPlayer player, InventoryBackup.GameMode from, InventoryBackup.GameMode to) {
|
||||
|
||||
InventoryBackup backup = new InventoryBackup(player, from);
|
||||
InventoryBackup restore = new InventoryBackup(player, to);
|
||||
String dim = WorldPosition.getDim(player.serverLevel());
|
||||
|
||||
if(dim.equalsIgnoreCase(ModDimensions.BUILDER_DIM()))
|
||||
{
|
||||
if(to.equals(InventoryBackup.GameMode.Creative))
|
||||
return; // Don't do a double backup
|
||||
}
|
||||
restore.setFormerGameMode(from);
|
||||
|
||||
restore.restore();
|
||||
backup.save();
|
||||
|
||||
if(to.equals(InventoryBackup.GameMode.Creative))
|
||||
{
|
||||
player.getInventory().clearContent();
|
||||
} else if(to.equals(InventoryBackup.GameMode.Builder))
|
||||
{
|
||||
player.getInventory().clearContent();
|
||||
}
|
||||
restore.apply();
|
||||
restore.save(); // Save the former gamemode for possible restore!
|
||||
|
||||
ChatHelpers.broadcastTo(player, ChatHelpers.macro(Messages.OTE_PREFIX + " !Dark_Green!Your inventory has been saved for [0], and your [1] inventory has been restored", from.getName(), to.getName()), player.server);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import net.minecraftforge.registries.ForgeRegistries;
|
|||
|
||||
@EventBusSubscriber(modid=OTEMod.MOD_ID, bus=Mod.EventBusSubscriber.Bus.FORGE)
|
||||
public class LoreHandlers {
|
||||
/*
|
||||
|
||||
@SubscribeEvent
|
||||
public void onBlockMined(BlockEvent.BreakEvent ev)
|
||||
{
|
||||
|
@ -37,16 +37,19 @@ public class LoreHandlers {
|
|||
ItemStack itemUsed = sp.getItemInHand(InteractionHand.MAIN_HAND);
|
||||
ResourceLocation loc = ForgeRegistries.ITEMS.getKey(itemUsed.getItem());
|
||||
String itemModName = ChatHelpers.macroize("[0]:[1]", loc.getNamespace(), loc.getPath());
|
||||
if(itemModName.contains("pickaxe"))
|
||||
|
||||
String sName = itemModName + "::" + itemUsed.getDisplayName();
|
||||
sName=sName.toLowerCase();
|
||||
if(sName.contains("pickaxe"))
|
||||
{
|
||||
updateItem(itemUsed, ItemStatType.PICK);
|
||||
}else if(itemModName.contains("shovel"))
|
||||
}else if(sName.contains("shovel"))
|
||||
{
|
||||
updateItem(itemUsed, ItemStatType.SHOVEL);
|
||||
} else if(itemModName.contains("axe"))
|
||||
} else if(sName.contains("axe"))
|
||||
{
|
||||
updateItem(itemUsed, ItemStatType.AXE);
|
||||
} else if(itemModName.contains("pickadze"))
|
||||
} else if(sName.contains("pickadze"))
|
||||
{
|
||||
updateItem(itemUsed, ItemStatType.PICK);
|
||||
}
|
||||
|
@ -66,14 +69,16 @@ public class LoreHandlers {
|
|||
ResourceLocation loc = ForgeRegistries.ITEMS.getKey(itemUsed.getItem());
|
||||
String itemModName = ChatHelpers.macroize("[0]:[1]", loc.getNamespace(), loc.getPath());
|
||||
|
||||
if(itemModName.contains("hoe"))
|
||||
String sName = itemModName + "::" + itemUsed.getDisplayName();
|
||||
sName=sName.toLowerCase();
|
||||
if(sName.contains("hoe"))
|
||||
{
|
||||
if(bs.is(Blocks.DIRT) || bs.is(Blocks.GRASS_BLOCK))
|
||||
{
|
||||
OTEMod.LOGGER.info("DIRT!");
|
||||
updateItem(itemUsed, ItemStatType.HOE);
|
||||
}
|
||||
} else if(itemModName.contains("shovel"))
|
||||
} else if(sName.contains("shovel"))
|
||||
{
|
||||
if(bs.is(Blocks.GRASS_BLOCK))
|
||||
{
|
||||
|
@ -101,7 +106,10 @@ public class LoreHandlers {
|
|||
String itemModName = ChatHelpers.macroize("[0]:[1]", loc.getNamespace(), loc.getPath());
|
||||
ResourceLocation locEnt = ForgeRegistries.ENTITY_TYPES.getKey(ev.getTarget().getType());
|
||||
String entityModName = ChatHelpers.macroize("[0]:[1]", locEnt.getNamespace(), locEnt.getPath());
|
||||
if(itemModName.contains("shears"))
|
||||
|
||||
String sName = itemModName + "::" + itemUsed.getDisplayName();
|
||||
sName=sName.toLowerCase();
|
||||
if(sName.contains("shears"))
|
||||
{
|
||||
if(entityModName.contains("sheep"))
|
||||
{
|
||||
|
@ -133,7 +141,9 @@ public class LoreHandlers {
|
|||
ItemStack weaponUsed = sp.getItemInHand(InteractionHand.MAIN_HAND);
|
||||
ResourceLocation loc = ForgeRegistries.ITEMS.getKey(weaponUsed.getItem());
|
||||
String itemModName = ChatHelpers.macroize("[0]:[1]", loc.getNamespace(), loc.getPath());
|
||||
if(itemModName.contains("sword"))
|
||||
String sName = itemModName + "::" + weaponUsed.getDisplayName();
|
||||
sName=sName.toLowerCase();
|
||||
if(sName.contains("sword"))
|
||||
{
|
||||
updateItem(weaponUsed, ItemStatType.SWORD);
|
||||
|
||||
|
@ -144,33 +154,39 @@ public class LoreHandlers {
|
|||
// Only valid to be used by OTEMod
|
||||
protected static void updateItem(ItemStack weaponUsed, ItemStatType type)
|
||||
{
|
||||
|
||||
// Update the mob kill count
|
||||
CompoundTag props = weaponUsed.getTag();
|
||||
if(props==null)props=new CompoundTag();
|
||||
CompoundTag container = props.getCompound(ItemStatTag.STATS_TAG+"_"+type.name().toLowerCase());
|
||||
LoreContainer contain = new LoreContainer(weaponUsed);
|
||||
|
||||
ItemStatTag isTag;
|
||||
try{
|
||||
isTag = new ItemStatTag(type, container.getInt(ItemStatTag.STATS_TAG+"_"+type.name().toLowerCase()));
|
||||
}catch (Exception e){
|
||||
isTag = new ItemStatTag(type, 0);
|
||||
}
|
||||
isTag.increment();
|
||||
LoreEntry entry;
|
||||
|
||||
if(contain.miscData.loreData.size()==0)
|
||||
try {
|
||||
|
||||
// Update the mob kill count
|
||||
CompoundTag props = weaponUsed.getTag();
|
||||
if(props==null)props=new CompoundTag();
|
||||
CompoundTag container = props.getCompound(ItemStatTag.STATS_TAG+"_"+type.name().toLowerCase());
|
||||
LoreContainer contain = new LoreContainer(weaponUsed);
|
||||
|
||||
ItemStatTag isTag;
|
||||
try{
|
||||
isTag = new ItemStatTag(type, container.getInt(ItemStatTag.STATS_TAG+"_"+type.name().toLowerCase()));
|
||||
}catch (Exception e){
|
||||
isTag = new ItemStatTag(type, 0);
|
||||
}
|
||||
isTag.increment();
|
||||
LoreEntry entry;
|
||||
|
||||
if(contain.miscData.loreData.size()==0)
|
||||
{
|
||||
// Missing entry
|
||||
entry = new LoreEntry.Builder().text(ItemStatistics.makeText(isTag)).build();
|
||||
contain.miscData.loreData.add(entry);
|
||||
}else {
|
||||
entry = contain.miscData.loreData.get(0); // Stat is set at 0
|
||||
entry.text = ItemStatistics.makeText(isTag);
|
||||
}
|
||||
|
||||
// Update item
|
||||
contain.commitLore();
|
||||
}catch(Exception e)
|
||||
{
|
||||
// Missing entry
|
||||
entry = new LoreEntry.Builder().text(ItemStatistics.makeText(isTag)).build();
|
||||
contain.miscData.loreData.add(entry);
|
||||
}else {
|
||||
entry = contain.miscData.loreData.get(0); // Stat is set at 0
|
||||
entry.text = ItemStatistics.makeText(isTag);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Update item
|
||||
contain.commitLore();
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,13 +16,112 @@ import java.util.List;
|
|||
|
||||
public class InventoryBackup extends OTEDatastore
|
||||
{
|
||||
/**
|
||||
* This is to introduce custom, virtual gamemodes. To allow for custom dimensions to have their own inventories.
|
||||
*/
|
||||
public enum GameMode {
|
||||
Adventure("adventure"),
|
||||
Spectator("spectator"),
|
||||
Creative("creative"),
|
||||
Survival("survival"),
|
||||
Thresholds("thresholds"),
|
||||
Builder("builder");
|
||||
|
||||
private final String name;
|
||||
private GameMode(String name)
|
||||
{
|
||||
this.name=name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public static GameMode fromGameType(GameType type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case ADVENTURE:
|
||||
{
|
||||
return Adventure;
|
||||
}
|
||||
case SPECTATOR:
|
||||
{
|
||||
return Spectator;
|
||||
}
|
||||
case CREATIVE:
|
||||
{
|
||||
return Creative;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return Survival;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static GameMode fromNBT(Tag tag)
|
||||
{
|
||||
String str = tag.getAsString();
|
||||
for(GameMode mode : values())
|
||||
{
|
||||
if(mode.getName().equalsIgnoreCase(str))
|
||||
{
|
||||
return mode;
|
||||
}
|
||||
}
|
||||
|
||||
return Survival;
|
||||
}
|
||||
|
||||
public Tag saveToNBT()
|
||||
{
|
||||
return StringTag.valueOf(name);
|
||||
}
|
||||
|
||||
public GameType toMinecraft()
|
||||
{
|
||||
switch(this)
|
||||
{
|
||||
|
||||
case Survival:
|
||||
{
|
||||
return GameType.SURVIVAL;
|
||||
}
|
||||
|
||||
case Creative:
|
||||
{
|
||||
return GameType.CREATIVE;
|
||||
}
|
||||
|
||||
case Adventure:
|
||||
{
|
||||
return GameType.ADVENTURE;
|
||||
}
|
||||
|
||||
case Spectator:
|
||||
{
|
||||
return GameType.SPECTATOR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
default:
|
||||
{
|
||||
return GameType.DEFAULT_MODE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ServerPlayer player;
|
||||
File my_file;
|
||||
|
||||
ListTag list;
|
||||
GameMode formerGameMode;
|
||||
|
||||
public static final Path FILE_TREE_PATH = of("gamemode_inventories");
|
||||
|
||||
public InventoryBackup(ServerPlayer player, GameType mode)
|
||||
public InventoryBackup(ServerPlayer player, GameMode mode)
|
||||
{
|
||||
this.player = player;
|
||||
if(!FILE_TREE_PATH.toFile().exists())
|
||||
|
@ -46,6 +145,11 @@ public class InventoryBackup extends OTEDatastore
|
|||
CompoundTag tag = NbtIo.read(my_file);
|
||||
list = tag.getList("inventory", Tag.TAG_COMPOUND);
|
||||
|
||||
if(tag.contains("gamemode"))
|
||||
{
|
||||
formerGameMode = GameMode.fromNBT(tag.get("gamemode"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
|
@ -60,6 +164,8 @@ public class InventoryBackup extends OTEDatastore
|
|||
list = new ListTag();
|
||||
list = player.getInventory().save(list);
|
||||
tag.put("inventory", list);
|
||||
if(formerGameMode != null)
|
||||
tag.put("gamemode", formerGameMode.saveToNBT());
|
||||
|
||||
NbtIo.write(tag, my_file);
|
||||
|
||||
|
@ -79,5 +185,12 @@ public class InventoryBackup extends OTEDatastore
|
|||
}
|
||||
}
|
||||
|
||||
public void setFormerGameMode(GameMode mode)
|
||||
{
|
||||
formerGameMode=mode;
|
||||
}
|
||||
|
||||
public GameMode getFormerGameMode() {
|
||||
return formerGameMode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ public class Messages {
|
|||
public static final String NICK_UPDATED;
|
||||
public static final String NAME_COLOR_UPDATED;
|
||||
public static final String CHAT_COLOR_UPDATED;
|
||||
public static final String STARTER_FAILURE_CONSOLE;
|
||||
public static final String CONSOLE_ERROR;
|
||||
public static final String STARTER_FAILURE_PERMISSIONS;
|
||||
public static final String STARTER_KIT_GIVEN;
|
||||
|
||||
|
@ -23,7 +23,7 @@ public class Messages {
|
|||
NICK_UPDATED = OTE_PREFIX + "!Dark_Purple! Your nickname has been updated";
|
||||
NAME_COLOR_UPDATED = OTE_PREFIX + "!Dark_Purple!Your name color has been updated";
|
||||
CHAT_COLOR_UPDATED = OTE_PREFIX + "!Dark_Purple!Your chat color has been updated";
|
||||
STARTER_FAILURE_CONSOLE = OTE_PREFIX + "!Dark_Red!This command can only be executed from within the game";
|
||||
CONSOLE_ERROR = OTE_PREFIX + "!Dark_Red!This command can only be executed from within the game, and by a player";
|
||||
STARTER_FAILURE_PERMISSIONS = OTE_PREFIX + "!Dark_Red!This command can only be executed by server operators";
|
||||
STARTER_KIT_GIVEN = OTE_PREFIX + "!Dark_Purple!You have been given a starter kit. Welcome to the server.";
|
||||
FLIGHT_GIVEN = OTE_PREFIX + "!Dark_Green!You start to feel lighter than a feather";
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
package dev.zontreck.otemod.ore;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.world.level.levelgen.placement.BiomeFilter;
|
||||
import net.minecraft.world.level.levelgen.placement.CountPlacement;
|
||||
import net.minecraft.world.level.levelgen.placement.InSquarePlacement;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacementModifier;
|
||||
import net.minecraft.world.level.levelgen.placement.RarityFilter;
|
||||
|
||||
public class ModdedOrePlacement {
|
||||
public static List<PlacementModifier> orePlacement(PlacementModifier p_195347_, PlacementModifier p_195348_) {
|
||||
return List.of(p_195347_, InSquarePlacement.spread(), p_195348_, BiomeFilter.biome());
|
||||
}
|
||||
|
||||
public static List<PlacementModifier> commonOrePlacement(int p_195344_, PlacementModifier p_195345_) {
|
||||
return orePlacement(CountPlacement.of(p_195344_), p_195345_);
|
||||
}
|
||||
|
||||
public static List<PlacementModifier> rareOrePlacement(int p_195350_, PlacementModifier p_195351_) {
|
||||
return orePlacement(RarityFilter.onAverageOnceEvery(p_195350_), p_195351_);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package dev.zontreck.otemod.ore;
|
||||
|
||||
|
||||
public class OreGenerator {
|
||||
/*
|
||||
|
||||
public static final List<ConfiguredFeature<OreConfiguration, OreFeature>> OVERWORLD_ORES = new ArrayList();
|
||||
|
||||
|
||||
public static final List<OreConfiguration.TargetBlockState> OVERWORLD_ETERNIUM_ORE = List.of(OreConfiguration.target(OreFeatures.STONE_ORE_REPLACEABLES, ModBlocks.ETERNIUM_ORE_BLOCK.get().defaultBlockState()), OreConfiguration.target(OreFeatures.DEEPSLATE_ORE_REPLACEABLES, ModBlocks.DEEPSLATE_ETERNIUM_ORE_BLOCK.get().defaultBlockState()));
|
||||
|
||||
public static final List<OreConfiguration.TargetBlockState> OVERWORLD_VAULTSTEEL_ORE = List.of(OreConfiguration.target(OreFeatures.DEEPSLATE_ORE_REPLACEABLES, ModBlocks.VAULT_STEEL_ORE_BLOCK.get().defaultBlockState()));
|
||||
|
||||
public static final List<OreConfiguration.TargetBlockState> NETHER_VAULTSTEEL_ORE = List.of( OreConfiguration.target(OreFeatures.NETHER_ORE_REPLACEABLES, ModBlocks.NETHER_VAULT_STEEL_ORE_BLOCK.get().defaultBlockState()));
|
||||
|
||||
|
||||
public static final Holder<ConfiguredFeature<OreConfiguration, ?>> ETERNIUM_ORE = FeatureUtils.register("eternium_ore_block", Feature.ORE, new OreConfiguration(OVERWORLD_ETERNIUM_ORE, 8));
|
||||
|
||||
public static final Holder<ConfiguredFeature<OreConfiguration, ?>> VAULTSTEEL_ORE = FeatureUtils.register("vault_steel_ore_block", Feature.ORE, new OreConfiguration(OVERWORLD_VAULTSTEEL_ORE, 6));
|
||||
|
||||
public static final Holder<ConfiguredFeature<OreConfiguration, ?>> VAULTSTEEL_ORE_NETHER = FeatureUtils.register("nether_vault_steel_ore_block", Feature.ORE, new OreConfiguration(NETHER_VAULTSTEEL_ORE, 8));
|
||||
|
||||
public static final Holder<PlacedFeature> ETERNIUM_ORE_PLACED = PlacementUtils.register("eternium_ore_placed",
|
||||
ETERNIUM_ORE, ModdedOrePlacement.commonOrePlacement(3, // VeinsPerChunk
|
||||
HeightRangePlacement.triangle(VerticalAnchor.absolute(-20), VerticalAnchor.absolute(20))));
|
||||
|
||||
public static final Holder<PlacedFeature> VAULT_STEEL_ORE_PLACED = PlacementUtils.register("vaultsteel_ore_placed", VAULTSTEEL_ORE, ModdedOrePlacement.rareOrePlacement(4, // Veins per chunk
|
||||
HeightRangePlacement.triangle(VerticalAnchor.absolute(-63), VerticalAnchor.absolute(-50))));
|
||||
|
||||
public static final Holder<PlacedFeature> NETHER_VAULTSTEEL_ORE_PLACED = PlacementUtils.register("nether_vaultsteel_ore_placed", VAULTSTEEL_ORE_NETHER, ModdedOrePlacement.rareOrePlacement(5, // Veins per chunk
|
||||
HeightRangePlacement.triangle(VerticalAnchor.absolute(1), VerticalAnchor.absolute(16))));
|
||||
|
||||
//public static final Holder<PlacedFeature> DEEPSLATE_AION_ORE_PLACED = PlacementUtils.register("deepslate_aion_ore_placed",
|
||||
// DEEPSLATE_AION_ORE, ModdedOrePlacement.commonOrePlacement(3, // VeinsPerChunk
|
||||
// HeightRangePlacement.triangle(VerticalAnchor.aboveBottom(-20), VerticalAnchor.aboveBottom(0))));
|
||||
|
||||
public static void generateOres(final BiomeLoadingEvent ev)
|
||||
{
|
||||
|
||||
List<Holder<PlacedFeature>> base = ev.getGeneration().getFeatures(GenerationStep.Decoration.UNDERGROUND_ORES);
|
||||
|
||||
//ShapedAionResources.LOGGER.info("Register: AION_ORE");
|
||||
base.add(ETERNIUM_ORE_PLACED);
|
||||
base.add(VAULT_STEEL_ORE_PLACED);
|
||||
base.add(NETHER_VAULTSTEEL_ORE_PLACED);
|
||||
//base.add(DEEPSLATE_AION_ORE_PLACED);
|
||||
}*/
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
package dev.zontreck.otemod.recipes;
|
||||
|
||||
public class ModRecipes {
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package dev.zontreck.otemod.registry;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class ModDimensions
|
||||
{
|
||||
public static final ResourceLocation BUILDER = new ResourceLocation(OTEMod.MOD_ID, "builder");
|
||||
public static String BUILDER_DIM()
|
||||
{
|
||||
return BUILDER.getNamespace() + ":" + BUILDER.getPath();
|
||||
}
|
||||
}
|
26
src/main/resources/data/otemod/dimension/builder.json
Normal file
26
src/main/resources/data/otemod/dimension/builder.json
Normal file
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"type": "otemod:builder",
|
||||
"generator": {
|
||||
"type": "minecraft:flat",
|
||||
"settings": {
|
||||
"biome": "minecraft:plains",
|
||||
"lakes": false,
|
||||
"features": false,
|
||||
"layers": [
|
||||
{
|
||||
"block": "minecraft:bedrock",
|
||||
"height": 1
|
||||
},
|
||||
{
|
||||
"block": "minecraft:stone",
|
||||
"height": 2
|
||||
},
|
||||
{
|
||||
"block": "minecraft:grass_block",
|
||||
"height": 3
|
||||
}
|
||||
],
|
||||
"structure_overrides": "minecraft:villages"
|
||||
}
|
||||
}
|
||||
}
|
19
src/main/resources/data/otemod/dimension_type/builder.json
Normal file
19
src/main/resources/data/otemod/dimension_type/builder.json
Normal file
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"ultrawarm": false,
|
||||
"natural": true,
|
||||
"piglin_safe": false,
|
||||
"respawn_anchor_works": false,
|
||||
"bed_works": false,
|
||||
"has_raids": false,
|
||||
"has_skylight": true,
|
||||
"has_ceiling": false,
|
||||
"coordinate_scale": 1,
|
||||
"ambient_light": 1,
|
||||
"logical_height": 384,
|
||||
"effects": "minecraft:the_end",
|
||||
"infiniburn": "#minecraft:infiniburn_overworld",
|
||||
"min_y": -64,
|
||||
"height": 384,
|
||||
"monster_spawn_light_level": 0,
|
||||
"monster_spawn_block_light_limit": 0
|
||||
}
|
|
@ -15,12 +15,6 @@
|
|||
"infiniburn": "#minecraft:infiniburn_overworld",
|
||||
"min_y": -64,
|
||||
"height": 384,
|
||||
"monster_spawn_light_level": {
|
||||
"type": "minecraft:uniform",
|
||||
"value": {
|
||||
"min_inclusive": 0,
|
||||
"max_inclusive": 0
|
||||
}
|
||||
},
|
||||
"monster_spawn_light_level": 0,
|
||||
"monster_spawn_block_light_limit": 0
|
||||
}
|
||||
|
|
|
@ -15,6 +15,6 @@
|
|||
"infiniburn": "#minecraft:infiniburn_overworld",
|
||||
"min_y": -64,
|
||||
"height": 384,
|
||||
"monster_spawn_light_level": 0,
|
||||
"monster_spawn_block_light_limit": 15
|
||||
"monster_spawn_light_level": 4,
|
||||
"monster_spawn_block_light_limit": 4
|
||||
}
|
||||
|
|
Reference in a new issue