Revert "Refactor and rename to Thresholds"
This reverts commit cd9d548806
.
This commit is contained in:
parent
cd9d548806
commit
858f359d4b
578 changed files with 215113 additions and 214942 deletions
|
@ -5,7 +5,7 @@ First of all, thank you for considering, or for contributing to any of the follo
|
||||||
```
|
```
|
||||||
LibZontreck
|
LibZontreck
|
||||||
Arias-Essentials
|
Arias-Essentials
|
||||||
Thresholds
|
OTEMod
|
||||||
ClaimsMod
|
ClaimsMod
|
||||||
WatchMyDurability
|
WatchMyDurability
|
||||||
```
|
```
|
||||||
|
@ -20,7 +20,7 @@ Code Contributions
|
||||||
|
|
||||||
Asset contribution
|
Asset contribution
|
||||||
----
|
----
|
||||||
2) Contributions are also accepted in the form of artwork or music, or sound, or block models from blockbench. Just simply follow the above steps to create your working base. Then send it to us in a pull request. No coding knowledge is necessary for adding these resources. Someone else can tackle that if you do not know how to code. An example of this is the Possum animal model in Thresholds. This was contributed by PossumTheWarrior via discord.
|
2) Contributions are also accepted in the form of artwork or music, or sound, or block models from blockbench. Just simply follow the above steps to create your working base. Then send it to us in a pull request. No coding knowledge is necessary for adding these resources. Someone else can tackle that if you do not know how to code. An example of this is the Possum animal model in OTEMod. This was contributed by PossumTheWarrior via discord.
|
||||||
|
|
||||||
Bug reporting or feature requests
|
Bug reporting or feature requests
|
||||||
----
|
----
|
||||||
|
|
|
@ -4,4 +4,4 @@ Liquids
|
||||||
|
|
||||||
|
|
||||||
Super Furnace
|
Super Furnace
|
||||||
* Melts materials into liquids. This is how to obtain the Thresholds liquids.
|
* Melts materials into liquids. This is how to obtain the OTEMod liquids.
|
|
@ -49,7 +49,7 @@ mod_name=Thresholds
|
||||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=GPLv3
|
mod_license=GPLv3
|
||||||
# The mod version. See https://semver.org/
|
# The mod version. See https://semver.org/
|
||||||
mod_version=1.4.011524.2217
|
mod_version=1.4.011524.2056
|
||||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
# 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.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
|
@ -57,4 +57,4 @@ mod_group_id=dev.zontreck
|
||||||
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
|
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
|
||||||
mod_authors=zontreck
|
mod_authors=zontreck
|
||||||
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
|
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
|
||||||
mod_description=Thresholds Mod
|
mod_description=Only The Essentials
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"pack": {
|
"pack": {
|
||||||
"description": {
|
"description": {
|
||||||
"text": "Thresholds Server Resource Pack"
|
"text": "OTEMod Server Resource Pack"
|
||||||
},
|
},
|
||||||
"pack_format": 15
|
"pack_format": 15
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,14 @@
|
||||||
package dev.zontreck.thresholds;
|
package dev.zontreck.otemod;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
|
@ -6,20 +16,24 @@ import dev.zontreck.libzontreck.profiles.Profile;
|
||||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||||
import dev.zontreck.thresholds.effects.ModEffects;
|
import dev.zontreck.otemod.effects.ModEffects;
|
||||||
import dev.zontreck.thresholds.implementation.CreativeModeTabs;
|
import dev.zontreck.otemod.implementation.CreativeModeTabs;
|
||||||
import dev.zontreck.thresholds.implementation.InventoryBackup;
|
import dev.zontreck.otemod.implementation.InventoryBackup;
|
||||||
import dev.zontreck.thresholds.implementation.Messages;
|
import dev.zontreck.otemod.implementation.Messages;
|
||||||
import dev.zontreck.thresholds.implementation.PlayerFirstJoinTag;
|
import dev.zontreck.otemod.implementation.PlayerFirstJoinTag;
|
||||||
import dev.zontreck.thresholds.implementation.compressor.CompressionChamberScreen;
|
import dev.zontreck.otemod.implementation.compressor.CompressionChamberScreen;
|
||||||
import dev.zontreck.thresholds.implementation.vault.*;
|
import dev.zontreck.otemod.implementation.vault.*;
|
||||||
import dev.zontreck.thresholds.integrations.KeyBindings;
|
import dev.zontreck.otemod.integrations.KeyBindings;
|
||||||
import dev.zontreck.thresholds.recipe.ModRecipes;
|
import dev.zontreck.otemod.recipe.ModRecipes;
|
||||||
import net.minecraft.client.gui.screens.MenuScreens;
|
import net.minecraft.client.gui.screens.MenuScreens;
|
||||||
|
import net.minecraft.client.renderer.entity.EntityRenderers;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.server.commands.GiveCommand;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.entity.item.ItemEntity;
|
import net.minecraft.world.entity.item.ItemEntity;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraft.world.level.GameType;
|
import net.minecraft.world.level.GameType;
|
||||||
|
@ -43,31 +57,32 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.blocks.ModBlocks;
|
import dev.zontreck.otemod.blocks.ModBlocks;
|
||||||
import dev.zontreck.thresholds.blocks.entity.ModEntities;
|
import dev.zontreck.otemod.blocks.entity.ModEntities;
|
||||||
import dev.zontreck.thresholds.chat.ChatServerOverride;
|
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||||
import dev.zontreck.thresholds.commands.CommandRegistry;
|
import dev.zontreck.otemod.commands.CommandRegistry;
|
||||||
import dev.zontreck.thresholds.configs.ThresholdsServerConfig;
|
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||||
import dev.zontreck.thresholds.enchantments.ModEnchantments;
|
import dev.zontreck.otemod.enchantments.ModEnchantments;
|
||||||
import dev.zontreck.thresholds.entities.ModEntityTypes;
|
import dev.zontreck.otemod.entities.ModEntityTypes;
|
||||||
import dev.zontreck.thresholds.events.LoreHandlers;
|
import dev.zontreck.otemod.entities.monsters.client.PossumRenderer;
|
||||||
import dev.zontreck.thresholds.implementation.inits.ModMenuTypes;
|
import dev.zontreck.otemod.events.LoreHandlers;
|
||||||
import dev.zontreck.thresholds.implementation.scrubber.ItemScrubberScreen;
|
import dev.zontreck.otemod.implementation.inits.ModMenuTypes;
|
||||||
import dev.zontreck.thresholds.implementation.scrubber.MagicalScrubberScreen;
|
import dev.zontreck.otemod.implementation.scrubber.ItemScrubberScreen;
|
||||||
import dev.zontreck.thresholds.items.ModItems;
|
import dev.zontreck.otemod.implementation.scrubber.MagicalScrubberScreen;
|
||||||
|
import dev.zontreck.otemod.items.ModItems;
|
||||||
//import dev.zontreck.otemod.ore.Modifier.ModifierOfBiomes;
|
//import dev.zontreck.otemod.ore.Modifier.ModifierOfBiomes;
|
||||||
import dev.zontreck.thresholds.networking.ModMessages;
|
import dev.zontreck.otemod.networking.ModMessages;
|
||||||
|
|
||||||
// The value here should match an entry in the META-INF/mods.toml file
|
// The value here should match an entry in the META-INF/mods.toml file
|
||||||
@Mod(ThresholdsMod.MOD_ID)
|
@Mod(OTEMod.MOD_ID)
|
||||||
public class ThresholdsMod
|
public class OTEMod
|
||||||
{
|
{
|
||||||
public static final Vector3 ZERO_VECTOR = new Vector3(0,0,0);
|
public static final Vector3 ZERO_VECTOR = new Vector3(0,0,0);
|
||||||
// Directly reference a slf4j logger
|
// Directly reference a slf4j logger
|
||||||
public static final Logger LOGGER = LogUtils.getLogger();
|
public static final Logger LOGGER = LogUtils.getLogger();
|
||||||
public static final String MOD_ID = "thresholds";
|
public static final String MOD_ID = "otemod";
|
||||||
public static final String MODIFY_BIOMES = "modify_biomes";
|
public static final String MODIFY_BIOMES = "modify_biomes";
|
||||||
public static final ResourceLocation MODIFY_BIOMES_RL = new ResourceLocation(ThresholdsMod.MOD_ID, MODIFY_BIOMES);
|
public static final ResourceLocation MODIFY_BIOMES_RL = new ResourceLocation(OTEMod.MOD_ID, MODIFY_BIOMES);
|
||||||
|
|
||||||
//public static List<TeleportContainer> TeleportRegistry = new ArrayList<>();
|
//public static List<TeleportContainer> TeleportRegistry = new ArrayList<>();
|
||||||
public static MinecraftServer THE_SERVER;
|
public static MinecraftServer THE_SERVER;
|
||||||
|
@ -78,23 +93,23 @@ public class ThresholdsMod
|
||||||
public static boolean DEVELOPER=false;
|
public static boolean DEVELOPER=false;
|
||||||
private static Thread MasterThread;
|
private static Thread MasterThread;
|
||||||
|
|
||||||
public static String ThresholdsPrefix = "";
|
public static String OTEPrefix = "";
|
||||||
public static String ONLY_PLAYER = "";
|
public static String ONLY_PLAYER = "";
|
||||||
public static IEventBus bus;
|
public static IEventBus bus;
|
||||||
|
|
||||||
|
|
||||||
public ThresholdsMod()
|
public OTEMod()
|
||||||
{
|
{
|
||||||
|
|
||||||
ThresholdsMod.ThresholdsPrefix = ChatColor.doColors("!dark_gray![!dark_green!!bold!Thresholds!reset!!dark_gray!]!reset!");
|
OTEMod.OTEPrefix = ChatColor.doColors("!dark_gray![!dark_green!!bold!OTEMod!reset!!dark_gray!]!reset!");
|
||||||
ThresholdsMod.ONLY_PLAYER = ChatColor.doColors("!dark_red!Only a player can execute this command");
|
OTEMod.ONLY_PLAYER = ChatColor.doColors("!dark_red!Only a player can execute this command");
|
||||||
|
|
||||||
bus = FMLJavaModLoadingContext.get().getModEventBus();
|
bus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||||
// Register the setup method for modloading
|
// Register the setup method for modloading
|
||||||
bus.addListener(this::setup);
|
bus.addListener(this::setup);
|
||||||
|
|
||||||
|
|
||||||
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, ThresholdsServerConfig.SPEC, "thresholds-server.toml");
|
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, OTEServerConfig.SPEC, "otemod-rss-server.toml");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,7 +124,7 @@ public class ThresholdsMod
|
||||||
MinecraftForge.EVENT_BUS.register(new ChatServerOverride());
|
MinecraftForge.EVENT_BUS.register(new ChatServerOverride());
|
||||||
MinecraftForge.EVENT_BUS.register(new CommandRegistry());
|
MinecraftForge.EVENT_BUS.register(new CommandRegistry());
|
||||||
MinecraftForge.EVENT_BUS.register(new VaultWatcher());
|
MinecraftForge.EVENT_BUS.register(new VaultWatcher());
|
||||||
MinecraftForge.EVENT_BUS.register(new dev.zontreck.thresholds.zschem.EventHandler());
|
MinecraftForge.EVENT_BUS.register(new dev.zontreck.otemod.zschem.EventHandler());
|
||||||
ModMenuTypes.CONTAINERS.register(bus);
|
ModMenuTypes.CONTAINERS.register(bus);
|
||||||
|
|
||||||
ModBlocks.register(bus);
|
ModBlocks.register(bus);
|
||||||
|
@ -173,7 +188,7 @@ public class ThresholdsMod
|
||||||
}else {
|
}else {
|
||||||
Starter data = StarterProvider.getStarter();
|
Starter data = StarterProvider.getStarter();
|
||||||
|
|
||||||
if(data.getLastChanged() > tag.LastGiven && ThresholdsServerConfig.GIVE_KIT_EVERY_CHANGE.get())
|
if(data.getLastChanged() > tag.LastGiven && OTEServerConfig.GIVE_KIT_EVERY_CHANGE.get())
|
||||||
{
|
{
|
||||||
tag = PlayerFirstJoinTag.now();
|
tag = PlayerFirstJoinTag.now();
|
||||||
tag.save(prof.NBT);
|
tag.save(prof.NBT);
|
||||||
|
@ -208,24 +223,24 @@ public class ThresholdsMod
|
||||||
public void onServerStarting(ServerStartedEvent event)
|
public void onServerStarting(ServerStartedEvent event)
|
||||||
{
|
{
|
||||||
// Changed away from Starting event due to multiple calls
|
// Changed away from Starting event due to multiple calls
|
||||||
if(ThresholdsMod.ALIVE){
|
if(OTEMod.ALIVE){
|
||||||
// We were called again?
|
// We were called again?
|
||||||
// Wtf... return
|
// Wtf... return
|
||||||
ThresholdsMod.LOGGER.info("/!\\ ALERT /!\\ ServerStartedEvent was called multiple times. This is a bug in MinecraftForge");
|
OTEMod.LOGGER.info("/!\\ ALERT /!\\ ServerStartedEvent was called multiple times. This is a bug in MinecraftForge");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Do something when the server starts
|
// Do something when the server starts
|
||||||
//LOGGER.info("HELLO from server starting");
|
//LOGGER.info("HELLO from server starting");
|
||||||
|
|
||||||
ThresholdsMod.ALIVE=true;
|
OTEMod.ALIVE=true;
|
||||||
//HealerQueue.Initialize(); // Set up the queue
|
//HealerQueue.Initialize(); // Set up the queue
|
||||||
|
|
||||||
// Set up the repeating task to expire a TeleportContainer
|
// Set up the repeating task to expire a TeleportContainer
|
||||||
ThresholdsMod.THE_SERVER = event.getServer();
|
OTEMod.THE_SERVER = event.getServer();
|
||||||
ThresholdsMod.MasterThread = new Thread(new Runnable(){
|
OTEMod.MasterThread = new Thread(new Runnable(){
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
while(ThresholdsMod.ALIVE){
|
while(OTEMod.ALIVE){
|
||||||
// Check if the teleports have expired
|
// Check if the teleports have expired
|
||||||
try {
|
try {
|
||||||
Thread.sleep(5000);
|
Thread.sleep(5000);
|
||||||
|
@ -245,10 +260,10 @@ public class ThresholdsMod
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
ThresholdsMod.LOGGER.info("Tearing down Thresholds teleport queue - The server is going down");
|
OTEMod.LOGGER.info("Tearing down OTEMod teleport queue - The server is going down");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ThresholdsMod.MasterThread.start();
|
OTEMod.MasterThread.start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +273,7 @@ public class ThresholdsMod
|
||||||
{
|
{
|
||||||
if(ev.getEntity().level().isClientSide)return;
|
if(ev.getEntity().level().isClientSide)return;
|
||||||
|
|
||||||
if(ThresholdsServerConfig.ITEM_DESPAWN_TIMER.get()<=0)return;
|
if(OTEServerConfig.ITEM_DESPAWN_TIMER.get()<=0)return;
|
||||||
|
|
||||||
ItemEntity ite = (ItemEntity)ev.getEntity();
|
ItemEntity ite = (ItemEntity)ev.getEntity();
|
||||||
if(ite.getAge() != (1200 * 5)) {
|
if(ite.getAge() != (1200 * 5)) {
|
||||||
|
@ -270,7 +285,7 @@ public class ThresholdsMod
|
||||||
//OTEMod.LOGGER.info("Giving extra life to item : "+ev.getEntity().getName().getString() + "; item age [ "+ev.getEntity().getAge()+ " ]");
|
//OTEMod.LOGGER.info("Giving extra life to item : "+ev.getEntity().getName().getString() + "; item age [ "+ev.getEntity().getAge()+ " ]");
|
||||||
// 1200 ticks per minute
|
// 1200 ticks per minute
|
||||||
// OTEMod item despawn amplifier is set in 5 minute intervals
|
// OTEMod item despawn amplifier is set in 5 minute intervals
|
||||||
ev.setExtraLife((1200 * 5)+ ((1200 * 5) * ThresholdsServerConfig.ITEM_DESPAWN_TIMER.get())); // reset the life count
|
ev.setExtraLife((1200 * 5)+ ((1200 * 5) * OTEServerConfig.ITEM_DESPAWN_TIMER.get())); // reset the life count
|
||||||
//OTEMod.LOGGER.info("Item ["+ev.getEntity().getItem().getDisplayName().getString()+"] was given extra life");
|
//OTEMod.LOGGER.info("Item ["+ev.getEntity().getItem().getDisplayName().getString()+"] was given extra life");
|
||||||
// Hopefully this works?
|
// Hopefully this works?
|
||||||
ev.setCanceled(true);
|
ev.setCanceled(true);
|
||||||
|
@ -281,14 +296,14 @@ public class ThresholdsMod
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onStop(final ServerStoppingEvent ev)
|
public void onStop(final ServerStoppingEvent ev)
|
||||||
{
|
{
|
||||||
ThresholdsMod.ALIVE=false; // Tear down all looping threads that will watch this
|
OTEMod.ALIVE=false; // Tear down all looping threads that will watch this
|
||||||
ThresholdsMod.MasterThread.interrupt();
|
OTEMod.MasterThread.interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent
|
// You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent
|
||||||
@Mod.EventBusSubscriber(modid = ThresholdsMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
@Mod.EventBusSubscriber(modid = OTEMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
public static class ClientModEvents
|
public static class ClientModEvents
|
||||||
{
|
{
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
|
@ -1,23 +1,24 @@
|
||||||
package dev.zontreck.thresholds.blocks;
|
package dev.zontreck.otemod.blocks;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.world.level.block.DoorBlock;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.SoundType;
|
import net.minecraft.world.level.block.DoorBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.world.level.block.state.properties.BlockSetType;
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||||
|
import net.minecraft.world.level.block.state.properties.BlockSetType;
|
||||||
public class AuroraDoorBlock extends DoorBlock
|
|
||||||
{
|
public class AuroraDoorBlock extends DoorBlock
|
||||||
public static final BlockBehaviour.Properties DOOR_PROPS;
|
{
|
||||||
static
|
public static final BlockBehaviour.Properties DOOR_PROPS;
|
||||||
{
|
static
|
||||||
DOOR_PROPS = BlockBehaviour.Properties.copy(Blocks.IRON_DOOR).requiresCorrectToolForDrops().strength(10, 100000f).sound(SoundType.NETHERITE_BLOCK);
|
{
|
||||||
}
|
DOOR_PROPS = BlockBehaviour.Properties.copy(Blocks.IRON_DOOR).requiresCorrectToolForDrops().strength(10, 100000f).sound(SoundType.NETHERITE_BLOCK);
|
||||||
|
}
|
||||||
public AuroraDoorBlock() {
|
|
||||||
super(DOOR_PROPS, BlockSetType.IRON);
|
public AuroraDoorBlock() {
|
||||||
|
super(DOOR_PROPS, BlockSetType.IRON);
|
||||||
|
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
package dev.zontreck.thresholds.blocks;
|
package dev.zontreck.otemod.blocks;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.blocks.entity.CompressionChamberBlockEntity;
|
import dev.zontreck.otemod.blocks.entity.CompressionChamberBlockEntity;
|
||||||
import dev.zontreck.thresholds.blocks.entity.ModEntities;
|
import dev.zontreck.otemod.blocks.entity.ModEntities;
|
||||||
import dev.zontreck.thresholds.networking.ModMessages;
|
import dev.zontreck.otemod.networking.ModMessages;
|
||||||
import dev.zontreck.thresholds.networking.packets.EnergySyncS2CPacket;
|
import dev.zontreck.otemod.networking.packets.EnergySyncS2CPacket;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
|
@ -1,4 +1,4 @@
|
||||||
package dev.zontreck.thresholds.blocks;
|
package dev.zontreck.otemod.blocks;
|
||||||
|
|
||||||
import net.minecraft.world.item.BlockItem;
|
import net.minecraft.world.item.BlockItem;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
|
@ -1,101 +1,102 @@
|
||||||
package dev.zontreck.thresholds.blocks;
|
package dev.zontreck.otemod.blocks;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.blocks.entity.ItemScrubberBlockEntity;
|
import dev.zontreck.otemod.blocks.entity.ItemScrubberBlockEntity;
|
||||||
import dev.zontreck.thresholds.blocks.entity.ModEntities;
|
import dev.zontreck.otemod.blocks.entity.ModEntities;
|
||||||
import dev.zontreck.thresholds.networking.ModMessages;
|
import dev.zontreck.otemod.networking.ModMessages;
|
||||||
import dev.zontreck.thresholds.networking.packets.EnergySyncS2CPacket;
|
import dev.zontreck.otemod.networking.packets.EnergySyncS2CPacket;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||||
import net.minecraft.world.level.block.*;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.*;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.StateDefinition;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraftforge.network.NetworkHooks;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
|
import net.minecraftforge.network.NetworkHooks;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
public class ItemScrubberBlock extends HorizontalDirectionalBlock implements EntityBlock
|
|
||||||
{
|
public class ItemScrubberBlock extends HorizontalDirectionalBlock implements EntityBlock
|
||||||
|
{
|
||||||
public ItemScrubberBlock(Properties p_54120_) {
|
|
||||||
super(p_54120_);
|
public ItemScrubberBlock(Properties p_54120_) {
|
||||||
//registerDefaultState(defaultBlockState().setValue(FACING, Direction.NORTH));
|
super(p_54120_);
|
||||||
}
|
//registerDefaultState(defaultBlockState().setValue(FACING, Direction.NORTH));
|
||||||
|
}
|
||||||
@Override
|
|
||||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) {
|
@Override
|
||||||
super.createBlockStateDefinition(pBuilder);
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) {
|
||||||
pBuilder.add(FACING);
|
super.createBlockStateDefinition(pBuilder);
|
||||||
}
|
pBuilder.add(FACING);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public RenderShape getRenderShape(BlockState state)
|
@Override
|
||||||
{
|
public RenderShape getRenderShape(BlockState state)
|
||||||
return RenderShape.MODEL;
|
{
|
||||||
}
|
return RenderShape.MODEL;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void onRemove(BlockState state, Level lvl, BlockPos pos, BlockState newState, boolean isMoving)
|
@Override
|
||||||
{
|
public void onRemove(BlockState state, Level lvl, BlockPos pos, BlockState newState, boolean isMoving)
|
||||||
if(state.getBlock()!=newState.getBlock())
|
{
|
||||||
{
|
if(state.getBlock()!=newState.getBlock())
|
||||||
BlockEntity bE = lvl.getBlockEntity(pos);
|
{
|
||||||
if(bE instanceof ItemScrubberBlockEntity)
|
BlockEntity bE = lvl.getBlockEntity(pos);
|
||||||
{
|
if(bE instanceof ItemScrubberBlockEntity)
|
||||||
((ItemScrubberBlockEntity)bE).doDrop();
|
{
|
||||||
}
|
((ItemScrubberBlockEntity)bE).doDrop();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
super.onRemove(state, lvl, pos, newState, isMoving);
|
|
||||||
}
|
super.onRemove(state, lvl, pos, newState, isMoving);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public InteractionResult use(BlockState state, Level lvl, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit)
|
@Override
|
||||||
{
|
public InteractionResult use(BlockState state, Level lvl, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit)
|
||||||
if(!lvl.isClientSide())
|
{
|
||||||
{
|
if(!lvl.isClientSide())
|
||||||
BlockEntity be = lvl.getBlockEntity(pos);
|
{
|
||||||
if(be instanceof ItemScrubberBlockEntity)
|
BlockEntity be = lvl.getBlockEntity(pos);
|
||||||
{
|
if(be instanceof ItemScrubberBlockEntity)
|
||||||
ItemScrubberBlockEntity entity = (ItemScrubberBlockEntity)be;
|
{
|
||||||
NetworkHooks.openScreen(((ServerPlayer)player), entity, pos);
|
ItemScrubberBlockEntity entity = (ItemScrubberBlockEntity)be;
|
||||||
|
NetworkHooks.openScreen(((ServerPlayer)player), entity, pos);
|
||||||
ModMessages.sendToPlayer(new EnergySyncS2CPacket(entity.getEnergyStorage().getEnergyStored(), entity.getBlockPos()), (ServerPlayer)player);
|
|
||||||
|
ModMessages.sendToPlayer(new EnergySyncS2CPacket(entity.getEnergyStorage().getEnergyStored(), entity.getBlockPos()), (ServerPlayer)player);
|
||||||
}else{
|
|
||||||
throw new IllegalStateException("Our container is missing!");
|
}else{
|
||||||
}
|
throw new IllegalStateException("Our container is missing!");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return InteractionResult.sidedSuccess(lvl.isClientSide);
|
|
||||||
}
|
return InteractionResult.sidedSuccess(lvl.isClientSide);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
@Nullable
|
@Override
|
||||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
@Nullable
|
||||||
return new ItemScrubberBlockEntity(pos, state);
|
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||||
}
|
return new ItemScrubberBlockEntity(pos, state);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level lvl, BlockState state, BlockEntityType<T> type)
|
@Override
|
||||||
{
|
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level lvl, BlockState state, BlockEntityType<T> type)
|
||||||
return createTickerHelper(type, ModEntities.ITEM_SCRUBBER.get(), ItemScrubberBlockEntity::tick);
|
{
|
||||||
}
|
return createTickerHelper(type, ModEntities.ITEM_SCRUBBER.get(), ItemScrubberBlockEntity::tick);
|
||||||
|
}
|
||||||
protected static <E extends BlockEntity, A extends BlockEntity> BlockEntityTicker<A> createTickerHelper(BlockEntityType<A> pServerType, BlockEntityType<E> pClientType, BlockEntityTicker<? super E> pTicker) {
|
|
||||||
return pClientType == pServerType ? (BlockEntityTicker<A>) pTicker : null;
|
protected static <E extends BlockEntity, A extends BlockEntity> BlockEntityTicker<A> createTickerHelper(BlockEntityType<A> pServerType, BlockEntityType<E> pClientType, BlockEntityTicker<? super E> pTicker) {
|
||||||
}
|
return pClientType == pServerType ? (BlockEntityTicker<A>) pTicker : null;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public BlockState getStateForPlacement(BlockPlaceContext pContext) {
|
@Override
|
||||||
return defaultBlockState().setValue(FACING, pContext.getHorizontalDirection().getOpposite());
|
public BlockState getStateForPlacement(BlockPlaceContext pContext) {
|
||||||
}
|
return defaultBlockState().setValue(FACING, pContext.getHorizontalDirection().getOpposite());
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -1,102 +1,102 @@
|
||||||
package dev.zontreck.thresholds.blocks;
|
package dev.zontreck.otemod.blocks;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.blocks.entity.MagicalScrubberBlockEntity;
|
import dev.zontreck.otemod.blocks.entity.MagicalScrubberBlockEntity;
|
||||||
import dev.zontreck.thresholds.blocks.entity.ModEntities;
|
import dev.zontreck.otemod.blocks.entity.ModEntities;
|
||||||
import dev.zontreck.thresholds.networking.ModMessages;
|
import dev.zontreck.otemod.networking.ModMessages;
|
||||||
import dev.zontreck.thresholds.networking.packets.EnergySyncS2CPacket;
|
import dev.zontreck.otemod.networking.packets.EnergySyncS2CPacket;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.*;
|
import net.minecraft.world.level.block.*;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.block.state.StateDefinition;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraftforge.network.NetworkHooks;
|
import net.minecraftforge.network.NetworkHooks;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class MagicalScrubberBlock extends HorizontalDirectionalBlock implements EntityBlock
|
public class MagicalScrubberBlock extends HorizontalDirectionalBlock implements EntityBlock
|
||||||
{
|
{
|
||||||
|
|
||||||
public MagicalScrubberBlock(Properties p_54120_) {
|
public MagicalScrubberBlock(Properties p_54120_) {
|
||||||
super(p_54120_);
|
super(p_54120_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) {
|
||||||
super.createBlockStateDefinition(pBuilder);
|
super.createBlockStateDefinition(pBuilder);
|
||||||
pBuilder.add(FACING);
|
pBuilder.add(FACING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RenderShape getRenderShape(BlockState state)
|
public RenderShape getRenderShape(BlockState state)
|
||||||
{
|
{
|
||||||
return RenderShape.MODEL;
|
return RenderShape.MODEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRemove(BlockState state, Level lvl, BlockPos pos, BlockState newState, boolean isMoving)
|
public void onRemove(BlockState state, Level lvl, BlockPos pos, BlockState newState, boolean isMoving)
|
||||||
{
|
{
|
||||||
if(state.getBlock()!=newState.getBlock())
|
if(state.getBlock()!=newState.getBlock())
|
||||||
{
|
{
|
||||||
BlockEntity bE = lvl.getBlockEntity(pos);
|
BlockEntity bE = lvl.getBlockEntity(pos);
|
||||||
if(bE instanceof MagicalScrubberBlockEntity)
|
if(bE instanceof MagicalScrubberBlockEntity)
|
||||||
{
|
{
|
||||||
((MagicalScrubberBlockEntity)bE).doDrop();
|
((MagicalScrubberBlockEntity)bE).doDrop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onRemove(state, lvl, pos, newState, isMoving);
|
super.onRemove(state, lvl, pos, newState, isMoving);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResult use(BlockState state, Level lvl, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit)
|
public InteractionResult use(BlockState state, Level lvl, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit)
|
||||||
{
|
{
|
||||||
if(!lvl.isClientSide())
|
if(!lvl.isClientSide())
|
||||||
{
|
{
|
||||||
BlockEntity be = lvl.getBlockEntity(pos);
|
BlockEntity be = lvl.getBlockEntity(pos);
|
||||||
if(be instanceof MagicalScrubberBlockEntity)
|
if(be instanceof MagicalScrubberBlockEntity)
|
||||||
{
|
{
|
||||||
MagicalScrubberBlockEntity entity = (MagicalScrubberBlockEntity)be;
|
MagicalScrubberBlockEntity entity = (MagicalScrubberBlockEntity)be;
|
||||||
NetworkHooks.openScreen(((ServerPlayer)player), entity, pos);
|
NetworkHooks.openScreen(((ServerPlayer)player), entity, pos);
|
||||||
|
|
||||||
ModMessages.sendToPlayer(new EnergySyncS2CPacket(entity.getEnergyStorage().getEnergyStored(), entity.getBlockPos()), (ServerPlayer)player);
|
ModMessages.sendToPlayer(new EnergySyncS2CPacket(entity.getEnergyStorage().getEnergyStored(), entity.getBlockPos()), (ServerPlayer)player);
|
||||||
}else{
|
}else{
|
||||||
throw new IllegalStateException("Our container is missing!");
|
throw new IllegalStateException("Our container is missing!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return InteractionResult.sidedSuccess(lvl.isClientSide);
|
return InteractionResult.sidedSuccess(lvl.isClientSide);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||||
return new MagicalScrubberBlockEntity(pos, state);
|
return new MagicalScrubberBlockEntity(pos, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level lvl, BlockState state, BlockEntityType<T> type)
|
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level lvl, BlockState state, BlockEntityType<T> type)
|
||||||
{
|
{
|
||||||
return createTickerHelper(type, ModEntities.MAGICAL_SCRUBBER.get(), MagicalScrubberBlockEntity::tick);
|
return createTickerHelper(type, ModEntities.MAGICAL_SCRUBBER.get(), MagicalScrubberBlockEntity::tick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected static <E extends BlockEntity, A extends BlockEntity> BlockEntityTicker<A> createTickerHelper(BlockEntityType<A> pServerType, BlockEntityType<E> pClientType, BlockEntityTicker<? super E> pTicker) {
|
protected static <E extends BlockEntity, A extends BlockEntity> BlockEntityTicker<A> createTickerHelper(BlockEntityType<A> pServerType, BlockEntityType<E> pClientType, BlockEntityTicker<? super E> pTicker) {
|
||||||
return pClientType == pServerType ? (BlockEntityTicker<A>) pTicker : null;
|
return pClientType == pServerType ? (BlockEntityTicker<A>) pTicker : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getStateForPlacement(BlockPlaceContext pContext) {
|
public BlockState getStateForPlacement(BlockPlaceContext pContext) {
|
||||||
return defaultBlockState().setValue(FACING, pContext.getHorizontalDirection().getOpposite());
|
return defaultBlockState().setValue(FACING, pContext.getHorizontalDirection().getOpposite());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,146 +1,147 @@
|
||||||
package dev.zontreck.thresholds.blocks;
|
package dev.zontreck.otemod.blocks;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.implementation.CreativeModeTabs;
|
import dev.zontreck.otemod.implementation.CreativeModeTabs;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.item.BlockItem;
|
import net.minecraft.world.item.BlockItem;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.FlintAndSteelItem;
|
||||||
import net.minecraft.world.level.BlockGetter;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.level.block.*;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
import net.minecraft.world.level.block.*;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
public class ModBlocks {
|
|
||||||
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, ThresholdsMod.MOD_ID);
|
public class ModBlocks {
|
||||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ThresholdsMod.MOD_ID);
|
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, OTEMod.MOD_ID);
|
||||||
|
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, OTEMod.MOD_ID);
|
||||||
public static void register(IEventBus bus){
|
|
||||||
BLOCKS.register(bus);
|
public static void register(IEventBus bus){
|
||||||
ITEMS.register(bus);
|
BLOCKS.register(bus);
|
||||||
ThresholdsMod.LOGGER.info("Registering all blocks...");
|
ITEMS.register(bus);
|
||||||
}
|
OTEMod.LOGGER.info("Registering all blocks...");
|
||||||
|
}
|
||||||
public static final RegistryObject<Block> ETERNIUM_ORE_BLOCK = BLOCKS.register("eternium_ore_block", () -> new Block(BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(7F).explosionResistance(1200).destroyTime(6)));
|
|
||||||
|
public static final RegistryObject<Block> ETERNIUM_ORE_BLOCK = BLOCKS.register("eternium_ore_block", () -> new Block(BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(7F).explosionResistance(1200).destroyTime(6)));
|
||||||
public static final RegistryObject<Item> ETERNIUM_ORE_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("eternium_ore_block", () -> new BlockItem(ETERNIUM_ORE_BLOCK.get(), new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> ETERNIUM_ORE_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("eternium_ore_block", () -> new BlockItem(ETERNIUM_ORE_BLOCK.get(), new Item.Properties())));
|
||||||
public static final RegistryObject<Block> VAULT_STEEL_ORE_BLOCK = BLOCKS.register("vault_steel_ore_block", ()->new Block(BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(8F).explosionResistance(1200).destroyTime(100)));
|
|
||||||
|
public static final RegistryObject<Block> VAULT_STEEL_ORE_BLOCK = BLOCKS.register("vault_steel_ore_block", ()->new Block(BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(8F).explosionResistance(1200).destroyTime(100)));
|
||||||
public static final RegistryObject<Item> VAULT_STEEL_ORE_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_steel_ore_block", ()->new BlockItem(VAULT_STEEL_ORE_BLOCK.get(), new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> VAULT_STEEL_ORE_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_steel_ore_block", ()->new BlockItem(VAULT_STEEL_ORE_BLOCK.get(), new Item.Properties())));
|
||||||
|
|
||||||
public static final RegistryObject<Block> NETHER_VAULT_STEEL_ORE_BLOCK = BLOCKS.register("nether_vault_steel_ore_block", ()->new Block(BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(8F).explosionResistance(1200).destroyTime(100)));
|
|
||||||
|
public static final RegistryObject<Block> NETHER_VAULT_STEEL_ORE_BLOCK = BLOCKS.register("nether_vault_steel_ore_block", ()->new Block(BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(8F).explosionResistance(1200).destroyTime(100)));
|
||||||
public static final RegistryObject<Item> NETHER_VAULT_STEEL_ORE_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("nether_vault_steel_ore_block", ()->new BlockItem(NETHER_VAULT_STEEL_ORE_BLOCK.get(), new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> NETHER_VAULT_STEEL_ORE_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("nether_vault_steel_ore_block", ()->new BlockItem(NETHER_VAULT_STEEL_ORE_BLOCK.get(), new Item.Properties())));
|
||||||
|
|
||||||
public static final RegistryObject<Block> ETERNIUM_BLOCK = BLOCKS.register("eternium_block", ()->new Block(BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(8F).explosionResistance(1200).destroyTime(100)));
|
|
||||||
|
public static final RegistryObject<Block> ETERNIUM_BLOCK = BLOCKS.register("eternium_block", ()->new Block(BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(8F).explosionResistance(1200).destroyTime(100)));
|
||||||
public static final RegistryObject<Item> ETERNIUM_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("eternium_block", ()->new FoiledBlockItem(ETERNIUM_BLOCK.get(), new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> ETERNIUM_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("eternium_block", ()->new FoiledBlockItem(ETERNIUM_BLOCK.get(), new Item.Properties())));
|
||||||
|
|
||||||
public static final RegistryObject<Block> DEEPSLATE_ETERNIUM_ORE_BLOCK = BLOCKS.register("deepslate_eternium_ore_block", () -> new Block(BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(5f).explosionResistance(1200).destroyTime(7)));
|
|
||||||
|
public static final RegistryObject<Block> DEEPSLATE_ETERNIUM_ORE_BLOCK = BLOCKS.register("deepslate_eternium_ore_block", () -> new Block(BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(5f).explosionResistance(1200).destroyTime(7)));
|
||||||
public static final RegistryObject<Item> DEEPSLATE_ETERNIUM_ORE_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("deepslate_eternium_ore_block", () -> new BlockItem(DEEPSLATE_ETERNIUM_ORE_BLOCK.get(), new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> DEEPSLATE_ETERNIUM_ORE_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("deepslate_eternium_ore_block", () -> new BlockItem(DEEPSLATE_ETERNIUM_ORE_BLOCK.get(), new Item.Properties())));
|
||||||
public static final RegistryObject<Block> AURORA_BLOCK = BLOCKS.register("aurora_block", () -> new Block(BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(9f).explosionResistance(100000f).destroyTime(10).sound(SoundType.NETHERITE_BLOCK)));
|
|
||||||
|
public static final RegistryObject<Block> AURORA_BLOCK = BLOCKS.register("aurora_block", () -> new Block(BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(9f).explosionResistance(100000f).destroyTime(10).sound(SoundType.NETHERITE_BLOCK)));
|
||||||
public static final RegistryObject<Item> AURORA_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("aurora_block", () -> new BlockItem(AURORA_BLOCK.get(), new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> AURORA_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("aurora_block", () -> new BlockItem(AURORA_BLOCK.get(), new Item.Properties())));
|
||||||
|
|
||||||
|
|
||||||
public static final RegistryObject<Block> AURORA_DOOR = BLOCKS.register("aurora_door", AuroraDoorBlock::new);
|
|
||||||
|
public static final RegistryObject<Block> AURORA_DOOR = BLOCKS.register("aurora_door", AuroraDoorBlock::new);
|
||||||
public static final RegistryObject<Item> AURORA_DOOR_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("aurora_door", () -> new BlockItem(AURORA_DOOR.get(), new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> AURORA_DOOR_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("aurora_door", () -> new BlockItem(AURORA_DOOR.get(), new Item.Properties())));
|
||||||
|
|
||||||
public static final RegistryObject<Block> CLEAR_GLASS_BLOCK = BLOCKS.register("clear_glass_block", () -> new Block(BlockBehaviour.Properties.copy(Blocks.GLASS).strength(1f).destroyTime(6).noOcclusion().isViewBlocking(ModBlocks::never)));
|
|
||||||
|
public static final RegistryObject<Block> CLEAR_GLASS_BLOCK = BLOCKS.register("clear_glass_block", () -> new Block(BlockBehaviour.Properties.copy(Blocks.GLASS).strength(1f).destroyTime(6).noOcclusion().isViewBlocking(ModBlocks::never)));
|
||||||
public static final RegistryObject<Item> CLEAR_GLASS_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("clear_glass_block", () -> new BlockItem(CLEAR_GLASS_BLOCK.get(), new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> CLEAR_GLASS_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("clear_glass_block", () -> new BlockItem(CLEAR_GLASS_BLOCK.get(), new Item.Properties())));
|
||||||
|
|
||||||
public static final RegistryObject<Block> ITEM_SCRUBBER = BLOCKS.register("item_scrubber", ()->new ItemScrubberBlock(BlockBehaviour.Properties.copy(ModBlocks.AURORA_BLOCK.get()).noOcclusion().isViewBlocking(ModBlocks::never)));
|
|
||||||
|
public static final RegistryObject<Block> ITEM_SCRUBBER = BLOCKS.register("item_scrubber", ()->new ItemScrubberBlock(BlockBehaviour.Properties.copy(ModBlocks.AURORA_BLOCK.get()).noOcclusion().isViewBlocking(ModBlocks::never)));
|
||||||
public static final RegistryObject<Item> ITEM_SCRUBBER_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("item_scrubber", ()->new BlockItem(ITEM_SCRUBBER.get(), new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> ITEM_SCRUBBER_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("item_scrubber", ()->new BlockItem(ITEM_SCRUBBER.get(), new Item.Properties())));
|
||||||
public static final RegistryObject<Block> MAGICAL_SCRUBBER = BLOCKS.register("magical_scrubber", ()->new MagicalScrubberBlock(BlockBehaviour.Properties.copy(ModBlocks.AURORA_BLOCK.get()).noOcclusion().isViewBlocking(ModBlocks::never)));
|
|
||||||
|
public static final RegistryObject<Block> MAGICAL_SCRUBBER = BLOCKS.register("magical_scrubber", ()->new MagicalScrubberBlock(BlockBehaviour.Properties.copy(ModBlocks.AURORA_BLOCK.get()).noOcclusion().isViewBlocking(ModBlocks::never)));
|
||||||
public static final RegistryObject<Item> MAGICAL_SCRUBBER_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("magical_scrubber", ()->new BlockItem(MAGICAL_SCRUBBER.get(), new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> MAGICAL_SCRUBBER_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("magical_scrubber", ()->new BlockItem(MAGICAL_SCRUBBER.get(), new Item.Properties())));
|
||||||
|
|
||||||
public static final RegistryObject<Block> STABLE_SINGULARITY = BLOCKS.register("stable_singularity", ()->new Block(BlockBehaviour.Properties.copy(ModBlocks.AURORA_BLOCK.get()).noOcclusion().isViewBlocking(ModBlocks::never)));
|
|
||||||
|
public static final RegistryObject<Block> STABLE_SINGULARITY = BLOCKS.register("stable_singularity", ()->new Block(BlockBehaviour.Properties.copy(ModBlocks.AURORA_BLOCK.get()).noOcclusion().isViewBlocking(ModBlocks::never)));
|
||||||
public static final RegistryObject<Item> STABLE_SINGULARITY_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("stable_singularity", ()->new BlockItem(STABLE_SINGULARITY.get(), new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> STABLE_SINGULARITY_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("stable_singularity", ()->new BlockItem(STABLE_SINGULARITY.get(), new Item.Properties())));
|
||||||
public static final RegistryObject<Block> ILUSIUM_ORE_BLOCK = BLOCKS.register("ilusium_ore_block", () -> new Block(BlockBehaviour.Properties.copy(ModBlocks.ETERNIUM_ORE_BLOCK.get()).noOcclusion()));
|
|
||||||
|
public static final RegistryObject<Block> ILUSIUM_ORE_BLOCK = BLOCKS.register("ilusium_ore_block", () -> new Block(BlockBehaviour.Properties.copy(ModBlocks.ETERNIUM_ORE_BLOCK.get()).noOcclusion()));
|
||||||
public static final RegistryObject<Item> ILUSIUM_ORE_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("ilusium_ore_block", () -> new BlockItem(ILUSIUM_ORE_BLOCK.get(), new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> ILUSIUM_ORE_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("ilusium_ore_block", () -> new BlockItem(ILUSIUM_ORE_BLOCK.get(), new Item.Properties())));
|
||||||
public static final RegistryObject<Block> DEEPSLATE_ILUSIUM_ORE_BLOCK = BLOCKS.register("deepslate_ilusium_ore_block", () -> new Block(BlockBehaviour.Properties.copy(ILUSIUM_ORE_BLOCK.get()).noOcclusion()));
|
|
||||||
|
public static final RegistryObject<Block> DEEPSLATE_ILUSIUM_ORE_BLOCK = BLOCKS.register("deepslate_ilusium_ore_block", () -> new Block(BlockBehaviour.Properties.copy(ILUSIUM_ORE_BLOCK.get()).noOcclusion()));
|
||||||
public static final RegistryObject<Item> DEEPSLATE_ILUSIUM_ORE_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("deepslate_ilusium_ore_block", () -> new BlockItem(DEEPSLATE_ILUSIUM_ORE_BLOCK.get(), new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> DEEPSLATE_ILUSIUM_ORE_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("deepslate_ilusium_ore_block", () -> new BlockItem(DEEPSLATE_ILUSIUM_ORE_BLOCK.get(), new Item.Properties())));
|
||||||
|
|
||||||
public static final RegistryObject<Block> ILUSIUM_BLOCK = BLOCKS.register("ilusium_block", () -> new Block(BlockBehaviour.Properties.copy(ModBlocks.ETERNIUM_BLOCK.get()).noOcclusion().strength(5, 20).requiresCorrectToolForDrops()));
|
|
||||||
|
public static final RegistryObject<Block> ILUSIUM_BLOCK = BLOCKS.register("ilusium_block", () -> new Block(BlockBehaviour.Properties.copy(ModBlocks.ETERNIUM_BLOCK.get()).noOcclusion().strength(5, 20).requiresCorrectToolForDrops()));
|
||||||
public static final RegistryObject<Item> ILUSIUM_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("ilusium_block", () -> new BlockItem(ILUSIUM_BLOCK.get(), new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> ILUSIUM_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("ilusium_block", () -> new BlockItem(ILUSIUM_BLOCK.get(), new Item.Properties())));
|
||||||
public static final RegistryObject<Block> COMPRESSION_CHAMBER_BLOCK = BLOCKS.register("compression_chamber", ()->new CompressionChamberBlock(BlockBehaviour.Properties.copy(ModBlocks.ILUSIUM_BLOCK.get()).noOcclusion().isViewBlocking(ModBlocks::never)));
|
|
||||||
|
public static final RegistryObject<Block> COMPRESSION_CHAMBER_BLOCK = BLOCKS.register("compression_chamber", ()->new CompressionChamberBlock(BlockBehaviour.Properties.copy(ModBlocks.ILUSIUM_BLOCK.get()).noOcclusion().isViewBlocking(ModBlocks::never)));
|
||||||
public static final RegistryObject<Item> COMPRESSION_CHAMBER_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("compression_chamber", ()->new BlockItem(COMPRESSION_CHAMBER_BLOCK.get(), new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> COMPRESSION_CHAMBER_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("compression_chamber", ()->new BlockItem(COMPRESSION_CHAMBER_BLOCK.get(), new Item.Properties())));
|
||||||
|
|
||||||
public static final RegistryObject<Block> COMPRESSED_OBSIDIAN_BLOCK = BLOCKS.register("compressed_obsidian_block", ()->new Block(BlockBehaviour.Properties.copy(Blocks.OBSIDIAN)));
|
|
||||||
|
public static final RegistryObject<Block> COMPRESSED_OBSIDIAN_BLOCK = BLOCKS.register("compressed_obsidian_block", ()->new Block(BlockBehaviour.Properties.copy(Blocks.OBSIDIAN)));
|
||||||
public static final RegistryObject<Item> COMPRESSED_OBSIDIAN_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("compressed_obsidian_block", ()->new BlockItem(COMPRESSED_OBSIDIAN_BLOCK.get(), new Item.Properties())));
|
|
||||||
public static final RegistryObject<Block> LAYERED_COMPRESSED_OBSIDIAN_BLOCK = BLOCKS.register("layered_compressed_obsidian_block", ()->new Block(BlockBehaviour.Properties.copy(Blocks.OBSIDIAN)));
|
public static final RegistryObject<Item> COMPRESSED_OBSIDIAN_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("compressed_obsidian_block", ()->new BlockItem(COMPRESSED_OBSIDIAN_BLOCK.get(), new Item.Properties())));
|
||||||
|
public static final RegistryObject<Block> LAYERED_COMPRESSED_OBSIDIAN_BLOCK = BLOCKS.register("layered_compressed_obsidian_block", ()->new Block(BlockBehaviour.Properties.copy(Blocks.OBSIDIAN)));
|
||||||
public static final RegistryObject<Item> LAYERED_COMPRESSED_OBSIDIAN_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("layered_compressed_obsidian_block", ()->new BlockItem(LAYERED_COMPRESSED_OBSIDIAN_BLOCK.get(), new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> LAYERED_COMPRESSED_OBSIDIAN_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("layered_compressed_obsidian_block", ()->new BlockItem(LAYERED_COMPRESSED_OBSIDIAN_BLOCK.get(), new Item.Properties())));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static final RegistryObject<Block> LIMINAL_TILES = BLOCKS.register("liminal_tiles", ()-> new Block(BlockBehaviour.Properties.copy(Blocks.BEDROCK)));
|
|
||||||
|
public static final RegistryObject<Block> LIMINAL_TILES = BLOCKS.register("liminal_tiles", ()-> new Block(BlockBehaviour.Properties.copy(Blocks.BEDROCK)));
|
||||||
public static final RegistryObject<Item> LIMINAL_TILES_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("liminal_tiles", ()->new BlockItem(LIMINAL_TILES.get(), new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> LIMINAL_TILES_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("liminal_tiles", ()->new BlockItem(LIMINAL_TILES.get(), new Item.Properties())));
|
||||||
public static final RegistryObject<Block> BLACK = BLOCKS.register("black", ()->new Block(BlockBehaviour.Properties.copy(Blocks.BEDROCK)));
|
|
||||||
|
public static final RegistryObject<Block> BLACK = BLOCKS.register("black", ()->new Block(BlockBehaviour.Properties.copy(Blocks.BEDROCK)));
|
||||||
public static final RegistryObject<Item> BLACK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("black", ()->new FoiledBlockItem(BLACK.get(), new Item.Properties().stacksTo(128))));
|
|
||||||
|
public static final RegistryObject<Item> BLACK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("black", ()->new FoiledBlockItem(BLACK.get(), new Item.Properties().stacksTo(128))));
|
||||||
public static final RegistryObject<Block> LIMINAL_TILE_STAIRS = BLOCKS.register("liminal_tile_stairs", ()->new StairBlock(LIMINAL_TILES.get()::defaultBlockState, BlockBehaviour.Properties.copy(Blocks.BEDROCK).destroyTime(1000).strength(1000)));
|
|
||||||
|
public static final RegistryObject<Block> LIMINAL_TILE_STAIRS = BLOCKS.register("liminal_tile_stairs", ()->new StairBlock(LIMINAL_TILES.get()::defaultBlockState, BlockBehaviour.Properties.copy(Blocks.BEDROCK).destroyTime(1000).strength(1000)));
|
||||||
public static final RegistryObject<Item> LIMINAL_TILE_STAIRS_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("liminal_tile_stairs", ()->new BlockItem(LIMINAL_TILE_STAIRS.get(), new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> LIMINAL_TILE_STAIRS_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("liminal_tile_stairs", ()->new BlockItem(LIMINAL_TILE_STAIRS.get(), new Item.Properties())));
|
||||||
public static final RegistryObject<Block> LIMINAL_TILE_SLAB = BLOCKS.register("liminal_tile_slab", ()->new SlabBlock(BlockBehaviour.Properties.copy(Blocks.BEDROCK)));
|
|
||||||
|
public static final RegistryObject<Block> LIMINAL_TILE_SLAB = BLOCKS.register("liminal_tile_slab", ()->new SlabBlock(BlockBehaviour.Properties.copy(Blocks.BEDROCK)));
|
||||||
public static final RegistryObject<Item> LIMINAL_TILE_SLAB_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("liminal_tile_slab", ()->new BlockItem(LIMINAL_TILE_SLAB.get(), new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> LIMINAL_TILE_SLAB_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("liminal_tile_slab", ()->new BlockItem(LIMINAL_TILE_SLAB.get(), new Item.Properties())));
|
||||||
public static final RegistryObject<Block> LIMINAL_WINDOW = BLOCKS.register("liminal_window", () -> new ParallaxWindow(15));
|
|
||||||
|
public static final RegistryObject<Block> LIMINAL_WINDOW = BLOCKS.register("liminal_window", () -> new ParallaxWindow(15));
|
||||||
public static final RegistryObject<Item> LIMINAL_WINDOW_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("liminal_window", () -> new BlockItem(LIMINAL_WINDOW.get(), new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> LIMINAL_WINDOW_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("liminal_window", () -> new BlockItem(LIMINAL_WINDOW.get(), new Item.Properties())));
|
||||||
|
|
||||||
/*
|
|
||||||
|
/*
|
||||||
|
|
||||||
public static final class_2248 LIMINAL_WINDOW_NOON = (class_2248)createBlock("liminal_window_noon", new LiminalWindowBlock(QuiltBlockSettings.method_9630((class_4970)class_2246.field_31037).method_9626(class_2498.field_11537)), true, (class_1761)ModItems.LIMINAL_POOLS_ITEM_GROUP);
|
|
||||||
|
public static final class_2248 LIMINAL_WINDOW_NOON = (class_2248)createBlock("liminal_window_noon", new LiminalWindowBlock(QuiltBlockSettings.method_9630((class_4970)class_2246.field_31037).method_9626(class_2498.field_11537)), true, (class_1761)ModItems.LIMINAL_POOLS_ITEM_GROUP);
|
||||||
public static final class_2248 LIMINAL_WINDOW_DUSK = (class_2248)createBlock("liminal_window_dusk", new LiminalWindowBlock(QuiltBlockSettings.method_9630((class_4970)class_2246.field_31037).method_9626(class_2498.field_11537)), true, (class_1761)ModItems.LIMINAL_POOLS_ITEM_GROUP);
|
|
||||||
|
public static final class_2248 LIMINAL_WINDOW_DUSK = (class_2248)createBlock("liminal_window_dusk", new LiminalWindowBlock(QuiltBlockSettings.method_9630((class_4970)class_2246.field_31037).method_9626(class_2498.field_11537)), true, (class_1761)ModItems.LIMINAL_POOLS_ITEM_GROUP);
|
||||||
public static final class_2248 LIMINAL_WINDOW_ABYSS = (class_2248)createBlock("liminal_window_abyss", new LiminalWindowBlock(QuiltBlockSettings.method_9630((class_4970)class_2246.field_31037).method_9626(class_2498.field_11537)), true, (class_1761)ModItems.LIMINAL_POOLS_ITEM_GROUP);*/
|
|
||||||
|
public static final class_2248 LIMINAL_WINDOW_ABYSS = (class_2248)createBlock("liminal_window_abyss", new LiminalWindowBlock(QuiltBlockSettings.method_9630((class_4970)class_2246.field_31037).method_9626(class_2498.field_11537)), true, (class_1761)ModItems.LIMINAL_POOLS_ITEM_GROUP);*/
|
||||||
|
|
||||||
private static boolean never(BlockState p_50806_, BlockGetter p_50807_, BlockPos p_50808_) {
|
|
||||||
return false;
|
private static boolean never(BlockState p_50806_, BlockGetter p_50807_, BlockPos p_50808_) {
|
||||||
}
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -1,10 +1,12 @@
|
||||||
package dev.zontreck.thresholds.blocks;
|
package dev.zontreck.otemod.blocks;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.level.BlockGetter;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.level.block.*;
|
import net.minecraft.world.level.block.*;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||||
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class ParallaxWindow extends BaseEntityBlock
|
public class ParallaxWindow extends BaseEntityBlock
|
|
@ -1,11 +1,11 @@
|
||||||
package dev.zontreck.thresholds.blocks.entity;
|
package dev.zontreck.otemod.blocks.entity;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.implementation.OutputItemStackHandler;
|
import dev.zontreck.otemod.implementation.OutputItemStackHandler;
|
||||||
import dev.zontreck.thresholds.implementation.compressor.CompressionChamberMenu;
|
import dev.zontreck.otemod.implementation.compressor.CompressionChamberMenu;
|
||||||
import dev.zontreck.thresholds.implementation.energy.OTEEnergy;
|
import dev.zontreck.otemod.implementation.energy.OTEEnergy;
|
||||||
import dev.zontreck.thresholds.networking.ModMessages;
|
import dev.zontreck.otemod.networking.ModMessages;
|
||||||
import dev.zontreck.thresholds.networking.packets.EnergySyncS2CPacket;
|
import dev.zontreck.otemod.networking.packets.EnergySyncS2CPacket;
|
||||||
import dev.zontreck.thresholds.recipe.CompressionChamberRecipe;
|
import dev.zontreck.otemod.recipe.CompressionChamberRecipe;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
@ -17,14 +17,17 @@ import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.ContainerData;
|
import net.minecraft.world.inventory.ContainerData;
|
||||||
|
import net.minecraft.world.inventory.SimpleContainerData;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
|
import net.minecraftforge.energy.EnergyStorage;
|
||||||
import net.minecraftforge.energy.IEnergyStorage;
|
import net.minecraftforge.energy.IEnergyStorage;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
|
@ -1,292 +1,292 @@
|
||||||
package dev.zontreck.thresholds.blocks.entity;
|
package dev.zontreck.otemod.blocks.entity;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.implementation.OutputItemStackHandler;
|
import dev.zontreck.otemod.implementation.OutputItemStackHandler;
|
||||||
import dev.zontreck.thresholds.implementation.energy.OTEEnergy;
|
import dev.zontreck.otemod.implementation.energy.OTEEnergy;
|
||||||
import dev.zontreck.thresholds.implementation.scrubber.ItemScrubberMenu;
|
import dev.zontreck.otemod.implementation.scrubber.ItemScrubberMenu;
|
||||||
import dev.zontreck.thresholds.networking.ModMessages;
|
import dev.zontreck.otemod.networking.ModMessages;
|
||||||
import dev.zontreck.thresholds.networking.packets.EnergySyncS2CPacket;
|
import dev.zontreck.otemod.networking.packets.EnergySyncS2CPacket;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.world.Containers;
|
import net.minecraft.world.Containers;
|
||||||
import net.minecraft.world.MenuProvider;
|
import net.minecraft.world.MenuProvider;
|
||||||
import net.minecraft.world.SimpleContainer;
|
import net.minecraft.world.SimpleContainer;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.ContainerData;
|
import net.minecraft.world.inventory.ContainerData;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.energy.IEnergyStorage;
|
import net.minecraftforge.energy.IEnergyStorage;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class ItemScrubberBlockEntity extends BlockEntity implements MenuProvider
|
public class ItemScrubberBlockEntity extends BlockEntity implements MenuProvider
|
||||||
{
|
{
|
||||||
|
|
||||||
protected final ItemStackHandler itemsHandler = new ItemStackHandler(1){
|
protected final ItemStackHandler itemsHandler = new ItemStackHandler(1){
|
||||||
@Override
|
@Override
|
||||||
protected void onContentsChanged(int slot)
|
protected void onContentsChanged(int slot)
|
||||||
{
|
{
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
protected final ItemStackHandler outputItems = new ItemStackHandler(1){
|
protected final ItemStackHandler outputItems = new ItemStackHandler(1){
|
||||||
@Override
|
@Override
|
||||||
protected void onContentsChanged(int slot)
|
protected void onContentsChanged(int slot)
|
||||||
{
|
{
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private ItemStackHandler outputSlot;
|
private ItemStackHandler outputSlot;
|
||||||
|
|
||||||
private final OTEEnergy ENERGY_STORAGE = new OTEEnergy(ENERGY_REQ*3, ENERGY_REQ+512) {
|
private final OTEEnergy ENERGY_STORAGE = new OTEEnergy(ENERGY_REQ*3, ENERGY_REQ+512) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChanged() {
|
public void onChanged() {
|
||||||
setChanged();
|
setChanged();
|
||||||
|
|
||||||
ModMessages.sendToAll(new EnergySyncS2CPacket(energy, getBlockPos()));
|
ModMessages.sendToAll(new EnergySyncS2CPacket(energy, getBlockPos()));
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final int ENERGY_REQ = 1500;
|
private static final int ENERGY_REQ = 1500;
|
||||||
private LazyOptional<IEnergyStorage> lazyEnergyHandler = LazyOptional.empty();
|
private LazyOptional<IEnergyStorage> lazyEnergyHandler = LazyOptional.empty();
|
||||||
|
|
||||||
private LazyOptional<IItemHandler> lazyItemHandler = LazyOptional.empty();
|
private LazyOptional<IItemHandler> lazyItemHandler = LazyOptional.empty();
|
||||||
private LazyOptional<IItemHandler> lazyOutputItems = LazyOptional.empty();
|
private LazyOptional<IItemHandler> lazyOutputItems = LazyOptional.empty();
|
||||||
|
|
||||||
public ItemScrubberBlockEntity(BlockPos pos, BlockState state) {
|
public ItemScrubberBlockEntity(BlockPos pos, BlockState state) {
|
||||||
super(ModEntities.ITEM_SCRUBBER.get(), pos, state);
|
super(ModEntities.ITEM_SCRUBBER.get(), pos, state);
|
||||||
outputSlot = new OutputItemStackHandler(outputItems);
|
outputSlot = new OutputItemStackHandler(outputItems);
|
||||||
|
|
||||||
this.data = new ContainerData() {
|
this.data = new ContainerData() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int get(int p_39284_) {
|
public int get(int p_39284_) {
|
||||||
return switch(p_39284_){
|
return switch(p_39284_){
|
||||||
case 0 -> ItemScrubberBlockEntity.this.progress;
|
case 0 -> ItemScrubberBlockEntity.this.progress;
|
||||||
default -> 0;
|
default -> 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(int p_39285_, int p_39286_) {
|
public void set(int p_39285_, int p_39286_) {
|
||||||
switch(p_39285_)
|
switch(p_39285_)
|
||||||
{
|
{
|
||||||
case 0 -> ItemScrubberBlockEntity.this.progress = p_39286_;
|
case 0 -> ItemScrubberBlockEntity.this.progress = p_39286_;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final ContainerData data;
|
protected final ContainerData data;
|
||||||
private int progress = 0;
|
private int progress = 0;
|
||||||
|
|
||||||
public static final int MAXIMUM_PROCESSING_TICKS = 250;
|
public static final int MAXIMUM_PROCESSING_TICKS = 250;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public AbstractContainerMenu createMenu(int id, Inventory inv, Player player) {
|
public AbstractContainerMenu createMenu(int id, Inventory inv, Player player) {
|
||||||
return new ItemScrubberMenu(id, inv, this, this.data);
|
return new ItemScrubberMenu(id, inv, this, this.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getDisplayName() {
|
public Component getDisplayName() {
|
||||||
return Component.translatable("block.otemod.item_scrubber");
|
return Component.translatable("block.otemod.item_scrubber");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side)
|
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side)
|
||||||
{
|
{
|
||||||
if(cap == ForgeCapabilities.ENERGY)
|
if(cap == ForgeCapabilities.ENERGY)
|
||||||
{
|
{
|
||||||
return lazyEnergyHandler.cast();
|
return lazyEnergyHandler.cast();
|
||||||
}
|
}
|
||||||
if(side == Direction.DOWN && cap == ForgeCapabilities.ITEM_HANDLER)
|
if(side == Direction.DOWN && cap == ForgeCapabilities.ITEM_HANDLER)
|
||||||
{
|
{
|
||||||
// Return the output slot only
|
// Return the output slot only
|
||||||
return lazyOutputItems.cast();
|
return lazyOutputItems.cast();
|
||||||
}
|
}
|
||||||
if(cap == ForgeCapabilities.ITEM_HANDLER)
|
if(cap == ForgeCapabilities.ITEM_HANDLER)
|
||||||
{
|
{
|
||||||
return lazyItemHandler.cast();
|
return lazyItemHandler.cast();
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.getCapability(cap,side);
|
return super.getCapability(cap,side);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad()
|
public void onLoad()
|
||||||
{
|
{
|
||||||
super.onLoad();
|
super.onLoad();
|
||||||
lazyItemHandler = LazyOptional.of(()->itemsHandler);
|
lazyItemHandler = LazyOptional.of(()->itemsHandler);
|
||||||
lazyOutputItems = LazyOptional.of(()->outputSlot);
|
lazyOutputItems = LazyOptional.of(()->outputSlot);
|
||||||
lazyEnergyHandler = LazyOptional.of(()->ENERGY_STORAGE);
|
lazyEnergyHandler = LazyOptional.of(()->ENERGY_STORAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invalidateCaps()
|
public void invalidateCaps()
|
||||||
{
|
{
|
||||||
super.invalidateCaps();
|
super.invalidateCaps();
|
||||||
lazyItemHandler.invalidate();
|
lazyItemHandler.invalidate();
|
||||||
lazyOutputItems.invalidate();
|
lazyOutputItems.invalidate();
|
||||||
lazyEnergyHandler.invalidate();
|
lazyEnergyHandler.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void saveAdditional(CompoundTag nbt)
|
protected void saveAdditional(CompoundTag nbt)
|
||||||
{
|
{
|
||||||
nbt.put("inventory", itemsHandler.serializeNBT());
|
nbt.put("inventory", itemsHandler.serializeNBT());
|
||||||
nbt.put("output", outputItems.serializeNBT());
|
nbt.put("output", outputItems.serializeNBT());
|
||||||
nbt.putInt("prog", progress);
|
nbt.putInt("prog", progress);
|
||||||
nbt.putInt("energy", ENERGY_STORAGE.getEnergyStored());
|
nbt.putInt("energy", ENERGY_STORAGE.getEnergyStored());
|
||||||
|
|
||||||
super.saveAdditional(nbt);
|
super.saveAdditional(nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(CompoundTag nbt){
|
public void load(CompoundTag nbt){
|
||||||
super.load(nbt);
|
super.load(nbt);
|
||||||
|
|
||||||
itemsHandler.deserializeNBT(nbt.getCompound("inventory"));
|
itemsHandler.deserializeNBT(nbt.getCompound("inventory"));
|
||||||
outputItems.deserializeNBT(nbt.getCompound("output"));
|
outputItems.deserializeNBT(nbt.getCompound("output"));
|
||||||
progress = nbt.getInt("prog");
|
progress = nbt.getInt("prog");
|
||||||
ENERGY_STORAGE.setEnergy(nbt.getInt("energy"));
|
ENERGY_STORAGE.setEnergy(nbt.getInt("energy"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doDrop()
|
public void doDrop()
|
||||||
{
|
{
|
||||||
SimpleContainer cont = new SimpleContainer(itemsHandler.getSlots());
|
SimpleContainer cont = new SimpleContainer(itemsHandler.getSlots());
|
||||||
for (int i = 0; i < itemsHandler.getSlots(); i++) {
|
for (int i = 0; i < itemsHandler.getSlots(); i++) {
|
||||||
cont.setItem(i, itemsHandler.getStackInSlot(i));
|
cont.setItem(i, itemsHandler.getStackInSlot(i));
|
||||||
}
|
}
|
||||||
cont = new SimpleContainer(outputItems.getSlots());
|
cont = new SimpleContainer(outputItems.getSlots());
|
||||||
for (int i = 0; i < outputItems.getSlots(); i++) {
|
for (int i = 0; i < outputItems.getSlots(); i++) {
|
||||||
cont.setItem(i, outputItems.getStackInSlot(i));
|
cont.setItem(i, outputItems.getStackInSlot(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
Containers.dropContents(this.level, this.worldPosition, cont);
|
Containers.dropContents(this.level, this.worldPosition, cont);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void tick(Level lvl, BlockPos pos, BlockState state, ItemScrubberBlockEntity entity)
|
public static void tick(Level lvl, BlockPos pos, BlockState state, ItemScrubberBlockEntity entity)
|
||||||
{
|
{
|
||||||
if(lvl.isClientSide())return;
|
if(lvl.isClientSide())return;
|
||||||
|
|
||||||
|
|
||||||
if(hasRecipe(entity))
|
if(hasRecipe(entity))
|
||||||
{
|
{
|
||||||
if(!hasEnergy(entity))return; // Halt until sufficient energy has been received
|
if(!hasEnergy(entity))return; // Halt until sufficient energy has been received
|
||||||
entity.progress++;
|
entity.progress++;
|
||||||
setChanged(lvl, pos, state);
|
setChanged(lvl, pos, state);
|
||||||
drain(entity);
|
drain(entity);
|
||||||
|
|
||||||
if(entity.progress >= ItemScrubberBlockEntity.MAXIMUM_PROCESSING_TICKS)
|
if(entity.progress >= ItemScrubberBlockEntity.MAXIMUM_PROCESSING_TICKS)
|
||||||
{
|
{
|
||||||
craftItem(entity);
|
craftItem(entity);
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
if(entity.progress>0){
|
if(entity.progress>0){
|
||||||
entity.resetProgress();
|
entity.resetProgress();
|
||||||
setChanged(lvl, pos, state);
|
setChanged(lvl, pos, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void drain(ItemScrubberBlockEntity entity) {
|
private static void drain(ItemScrubberBlockEntity entity) {
|
||||||
entity.ENERGY_STORAGE.extractEnergy(ENERGY_REQ, false);
|
entity.ENERGY_STORAGE.extractEnergy(ENERGY_REQ, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean hasEnergy(ItemScrubberBlockEntity entity) {
|
private static boolean hasEnergy(ItemScrubberBlockEntity entity) {
|
||||||
return (entity.ENERGY_STORAGE.getEnergyStored() >= ENERGY_REQ);
|
return (entity.ENERGY_STORAGE.getEnergyStored() >= ENERGY_REQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void craftItem(ItemScrubberBlockEntity entity) {
|
private static void craftItem(ItemScrubberBlockEntity entity) {
|
||||||
if(hasRecipe(entity))
|
if(hasRecipe(entity))
|
||||||
{
|
{
|
||||||
ItemStack existing = entity.outputItems.getStackInSlot(0);
|
ItemStack existing = entity.outputItems.getStackInSlot(0);
|
||||||
existing.setCount(existing.getCount()+1);
|
existing.setCount(existing.getCount()+1);
|
||||||
if(existing.is(Items.AIR))
|
if(existing.is(Items.AIR))
|
||||||
{
|
{
|
||||||
existing = makeOutputItem(entity.itemsHandler.getStackInSlot(0));
|
existing = makeOutputItem(entity.itemsHandler.getStackInSlot(0));
|
||||||
}
|
}
|
||||||
entity.itemsHandler.extractItem(0, 1, false);
|
entity.itemsHandler.extractItem(0, 1, false);
|
||||||
entity.outputItems.setStackInSlot(0, existing);
|
entity.outputItems.setStackInSlot(0, existing);
|
||||||
|
|
||||||
entity.resetProgress();
|
entity.resetProgress();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean hasRecipe(ItemScrubberBlockEntity entity) {
|
private static boolean hasRecipe(ItemScrubberBlockEntity entity) {
|
||||||
SimpleContainer inventory = new SimpleContainer(entity.itemsHandler.getSlots());
|
SimpleContainer inventory = new SimpleContainer(entity.itemsHandler.getSlots());
|
||||||
for(int i=0;i<entity.itemsHandler.getSlots();i++)
|
for(int i=0;i<entity.itemsHandler.getSlots();i++)
|
||||||
{
|
{
|
||||||
inventory.setItem(i, entity.itemsHandler.getStackInSlot(i));
|
inventory.setItem(i, entity.itemsHandler.getStackInSlot(i));
|
||||||
}
|
}
|
||||||
SimpleContainer output = new SimpleContainer(entity.outputItems.getSlots());
|
SimpleContainer output = new SimpleContainer(entity.outputItems.getSlots());
|
||||||
for(int i=0;i<entity.outputItems.getSlots();i++)
|
for(int i=0;i<entity.outputItems.getSlots();i++)
|
||||||
{
|
{
|
||||||
output.setItem(i, entity.outputItems.getStackInSlot(i));
|
output.setItem(i, entity.outputItems.getStackInSlot(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
boolean hasAnItem = !entity.itemsHandler.getStackInSlot(0).isEmpty();
|
boolean hasAnItem = !entity.itemsHandler.getStackInSlot(0).isEmpty();
|
||||||
|
|
||||||
ItemStack result = null;
|
ItemStack result = null;
|
||||||
if(hasAnItem)
|
if(hasAnItem)
|
||||||
{
|
{
|
||||||
result = makeOutputItem(entity.itemsHandler.getStackInSlot(0));
|
result = makeOutputItem(entity.itemsHandler.getStackInSlot(0));
|
||||||
|
|
||||||
}
|
}
|
||||||
return hasAnItem && canInsertIntoOutput(output, result);
|
return hasAnItem && canInsertIntoOutput(output, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean canInsertIntoOutput(SimpleContainer inventory, ItemStack result) {
|
private static boolean canInsertIntoOutput(SimpleContainer inventory, ItemStack result) {
|
||||||
ItemStack existing = inventory.getItem(0);
|
ItemStack existing = inventory.getItem(0);
|
||||||
boolean stackCompat = (existing.getMaxStackSize() > existing.getCount());
|
boolean stackCompat = (existing.getMaxStackSize() > existing.getCount());
|
||||||
boolean sameType = (existing.getItem() == result.getItem());
|
boolean sameType = (existing.getItem() == result.getItem());
|
||||||
boolean outputEmpty = existing.isEmpty();
|
boolean outputEmpty = existing.isEmpty();
|
||||||
|
|
||||||
if(outputEmpty)return true;
|
if(outputEmpty)return true;
|
||||||
return (stackCompat && sameType);
|
return (stackCompat && sameType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetProgress() {
|
private void resetProgress() {
|
||||||
progress=0;
|
progress=0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static ItemStack makeOutputItem(ItemStack original)
|
protected static ItemStack makeOutputItem(ItemStack original)
|
||||||
{
|
{
|
||||||
ItemStack newItem = new ItemStack(original.getItem(),1);
|
ItemStack newItem = new ItemStack(original.getItem(),1);
|
||||||
return newItem;
|
return newItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnergyStorage getEnergyStorage() {
|
public IEnergyStorage getEnergyStorage() {
|
||||||
return ENERGY_STORAGE;
|
return ENERGY_STORAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnergy(int energy) {
|
public void setEnergy(int energy) {
|
||||||
ENERGY_STORAGE.setEnergy(energy);
|
ENERGY_STORAGE.setEnergy(energy);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,332 +1,332 @@
|
||||||
package dev.zontreck.thresholds.blocks.entity;
|
package dev.zontreck.otemod.blocks.entity;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.util.ItemUtils;
|
import dev.zontreck.libzontreck.util.ItemUtils;
|
||||||
import dev.zontreck.thresholds.implementation.OutputItemStackHandler;
|
import dev.zontreck.otemod.implementation.OutputItemStackHandler;
|
||||||
import dev.zontreck.thresholds.implementation.energy.OTEEnergy;
|
import dev.zontreck.otemod.implementation.energy.OTEEnergy;
|
||||||
import dev.zontreck.thresholds.implementation.scrubber.MagicalScrubberMenu;
|
import dev.zontreck.otemod.implementation.scrubber.MagicalScrubberMenu;
|
||||||
import dev.zontreck.thresholds.networking.ModMessages;
|
import dev.zontreck.otemod.networking.ModMessages;
|
||||||
import dev.zontreck.thresholds.networking.packets.EnergySyncS2CPacket;
|
import dev.zontreck.otemod.networking.packets.EnergySyncS2CPacket;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.world.Containers;
|
import net.minecraft.world.Containers;
|
||||||
import net.minecraft.world.MenuProvider;
|
import net.minecraft.world.MenuProvider;
|
||||||
import net.minecraft.world.SimpleContainer;
|
import net.minecraft.world.SimpleContainer;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.ContainerData;
|
import net.minecraft.world.inventory.ContainerData;
|
||||||
import net.minecraft.world.item.EnchantedBookItem;
|
import net.minecraft.world.item.EnchantedBookItem;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraft.world.item.enchantment.Enchantment;
|
import net.minecraft.world.item.enchantment.Enchantment;
|
||||||
import net.minecraft.world.item.enchantment.EnchantmentInstance;
|
import net.minecraft.world.item.enchantment.EnchantmentInstance;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.energy.IEnergyStorage;
|
import net.minecraftforge.energy.IEnergyStorage;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class MagicalScrubberBlockEntity extends BlockEntity implements MenuProvider
|
public class MagicalScrubberBlockEntity extends BlockEntity implements MenuProvider
|
||||||
{
|
{
|
||||||
|
|
||||||
protected final ItemStackHandler itemsHandler = new ItemStackHandler(1){
|
protected final ItemStackHandler itemsHandler = new ItemStackHandler(1){
|
||||||
@Override
|
@Override
|
||||||
protected void onContentsChanged(int slot)
|
protected void onContentsChanged(int slot)
|
||||||
{
|
{
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
protected final ItemStackHandler outputItems = new ItemStackHandler(1){
|
protected final ItemStackHandler outputItems = new ItemStackHandler(1){
|
||||||
@Override
|
@Override
|
||||||
protected void onContentsChanged(int slot)
|
protected void onContentsChanged(int slot)
|
||||||
{
|
{
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private ItemStackHandler outputSlot;
|
private ItemStackHandler outputSlot;
|
||||||
|
|
||||||
private final OTEEnergy ENERGY_STORAGE = new OTEEnergy(ENERGY_REQ*3, ENERGY_REQ+512) {
|
private final OTEEnergy ENERGY_STORAGE = new OTEEnergy(ENERGY_REQ*3, ENERGY_REQ+512) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChanged() {
|
public void onChanged() {
|
||||||
setChanged();
|
setChanged();
|
||||||
|
|
||||||
ModMessages.sendToAll(new EnergySyncS2CPacket(energy, getBlockPos()));
|
ModMessages.sendToAll(new EnergySyncS2CPacket(energy, getBlockPos()));
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final int ENERGY_REQ = 1000;
|
private static final int ENERGY_REQ = 1000;
|
||||||
private LazyOptional<IEnergyStorage> lazyEnergyHandler = LazyOptional.empty();
|
private LazyOptional<IEnergyStorage> lazyEnergyHandler = LazyOptional.empty();
|
||||||
|
|
||||||
private LazyOptional<IItemHandler> lazyItemHandler = LazyOptional.empty();
|
private LazyOptional<IItemHandler> lazyItemHandler = LazyOptional.empty();
|
||||||
private LazyOptional<IItemHandler> lazyOutputItems = LazyOptional.empty();
|
private LazyOptional<IItemHandler> lazyOutputItems = LazyOptional.empty();
|
||||||
|
|
||||||
public MagicalScrubberBlockEntity(BlockPos pos, BlockState state) {
|
public MagicalScrubberBlockEntity(BlockPos pos, BlockState state) {
|
||||||
super(ModEntities.MAGICAL_SCRUBBER.get(), pos, state);
|
super(ModEntities.MAGICAL_SCRUBBER.get(), pos, state);
|
||||||
outputSlot = new OutputItemStackHandler(outputItems);
|
outputSlot = new OutputItemStackHandler(outputItems);
|
||||||
|
|
||||||
this.data = new ContainerData() {
|
this.data = new ContainerData() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int get(int p_39284_) {
|
public int get(int p_39284_) {
|
||||||
return switch(p_39284_){
|
return switch(p_39284_){
|
||||||
case 0 -> MagicalScrubberBlockEntity.this.progress;
|
case 0 -> MagicalScrubberBlockEntity.this.progress;
|
||||||
default -> 0;
|
default -> 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(int p_39285_, int p_39286_) {
|
public void set(int p_39285_, int p_39286_) {
|
||||||
switch(p_39285_)
|
switch(p_39285_)
|
||||||
{
|
{
|
||||||
case 0 -> MagicalScrubberBlockEntity.this.progress = p_39286_;
|
case 0 -> MagicalScrubberBlockEntity.this.progress = p_39286_;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final ContainerData data;
|
protected final ContainerData data;
|
||||||
private int progress = 0;
|
private int progress = 0;
|
||||||
|
|
||||||
public static final int MAXIMUM_PROCESSING_TICKS = 175;
|
public static final int MAXIMUM_PROCESSING_TICKS = 175;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public AbstractContainerMenu createMenu(int id, Inventory inv, Player player) {
|
public AbstractContainerMenu createMenu(int id, Inventory inv, Player player) {
|
||||||
return new MagicalScrubberMenu(id, inv, this, this.data);
|
return new MagicalScrubberMenu(id, inv, this, this.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getDisplayName() {
|
public Component getDisplayName() {
|
||||||
return Component.translatable("block.otemod.magical_scrubber");
|
return Component.translatable("block.otemod.magical_scrubber");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side)
|
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side)
|
||||||
{
|
{
|
||||||
if(cap == ForgeCapabilities.ENERGY)
|
if(cap == ForgeCapabilities.ENERGY)
|
||||||
{
|
{
|
||||||
return lazyEnergyHandler.cast();
|
return lazyEnergyHandler.cast();
|
||||||
}
|
}
|
||||||
if(side == Direction.DOWN && cap == ForgeCapabilities.ITEM_HANDLER)
|
if(side == Direction.DOWN && cap == ForgeCapabilities.ITEM_HANDLER)
|
||||||
{
|
{
|
||||||
// Return the output slot only
|
// Return the output slot only
|
||||||
return lazyOutputItems.cast();
|
return lazyOutputItems.cast();
|
||||||
}
|
}
|
||||||
if(cap == ForgeCapabilities.ITEM_HANDLER)
|
if(cap == ForgeCapabilities.ITEM_HANDLER)
|
||||||
{
|
{
|
||||||
return lazyItemHandler.cast();
|
return lazyItemHandler.cast();
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.getCapability(cap,side);
|
return super.getCapability(cap,side);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad()
|
public void onLoad()
|
||||||
{
|
{
|
||||||
super.onLoad();
|
super.onLoad();
|
||||||
lazyItemHandler = LazyOptional.of(()->itemsHandler);
|
lazyItemHandler = LazyOptional.of(()->itemsHandler);
|
||||||
lazyOutputItems = LazyOptional.of(()->outputSlot);
|
lazyOutputItems = LazyOptional.of(()->outputSlot);
|
||||||
lazyEnergyHandler = LazyOptional.of(()->ENERGY_STORAGE);
|
lazyEnergyHandler = LazyOptional.of(()->ENERGY_STORAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invalidateCaps()
|
public void invalidateCaps()
|
||||||
{
|
{
|
||||||
super.invalidateCaps();
|
super.invalidateCaps();
|
||||||
lazyItemHandler.invalidate();
|
lazyItemHandler.invalidate();
|
||||||
lazyOutputItems.invalidate();
|
lazyOutputItems.invalidate();
|
||||||
lazyEnergyHandler.invalidate();
|
lazyEnergyHandler.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void saveAdditional(CompoundTag nbt)
|
protected void saveAdditional(CompoundTag nbt)
|
||||||
{
|
{
|
||||||
nbt.put("inventory", itemsHandler.serializeNBT());
|
nbt.put("inventory", itemsHandler.serializeNBT());
|
||||||
nbt.put("output", outputItems.serializeNBT());
|
nbt.put("output", outputItems.serializeNBT());
|
||||||
nbt.putInt("prog", progress);
|
nbt.putInt("prog", progress);
|
||||||
nbt.putInt("energy", ENERGY_STORAGE.getEnergyStored());
|
nbt.putInt("energy", ENERGY_STORAGE.getEnergyStored());
|
||||||
|
|
||||||
super.saveAdditional(nbt);
|
super.saveAdditional(nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(CompoundTag nbt){
|
public void load(CompoundTag nbt){
|
||||||
super.load(nbt);
|
super.load(nbt);
|
||||||
|
|
||||||
itemsHandler.deserializeNBT(nbt.getCompound("inventory"));
|
itemsHandler.deserializeNBT(nbt.getCompound("inventory"));
|
||||||
outputItems.deserializeNBT(nbt.getCompound("output"));
|
outputItems.deserializeNBT(nbt.getCompound("output"));
|
||||||
progress = nbt.getInt("prog");
|
progress = nbt.getInt("prog");
|
||||||
ENERGY_STORAGE.setEnergy(nbt.getInt("energy"));
|
ENERGY_STORAGE.setEnergy(nbt.getInt("energy"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doDrop()
|
public void doDrop()
|
||||||
{
|
{
|
||||||
SimpleContainer cont = new SimpleContainer(itemsHandler.getSlots());
|
SimpleContainer cont = new SimpleContainer(itemsHandler.getSlots());
|
||||||
for (int i = 0; i < itemsHandler.getSlots(); i++) {
|
for (int i = 0; i < itemsHandler.getSlots(); i++) {
|
||||||
cont.setItem(i, itemsHandler.getStackInSlot(i));
|
cont.setItem(i, itemsHandler.getStackInSlot(i));
|
||||||
}
|
}
|
||||||
cont = new SimpleContainer(outputItems.getSlots());
|
cont = new SimpleContainer(outputItems.getSlots());
|
||||||
for (int i = 0; i < outputItems.getSlots(); i++) {
|
for (int i = 0; i < outputItems.getSlots(); i++) {
|
||||||
cont.setItem(i, outputItems.getStackInSlot(i));
|
cont.setItem(i, outputItems.getStackInSlot(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
Containers.dropContents(this.level, this.worldPosition, cont);
|
Containers.dropContents(this.level, this.worldPosition, cont);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void tick(Level lvl, BlockPos pos, BlockState state, MagicalScrubberBlockEntity entity)
|
public static void tick(Level lvl, BlockPos pos, BlockState state, MagicalScrubberBlockEntity entity)
|
||||||
{
|
{
|
||||||
if(lvl.isClientSide())return;
|
if(lvl.isClientSide())return;
|
||||||
|
|
||||||
if(hasRecipe(entity))
|
if(hasRecipe(entity))
|
||||||
{
|
{
|
||||||
if(!hasEnergy(entity))return; // Halt until sufficient energy has been received
|
if(!hasEnergy(entity))return; // Halt until sufficient energy has been received
|
||||||
entity.progress++;
|
entity.progress++;
|
||||||
setChanged(lvl, pos, state);
|
setChanged(lvl, pos, state);
|
||||||
drain(entity);
|
drain(entity);
|
||||||
|
|
||||||
if(entity.progress >= MagicalScrubberBlockEntity.MAXIMUM_PROCESSING_TICKS)
|
if(entity.progress >= MagicalScrubberBlockEntity.MAXIMUM_PROCESSING_TICKS)
|
||||||
{
|
{
|
||||||
craftItem(entity);
|
craftItem(entity);
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
if(entity.progress>0){
|
if(entity.progress>0){
|
||||||
entity.resetProgress();
|
entity.resetProgress();
|
||||||
setChanged(lvl, pos, state);
|
setChanged(lvl, pos, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void drain(MagicalScrubberBlockEntity entity) {
|
private static void drain(MagicalScrubberBlockEntity entity) {
|
||||||
entity.ENERGY_STORAGE.extractEnergy(ENERGY_REQ, false);
|
entity.ENERGY_STORAGE.extractEnergy(ENERGY_REQ, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean hasEnergy(MagicalScrubberBlockEntity entity) {
|
private static boolean hasEnergy(MagicalScrubberBlockEntity entity) {
|
||||||
return (entity.ENERGY_STORAGE.getEnergyStored() >= ENERGY_REQ);
|
return (entity.ENERGY_STORAGE.getEnergyStored() >= ENERGY_REQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void craftItem(MagicalScrubberBlockEntity entity) {
|
private static void craftItem(MagicalScrubberBlockEntity entity) {
|
||||||
if(hasRecipe(entity))
|
if(hasRecipe(entity))
|
||||||
{
|
{
|
||||||
ItemStack existing = entity.outputItems.getStackInSlot(0);
|
ItemStack existing = entity.outputItems.getStackInSlot(0);
|
||||||
ItemStack main = entity.itemsHandler.getStackInSlot(0);
|
ItemStack main = entity.itemsHandler.getStackInSlot(0);
|
||||||
|
|
||||||
//Map<Enchantment, Integer> enchants = main.getAllEnchantments();
|
//Map<Enchantment, Integer> enchants = main.getAllEnchantments();
|
||||||
Map<Enchantment, Integer> enchantments = ItemUtils.getEnchantments(main.copy());
|
Map<Enchantment, Integer> enchantments = ItemUtils.getEnchantments(main.copy());
|
||||||
|
|
||||||
if(enchantments.size()>0)
|
if(enchantments.size()>0)
|
||||||
{
|
{
|
||||||
Iterator<Map.Entry<Enchantment,Integer>> iEntries = enchantments.entrySet().iterator();
|
Iterator<Map.Entry<Enchantment,Integer>> iEntries = enchantments.entrySet().iterator();
|
||||||
try{
|
try{
|
||||||
Map.Entry<Enchantment,Integer> entry = iEntries.next();
|
Map.Entry<Enchantment,Integer> entry = iEntries.next();
|
||||||
EnchantmentInstance eInst = new EnchantmentInstance(entry.getKey(), entry.getValue());
|
EnchantmentInstance eInst = new EnchantmentInstance(entry.getKey(), entry.getValue());
|
||||||
existing = EnchantedBookItem.createForEnchantment(eInst);
|
existing = EnchantedBookItem.createForEnchantment(eInst);
|
||||||
iEntries.remove();
|
iEntries.remove();
|
||||||
main = makeOutputItem(main.copy());
|
main = makeOutputItem(main.copy());
|
||||||
while(iEntries.hasNext())
|
while(iEntries.hasNext())
|
||||||
{
|
{
|
||||||
entry = iEntries.next();
|
entry = iEntries.next();
|
||||||
main.enchant(entry.getKey(), entry.getValue());
|
main.enchant(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}catch(Exception E)
|
}catch(Exception E)
|
||||||
{
|
{
|
||||||
entity.outputItems.setStackInSlot(0, main);
|
entity.outputItems.setStackInSlot(0, main);
|
||||||
entity.itemsHandler.extractItem(0, 1, false);
|
entity.itemsHandler.extractItem(0, 1, false);
|
||||||
entity.resetProgress();
|
entity.resetProgress();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(enchantments.size()==0){
|
if(enchantments.size()==0){
|
||||||
entity.itemsHandler.extractItem(0, 1, false);
|
entity.itemsHandler.extractItem(0, 1, false);
|
||||||
}else entity.itemsHandler.setStackInSlot(0, main);
|
}else entity.itemsHandler.setStackInSlot(0, main);
|
||||||
|
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
existing.setCount(existing.getCount()+1);
|
existing.setCount(existing.getCount()+1);
|
||||||
if(existing.is(Items.AIR))
|
if(existing.is(Items.AIR))
|
||||||
{
|
{
|
||||||
existing = makeOutputItem(entity.itemsHandler.getStackInSlot(0));
|
existing = makeOutputItem(entity.itemsHandler.getStackInSlot(0));
|
||||||
}
|
}
|
||||||
entity.itemsHandler.extractItem(0, 1, false);
|
entity.itemsHandler.extractItem(0, 1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.outputItems.setStackInSlot(0, existing);
|
entity.outputItems.setStackInSlot(0, existing);
|
||||||
entity.resetProgress();
|
entity.resetProgress();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean hasRecipe(MagicalScrubberBlockEntity entity) {
|
private static boolean hasRecipe(MagicalScrubberBlockEntity entity) {
|
||||||
SimpleContainer inventory = new SimpleContainer(entity.itemsHandler.getSlots());
|
SimpleContainer inventory = new SimpleContainer(entity.itemsHandler.getSlots());
|
||||||
for(int i=0;i<entity.itemsHandler.getSlots();i++)
|
for(int i=0;i<entity.itemsHandler.getSlots();i++)
|
||||||
{
|
{
|
||||||
inventory.setItem(i, entity.itemsHandler.getStackInSlot(i));
|
inventory.setItem(i, entity.itemsHandler.getStackInSlot(i));
|
||||||
}
|
}
|
||||||
SimpleContainer output = new SimpleContainer(entity.outputItems.getSlots());
|
SimpleContainer output = new SimpleContainer(entity.outputItems.getSlots());
|
||||||
for(int i=0;i<entity.outputItems.getSlots();i++)
|
for(int i=0;i<entity.outputItems.getSlots();i++)
|
||||||
{
|
{
|
||||||
output.setItem(i, entity.outputItems.getStackInSlot(i));
|
output.setItem(i, entity.outputItems.getStackInSlot(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
boolean hasAnItem = !entity.itemsHandler.getStackInSlot(0).isEmpty();
|
boolean hasAnItem = !entity.itemsHandler.getStackInSlot(0).isEmpty();
|
||||||
|
|
||||||
ItemStack result = null;
|
ItemStack result = null;
|
||||||
if(hasAnItem)
|
if(hasAnItem)
|
||||||
{
|
{
|
||||||
result = makeOutputItem(entity.itemsHandler.getStackInSlot(0));
|
result = makeOutputItem(entity.itemsHandler.getStackInSlot(0));
|
||||||
|
|
||||||
}
|
}
|
||||||
return hasAnItem && canInsertIntoOutput(output, result);
|
return hasAnItem && canInsertIntoOutput(output, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean canInsertIntoOutput(SimpleContainer inventory, ItemStack result) {
|
private static boolean canInsertIntoOutput(SimpleContainer inventory, ItemStack result) {
|
||||||
ItemStack existing = inventory.getItem(0);
|
ItemStack existing = inventory.getItem(0);
|
||||||
boolean stackCompat = (existing.getMaxStackSize() > existing.getCount());
|
boolean stackCompat = (existing.getMaxStackSize() > existing.getCount());
|
||||||
boolean sameType = (existing.getItem() == result.getItem());
|
boolean sameType = (existing.getItem() == result.getItem());
|
||||||
boolean outputEmpty = existing.isEmpty();
|
boolean outputEmpty = existing.isEmpty();
|
||||||
|
|
||||||
if(outputEmpty)return true;
|
if(outputEmpty)return true;
|
||||||
return (stackCompat && sameType);
|
return (stackCompat && sameType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetProgress() {
|
private void resetProgress() {
|
||||||
progress=0;
|
progress=0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static ItemStack makeOutputItem(ItemStack original)
|
protected static ItemStack makeOutputItem(ItemStack original)
|
||||||
{
|
{
|
||||||
ItemStack newItem = new ItemStack(original.getItem(),1);
|
ItemStack newItem = new ItemStack(original.getItem(),1);
|
||||||
return newItem;
|
return newItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnergyStorage getEnergyStorage() {
|
public IEnergyStorage getEnergyStorage() {
|
||||||
return ENERGY_STORAGE;
|
return ENERGY_STORAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnergy(int energy) {
|
public void setEnergy(int energy) {
|
||||||
ENERGY_STORAGE.setEnergy(energy);
|
ENERGY_STORAGE.setEnergy(energy);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,31 +1,32 @@
|
||||||
package dev.zontreck.thresholds.blocks.entity;
|
package dev.zontreck.otemod.blocks.entity;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.blocks.ModBlocks;
|
import dev.zontreck.otemod.blocks.CompressionChamberBlock;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import dev.zontreck.otemod.blocks.ModBlocks;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
public class ModEntities {
|
|
||||||
|
public class ModEntities {
|
||||||
public static final DeferredRegister<BlockEntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, ThresholdsMod.MOD_ID);
|
|
||||||
|
public static final DeferredRegister<BlockEntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, OTEMod.MOD_ID);
|
||||||
public static final RegistryObject <BlockEntityType <ItemScrubberBlockEntity>> ITEM_SCRUBBER = ENTITIES.register("item_scrubber", ()-> BlockEntityType.Builder.of(ItemScrubberBlockEntity::new, ModBlocks.ITEM_SCRUBBER.get()).build(null));
|
|
||||||
|
public static final RegistryObject <BlockEntityType <ItemScrubberBlockEntity>> ITEM_SCRUBBER = ENTITIES.register("item_scrubber", ()-> BlockEntityType.Builder.of(ItemScrubberBlockEntity::new, ModBlocks.ITEM_SCRUBBER.get()).build(null));
|
||||||
public static final RegistryObject <BlockEntityType <MagicalScrubberBlockEntity>> MAGICAL_SCRUBBER = ENTITIES.register("magical_scrubber", ()-> BlockEntityType.Builder.of(MagicalScrubberBlockEntity::new, ModBlocks.MAGICAL_SCRUBBER.get()).build(null));
|
|
||||||
|
public static final RegistryObject <BlockEntityType <MagicalScrubberBlockEntity>> MAGICAL_SCRUBBER = ENTITIES.register("magical_scrubber", ()-> BlockEntityType.Builder.of(MagicalScrubberBlockEntity::new, ModBlocks.MAGICAL_SCRUBBER.get()).build(null));
|
||||||
public static final ResourceLocation PARALLAX_BLOCK = new ResourceLocation(ThresholdsMod.MOD_ID, "parallax_block");
|
|
||||||
|
public static final ResourceLocation PARALLAX_BLOCK = new ResourceLocation(OTEMod.MOD_ID, "parallax_block");
|
||||||
public static final RegistryObject<BlockEntityType<CompressionChamberBlockEntity>> COMPRESSION_CHAMBER = ENTITIES.register("compression_chamber", ()->BlockEntityType.Builder.of(CompressionChamberBlockEntity::new, ModBlocks.COMPRESSION_CHAMBER_BLOCK.get()).build(null));
|
|
||||||
|
public static final RegistryObject<BlockEntityType<CompressionChamberBlockEntity>> COMPRESSION_CHAMBER = ENTITIES.register("compression_chamber", ()->BlockEntityType.Builder.of(CompressionChamberBlockEntity::new, ModBlocks.COMPRESSION_CHAMBER_BLOCK.get()).build(null));
|
||||||
public static final RegistryObject <BlockEntityType <ParallaxWindowEntity>> PARALLAX_WINDOW_ENTITY = ENTITIES.register("parallax_window", ()->BlockEntityType.Builder.of(ParallaxWindowEntity::new, ModBlocks.LIMINAL_WINDOW.get()).build(null));
|
|
||||||
|
public static final RegistryObject <BlockEntityType <ParallaxWindowEntity>> PARALLAX_WINDOW_ENTITY = ENTITIES.register("parallax_window", ()->BlockEntityType.Builder.of(ParallaxWindowEntity::new, ModBlocks.LIMINAL_WINDOW.get()).build(null));
|
||||||
|
|
||||||
public static void register(IEventBus eventBus)
|
|
||||||
{
|
public static void register(IEventBus eventBus)
|
||||||
ENTITIES.register(eventBus);
|
{
|
||||||
}
|
ENTITIES.register(eventBus);
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -1,11 +1,14 @@
|
||||||
package dev.zontreck.thresholds.blocks.entity;
|
package dev.zontreck.otemod.blocks.entity;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import org.joml.Matrix4f;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
|
@ -1,41 +1,41 @@
|
||||||
package dev.zontreck.thresholds.blocks.types;
|
package dev.zontreck.otemod.blocks.types;
|
||||||
|
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Direction.Plane;
|
import net.minecraft.core.Direction.Plane;
|
||||||
import net.minecraft.world.level.block.IronBarsBlock;
|
import net.minecraft.world.level.block.IronBarsBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||||
|
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
|
|
||||||
/** Pane block with sensible culling */
|
/** Pane block with sensible culling */
|
||||||
public class AlternatePaneBlock extends IronBarsBlock {
|
public class AlternatePaneBlock extends IronBarsBlock {
|
||||||
public static final EnumMap<Direction,BooleanProperty> DIRECTIONS;
|
public static final EnumMap<Direction,BooleanProperty> DIRECTIONS;
|
||||||
static {
|
static {
|
||||||
DIRECTIONS = new EnumMap<>(Direction.class);
|
DIRECTIONS = new EnumMap<>(Direction.class);
|
||||||
DIRECTIONS.put(Direction.NORTH, NORTH);
|
DIRECTIONS.put(Direction.NORTH, NORTH);
|
||||||
DIRECTIONS.put(Direction.EAST, EAST);
|
DIRECTIONS.put(Direction.EAST, EAST);
|
||||||
DIRECTIONS.put(Direction.SOUTH, SOUTH);
|
DIRECTIONS.put(Direction.SOUTH, SOUTH);
|
||||||
DIRECTIONS.put(Direction.WEST, WEST);
|
DIRECTIONS.put(Direction.WEST, WEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlternatePaneBlock(Properties builder) {
|
public AlternatePaneBlock(Properties builder) {
|
||||||
super(builder);
|
super(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean skipRendering(BlockState state, BlockState adjacentBlockState, Direction side) {
|
public boolean skipRendering(BlockState state, BlockState adjacentBlockState, Direction side) {
|
||||||
// cull top and bottom if all props that we have are contained in the above or below
|
// cull top and bottom if all props that we have are contained in the above or below
|
||||||
if (adjacentBlockState.getBlock() == this && side.getAxis().isVertical()) {
|
if (adjacentBlockState.getBlock() == this && side.getAxis().isVertical()) {
|
||||||
for (Direction dir : Plane.HORIZONTAL) {
|
for (Direction dir : Plane.HORIZONTAL) {
|
||||||
BooleanProperty prop = DIRECTIONS.get(dir);
|
BooleanProperty prop = DIRECTIONS.get(dir);
|
||||||
if (state.getValue(prop) && !adjacentBlockState.getValue(prop)) {
|
if (state.getValue(prop) && !adjacentBlockState.getValue(prop)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.skipRendering(state, adjacentBlockState, side);
|
return super.skipRendering(state, adjacentBlockState, side);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,133 +1,133 @@
|
||||||
package dev.zontreck.thresholds.chat;
|
package dev.zontreck.otemod.chat;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
import dev.zontreck.libzontreck.chat.HoverTip;
|
import dev.zontreck.libzontreck.chat.HoverTip;
|
||||||
import dev.zontreck.libzontreck.events.ProfileLoadedEvent;
|
import dev.zontreck.libzontreck.events.ProfileLoadedEvent;
|
||||||
import dev.zontreck.libzontreck.events.ProfileUnloadingEvent;
|
import dev.zontreck.libzontreck.events.ProfileUnloadingEvent;
|
||||||
import dev.zontreck.libzontreck.profiles.Profile;
|
import dev.zontreck.libzontreck.profiles.Profile;
|
||||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import dev.zontreck.libzontreck.util.ItemUtils;
|
import dev.zontreck.libzontreck.util.ItemUtils;
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.configs.ThresholdsServerConfig;
|
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||||
import dev.zontreck.thresholds.configs.PlayerFlyCache;
|
import dev.zontreck.otemod.configs.PlayerFlyCache;
|
||||||
import dev.zontreck.thresholds.enchantments.ModEnchantments;
|
import dev.zontreck.otemod.enchantments.ModEnchantments;
|
||||||
import dev.zontreck.thresholds.implementation.vault.StarterProvider;
|
import dev.zontreck.otemod.implementation.vault.StarterProvider;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.Style;
|
import net.minecraft.network.chat.Style;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.entity.player.Abilities;
|
import net.minecraft.world.entity.player.Abilities;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraftforge.event.ServerChatEvent;
|
import net.minecraftforge.event.ServerChatEvent;
|
||||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||||
|
|
||||||
@EventBusSubscriber(modid= ThresholdsMod.MOD_ID, bus=Mod.EventBusSubscriber.Bus.FORGE)
|
@EventBusSubscriber(modid=OTEMod.MOD_ID, bus=Mod.EventBusSubscriber.Bus.FORGE)
|
||||||
public class ChatServerOverride {
|
public class ChatServerOverride {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onJoin(final ProfileLoadedEvent ev)
|
public void onJoin(final ProfileLoadedEvent ev)
|
||||||
{
|
{
|
||||||
//Player joined, send custom alert
|
//Player joined, send custom alert
|
||||||
ServerPlayer play = ev.player;
|
ServerPlayer play = ev.player;
|
||||||
Profile prof = ev.profile;
|
Profile prof = ev.profile;
|
||||||
|
|
||||||
|
|
||||||
if(prof.flying)
|
if(prof.flying)
|
||||||
{
|
{
|
||||||
play.getAbilities().flying=true;
|
play.getAbilities().flying=true;
|
||||||
play.onUpdateAbilities();
|
play.onUpdateAbilities();
|
||||||
}
|
}
|
||||||
|
|
||||||
Abilities playerAbilities = play.getAbilities();
|
Abilities playerAbilities = play.getAbilities();
|
||||||
boolean mayFly = false;
|
boolean mayFly = false;
|
||||||
ItemStack feet = play.getItemBySlot(EquipmentSlot.FEET);
|
ItemStack feet = play.getItemBySlot(EquipmentSlot.FEET);
|
||||||
if(ItemUtils.getEnchantmentLevel(ModEnchantments.FLIGHT_ENCHANTMENT.get(), feet)>0)mayFly = true;
|
if(ItemUtils.getEnchantmentLevel(ModEnchantments.FLIGHT_ENCHANTMENT.get(), feet)>0)mayFly = true;
|
||||||
|
|
||||||
playerAbilities.mayfly=mayFly;
|
playerAbilities.mayfly=mayFly;
|
||||||
PlayerFlyCache c = PlayerFlyCache.cachePlayer(play);
|
PlayerFlyCache c = PlayerFlyCache.cachePlayer(play);
|
||||||
c.Flying=prof.flying;
|
c.Flying=prof.flying;
|
||||||
c.FlyEnabled = mayFly;
|
c.FlyEnabled = mayFly;
|
||||||
c.Assert(play);
|
c.Assert(play);
|
||||||
|
|
||||||
if(StarterProvider.exists())
|
if(StarterProvider.exists())
|
||||||
ThresholdsMod.checkFirstJoin(ev.player);
|
OTEMod.checkFirstJoin(ev.player);
|
||||||
|
|
||||||
if(!ThresholdsServerConfig.USE_CUSTOM_JOINLEAVE.get()) return;
|
if(!OTEServerConfig.USE_CUSTOM_JOINLEAVE.get()) return;
|
||||||
|
|
||||||
ChatHelpers.broadcast(ChatHelpers.macro("!Dark_Gray![!Dark_Green!+!Dark_Gray!] !Bold!!Dark_Aqua![0]",prof.nickname), ev.level.getServer());
|
ChatHelpers.broadcast(ChatHelpers.macro("!Dark_Gray![!Dark_Green!+!Dark_Gray!] !Bold!!Dark_Aqua![0]",prof.nickname), ev.level.getServer());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onLeave(ProfileUnloadingEvent ev)
|
public void onLeave(ProfileUnloadingEvent ev)
|
||||||
{
|
{
|
||||||
// Get player profile, send disconnect alert, then commit profile and remove it from memory
|
// Get player profile, send disconnect alert, then commit profile and remove it from memory
|
||||||
Profile px=ev.profile;
|
Profile px=ev.profile;
|
||||||
|
|
||||||
|
|
||||||
if(px==null)return;
|
if(px==null)return;
|
||||||
|
|
||||||
if(!ThresholdsServerConfig.USE_CUSTOM_JOINLEAVE.get()) return;
|
if(!OTEServerConfig.USE_CUSTOM_JOINLEAVE.get()) return;
|
||||||
|
|
||||||
// Send the alert
|
// Send the alert
|
||||||
ChatHelpers.broadcast(ChatHelpers.macro("!Dark_Gray![!Dark_Red!-!Dark_Gray!] !Bold!!Dark_Aqua![0]", px.nickname), px.player.server);
|
ChatHelpers.broadcast(ChatHelpers.macro("!Dark_Gray![!Dark_Red!-!Dark_Gray!] !Bold!!Dark_Aqua![0]", px.nickname), px.player.server);
|
||||||
|
|
||||||
|
|
||||||
px.flying=px.player.getAbilities().flying;
|
px.flying=px.player.getAbilities().flying;
|
||||||
ev.setCanceled(true);
|
ev.setCanceled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onClone(final PlayerEvent.Clone ev)
|
public void onClone(final PlayerEvent.Clone ev)
|
||||||
{
|
{
|
||||||
if(ev.getEntity().level().isClientSide)return;
|
if(ev.getEntity().level().isClientSide)return;
|
||||||
// Fix for fly ability not copying to new instance on death or other circumstances
|
// Fix for fly ability not copying to new instance on death or other circumstances
|
||||||
Player old = ev.getOriginal();
|
Player old = ev.getOriginal();
|
||||||
Player n = ev.getEntity();
|
Player n = ev.getEntity();
|
||||||
|
|
||||||
PlayerFlyCache c = PlayerFlyCache.cachePlayer((ServerPlayer)old);
|
PlayerFlyCache c = PlayerFlyCache.cachePlayer((ServerPlayer)old);
|
||||||
c.Assert((ServerPlayer)n);
|
c.Assert((ServerPlayer)n);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onChat(final ServerChatEvent ev){
|
public void onChat(final ServerChatEvent ev){
|
||||||
if(ev.getPlayer().level().isClientSide)return;
|
if(ev.getPlayer().level().isClientSide)return;
|
||||||
// Player has chatted, apply override
|
// Player has chatted, apply override
|
||||||
if(!ThresholdsServerConfig.USE_CUSTOM_CHATREPLACER.get()) return;
|
if(!OTEServerConfig.USE_CUSTOM_CHATREPLACER.get()) return;
|
||||||
|
|
||||||
|
|
||||||
ServerPlayer sp = ev.getPlayer();
|
ServerPlayer sp = ev.getPlayer();
|
||||||
// Get profile
|
// Get profile
|
||||||
Profile XD=null;
|
Profile XD=null;
|
||||||
try {
|
try {
|
||||||
XD = Profile.get_profile_of(sp.getStringUUID());
|
XD = Profile.get_profile_of(sp.getStringUUID());
|
||||||
} catch (UserProfileNotYetExistsException e) {
|
} catch (UserProfileNotYetExistsException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Override the chat!
|
// Override the chat!
|
||||||
String prefixStr = "";
|
String prefixStr = "";
|
||||||
if(XD.prefix != ""){
|
if(XD.prefix != ""){
|
||||||
prefixStr = ChatColor.DARK_GRAY + "[" + ChatColor.BOLD + XD.prefix_color + XD.prefix + ChatColor.resetChat() + ChatColor.DARK_GRAY + "] ";
|
prefixStr = ChatColor.DARK_GRAY + "[" + ChatColor.BOLD + XD.prefix_color + XD.prefix + ChatColor.resetChat() + ChatColor.DARK_GRAY + "] ";
|
||||||
}
|
}
|
||||||
|
|
||||||
String msg = ev.getRawText();
|
String msg = ev.getRawText();
|
||||||
msg= ChatColor.doColors(msg);
|
msg= ChatColor.doColors(msg);
|
||||||
|
|
||||||
String nameStr = ChatColor.resetChat() + "< "+ XD.name_color + XD.nickname + ChatColor.resetChat() + " >";
|
String nameStr = ChatColor.resetChat() + "< "+ XD.name_color + XD.nickname + ChatColor.resetChat() + " >";
|
||||||
String message = ": "+XD.chat_color + msg;
|
String message = ": "+XD.chat_color + msg;
|
||||||
Style hover = Style.EMPTY;
|
Style hover = Style.EMPTY;
|
||||||
hover=hover.withFont(Style.DEFAULT_FONT).withHoverEvent(HoverTip.get(ChatColor.MINECOIN_GOLD+"User Name: "+XD.username));
|
hover=hover.withFont(Style.DEFAULT_FONT).withHoverEvent(HoverTip.get(ChatColor.MINECOIN_GOLD+"User Name: "+XD.username));
|
||||||
ev.setCanceled(true);
|
ev.setCanceled(true);
|
||||||
|
|
||||||
ChatHelpers.broadcast(Component.literal(prefixStr + nameStr + message).setStyle(hover), ev.getPlayer().server);
|
ChatHelpers.broadcast(Component.literal(prefixStr + nameStr + message).setStyle(hover), ev.getPlayer().server);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,8 +1,9 @@
|
||||||
package dev.zontreck.thresholds.client.renderer;
|
package dev.zontreck.otemod.client.renderer;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
import dev.zontreck.thresholds.blocks.entity.ParallaxWindowEntity;
|
import dev.zontreck.otemod.blocks.ParallaxWindow;
|
||||||
|
import dev.zontreck.otemod.blocks.entity.ParallaxWindowEntity;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
|
@ -1,110 +1,110 @@
|
||||||
package dev.zontreck.thresholds.commands;
|
package dev.zontreck.otemod.commands;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.commands.items.ShareItemInChatCommand;
|
import dev.zontreck.otemod.commands.items.ShareItemInChatCommand;
|
||||||
import dev.zontreck.thresholds.commands.profilecmds.ChatColorCommand;
|
import dev.zontreck.otemod.commands.profilecmds.ChatColorCommand;
|
||||||
import dev.zontreck.thresholds.commands.profilecmds.NameColorCommand;
|
import dev.zontreck.otemod.commands.profilecmds.NameColorCommand;
|
||||||
import dev.zontreck.thresholds.commands.profilecmds.NickCommand;
|
import dev.zontreck.otemod.commands.profilecmds.NickCommand;
|
||||||
import dev.zontreck.thresholds.commands.profilecmds.PrefixColorCommand;
|
import dev.zontreck.otemod.commands.profilecmds.PrefixColorCommand;
|
||||||
import dev.zontreck.thresholds.commands.profilecmds.PrefixCommand;
|
import dev.zontreck.otemod.commands.profilecmds.PrefixCommand;
|
||||||
import dev.zontreck.thresholds.commands.vaults.StarterCommand;
|
import dev.zontreck.otemod.commands.vaults.StarterCommand;
|
||||||
import dev.zontreck.thresholds.commands.vaults.TrashCommand;
|
import dev.zontreck.otemod.commands.vaults.TrashCommand;
|
||||||
import dev.zontreck.thresholds.commands.vaults.VaultCommand;
|
import dev.zontreck.otemod.commands.vaults.VaultCommand;
|
||||||
import dev.zontreck.thresholds.commands.zschem.LoadSchem;
|
import dev.zontreck.otemod.commands.zschem.LoadSchem;
|
||||||
import dev.zontreck.thresholds.commands.zschem.Place;
|
import dev.zontreck.otemod.commands.zschem.Place;
|
||||||
import dev.zontreck.thresholds.commands.zschem.PlaceAsAir;
|
import dev.zontreck.otemod.commands.zschem.PlaceAsAir;
|
||||||
import dev.zontreck.thresholds.commands.zschem.SaveSchem;
|
import dev.zontreck.otemod.commands.zschem.SaveSchem;
|
||||||
import dev.zontreck.thresholds.commands.zschem.SetPos1;
|
import dev.zontreck.otemod.commands.zschem.SetPos1;
|
||||||
import dev.zontreck.thresholds.commands.zschem.SetPos2;
|
import dev.zontreck.otemod.commands.zschem.SetPos2;
|
||||||
import dev.zontreck.thresholds.configs.ThresholdsServerConfig;
|
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||||
|
|
||||||
@EventBusSubscriber(modid= ThresholdsMod.MOD_ID,bus=Mod.EventBusSubscriber.Bus.FORGE)
|
@EventBusSubscriber(modid=OTEMod.MOD_ID,bus=Mod.EventBusSubscriber.Bus.FORGE)
|
||||||
public class CommandRegistry {
|
public class CommandRegistry {
|
||||||
public static Map<String,Long> CommandCooldownRegistry = new HashMap<>();
|
public static Map<String,Long> CommandCooldownRegistry = new HashMap<>();
|
||||||
|
|
||||||
public static void markUsed(String cmd)
|
public static void markUsed(String cmd)
|
||||||
{
|
{
|
||||||
// Command was used, mark the current time
|
// Command was used, mark the current time
|
||||||
CommandCooldownRegistry.put(cmd, Instant.now().getEpochSecond());
|
CommandCooldownRegistry.put(cmd, Instant.now().getEpochSecond());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canUse(String cmd)
|
public static boolean canUse(String cmd)
|
||||||
{
|
{
|
||||||
if(!CommandCooldownRegistry.containsKey(cmd)) return true;
|
if(!CommandCooldownRegistry.containsKey(cmd)) return true;
|
||||||
long lastUse = CommandCooldownRegistry.get(cmd);
|
long lastUse = CommandCooldownRegistry.get(cmd);
|
||||||
switch(cmd)
|
switch(cmd)
|
||||||
{
|
{
|
||||||
case "rtp":
|
case "rtp":
|
||||||
{
|
{
|
||||||
if(Instant.now().getEpochSecond() > lastUse+Long.parseLong(String.valueOf(ThresholdsServerConfig.RTP_COOLDOWN))){
|
if(Instant.now().getEpochSecond() > lastUse+Long.parseLong(String.valueOf(OTEServerConfig.RTP_COOLDOWN))){
|
||||||
CommandCooldownRegistry.remove(cmd);
|
CommandCooldownRegistry.remove(cmd);
|
||||||
return true;
|
return true;
|
||||||
}else return false;
|
}else return false;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
CommandCooldownRegistry.remove(cmd);
|
CommandCooldownRegistry.remove(cmd);
|
||||||
return true; // cooldown not yet made
|
return true; // cooldown not yet made
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public static String getRemaining(String string) {
|
public static String getRemaining(String string) {
|
||||||
long now = Instant.now().getEpochSecond();
|
long now = Instant.now().getEpochSecond();
|
||||||
if(!CommandCooldownRegistry.containsKey(string))return "0";
|
if(!CommandCooldownRegistry.containsKey(string))return "0";
|
||||||
long used = CommandCooldownRegistry.get(string);
|
long used = CommandCooldownRegistry.get(string);
|
||||||
long cmd_time = 0L;
|
long cmd_time = 0L;
|
||||||
switch(string)
|
switch(string)
|
||||||
{
|
{
|
||||||
case "rtp":
|
case "rtp":
|
||||||
{
|
{
|
||||||
cmd_time = Long.parseLong(String.valueOf(ThresholdsServerConfig.RTP_COOLDOWN));
|
cmd_time = Long.parseLong(String.valueOf(OTEServerConfig.RTP_COOLDOWN));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
cmd_time = 0L;
|
cmd_time = 0L;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
used+=cmd_time;
|
used+=cmd_time;
|
||||||
long diff = used-now;
|
long diff = used-now;
|
||||||
if(diff<0)diff=0L;
|
if(diff<0)diff=0L;
|
||||||
return String.valueOf(diff);
|
return String.valueOf(diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onRegisterCommands(final RegisterCommandsEvent ev)
|
public void onRegisterCommands(final RegisterCommandsEvent ev)
|
||||||
{
|
{
|
||||||
|
|
||||||
ChatColorCommand.register(ev.getDispatcher());
|
ChatColorCommand.register(ev.getDispatcher());
|
||||||
NameColorCommand.register(ev.getDispatcher());
|
NameColorCommand.register(ev.getDispatcher());
|
||||||
PrefixColorCommand.register(ev.getDispatcher());
|
PrefixColorCommand.register(ev.getDispatcher());
|
||||||
PrefixCommand.register(ev.getDispatcher());
|
PrefixCommand.register(ev.getDispatcher());
|
||||||
NickCommand.register(ev.getDispatcher());
|
NickCommand.register(ev.getDispatcher());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VaultCommand.register(ev.getDispatcher());
|
VaultCommand.register(ev.getDispatcher());
|
||||||
TrashCommand.register(ev.getDispatcher());
|
TrashCommand.register(ev.getDispatcher());
|
||||||
|
|
||||||
SetPos1.register(ev.getDispatcher());
|
SetPos1.register(ev.getDispatcher());
|
||||||
SetPos2.register(ev.getDispatcher());
|
SetPos2.register(ev.getDispatcher());
|
||||||
SaveSchem.register(ev.getDispatcher());
|
SaveSchem.register(ev.getDispatcher());
|
||||||
LoadSchem.register(ev.getDispatcher());
|
LoadSchem.register(ev.getDispatcher());
|
||||||
Place.register(ev.getDispatcher());
|
Place.register(ev.getDispatcher());
|
||||||
PlaceAsAir.register(ev.getDispatcher());
|
PlaceAsAir.register(ev.getDispatcher());
|
||||||
|
|
||||||
ShareItemInChatCommand.register(ev.getDispatcher());
|
ShareItemInChatCommand.register(ev.getDispatcher());
|
||||||
StarterCommand.register(ev.getDispatcher());
|
StarterCommand.register(ev.getDispatcher());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,52 +1,52 @@
|
||||||
package dev.zontreck.thresholds.commands;
|
package dev.zontreck.otemod.commands;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
|
||||||
public class FlyCommand {
|
public class FlyCommand {
|
||||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||||
{
|
{
|
||||||
dispatcher.register(Commands.literal("fly").executes(FlyCommand::Fly));
|
dispatcher.register(Commands.literal("fly").executes(FlyCommand::Fly));
|
||||||
|
|
||||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||||
//String arg = StringArgumentType.getString(command, "nickname");
|
//String arg = StringArgumentType.getString(command, "nickname");
|
||||||
//return setHome(command.getSource(), arg);
|
//return setHome(command.getSource(), arg);
|
||||||
//}));
|
//}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int Fly(CommandContext<CommandSourceStack> ctx2)
|
private static int Fly(CommandContext<CommandSourceStack> ctx2)
|
||||||
{
|
{
|
||||||
// Request homes
|
// Request homes
|
||||||
// String homeName = "";
|
// String homeName = "";
|
||||||
// CommandSourceStack ctx = ctx2.getSource();
|
// CommandSourceStack ctx = ctx2.getSource();
|
||||||
// homeName = StringArgumentType.getString(ctx2, "nickname");
|
// homeName = StringArgumentType.getString(ctx2, "nickname");
|
||||||
// if(homeName==null)return 0;
|
// if(homeName==null)return 0;
|
||||||
CommandSourceStack ctx = ctx2.getSource();
|
CommandSourceStack ctx = ctx2.getSource();
|
||||||
|
|
||||||
ServerPlayer p = (ServerPlayer)ctx.getEntity();
|
ServerPlayer p = (ServerPlayer)ctx.getEntity();
|
||||||
if(p==null)return 1;
|
if(p==null)return 1;
|
||||||
|
|
||||||
if(p.getAbilities().mayfly){
|
if(p.getAbilities().mayfly){
|
||||||
p.getAbilities().mayfly=false;
|
p.getAbilities().mayfly=false;
|
||||||
p.getAbilities().flying=false;
|
p.getAbilities().flying=false;
|
||||||
p.onUpdateAbilities();
|
p.onUpdateAbilities();
|
||||||
|
|
||||||
|
|
||||||
ctx.sendSystemMessage(Component.literal(ThresholdsMod.ThresholdsPrefix + ChatColor.DARK_PURPLE + " Your ability to fly has been disabled"));
|
ctx.sendSystemMessage(Component.literal(OTEMod.OTEPrefix + ChatColor.DARK_PURPLE + " Your ability to fly has been disabled"));
|
||||||
}else {
|
}else {
|
||||||
p.getAbilities().mayfly=true;
|
p.getAbilities().mayfly=true;
|
||||||
p.onUpdateAbilities();
|
p.onUpdateAbilities();
|
||||||
|
|
||||||
ctx.sendSystemMessage(Component.literal(ThresholdsMod.ThresholdsPrefix + ChatColor.DARK_PURPLE + " You can now fly"));
|
ctx.sendSystemMessage(Component.literal(OTEMod.OTEPrefix + ChatColor.DARK_PURPLE + " You can now fly"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package dev.zontreck.thresholds.commands.antigrief;
|
package dev.zontreck.otemod.commands.antigrief;
|
||||||
|
|
||||||
// This will accelerate the healing queue, not do it instantly!
|
// This will accelerate the healing queue, not do it instantly!
|
||||||
// The queue will get processed at a rate of 10* the configured rate.
|
// The queue will get processed at a rate of 10* the configured rate.
|
||||||
public class HealNow
|
public class HealNow
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
package dev.zontreck.thresholds.commands.items;
|
package dev.zontreck.otemod.commands.items;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import dev.zontreck.libzontreck.chat.HoverTip;
|
import dev.zontreck.libzontreck.chat.HoverTip;
|
||||||
import dev.zontreck.libzontreck.profiles.Profile;
|
import dev.zontreck.libzontreck.profiles.Profile;
|
||||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
|
@ -36,7 +36,7 @@ public class ShareItemInChatCommand {
|
||||||
ItemStack is = play.getItemInHand(InteractionHand.MAIN_HAND);
|
ItemStack is = play.getItemInHand(InteractionHand.MAIN_HAND);
|
||||||
if(is.getItem() instanceof AirItem)
|
if(is.getItem() instanceof AirItem)
|
||||||
{
|
{
|
||||||
play.displayClientMessage(ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Red!You cannot share air in the chat."), false);
|
play.displayClientMessage(ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Red!You cannot share air in the chat."), false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,11 +47,11 @@ public class ShareItemInChatCommand {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
MutableComponent component = ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix).append(is.getDisplayName()).append(ChatHelpers.macro(" !White!-!Dark_Purple! Hover here to see the item that "+prof.name_color+prof.nickname+"!Dark_Purple! shared"));
|
MutableComponent component = ChatHelpers.macro(OTEMod.OTEPrefix).append(is.getDisplayName()).append(ChatHelpers.macro(" !White!-!Dark_Purple! Hover here to see the item that "+prof.name_color+prof.nickname+"!Dark_Purple! shared"));
|
||||||
Style style = Style.EMPTY.withFont(Style.DEFAULT_FONT);
|
Style style = Style.EMPTY.withFont(Style.DEFAULT_FONT);
|
||||||
component = component.withStyle(style.withHoverEvent(HoverTip.getItem(is)));
|
component = component.withStyle(style.withHoverEvent(HoverTip.getItem(is)));
|
||||||
|
|
||||||
ChatHelpers.broadcast(component, ThresholdsMod.THE_SERVER);
|
ChatHelpers.broadcast(component, OTEMod.THE_SERVER);
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
return 1;
|
return 1;
|
|
@ -1,59 +1,60 @@
|
||||||
package dev.zontreck.thresholds.commands.profilecmds;
|
package dev.zontreck.otemod.commands.profilecmds;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import dev.zontreck.libzontreck.LibZontreck;
|
import dev.zontreck.libzontreck.LibZontreck;
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor.ColorOptions;
|
import dev.zontreck.libzontreck.chat.ChatColor.ColorOptions;
|
||||||
import dev.zontreck.libzontreck.profiles.Profile;
|
import dev.zontreck.libzontreck.profiles.Profile;
|
||||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import dev.zontreck.thresholds.implementation.Messages;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import dev.zontreck.otemod.implementation.Messages;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraftforge.server.command.EnumArgument;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraftforge.server.command.EnumArgument;
|
||||||
public class ChatColorCommand {
|
|
||||||
|
public class ChatColorCommand {
|
||||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
|
||||||
{
|
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||||
dispatcher.register(Commands.literal("chat_color")
|
{
|
||||||
.executes(c->setchatcolor(c.getSource(), ColorOptions.White))
|
dispatcher.register(Commands.literal("chat_color")
|
||||||
.then(Commands.argument("color", EnumArgument.enumArgument(ChatColor.ColorOptions.class))//StringArgumentType.string())
|
.executes(c->setchatcolor(c.getSource(), ColorOptions.White))
|
||||||
.executes(c -> setchatcolor(c.getSource(), c.getArgument("color", ChatColor.ColorOptions.class)))// EnumArgument.getS(c, "color")))
|
.then(Commands.argument("color", EnumArgument.enumArgument(ChatColor.ColorOptions.class))//StringArgumentType.string())
|
||||||
)
|
.executes(c -> setchatcolor(c.getSource(), c.getArgument("color", ChatColor.ColorOptions.class)))// EnumArgument.getS(c, "color")))
|
||||||
);
|
)
|
||||||
|
);
|
||||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
|
||||||
//String arg = StringArgumentType.getString(command, "nickname");
|
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||||
//return setHome(command.getSource(), arg);
|
//String arg = StringArgumentType.getString(command, "nickname");
|
||||||
//}));
|
//return setHome(command.getSource(), arg);
|
||||||
}
|
//}));
|
||||||
|
}
|
||||||
public static int setchatcolor(CommandSourceStack source, ColorOptions string) {
|
|
||||||
|
public static int setchatcolor(CommandSourceStack source, ColorOptions string) {
|
||||||
// Chat Color has a registry of colors that we can use to map back to our desired color
|
|
||||||
// To code
|
// Chat Color has a registry of colors that we can use to map back to our desired color
|
||||||
String colorcoded = ChatColor.from(string);
|
// To code
|
||||||
|
String colorcoded = ChatColor.from(string);
|
||||||
// Get profile
|
|
||||||
if(!(source.getEntity() instanceof Player)){
|
// Get profile
|
||||||
return 1;
|
if(!(source.getEntity() instanceof Player)){
|
||||||
}
|
return 1;
|
||||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
}
|
||||||
Profile p;
|
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||||
try {
|
Profile p;
|
||||||
p = Profile.get_profile_of(play.getStringUUID());
|
try {
|
||||||
} catch (UserProfileNotYetExistsException e) {
|
p = Profile.get_profile_of(play.getStringUUID());
|
||||||
return 1;
|
} catch (UserProfileNotYetExistsException e) {
|
||||||
}
|
return 1;
|
||||||
p.chat_color = colorcoded;
|
}
|
||||||
p.commit();
|
p.chat_color = colorcoded;
|
||||||
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
p.commit();
|
||||||
|
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
||||||
ChatHelpers.broadcastTo(play, ChatHelpers.macro(Messages.CHAT_COLOR_UPDATED), source.getServer());
|
|
||||||
|
ChatHelpers.broadcastTo(play, ChatHelpers.macro(Messages.CHAT_COLOR_UPDATED), source.getServer());
|
||||||
return 0;
|
|
||||||
}
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -1,60 +1,61 @@
|
||||||
package dev.zontreck.thresholds.commands.profilecmds;
|
package dev.zontreck.otemod.commands.profilecmds;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import dev.zontreck.libzontreck.LibZontreck;
|
import dev.zontreck.libzontreck.LibZontreck;
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor.ColorOptions;
|
import dev.zontreck.libzontreck.chat.ChatColor.ColorOptions;
|
||||||
import dev.zontreck.libzontreck.profiles.Profile;
|
import dev.zontreck.libzontreck.profiles.Profile;
|
||||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import dev.zontreck.thresholds.implementation.Messages;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import dev.zontreck.otemod.implementation.Messages;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraftforge.server.command.EnumArgument;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraftforge.server.command.EnumArgument;
|
||||||
public class NameColorCommand {
|
|
||||||
|
public class NameColorCommand {
|
||||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
|
||||||
{
|
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||||
dispatcher.register(Commands.literal("nick_color")
|
{
|
||||||
.executes(c->setchatcolor(c.getSource(), ColorOptions.White))
|
dispatcher.register(Commands.literal("nick_color")
|
||||||
.then(Commands.argument("color", EnumArgument.enumArgument(ChatColor.ColorOptions.class))//StringArgumentType.string())
|
.executes(c->setchatcolor(c.getSource(), ColorOptions.White))
|
||||||
.executes(c -> setchatcolor(c.getSource(), c.getArgument("color", ChatColor.ColorOptions.class)))// EnumArgument.getS(c, "color")))
|
.then(Commands.argument("color", EnumArgument.enumArgument(ChatColor.ColorOptions.class))//StringArgumentType.string())
|
||||||
)
|
.executes(c -> setchatcolor(c.getSource(), c.getArgument("color", ChatColor.ColorOptions.class)))// EnumArgument.getS(c, "color")))
|
||||||
);
|
)
|
||||||
|
);
|
||||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
|
||||||
//String arg = StringArgumentType.getString(command, "nickname");
|
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||||
//return setHome(command.getSource(), arg);
|
//String arg = StringArgumentType.getString(command, "nickname");
|
||||||
//}));
|
//return setHome(command.getSource(), arg);
|
||||||
}
|
//}));
|
||||||
|
}
|
||||||
public static int setchatcolor(CommandSourceStack source, ColorOptions string) {
|
|
||||||
|
public static int setchatcolor(CommandSourceStack source, ColorOptions string) {
|
||||||
// Chat Color has a registry of colors that we can use to map back to our desired color
|
|
||||||
// To code
|
// Chat Color has a registry of colors that we can use to map back to our desired color
|
||||||
String colorcoded = ChatColor.from(string);
|
// To code
|
||||||
|
String colorcoded = ChatColor.from(string);
|
||||||
// Get profile
|
|
||||||
if(!(source.getEntity() instanceof Player)){
|
// Get profile
|
||||||
return 1;
|
if(!(source.getEntity() instanceof Player)){
|
||||||
}
|
return 1;
|
||||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
}
|
||||||
Profile p;
|
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||||
try {
|
Profile p;
|
||||||
p = Profile.get_profile_of(play.getStringUUID());
|
try {
|
||||||
} catch (UserProfileNotYetExistsException e) {
|
p = Profile.get_profile_of(play.getStringUUID());
|
||||||
return 1;
|
} catch (UserProfileNotYetExistsException e) {
|
||||||
}
|
return 1;
|
||||||
p.name_color = colorcoded;
|
}
|
||||||
p.commit();
|
p.name_color = colorcoded;
|
||||||
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
p.commit();
|
||||||
|
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
||||||
|
|
||||||
ChatHelpers.broadcastTo(play, ChatHelpers.macro(Messages.NAME_COLOR_UPDATED), source.getServer());
|
|
||||||
|
ChatHelpers.broadcastTo(play, ChatHelpers.macro(Messages.NAME_COLOR_UPDATED), source.getServer());
|
||||||
return 0;
|
|
||||||
}
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -1,55 +1,57 @@
|
||||||
package dev.zontreck.thresholds.commands.profilecmds;
|
package dev.zontreck.otemod.commands.profilecmds;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
import dev.zontreck.libzontreck.LibZontreck;
|
import dev.zontreck.libzontreck.LibZontreck;
|
||||||
import dev.zontreck.libzontreck.profiles.Profile;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
import dev.zontreck.libzontreck.profiles.Profile;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||||
import dev.zontreck.thresholds.implementation.Messages;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import net.minecraft.commands.Commands;
|
import dev.zontreck.otemod.implementation.Messages;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.commands.Commands;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
public class NickCommand {
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
|
||||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
public class NickCommand {
|
||||||
{
|
|
||||||
dispatcher.register(Commands.literal("nick")
|
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||||
.executes(c->setchatcolor(c.getSource(), c.getSource().getPlayerOrException().getName().getString()))
|
{
|
||||||
.then(Commands.argument("new_name", StringArgumentType.string())//StringArgumentType.string())
|
dispatcher.register(Commands.literal("nick")
|
||||||
.executes(c -> setchatcolor(c.getSource(), StringArgumentType.getString(c, "new_name")))// EnumArgument.getS(c, "color")))
|
.executes(c->setchatcolor(c.getSource(), c.getSource().getPlayerOrException().getName().getString()))
|
||||||
)
|
.then(Commands.argument("new_name", StringArgumentType.string())//StringArgumentType.string())
|
||||||
);
|
.executes(c -> setchatcolor(c.getSource(), StringArgumentType.getString(c, "new_name")))// EnumArgument.getS(c, "color")))
|
||||||
|
)
|
||||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
);
|
||||||
//String arg = StringArgumentType.getString(command, "nickname");
|
|
||||||
//return setHome(command.getSource(), arg);
|
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||||
//}));
|
//String arg = StringArgumentType.getString(command, "nickname");
|
||||||
}
|
//return setHome(command.getSource(), arg);
|
||||||
|
//}));
|
||||||
public static int setchatcolor(CommandSourceStack source, String string) {
|
}
|
||||||
|
|
||||||
// Get profile
|
public static int setchatcolor(CommandSourceStack source, String string) {
|
||||||
if(!(source.getEntity() instanceof Player)){
|
|
||||||
return 1;
|
// Get profile
|
||||||
}
|
if(!(source.getEntity() instanceof Player)){
|
||||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
return 1;
|
||||||
|
}
|
||||||
Profile p;
|
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||||
try {
|
|
||||||
p = Profile.get_profile_of(play.getStringUUID());
|
Profile p;
|
||||||
} catch (UserProfileNotYetExistsException e) {
|
try {
|
||||||
return 1;
|
p = Profile.get_profile_of(play.getStringUUID());
|
||||||
}
|
} catch (UserProfileNotYetExistsException e) {
|
||||||
p.nickname = string;
|
return 1;
|
||||||
p.commit();
|
}
|
||||||
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
p.nickname = string;
|
||||||
|
p.commit();
|
||||||
|
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
||||||
ChatHelpers.broadcastTo(play, ChatHelpers.macro(Messages.NICK_UPDATED), source.getServer());
|
|
||||||
|
|
||||||
return 0;
|
ChatHelpers.broadcastTo(play, ChatHelpers.macro(Messages.NICK_UPDATED), source.getServer());
|
||||||
}
|
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,60 +1,61 @@
|
||||||
package dev.zontreck.thresholds.commands.profilecmds;
|
package dev.zontreck.otemod.commands.profilecmds;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import dev.zontreck.libzontreck.LibZontreck;
|
import dev.zontreck.libzontreck.LibZontreck;
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor.ColorOptions;
|
import dev.zontreck.libzontreck.chat.ChatColor.ColorOptions;
|
||||||
import dev.zontreck.libzontreck.profiles.Profile;
|
import dev.zontreck.libzontreck.profiles.Profile;
|
||||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import dev.zontreck.thresholds.implementation.Messages;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import dev.zontreck.otemod.implementation.Messages;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraftforge.server.command.EnumArgument;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraftforge.server.command.EnumArgument;
|
||||||
public class PrefixColorCommand {
|
|
||||||
|
public class PrefixColorCommand {
|
||||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
|
||||||
{
|
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||||
dispatcher.register(Commands.literal("prefix_color")
|
{
|
||||||
.executes(c->setchatcolor(c.getSource(), ColorOptions.White))
|
dispatcher.register(Commands.literal("prefix_color")
|
||||||
.then(Commands.argument("color", EnumArgument.enumArgument(ChatColor.ColorOptions.class))//StringArgumentType.string())
|
.executes(c->setchatcolor(c.getSource(), ColorOptions.White))
|
||||||
.executes(c -> setchatcolor(c.getSource(), c.getArgument("color", ChatColor.ColorOptions.class)))// EnumArgument.getS(c, "color")))
|
.then(Commands.argument("color", EnumArgument.enumArgument(ChatColor.ColorOptions.class))//StringArgumentType.string())
|
||||||
)
|
.executes(c -> setchatcolor(c.getSource(), c.getArgument("color", ChatColor.ColorOptions.class)))// EnumArgument.getS(c, "color")))
|
||||||
);
|
)
|
||||||
|
);
|
||||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
|
||||||
//String arg = StringArgumentType.getString(command, "nickname");
|
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||||
//return setHome(command.getSource(), arg);
|
//String arg = StringArgumentType.getString(command, "nickname");
|
||||||
//}));
|
//return setHome(command.getSource(), arg);
|
||||||
}
|
//}));
|
||||||
|
}
|
||||||
public static int setchatcolor(CommandSourceStack source, ColorOptions string) {
|
|
||||||
|
public static int setchatcolor(CommandSourceStack source, ColorOptions string) {
|
||||||
// Chat Color has a registry of colors that we can use to map back to our desired color
|
|
||||||
// To code
|
// Chat Color has a registry of colors that we can use to map back to our desired color
|
||||||
String colorcoded = ChatColor.from(string);
|
// To code
|
||||||
|
String colorcoded = ChatColor.from(string);
|
||||||
// Get profile
|
|
||||||
if(!(source.getEntity() instanceof Player)){
|
// Get profile
|
||||||
return 1;
|
if(!(source.getEntity() instanceof Player)){
|
||||||
}
|
return 1;
|
||||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
}
|
||||||
|
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||||
Profile p;
|
|
||||||
try {
|
Profile p;
|
||||||
p = Profile.get_profile_of(play.getStringUUID());
|
try {
|
||||||
} catch (UserProfileNotYetExistsException e) {
|
p = Profile.get_profile_of(play.getStringUUID());
|
||||||
return 1;
|
} catch (UserProfileNotYetExistsException e) {
|
||||||
}
|
return 1;
|
||||||
p.prefix_color = colorcoded;
|
}
|
||||||
p.commit();
|
p.prefix_color = colorcoded;
|
||||||
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
p.commit();
|
||||||
|
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
||||||
ChatHelpers.broadcastTo(play, ChatHelpers.macro(Messages.PREFIX_COLOR_UPDATED), source.getServer());
|
|
||||||
|
ChatHelpers.broadcastTo(play, ChatHelpers.macro(Messages.PREFIX_COLOR_UPDATED), source.getServer());
|
||||||
return 0;
|
|
||||||
}
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -1,54 +1,56 @@
|
||||||
package dev.zontreck.thresholds.commands.profilecmds;
|
package dev.zontreck.otemod.commands.profilecmds;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
import dev.zontreck.libzontreck.LibZontreck;
|
import dev.zontreck.libzontreck.LibZontreck;
|
||||||
import dev.zontreck.libzontreck.profiles.Profile;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
import dev.zontreck.libzontreck.profiles.Profile;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||||
import dev.zontreck.thresholds.implementation.Messages;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import net.minecraft.commands.Commands;
|
import dev.zontreck.otemod.implementation.Messages;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.commands.Commands;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
public class PrefixCommand {
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
|
||||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
public class PrefixCommand {
|
||||||
{
|
|
||||||
dispatcher.register(Commands.literal("prefix")
|
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||||
.executes(c->setchatcolor(c.getSource(), "Member"))
|
{
|
||||||
.then(Commands.argument("new_prefix", StringArgumentType.string())//StringArgumentType.string())
|
dispatcher.register(Commands.literal("prefix")
|
||||||
.executes(c -> setchatcolor(c.getSource(), StringArgumentType.getString(c, "new_prefix")))// EnumArgument.getS(c, "color")))
|
.executes(c->setchatcolor(c.getSource(), "Member"))
|
||||||
)
|
.then(Commands.argument("new_prefix", StringArgumentType.string())//StringArgumentType.string())
|
||||||
);
|
.executes(c -> setchatcolor(c.getSource(), StringArgumentType.getString(c, "new_prefix")))// EnumArgument.getS(c, "color")))
|
||||||
|
)
|
||||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
);
|
||||||
//String arg = StringArgumentType.getString(command, "nickname");
|
|
||||||
//return setHome(command.getSource(), arg);
|
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||||
//}));
|
//String arg = StringArgumentType.getString(command, "nickname");
|
||||||
}
|
//return setHome(command.getSource(), arg);
|
||||||
|
//}));
|
||||||
public static int setchatcolor(CommandSourceStack source, String string) {
|
}
|
||||||
|
|
||||||
// Get profile
|
public static int setchatcolor(CommandSourceStack source, String string) {
|
||||||
if(!(source.getEntity() instanceof Player)){
|
|
||||||
return 1;
|
// Get profile
|
||||||
}
|
if(!(source.getEntity() instanceof Player)){
|
||||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
return 1;
|
||||||
|
}
|
||||||
Profile p;
|
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||||
try {
|
|
||||||
p = Profile.get_profile_of(play.getStringUUID());
|
Profile p;
|
||||||
} catch (UserProfileNotYetExistsException e) {
|
try {
|
||||||
return 1;
|
p = Profile.get_profile_of(play.getStringUUID());
|
||||||
}
|
} catch (UserProfileNotYetExistsException e) {
|
||||||
p.prefix = string;
|
return 1;
|
||||||
p.commit();
|
}
|
||||||
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
p.prefix = string;
|
||||||
|
p.commit();
|
||||||
ChatHelpers.broadcastTo(play, ChatHelpers.macro(Messages.PREFIX_UPDATED), source.getServer());
|
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
||||||
|
|
||||||
return 0;
|
ChatHelpers.broadcastTo(play, ChatHelpers.macro(Messages.PREFIX_UPDATED), source.getServer());
|
||||||
}
|
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,15 +1,17 @@
|
||||||
package dev.zontreck.thresholds.commands.vaults;
|
package dev.zontreck.otemod.commands.vaults;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
import dev.zontreck.libzontreck.profiles.Profile;
|
import dev.zontreck.libzontreck.profiles.Profile;
|
||||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.implementation.Messages;
|
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||||
import dev.zontreck.thresholds.implementation.PlayerFirstJoinTag;
|
import dev.zontreck.otemod.implementation.Messages;
|
||||||
import dev.zontreck.thresholds.implementation.vault.NoMoreVaultException;
|
import dev.zontreck.otemod.implementation.PlayerFirstJoinTag;
|
||||||
import dev.zontreck.thresholds.implementation.vault.StarterContainer;
|
import dev.zontreck.otemod.implementation.vault.NoMoreVaultException;
|
||||||
import dev.zontreck.thresholds.implementation.vault.VaultContainer;
|
import dev.zontreck.otemod.implementation.vault.StarterContainer;
|
||||||
|
import dev.zontreck.otemod.implementation.vault.VaultContainer;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.commands.arguments.EntityArgument;
|
import net.minecraft.commands.arguments.EntityArgument;
|
||||||
|
@ -18,6 +20,8 @@ import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.SimpleMenuProvider;
|
import net.minecraft.world.SimpleMenuProvider;
|
||||||
import net.minecraftforge.network.NetworkHooks;
|
import net.minecraftforge.network.NetworkHooks;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
public class StarterCommand
|
public class StarterCommand
|
||||||
{
|
{
|
||||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||||
|
@ -46,7 +50,7 @@ public class StarterCommand
|
||||||
|
|
||||||
PFJT.save(prof.NBT);
|
PFJT.save(prof.NBT);
|
||||||
|
|
||||||
ThresholdsMod.checkFirstJoin(player);
|
OTEMod.checkFirstJoin(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int openStarterMenu(CommandSourceStack ctx)
|
public static int openStarterMenu(CommandSourceStack ctx)
|
||||||
|
@ -85,7 +89,7 @@ public class StarterCommand
|
||||||
try {
|
try {
|
||||||
container = new StarterContainer(p);
|
container = new StarterContainer(p);
|
||||||
} catch (NoMoreVaultException e) {
|
} catch (NoMoreVaultException e) {
|
||||||
ChatHelpers.broadcastTo(p.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +"!Dark_Red!You cannot open anymore vaults. Craft a new vault!"), p.server);
|
ChatHelpers.broadcastTo(p.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+"!Dark_Red!You cannot open anymore vaults. Craft a new vault!"), p.server);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,48 +1,48 @@
|
||||||
package dev.zontreck.thresholds.commands.vaults;
|
package dev.zontreck.otemod.commands.vaults;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.implementation.vault.NoMoreVaultException;
|
import dev.zontreck.otemod.implementation.vault.NoMoreVaultException;
|
||||||
import dev.zontreck.thresholds.implementation.vault.VaultContainer;
|
import dev.zontreck.otemod.implementation.vault.VaultContainer;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.SimpleMenuProvider;
|
import net.minecraft.world.SimpleMenuProvider;
|
||||||
import net.minecraftforge.network.NetworkHooks;
|
import net.minecraftforge.network.NetworkHooks;
|
||||||
|
|
||||||
public class TrashCommand {
|
public class TrashCommand {
|
||||||
|
|
||||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||||
{
|
{
|
||||||
dispatcher.register(Commands.literal("trash").executes(c-> vault(c.getSource())));
|
dispatcher.register(Commands.literal("trash").executes(c-> vault(c.getSource())));
|
||||||
|
|
||||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||||
//String arg = StringArgumentType.getString(command, "nickname");
|
//String arg = StringArgumentType.getString(command, "nickname");
|
||||||
//return setHome(command.getSource(), arg);
|
//return setHome(command.getSource(), arg);
|
||||||
//}));
|
//}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int vault(CommandSourceStack source) {
|
private static int vault(CommandSourceStack source) {
|
||||||
//VaultContainer cont = new VaultContainer(i, source.getPlayer().getUUID());
|
//VaultContainer cont = new VaultContainer(i, source.getPlayer().getUUID());
|
||||||
//cont.startOpen(source.getPlayer());
|
//cont.startOpen(source.getPlayer());
|
||||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||||
|
|
||||||
VaultContainer container;
|
VaultContainer container;
|
||||||
try {
|
try {
|
||||||
container = new VaultContainer(play, -1);
|
container = new VaultContainer(play, -1);
|
||||||
} catch (NoMoreVaultException e) {
|
} catch (NoMoreVaultException e) {
|
||||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Red!You cannot open anymore vaults. Craft a new vault!"), play.server);
|
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Red!You cannot open anymore vaults. Craft a new vault!"), play.server);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkHooks.openScreen(play, new SimpleMenuProvider(container.serverMenu, Component.literal("Trash")));
|
NetworkHooks.openScreen(play, new SimpleMenuProvider(container.serverMenu, Component.literal("Trash")));
|
||||||
|
|
||||||
// Add to the master vault registry
|
// Add to the master vault registry
|
||||||
if(VaultContainer.VAULT_REGISTRY.containsKey(play.getUUID()))VaultContainer.VAULT_REGISTRY.remove(play.getUUID());
|
if(VaultContainer.VAULT_REGISTRY.containsKey(play.getUUID()))VaultContainer.VAULT_REGISTRY.remove(play.getUUID());
|
||||||
VaultContainer.VAULT_REGISTRY.put(play.getUUID(), container);
|
VaultContainer.VAULT_REGISTRY.put(play.getUUID(), container);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,60 +1,60 @@
|
||||||
package dev.zontreck.thresholds.commands.vaults;
|
package dev.zontreck.otemod.commands.vaults;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.implementation.vault.NoMoreVaultException;
|
import dev.zontreck.otemod.implementation.vault.NoMoreVaultException;
|
||||||
import dev.zontreck.thresholds.implementation.vault.VaultContainer;
|
import dev.zontreck.otemod.implementation.vault.VaultContainer;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.SimpleMenuProvider;
|
import net.minecraft.world.SimpleMenuProvider;
|
||||||
import net.minecraftforge.network.NetworkHooks;
|
import net.minecraftforge.network.NetworkHooks;
|
||||||
|
|
||||||
public class VaultCommand {
|
public class VaultCommand {
|
||||||
|
|
||||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||||
{
|
{
|
||||||
dispatcher.register(Commands.literal("pv").executes(c-> vault(c.getSource(), 0)).then(Commands.argument("number", IntegerArgumentType.integer()).executes(c -> vault(c.getSource(), IntegerArgumentType.getInteger(c, "number")))));
|
dispatcher.register(Commands.literal("pv").executes(c-> vault(c.getSource(), 0)).then(Commands.argument("number", IntegerArgumentType.integer()).executes(c -> vault(c.getSource(), IntegerArgumentType.getInteger(c, "number")))));
|
||||||
dispatcher.register(Commands.literal("vault").executes(c-> vault(c.getSource(), 0)).then(Commands.argument("number", IntegerArgumentType.integer()).executes(c -> vault(c.getSource(), IntegerArgumentType.getInteger(c, "number")))));
|
dispatcher.register(Commands.literal("vault").executes(c-> vault(c.getSource(), 0)).then(Commands.argument("number", IntegerArgumentType.integer()).executes(c -> vault(c.getSource(), IntegerArgumentType.getInteger(c, "number")))));
|
||||||
|
|
||||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||||
//String arg = StringArgumentType.getString(command, "nickname");
|
//String arg = StringArgumentType.getString(command, "nickname");
|
||||||
//return setHome(command.getSource(), arg);
|
//return setHome(command.getSource(), arg);
|
||||||
//}));
|
//}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int vault(CommandSourceStack source, int i) {
|
private static int vault(CommandSourceStack source, int i) {
|
||||||
//VaultContainer cont = new VaultContainer(i, source.getPlayer().getUUID());
|
//VaultContainer cont = new VaultContainer(i, source.getPlayer().getUUID());
|
||||||
//cont.startOpen(source.getPlayer());
|
//cont.startOpen(source.getPlayer());
|
||||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||||
if(i <0)
|
if(i <0)
|
||||||
{
|
{
|
||||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Red!You can only specify a vault number in the positive range"), source.getServer());
|
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Red!You can only specify a vault number in the positive range"), source.getServer());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
doOpen(play, i);
|
doOpen(play, i);
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void doOpen(ServerPlayer p, int i){
|
public static void doOpen(ServerPlayer p, int i){
|
||||||
|
|
||||||
VaultContainer container;
|
VaultContainer container;
|
||||||
try {
|
try {
|
||||||
container = new VaultContainer(p, i);
|
container = new VaultContainer(p, i);
|
||||||
} catch (NoMoreVaultException e) {
|
} catch (NoMoreVaultException e) {
|
||||||
ChatHelpers.broadcastTo(p.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Red!You cannot open anymore vaults. Craft a new vault!"), p.server);
|
ChatHelpers.broadcastTo(p.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Red!You cannot open anymore vaults. Craft a new vault!"), p.server);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkHooks.openScreen(p, new SimpleMenuProvider(container.serverMenu, Component.literal("Vault " + i)));
|
NetworkHooks.openScreen(p, new SimpleMenuProvider(container.serverMenu, Component.literal("Vault " + i)));
|
||||||
|
|
||||||
// Add to the master vault registry
|
// Add to the master vault registry
|
||||||
if(VaultContainer.VAULT_REGISTRY.containsKey(p.getUUID()))VaultContainer.VAULT_REGISTRY.remove(p.getUUID());
|
if(VaultContainer.VAULT_REGISTRY.containsKey(p.getUUID()))VaultContainer.VAULT_REGISTRY.remove(p.getUUID());
|
||||||
VaultContainer.VAULT_REGISTRY.put(p.getUUID(), container);
|
VaultContainer.VAULT_REGISTRY.put(p.getUUID(), container);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,139 +1,139 @@
|
||||||
package dev.zontreck.thresholds.commands.zschem;
|
package dev.zontreck.otemod.commands.zschem;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||||
import dev.zontreck.libzontreck.vectors.WorldPosition;
|
import dev.zontreck.libzontreck.vectors.WorldPosition;
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.integrations.LuckPermsHelper;
|
import dev.zontreck.otemod.integrations.LuckPermsHelper;
|
||||||
import dev.zontreck.thresholds.permissions.Permissions;
|
import dev.zontreck.otemod.permissions.Permissions;
|
||||||
import dev.zontreck.thresholds.zschem.MemoryHolder;
|
import dev.zontreck.otemod.zschem.MemoryHolder;
|
||||||
import dev.zontreck.thresholds.zschem.MemoryHolder.Container;
|
import dev.zontreck.otemod.zschem.MemoryHolder.Container;
|
||||||
import dev.zontreck.thresholds.zschem.StoredBlock;
|
import dev.zontreck.otemod.zschem.StoredBlock;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.nbt.ListTag;
|
||||||
import net.minecraft.nbt.NbtIo;
|
import net.minecraft.nbt.NbtIo;
|
||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraftforge.fml.loading.FMLConfig;
|
import net.minecraftforge.fml.loading.FMLConfig;
|
||||||
import net.minecraftforge.fml.loading.FMLPaths;
|
import net.minecraftforge.fml.loading.FMLPaths;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class LoadSchem {
|
public class LoadSchem {
|
||||||
|
|
||||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||||
{
|
{
|
||||||
dispatcher.register(Commands.literal("loadzschem").executes(c-> loadSchematicUsage(c.getSource())).then(Commands.argument("name", StringArgumentType.string()).executes(z->loadSchematic(z.getSource(), StringArgumentType.getString(z, "name")))));
|
dispatcher.register(Commands.literal("loadzschem").executes(c-> loadSchematicUsage(c.getSource())).then(Commands.argument("name", StringArgumentType.string()).executes(z->loadSchematic(z.getSource(), StringArgumentType.getString(z, "name")))));
|
||||||
|
|
||||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||||
//String arg = StringArgumentType.getString(command, "nickname");
|
//String arg = StringArgumentType.getString(command, "nickname");
|
||||||
//return setHome(command.getSource(), arg);
|
//return setHome(command.getSource(), arg);
|
||||||
//}));
|
//}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int loadSchematic(CommandSourceStack source, String name) {
|
private static int loadSchematic(CommandSourceStack source, String name) {
|
||||||
// Perform sanity checks
|
// Perform sanity checks
|
||||||
|
|
||||||
|
|
||||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||||
if(play==null)return 1;
|
if(play==null)return 1;
|
||||||
|
|
||||||
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_load)){
|
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_load)){
|
||||||
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_load, Permissions.zschem);
|
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_load, Permissions.zschem);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(MemoryHolder.hasPlayerCached(play))
|
if(MemoryHolder.hasPlayerCached(play))
|
||||||
{
|
{
|
||||||
Container cont = MemoryHolder.getContainer(play);
|
Container cont = MemoryHolder.getContainer(play);
|
||||||
if(cont == null)
|
if(cont == null)
|
||||||
{
|
{
|
||||||
|
|
||||||
loadSchematicUsage(source);
|
loadSchematicUsage(source);
|
||||||
}else {
|
}else {
|
||||||
if(cont.Pos1 != ThresholdsMod.ZERO_VECTOR)
|
if(cont.Pos1 != OTEMod.ZERO_VECTOR)
|
||||||
{
|
{
|
||||||
// Lets go!
|
// Lets go!
|
||||||
List<StoredBlock> blocks = new ArrayList<StoredBlock>();
|
List<StoredBlock> blocks = new ArrayList<StoredBlock>();
|
||||||
// First we calculate every vector between pos1 and pos2.
|
// First we calculate every vector between pos1 and pos2.
|
||||||
// Then we subtract pos1 from the vector to acquire a relative position.
|
// Then we subtract pos1 from the vector to acquire a relative position.
|
||||||
// Then we save the block with this relative position to the blocks list
|
// Then we save the block with this relative position to the blocks list
|
||||||
// Once serialized, it is then possible to add the position. Note that this makes it impossible to rotate a zschem like with worldedit, but thats usually fine for our usecases. once in-game worldedit can be used to rotate.
|
// Once serialized, it is then possible to add the position. Note that this makes it impossible to rotate a zschem like with worldedit, but thats usually fine for our usecases. once in-game worldedit can be used to rotate.
|
||||||
// TODO: Also- It is possible that a rotational implementation can be added in the future
|
// TODO: Also- It is possible that a rotational implementation can be added in the future
|
||||||
|
|
||||||
Path configDir = FMLPaths.GAMEDIR.get().resolve(FMLConfig.defaultConfigPath());
|
Path configDir = FMLPaths.GAMEDIR.get().resolve(FMLConfig.defaultConfigPath());
|
||||||
configDir = configDir.resolve("ZSchems");
|
configDir = configDir.resolve("ZSchems");
|
||||||
File X = configDir.toFile();
|
File X = configDir.toFile();
|
||||||
if(!X.exists())
|
if(!X.exists())
|
||||||
{
|
{
|
||||||
X.mkdir();
|
X.mkdir();
|
||||||
}
|
}
|
||||||
configDir = configDir.resolve(name+"-zschem.nbt");
|
configDir = configDir.resolve(name+"-zschem.nbt");
|
||||||
|
|
||||||
if(configDir.toFile().exists()){
|
if(configDir.toFile().exists()){
|
||||||
CompoundTag CT=new CompoundTag();
|
CompoundTag CT=new CompoundTag();
|
||||||
try {
|
try {
|
||||||
CT = NbtIo.readCompressed(configDir.toFile());
|
CT = NbtIo.readCompressed(configDir.toFile());
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ListTag blst = CT.getList("blocks", CompoundTag.TAG_COMPOUND);
|
ListTag blst = CT.getList("blocks", CompoundTag.TAG_COMPOUND);
|
||||||
Iterator<Tag> tags = blst.iterator();
|
Iterator<Tag> tags = blst.iterator();
|
||||||
while(tags.hasNext())
|
while(tags.hasNext())
|
||||||
{
|
{
|
||||||
CompoundTag nxt = (CompoundTag)tags.next();
|
CompoundTag nxt = (CompoundTag)tags.next();
|
||||||
StoredBlock sb = new StoredBlock(nxt);
|
StoredBlock sb = new StoredBlock(nxt);
|
||||||
ServerLevel pasteLvl = cont.lvl;
|
ServerLevel pasteLvl = cont.lvl;
|
||||||
sb.updateWorld(pasteLvl);
|
sb.updateWorld(pasteLvl);
|
||||||
|
|
||||||
WorldPosition wp = sb.getWorldPosition();
|
WorldPosition wp = sb.getWorldPosition();
|
||||||
Vector3 superPos = cont.Pos1;
|
Vector3 superPos = cont.Pos1;
|
||||||
wp.Position = superPos.add(wp.Position);
|
wp.Position = superPos.add(wp.Position);
|
||||||
sb.setPosition(wp.Position);
|
sb.setPosition(wp.Position);
|
||||||
|
|
||||||
|
|
||||||
blocks.add(sb);
|
blocks.add(sb);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryHolder.setBlocks(play, blocks);
|
MemoryHolder.setBlocks(play, blocks);
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix + " !Dark_Red!No such ZSchem exists!"), source.getServer());
|
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix + " !Dark_Red!No such ZSchem exists!"), source.getServer());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Green!ZSchem loaded from disk!"), ThresholdsMod.THE_SERVER);
|
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Green!ZSchem loaded from disk!"), OTEMod.THE_SERVER);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro("!Dark_Red! You must set the first position"), ThresholdsMod.THE_SERVER);
|
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro("!Dark_Red! You must set the first position"), OTEMod.THE_SERVER);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int loadSchematicUsage(CommandSourceStack source)
|
private static int loadSchematicUsage(CommandSourceStack source)
|
||||||
{
|
{
|
||||||
String usage = ThresholdsMod.ThresholdsPrefix;
|
String usage = OTEMod.OTEPrefix;
|
||||||
usage += "!gold! /loadzschem [string:name]";
|
usage += "!gold! /loadzschem [string:name]";
|
||||||
ServerPlayer play=(ServerPlayer)source.getEntity();
|
ServerPlayer play=(ServerPlayer)source.getEntity();
|
||||||
if(play==null)return 1;
|
if(play==null)return 1;
|
||||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(usage), ThresholdsMod.THE_SERVER);
|
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(usage), OTEMod.THE_SERVER);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,75 +1,75 @@
|
||||||
package dev.zontreck.thresholds.commands.zschem;
|
package dev.zontreck.otemod.commands.zschem;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.integrations.LuckPermsHelper;
|
import dev.zontreck.otemod.integrations.LuckPermsHelper;
|
||||||
import dev.zontreck.thresholds.permissions.Permissions;
|
import dev.zontreck.otemod.permissions.Permissions;
|
||||||
import dev.zontreck.thresholds.zschem.MemoryHolder;
|
import dev.zontreck.otemod.zschem.MemoryHolder;
|
||||||
import dev.zontreck.thresholds.zschem.MemoryHolder.Container;
|
import dev.zontreck.otemod.zschem.MemoryHolder.Container;
|
||||||
import dev.zontreck.thresholds.zschem.StoredBlock;
|
import dev.zontreck.otemod.zschem.StoredBlock;
|
||||||
import dev.zontreck.thresholds.zschem.WorldProp;
|
import dev.zontreck.otemod.zschem.WorldProp;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
// This command will place the loaded schematic in world. The schematic will originate from position 1. The positions are relative and are added onto position 1.
|
// This command will place the loaded schematic in world. The schematic will originate from position 1. The positions are relative and are added onto position 1.
|
||||||
public class Place {
|
public class Place {
|
||||||
|
|
||||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||||
{
|
{
|
||||||
dispatcher.register(Commands.literal("placezschem").executes(c-> place(c.getSource())));
|
dispatcher.register(Commands.literal("placezschem").executes(c-> place(c.getSource())));
|
||||||
|
|
||||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||||
//String arg = StringArgumentType.getString(command, "nickname");
|
//String arg = StringArgumentType.getString(command, "nickname");
|
||||||
//return setHome(command.getSource(), arg);
|
//return setHome(command.getSource(), arg);
|
||||||
//}));
|
//}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int place(CommandSourceStack source) {
|
private static int place(CommandSourceStack source) {
|
||||||
|
|
||||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||||
if(play==null)return 1;
|
if(play==null)return 1;
|
||||||
|
|
||||||
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_place)){
|
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_place)){
|
||||||
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_place, Permissions.zschem);
|
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_place, Permissions.zschem);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!MemoryHolder.hasPlayerCached(play)){
|
if(!MemoryHolder.hasPlayerCached(play)){
|
||||||
|
|
||||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Red!You must first load the zschem!"), ThresholdsMod.THE_SERVER);
|
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Red!You must first load the zschem!"), OTEMod.THE_SERVER);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Container cont = MemoryHolder.getContainer(play);
|
Container cont = MemoryHolder.getContainer(play);
|
||||||
List<StoredBlock> blocks = cont.blocks;
|
List<StoredBlock> blocks = cont.blocks;
|
||||||
Collections.shuffle(blocks);
|
Collections.shuffle(blocks);
|
||||||
|
|
||||||
if(cont.Pos1 != ThresholdsMod.ZERO_VECTOR)
|
if(cont.Pos1 != OTEMod.ZERO_VECTOR)
|
||||||
{
|
{
|
||||||
WorldProp system = WorldProp.acquire(cont.lvl);
|
WorldProp system = WorldProp.acquire(cont.lvl);
|
||||||
// Begin the process
|
// Begin the process
|
||||||
for (StoredBlock storedBlock : blocks) {
|
for (StoredBlock storedBlock : blocks) {
|
||||||
// alter the stored block and send it off to the queue system for the relevant world!
|
// alter the stored block and send it off to the queue system for the relevant world!
|
||||||
|
|
||||||
system.customEnqueue(storedBlock);
|
system.customEnqueue(storedBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
|
|
||||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Red!You must first load the zschem!"), ThresholdsMod.THE_SERVER);
|
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Red!You must first load the zschem!"), OTEMod.THE_SERVER);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Green!Enqueued!"), ThresholdsMod.THE_SERVER);
|
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Green!Enqueued!"), OTEMod.THE_SERVER);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,82 +1,82 @@
|
||||||
package dev.zontreck.thresholds.commands.zschem;
|
package dev.zontreck.otemod.commands.zschem;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.integrations.LuckPermsHelper;
|
import dev.zontreck.otemod.integrations.LuckPermsHelper;
|
||||||
import dev.zontreck.thresholds.permissions.Permissions;
|
import dev.zontreck.otemod.permissions.Permissions;
|
||||||
import dev.zontreck.thresholds.zschem.MemoryHolder;
|
import dev.zontreck.otemod.zschem.MemoryHolder;
|
||||||
import dev.zontreck.thresholds.zschem.MemoryHolder.Container;
|
import dev.zontreck.otemod.zschem.MemoryHolder.Container;
|
||||||
import dev.zontreck.thresholds.zschem.StoredBlock;
|
import dev.zontreck.otemod.zschem.StoredBlock;
|
||||||
import dev.zontreck.thresholds.zschem.WorldProp;
|
import dev.zontreck.otemod.zschem.WorldProp;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
// This command will place the loaded schematic in world. The schematic will originate from position 1. The positions are relative and are added onto position 1.
|
// This command will place the loaded schematic in world. The schematic will originate from position 1. The positions are relative and are added onto position 1.
|
||||||
public class PlaceAsAir {
|
public class PlaceAsAir {
|
||||||
|
|
||||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||||
{
|
{
|
||||||
dispatcher.register(Commands.literal("zsetair").executes(c-> place(c.getSource())));
|
dispatcher.register(Commands.literal("zsetair").executes(c-> place(c.getSource())));
|
||||||
|
|
||||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||||
//String arg = StringArgumentType.getString(command, "nickname");
|
//String arg = StringArgumentType.getString(command, "nickname");
|
||||||
//return setHome(command.getSource(), arg);
|
//return setHome(command.getSource(), arg);
|
||||||
//}));
|
//}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int place(CommandSourceStack source) {
|
private static int place(CommandSourceStack source) {
|
||||||
|
|
||||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||||
if(play==null)return 1;
|
if(play==null)return 1;
|
||||||
|
|
||||||
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_air)){
|
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_air)){
|
||||||
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_air, Permissions.zschem);
|
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_air, Permissions.zschem);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!MemoryHolder.hasPlayerCached(play)){
|
if(!MemoryHolder.hasPlayerCached(play)){
|
||||||
|
|
||||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Red!You must first set the positions!"), ThresholdsMod.THE_SERVER);
|
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Red!You must first set the positions!"), OTEMod.THE_SERVER);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Container cont = MemoryHolder.getContainer(play);
|
Container cont = MemoryHolder.getContainer(play);
|
||||||
|
|
||||||
if(cont.Pos1 != ThresholdsMod.ZERO_VECTOR && cont.Pos2 != ThresholdsMod.ZERO_VECTOR)
|
if(cont.Pos1 != OTEMod.ZERO_VECTOR && cont.Pos2 != OTEMod.ZERO_VECTOR)
|
||||||
{
|
{
|
||||||
WorldProp system = WorldProp.acquire(cont.lvl);
|
WorldProp system = WorldProp.acquire(cont.lvl);
|
||||||
// Begin the process
|
// Begin the process
|
||||||
List<Vector3> positions = cont.Pos1.makeCube(cont.Pos2);
|
List<Vector3> positions = cont.Pos1.makeCube(cont.Pos2);
|
||||||
Collections.shuffle(positions);
|
Collections.shuffle(positions);
|
||||||
Iterator<Vector3> v3 = positions.iterator();
|
Iterator<Vector3> v3 = positions.iterator();
|
||||||
|
|
||||||
while(v3.hasNext())
|
while(v3.hasNext())
|
||||||
{
|
{
|
||||||
Vector3 pos = v3.next();
|
Vector3 pos = v3.next();
|
||||||
StoredBlock sb = new StoredBlock(pos.asBlockPos(), Blocks.AIR.defaultBlockState(), source.getLevel());
|
StoredBlock sb = new StoredBlock(pos.asBlockPos(), Blocks.AIR.defaultBlockState(), source.getLevel());
|
||||||
system.customEnqueue(sb);
|
system.customEnqueue(sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
|
|
||||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Red!You must first set the positions!"), ThresholdsMod.THE_SERVER);
|
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Red!You must first set the positions!"), OTEMod.THE_SERVER);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Green!Enqueued!"), ThresholdsMod.THE_SERVER);
|
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Green!Enqueued!"), OTEMod.THE_SERVER);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,125 +1,125 @@
|
||||||
package dev.zontreck.thresholds.commands.zschem;
|
package dev.zontreck.otemod.commands.zschem;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.integrations.LuckPermsHelper;
|
import dev.zontreck.otemod.integrations.LuckPermsHelper;
|
||||||
import dev.zontreck.thresholds.permissions.Permissions;
|
import dev.zontreck.otemod.permissions.Permissions;
|
||||||
import dev.zontreck.thresholds.zschem.MemoryHolder;
|
import dev.zontreck.otemod.zschem.MemoryHolder;
|
||||||
import dev.zontreck.thresholds.zschem.MemoryHolder.Container;
|
import dev.zontreck.otemod.zschem.MemoryHolder.Container;
|
||||||
import dev.zontreck.thresholds.zschem.StoredBlock;
|
import dev.zontreck.otemod.zschem.StoredBlock;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.nbt.ListTag;
|
||||||
import net.minecraft.nbt.NbtIo;
|
import net.minecraft.nbt.NbtIo;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraftforge.fml.loading.FMLConfig;
|
import net.minecraftforge.fml.loading.FMLConfig;
|
||||||
import net.minecraftforge.fml.loading.FMLPaths;
|
import net.minecraftforge.fml.loading.FMLPaths;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SaveSchem {
|
public class SaveSchem {
|
||||||
|
|
||||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||||
{
|
{
|
||||||
dispatcher.register(Commands.literal("savezschem").executes(c-> saveSchematicUsage(c.getSource())).then(Commands.argument("name", StringArgumentType.string()).executes(z->saveSchematic(z.getSource(), StringArgumentType.getString(z, "name")))));
|
dispatcher.register(Commands.literal("savezschem").executes(c-> saveSchematicUsage(c.getSource())).then(Commands.argument("name", StringArgumentType.string()).executes(z->saveSchematic(z.getSource(), StringArgumentType.getString(z, "name")))));
|
||||||
|
|
||||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||||
//String arg = StringArgumentType.getString(command, "nickname");
|
//String arg = StringArgumentType.getString(command, "nickname");
|
||||||
//return setHome(command.getSource(), arg);
|
//return setHome(command.getSource(), arg);
|
||||||
//}));
|
//}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int saveSchematic(CommandSourceStack source, String name) {
|
private static int saveSchematic(CommandSourceStack source, String name) {
|
||||||
// Perform sanity checks
|
// Perform sanity checks
|
||||||
|
|
||||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||||
if(play==null)return 1;
|
if(play==null)return 1;
|
||||||
|
|
||||||
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_save)){
|
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_save)){
|
||||||
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_save, Permissions.zschem);
|
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_save, Permissions.zschem);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(MemoryHolder.hasPlayerCached(play))
|
if(MemoryHolder.hasPlayerCached(play))
|
||||||
{
|
{
|
||||||
Container cont = MemoryHolder.getContainer(play);
|
Container cont = MemoryHolder.getContainer(play);
|
||||||
if(cont == null)
|
if(cont == null)
|
||||||
{
|
{
|
||||||
|
|
||||||
saveSchematicUsage(source);
|
saveSchematicUsage(source);
|
||||||
}else {
|
}else {
|
||||||
if(cont.Pos1 != ThresholdsMod.ZERO_VECTOR && cont.Pos2 != ThresholdsMod.ZERO_VECTOR)
|
if(cont.Pos1 != OTEMod.ZERO_VECTOR && cont.Pos2 != OTEMod.ZERO_VECTOR)
|
||||||
{
|
{
|
||||||
// Lets go!
|
// Lets go!
|
||||||
List<StoredBlock> blocks = new ArrayList<StoredBlock>();
|
List<StoredBlock> blocks = new ArrayList<StoredBlock>();
|
||||||
// First we calculate every vector between pos1 and pos2.
|
// First we calculate every vector between pos1 and pos2.
|
||||||
// Then we subtract pos1 from the vector to acquire a relative position.
|
// Then we subtract pos1 from the vector to acquire a relative position.
|
||||||
// Then we save the block with this relative position to the blocks list
|
// Then we save the block with this relative position to the blocks list
|
||||||
// Once serialized, it is then possible to add the position. Note that this makes it impossible to rotate a zschem like with worldedit, but thats usually fine for our usecases. once in-game worldedit can be used to rotate.
|
// Once serialized, it is then possible to add the position. Note that this makes it impossible to rotate a zschem like with worldedit, but thats usually fine for our usecases. once in-game worldedit can be used to rotate.
|
||||||
// TODO: Also- It is possible that a rotational implementation can be added in the future
|
// TODO: Also- It is possible that a rotational implementation can be added in the future
|
||||||
|
|
||||||
List<Vector3> positions = cont.Pos1.makeCube(cont.Pos2);
|
List<Vector3> positions = cont.Pos1.makeCube(cont.Pos2);
|
||||||
|
|
||||||
for (Vector3 vector3 : positions) {
|
for (Vector3 vector3 : positions) {
|
||||||
Vector3 v3 = vector3.subtract(cont.Pos1);
|
Vector3 v3 = vector3.subtract(cont.Pos1);
|
||||||
|
|
||||||
BlockPos current = vector3.asBlockPos();
|
BlockPos current = vector3.asBlockPos();
|
||||||
|
|
||||||
StoredBlock sb = new StoredBlock(current, cont.lvl.getBlockState(current), cont.lvl);
|
StoredBlock sb = new StoredBlock(current, cont.lvl.getBlockState(current), cont.lvl);
|
||||||
sb.setPosition(v3);
|
sb.setPosition(v3);
|
||||||
|
|
||||||
blocks.add(sb);
|
blocks.add(sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundTag savedSchem = new CompoundTag();
|
CompoundTag savedSchem = new CompoundTag();
|
||||||
ListTag lst = new ListTag();
|
ListTag lst = new ListTag();
|
||||||
for (StoredBlock sBlock : blocks) {
|
for (StoredBlock sBlock : blocks) {
|
||||||
lst.add(sBlock.serialize());
|
lst.add(sBlock.serialize());
|
||||||
}
|
}
|
||||||
savedSchem.put("blocks", lst);
|
savedSchem.put("blocks", lst);
|
||||||
|
|
||||||
|
|
||||||
Path configDir = FMLPaths.GAMEDIR.get().resolve(FMLConfig.defaultConfigPath());
|
Path configDir = FMLPaths.GAMEDIR.get().resolve(FMLConfig.defaultConfigPath());
|
||||||
configDir = configDir.resolve("ZSchems");
|
configDir = configDir.resolve("ZSchems");
|
||||||
File X = configDir.toFile();
|
File X = configDir.toFile();
|
||||||
if(!X.exists())
|
if(!X.exists())
|
||||||
{
|
{
|
||||||
X.mkdir();
|
X.mkdir();
|
||||||
}
|
}
|
||||||
configDir = configDir.resolve(name+"-zschem.nbt");
|
configDir = configDir.resolve(name+"-zschem.nbt");
|
||||||
|
|
||||||
// Save file!
|
// Save file!
|
||||||
try {
|
try {
|
||||||
NbtIo.writeCompressed(savedSchem, configDir.toFile());
|
NbtIo.writeCompressed(savedSchem, configDir.toFile());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Green!ZSchem saved to disk!"), ThresholdsMod.THE_SERVER);
|
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Green!ZSchem saved to disk!"), OTEMod.THE_SERVER);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro("!Dark_Red! You must first set the positions"), ThresholdsMod.THE_SERVER);
|
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro("!Dark_Red! You must first set the positions"), OTEMod.THE_SERVER);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int saveSchematicUsage(CommandSourceStack source)
|
private static int saveSchematicUsage(CommandSourceStack source)
|
||||||
{
|
{
|
||||||
String usage = ThresholdsMod.ThresholdsPrefix;
|
String usage = OTEMod.OTEPrefix;
|
||||||
usage += "!gold! /savezschem [string:name]";
|
usage += "!gold! /savezschem [string:name]";
|
||||||
ServerPlayer play=(ServerPlayer)source.getEntity();
|
ServerPlayer play=(ServerPlayer)source.getEntity();
|
||||||
if(play==null)return 1;
|
if(play==null)return 1;
|
||||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(usage), ThresholdsMod.THE_SERVER);
|
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(usage), OTEMod.THE_SERVER);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,44 +1,44 @@
|
||||||
package dev.zontreck.thresholds.commands.zschem;
|
package dev.zontreck.otemod.commands.zschem;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.integrations.LuckPermsHelper;
|
import dev.zontreck.otemod.integrations.LuckPermsHelper;
|
||||||
import dev.zontreck.thresholds.permissions.Permissions;
|
import dev.zontreck.otemod.permissions.Permissions;
|
||||||
import dev.zontreck.thresholds.zschem.MemoryHolder;
|
import dev.zontreck.otemod.zschem.MemoryHolder;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
|
||||||
public class SetPos1 {
|
public class SetPos1 {
|
||||||
|
|
||||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||||
{
|
{
|
||||||
dispatcher.register(Commands.literal("zpos1").executes(c-> setzPos1(c.getSource())));
|
dispatcher.register(Commands.literal("zpos1").executes(c-> setzPos1(c.getSource())));
|
||||||
|
|
||||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||||
//String arg = StringArgumentType.getString(command, "nickname");
|
//String arg = StringArgumentType.getString(command, "nickname");
|
||||||
//return setHome(command.getSource(), arg);
|
//return setHome(command.getSource(), arg);
|
||||||
//}));
|
//}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int setzPos1(CommandSourceStack source) {
|
private static int setzPos1(CommandSourceStack source) {
|
||||||
|
|
||||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||||
if(play==null)return 1;
|
if(play==null)return 1;
|
||||||
|
|
||||||
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_pos1)){
|
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_pos1)){
|
||||||
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_pos1, Permissions.zschem);
|
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_pos1, Permissions.zschem);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
MemoryHolder.setPos1(play, new Vector3(source.getPosition()));
|
MemoryHolder.setPos1(play, new Vector3(source.getPosition()));
|
||||||
MemoryHolder.setLevel(play, source.getLevel());
|
MemoryHolder.setLevel(play, source.getLevel());
|
||||||
|
|
||||||
ChatHelpers.broadcastTo(play.getUUID(), Component.literal(ThresholdsMod.ThresholdsPrefix +ChatColor.doColors(" !Dark_Green!Position 1 set!")), ThresholdsMod.THE_SERVER);
|
ChatHelpers.broadcastTo(play.getUUID(), Component.literal(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Position 1 set!")), OTEMod.THE_SERVER);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,44 +1,44 @@
|
||||||
package dev.zontreck.thresholds.commands.zschem;
|
package dev.zontreck.otemod.commands.zschem;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.integrations.LuckPermsHelper;
|
import dev.zontreck.otemod.integrations.LuckPermsHelper;
|
||||||
import dev.zontreck.thresholds.permissions.Permissions;
|
import dev.zontreck.otemod.permissions.Permissions;
|
||||||
import dev.zontreck.thresholds.zschem.MemoryHolder;
|
import dev.zontreck.otemod.zschem.MemoryHolder;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
|
||||||
public class SetPos2 {
|
public class SetPos2 {
|
||||||
|
|
||||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||||
{
|
{
|
||||||
dispatcher.register(Commands.literal("zpos2").executes(c-> setzPos2(c.getSource())));
|
dispatcher.register(Commands.literal("zpos2").executes(c-> setzPos2(c.getSource())));
|
||||||
|
|
||||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||||
//String arg = StringArgumentType.getString(command, "nickname");
|
//String arg = StringArgumentType.getString(command, "nickname");
|
||||||
//return setHome(command.getSource(), arg);
|
//return setHome(command.getSource(), arg);
|
||||||
//}));
|
//}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int setzPos2(CommandSourceStack source) {
|
private static int setzPos2(CommandSourceStack source) {
|
||||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||||
if(play==null)return 1;
|
if(play==null)return 1;
|
||||||
|
|
||||||
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_pos2)){
|
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_pos2)){
|
||||||
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_pos2, Permissions.zschem);
|
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_pos2, Permissions.zschem);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryHolder.setPos2(play, new Vector3(source.getPosition()));
|
MemoryHolder.setPos2(play, new Vector3(source.getPosition()));
|
||||||
MemoryHolder.setLevel(play, source.getLevel());
|
MemoryHolder.setLevel(play, source.getLevel());
|
||||||
|
|
||||||
ChatHelpers.broadcastTo(play.getUUID(), Component.literal(ThresholdsMod.ThresholdsPrefix +ChatColor.doColors(" !Dark_Green!Position 2 set!")), ThresholdsMod.THE_SERVER);
|
ChatHelpers.broadcastTo(play.getUUID(), Component.literal(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Position 2 set!")), OTEMod.THE_SERVER);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,95 +1,96 @@
|
||||||
package dev.zontreck.thresholds.configs;
|
package dev.zontreck.otemod.configs;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraftforge.common.ForgeConfigSpec;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
public class ThresholdsServerConfig {
|
|
||||||
public static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
|
public class OTEServerConfig {
|
||||||
public static final ForgeConfigSpec SPEC;
|
public static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
|
||||||
|
public static final ForgeConfigSpec SPEC;
|
||||||
public static final ForgeConfigSpec.ConfigValue<Double> SPAWN_EGG_CHANCE;
|
|
||||||
|
public static final ForgeConfigSpec.ConfigValue<Double> SPAWN_EGG_CHANCE;
|
||||||
public static final ForgeConfigSpec.ConfigValue<Integer> ITEM_DESPAWN_TIMER;
|
|
||||||
|
public static final ForgeConfigSpec.ConfigValue<Integer> ITEM_DESPAWN_TIMER;
|
||||||
|
|
||||||
public static final ForgeConfigSpec.ConfigValue<Integer> RTP_COOLDOWN;
|
|
||||||
|
public static final ForgeConfigSpec.ConfigValue<Integer> RTP_COOLDOWN;
|
||||||
|
|
||||||
public static final ForgeConfigSpec.ConfigValue<Integer> HEALER_TIMER;
|
|
||||||
public static final ForgeConfigSpec.BooleanValue DEBUG_HEALER;
|
public static final ForgeConfigSpec.ConfigValue<Integer> HEALER_TIMER;
|
||||||
public static final ForgeConfigSpec.ConfigValue<Integer> TIME_BETWEEN_BLOCKS;
|
public static final ForgeConfigSpec.BooleanValue DEBUG_HEALER;
|
||||||
public static final ForgeConfigSpec.ConfigValue<Integer> MAX_TRIES_HEAL;
|
public static final ForgeConfigSpec.ConfigValue<Integer> TIME_BETWEEN_BLOCKS;
|
||||||
public static final ForgeConfigSpec.ConfigValue<Integer> MAX_VAULTS;
|
public static final ForgeConfigSpec.ConfigValue<Integer> MAX_TRIES_HEAL;
|
||||||
public static final ForgeConfigSpec.ConfigValue<List<String>> EXCLUDE_DIMS;
|
public static final ForgeConfigSpec.ConfigValue<Integer> MAX_VAULTS;
|
||||||
|
public static final ForgeConfigSpec.ConfigValue<List<String>> EXCLUDE_DIMS;
|
||||||
public static final ForgeConfigSpec.ConfigValue<Double> CHANCE_OF_PLAYER_HEAD;
|
|
||||||
public static final ForgeConfigSpec.ConfigValue<Boolean> ENABLE_PLAYER_HEAD_DROPS;
|
public static final ForgeConfigSpec.ConfigValue<Double> CHANCE_OF_PLAYER_HEAD;
|
||||||
|
public static final ForgeConfigSpec.ConfigValue<Boolean> ENABLE_PLAYER_HEAD_DROPS;
|
||||||
|
|
||||||
public static final ForgeConfigSpec.BooleanValue USE_CUSTOM_JOINLEAVE;
|
|
||||||
public static final ForgeConfigSpec.BooleanValue USE_CUSTOM_CHATREPLACER;
|
public static final ForgeConfigSpec.BooleanValue USE_CUSTOM_JOINLEAVE;
|
||||||
|
public static final ForgeConfigSpec.BooleanValue USE_CUSTOM_CHATREPLACER;
|
||||||
public static final ForgeConfigSpec.ConfigValue<Boolean> ENABLE_DEATH_MESSAGES;
|
|
||||||
|
public static final ForgeConfigSpec.ConfigValue<Boolean> ENABLE_DEATH_MESSAGES;
|
||||||
public static final ForgeConfigSpec.ConfigValue<Boolean> GIVE_KIT_EVERY_CHANGE;
|
|
||||||
|
public static final ForgeConfigSpec.ConfigValue<Boolean> GIVE_KIT_EVERY_CHANGE;
|
||||||
public static final ForgeConfigSpec.ConfigValue<Boolean> DEBUG;
|
|
||||||
|
public static final ForgeConfigSpec.ConfigValue<Boolean> DEBUG;
|
||||||
static {
|
|
||||||
List<String> defaultExcludeDimensions = new ArrayList<String>();
|
static {
|
||||||
defaultExcludeDimensions.add("minecraft:the_nether"); // Excluded to make mining for Ancient Debris easier
|
List<String> defaultExcludeDimensions = new ArrayList<String>();
|
||||||
defaultExcludeDimensions.add("minecraft:the_end"); // Excluded due to End Crystals
|
defaultExcludeDimensions.add("minecraft:the_nether"); // Excluded to make mining for Ancient Debris easier
|
||||||
|
defaultExcludeDimensions.add("minecraft:the_end"); // Excluded due to End Crystals
|
||||||
BUILDER.push("OTE");
|
|
||||||
DEBUG = BUILDER.comment("Turn on debug messages in the console for all OTE functions? This could be spammy").define("debug_enabled", false);
|
BUILDER.push("OTE");
|
||||||
|
DEBUG = BUILDER.comment("Turn on debug messages in the console for all OTE functions? This could be spammy").define("debug_enabled", false);
|
||||||
BUILDER.push("STARTERKIT");
|
|
||||||
GIVE_KIT_EVERY_CHANGE = BUILDER.comment("Enable this to give the starter kit every time it is changed, regardless of whether the player has already received that kit on their next join.").define("starter_kit_given_on_change", false);
|
BUILDER.push("STARTERKIT");
|
||||||
|
GIVE_KIT_EVERY_CHANGE = BUILDER.comment("Enable this to give the starter kit every time it is changed, regardless of whether the player has already received that kit on their next join.").define("starter_kit_given_on_change", false);
|
||||||
BUILDER.pop();
|
|
||||||
|
BUILDER.pop();
|
||||||
|
|
||||||
MAX_VAULTS = BUILDER.comment("What is the maximum number of vaults a player may have available? (0 is unlimited)").define("max_vaults", 0);
|
|
||||||
ITEM_DESPAWN_TIMER = BUILDER.comment("How many times should the item's expire be cancelled. The vanilla expire time is 5 minutes, so this would be ticked down once every 5 minutes.").define("item_extra_lives", 2);
|
MAX_VAULTS = BUILDER.comment("What is the maximum number of vaults a player may have available? (0 is unlimited)").define("max_vaults", 0);
|
||||||
ENABLE_DEATH_MESSAGES = BUILDER.comment("Whether you want to enable the death messages to be output by OTEMod when a player dies. These can be quite random!").define("enable_ote_death_msgs", true);
|
ITEM_DESPAWN_TIMER = BUILDER.comment("How many times should the item's expire be cancelled. The vanilla expire time is 5 minutes, so this would be ticked down once every 5 minutes.").define("item_extra_lives", 2);
|
||||||
|
ENABLE_DEATH_MESSAGES = BUILDER.comment("Whether you want to enable the death messages to be output by OTEMod when a player dies. These can be quite random!").define("enable_ote_death_msgs", true);
|
||||||
BUILDER.push("drops");
|
|
||||||
ENABLE_PLAYER_HEAD_DROPS = BUILDER.comment("Whether to enable dropping of player Heads").define("enable_player_head_drops", true);
|
BUILDER.push("drops");
|
||||||
SPAWN_EGG_CHANCE = BUILDER.comment("What is the chance for a spawn egg to drop from a mob when looting 3 is used? Default: 0.25").define("spawn_egg_chance", 0.25);
|
ENABLE_PLAYER_HEAD_DROPS = BUILDER.comment("Whether to enable dropping of player Heads").define("enable_player_head_drops", true);
|
||||||
CHANCE_OF_PLAYER_HEAD = BUILDER.comment("Chance of a player head dropping on death").define("player_death_drops_head", 0.5);
|
SPAWN_EGG_CHANCE = BUILDER.comment("What is the chance for a spawn egg to drop from a mob when looting 3 is used? Default: 0.25").define("spawn_egg_chance", 0.25);
|
||||||
|
CHANCE_OF_PLAYER_HEAD = BUILDER.comment("Chance of a player head dropping on death").define("player_death_drops_head", 0.5);
|
||||||
BUILDER.pop();
|
|
||||||
BUILDER.pop();
|
BUILDER.pop();
|
||||||
BUILDER.push("COMMANDS");
|
BUILDER.pop();
|
||||||
|
BUILDER.push("COMMANDS");
|
||||||
|
|
||||||
RTP_COOLDOWN = BUILDER.comment("How many seconds between RTP uses? This can be quite laggy on the server due to the potential that new chunks are getting generated").define("rtp.cooldown", 30); // Default of 30 should be enough
|
|
||||||
|
RTP_COOLDOWN = BUILDER.comment("How many seconds between RTP uses? This can be quite laggy on the server due to the potential that new chunks are getting generated").define("rtp.cooldown", 30); // Default of 30 should be enough
|
||||||
BUILDER.pop();
|
|
||||||
BUILDER.push("ANTIGRIEF").comment("AntiGrief Explosion Healing Events");
|
BUILDER.pop();
|
||||||
HEALER_TIMER = BUILDER.comment("Time between healing events (In Milliseconds)").define("timer", 250); // Should this be lower?
|
BUILDER.push("ANTIGRIEF").comment("AntiGrief Explosion Healing Events");
|
||||||
DEBUG_HEALER = BUILDER.comment("Whether or not to debug the healer engine. (Saves as SNBT instead of NBT)").define("debug", false);
|
HEALER_TIMER = BUILDER.comment("Time between healing events (In Milliseconds)").define("timer", 250); // Should this be lower?
|
||||||
TIME_BETWEEN_BLOCKS = BUILDER.comment("The amount of time between restoring blocks (Maximum). This is in ticks").define("time_between", 25);
|
DEBUG_HEALER = BUILDER.comment("Whether or not to debug the healer engine. (Saves as SNBT instead of NBT)").define("debug", false);
|
||||||
|
TIME_BETWEEN_BLOCKS = BUILDER.comment("The amount of time between restoring blocks (Maximum). This is in ticks").define("time_between", 25);
|
||||||
MAX_TRIES_HEAL = BUILDER.comment("Maximum amount of retries to restore a block").define("max_tries", 6);
|
|
||||||
|
MAX_TRIES_HEAL = BUILDER.comment("Maximum amount of retries to restore a block").define("max_tries", 6);
|
||||||
List<String> defDims = new ArrayList<String>();
|
|
||||||
defDims.add("minecraft:the_end");
|
List<String> defDims = new ArrayList<String>();
|
||||||
defDims.add("minecraft:the_nether");
|
defDims.add("minecraft:the_end");
|
||||||
defDims.add("thresholds:resource");
|
defDims.add("minecraft:the_nether");
|
||||||
EXCLUDE_DIMS = BUILDER.comment("Dimension names (ex. minecraft:overworld) to exclude from the explosion healing events").define("exclude_dimensions", defDims);
|
defDims.add("otemod:resource");
|
||||||
|
EXCLUDE_DIMS = BUILDER.comment("Dimension names (ex. minecraft:overworld) to exclude from the explosion healing events").define("exclude_dimensions", defDims);
|
||||||
BUILDER.pop();
|
|
||||||
|
BUILDER.pop();
|
||||||
BUILDER.push("CHATSERVER");
|
|
||||||
USE_CUSTOM_JOINLEAVE = BUILDER.comment("Whether to use the custom join and leave messages").define("join_leave_messages", true);
|
BUILDER.push("CHATSERVER");
|
||||||
USE_CUSTOM_CHATREPLACER = BUILDER.comment("Whether to use the custom chat replacer (If disabled the relevant commands will be removed)").define("chatprettifier", true);
|
USE_CUSTOM_JOINLEAVE = BUILDER.comment("Whether to use the custom join and leave messages").define("join_leave_messages", true);
|
||||||
|
USE_CUSTOM_CHATREPLACER = BUILDER.comment("Whether to use the custom chat replacer (If disabled the relevant commands will be removed)").define("chatprettifier", true);
|
||||||
BUILDER.pop();
|
|
||||||
|
BUILDER.pop();
|
||||||
SPEC=BUILDER.build();
|
|
||||||
}
|
SPEC=BUILDER.build();
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -1,27 +1,27 @@
|
||||||
package dev.zontreck.thresholds.configs;
|
package dev.zontreck.otemod.configs;
|
||||||
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.entity.player.Abilities;
|
import net.minecraft.world.entity.player.Abilities;
|
||||||
|
|
||||||
public class PlayerFlyCache
|
public class PlayerFlyCache
|
||||||
{
|
{
|
||||||
public boolean FlyEnabled;
|
public boolean FlyEnabled;
|
||||||
public boolean Flying;
|
public boolean Flying;
|
||||||
public static PlayerFlyCache cachePlayer(ServerPlayer play){
|
public static PlayerFlyCache cachePlayer(ServerPlayer play){
|
||||||
PlayerFlyCache cache = new PlayerFlyCache();
|
PlayerFlyCache cache = new PlayerFlyCache();
|
||||||
cache.FlyEnabled = play.getAbilities().mayfly;
|
cache.FlyEnabled = play.getAbilities().mayfly;
|
||||||
cache.Flying = play.getAbilities().flying;
|
cache.Flying = play.getAbilities().flying;
|
||||||
|
|
||||||
play.onUpdateAbilities();
|
play.onUpdateAbilities();
|
||||||
|
|
||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Assert(ServerPlayer play){
|
public void Assert(ServerPlayer play){
|
||||||
Abilities playerAbilities = play.getAbilities();
|
Abilities playerAbilities = play.getAbilities();
|
||||||
playerAbilities.flying=Flying;
|
playerAbilities.flying=Flying;
|
||||||
playerAbilities.mayfly=FlyEnabled;
|
playerAbilities.mayfly=FlyEnabled;
|
||||||
|
|
||||||
play.onUpdateAbilities();
|
play.onUpdateAbilities();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package dev.zontreck.thresholds.database;
|
package dev.zontreck.otemod.database;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
|
@ -1,17 +1,19 @@
|
||||||
package dev.zontreck.thresholds.effects;
|
package dev.zontreck.otemod.effects;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.LibZontreck;
|
import dev.zontreck.libzontreck.LibZontreck;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import dev.zontreck.libzontreck.util.ItemUtils;
|
import dev.zontreck.libzontreck.util.ItemUtils;
|
||||||
import dev.zontreck.libzontreck.util.ServerUtilities;
|
import dev.zontreck.libzontreck.util.ServerUtilities;
|
||||||
import dev.zontreck.thresholds.enchantments.ModEnchantments;
|
import dev.zontreck.otemod.enchantments.ModEnchantments;
|
||||||
import dev.zontreck.thresholds.implementation.Messages;
|
import dev.zontreck.otemod.implementation.Messages;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.effect.MobEffect;
|
import net.minecraft.world.effect.MobEffect;
|
||||||
import net.minecraft.world.effect.MobEffectCategory;
|
import net.minecraft.world.effect.MobEffectCategory;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
import net.minecraft.world.entity.ai.attributes.AttributeMap;
|
||||||
|
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||||
import net.minecraft.world.entity.player.Abilities;
|
import net.minecraft.world.entity.player.Abilities;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
|
@ -1,6 +1,6 @@
|
||||||
package dev.zontreck.thresholds.effects;
|
package dev.zontreck.otemod.effects;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import net.minecraft.world.effect.MobEffect;
|
import net.minecraft.world.effect.MobEffect;
|
||||||
import net.minecraft.world.effect.MobEffectCategory;
|
import net.minecraft.world.effect.MobEffectCategory;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
|
@ -10,7 +10,7 @@ import net.minecraftforge.registries.RegistryObject;
|
||||||
|
|
||||||
public class ModEffects
|
public class ModEffects
|
||||||
{
|
{
|
||||||
public static final DeferredRegister<MobEffect> REGISTRY = DeferredRegister.create(ForgeRegistries.MOB_EFFECTS, ThresholdsMod.MOD_ID);
|
public static final DeferredRegister<MobEffect> REGISTRY = DeferredRegister.create(ForgeRegistries.MOB_EFFECTS, OTEMod.MOD_ID);
|
||||||
|
|
||||||
public static final RegistryObject<MobEffect> FLIGHT = REGISTRY.register("flight", ()->new FlightEffect(MobEffectCategory.BENEFICIAL, 0xFF0000FF));
|
public static final RegistryObject<MobEffect> FLIGHT = REGISTRY.register("flight", ()->new FlightEffect(MobEffectCategory.BENEFICIAL, 0xFF0000FF));
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package dev.zontreck.thresholds.enchantments;
|
package dev.zontreck.otemod.enchantments;
|
||||||
|
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.item.enchantment.Enchantment;
|
import net.minecraft.world.item.enchantment.Enchantment;
|
|
@ -1,106 +1,117 @@
|
||||||
package dev.zontreck.thresholds.enchantments;
|
package dev.zontreck.otemod.enchantments;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.util.ItemUtils;
|
import dev.zontreck.libzontreck.util.ItemUtils;
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.configs.ThresholdsServerConfig;
|
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||||
import dev.zontreck.thresholds.effects.ModEffects;
|
import dev.zontreck.otemod.effects.ModEffects;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.effect.MobEffect;
|
||||||
import net.minecraft.world.item.enchantment.Enchantment;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraftforge.event.TickEvent;
|
import net.minecraft.world.entity.player.Abilities;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraftforge.fml.LogicalSide;
|
import net.minecraft.world.item.ArmorItem;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.enchantment.Enchantment;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||||
|
import net.minecraft.world.item.enchantment.Enchantments;
|
||||||
@Mod.EventBusSubscriber(modid = ThresholdsMod.MOD_ID)
|
import net.minecraft.world.item.enchantment.SoulSpeedEnchantment;
|
||||||
public class FlightEnchantment extends Enchantment
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
{
|
import net.minecraftforge.event.TickEvent;
|
||||||
|
import net.minecraftforge.event.entity.living.LivingEquipmentChangeEvent;
|
||||||
public FlightEnchantment(EquipmentSlot... slots)
|
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||||
{
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
super(Rarity.VERY_RARE, EnchantmentCategory.ARMOR_FEET, slots);
|
import net.minecraftforge.fml.LogicalSide;
|
||||||
}
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
@Override
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
public int getMaxLevel()
|
|
||||||
{
|
@Mod.EventBusSubscriber(modid = OTEMod.MOD_ID)
|
||||||
return 1;
|
public class FlightEnchantment extends Enchantment
|
||||||
}
|
{
|
||||||
|
|
||||||
@Override
|
public FlightEnchantment(EquipmentSlot... slots)
|
||||||
public int getMinCost(int level)
|
{
|
||||||
{
|
super(Rarity.VERY_RARE, EnchantmentCategory.ARMOR_FEET, slots);
|
||||||
return 28 + (level - 1) * 15;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public int getMaxLevel()
|
||||||
public int getMaxCost(int level)
|
{
|
||||||
{
|
return 1;
|
||||||
return this.getMinCost(level) + 15;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public int getMinCost(int level)
|
||||||
public boolean isTreasureOnly(){
|
{
|
||||||
return true;
|
return 28 + (level - 1) * 15;
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public boolean isTradeable()
|
@Override
|
||||||
{
|
public int getMaxCost(int level)
|
||||||
return true;
|
{
|
||||||
}
|
return this.getMinCost(level) + 15;
|
||||||
|
}
|
||||||
// Not a bug. Flight is meant to be a permanent upgrade to a item. It is considered a curse due to unstable behavior. Flight will eat up durability and forge energy
|
|
||||||
// Flight should NOT be able to be removed via the grindstone
|
@Override
|
||||||
@Override
|
public boolean isTreasureOnly(){
|
||||||
public boolean isCurse()
|
return true;
|
||||||
{
|
}
|
||||||
return true;
|
@Override
|
||||||
}
|
public boolean isTradeable()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
public static AtomicInteger TICKS = new AtomicInteger(0);
|
}
|
||||||
@SubscribeEvent
|
|
||||||
public static void onEnchantmentTick(TickEvent.PlayerTickEvent event)
|
// Not a bug. Flight is meant to be a permanent upgrade to a item. It is considered a curse due to unstable behavior. Flight will eat up durability and forge energy
|
||||||
{
|
// Flight should NOT be able to be removed via the grindstone
|
||||||
if(event.side == LogicalSide.CLIENT) return;
|
@Override
|
||||||
|
public boolean isCurse()
|
||||||
if(TICKS.getAndIncrement() >= (5*20))
|
{
|
||||||
{
|
return true;
|
||||||
TICKS.set(0);
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static AtomicInteger TICKS = new AtomicInteger(0);
|
||||||
if(ThresholdsServerConfig.DEBUG.get())
|
@SubscribeEvent
|
||||||
{
|
public static void onEnchantmentTick(TickEvent.PlayerTickEvent event)
|
||||||
ThresholdsMod.LOGGER.info("> Flight Enchantment Tick <");
|
{
|
||||||
}
|
if(event.side == LogicalSide.CLIENT) return;
|
||||||
|
|
||||||
if(event.phase == TickEvent.Phase.END)
|
if(TICKS.getAndIncrement() >= (5*20))
|
||||||
{
|
{
|
||||||
|
TICKS.set(0);
|
||||||
ServerPlayer sp = (ServerPlayer) event.player;
|
|
||||||
|
|
||||||
ItemStack feet = sp.getItemBySlot(EquipmentSlot.FEET);
|
|
||||||
|
if(OTEServerConfig.DEBUG.get())
|
||||||
boolean hasFlight = false;
|
{
|
||||||
|
OTEMod.LOGGER.info("> Flight Enchantment Tick <");
|
||||||
if(ItemUtils.getEnchantmentLevel(ModEnchantments.FLIGHT_ENCHANTMENT.get(), feet)>0)hasFlight=true;
|
}
|
||||||
|
|
||||||
if(hasFlight)
|
if(event.phase == TickEvent.Phase.END)
|
||||||
{
|
{
|
||||||
MobEffectInstance inst = new MobEffectInstance(ModEffects.FLIGHT.get(), -1, 0, false, false, true);
|
|
||||||
|
ServerPlayer sp = (ServerPlayer) event.player;
|
||||||
event.player.addEffect(inst);
|
|
||||||
}
|
ItemStack feet = sp.getItemBySlot(EquipmentSlot.FEET);
|
||||||
}
|
|
||||||
}
|
boolean hasFlight = false;
|
||||||
|
|
||||||
|
if(ItemUtils.getEnchantmentLevel(ModEnchantments.FLIGHT_ENCHANTMENT.get(), feet)>0)hasFlight=true;
|
||||||
}
|
|
||||||
|
if(hasFlight)
|
||||||
}
|
{
|
||||||
|
MobEffectInstance inst = new MobEffectInstance(ModEffects.FLIGHT.get(), -1, 0, false, false, true);
|
||||||
|
|
||||||
|
event.player.addEffect(inst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,75 +1,78 @@
|
||||||
package dev.zontreck.thresholds.enchantments;
|
package dev.zontreck.otemod.enchantments;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import java.util.Random;
|
||||||
import dev.zontreck.thresholds.configs.ThresholdsServerConfig;
|
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||||
import net.minecraft.world.item.enchantment.Enchantment;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.SwordItem;
|
||||||
public class MobEggEnchantment extends Enchantment
|
import net.minecraft.world.item.enchantment.Enchantment;
|
||||||
{
|
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||||
public static final String TAG_BIAS = "mob_egging_bias";
|
|
||||||
|
public class MobEggEnchantment extends Enchantment
|
||||||
public MobEggEnchantment()
|
{
|
||||||
{
|
public static final String TAG_BIAS = "mob_egging_bias";
|
||||||
super(Rarity.VERY_RARE, EnchantmentCategory.WEAPON, new EquipmentSlot[] {EquipmentSlot.MAINHAND});
|
|
||||||
}
|
public MobEggEnchantment()
|
||||||
|
{
|
||||||
@Override
|
super(Rarity.VERY_RARE, EnchantmentCategory.WEAPON, new EquipmentSlot[] {EquipmentSlot.MAINHAND});
|
||||||
public int getMaxLevel()
|
}
|
||||||
{
|
|
||||||
return 6;
|
@Override
|
||||||
}
|
public int getMaxLevel()
|
||||||
|
{
|
||||||
@Override
|
return 6;
|
||||||
public int getMinCost(int level)
|
}
|
||||||
{
|
|
||||||
return 28 + (level - 1) * 15;
|
@Override
|
||||||
}
|
public int getMinCost(int level)
|
||||||
|
{
|
||||||
@Override
|
return 28 + (level - 1) * 15;
|
||||||
public int getMaxCost(int level)
|
}
|
||||||
{
|
|
||||||
return this.getMinCost(level) + 15;
|
@Override
|
||||||
}
|
public int getMaxCost(int level)
|
||||||
|
{
|
||||||
|
return this.getMinCost(level) + 15;
|
||||||
@Override
|
}
|
||||||
public boolean canApplyAtEnchantingTable(ItemStack stack)
|
|
||||||
{
|
|
||||||
return super.canApplyAtEnchantingTable(stack);
|
@Override
|
||||||
}
|
public boolean canApplyAtEnchantingTable(ItemStack stack)
|
||||||
|
{
|
||||||
@Override
|
return super.canApplyAtEnchantingTable(stack);
|
||||||
public boolean isTreasureOnly(){
|
}
|
||||||
return false;
|
|
||||||
}
|
@Override
|
||||||
@Override
|
public boolean isTreasureOnly(){
|
||||||
public boolean isTradeable()
|
return false;
|
||||||
{
|
}
|
||||||
return true;
|
@Override
|
||||||
}
|
public boolean isTradeable()
|
||||||
|
{
|
||||||
@Override
|
return true;
|
||||||
public boolean isDiscoverable()
|
}
|
||||||
{
|
|
||||||
return false;
|
@Override
|
||||||
}
|
public boolean isDiscoverable()
|
||||||
|
{
|
||||||
public static boolean givesEgg(int level, int bias)
|
return false;
|
||||||
{
|
}
|
||||||
double CHANCE = ThresholdsServerConfig.SPAWN_EGG_CHANCE.get() * 100;
|
|
||||||
|
public static boolean givesEgg(int level, int bias)
|
||||||
CHANCE *= (level / 0.5);
|
{
|
||||||
CHANCE += bias;
|
double CHANCE = OTEServerConfig.SPAWN_EGG_CHANCE.get() * 100;
|
||||||
|
|
||||||
double rng = Math.random()*100000;
|
CHANCE *= (level / 0.5);
|
||||||
|
CHANCE += bias;
|
||||||
if(ThresholdsServerConfig.DEBUG.get())
|
|
||||||
{
|
double rng = Math.random()*100000;
|
||||||
ThresholdsMod.LOGGER.info("Spawn Egg Chance (" + CHANCE + ") [" + rng + "]");
|
|
||||||
}
|
if(OTEServerConfig.DEBUG.get())
|
||||||
return (rng <= CHANCE);
|
{
|
||||||
}
|
OTEMod.LOGGER.info("Spawn Egg Chance (" + CHANCE + ") [" + rng + "]");
|
||||||
}
|
}
|
||||||
|
return (rng <= CHANCE);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,28 +1,28 @@
|
||||||
package dev.zontreck.thresholds.enchantments;
|
package dev.zontreck.otemod.enchantments;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.item.enchantment.Enchantment;
|
import net.minecraft.world.item.enchantment.Enchantment;
|
||||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
|
|
||||||
public class ModEnchantments {
|
public class ModEnchantments {
|
||||||
|
|
||||||
protected static final EquipmentSlot[] ARMOR_SLOTS = new EquipmentSlot[]{EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET};
|
protected static final EquipmentSlot[] ARMOR_SLOTS = new EquipmentSlot[]{EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET};
|
||||||
public static final DeferredRegister<Enchantment> REGISTERS = DeferredRegister.create(ForgeRegistries.ENCHANTMENTS, ThresholdsMod.MOD_ID);
|
public static final DeferredRegister<Enchantment> REGISTERS = DeferredRegister.create(ForgeRegistries.ENCHANTMENTS, OTEMod.MOD_ID);
|
||||||
|
|
||||||
public static final RegistryObject<Enchantment> MOB_EGGING_ENCHANTMENT = REGISTERS.register("mob_egging", ()->new MobEggEnchantment());
|
public static final RegistryObject<Enchantment> MOB_EGGING_ENCHANTMENT = REGISTERS.register("mob_egging", ()->new MobEggEnchantment());
|
||||||
|
|
||||||
public static final RegistryObject<Enchantment> FLIGHT_ENCHANTMENT = REGISTERS.register("player_flight", ()->new FlightEnchantment(EquipmentSlot.FEET));
|
public static final RegistryObject<Enchantment> FLIGHT_ENCHANTMENT = REGISTERS.register("player_flight", ()->new FlightEnchantment(EquipmentSlot.FEET));
|
||||||
|
|
||||||
public static final RegistryObject<Enchantment> BORROWED_PROTECTION = REGISTERS.register("borrowed_protection", ()->new BorrowedProtectionEnchantment(Enchantment.Rarity.UNCOMMON, EnchantmentCategory.ARMOR, ARMOR_SLOTS));
|
public static final RegistryObject<Enchantment> BORROWED_PROTECTION = REGISTERS.register("borrowed_protection", ()->new BorrowedProtectionEnchantment(Enchantment.Rarity.UNCOMMON, EnchantmentCategory.ARMOR, ARMOR_SLOTS));
|
||||||
|
|
||||||
public static final RegistryObject<Enchantment> NIGHT_VISION_ENCHANT = REGISTERS.register("night_vision", ()->new NightVisionEnchantment(EquipmentSlot.HEAD));
|
public static final RegistryObject<Enchantment> NIGHT_VISION_ENCHANT = REGISTERS.register("night_vision", ()->new NightVisionEnchantment(EquipmentSlot.HEAD));
|
||||||
|
|
||||||
public static void register(IEventBus bus){
|
public static void register(IEventBus bus){
|
||||||
REGISTERS.register(bus);
|
REGISTERS.register(bus);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,9 @@
|
||||||
package dev.zontreck.thresholds.enchantments;
|
package dev.zontreck.otemod.enchantments;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.util.ItemUtils;
|
import dev.zontreck.libzontreck.util.ItemUtils;
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.configs.ThresholdsServerConfig;
|
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||||
|
import dev.zontreck.otemod.effects.ModEffects;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.world.effect.MobEffects;
|
import net.minecraft.world.effect.MobEffects;
|
||||||
|
@ -10,6 +11,7 @@ import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.enchantment.Enchantment;
|
import net.minecraft.world.item.enchantment.Enchantment;
|
||||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.event.TickEvent;
|
import net.minecraftforge.event.TickEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.LogicalSide;
|
import net.minecraftforge.fml.LogicalSide;
|
||||||
|
@ -17,7 +19,7 @@ import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = ThresholdsMod.MOD_ID)
|
@Mod.EventBusSubscriber(modid = OTEMod.MOD_ID)
|
||||||
public class NightVisionEnchantment extends Enchantment
|
public class NightVisionEnchantment extends Enchantment
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -62,9 +64,9 @@ public class NightVisionEnchantment extends Enchantment
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(ThresholdsServerConfig.DEBUG.get())
|
if(OTEServerConfig.DEBUG.get())
|
||||||
{
|
{
|
||||||
ThresholdsMod.LOGGER.info("> NVision Enchantment Tick <");
|
OTEMod.LOGGER.info("> NVision Enchantment Tick <");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(event.phase == TickEvent.Phase.END)
|
if(event.phase == TickEvent.Phase.END)
|
|
@ -1,6 +1,14 @@
|
||||||
package dev.zontreck.thresholds.entities;
|
package dev.zontreck.otemod.entities;
|
||||||
|
|
||||||
|
import dev.zontreck.otemod.OTEMod;
|
||||||
|
import dev.zontreck.otemod.entities.monsters.PossumEntity;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.entity.EntityType;
|
||||||
|
import net.minecraft.world.entity.MobCategory;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
|
|
||||||
public class ModEntityTypes {
|
public class ModEntityTypes {
|
||||||
//public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, OTEMod.MOD_ID);
|
//public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, OTEMod.MOD_ID);
|
|
@ -1,4 +1,4 @@
|
||||||
package dev.zontreck.thresholds.entities.monsters;
|
package dev.zontreck.otemod.entities.monsters;
|
||||||
|
|
||||||
|
|
||||||
public class PossumEntity
|
public class PossumEntity
|
|
@ -1,4 +1,4 @@
|
||||||
package dev.zontreck.thresholds.entities.monsters.client;
|
package dev.zontreck.otemod.entities.monsters.client;
|
||||||
|
|
||||||
|
|
||||||
public class PossumModel
|
public class PossumModel
|
|
@ -1,4 +1,4 @@
|
||||||
package dev.zontreck.thresholds.entities.monsters.client;
|
package dev.zontreck.otemod.entities.monsters.client;
|
||||||
|
|
||||||
|
|
||||||
public class PossumRenderer
|
public class PossumRenderer
|
|
@ -1,39 +1,39 @@
|
||||||
package dev.zontreck.thresholds.events;
|
package dev.zontreck.otemod.events;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.integrations.KeyBindings;
|
import dev.zontreck.otemod.integrations.KeyBindings;
|
||||||
import dev.zontreck.thresholds.networking.ModMessages;
|
import dev.zontreck.otemod.networking.ModMessages;
|
||||||
import dev.zontreck.thresholds.networking.packets.OpenVaultC2SPacket;
|
import dev.zontreck.otemod.networking.packets.OpenVaultC2SPacket;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.client.event.InputEvent;
|
import net.minecraftforge.client.event.InputEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
public class ClientEvents {
|
public class ClientEvents {
|
||||||
@Mod.EventBusSubscriber(modid = ThresholdsMod.MOD_ID, value = Dist.CLIENT)
|
@Mod.EventBusSubscriber(modid = OTEMod.MOD_ID, value = Dist.CLIENT)
|
||||||
public static class ForgeEvents
|
public static class ForgeEvents
|
||||||
{
|
{
|
||||||
// Timeout!
|
// Timeout!
|
||||||
static long lastPress;
|
static long lastPress;
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onKeyInput(InputEvent.Key event)
|
public static void onKeyInput(InputEvent.Key event)
|
||||||
{
|
{
|
||||||
//OTEMod.LOGGER.info("KEY PRESS: "+event.getKey());
|
//OTEMod.LOGGER.info("KEY PRESS: "+event.getKey());
|
||||||
if(KeyBindings.OPEN_VAULT.matches(event.getKey(), event.getScanCode()) && Minecraft.getInstance().screen == null && lastPress+10 < Instant.now().getEpochSecond())
|
if(KeyBindings.OPEN_VAULT.matches(event.getKey(), event.getScanCode()) && Minecraft.getInstance().screen == null && lastPress+10 < Instant.now().getEpochSecond())
|
||||||
{
|
{
|
||||||
lastPress = Instant.now().getEpochSecond();
|
lastPress = Instant.now().getEpochSecond();
|
||||||
ModMessages.sendToServer(new OpenVaultC2SPacket(0, false, 0));
|
ModMessages.sendToServer(new OpenVaultC2SPacket(0, false, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = ThresholdsMod.MOD_ID, value=Dist.CLIENT, bus=Mod.EventBusSubscriber.Bus.MOD)
|
@Mod.EventBusSubscriber(modid = OTEMod.MOD_ID, value=Dist.CLIENT, bus=Mod.EventBusSubscriber.Bus.MOD)
|
||||||
public static class ClientModBus
|
public static class ClientModBus
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,138 +1,143 @@
|
||||||
package dev.zontreck.thresholds.events;
|
package dev.zontreck.otemod.events;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.lore.LoreContainer;
|
import dev.zontreck.libzontreck.lore.LoreContainer;
|
||||||
import dev.zontreck.libzontreck.lore.LoreEntry;
|
import dev.zontreck.libzontreck.lore.LoreEntry;
|
||||||
import dev.zontreck.libzontreck.profiles.Profile;
|
import dev.zontreck.libzontreck.profiles.Profile;
|
||||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import dev.zontreck.libzontreck.util.ItemUtils;
|
import dev.zontreck.libzontreck.util.ItemUtils;
|
||||||
import dev.zontreck.libzontreck.util.heads.HeadUtilities;
|
import dev.zontreck.libzontreck.util.heads.HeadUtilities;
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.configs.ThresholdsServerConfig;
|
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||||
import dev.zontreck.thresholds.enchantments.MobEggEnchantment;
|
import dev.zontreck.otemod.enchantments.MobEggEnchantment;
|
||||||
import dev.zontreck.thresholds.enchantments.ModEnchantments;
|
import dev.zontreck.otemod.enchantments.ModEnchantments;
|
||||||
import dev.zontreck.thresholds.implementation.DeathMessages;
|
import dev.zontreck.otemod.implementation.DeathMessages;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import dev.zontreck.otemod.implementation.InventoryBackup;
|
||||||
import net.minecraft.network.chat.Component;
|
import dev.zontreck.otemod.items.tags.ItemStatType;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.entity.item.ItemEntity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.entity.item.ItemEntity;
|
||||||
import net.minecraft.world.item.enchantment.Enchantments;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraftforge.common.ForgeSpawnEggItem;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
import net.minecraft.world.item.enchantment.Enchantments;
|
||||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
import net.minecraft.world.level.GameType;
|
||||||
import net.minecraftforge.eventbus.api.EventPriority;
|
import net.minecraftforge.common.ForgeSpawnEggItem;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||||
|
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||||
import java.time.Instant;
|
import net.minecraftforge.eventbus.api.EventPriority;
|
||||||
import java.util.Date;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import java.util.Random;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
@Mod.EventBusSubscriber(modid= ThresholdsMod.MOD_ID)
|
|
||||||
public class EventHandler {
|
import java.time.Instant;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Random;
|
||||||
@SubscribeEvent (priority = EventPriority.HIGHEST)
|
|
||||||
public static void playerDied(LivingDeathEvent event)
|
@Mod.EventBusSubscriber(modid=OTEMod.MOD_ID)
|
||||||
{
|
public class EventHandler {
|
||||||
if(!(event.getEntity() instanceof Player))return;
|
|
||||||
|
|
||||||
Profile profile;
|
@SubscribeEvent (priority = EventPriority.HIGHEST)
|
||||||
try {
|
public static void playerDied(LivingDeathEvent event)
|
||||||
profile = Profile.get_profile_of(event.getEntity().getStringUUID());
|
{
|
||||||
} catch (UserProfileNotYetExistsException e) {
|
if(!(event.getEntity() instanceof Player))return;
|
||||||
e.printStackTrace();
|
|
||||||
return;
|
Profile profile;
|
||||||
}
|
try {
|
||||||
profile.deaths++;
|
profile = Profile.get_profile_of(event.getEntity().getStringUUID());
|
||||||
profile.commit();
|
} catch (UserProfileNotYetExistsException e) {
|
||||||
if(!ThresholdsServerConfig.ENABLE_PLAYER_HEAD_DROPS.get())
|
e.printStackTrace();
|
||||||
{
|
return;
|
||||||
return;
|
}
|
||||||
}
|
profile.deaths++;
|
||||||
int looting=0;
|
profile.commit();
|
||||||
//ServerPlayer killedPlayer = (ServerPlayer)ent;
|
if(!OTEServerConfig.ENABLE_PLAYER_HEAD_DROPS.get())
|
||||||
if(event.getEntity() instanceof Player){
|
{
|
||||||
ServerPlayer pla = profile.player;
|
return;
|
||||||
looting = ItemUtils.getEnchantmentLevel(Enchantments.MOB_LOOTING, pla.getMainHandItem());
|
}
|
||||||
|
int looting=0;
|
||||||
}
|
//ServerPlayer killedPlayer = (ServerPlayer)ent;
|
||||||
|
if(event.getEntity() instanceof Player){
|
||||||
// Calculate chance
|
ServerPlayer pla = profile.player;
|
||||||
double base_chance = ThresholdsServerConfig.CHANCE_OF_PLAYER_HEAD.get();
|
looting = ItemUtils.getEnchantmentLevel(Enchantments.MOB_LOOTING, pla.getMainHandItem());
|
||||||
base_chance += looting;
|
|
||||||
base_chance *= 100;
|
}
|
||||||
|
|
||||||
Random rng = new Random();
|
// Calculate chance
|
||||||
double num = rng.nextDouble(0,100000);
|
double base_chance = OTEServerConfig.CHANCE_OF_PLAYER_HEAD.get();
|
||||||
if(num <= base_chance)
|
base_chance += looting;
|
||||||
{
|
base_chance *= 100;
|
||||||
ItemStack head = HeadUtilities.get(profile.username, "").setHoverName(ChatHelpers.macro(profile.nickname+"'s Head"));
|
|
||||||
LoreContainer lore = new LoreContainer(head);
|
Random rng = new Random();
|
||||||
LoreEntry entry = new LoreEntry.Builder().bold(true).text(ChatHelpers.macroize("!dark_green!Player: " + profile.name_color+profile.username)).build();
|
double num = rng.nextDouble(0,100000);
|
||||||
lore.miscData.loreData.add(entry);
|
if(num <= base_chance)
|
||||||
|
{
|
||||||
entry = new LoreEntry.Builder().text(ChatHelpers.macroize("!Dark_Purple!Date: !Dark_Red![0]", Date.from(Instant.now()).toString())).build();
|
ItemStack head = HeadUtilities.get(profile.username, "").setHoverName(ChatHelpers.macro(profile.nickname+"'s Head"));
|
||||||
lore.miscData.loreData.add(entry);
|
LoreContainer lore = new LoreContainer(head);
|
||||||
|
LoreEntry entry = new LoreEntry.Builder().bold(true).text(ChatHelpers.macroize("!dark_green!Player: " + profile.name_color+profile.username)).build();
|
||||||
entry = new LoreEntry.Builder().text(ChatHelpers.macroize("!Dark_Purple!Total Deaths: !Dark_Red![0]", String.valueOf(profile.deaths))).build();
|
lore.miscData.loreData.add(entry);
|
||||||
lore.miscData.loreData.add(entry);
|
|
||||||
lore.commitLore();
|
entry = new LoreEntry.Builder().text(ChatHelpers.macroize("!Dark_Purple!Date: !Dark_Red![0]", Date.from(Instant.now()).toString())).build();
|
||||||
|
lore.miscData.loreData.add(entry);
|
||||||
|
|
||||||
event.getEntity().spawnAtLocation(head);
|
entry = new LoreEntry.Builder().text(ChatHelpers.macroize("!Dark_Purple!Total Deaths: !Dark_Red![0]", String.valueOf(profile.deaths))).build();
|
||||||
}
|
lore.miscData.loreData.add(entry);
|
||||||
|
lore.commitLore();
|
||||||
try {
|
|
||||||
ChatHelpers.broadcast(Component.literal(DeathMessages.getRandomDeathMessage(Profile.get_profile_of(event.getEntity().getStringUUID()), event.getSource())), event.getEntity().level().getServer());
|
|
||||||
} catch (UserProfileNotYetExistsException e) {
|
event.getEntity().spawnAtLocation(head);
|
||||||
// TODO Auto-generated catch block
|
}
|
||||||
e.printStackTrace();
|
|
||||||
}
|
try {
|
||||||
}
|
ChatHelpers.broadcast(Component.literal(DeathMessages.getRandomDeathMessage(Profile.get_profile_of(event.getEntity().getStringUUID()), event.getSource())), event.getEntity().level().getServer());
|
||||||
|
} catch (UserProfileNotYetExistsException e) {
|
||||||
@SubscribeEvent
|
// TODO Auto-generated catch block
|
||||||
public void onEntityKilled(LivingDropsEvent ev){
|
e.printStackTrace();
|
||||||
if(ev.getEntity().level().isClientSide)return;
|
}
|
||||||
|
}
|
||||||
Entity killedentity = ev.getEntity();
|
|
||||||
Entity ent = ev.getSource().getEntity();
|
@SubscribeEvent
|
||||||
if(ent instanceof Player)
|
public void onEntityKilled(LivingDropsEvent ev){
|
||||||
{
|
if(ev.getEntity().level().isClientSide)return;
|
||||||
ServerPlayer play = (ServerPlayer)ent;
|
|
||||||
LivingEntity killed = ev.getEntity();
|
Entity killedentity = ev.getEntity();
|
||||||
|
Entity ent = ev.getSource().getEntity();
|
||||||
ItemStack stack = play.getMainHandItem();
|
if(ent instanceof Player)
|
||||||
int levelOfEgging = ItemUtils.getEnchantmentLevel(ModEnchantments.MOB_EGGING_ENCHANTMENT.get(),stack);
|
{
|
||||||
|
ServerPlayer play = (ServerPlayer)ent;
|
||||||
if(levelOfEgging==0)return;
|
LivingEntity killed = ev.getEntity();
|
||||||
CompoundTag tag = stack.getTag();
|
|
||||||
int bias = tag.getInt(MobEggEnchantment.TAG_BIAS);
|
ItemStack stack = play.getMainHandItem();
|
||||||
|
int levelOfEgging = ItemUtils.getEnchantmentLevel(ModEnchantments.MOB_EGGING_ENCHANTMENT.get(),stack);
|
||||||
|
|
||||||
if(MobEggEnchantment.givesEgg(levelOfEgging, bias))
|
if(levelOfEgging==0)return;
|
||||||
{
|
CompoundTag tag = stack.getTag();
|
||||||
bias=0;
|
int bias = tag.getInt(MobEggEnchantment.TAG_BIAS);
|
||||||
tag.putInt(MobEggEnchantment.TAG_BIAS, bias);
|
|
||||||
// .25% chance
|
|
||||||
// Check enchantment level for looting
|
if(MobEggEnchantment.givesEgg(levelOfEgging, bias))
|
||||||
int level = ItemUtils.getEnchantmentLevel (Enchantments.MOB_LOOTING,stack);
|
{
|
||||||
if(level==3){
|
bias=0;
|
||||||
ItemStack egg = new ItemStack(ForgeSpawnEggItem.fromEntityType(killed.getType()));
|
tag.putInt(MobEggEnchantment.TAG_BIAS, bias);
|
||||||
ev.getDrops().add(new ItemEntity(killed.level(), killed.getX(), killed.getY(), killed.getZ(), egg));
|
// .25% chance
|
||||||
//LoreHandlers.updateItem(stack, ItemStatType.EGGING);
|
// Check enchantment level for looting
|
||||||
}
|
int level = ItemUtils.getEnchantmentLevel (Enchantments.MOB_LOOTING,stack);
|
||||||
}else{
|
if(level==3){
|
||||||
bias += 1;
|
ItemStack egg = new ItemStack(ForgeSpawnEggItem.fromEntityType(killed.getType()));
|
||||||
tag.putInt(MobEggEnchantment.TAG_BIAS, bias);
|
ev.getDrops().add(new ItemEntity(killed.level(), killed.getX(), killed.getY(), killed.getZ(), egg));
|
||||||
}
|
//LoreHandlers.updateItem(stack, ItemStatType.EGGING);
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
}
|
bias += 1;
|
||||||
|
tag.putInt(MobEggEnchantment.TAG_BIAS, bias);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,155 +1,176 @@
|
||||||
package dev.zontreck.thresholds.events;
|
package dev.zontreck.otemod.events;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.libzontreck.lore.LoreContainer;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import dev.zontreck.libzontreck.lore.LoreEntry;
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
|
import dev.zontreck.otemod.OTEMod;
|
||||||
@EventBusSubscriber(modid= ThresholdsMod.MOD_ID, bus=Mod.EventBusSubscriber.Bus.FORGE)
|
import dev.zontreck.otemod.items.tags.ItemStatTag;
|
||||||
public class LoreHandlers {
|
import dev.zontreck.otemod.items.tags.ItemStatType;
|
||||||
/*
|
import dev.zontreck.otemod.items.tags.ItemStatistics;
|
||||||
@SubscribeEvent
|
import net.minecraft.nbt.CompoundTag;
|
||||||
public void onBlockMined(BlockEvent.BreakEvent ev)
|
import net.minecraft.resources.ResourceLocation;
|
||||||
{
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
if(ev.getLevel().isClientSide())return;
|
import net.minecraft.world.InteractionHand;
|
||||||
|
import net.minecraft.world.InteractionResult;
|
||||||
ServerPlayer sp = (ServerPlayer)ev.getPlayer();
|
import net.minecraft.world.entity.Entity;
|
||||||
ItemStack itemUsed = sp.getItemInHand(InteractionHand.MAIN_HAND);
|
import net.minecraft.world.entity.player.Player;
|
||||||
ResourceLocation loc = ForgeRegistries.ITEMS.getKey(itemUsed.getItem());
|
import net.minecraft.world.item.ItemStack;
|
||||||
String itemModName = ChatHelpers.macroize("[0]:[1]", loc.getNamespace(), loc.getPath());
|
import net.minecraft.world.level.block.Blocks;
|
||||||
if(itemModName.contains("pickaxe"))
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
{
|
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||||
updateItem(itemUsed, ItemStatType.PICK);
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||||
}else if(itemModName.contains("shovel"))
|
import net.minecraftforge.event.level.BlockEvent;
|
||||||
{
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
updateItem(itemUsed, ItemStatType.SHOVEL);
|
import net.minecraftforge.fml.common.Mod;
|
||||||
} else if(itemModName.contains("axe"))
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||||
{
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
updateItem(itemUsed, ItemStatType.AXE);
|
|
||||||
} else if(itemModName.contains("pickadze"))
|
@EventBusSubscriber(modid=OTEMod.MOD_ID, bus=Mod.EventBusSubscriber.Bus.FORGE)
|
||||||
{
|
public class LoreHandlers {
|
||||||
updateItem(itemUsed, ItemStatType.PICK);
|
/*
|
||||||
}
|
@SubscribeEvent
|
||||||
}
|
public void onBlockMined(BlockEvent.BreakEvent ev)
|
||||||
|
{
|
||||||
@SubscribeEvent
|
if(ev.getLevel().isClientSide())return;
|
||||||
public void onBlock(BlockEvent.BlockToolModificationEvent ev)
|
|
||||||
{
|
ServerPlayer sp = (ServerPlayer)ev.getPlayer();
|
||||||
|
ItemStack itemUsed = sp.getItemInHand(InteractionHand.MAIN_HAND);
|
||||||
if(ev.getLevel().isClientSide())return;
|
ResourceLocation loc = ForgeRegistries.ITEMS.getKey(itemUsed.getItem());
|
||||||
|
String itemModName = ChatHelpers.macroize("[0]:[1]", loc.getNamespace(), loc.getPath());
|
||||||
// Check the block right clicked, and the item in hand
|
if(itemModName.contains("pickaxe"))
|
||||||
|
{
|
||||||
ServerPlayer sp = (ServerPlayer)ev.getPlayer();
|
updateItem(itemUsed, ItemStatType.PICK);
|
||||||
ItemStack itemUsed = sp.getMainHandItem();
|
}else if(itemModName.contains("shovel"))
|
||||||
BlockState bs = ev.getState();
|
{
|
||||||
ResourceLocation loc = ForgeRegistries.ITEMS.getKey(itemUsed.getItem());
|
updateItem(itemUsed, ItemStatType.SHOVEL);
|
||||||
String itemModName = ChatHelpers.macroize("[0]:[1]", loc.getNamespace(), loc.getPath());
|
} else if(itemModName.contains("axe"))
|
||||||
|
{
|
||||||
if(itemModName.contains("hoe"))
|
updateItem(itemUsed, ItemStatType.AXE);
|
||||||
{
|
} else if(itemModName.contains("pickadze"))
|
||||||
if(bs.is(Blocks.DIRT) || bs.is(Blocks.GRASS_BLOCK))
|
{
|
||||||
{
|
updateItem(itemUsed, ItemStatType.PICK);
|
||||||
OTEMod.LOGGER.info("DIRT!");
|
}
|
||||||
updateItem(itemUsed, ItemStatType.HOE);
|
}
|
||||||
}
|
|
||||||
} else if(itemModName.contains("shovel"))
|
@SubscribeEvent
|
||||||
{
|
public void onBlock(BlockEvent.BlockToolModificationEvent ev)
|
||||||
if(bs.is(Blocks.GRASS_BLOCK))
|
{
|
||||||
{
|
|
||||||
updateItem(itemUsed, ItemStatType.SHOVELPATH);
|
if(ev.getLevel().isClientSide())return;
|
||||||
}
|
|
||||||
}
|
// Check the block right clicked, and the item in hand
|
||||||
|
|
||||||
|
ServerPlayer sp = (ServerPlayer)ev.getPlayer();
|
||||||
}
|
ItemStack itemUsed = sp.getMainHandItem();
|
||||||
|
BlockState bs = ev.getState();
|
||||||
@SubscribeEvent
|
ResourceLocation loc = ForgeRegistries.ITEMS.getKey(itemUsed.getItem());
|
||||||
public void onShears(PlayerInteractEvent.EntityInteract ev)
|
String itemModName = ChatHelpers.macroize("[0]:[1]", loc.getNamespace(), loc.getPath());
|
||||||
{
|
|
||||||
|
if(itemModName.contains("hoe"))
|
||||||
if(ev.getLevel().isClientSide)return;
|
{
|
||||||
if(ev.getCancellationResult() == InteractionResult.PASS)
|
if(bs.is(Blocks.DIRT) || bs.is(Blocks.GRASS_BLOCK))
|
||||||
{
|
{
|
||||||
// Check the entity right-clicked, and the item in hand
|
OTEMod.LOGGER.info("DIRT!");
|
||||||
|
updateItem(itemUsed, ItemStatType.HOE);
|
||||||
OTEMod.LOGGER.info("Success");
|
}
|
||||||
ServerPlayer sp = (ServerPlayer)ev.getEntity();
|
} else if(itemModName.contains("shovel"))
|
||||||
ItemStack itemUsed = sp.getMainHandItem();
|
{
|
||||||
Entity target = ev.getTarget();
|
if(bs.is(Blocks.GRASS_BLOCK))
|
||||||
ResourceLocation loc = ForgeRegistries.ITEMS.getKey(itemUsed.getItem());
|
{
|
||||||
String itemModName = ChatHelpers.macroize("[0]:[1]", loc.getNamespace(), loc.getPath());
|
updateItem(itemUsed, ItemStatType.SHOVELPATH);
|
||||||
ResourceLocation locEnt = ForgeRegistries.ENTITY_TYPES.getKey(ev.getTarget().getType());
|
}
|
||||||
String entityModName = ChatHelpers.macroize("[0]:[1]", locEnt.getNamespace(), locEnt.getPath());
|
}
|
||||||
if(itemModName.contains("shears"))
|
|
||||||
{
|
|
||||||
if(entityModName.contains("sheep"))
|
}
|
||||||
{
|
|
||||||
updateItem(itemUsed, ItemStatType.SHEARS);
|
@SubscribeEvent
|
||||||
}
|
public void onShears(PlayerInteractEvent.EntityInteract ev)
|
||||||
}
|
{
|
||||||
}
|
|
||||||
}
|
if(ev.getLevel().isClientSide)return;
|
||||||
|
if(ev.getCancellationResult() == InteractionResult.PASS)
|
||||||
|
{
|
||||||
@SubscribeEvent
|
// Check the entity right-clicked, and the item in hand
|
||||||
public void onEntityKilled(LivingDeathEvent ev)
|
|
||||||
{
|
OTEMod.LOGGER.info("Success");
|
||||||
if(ev.getEntity().level().isClientSide)return;
|
ServerPlayer sp = (ServerPlayer)ev.getEntity();
|
||||||
|
ItemStack itemUsed = sp.getMainHandItem();
|
||||||
// Handle two things
|
Entity target = ev.getTarget();
|
||||||
|
ResourceLocation loc = ForgeRegistries.ITEMS.getKey(itemUsed.getItem());
|
||||||
// 1. Update mob kill count on a sword if wielded.
|
String itemModName = ChatHelpers.macroize("[0]:[1]", loc.getNamespace(), loc.getPath());
|
||||||
// 2. If mob, process randomness. If death by player with looting 3, 0.1% chance for a spawn egg to drop
|
ResourceLocation locEnt = ForgeRegistries.ENTITY_TYPES.getKey(ev.getTarget().getType());
|
||||||
Entity source = ev.getSource().getEntity();
|
String entityModName = ChatHelpers.macroize("[0]:[1]", locEnt.getNamespace(), locEnt.getPath());
|
||||||
ServerPlayer sp= null;
|
if(itemModName.contains("shears"))
|
||||||
if(source instanceof Player)
|
{
|
||||||
{
|
if(entityModName.contains("sheep"))
|
||||||
sp = (ServerPlayer)source;
|
{
|
||||||
}
|
updateItem(itemUsed, ItemStatType.SHEARS);
|
||||||
|
}
|
||||||
if(sp==null)return;
|
}
|
||||||
|
}
|
||||||
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"))
|
@SubscribeEvent
|
||||||
{
|
public void onEntityKilled(LivingDeathEvent ev)
|
||||||
updateItem(weaponUsed, ItemStatType.SWORD);
|
{
|
||||||
|
if(ev.getEntity().level().isClientSide)return;
|
||||||
}
|
|
||||||
|
// Handle two things
|
||||||
}
|
|
||||||
|
// 1. Update mob kill count on a sword if wielded.
|
||||||
// Only valid to be used by OTEMod
|
// 2. If mob, process randomness. If death by player with looting 3, 0.1% chance for a spawn egg to drop
|
||||||
protected static void updateItem(ItemStack weaponUsed, ItemStatType type)
|
Entity source = ev.getSource().getEntity();
|
||||||
{
|
ServerPlayer sp= null;
|
||||||
|
if(source instanceof Player)
|
||||||
// Update the mob kill count
|
{
|
||||||
CompoundTag props = weaponUsed.getTag();
|
sp = (ServerPlayer)source;
|
||||||
if(props==null)props=new CompoundTag();
|
}
|
||||||
CompoundTag container = props.getCompound(ItemStatTag.STATS_TAG+"_"+type.name().toLowerCase());
|
|
||||||
LoreContainer contain = new LoreContainer(weaponUsed);
|
if(sp==null)return;
|
||||||
|
|
||||||
ItemStatTag isTag;
|
ItemStack weaponUsed = sp.getItemInHand(InteractionHand.MAIN_HAND);
|
||||||
try{
|
ResourceLocation loc = ForgeRegistries.ITEMS.getKey(weaponUsed.getItem());
|
||||||
isTag = new ItemStatTag(type, container.getInt(ItemStatTag.STATS_TAG+"_"+type.name().toLowerCase()));
|
String itemModName = ChatHelpers.macroize("[0]:[1]", loc.getNamespace(), loc.getPath());
|
||||||
}catch (Exception e){
|
if(itemModName.contains("sword"))
|
||||||
isTag = new ItemStatTag(type, 0);
|
{
|
||||||
}
|
updateItem(weaponUsed, ItemStatType.SWORD);
|
||||||
isTag.increment();
|
|
||||||
LoreEntry entry;
|
}
|
||||||
|
|
||||||
if(contain.miscData.loreData.size()==0)
|
}
|
||||||
{
|
|
||||||
// Missing entry
|
// Only valid to be used by OTEMod
|
||||||
entry = new LoreEntry.Builder().text(ItemStatistics.makeText(isTag)).build();
|
protected static void updateItem(ItemStack weaponUsed, ItemStatType type)
|
||||||
contain.miscData.loreData.add(entry);
|
{
|
||||||
}else {
|
|
||||||
entry = contain.miscData.loreData.get(0); // Stat is set at 0
|
// Update the mob kill count
|
||||||
entry.text = ItemStatistics.makeText(isTag);
|
CompoundTag props = weaponUsed.getTag();
|
||||||
}
|
if(props==null)props=new CompoundTag();
|
||||||
|
CompoundTag container = props.getCompound(ItemStatTag.STATS_TAG+"_"+type.name().toLowerCase());
|
||||||
// Update item
|
LoreContainer contain = new LoreContainer(weaponUsed);
|
||||||
contain.commitLore();
|
|
||||||
}*/
|
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();
|
||||||
|
}*/
|
||||||
|
}
|
|
@ -1,17 +1,21 @@
|
||||||
package dev.zontreck.thresholds.events;
|
package dev.zontreck.otemod.events;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
|
import dev.zontreck.otemod.entities.ModEntityTypes;
|
||||||
|
import dev.zontreck.otemod.entities.monsters.PossumEntity;
|
||||||
|
import net.minecraft.world.entity.EntityType;
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
|
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = ThresholdsMod.MOD_ID, bus = Bus.MOD)
|
@Mod.EventBusSubscriber(modid = OTEMod.MOD_ID, bus = Bus.MOD)
|
||||||
public class ModEventBusEvents {
|
public class ModEventBusEvents {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onMobAttributeCreation(EntityAttributeCreationEvent ev)
|
public static void onMobAttributeCreation(EntityAttributeCreationEvent ev)
|
||||||
{
|
{
|
||||||
//ev.put((EntityType<? extends LivingEntity>) ModEntityTypes.POSSUM.get(), PossumEntity.createAttributes());
|
//ev.put((EntityType<? extends LivingEntity>) ModEntityTypes.POSSUM.get(), PossumEntity.createAttributes());
|
||||||
ThresholdsMod.LOGGER.info("/!\\ REGISTERING ATTRIBUTES /!\\");
|
OTEMod.LOGGER.info("/!\\ REGISTERING ATTRIBUTES /!\\");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package dev.zontreck.thresholds.implementation;
|
package dev.zontreck.otemod.implementation;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.items.ModItems;
|
import dev.zontreck.otemod.items.ModItems;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.world.item.CreativeModeTab;
|
import net.minecraft.world.item.CreativeModeTab;
|
||||||
|
@ -9,16 +9,17 @@ import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.level.ItemLike;
|
import net.minecraft.world.level.ItemLike;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = ThresholdsMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
@Mod.EventBusSubscriber(modid = OTEMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
public class CreativeModeTabs
|
public class CreativeModeTabs
|
||||||
{
|
{
|
||||||
public static final DeferredRegister<CreativeModeTab> REGISTER = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, ThresholdsMod.MOD_ID);
|
public static final DeferredRegister<CreativeModeTab> REGISTER = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, OTEMod.MOD_ID);
|
||||||
|
|
||||||
public static final List<Supplier<? extends ItemLike>> OTEMOD_TAB_ITEMS = new ArrayList<>();
|
public static final List<Supplier<? extends ItemLike>> OTEMOD_TAB_ITEMS = new ArrayList<>();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package dev.zontreck.thresholds.implementation;
|
package dev.zontreck.otemod.implementation;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -8,6 +8,7 @@ import dev.zontreck.libzontreck.profiles.Profile;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
import net.minecraft.world.damagesource.DamageTypes;
|
import net.minecraft.world.damagesource.DamageTypes;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
|
||||||
public class DeathMessages {
|
public class DeathMessages {
|
||||||
private static final List<String> messages;
|
private static final List<String> messages;
|
|
@ -1,13 +1,18 @@
|
||||||
package dev.zontreck.thresholds.implementation;
|
package dev.zontreck.otemod.implementation;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.database.OTEDatastore;
|
import dev.zontreck.otemod.database.OTEDatastore;
|
||||||
import net.minecraft.nbt.*;
|
import net.minecraft.nbt.*;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.GameType;
|
import net.minecraft.world.level.GameType;
|
||||||
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class InventoryBackup extends OTEDatastore
|
public class InventoryBackup extends OTEDatastore
|
||||||
{
|
{
|
|
@ -0,0 +1,32 @@
|
||||||
|
package dev.zontreck.otemod.implementation;
|
||||||
|
|
||||||
|
public class Messages {
|
||||||
|
public static final String OTE_PREFIX;
|
||||||
|
public static final String PREFIX_UPDATED;
|
||||||
|
public static final String PREFIX_COLOR_UPDATED;
|
||||||
|
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 STARTER_FAILURE_PERMISSIONS;
|
||||||
|
public static final String STARTER_KIT_GIVEN;
|
||||||
|
|
||||||
|
public static final String FLIGHT_GIVEN;
|
||||||
|
public static final String FLIGHT_REMOVED;
|
||||||
|
|
||||||
|
|
||||||
|
static{
|
||||||
|
OTE_PREFIX = "!Dark_Gray![!Dark_Purple!OTE!Dark_Gray!] ";
|
||||||
|
|
||||||
|
PREFIX_UPDATED = OTE_PREFIX + " !Dark_Purple!Your prefix has been updated";
|
||||||
|
PREFIX_COLOR_UPDATED = OTE_PREFIX + "!Dark_Purple!Your prefix color has been updated";
|
||||||
|
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";
|
||||||
|
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";
|
||||||
|
FLIGHT_REMOVED = OTE_PREFIX + "!Dark_Red!You have a sinking feeling you are no longer lighter than a feather.";
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package dev.zontreck.thresholds.implementation;
|
package dev.zontreck.otemod.implementation;
|
||||||
|
|
||||||
public class MouseHelpers {
|
public class MouseHelpers {
|
||||||
public static boolean isMouseOver(double mouseX, double mouseY, int x, int y, int sizeX, int sizeY)
|
public static boolean isMouseOver(double mouseX, double mouseY, int x, int y, int sizeX, int sizeY)
|
|
@ -1,44 +1,44 @@
|
||||||
package dev.zontreck.thresholds.implementation;
|
package dev.zontreck.otemod.implementation;
|
||||||
|
|
||||||
import net.minecraft.core.NonNullList;
|
import net.minecraft.core.NonNullList;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
|
||||||
public class OutputItemStackHandler extends ItemStackHandler {
|
public class OutputItemStackHandler extends ItemStackHandler {
|
||||||
private final ItemStackHandler internalSlot;
|
private final ItemStackHandler internalSlot;
|
||||||
|
|
||||||
public OutputItemStackHandler(ItemStackHandler hidden) {
|
public OutputItemStackHandler(ItemStackHandler hidden) {
|
||||||
super();
|
super();
|
||||||
internalSlot = hidden;
|
internalSlot = hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSize(int size) {
|
public void setSize(int size) {
|
||||||
stacks = NonNullList.<ItemStack>withSize(size, ItemStack.EMPTY);
|
stacks = NonNullList.<ItemStack>withSize(size, ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setStackInSlot(int slot, ItemStack stack) {
|
public void setStackInSlot(int slot, ItemStack stack) {
|
||||||
internalSlot.setStackInSlot(slot, stack);
|
internalSlot.setStackInSlot(slot, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSlots() {
|
public int getSlots() {
|
||||||
return internalSlot.getSlots();
|
return internalSlot.getSlots();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getStackInSlot(int slot) {
|
public ItemStack getStackInSlot(int slot) {
|
||||||
return internalSlot.getStackInSlot(slot);
|
return internalSlot.getStackInSlot(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
|
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack extractItem(int slot, int amount, boolean simulate) {
|
public ItemStack extractItem(int slot, int amount, boolean simulate) {
|
||||||
return internalSlot.extractItem(slot, amount, simulate);
|
return internalSlot.extractItem(slot, amount, simulate);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package dev.zontreck.thresholds.implementation;
|
package dev.zontreck.otemod.implementation;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.LongTag;
|
import net.minecraft.nbt.LongTag;
|
|
@ -1,4 +1,4 @@
|
||||||
package dev.zontreck.thresholds.implementation;
|
package dev.zontreck.otemod.implementation;
|
||||||
|
|
||||||
public class StarterKitDoesNotExistException extends Exception
|
public class StarterKitDoesNotExistException extends Exception
|
||||||
{
|
{
|
|
@ -1,8 +1,11 @@
|
||||||
package dev.zontreck.thresholds.implementation.compressor;
|
package dev.zontreck.otemod.implementation.compressor;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.blocks.ModBlocks;
|
import dev.zontreck.otemod.blocks.ModBlocks;
|
||||||
import dev.zontreck.thresholds.blocks.entity.CompressionChamberBlockEntity;
|
import dev.zontreck.otemod.blocks.entity.CompressionChamberBlockEntity;
|
||||||
import dev.zontreck.thresholds.implementation.inits.ModMenuTypes;
|
import dev.zontreck.otemod.blocks.entity.ItemScrubberBlockEntity;
|
||||||
|
import dev.zontreck.otemod.blocks.entity.ModEntities;
|
||||||
|
import dev.zontreck.otemod.implementation.inits.ModMenuTypes;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
|
@ -1,9 +1,9 @@
|
||||||
package dev.zontreck.thresholds.implementation.compressor;
|
package dev.zontreck.otemod.implementation.compressor;
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.implementation.MouseHelpers;
|
import dev.zontreck.otemod.implementation.MouseHelpers;
|
||||||
import dev.zontreck.thresholds.implementation.energy.screenrenderer.EnergyInfoArea;
|
import dev.zontreck.otemod.implementation.energy.screenrenderer.EnergyInfoArea;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
|
@ -16,7 +16,7 @@ import java.util.Optional;
|
||||||
public class CompressionChamberScreen extends AbstractContainerScreen<CompressionChamberMenu> {
|
public class CompressionChamberScreen extends AbstractContainerScreen<CompressionChamberMenu> {
|
||||||
|
|
||||||
|
|
||||||
private static final ResourceLocation TEXTURE = new ResourceLocation(ThresholdsMod.MOD_ID, "textures/gui/energized_compression_chamber.png");
|
private static final ResourceLocation TEXTURE = new ResourceLocation(OTEMod.MOD_ID, "textures/gui/energized_compression_chamber.png");
|
||||||
|
|
||||||
private EnergyInfoArea EIA;
|
private EnergyInfoArea EIA;
|
||||||
|
|
|
@ -1,42 +1,42 @@
|
||||||
package dev.zontreck.thresholds.implementation.energy;
|
package dev.zontreck.otemod.implementation.energy;
|
||||||
|
|
||||||
import net.minecraftforge.energy.EnergyStorage;
|
import net.minecraftforge.energy.EnergyStorage;
|
||||||
|
|
||||||
public abstract class OTEEnergy extends EnergyStorage
|
public abstract class OTEEnergy extends EnergyStorage
|
||||||
{
|
{
|
||||||
|
|
||||||
public OTEEnergy(int capacity, int maxTransfer) {
|
public OTEEnergy(int capacity, int maxTransfer) {
|
||||||
super(capacity, maxTransfer);
|
super(capacity, maxTransfer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int extractEnergy(int max, boolean simulate)
|
public int extractEnergy(int max, boolean simulate)
|
||||||
{
|
{
|
||||||
int ex = super.extractEnergy(max, simulate);
|
int ex = super.extractEnergy(max, simulate);
|
||||||
if(ex != 0){
|
if(ex != 0){
|
||||||
onChanged();
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ex;
|
return ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int receiveEnergy(int max, boolean simulate)
|
public int receiveEnergy(int max, boolean simulate)
|
||||||
{
|
{
|
||||||
int rcv = super.receiveEnergy(max, simulate);
|
int rcv = super.receiveEnergy(max, simulate);
|
||||||
if(rcv!=0){
|
if(rcv!=0){
|
||||||
onChanged();
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
return rcv;
|
return rcv;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int setEnergy(int energy){
|
public int setEnergy(int energy){
|
||||||
this.energy=energy;
|
this.energy=energy;
|
||||||
onChanged();
|
onChanged();
|
||||||
return energy;
|
return energy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void onChanged();
|
public abstract void onChanged();
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
package dev.zontreck.thresholds.implementation.energy.screenrenderer;
|
package dev.zontreck.otemod.implementation.energy.screenrenderer;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.renderer.Rect2i;
|
import net.minecraft.client.renderer.Rect2i;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
|
@ -1,5 +1,8 @@
|
||||||
package dev.zontreck.thresholds.implementation.energy.screenrenderer;
|
package dev.zontreck.otemod.implementation.energy.screenrenderer;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.renderer.Rect2i;
|
import net.minecraft.client.renderer.Rect2i;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package dev.zontreck.thresholds.implementation.events;
|
package dev.zontreck.otemod.implementation.events;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.profiles.Profile;
|
import dev.zontreck.libzontreck.profiles.Profile;
|
||||||
import dev.zontreck.thresholds.configs.ThresholdsServerConfig;
|
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||||
import net.minecraftforge.eventbus.api.Event;
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
|
|
||||||
public class VaultCreatedEvent extends Event
|
public class VaultCreatedEvent extends Event
|
||||||
|
@ -16,7 +16,7 @@ public class VaultCreatedEvent extends Event
|
||||||
|
|
||||||
public VaultCreatedEvent(int num, Profile user, int vaultsInUse)
|
public VaultCreatedEvent(int num, Profile user, int vaultsInUse)
|
||||||
{
|
{
|
||||||
max= ThresholdsServerConfig.MAX_VAULTS.get();
|
max=OTEServerConfig.MAX_VAULTS.get();
|
||||||
vault_num = num;
|
vault_num = num;
|
||||||
in_use = vaultsInUse;
|
in_use = vaultsInUse;
|
||||||
playerMax=user.available_vaults;
|
playerMax=user.available_vaults;
|
|
@ -1,4 +1,4 @@
|
||||||
package dev.zontreck.thresholds.implementation.events;
|
package dev.zontreck.otemod.implementation.events;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.profiles.Profile;
|
import dev.zontreck.libzontreck.profiles.Profile;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package dev.zontreck.thresholds.implementation.events;
|
package dev.zontreck.otemod.implementation.events;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.profiles.Profile;
|
import dev.zontreck.libzontreck.profiles.Profile;
|
||||||
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
|
||||||
public class VaultModifiedEvent extends VaultCreatedEvent
|
public class VaultModifiedEvent extends VaultCreatedEvent
|
|
@ -1,41 +1,41 @@
|
||||||
package dev.zontreck.thresholds.implementation.inits;
|
package dev.zontreck.otemod.implementation.inits;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.implementation.compressor.CompressionChamberMenu;
|
import dev.zontreck.otemod.implementation.compressor.CompressionChamberMenu;
|
||||||
import dev.zontreck.thresholds.implementation.scrubber.ItemScrubberMenu;
|
import dev.zontreck.otemod.implementation.scrubber.ItemScrubberMenu;
|
||||||
import dev.zontreck.thresholds.implementation.scrubber.MagicalScrubberMenu;
|
import dev.zontreck.otemod.implementation.scrubber.MagicalScrubberMenu;
|
||||||
import dev.zontreck.thresholds.implementation.vault.StarterMenu;
|
import dev.zontreck.otemod.implementation.vault.StarterMenu;
|
||||||
import dev.zontreck.thresholds.implementation.vault.VaultMenu;
|
import dev.zontreck.otemod.implementation.vault.VaultMenu;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.MenuType;
|
import net.minecraft.world.inventory.MenuType;
|
||||||
import net.minecraftforge.common.extensions.IForgeMenuType;
|
import net.minecraftforge.common.extensions.IForgeMenuType;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
import net.minecraftforge.network.IContainerFactory;
|
import net.minecraftforge.network.IContainerFactory;
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
|
|
||||||
public final class ModMenuTypes
|
public final class ModMenuTypes
|
||||||
{
|
{
|
||||||
public static final DeferredRegister<MenuType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.MENU_TYPES, ThresholdsMod.MOD_ID);
|
public static final DeferredRegister<MenuType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.MENU_TYPES, OTEMod.MOD_ID);
|
||||||
|
|
||||||
public static final RegistryObject<MenuType<VaultMenu>> VAULT = registerMenuType(VaultMenu::new, "vault");
|
public static final RegistryObject<MenuType<VaultMenu>> VAULT = registerMenuType(VaultMenu::new, "vault");
|
||||||
|
|
||||||
public static final RegistryObject<MenuType<StarterMenu>> STARTER = registerMenuType(StarterMenu::new, "starter");
|
public static final RegistryObject<MenuType<StarterMenu>> STARTER = registerMenuType(StarterMenu::new, "starter");
|
||||||
|
|
||||||
public static final RegistryObject<MenuType<ItemScrubberMenu>> SCRUBBER = registerMenuType(ItemScrubberMenu::new, "item_scrubber_menu");
|
public static final RegistryObject<MenuType<ItemScrubberMenu>> SCRUBBER = registerMenuType(ItemScrubberMenu::new, "item_scrubber_menu");
|
||||||
public static final RegistryObject<MenuType<MagicalScrubberMenu>> MAGIC_SCRUBBER = registerMenuType(MagicalScrubberMenu::new, "magical_scrubber_menu");
|
public static final RegistryObject<MenuType<MagicalScrubberMenu>> MAGIC_SCRUBBER = registerMenuType(MagicalScrubberMenu::new, "magical_scrubber_menu");
|
||||||
|
|
||||||
public static final RegistryObject<MenuType<CompressionChamberMenu>> COMPRESSION_CHAMBER = registerMenuType(CompressionChamberMenu::new, "compression_chamber");
|
public static final RegistryObject<MenuType<CompressionChamberMenu>> COMPRESSION_CHAMBER = registerMenuType(CompressionChamberMenu::new, "compression_chamber");
|
||||||
|
|
||||||
|
|
||||||
private static <T extends AbstractContainerMenu> RegistryObject<MenuType<T>> registerMenuType(IContainerFactory<T> factory, String name)
|
private static <T extends AbstractContainerMenu> RegistryObject<MenuType<T>> registerMenuType(IContainerFactory<T> factory, String name)
|
||||||
{
|
{
|
||||||
return CONTAINERS.register(name, ()->IForgeMenuType.create(factory));
|
return CONTAINERS.register(name, ()->IForgeMenuType.create(factory));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void register(IEventBus bus)
|
public static void register(IEventBus bus)
|
||||||
{
|
{
|
||||||
CONTAINERS.register(bus);
|
CONTAINERS.register(bus);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,150 +1,150 @@
|
||||||
package dev.zontreck.thresholds.implementation.scrubber;
|
package dev.zontreck.otemod.implementation.scrubber;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.blocks.ModBlocks;
|
import dev.zontreck.otemod.blocks.ModBlocks;
|
||||||
import dev.zontreck.thresholds.blocks.entity.ItemScrubberBlockEntity;
|
import dev.zontreck.otemod.blocks.entity.ItemScrubberBlockEntity;
|
||||||
import dev.zontreck.thresholds.implementation.inits.ModMenuTypes;
|
import dev.zontreck.otemod.implementation.inits.ModMenuTypes;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.*;
|
import net.minecraft.world.inventory.*;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||||
import net.minecraftforge.items.SlotItemHandler;
|
import net.minecraftforge.items.SlotItemHandler;
|
||||||
|
|
||||||
public class ItemScrubberMenu extends AbstractContainerMenu
|
public class ItemScrubberMenu extends AbstractContainerMenu
|
||||||
{
|
{
|
||||||
public final ItemScrubberBlockEntity entity;
|
public final ItemScrubberBlockEntity entity;
|
||||||
private final Level level;
|
private final Level level;
|
||||||
private final ContainerData data;
|
private final ContainerData data;
|
||||||
|
|
||||||
public ItemScrubberMenu(int id, Inventory inv, FriendlyByteBuf buf)
|
public ItemScrubberMenu(int id, Inventory inv, FriendlyByteBuf buf)
|
||||||
{
|
{
|
||||||
this(id, inv, inv.player.level().getBlockEntity(buf.readBlockPos()), new SimpleContainerData(1));
|
this(id, inv, inv.player.level().getBlockEntity(buf.readBlockPos()), new SimpleContainerData(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemScrubberMenu(int id, Inventory inv, BlockEntity entity, ContainerData data){
|
public ItemScrubberMenu(int id, Inventory inv, BlockEntity entity, ContainerData data){
|
||||||
super(ModMenuTypes.SCRUBBER.get(), id);
|
super(ModMenuTypes.SCRUBBER.get(), id);
|
||||||
|
|
||||||
checkContainerSize(inv, 1);
|
checkContainerSize(inv, 1);
|
||||||
this.entity = (ItemScrubberBlockEntity)entity;
|
this.entity = (ItemScrubberBlockEntity)entity;
|
||||||
this.data=data;
|
this.data=data;
|
||||||
this.level = inv.player.level();
|
this.level = inv.player.level();
|
||||||
|
|
||||||
addPlayerInventory(inv);
|
addPlayerInventory(inv);
|
||||||
addPlayerHotbar(inv);
|
addPlayerHotbar(inv);
|
||||||
|
|
||||||
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.UP).ifPresent(handler->{
|
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.UP).ifPresent(handler->{
|
||||||
addSlot(new SlotItemHandler(handler, 0, 16, 41));
|
addSlot(new SlotItemHandler(handler, 0, 16, 41));
|
||||||
});
|
});
|
||||||
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.DOWN).ifPresent(handler->{
|
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.DOWN).ifPresent(handler->{
|
||||||
addSlot(new SlotItemHandler(handler, 0, 177, 41));
|
addSlot(new SlotItemHandler(handler, 0, 177, 41));
|
||||||
});
|
});
|
||||||
|
|
||||||
addDataSlots(data);
|
addDataSlots(data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCrafting()
|
public boolean isCrafting()
|
||||||
{
|
{
|
||||||
return data.get(0) > 0;
|
return data.get(0) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getScaledProgress()
|
public int getScaledProgress()
|
||||||
{
|
{
|
||||||
if(!isCrafting())return 0;
|
if(!isCrafting())return 0;
|
||||||
int progress = this.data.get(0);
|
int progress = this.data.get(0);
|
||||||
int max = ItemScrubberBlockEntity.MAXIMUM_PROCESSING_TICKS;
|
int max = ItemScrubberBlockEntity.MAXIMUM_PROCESSING_TICKS;
|
||||||
|
|
||||||
int progressArrow = 125;
|
int progressArrow = 125;
|
||||||
|
|
||||||
|
|
||||||
if(progress != 0 && max != 0)
|
if(progress != 0 && max != 0)
|
||||||
{
|
{
|
||||||
int percent = progress * progressArrow / max;
|
int percent = progress * progressArrow / max;
|
||||||
return percent;
|
return percent;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// CREDIT GOES TO: diesieben07 | https://github.com/diesieben07/SevenCommons
|
// CREDIT GOES TO: diesieben07 | https://github.com/diesieben07/SevenCommons
|
||||||
// must assign a slot number to each of the slots used by the GUI.
|
// must assign a slot number to each of the slots used by the GUI.
|
||||||
// For this container, we can see both the tile inventory's slots as well as the player inventory slots and the hotbar.
|
// For this container, we can see both the tile inventory's slots as well as the player inventory slots and the hotbar.
|
||||||
// Each time we add a Slot to the container, it automatically increases the slotIndex, which means
|
// Each time we add a Slot to the container, it automatically increases the slotIndex, which means
|
||||||
// 0 - 8 = hotbar slots (which will map to the InventoryPlayer slot numbers 0 - 8)
|
// 0 - 8 = hotbar slots (which will map to the InventoryPlayer slot numbers 0 - 8)
|
||||||
// 9 - 35 = player inventory slots (which map to the InventoryPlayer slot numbers 9 - 35)
|
// 9 - 35 = player inventory slots (which map to the InventoryPlayer slot numbers 9 - 35)
|
||||||
// 36 - 44 = TileInventory slots, which map to our TileEntity slot numbers 0 - 8)
|
// 36 - 44 = TileInventory slots, which map to our TileEntity slot numbers 0 - 8)
|
||||||
private static final int HOTBAR_SLOT_COUNT = 9;
|
private static final int HOTBAR_SLOT_COUNT = 9;
|
||||||
private static final int PLAYER_INVENTORY_ROW_COUNT = 3;
|
private static final int PLAYER_INVENTORY_ROW_COUNT = 3;
|
||||||
private static final int PLAYER_INVENTORY_COLUMN_COUNT = 9;
|
private static final int PLAYER_INVENTORY_COLUMN_COUNT = 9;
|
||||||
private static final int PLAYER_INVENTORY_SLOT_COUNT = PLAYER_INVENTORY_COLUMN_COUNT * PLAYER_INVENTORY_ROW_COUNT;
|
private static final int PLAYER_INVENTORY_SLOT_COUNT = PLAYER_INVENTORY_COLUMN_COUNT * PLAYER_INVENTORY_ROW_COUNT;
|
||||||
private static final int VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_SLOT_COUNT;
|
private static final int VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_SLOT_COUNT;
|
||||||
private static final int VANILLA_FIRST_SLOT_INDEX = 0;
|
private static final int VANILLA_FIRST_SLOT_INDEX = 0;
|
||||||
private static final int TE_INVENTORY_FIRST_SLOT_INDEX = VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT;
|
private static final int TE_INVENTORY_FIRST_SLOT_INDEX = VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT;
|
||||||
|
|
||||||
// THIS YOU HAVE TO DEFINE!
|
// THIS YOU HAVE TO DEFINE!
|
||||||
private static final int TE_INVENTORY_SLOT_COUNT = 2; // must be the number of slots you have!
|
private static final int TE_INVENTORY_SLOT_COUNT = 2; // must be the number of slots you have!
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack quickMoveStack(Player playerIn, int index) {
|
public ItemStack quickMoveStack(Player playerIn, int index) {
|
||||||
Slot sourceSlot = slots.get(index);
|
Slot sourceSlot = slots.get(index);
|
||||||
if (sourceSlot == null || !sourceSlot.hasItem()) return ItemStack.EMPTY; //EMPTY_ITEM
|
if (sourceSlot == null || !sourceSlot.hasItem()) return ItemStack.EMPTY; //EMPTY_ITEM
|
||||||
ItemStack sourceStack = sourceSlot.getItem();
|
ItemStack sourceStack = sourceSlot.getItem();
|
||||||
ItemStack copyOfSourceStack = sourceStack.copy();
|
ItemStack copyOfSourceStack = sourceStack.copy();
|
||||||
|
|
||||||
// Check if the slot clicked is one of the vanilla container slots
|
// Check if the slot clicked is one of the vanilla container slots
|
||||||
if (index < VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT) {
|
if (index < VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT) {
|
||||||
// This is a vanilla container slot so merge the stack into the tile inventory
|
// This is a vanilla container slot so merge the stack into the tile inventory
|
||||||
if (!moveItemStackTo(sourceStack, TE_INVENTORY_FIRST_SLOT_INDEX, TE_INVENTORY_FIRST_SLOT_INDEX
|
if (!moveItemStackTo(sourceStack, TE_INVENTORY_FIRST_SLOT_INDEX, TE_INVENTORY_FIRST_SLOT_INDEX
|
||||||
+ TE_INVENTORY_SLOT_COUNT, false)) {
|
+ TE_INVENTORY_SLOT_COUNT, false)) {
|
||||||
return ItemStack.EMPTY; // EMPTY_ITEM
|
return ItemStack.EMPTY; // EMPTY_ITEM
|
||||||
}
|
}
|
||||||
} else if (index < TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT) {
|
} else if (index < TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT) {
|
||||||
// This is a TE slot so merge the stack into the players inventory
|
// This is a TE slot so merge the stack into the players inventory
|
||||||
if (!moveItemStackTo(sourceStack, VANILLA_FIRST_SLOT_INDEX, VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT, false)) {
|
if (!moveItemStackTo(sourceStack, VANILLA_FIRST_SLOT_INDEX, VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT, false)) {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Invalid slotIndex:" + index);
|
System.out.println("Invalid slotIndex:" + index);
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
// If stack size == 0 (the entire stack was moved) set slot contents to null
|
// If stack size == 0 (the entire stack was moved) set slot contents to null
|
||||||
if (sourceStack.getCount() == 0) {
|
if (sourceStack.getCount() == 0) {
|
||||||
sourceSlot.set(ItemStack.EMPTY);
|
sourceSlot.set(ItemStack.EMPTY);
|
||||||
} else {
|
} else {
|
||||||
sourceSlot.setChanged();
|
sourceSlot.setChanged();
|
||||||
}
|
}
|
||||||
sourceSlot.onTake(playerIn, sourceStack);
|
sourceSlot.onTake(playerIn, sourceStack);
|
||||||
return copyOfSourceStack;
|
return copyOfSourceStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stillValid(Player player) {
|
public boolean stillValid(Player player) {
|
||||||
return stillValid(ContainerLevelAccess.create(level, entity.getBlockPos()), player, ModBlocks.ITEM_SCRUBBER.get());
|
return stillValid(ContainerLevelAccess.create(level, entity.getBlockPos()), player, ModBlocks.ITEM_SCRUBBER.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int PLAYER_INVENTORY_FIRST_SLOT_HEIGHT = 69;
|
private static final int PLAYER_INVENTORY_FIRST_SLOT_HEIGHT = 69;
|
||||||
private static final int PLAYER_INVENTORY_FIRST_SLOT_LEFT = 24;
|
private static final int PLAYER_INVENTORY_FIRST_SLOT_LEFT = 24;
|
||||||
private static final int PLAYER_HOTBAR_FIRST_SLOT = 125;
|
private static final int PLAYER_HOTBAR_FIRST_SLOT = 125;
|
||||||
|
|
||||||
private void addPlayerInventory(Inventory inv)
|
private void addPlayerInventory(Inventory inv)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
for (int j = 0; j < 9; j++) {
|
for (int j = 0; j < 9; j++) {
|
||||||
this.addSlot(new Slot(inv, j+i*9+9, PLAYER_INVENTORY_FIRST_SLOT_LEFT+j*18, PLAYER_INVENTORY_FIRST_SLOT_HEIGHT+i*18));
|
this.addSlot(new Slot(inv, j+i*9+9, PLAYER_INVENTORY_FIRST_SLOT_LEFT+j*18, PLAYER_INVENTORY_FIRST_SLOT_HEIGHT+i*18));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPlayerHotbar(Inventory inv)
|
private void addPlayerHotbar(Inventory inv)
|
||||||
{
|
{
|
||||||
for (int index = 0; index < 9; index++) {
|
for (int index = 0; index < 9; index++) {
|
||||||
this.addSlot(new Slot(inv, index, PLAYER_INVENTORY_FIRST_SLOT_LEFT+index*18, PLAYER_HOTBAR_FIRST_SLOT));
|
this.addSlot(new Slot(inv, index, PLAYER_INVENTORY_FIRST_SLOT_LEFT+index*18, PLAYER_HOTBAR_FIRST_SLOT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,99 +1,100 @@
|
||||||
package dev.zontreck.thresholds.implementation.scrubber;
|
package dev.zontreck.otemod.implementation.scrubber;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
|
||||||
import dev.zontreck.thresholds.implementation.MouseHelpers;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.implementation.energy.screenrenderer.EnergyInfoArea;
|
import dev.zontreck.otemod.implementation.MouseHelpers;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import dev.zontreck.otemod.implementation.energy.screenrenderer.EnergyInfoArea;
|
||||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
public class ItemScrubberScreen extends AbstractContainerScreen<ItemScrubberMenu>
|
|
||||||
{
|
public class ItemScrubberScreen extends AbstractContainerScreen<ItemScrubberMenu>
|
||||||
private static final ResourceLocation TEXTURE = new ResourceLocation(ThresholdsMod.MOD_ID, "textures/gui/item_scrubber_gui.png");
|
{
|
||||||
|
private static final ResourceLocation TEXTURE = new ResourceLocation(OTEMod.MOD_ID, "textures/gui/item_scrubber_gui.png");
|
||||||
private EnergyInfoArea EIA;
|
|
||||||
|
private EnergyInfoArea EIA;
|
||||||
public ItemScrubberScreen(ItemScrubberMenu p_97741_, Inventory p_97742_, Component p_97743_) {
|
|
||||||
super(p_97741_, p_97742_, p_97743_);
|
public ItemScrubberScreen(ItemScrubberMenu p_97741_, Inventory p_97742_, Component p_97743_) {
|
||||||
|
super(p_97741_, p_97742_, p_97743_);
|
||||||
|
|
||||||
this.topPos=0;
|
|
||||||
this.leftPos=0;
|
this.topPos=0;
|
||||||
|
this.leftPos=0;
|
||||||
this.imageWidth = 208;
|
|
||||||
this.imageHeight = 165;
|
this.imageWidth = 208;
|
||||||
}
|
this.imageHeight = 165;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
protected void init()
|
@Override
|
||||||
{
|
protected void init()
|
||||||
super.init();
|
{
|
||||||
assignEnergyArea();
|
super.init();
|
||||||
}
|
assignEnergyArea();
|
||||||
|
}
|
||||||
private void assignEnergyArea() {
|
|
||||||
int x = (width - imageWidth )/2;
|
private void assignEnergyArea() {
|
||||||
int y = (height - imageHeight)/2;
|
int x = (width - imageWidth )/2;
|
||||||
|
int y = (height - imageHeight)/2;
|
||||||
EIA = new EnergyInfoArea(x+188, y+69, menu.entity.getEnergyStorage(), 7, 72);
|
|
||||||
}
|
EIA = new EnergyInfoArea(x+188, y+69, menu.entity.getEnergyStorage(), 7, 72);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
protected void renderBg(GuiGraphics poseStack, float partialTick, int mouseX, int mouseY) {
|
@Override
|
||||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
protected void renderBg(GuiGraphics poseStack, float partialTick, int mouseX, int mouseY) {
|
||||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||||
RenderSystem.setShaderTexture(0, TEXTURE);
|
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
RenderSystem.setShaderTexture(0, TEXTURE);
|
||||||
|
|
||||||
poseStack.blit(TEXTURE, this.leftPos, this.topPos, 0,0, imageWidth, imageHeight);
|
|
||||||
renderUncraftingProgress(poseStack);
|
poseStack.blit(TEXTURE, this.leftPos, this.topPos, 0,0, imageWidth, imageHeight);
|
||||||
EIA.draw(poseStack);
|
renderUncraftingProgress(poseStack);
|
||||||
}
|
EIA.draw(poseStack);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void renderLabels(GuiGraphics stack, int mouseX, int mouseY)
|
@Override
|
||||||
{
|
protected void renderLabels(GuiGraphics stack, int mouseX, int mouseY)
|
||||||
stack.drawString(font, this.title.getString(), 63, 12, 0xFFFFFF);
|
{
|
||||||
|
stack.drawString(font, this.title.getString(), 63, 12, 0xFFFFFF);
|
||||||
int x = (width - imageWidth )/2;
|
|
||||||
int y = (height - imageHeight)/2;
|
int x = (width - imageWidth )/2;
|
||||||
renderEnergy(stack, mouseX, mouseY, x, y);
|
int y = (height - imageHeight)/2;
|
||||||
//this.font.draw(stack, this.playerInventoryTitle.getString(), this.leftPos + 17, this.topPos + 123, 0xFFFFFF);
|
renderEnergy(stack, mouseX, mouseY, x, y);
|
||||||
}
|
//this.font.draw(stack, this.playerInventoryTitle.getString(), this.leftPos + 17, this.topPos + 123, 0xFFFFFF);
|
||||||
|
}
|
||||||
private void renderEnergy(GuiGraphics stack, int mouseX, int mouseY, int x, int y) {
|
|
||||||
if(isMouseAbove(mouseX, mouseY, x, y, 188, 69, 7, 72)){
|
private void renderEnergy(GuiGraphics stack, int mouseX, int mouseY, int x, int y) {
|
||||||
stack.renderTooltip(font, EIA.getTooltips(), Optional.empty(), mouseX-x, mouseY-y);
|
if(isMouseAbove(mouseX, mouseY, x, y, 188, 69, 7, 72)){
|
||||||
}
|
stack.renderTooltip(font, EIA.getTooltips(), Optional.empty(), mouseX-x, mouseY-y);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private void renderUncraftingProgress(GuiGraphics stack)
|
|
||||||
{
|
private void renderUncraftingProgress(GuiGraphics stack)
|
||||||
if(menu.isCrafting())
|
{
|
||||||
{
|
if(menu.isCrafting())
|
||||||
stack.blit(TEXTURE, leftPos+42, topPos+45, 1, 168, menu.getScaledProgress(),6);
|
{
|
||||||
}
|
stack.blit(TEXTURE, leftPos+42, topPos+45, 1, 168, menu.getScaledProgress(),6);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void render(GuiGraphics stack, int mouseX, int mouseY, float delta)
|
@Override
|
||||||
{
|
public void render(GuiGraphics stack, int mouseX, int mouseY, float delta)
|
||||||
renderBackground(stack);
|
{
|
||||||
super.render(stack, mouseX, mouseY, delta);
|
renderBackground(stack);
|
||||||
renderTooltip(stack, mouseX, mouseY);
|
super.render(stack, mouseX, mouseY, delta);
|
||||||
}
|
renderTooltip(stack, mouseX, mouseY);
|
||||||
|
}
|
||||||
private boolean isMouseAbove(int mouseX, int mouseY, int x, int y, int offsetX, int offsetY, int width, int height)
|
|
||||||
{
|
private boolean isMouseAbove(int mouseX, int mouseY, int x, int y, int offsetX, int offsetY, int width, int height)
|
||||||
return MouseHelpers.isMouseOver(mouseX, mouseY, x+offsetX, y+offsetY, width, height);
|
{
|
||||||
}
|
return MouseHelpers.isMouseOver(mouseX, mouseY, x+offsetX, y+offsetY, width, height);
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
|
@ -1,150 +1,150 @@
|
||||||
package dev.zontreck.thresholds.implementation.scrubber;
|
package dev.zontreck.otemod.implementation.scrubber;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.blocks.ModBlocks;
|
import dev.zontreck.otemod.blocks.ModBlocks;
|
||||||
import dev.zontreck.thresholds.blocks.entity.MagicalScrubberBlockEntity;
|
import dev.zontreck.otemod.blocks.entity.MagicalScrubberBlockEntity;
|
||||||
import dev.zontreck.thresholds.implementation.inits.ModMenuTypes;
|
import dev.zontreck.otemod.implementation.inits.ModMenuTypes;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.*;
|
import net.minecraft.world.inventory.*;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||||
import net.minecraftforge.items.SlotItemHandler;
|
import net.minecraftforge.items.SlotItemHandler;
|
||||||
|
|
||||||
public class MagicalScrubberMenu extends AbstractContainerMenu
|
public class MagicalScrubberMenu extends AbstractContainerMenu
|
||||||
{
|
{
|
||||||
public final MagicalScrubberBlockEntity entity;
|
public final MagicalScrubberBlockEntity entity;
|
||||||
private final Level level;
|
private final Level level;
|
||||||
private final ContainerData data;
|
private final ContainerData data;
|
||||||
|
|
||||||
public MagicalScrubberMenu(int id, Inventory inv, FriendlyByteBuf buf)
|
public MagicalScrubberMenu(int id, Inventory inv, FriendlyByteBuf buf)
|
||||||
{
|
{
|
||||||
this(id, inv, inv.player.level().getBlockEntity(buf.readBlockPos()), new SimpleContainerData(1));
|
this(id, inv, inv.player.level().getBlockEntity(buf.readBlockPos()), new SimpleContainerData(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public MagicalScrubberMenu(int id, Inventory inv, BlockEntity entity, ContainerData data){
|
public MagicalScrubberMenu(int id, Inventory inv, BlockEntity entity, ContainerData data){
|
||||||
super(ModMenuTypes.MAGIC_SCRUBBER.get(), id);
|
super(ModMenuTypes.MAGIC_SCRUBBER.get(), id);
|
||||||
|
|
||||||
checkContainerSize(inv, 1);
|
checkContainerSize(inv, 1);
|
||||||
this.entity = (MagicalScrubberBlockEntity)entity;
|
this.entity = (MagicalScrubberBlockEntity)entity;
|
||||||
this.data=data;
|
this.data=data;
|
||||||
this.level = inv.player.level();
|
this.level = inv.player.level();
|
||||||
|
|
||||||
addPlayerInventory(inv);
|
addPlayerInventory(inv);
|
||||||
addPlayerHotbar(inv);
|
addPlayerHotbar(inv);
|
||||||
|
|
||||||
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.UP).ifPresent(handler->{
|
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.UP).ifPresent(handler->{
|
||||||
addSlot(new SlotItemHandler(handler, 0, 16, 41));
|
addSlot(new SlotItemHandler(handler, 0, 16, 41));
|
||||||
});
|
});
|
||||||
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.DOWN).ifPresent(handler->{
|
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.DOWN).ifPresent(handler->{
|
||||||
addSlot(new SlotItemHandler(handler, 0, 177, 41));
|
addSlot(new SlotItemHandler(handler, 0, 177, 41));
|
||||||
});
|
});
|
||||||
|
|
||||||
addDataSlots(data);
|
addDataSlots(data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCrafting()
|
public boolean isCrafting()
|
||||||
{
|
{
|
||||||
return data.get(0) > 0;
|
return data.get(0) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getScaledProgress()
|
public int getScaledProgress()
|
||||||
{
|
{
|
||||||
if(!isCrafting())return 0;
|
if(!isCrafting())return 0;
|
||||||
int progress = this.data.get(0);
|
int progress = this.data.get(0);
|
||||||
int max = MagicalScrubberBlockEntity.MAXIMUM_PROCESSING_TICKS;
|
int max = MagicalScrubberBlockEntity.MAXIMUM_PROCESSING_TICKS;
|
||||||
|
|
||||||
int progressArrow = 125;
|
int progressArrow = 125;
|
||||||
|
|
||||||
|
|
||||||
if(progress != 0 && max != 0)
|
if(progress != 0 && max != 0)
|
||||||
{
|
{
|
||||||
int percent = progress * progressArrow / max;
|
int percent = progress * progressArrow / max;
|
||||||
return percent;
|
return percent;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// CREDIT GOES TO: diesieben07 | https://github.com/diesieben07/SevenCommons
|
// CREDIT GOES TO: diesieben07 | https://github.com/diesieben07/SevenCommons
|
||||||
// must assign a slot number to each of the slots used by the GUI.
|
// must assign a slot number to each of the slots used by the GUI.
|
||||||
// For this container, we can see both the tile inventory's slots as well as the player inventory slots and the hotbar.
|
// For this container, we can see both the tile inventory's slots as well as the player inventory slots and the hotbar.
|
||||||
// Each time we add a Slot to the container, it automatically increases the slotIndex, which means
|
// Each time we add a Slot to the container, it automatically increases the slotIndex, which means
|
||||||
// 0 - 8 = hotbar slots (which will map to the InventoryPlayer slot numbers 0 - 8)
|
// 0 - 8 = hotbar slots (which will map to the InventoryPlayer slot numbers 0 - 8)
|
||||||
// 9 - 35 = player inventory slots (which map to the InventoryPlayer slot numbers 9 - 35)
|
// 9 - 35 = player inventory slots (which map to the InventoryPlayer slot numbers 9 - 35)
|
||||||
// 36 - 44 = TileInventory slots, which map to our TileEntity slot numbers 0 - 8)
|
// 36 - 44 = TileInventory slots, which map to our TileEntity slot numbers 0 - 8)
|
||||||
private static final int HOTBAR_SLOT_COUNT = 9;
|
private static final int HOTBAR_SLOT_COUNT = 9;
|
||||||
private static final int PLAYER_INVENTORY_ROW_COUNT = 3;
|
private static final int PLAYER_INVENTORY_ROW_COUNT = 3;
|
||||||
private static final int PLAYER_INVENTORY_COLUMN_COUNT = 9;
|
private static final int PLAYER_INVENTORY_COLUMN_COUNT = 9;
|
||||||
private static final int PLAYER_INVENTORY_SLOT_COUNT = PLAYER_INVENTORY_COLUMN_COUNT * PLAYER_INVENTORY_ROW_COUNT;
|
private static final int PLAYER_INVENTORY_SLOT_COUNT = PLAYER_INVENTORY_COLUMN_COUNT * PLAYER_INVENTORY_ROW_COUNT;
|
||||||
private static final int VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_SLOT_COUNT;
|
private static final int VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_SLOT_COUNT;
|
||||||
private static final int VANILLA_FIRST_SLOT_INDEX = 0;
|
private static final int VANILLA_FIRST_SLOT_INDEX = 0;
|
||||||
private static final int TE_INVENTORY_FIRST_SLOT_INDEX = VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT;
|
private static final int TE_INVENTORY_FIRST_SLOT_INDEX = VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT;
|
||||||
|
|
||||||
// THIS YOU HAVE TO DEFINE!
|
// THIS YOU HAVE TO DEFINE!
|
||||||
private static final int TE_INVENTORY_SLOT_COUNT = 2; // must be the number of slots you have!
|
private static final int TE_INVENTORY_SLOT_COUNT = 2; // must be the number of slots you have!
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack quickMoveStack(Player playerIn, int index) {
|
public ItemStack quickMoveStack(Player playerIn, int index) {
|
||||||
Slot sourceSlot = slots.get(index);
|
Slot sourceSlot = slots.get(index);
|
||||||
if (sourceSlot == null || !sourceSlot.hasItem()) return ItemStack.EMPTY; //EMPTY_ITEM
|
if (sourceSlot == null || !sourceSlot.hasItem()) return ItemStack.EMPTY; //EMPTY_ITEM
|
||||||
ItemStack sourceStack = sourceSlot.getItem();
|
ItemStack sourceStack = sourceSlot.getItem();
|
||||||
ItemStack copyOfSourceStack = sourceStack.copy();
|
ItemStack copyOfSourceStack = sourceStack.copy();
|
||||||
|
|
||||||
// Check if the slot clicked is one of the vanilla container slots
|
// Check if the slot clicked is one of the vanilla container slots
|
||||||
if (index < VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT) {
|
if (index < VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT) {
|
||||||
// This is a vanilla container slot so merge the stack into the tile inventory
|
// This is a vanilla container slot so merge the stack into the tile inventory
|
||||||
if (!moveItemStackTo(sourceStack, TE_INVENTORY_FIRST_SLOT_INDEX, TE_INVENTORY_FIRST_SLOT_INDEX
|
if (!moveItemStackTo(sourceStack, TE_INVENTORY_FIRST_SLOT_INDEX, TE_INVENTORY_FIRST_SLOT_INDEX
|
||||||
+ TE_INVENTORY_SLOT_COUNT, false)) {
|
+ TE_INVENTORY_SLOT_COUNT, false)) {
|
||||||
return ItemStack.EMPTY; // EMPTY_ITEM
|
return ItemStack.EMPTY; // EMPTY_ITEM
|
||||||
}
|
}
|
||||||
} else if (index < TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT) {
|
} else if (index < TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT) {
|
||||||
// This is a TE slot so merge the stack into the players inventory
|
// This is a TE slot so merge the stack into the players inventory
|
||||||
if (!moveItemStackTo(sourceStack, VANILLA_FIRST_SLOT_INDEX, VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT, false)) {
|
if (!moveItemStackTo(sourceStack, VANILLA_FIRST_SLOT_INDEX, VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT, false)) {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Invalid slotIndex:" + index);
|
System.out.println("Invalid slotIndex:" + index);
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
// If stack size == 0 (the entire stack was moved) set slot contents to null
|
// If stack size == 0 (the entire stack was moved) set slot contents to null
|
||||||
if (sourceStack.getCount() == 0) {
|
if (sourceStack.getCount() == 0) {
|
||||||
sourceSlot.set(ItemStack.EMPTY);
|
sourceSlot.set(ItemStack.EMPTY);
|
||||||
} else {
|
} else {
|
||||||
sourceSlot.setChanged();
|
sourceSlot.setChanged();
|
||||||
}
|
}
|
||||||
sourceSlot.onTake(playerIn, sourceStack);
|
sourceSlot.onTake(playerIn, sourceStack);
|
||||||
return copyOfSourceStack;
|
return copyOfSourceStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stillValid(Player player) {
|
public boolean stillValid(Player player) {
|
||||||
return stillValid(ContainerLevelAccess.create(level, entity.getBlockPos()), player, ModBlocks.MAGICAL_SCRUBBER.get());
|
return stillValid(ContainerLevelAccess.create(level, entity.getBlockPos()), player, ModBlocks.MAGICAL_SCRUBBER.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int PLAYER_INVENTORY_FIRST_SLOT_HEIGHT = 69;
|
private static final int PLAYER_INVENTORY_FIRST_SLOT_HEIGHT = 69;
|
||||||
private static final int PLAYER_INVENTORY_FIRST_SLOT_LEFT = 24;
|
private static final int PLAYER_INVENTORY_FIRST_SLOT_LEFT = 24;
|
||||||
private static final int PLAYER_HOTBAR_FIRST_SLOT = 125;
|
private static final int PLAYER_HOTBAR_FIRST_SLOT = 125;
|
||||||
|
|
||||||
private void addPlayerInventory(Inventory inv)
|
private void addPlayerInventory(Inventory inv)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
for (int j = 0; j < 9; j++) {
|
for (int j = 0; j < 9; j++) {
|
||||||
this.addSlot(new Slot(inv, j+i*9+9, PLAYER_INVENTORY_FIRST_SLOT_LEFT+j*18, PLAYER_INVENTORY_FIRST_SLOT_HEIGHT+i*18));
|
this.addSlot(new Slot(inv, j+i*9+9, PLAYER_INVENTORY_FIRST_SLOT_LEFT+j*18, PLAYER_INVENTORY_FIRST_SLOT_HEIGHT+i*18));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPlayerHotbar(Inventory inv)
|
private void addPlayerHotbar(Inventory inv)
|
||||||
{
|
{
|
||||||
for (int index = 0; index < 9; index++) {
|
for (int index = 0; index < 9; index++) {
|
||||||
this.addSlot(new Slot(inv, index, PLAYER_INVENTORY_FIRST_SLOT_LEFT+index*18, PLAYER_HOTBAR_FIRST_SLOT));
|
this.addSlot(new Slot(inv, index, PLAYER_INVENTORY_FIRST_SLOT_LEFT+index*18, PLAYER_HOTBAR_FIRST_SLOT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,99 +1,100 @@
|
||||||
package dev.zontreck.thresholds.implementation.scrubber;
|
package dev.zontreck.otemod.implementation.scrubber;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
|
||||||
import dev.zontreck.thresholds.implementation.MouseHelpers;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.implementation.energy.screenrenderer.EnergyInfoArea;
|
import dev.zontreck.otemod.implementation.MouseHelpers;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import dev.zontreck.otemod.implementation.energy.screenrenderer.EnergyInfoArea;
|
||||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
public class MagicalScrubberScreen extends AbstractContainerScreen<MagicalScrubberMenu>
|
|
||||||
{
|
public class MagicalScrubberScreen extends AbstractContainerScreen<MagicalScrubberMenu>
|
||||||
|
{
|
||||||
private static final ResourceLocation TEXTURE = new ResourceLocation(ThresholdsMod.MOD_ID, "textures/gui/item_scrubber_gui.png");
|
|
||||||
|
private static final ResourceLocation TEXTURE = new ResourceLocation(OTEMod.MOD_ID, "textures/gui/item_scrubber_gui.png");
|
||||||
private EnergyInfoArea EIA;
|
|
||||||
|
private EnergyInfoArea EIA;
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void init()
|
@Override
|
||||||
{
|
protected void init()
|
||||||
super.init();
|
{
|
||||||
assignEnergyArea();
|
super.init();
|
||||||
}
|
assignEnergyArea();
|
||||||
|
}
|
||||||
private void assignEnergyArea() {
|
|
||||||
int x = (width - imageWidth )/2;
|
private void assignEnergyArea() {
|
||||||
int y = (height - imageHeight)/2;
|
int x = (width - imageWidth )/2;
|
||||||
|
int y = (height - imageHeight)/2;
|
||||||
EIA = new EnergyInfoArea(x+188, y+69, menu.entity.getEnergyStorage(), 7, 72);
|
|
||||||
}
|
EIA = new EnergyInfoArea(x+188, y+69, menu.entity.getEnergyStorage(), 7, 72);
|
||||||
|
}
|
||||||
|
|
||||||
public MagicalScrubberScreen(MagicalScrubberMenu pMenu, Inventory pPlayerInventory, Component pTitle) {
|
|
||||||
super(pMenu, pPlayerInventory, pTitle);
|
public MagicalScrubberScreen(MagicalScrubberMenu pMenu, Inventory pPlayerInventory, Component pTitle) {
|
||||||
this.topPos=0;
|
super(pMenu, pPlayerInventory, pTitle);
|
||||||
this.leftPos=0;
|
this.topPos=0;
|
||||||
|
this.leftPos=0;
|
||||||
this.imageWidth = 208;
|
|
||||||
this.imageHeight = 165;
|
this.imageWidth = 208;
|
||||||
}
|
this.imageHeight = 165;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
protected void renderBg(GuiGraphics poseStack, float partialTick, int mouseX, int mouseY) {
|
@Override
|
||||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
protected void renderBg(GuiGraphics poseStack, float partialTick, int mouseX, int mouseY) {
|
||||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||||
RenderSystem.setShaderTexture(0, TEXTURE);
|
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
RenderSystem.setShaderTexture(0, TEXTURE);
|
||||||
|
|
||||||
poseStack.blit(TEXTURE, this.leftPos, this.topPos, 0, 0, imageWidth, imageHeight);
|
|
||||||
renderUncraftingProgress(poseStack);
|
poseStack.blit(TEXTURE, this.leftPos, this.topPos, 0, 0, imageWidth, imageHeight);
|
||||||
EIA.draw(poseStack);
|
renderUncraftingProgress(poseStack);
|
||||||
}
|
EIA.draw(poseStack);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void renderLabels(GuiGraphics stack, int mouseX, int mouseY)
|
@Override
|
||||||
{
|
protected void renderLabels(GuiGraphics stack, int mouseX, int mouseY)
|
||||||
stack.drawString(font, title.getString(), 63, 12, 0xFFFFFF);
|
{
|
||||||
|
stack.drawString(font, title.getString(), 63, 12, 0xFFFFFF);
|
||||||
int x = (width - imageWidth )/2;
|
|
||||||
int y = (height - imageHeight)/2;
|
int x = (width - imageWidth )/2;
|
||||||
renderEnergy(stack, mouseX, mouseY, x, y);
|
int y = (height - imageHeight)/2;
|
||||||
//this.font.draw(stack, this.playerInventoryTitle.getString(), this.leftPos + 17, this.topPos + 123, 0xFFFFFF);
|
renderEnergy(stack, mouseX, mouseY, x, y);
|
||||||
}
|
//this.font.draw(stack, this.playerInventoryTitle.getString(), this.leftPos + 17, this.topPos + 123, 0xFFFFFF);
|
||||||
|
}
|
||||||
private void renderEnergy(GuiGraphics stack, int mouseX, int mouseY, int x, int y) {
|
|
||||||
if(isMouseAbove(mouseX, mouseY, x, y, 188, 69, 7, 72)){
|
private void renderEnergy(GuiGraphics stack, int mouseX, int mouseY, int x, int y) {
|
||||||
stack.renderTooltip(font, EIA.getTooltips(), Optional.empty(), mouseX-x, mouseY-y);
|
if(isMouseAbove(mouseX, mouseY, x, y, 188, 69, 7, 72)){
|
||||||
}
|
stack.renderTooltip(font, EIA.getTooltips(), Optional.empty(), mouseX-x, mouseY-y);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private void renderUncraftingProgress(GuiGraphics stack)
|
|
||||||
{
|
private void renderUncraftingProgress(GuiGraphics stack)
|
||||||
if(menu.isCrafting())
|
{
|
||||||
{
|
if(menu.isCrafting())
|
||||||
stack.blit(TEXTURE, leftPos+42, topPos+45, 1, 168, menu.getScaledProgress(), 6);
|
{
|
||||||
}
|
stack.blit(TEXTURE, leftPos+42, topPos+45, 1, 168, menu.getScaledProgress(), 6);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void render(GuiGraphics stack, int mouseX, int mouseY, float delta)
|
@Override
|
||||||
{
|
public void render(GuiGraphics stack, int mouseX, int mouseY, float delta)
|
||||||
renderBackground(stack);
|
{
|
||||||
super.render(stack, mouseX, mouseY, delta);
|
renderBackground(stack);
|
||||||
renderTooltip(stack, mouseX, mouseY);
|
super.render(stack, mouseX, mouseY, delta);
|
||||||
}
|
renderTooltip(stack, mouseX, mouseY);
|
||||||
|
}
|
||||||
private boolean isMouseAbove(int mouseX, int mouseY, int x, int y, int offsetX, int offsetY, int width, int height)
|
|
||||||
{
|
private boolean isMouseAbove(int mouseX, int mouseY, int x, int y, int offsetX, int offsetY, int width, int height)
|
||||||
return MouseHelpers.isMouseOver(mouseX, mouseY, x+offsetX, y+offsetY, width, height);
|
{
|
||||||
}
|
return MouseHelpers.isMouseOver(mouseX, mouseY, x+offsetX, y+offsetY, width, height);
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package dev.zontreck.thresholds.implementation.vault;
|
package dev.zontreck.otemod.implementation.vault;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* You cannot create or open the vault due to server settings
|
* You cannot create or open the vault due to server settings
|
|
@ -1,5 +1,6 @@
|
||||||
package dev.zontreck.thresholds.implementation.vault;
|
package dev.zontreck.otemod.implementation.vault;
|
||||||
|
|
||||||
|
import dev.zontreck.libzontreck.profiles.Profile;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.LongTag;
|
import net.minecraft.nbt.LongTag;
|
||||||
import net.minecraft.nbt.NbtIo;
|
import net.minecraft.nbt.NbtIo;
|
|
@ -1,9 +1,13 @@
|
||||||
package dev.zontreck.thresholds.implementation.vault;
|
package dev.zontreck.otemod.implementation.vault;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
import dev.zontreck.libzontreck.profiles.Profile;
|
import dev.zontreck.libzontreck.profiles.Profile;
|
||||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
|
import dev.zontreck.otemod.OTEMod;
|
||||||
|
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||||
|
import dev.zontreck.otemod.implementation.StarterKitDoesNotExistException;
|
||||||
|
import dev.zontreck.otemod.implementation.events.VaultModifiedEvent;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
|
@ -1,6 +1,6 @@
|
||||||
package dev.zontreck.thresholds.implementation.vault;
|
package dev.zontreck.otemod.implementation.vault;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.implementation.inits.ModMenuTypes;
|
import dev.zontreck.otemod.implementation.inits.ModMenuTypes;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
|
@ -1,11 +1,14 @@
|
||||||
package dev.zontreck.thresholds.implementation.vault;
|
package dev.zontreck.otemod.implementation.vault;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.database.OTEDatastore;
|
import dev.zontreck.libzontreck.profiles.Profile;
|
||||||
|
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||||
|
import dev.zontreck.otemod.database.OTEDatastore;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class StarterProvider extends OTEDatastore
|
public class StarterProvider extends OTEDatastore
|
||||||
{
|
{
|
|
@ -1,8 +1,12 @@
|
||||||
package dev.zontreck.thresholds.implementation.vault;
|
package dev.zontreck.otemod.implementation.vault;
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
|
import dev.zontreck.otemod.networking.ModMessages;
|
||||||
|
import dev.zontreck.otemod.networking.packets.OpenStarterVaultC2SPacket;
|
||||||
|
import dev.zontreck.otemod.networking.packets.OpenVaultC2SPacket;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
@ -19,7 +23,7 @@ public class StarterScreen extends AbstractContainerScreen <StarterMenu>
|
||||||
public final Player thePlayer;
|
public final Player thePlayer;
|
||||||
public final StarterMenu THE_CONTAINER;
|
public final StarterMenu THE_CONTAINER;
|
||||||
|
|
||||||
private static final ResourceLocation TEXTURE = new ResourceLocation(ThresholdsMod.MOD_ID, "textures/gui/vault.png");
|
private static final ResourceLocation TEXTURE = new ResourceLocation(OTEMod.MOD_ID, "textures/gui/vault.png");
|
||||||
|
|
||||||
public StarterScreen(StarterMenu container, Inventory playerInv, Component comp){
|
public StarterScreen(StarterMenu container, Inventory playerInv, Component comp){
|
||||||
super(container, playerInv, comp);
|
super(container, playerInv, comp);
|
|
@ -1,4 +1,4 @@
|
||||||
package dev.zontreck.thresholds.implementation.vault;
|
package dev.zontreck.otemod.implementation.vault;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.profiles.Profile;
|
import dev.zontreck.libzontreck.profiles.Profile;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
|
@ -1,116 +1,116 @@
|
||||||
package dev.zontreck.thresholds.implementation.vault;
|
package dev.zontreck.otemod.implementation.vault;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
import dev.zontreck.libzontreck.profiles.Profile;
|
import dev.zontreck.libzontreck.profiles.Profile;
|
||||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.implementation.events.VaultModifiedEvent;
|
import dev.zontreck.otemod.implementation.events.VaultModifiedEvent;
|
||||||
import dev.zontreck.thresholds.implementation.vault.VaultProvider.VaultAccessStrategy;
|
import dev.zontreck.otemod.implementation.vault.VaultProvider.VaultAccessStrategy;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.inventory.MenuConstructor;
|
import net.minecraft.world.inventory.MenuConstructor;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class VaultContainer
|
public class VaultContainer
|
||||||
{
|
{
|
||||||
public static Map<UUID, VaultContainer> VAULT_REGISTRY = new HashMap<>();
|
public static Map<UUID, VaultContainer> VAULT_REGISTRY = new HashMap<>();
|
||||||
public VaultMenu theContainer;
|
public VaultMenu theContainer;
|
||||||
public ItemStackHandler myInventory;
|
public ItemStackHandler myInventory;
|
||||||
public ItemStackHandler startingInventory;
|
public ItemStackHandler startingInventory;
|
||||||
public MenuConstructor serverMenu;
|
public MenuConstructor serverMenu;
|
||||||
public UUID owner;
|
public UUID owner;
|
||||||
private MinecraftServer server;
|
private MinecraftServer server;
|
||||||
public final int VAULT_NUMBER;
|
public final int VAULT_NUMBER;
|
||||||
public final UUID VaultID;
|
public final UUID VaultID;
|
||||||
public Vault main_accessor;
|
public Vault main_accessor;
|
||||||
private boolean invalid;
|
private boolean invalid;
|
||||||
public VaultContainer(ServerPlayer player, int vaultNum) throws NoMoreVaultException {
|
public VaultContainer(ServerPlayer player, int vaultNum) throws NoMoreVaultException {
|
||||||
myInventory = new ItemStackHandler(54); // Vaults have a fixed size at the same as a double chest
|
myInventory = new ItemStackHandler(54); // Vaults have a fixed size at the same as a double chest
|
||||||
startingInventory = new ItemStackHandler(64);
|
startingInventory = new ItemStackHandler(64);
|
||||||
theContainer = new VaultMenu(player.containerCounter+1, player.getInventory(), myInventory, BlockPos.ZERO, player, vaultNum);
|
theContainer = new VaultMenu(player.containerCounter+1, player.getInventory(), myInventory, BlockPos.ZERO, player, vaultNum);
|
||||||
VaultID = theContainer.VaultMenuID;
|
VaultID = theContainer.VaultMenuID;
|
||||||
owner = player.getUUID();
|
owner = player.getUUID();
|
||||||
server=player.server;
|
server=player.server;
|
||||||
serverMenu = theContainer.getServerMenu(myInventory, vaultNum);
|
serverMenu = theContainer.getServerMenu(myInventory, vaultNum);
|
||||||
VAULT_NUMBER=vaultNum;
|
VAULT_NUMBER=vaultNum;
|
||||||
if(VAULT_NUMBER == -1)return; // Trash ID
|
if(VAULT_NUMBER == -1)return; // Trash ID
|
||||||
|
|
||||||
// Check database for vault
|
// Check database for vault
|
||||||
VaultAccessStrategy strategy;
|
VaultAccessStrategy strategy;
|
||||||
try {
|
try {
|
||||||
strategy = VaultProvider.check(Profile.get_profile_of(player.getStringUUID()), vaultNum);
|
strategy = VaultProvider.check(Profile.get_profile_of(player.getStringUUID()), vaultNum);
|
||||||
if(strategy == VaultAccessStrategy.CREATE || strategy == VaultAccessStrategy.OPEN)
|
if(strategy == VaultAccessStrategy.CREATE || strategy == VaultAccessStrategy.OPEN)
|
||||||
{
|
{
|
||||||
Vault accessor = VaultProvider.get(Profile.get_profile_of(player.getStringUUID()), vaultNum);
|
Vault accessor = VaultProvider.get(Profile.get_profile_of(player.getStringUUID()), vaultNum);
|
||||||
if(accessor.isNew)
|
if(accessor.isNew)
|
||||||
{
|
{
|
||||||
main_accessor=accessor;
|
main_accessor=accessor;
|
||||||
return;
|
return;
|
||||||
}else {
|
}else {
|
||||||
myInventory.deserializeNBT(accessor.getContents());
|
myInventory.deserializeNBT(accessor.getContents());
|
||||||
startingInventory.deserializeNBT(accessor.getContents());
|
startingInventory.deserializeNBT(accessor.getContents());
|
||||||
}
|
}
|
||||||
main_accessor=accessor;
|
main_accessor=accessor;
|
||||||
}else {
|
}else {
|
||||||
// DENY
|
// DENY
|
||||||
throw new NoMoreVaultException("No more vaults can be created", vaultNum);
|
throw new NoMoreVaultException("No more vaults can be created", vaultNum);
|
||||||
}
|
}
|
||||||
} catch (UserProfileNotYetExistsException e) {
|
} catch (UserProfileNotYetExistsException e) {
|
||||||
throw new NoMoreVaultException("User profile not exists. No vault can be opened or created", -9999);
|
throw new NoMoreVaultException("User profile not exists. No vault can be opened or created", -9999);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Container is now ready to be sent to the client!
|
// Container is now ready to be sent to the client!
|
||||||
}
|
}
|
||||||
|
|
||||||
public void commit()
|
public void commit()
|
||||||
{
|
{
|
||||||
if(invalid)return;
|
if(invalid)return;
|
||||||
if(VAULT_NUMBER == -1)return; // We have no need to save the trash
|
if(VAULT_NUMBER == -1)return; // We have no need to save the trash
|
||||||
boolean isEmpty=true;
|
boolean isEmpty=true;
|
||||||
CompoundTag saved = myInventory.serializeNBT();
|
CompoundTag saved = myInventory.serializeNBT();
|
||||||
ChatHelpers.broadcastToAbove(owner, Component.literal(ChatColor.BOLD+ChatColor.DARK_GREEN+"Saving the vault's contents..."), server);
|
ChatHelpers.broadcastToAbove(owner, Component.literal(ChatColor.BOLD+ChatColor.DARK_GREEN+"Saving the vault's contents..."), server);
|
||||||
|
|
||||||
Profile profile=null;
|
Profile profile=null;
|
||||||
try {
|
try {
|
||||||
profile = Profile.get_profile_of(owner.toString());
|
profile = Profile.get_profile_of(owner.toString());
|
||||||
} catch (UserProfileNotYetExistsException e) {
|
} catch (UserProfileNotYetExistsException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0;i<myInventory.getSlots();i++)
|
for(int i = 0;i<myInventory.getSlots();i++)
|
||||||
{
|
{
|
||||||
ItemStack is = myInventory.getStackInSlot(i);
|
ItemStack is = myInventory.getStackInSlot(i);
|
||||||
if(!is.is(Items.AIR))
|
if(!is.is(Items.AIR))
|
||||||
{
|
{
|
||||||
isEmpty=false;
|
isEmpty=false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!isEmpty)
|
if(!isEmpty)
|
||||||
main_accessor.setContents(saved);
|
main_accessor.setContents(saved);
|
||||||
else
|
else
|
||||||
main_accessor.delete();
|
main_accessor.delete();
|
||||||
|
|
||||||
|
|
||||||
VaultModifiedEvent vme = new VaultModifiedEvent(VAULT_NUMBER, profile, VaultProvider.getInUse(profile), myInventory, startingInventory);
|
VaultModifiedEvent vme = new VaultModifiedEvent(VAULT_NUMBER, profile, VaultProvider.getInUse(profile), myInventory, startingInventory);
|
||||||
ThresholdsMod.bus.post(vme);
|
OTEMod.bus.post(vme);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void invalidate()
|
public void invalidate()
|
||||||
{
|
{
|
||||||
invalid=true;
|
invalid=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,152 +1,153 @@
|
||||||
package dev.zontreck.thresholds.implementation.vault;
|
package dev.zontreck.otemod.implementation.vault;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.implementation.inits.ModMenuTypes;
|
import dev.zontreck.otemod.implementation.inits.ModMenuTypes;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.MenuConstructor;
|
import net.minecraft.world.inventory.ClickType;
|
||||||
import net.minecraft.world.inventory.Slot;
|
import net.minecraft.world.inventory.MenuConstructor;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.inventory.Slot;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.SlotItemHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
import net.minecraftforge.items.SlotItemHandler;
|
||||||
public class VaultMenu extends AbstractContainerMenu
|
|
||||||
{
|
public class VaultMenu extends AbstractContainerMenu
|
||||||
//private final ContainerLevelAccess containerAccess;
|
{
|
||||||
public final UUID VaultMenuID;
|
//private final ContainerLevelAccess containerAccess;
|
||||||
public final Player thePlayer;
|
public final UUID VaultMenuID;
|
||||||
public final int VAULT_NUMBER;
|
public final Player thePlayer;
|
||||||
|
public final int VAULT_NUMBER;
|
||||||
public VaultMenu (int id, Inventory player, FriendlyByteBuf buf)
|
|
||||||
{
|
public VaultMenu (int id, Inventory player, FriendlyByteBuf buf)
|
||||||
this(id, player, new ItemStackHandler(54), player.player.getOnPos(), player.player, 0);
|
{
|
||||||
}
|
this(id, player, new ItemStackHandler(54), player.player.getOnPos(), player.player, 0);
|
||||||
|
}
|
||||||
public VaultMenu (int id, Inventory player, IItemHandler slots, BlockPos pos, Player play, int vaultNum)
|
|
||||||
{
|
public VaultMenu (int id, Inventory player, IItemHandler slots, BlockPos pos, Player play, int vaultNum)
|
||||||
super(ModMenuTypes.VAULT.get(), id);
|
{
|
||||||
thePlayer=play;
|
super(ModMenuTypes.VAULT.get(), id);
|
||||||
VaultMenuID=UUID.randomUUID();
|
thePlayer=play;
|
||||||
VAULT_NUMBER=vaultNum;
|
VaultMenuID=UUID.randomUUID();
|
||||||
//this.containerAccess = ContainerLevelAccess.create(player.player.level, pos);
|
VAULT_NUMBER=vaultNum;
|
||||||
|
//this.containerAccess = ContainerLevelAccess.create(player.player.level, pos);
|
||||||
final int slotSize = 18;
|
|
||||||
final int startX = 24;
|
final int slotSize = 18;
|
||||||
final int inventoryY = 38;
|
final int startX = 24;
|
||||||
|
final int inventoryY = 38;
|
||||||
addPlayerInventory(player);
|
|
||||||
addPlayerHotbar(player);
|
addPlayerInventory(player);
|
||||||
|
addPlayerHotbar(player);
|
||||||
|
|
||||||
for (int row = 0; row < 6; row++)
|
|
||||||
{
|
for (int row = 0; row < 6; row++)
|
||||||
for (int column = 0; column < 9; column++)
|
{
|
||||||
{
|
for (int column = 0; column < 9; column++)
|
||||||
addSlot(new SlotItemHandler(slots, row*9 + column, startX+column * slotSize , inventoryY + row * slotSize));
|
{
|
||||||
}
|
addSlot(new SlotItemHandler(slots, row*9 + column, startX+column * slotSize , inventoryY + row * slotSize));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// CREDIT GOES TO: diesieben07 | https://github.com/diesieben07/SevenCommons
|
|
||||||
// must assign a slot number to each of the slots used by the GUI.
|
// CREDIT GOES TO: diesieben07 | https://github.com/diesieben07/SevenCommons
|
||||||
// For this container, we can see both the tile inventory's slots as well as the player inventory slots and the hotbar.
|
// must assign a slot number to each of the slots used by the GUI.
|
||||||
// Each time we add a Slot to the container, it automatically increases the slotIndex, which means
|
// For this container, we can see both the tile inventory's slots as well as the player inventory slots and the hotbar.
|
||||||
// 0 - 8 = hotbar slots (which will map to the InventoryPlayer slot numbers 0 - 8)
|
// Each time we add a Slot to the container, it automatically increases the slotIndex, which means
|
||||||
// 9 - 35 = player inventory slots (which map to the InventoryPlayer slot numbers 9 - 35)
|
// 0 - 8 = hotbar slots (which will map to the InventoryPlayer slot numbers 0 - 8)
|
||||||
// 36 - 44 = TileInventory slots, which map to our TileEntity slot numbers 0 - 8)
|
// 9 - 35 = player inventory slots (which map to the InventoryPlayer slot numbers 9 - 35)
|
||||||
private static final int HOTBAR_SLOT_COUNT = 9;
|
// 36 - 44 = TileInventory slots, which map to our TileEntity slot numbers 0 - 8)
|
||||||
private static final int PLAYER_INVENTORY_ROW_COUNT = 3;
|
private static final int HOTBAR_SLOT_COUNT = 9;
|
||||||
private static final int PLAYER_INVENTORY_COLUMN_COUNT = 9;
|
private static final int PLAYER_INVENTORY_ROW_COUNT = 3;
|
||||||
private static final int PLAYER_INVENTORY_SLOT_COUNT = PLAYER_INVENTORY_COLUMN_COUNT * PLAYER_INVENTORY_ROW_COUNT;
|
private static final int PLAYER_INVENTORY_COLUMN_COUNT = 9;
|
||||||
private static final int VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_SLOT_COUNT;
|
private static final int PLAYER_INVENTORY_SLOT_COUNT = PLAYER_INVENTORY_COLUMN_COUNT * PLAYER_INVENTORY_ROW_COUNT;
|
||||||
private static final int VANILLA_FIRST_SLOT_INDEX = 0;
|
private static final int VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_SLOT_COUNT;
|
||||||
private static final int TE_INVENTORY_FIRST_SLOT_INDEX = VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT;
|
private static final int VANILLA_FIRST_SLOT_INDEX = 0;
|
||||||
|
private static final int TE_INVENTORY_FIRST_SLOT_INDEX = VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT;
|
||||||
// THIS YOU HAVE TO DEFINE!
|
|
||||||
private static final int TE_INVENTORY_SLOT_COUNT = 54; // must be the number of slots you have!
|
// THIS YOU HAVE TO DEFINE!
|
||||||
|
private static final int TE_INVENTORY_SLOT_COUNT = 54; // must be the number of slots you have!
|
||||||
@Override
|
|
||||||
public ItemStack quickMoveStack(Player playerIn, int index) {
|
@Override
|
||||||
Slot sourceSlot = slots.get(index);
|
public ItemStack quickMoveStack(Player playerIn, int index) {
|
||||||
if (sourceSlot == null || !sourceSlot.hasItem()) return ItemStack.EMPTY; //EMPTY_ITEM
|
Slot sourceSlot = slots.get(index);
|
||||||
ItemStack sourceStack = sourceSlot.getItem();
|
if (sourceSlot == null || !sourceSlot.hasItem()) return ItemStack.EMPTY; //EMPTY_ITEM
|
||||||
ItemStack copyOfSourceStack = sourceStack.copy();
|
ItemStack sourceStack = sourceSlot.getItem();
|
||||||
|
ItemStack copyOfSourceStack = sourceStack.copy();
|
||||||
// Check if the slot clicked is one of the vanilla container slots
|
|
||||||
if (index < VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT) {
|
// Check if the slot clicked is one of the vanilla container slots
|
||||||
// This is a vanilla container slot so merge the stack into the tile inventory
|
if (index < VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT) {
|
||||||
if (!moveItemStackTo(sourceStack, TE_INVENTORY_FIRST_SLOT_INDEX, TE_INVENTORY_FIRST_SLOT_INDEX
|
// This is a vanilla container slot so merge the stack into the tile inventory
|
||||||
+ TE_INVENTORY_SLOT_COUNT, false)) {
|
if (!moveItemStackTo(sourceStack, TE_INVENTORY_FIRST_SLOT_INDEX, TE_INVENTORY_FIRST_SLOT_INDEX
|
||||||
return ItemStack.EMPTY; // EMPTY_ITEM
|
+ TE_INVENTORY_SLOT_COUNT, false)) {
|
||||||
}
|
return ItemStack.EMPTY; // EMPTY_ITEM
|
||||||
} else if (index < TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT) {
|
}
|
||||||
// This is a TE slot so merge the stack into the players inventory
|
} else if (index < TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT) {
|
||||||
if (!moveItemStackTo(sourceStack, VANILLA_FIRST_SLOT_INDEX, VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT, false)) {
|
// This is a TE slot so merge the stack into the players inventory
|
||||||
return ItemStack.EMPTY;
|
if (!moveItemStackTo(sourceStack, VANILLA_FIRST_SLOT_INDEX, VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT, false)) {
|
||||||
}
|
return ItemStack.EMPTY;
|
||||||
} else {
|
}
|
||||||
System.out.println("Invalid slotIndex:" + index);
|
} else {
|
||||||
return ItemStack.EMPTY;
|
System.out.println("Invalid slotIndex:" + index);
|
||||||
}
|
return ItemStack.EMPTY;
|
||||||
// If stack size == 0 (the entire stack was moved) set slot contents to null
|
}
|
||||||
if (sourceStack.getCount() == 0) {
|
// If stack size == 0 (the entire stack was moved) set slot contents to null
|
||||||
sourceSlot.set(ItemStack.EMPTY);
|
if (sourceStack.getCount() == 0) {
|
||||||
} else {
|
sourceSlot.set(ItemStack.EMPTY);
|
||||||
sourceSlot.setChanged();
|
} else {
|
||||||
}
|
sourceSlot.setChanged();
|
||||||
sourceSlot.onTake(playerIn, sourceStack);
|
}
|
||||||
return copyOfSourceStack;
|
sourceSlot.onTake(playerIn, sourceStack);
|
||||||
}
|
return copyOfSourceStack;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean stillValid(Player p_38874_) {
|
@Override
|
||||||
return true; // We have no block
|
public boolean stillValid(Player p_38874_) {
|
||||||
}
|
return true; // We have no block
|
||||||
|
}
|
||||||
public static MenuConstructor getServerMenu (ItemStackHandler inventory, int vaultNum){
|
|
||||||
return (id, player, play) -> new VaultMenu(id, player, inventory, BlockPos.ZERO, player.player, vaultNum);
|
public static MenuConstructor getServerMenu (ItemStackHandler inventory, int vaultNum){
|
||||||
}
|
return (id, player, play) -> new VaultMenu(id, player, inventory, BlockPos.ZERO, player.player, vaultNum);
|
||||||
|
}
|
||||||
|
|
||||||
public void doCommitAction()
|
|
||||||
{
|
public void doCommitAction()
|
||||||
|
{
|
||||||
// Locate the Vault in the Vault Registry and commit changes.
|
|
||||||
// Search for myself!
|
// Locate the Vault in the Vault Registry and commit changes.
|
||||||
for(Map.Entry<UUID,VaultContainer> e : VaultContainer.VAULT_REGISTRY.entrySet())
|
// Search for myself!
|
||||||
{
|
for(Map.Entry<UUID,VaultContainer> e : VaultContainer.VAULT_REGISTRY.entrySet())
|
||||||
if(e.getValue().VaultID.equals(VaultMenuID))
|
{
|
||||||
{
|
if(e.getValue().VaultID.equals(VaultMenuID))
|
||||||
e.getValue().commit();
|
{
|
||||||
}
|
e.getValue().commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static final int PLAYER_INVENTORY_FIRST_SLOT_HEIGHT = 156;
|
|
||||||
private static final int PLAYER_INVENTORY_FIRST_SLOT_LEFT = 24;
|
private static final int PLAYER_INVENTORY_FIRST_SLOT_HEIGHT = 156;
|
||||||
private static final int PLAYER_HOTBAR_FIRST_SLOT = 212;
|
private static final int PLAYER_INVENTORY_FIRST_SLOT_LEFT = 24;
|
||||||
|
private static final int PLAYER_HOTBAR_FIRST_SLOT = 212;
|
||||||
private void addPlayerInventory(Inventory inv)
|
|
||||||
{
|
private void addPlayerInventory(Inventory inv)
|
||||||
for (int i = 0; i < 3; i++) {
|
{
|
||||||
for (int j = 0; j < 9; j++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
this.addSlot(new Slot(inv, j+i*9+9, PLAYER_INVENTORY_FIRST_SLOT_LEFT+j*18, PLAYER_INVENTORY_FIRST_SLOT_HEIGHT+i*18));
|
for (int j = 0; j < 9; j++) {
|
||||||
}
|
this.addSlot(new Slot(inv, j+i*9+9, PLAYER_INVENTORY_FIRST_SLOT_LEFT+j*18, PLAYER_INVENTORY_FIRST_SLOT_HEIGHT+i*18));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private void addPlayerHotbar(Inventory inv)
|
|
||||||
{
|
private void addPlayerHotbar(Inventory inv)
|
||||||
for (int index = 0; index < 9; index++) {
|
{
|
||||||
this.addSlot(new Slot(inv, index, PLAYER_INVENTORY_FIRST_SLOT_LEFT+index*18, PLAYER_HOTBAR_FIRST_SLOT));
|
for (int index = 0; index < 9; index++) {
|
||||||
}
|
this.addSlot(new Slot(inv, index, PLAYER_INVENTORY_FIRST_SLOT_LEFT+index*18, PLAYER_HOTBAR_FIRST_SLOT));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package dev.zontreck.thresholds.implementation.vault;
|
package dev.zontreck.otemod.implementation.vault;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -7,8 +7,8 @@ import java.nio.file.Path;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.profiles.Profile;
|
import dev.zontreck.libzontreck.profiles.Profile;
|
||||||
import dev.zontreck.thresholds.configs.ThresholdsServerConfig;
|
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||||
import dev.zontreck.thresholds.database.OTEDatastore;
|
import dev.zontreck.otemod.database.OTEDatastore;
|
||||||
|
|
||||||
public class VaultProvider extends OTEDatastore
|
public class VaultProvider extends OTEDatastore
|
||||||
{
|
{
|
||||||
|
@ -67,12 +67,12 @@ public class VaultProvider extends OTEDatastore
|
||||||
|
|
||||||
public static boolean isAtMaxVaults(Profile prof, int consumed)
|
public static boolean isAtMaxVaults(Profile prof, int consumed)
|
||||||
{
|
{
|
||||||
if(ThresholdsServerConfig.MAX_VAULTS.get()==0){
|
if(OTEServerConfig.MAX_VAULTS.get()==0){
|
||||||
if(consumed < prof.available_vaults){
|
if(consumed < prof.available_vaults){
|
||||||
return false;
|
return false;
|
||||||
}else return true;
|
}else return true;
|
||||||
}
|
}
|
||||||
if(prof.available_vaults >= ThresholdsServerConfig.MAX_VAULTS.get())
|
if(prof.available_vaults >= OTEServerConfig.MAX_VAULTS.get())
|
||||||
{
|
{
|
||||||
if(consumed<prof.available_vaults)
|
if(consumed<prof.available_vaults)
|
||||||
{
|
{
|
|
@ -1,84 +1,91 @@
|
||||||
package dev.zontreck.thresholds.implementation.vault;
|
package dev.zontreck.otemod.implementation.vault;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
|
||||||
import dev.zontreck.thresholds.networking.ModMessages;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.networking.packets.OpenVaultC2SPacket;
|
import dev.zontreck.otemod.commands.vaults.VaultCommand;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import dev.zontreck.otemod.networking.ModMessages;
|
||||||
import net.minecraft.client.gui.components.Button;
|
import dev.zontreck.otemod.networking.packets.OpenVaultC2SPacket;
|
||||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.client.gui.components.Button.OnPress;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.client.gui.font.TextFieldHelper;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
public class VaultScreen extends AbstractContainerScreen <VaultMenu>
|
import net.minecraft.resources.ResourceLocation;
|
||||||
{
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
// 176x224
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
public final UUID VaultMenuID;
|
import net.minecraft.world.entity.player.Player;
|
||||||
public final Player thePlayer;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
public final VaultMenu THE_CONTAINER;
|
import net.minecraftforge.network.NetworkHooks;
|
||||||
|
|
||||||
private static final ResourceLocation TEXTURE = new ResourceLocation(ThresholdsMod.MOD_ID, "textures/gui/vault.png");
|
public class VaultScreen extends AbstractContainerScreen <VaultMenu>
|
||||||
|
{
|
||||||
public VaultScreen(VaultMenu container, Inventory playerInv, Component comp){
|
// 176x224
|
||||||
super(container, playerInv, comp);
|
public final UUID VaultMenuID;
|
||||||
thePlayer=playerInv.player;
|
public final Player thePlayer;
|
||||||
|
public final VaultMenu THE_CONTAINER;
|
||||||
this.VaultMenuID = container.VaultMenuID;
|
|
||||||
this.leftPos = 0;
|
private static final ResourceLocation TEXTURE = new ResourceLocation(OTEMod.MOD_ID, "textures/gui/vault.png");
|
||||||
this.topPos = 0;
|
|
||||||
this.THE_CONTAINER=container;
|
public VaultScreen(VaultMenu container, Inventory playerInv, Component comp){
|
||||||
|
super(container, playerInv, comp);
|
||||||
this.imageWidth = 207;
|
thePlayer=playerInv.player;
|
||||||
this.imageHeight = 238;
|
|
||||||
}
|
this.VaultMenuID = container.VaultMenuID;
|
||||||
|
this.leftPos = 0;
|
||||||
@Override
|
this.topPos = 0;
|
||||||
public void render(GuiGraphics stack, int mouseX, int mouseY, float partialTicks)
|
this.THE_CONTAINER=container;
|
||||||
{
|
|
||||||
this.renderBackground(stack);
|
this.imageWidth = 207;
|
||||||
super.render(stack, mouseX, mouseY, partialTicks);
|
this.imageHeight = 238;
|
||||||
this.renderTooltip(stack, mouseX, mouseY);
|
}
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public void render(GuiGraphics stack, int mouseX, int mouseY, float partialTicks)
|
||||||
@Override
|
{
|
||||||
protected void init()
|
this.renderBackground(stack);
|
||||||
{
|
super.render(stack, mouseX, mouseY, partialTicks);
|
||||||
super.init();
|
this.renderTooltip(stack, mouseX, mouseY);
|
||||||
this.inventoryLabelY = 12;
|
|
||||||
this.inventoryLabelX = 63;
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
// This is where custom controls would be added!
|
protected void init()
|
||||||
|
{
|
||||||
this.addWidget(Button.builder(Component.literal(""), (BTN)->{
|
super.init();
|
||||||
thePlayer.closeContainer();
|
this.inventoryLabelY = 12;
|
||||||
ModMessages.sendToServer(new OpenVaultC2SPacket(0, true, -1));
|
this.inventoryLabelX = 63;
|
||||||
}).size(16,16).pos(this.leftPos+7, this.topPos+86).build());
|
|
||||||
|
|
||||||
|
// This is where custom controls would be added!
|
||||||
this.addWidget(Button.builder(Component.literal(""), (BTN)->{
|
|
||||||
thePlayer.closeContainer();
|
this.addWidget(Button.builder(Component.literal(""), (BTN)->{
|
||||||
ModMessages.sendToServer(new OpenVaultC2SPacket(0, true, 1));
|
thePlayer.closeContainer();
|
||||||
}).size(16,16).pos(this.leftPos+187, this.topPos+84).build());
|
ModMessages.sendToServer(new OpenVaultC2SPacket(0, true, -1));
|
||||||
|
}).size(16,16).pos(this.leftPos+7, this.topPos+86).build());
|
||||||
}
|
|
||||||
|
|
||||||
|
this.addWidget(Button.builder(Component.literal(""), (BTN)->{
|
||||||
@Override
|
thePlayer.closeContainer();
|
||||||
protected void renderBg(GuiGraphics pGuiGraphics, float pPartialTick, int pMouseX, int pMouseY)
|
ModMessages.sendToServer(new OpenVaultC2SPacket(0, true, 1));
|
||||||
{
|
}).size(16,16).pos(this.leftPos+187, this.topPos+84).build());
|
||||||
renderBackground(pGuiGraphics);
|
|
||||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
}
|
||||||
RenderSystem.setShaderColor (1.0f, 1.0f, 1.0f, 1.0f);
|
|
||||||
RenderSystem.setShaderTexture(0, TEXTURE);
|
|
||||||
|
@Override
|
||||||
pGuiGraphics.blit(TEXTURE, this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight);
|
protected void renderBg(GuiGraphics pGuiGraphics, float pPartialTick, int pMouseX, int pMouseY)
|
||||||
}
|
{
|
||||||
}
|
renderBackground(pGuiGraphics);
|
||||||
|
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||||
|
RenderSystem.setShaderColor (1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
RenderSystem.setShaderTexture(0, TEXTURE);
|
||||||
|
|
||||||
|
pGuiGraphics.blit(TEXTURE, this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,44 +1,45 @@
|
||||||
package dev.zontreck.thresholds.implementation.vault;
|
package dev.zontreck.otemod.implementation.vault;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import net.minecraftforge.event.entity.player.PlayerContainerEvent;
|
import net.minecraftforge.client.event.ContainerScreenEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.event.entity.player.PlayerContainerEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||||
@EventBusSubscriber(modid= ThresholdsMod.MOD_ID,bus=Mod.EventBusSubscriber.Bus.FORGE)
|
|
||||||
public class VaultWatcher {
|
@EventBusSubscriber(modid=OTEMod.MOD_ID,bus=Mod.EventBusSubscriber.Bus.FORGE)
|
||||||
|
public class VaultWatcher {
|
||||||
@SubscribeEvent
|
|
||||||
public void onClosedContainer(PlayerContainerEvent.Close ev)
|
@SubscribeEvent
|
||||||
{
|
public void onClosedContainer(PlayerContainerEvent.Close ev)
|
||||||
if(ev.getEntity().level().isClientSide)return;
|
{
|
||||||
//OTEMod.LOGGER.info("Player closed a container");
|
if(ev.getEntity().level().isClientSide)return;
|
||||||
// Player closed the container
|
//OTEMod.LOGGER.info("Player closed a container");
|
||||||
// Check if it is a vault Container
|
// Player closed the container
|
||||||
if(ev.getContainer() instanceof VaultMenu)
|
// Check if it is a vault Container
|
||||||
{
|
if(ev.getContainer() instanceof VaultMenu)
|
||||||
// During testing the instance of VaultMenu we get passed back through this method gets a regenerated Vault ID, so our only option is to iterate here and commit a vault based on owner ID
|
{
|
||||||
for(Map.Entry<UUID, VaultContainer> entry : VaultContainer.VAULT_REGISTRY.entrySet()){
|
// During testing the instance of VaultMenu we get passed back through this method gets a regenerated Vault ID, so our only option is to iterate here and commit a vault based on owner ID
|
||||||
if(entry.getKey() == ev.getEntity().getUUID())
|
for(Map.Entry<UUID, VaultContainer> entry : VaultContainer.VAULT_REGISTRY.entrySet()){
|
||||||
{
|
if(entry.getKey() == ev.getEntity().getUUID())
|
||||||
entry.getValue().commit();
|
{
|
||||||
entry.getValue().invalidate();
|
entry.getValue().commit();
|
||||||
}
|
entry.getValue().invalidate();
|
||||||
}
|
}
|
||||||
} else if(ev.getContainer() instanceof StarterMenu)
|
}
|
||||||
{
|
} else if(ev.getContainer() instanceof StarterMenu)
|
||||||
for(Map.Entry<UUID, StarterContainer> entry : StarterContainer.VAULT_REGISTRY.entrySet())
|
{
|
||||||
{
|
for(Map.Entry<UUID, StarterContainer> entry : StarterContainer.VAULT_REGISTRY.entrySet())
|
||||||
if(entry.getKey() == ev.getEntity().getUUID())
|
{
|
||||||
{
|
if(entry.getKey() == ev.getEntity().getUUID())
|
||||||
entry.getValue().commit();
|
{
|
||||||
entry.getValue().invalidate();
|
entry.getValue().commit();
|
||||||
}
|
entry.getValue().invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -1,28 +1,30 @@
|
||||||
package dev.zontreck.thresholds.integrations;
|
package dev.zontreck.otemod.integrations;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.InputConstants;
|
import com.mojang.blaze3d.platform.InputConstants;
|
||||||
|
|
||||||
import net.minecraft.client.KeyMapping;
|
import net.minecraft.client.KeyMapping;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraft.client.multiplayer.ClientRegistryLayer;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
|
||||||
@OnlyIn(Dist.CLIENT)
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
public class KeyBindings {
|
|
||||||
public static final String KEY_CATEGORY_OTEMOD = "key.category.otemod";
|
@OnlyIn(Dist.CLIENT)
|
||||||
public static final String KEY_OPEN_VAULT = "key.otemod.open_vault";
|
public class KeyBindings {
|
||||||
|
public static final String KEY_CATEGORY_OTEMOD = "key.category.otemod";
|
||||||
public static final KeyMapping OPEN_VAULT = createKeyMapping(KEY_OPEN_VAULT, InputConstants.KEY_V, KEY_CATEGORY_OTEMOD);
|
public static final String KEY_OPEN_VAULT = "key.otemod.open_vault";
|
||||||
|
|
||||||
private static KeyMapping createKeyMapping(String name, int keycode, String category){
|
public static final KeyMapping OPEN_VAULT = createKeyMapping(KEY_OPEN_VAULT, InputConstants.KEY_V, KEY_CATEGORY_OTEMOD);
|
||||||
final KeyMapping key = new KeyMapping(name, keycode, category);
|
|
||||||
return key;
|
private static KeyMapping createKeyMapping(String name, int keycode, String category){
|
||||||
}
|
final KeyMapping key = new KeyMapping(name, keycode, category);
|
||||||
|
return key;
|
||||||
@SubscribeEvent
|
}
|
||||||
public static void registerKeyMappings(RegisterKeyMappingsEvent event)
|
|
||||||
{
|
@SubscribeEvent
|
||||||
event.register(OPEN_VAULT);
|
public static void registerKeyMappings(RegisterKeyMappingsEvent event)
|
||||||
}
|
{
|
||||||
}
|
event.register(OPEN_VAULT);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,37 +1,40 @@
|
||||||
package dev.zontreck.thresholds.integrations;
|
package dev.zontreck.otemod.integrations;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
import dev.zontreck.thresholds.implementation.Messages;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||||
|
import dev.zontreck.otemod.implementation.Messages;
|
||||||
public class LuckPermsHelper {
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
/*public static LuckPerms getLuckPerms()
|
import net.minecraft.world.entity.player.Player;
|
||||||
{
|
|
||||||
return LuckPermsProvider.get();
|
public class LuckPermsHelper {
|
||||||
}
|
/*public static LuckPerms getLuckPerms()
|
||||||
|
{
|
||||||
private static User getUserOf(Player p){
|
return LuckPermsProvider.get();
|
||||||
return getLuckPerms().getPlayerAdapter(Player.class).getUser(p);
|
}
|
||||||
}
|
|
||||||
|
private static User getUserOf(Player p){
|
||||||
private static boolean hasPermission(User u, String perm)
|
return getLuckPerms().getPlayerAdapter(Player.class).getUser(p);
|
||||||
{
|
}
|
||||||
return u.getCachedData().getPermissionData().checkPermission(perm).asBoolean();
|
|
||||||
}*/
|
private static boolean hasPermission(User u, String perm)
|
||||||
|
{
|
||||||
public static boolean hasPermission(Player p, String perm)
|
return u.getCachedData().getPermissionData().checkPermission(perm).asBoolean();
|
||||||
{
|
}*/
|
||||||
//User u = getUserOf(p);
|
|
||||||
|
public static boolean hasPermission(Player p, String perm)
|
||||||
return true;
|
{
|
||||||
}
|
//User u = getUserOf(p);
|
||||||
|
|
||||||
public static boolean hasGroupOrPerm(Player p, String group, String perm){
|
return true;
|
||||||
return hasPermission(p, group) || hasPermission(p, perm);
|
}
|
||||||
}
|
|
||||||
|
public static boolean hasGroupOrPerm(Player p, String group, String perm){
|
||||||
public static void sendNoPermissionsMessage(ServerPlayer play, String perm, String group) {
|
return hasPermission(p, group) || hasPermission(p, perm);
|
||||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(Messages.THRESHOLDS_PREFIX +" !Dark_Red!You do not have permission to use that command. You need permission !Gold!"+perm+" !White! or !Gold!"+group), play.server);
|
}
|
||||||
}
|
|
||||||
}
|
public static void sendNoPermissionsMessage(ServerPlayer play, String perm, String group) {
|
||||||
|
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(Messages.OTE_PREFIX+" !Dark_Red!You do not have permission to use that command. You need permission !Gold!"+perm+" !White! or !Gold!"+group), play.server);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
package dev.zontreck.thresholds.items;
|
package dev.zontreck.otemod.items;
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
|
|
||||||
public class IhanCrystal extends Item{
|
public class IhanCrystal extends Item{
|
||||||
|
|
||||||
public IhanCrystal(Properties p_41383_) {
|
public IhanCrystal(Properties p_41383_) {
|
||||||
super(p_41383_);
|
super(p_41383_);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,76 +1,79 @@
|
||||||
package dev.zontreck.thresholds.items;
|
package dev.zontreck.otemod.items;
|
||||||
|
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.implementation.CreativeModeTabs;
|
import dev.zontreck.otemod.blocks.FoiledBlockItem;
|
||||||
import net.minecraft.world.item.*;
|
import dev.zontreck.otemod.entities.ModEntityTypes;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import dev.zontreck.otemod.implementation.CreativeModeTabs;
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
import net.minecraft.world.item.*;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.common.ForgeSpawnEggItem;
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
public class ModItems {
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ThresholdsMod.MOD_ID);
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
|
|
||||||
public static final RegistryObject<Item> ETERNIUM_FRAGMENT = CreativeModeTabs.addToOTEModTab(ITEMS.register("eternium_fragment", () -> new Item(new Item.Properties())));
|
public class ModItems {
|
||||||
|
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, OTEMod.MOD_ID);
|
||||||
public static final RegistryObject<Item> IHAN_CRYSTAL = CreativeModeTabs.addToOTEModTab(ITEMS.register("ihan_crystal", () -> new Item(new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> ETERNIUM_FRAGMENT = CreativeModeTabs.addToOTEModTab(ITEMS.register("eternium_fragment", () -> new Item(new Item.Properties())));
|
||||||
public static final RegistryObject<Item> AURORA_COMPOUND = CreativeModeTabs.addToOTEModTab(ITEMS.register("aurora_compound", () -> new Item(new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> IHAN_CRYSTAL = CreativeModeTabs.addToOTEModTab(ITEMS.register("ihan_crystal", () -> new Item(new Item.Properties())));
|
||||||
|
|
||||||
public static final RegistryObject<Item> ETERNIUM_RAW_ORE = CreativeModeTabs.addToOTEModTab(ITEMS.register("eternium_ore", () -> new Item(new Item.Properties())));
|
public static final RegistryObject<Item> AURORA_COMPOUND = CreativeModeTabs.addToOTEModTab(ITEMS.register("aurora_compound", () -> new Item(new Item.Properties())));
|
||||||
|
|
||||||
public static final RegistryObject<Item> ETERNIUM_INGOT = CreativeModeTabs.addToOTEModTab(ITEMS.register("eternium_ingot", ()-> new SimpleFoiledItem(new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> ETERNIUM_RAW_ORE = CreativeModeTabs.addToOTEModTab(ITEMS.register("eternium_ore", () -> new Item(new Item.Properties())));
|
||||||
|
|
||||||
|
public static final RegistryObject<Item> ETERNIUM_INGOT = CreativeModeTabs.addToOTEModTab(ITEMS.register("eternium_ingot", ()-> new SimpleFoiledItem(new Item.Properties())));
|
||||||
public static final RegistryObject<Item> MELTED_ENDER_PEARL = CreativeModeTabs.addToOTEModTab(ITEMS.register("melted_ender_pearl", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
|
||||||
public static final RegistryObject<Item> SINGULARITY = CreativeModeTabs.addToOTEModTab(ITEMS.register("singularity", () -> new UnstableSingularity(new Item.Properties().stacksTo(1))));
|
|
||||||
|
|
||||||
public static final RegistryObject<Item> COMPRESSED_OBSIDIAN_SHEET = CreativeModeTabs.addToOTEModTab(ITEMS.register("compressed_obsidian_sheet", ()->new Item(new Item.Properties())));
|
public static final RegistryObject<Item> MELTED_ENDER_PEARL = CreativeModeTabs.addToOTEModTab(ITEMS.register("melted_ender_pearl", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
||||||
|
public static final RegistryObject<Item> SINGULARITY = CreativeModeTabs.addToOTEModTab(ITEMS.register("singularity", () -> new UnstableSingularity(new Item.Properties().stacksTo(1))));
|
||||||
public static final RegistryObject<Item> LAYERED_COMPRESSED_OBSIDIAN_SHEET = CreativeModeTabs.addToOTEModTab(ITEMS.register("layered_compressed_obsidian_sheet", ()->new SimpleFoiledItem(new Item.Properties())));
|
|
||||||
public static final RegistryObject<Item> ENCASED_SINGULARITY = CreativeModeTabs.addToOTEModTab(ITEMS.register("encased_singularity", ()->new SimpleFoiledItem(new Item.Properties())));
|
public static final RegistryObject<Item> COMPRESSED_OBSIDIAN_SHEET = CreativeModeTabs.addToOTEModTab(ITEMS.register("compressed_obsidian_sheet", ()->new Item(new Item.Properties())));
|
||||||
|
|
||||||
public static final RegistryObject<Item> ETERNIUM_ROD = CreativeModeTabs.addToOTEModTab(ITEMS.register("eternium_rod", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
public static final RegistryObject<Item> LAYERED_COMPRESSED_OBSIDIAN_SHEET = CreativeModeTabs.addToOTEModTab(ITEMS.register("layered_compressed_obsidian_sheet", ()->new SimpleFoiledItem(new Item.Properties())));
|
||||||
public static final RegistryObject<Item> SCRUBBER_FRAME_PIECE = CreativeModeTabs.addToOTEModTab(ITEMS.register("scrubber_frame_piece", () -> new Item(new Item.Properties().stacksTo(64))));
|
public static final RegistryObject<Item> ENCASED_SINGULARITY = CreativeModeTabs.addToOTEModTab(ITEMS.register("encased_singularity", ()->new SimpleFoiledItem(new Item.Properties())));
|
||||||
public static final RegistryObject<Item> SCRUBBER_FRAME = CreativeModeTabs.addToOTEModTab(ITEMS.register("scrubber_frame", () -> new Item(new Item.Properties().stacksTo(64))));
|
|
||||||
|
public static final RegistryObject<Item> ETERNIUM_ROD = CreativeModeTabs.addToOTEModTab(ITEMS.register("eternium_rod", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
||||||
|
public static final RegistryObject<Item> SCRUBBER_FRAME_PIECE = CreativeModeTabs.addToOTEModTab(ITEMS.register("scrubber_frame_piece", () -> new Item(new Item.Properties().stacksTo(64))));
|
||||||
public static final RegistryObject<Item> VAULTSTEEL_INGOT = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_steel_ingot", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
public static final RegistryObject<Item> SCRUBBER_FRAME = CreativeModeTabs.addToOTEModTab(ITEMS.register("scrubber_frame", () -> new Item(new Item.Properties().stacksTo(64))));
|
||||||
public static final RegistryObject<Item> VAULT_FRAG_BL = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_lower_left", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
|
||||||
public static final RegistryObject<Item> VAULT_FRAG_LC = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_lower", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
|
||||||
public static final RegistryObject<Item> VAULT_FRAG_BR = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_lower_right", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
public static final RegistryObject<Item> VAULTSTEEL_INGOT = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_steel_ingot", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
||||||
public static final RegistryObject<Item> VAULT_FRAG_L = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_left", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
public static final RegistryObject<Item> VAULT_FRAG_BL = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_lower_left", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
||||||
public static final RegistryObject<Item> VAULT_FRAG_R = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_right", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
public static final RegistryObject<Item> VAULT_FRAG_LC = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_lower", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
||||||
public static final RegistryObject<Item> VAULT_FRAG_UR = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_upper_right", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
public static final RegistryObject<Item> VAULT_FRAG_BR = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_lower_right", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
||||||
public static final RegistryObject<Item> VAULT_FRAG_UL = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_upper_left", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
public static final RegistryObject<Item> VAULT_FRAG_L = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_left", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
||||||
public static final RegistryObject<Item> VAULT_FRAG_U = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_upper", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
public static final RegistryObject<Item> VAULT_FRAG_R = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_right", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
||||||
public static final RegistryObject<Item> VAULT_FRAG_C = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_center", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
public static final RegistryObject<Item> VAULT_FRAG_UR = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_upper_right", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
||||||
|
public static final RegistryObject<Item> VAULT_FRAG_UL = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_upper_left", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
||||||
|
public static final RegistryObject<Item> VAULT_FRAG_U = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_upper", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
||||||
public static final RegistryObject<Item> VAULT = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault", () -> new VaultItem(new Item.Properties().stacksTo(64))));
|
public static final RegistryObject<Item> VAULT_FRAG_C = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_center", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
||||||
|
|
||||||
public static final RegistryObject<Item> VAULT_RAW_ORE = CreativeModeTabs.addToOTEModTab(ITEMS.register("raw_vault_steel_ore", () -> new Item(new Item.Properties().stacksTo(64))));
|
|
||||||
|
public static final RegistryObject<Item> VAULT = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault", () -> new VaultItem(new Item.Properties().stacksTo(64))));
|
||||||
public static final RegistryObject<Item> POSS_BALL = CreativeModeTabs.addToOTEModTab(ITEMS.register("poss_ball", () -> new PossBallItem(new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> VAULT_RAW_ORE = CreativeModeTabs.addToOTEModTab(ITEMS.register("raw_vault_steel_ore", () -> new Item(new Item.Properties().stacksTo(64))));
|
||||||
public static final RegistryObject<Item> ILUSIUM_ORE = CreativeModeTabs.addToOTEModTab(ITEMS.register("ilusium_ore", () -> new Item(new Item.Properties().fireResistant())));
|
|
||||||
public static final RegistryObject<Item> ILUSIUM_ROD = CreativeModeTabs.addToOTEModTab(ITEMS.register("ilusium_rod", () -> new Item(new Item.Properties().fireResistant())));
|
public static final RegistryObject<Item> POSS_BALL = CreativeModeTabs.addToOTEModTab(ITEMS.register("poss_ball", () -> new PossBallItem(new Item.Properties())));
|
||||||
|
|
||||||
//public static final RegistryObject<Item> ILUSIUM_DUST = CreativeModeTabs.addToOTEModTab(ITEMS.register("ilusium_dust", () -> new Item(new Item.Properties().fireResistant())));
|
public static final RegistryObject<Item> ILUSIUM_ORE = CreativeModeTabs.addToOTEModTab(ITEMS.register("ilusium_ore", () -> new Item(new Item.Properties().fireResistant())));
|
||||||
|
public static final RegistryObject<Item> ILUSIUM_ROD = CreativeModeTabs.addToOTEModTab(ITEMS.register("ilusium_rod", () -> new Item(new Item.Properties().fireResistant())));
|
||||||
public static final RegistryObject<Item> ILUSIUM_INGOT = CreativeModeTabs.addToOTEModTab(ITEMS.register("ilusium_ingot", () -> new Item(new Item.Properties().fireResistant())));
|
|
||||||
|
//public static final RegistryObject<Item> ILUSIUM_DUST = CreativeModeTabs.addToOTEModTab(ITEMS.register("ilusium_dust", () -> new Item(new Item.Properties().fireResistant())));
|
||||||
public static final RegistryObject<Item> EMPTY_SPAWN_EGG = CreativeModeTabs.addToOTEModTab(ITEMS.register("empty_spawn_egg", () -> new Item(new Item.Properties())));
|
|
||||||
|
public static final RegistryObject<Item> ILUSIUM_INGOT = CreativeModeTabs.addToOTEModTab(ITEMS.register("ilusium_ingot", () -> new Item(new Item.Properties().fireResistant())));
|
||||||
|
|
||||||
//public static final RegistryObject<Item> POSSUM_SPAWN_EGG = ITEMS.register("possum_spawn_egg", () -> new ForgeSpawnEggItem(ModEntityTypes.POSSUM, 0x938686, 0xc68787, new Item.Properties())));
|
public static final RegistryObject<Item> EMPTY_SPAWN_EGG = CreativeModeTabs.addToOTEModTab(ITEMS.register("empty_spawn_egg", () -> new Item(new Item.Properties())));
|
||||||
|
|
||||||
|
|
||||||
|
//public static final RegistryObject<Item> POSSUM_SPAWN_EGG = ITEMS.register("possum_spawn_egg", () -> new ForgeSpawnEggItem(ModEntityTypes.POSSUM, 0x938686, 0xc68787, new Item.Properties())));
|
||||||
public static void register(IEventBus bus){
|
|
||||||
ITEMS.register(bus);
|
|
||||||
}
|
|
||||||
|
public static void register(IEventBus bus){
|
||||||
}
|
ITEMS.register(bus);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package dev.zontreck.thresholds.items;
|
package dev.zontreck.otemod.items;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
|
@ -6,7 +6,10 @@ import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.stats.Stats;
|
import net.minecraft.stats.Stats;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResultHolder;
|
import net.minecraft.world.InteractionResultHolder;
|
||||||
|
import net.minecraft.world.entity.monster.Guardian;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.entity.projectile.Arrow;
|
||||||
|
import net.minecraft.world.item.EggItem;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
|
@ -1,11 +1,16 @@
|
||||||
package dev.zontreck.thresholds.items;
|
package dev.zontreck.otemod.items;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
|
import dev.zontreck.libzontreck.lore.ExtraLore;
|
||||||
import dev.zontreck.libzontreck.lore.LoreContainer;
|
import dev.zontreck.libzontreck.lore.LoreContainer;
|
||||||
import dev.zontreck.libzontreck.lore.LoreEntry;
|
import dev.zontreck.libzontreck.lore.LoreEntry;
|
||||||
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import net.minecraft.core.particles.ItemParticleOption;
|
import net.minecraft.core.particles.ItemParticleOption;
|
||||||
import net.minecraft.core.particles.ParticleTypes;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.nbt.NbtUtils;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
@ -15,6 +20,7 @@ import net.minecraft.world.entity.projectile.ThrowableItemProjectile;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.block.DropperBlock;
|
||||||
import net.minecraft.world.phys.EntityHitResult;
|
import net.minecraft.world.phys.EntityHitResult;
|
||||||
import net.minecraft.world.phys.HitResult;
|
import net.minecraft.world.phys.HitResult;
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
package dev.zontreck.thresholds.items;
|
package dev.zontreck.otemod.items;
|
||||||
|
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.item.SimpleFoiledItem;
|
import net.minecraft.world.item.SimpleFoiledItem;
|
||||||
import net.minecraft.world.item.context.UseOnContext;
|
import net.minecraft.world.item.context.UseOnContext;
|
||||||
|
import net.minecraft.world.level.Explosion;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||||
|
|
||||||
public class UnstableSingularity extends SimpleFoiledItem
|
public class UnstableSingularity extends SimpleFoiledItem
|
||||||
{
|
{
|
|
@ -1,17 +1,22 @@
|
||||||
package dev.zontreck.thresholds.items;
|
package dev.zontreck.otemod.items;
|
||||||
|
|
||||||
|
|
||||||
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
import dev.zontreck.libzontreck.profiles.Profile;
|
import dev.zontreck.libzontreck.profiles.Profile;
|
||||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import dev.zontreck.thresholds.ThresholdsMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.thresholds.configs.ThresholdsServerConfig;
|
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||||
|
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||||
|
import dev.zontreck.otemod.events.LoreHandlers;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResultHolder;
|
import net.minecraft.world.InteractionResultHolder;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
|
import net.minecraft.world.item.SimpleFoiledItem;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
|
||||||
public class VaultItem extends Item
|
public class VaultItem extends Item
|
||||||
|
@ -37,7 +42,7 @@ public class VaultItem extends Item
|
||||||
@Override
|
@Override
|
||||||
public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pUsedHand)
|
public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pUsedHand)
|
||||||
{
|
{
|
||||||
ThresholdsMod.LOGGER.info("Vault item is being used");
|
OTEMod.LOGGER.info("Vault item is being used");
|
||||||
if(!pLevel.isClientSide && pUsedHand == InteractionHand.MAIN_HAND)
|
if(!pLevel.isClientSide && pUsedHand == InteractionHand.MAIN_HAND)
|
||||||
{
|
{
|
||||||
ItemStack is = pPlayer.getItemInHand(pUsedHand);
|
ItemStack is = pPlayer.getItemInHand(pUsedHand);
|
||||||
|
@ -45,16 +50,16 @@ public class VaultItem extends Item
|
||||||
Profile p;
|
Profile p;
|
||||||
try {
|
try {
|
||||||
p = Profile.get_profile_of(pPlayer.getStringUUID());
|
p = Profile.get_profile_of(pPlayer.getStringUUID());
|
||||||
if(ThresholdsServerConfig.MAX_VAULTS.get()>0)
|
if(OTEServerConfig.MAX_VAULTS.get()>0)
|
||||||
{
|
{
|
||||||
if(p.available_vaults >= ThresholdsServerConfig.MAX_VAULTS.get())
|
if(p.available_vaults >= OTEServerConfig.MAX_VAULTS.get())
|
||||||
{
|
{
|
||||||
ChatHelpers.broadcastTo(pPlayer.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Red!You cannot activate anymore vaults due to the maximum set by the server admin"), ThresholdsMod.THE_SERVER);
|
ChatHelpers.broadcastTo(pPlayer.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Red!You cannot activate anymore vaults due to the maximum set by the server admin"), OTEMod.THE_SERVER);
|
||||||
return InteractionResultHolder.pass(is);
|
return InteractionResultHolder.pass(is);
|
||||||
} else {
|
} else {
|
||||||
p.available_vaults++;
|
p.available_vaults++;
|
||||||
p.commit();
|
p.commit();
|
||||||
ChatHelpers.broadcastTo(pPlayer.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Green!You now have "+String.valueOf(p.available_vaults)+" available vaults"), ThresholdsMod.THE_SERVER);
|
ChatHelpers.broadcastTo(pPlayer.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Green!You now have "+String.valueOf(p.available_vaults)+" available vaults"), OTEMod.THE_SERVER);
|
||||||
pPlayer.setItemInHand(pUsedHand, new ItemStack(Items.AIR));
|
pPlayer.setItemInHand(pUsedHand, new ItemStack(Items.AIR));
|
||||||
|
|
||||||
return InteractionResultHolder.consume(is);
|
return InteractionResultHolder.consume(is);
|
||||||
|
@ -62,7 +67,7 @@ public class VaultItem extends Item
|
||||||
}else {
|
}else {
|
||||||
p.available_vaults++;
|
p.available_vaults++;
|
||||||
p.commit();
|
p.commit();
|
||||||
ChatHelpers.broadcastTo(pPlayer.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Green!You now have "+String.valueOf(p.available_vaults)+" available vaults"), ThresholdsMod.THE_SERVER);
|
ChatHelpers.broadcastTo(pPlayer.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Green!You now have "+String.valueOf(p.available_vaults)+" available vaults"), OTEMod.THE_SERVER);
|
||||||
pPlayer.setItemInHand(pUsedHand, new ItemStack(Items.AIR));
|
pPlayer.setItemInHand(pUsedHand, new ItemStack(Items.AIR));
|
||||||
|
|
||||||
return InteractionResultHolder.consume(is);
|
return InteractionResultHolder.consume(is);
|
|
@ -1,28 +1,28 @@
|
||||||
package dev.zontreck.thresholds.items.tags;
|
package dev.zontreck.otemod.items.tags;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
|
||||||
public class ItemStatTag {
|
public class ItemStatTag {
|
||||||
public static final String STATS_TAG = "stat";
|
public static final String STATS_TAG = "stat";
|
||||||
public ItemStatType type;
|
public ItemStatType type;
|
||||||
public int value;
|
public int value;
|
||||||
|
|
||||||
public ItemStatTag(ItemStatType t, int tag)
|
public ItemStatTag(ItemStatType t, int tag)
|
||||||
{
|
{
|
||||||
type = t;
|
type = t;
|
||||||
value = tag;
|
value = tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void increment(){
|
public void increment(){
|
||||||
value++;
|
value++;
|
||||||
}
|
}
|
||||||
public void decrement()
|
public void decrement()
|
||||||
{
|
{
|
||||||
value--;
|
value--;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(CompoundTag tag)
|
public void save(CompoundTag tag)
|
||||||
{
|
{
|
||||||
tag.putInt(STATS_TAG+"_"+type.name().toLowerCase(), value);
|
tag.putInt(STATS_TAG+"_"+type.name().toLowerCase(), value);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,13 +1,13 @@
|
||||||
package dev.zontreck.thresholds.items.tags;
|
package dev.zontreck.otemod.items.tags;
|
||||||
|
|
||||||
public enum ItemStatType {
|
public enum ItemStatType {
|
||||||
SWORD,
|
SWORD,
|
||||||
ARMOR,
|
ARMOR,
|
||||||
PICK,
|
PICK,
|
||||||
AXE,
|
AXE,
|
||||||
SHOVEL,
|
SHOVEL,
|
||||||
SHOVELPATH,
|
SHOVELPATH,
|
||||||
HOE,
|
HOE,
|
||||||
SHEARS,
|
SHEARS,
|
||||||
EGGING
|
EGGING
|
||||||
}
|
}
|
|
@ -1,47 +1,47 @@
|
||||||
package dev.zontreck.thresholds.items.tags;
|
package dev.zontreck.otemod.items.tags;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
|
|
||||||
public class ItemStatistics {
|
public class ItemStatistics {
|
||||||
|
|
||||||
public static String makeText(ItemStatTag tag)
|
public static String makeText(ItemStatTag tag)
|
||||||
{
|
{
|
||||||
return makeText(tag.type, tag.value);
|
return makeText(tag.type, tag.value);
|
||||||
}
|
}
|
||||||
public static String makeText(ItemStatType type, int val)
|
public static String makeText(ItemStatType type, int val)
|
||||||
{
|
{
|
||||||
String lore = ChatColor.doColors("!White!");
|
String lore = ChatColor.doColors("!White!");
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case SWORD -> {
|
case SWORD -> {
|
||||||
lore += "Mobs Killed: ";
|
lore += "Mobs Killed: ";
|
||||||
}
|
}
|
||||||
case PICK -> {
|
case PICK -> {
|
||||||
lore += "Blocks Mined: ";
|
lore += "Blocks Mined: ";
|
||||||
}
|
}
|
||||||
case ARMOR -> {
|
case ARMOR -> {
|
||||||
lore += "Damage Taken: ";
|
lore += "Damage Taken: ";
|
||||||
}
|
}
|
||||||
case SHOVEL -> {
|
case SHOVEL -> {
|
||||||
lore += "Blocks Dug Up: ";
|
lore += "Blocks Dug Up: ";
|
||||||
}
|
}
|
||||||
case SHOVELPATH -> {
|
case SHOVELPATH -> {
|
||||||
lore += "Paths Made: ";
|
lore += "Paths Made: ";
|
||||||
}
|
}
|
||||||
case AXE -> {
|
case AXE -> {
|
||||||
lore += "Wood Chopped: ";
|
lore += "Wood Chopped: ";
|
||||||
}
|
}
|
||||||
case HOE -> {
|
case HOE -> {
|
||||||
lore += "Blocks Hoed: ";
|
lore += "Blocks Hoed: ";
|
||||||
}
|
}
|
||||||
case SHEARS -> {
|
case SHEARS -> {
|
||||||
lore += "Sheep Shaved: ";
|
lore += "Sheep Shaved: ";
|
||||||
}
|
}
|
||||||
case EGGING -> {
|
case EGGING -> {
|
||||||
lore += "Mobs Egged: ";
|
lore += "Mobs Egged: ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lore += ChatColor.doColors("!Green!"+val);
|
lore += ChatColor.doColors("!Green!"+val);
|
||||||
return lore;
|
return lore;
|
||||||
}
|
}
|
||||||
}
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue