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
|
||||
Arias-Essentials
|
||||
Thresholds
|
||||
OTEMod
|
||||
ClaimsMod
|
||||
WatchMyDurability
|
||||
```
|
||||
|
@ -20,7 +20,7 @@ Code Contributions
|
|||
|
||||
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
|
||||
----
|
||||
|
|
|
@ -4,4 +4,4 @@ Liquids
|
|||
|
||||
|
||||
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.
|
||||
mod_license=GPLv3
|
||||
# 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.
|
||||
# This should match the base package used for the mod sources.
|
||||
# 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.
|
||||
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.
|
||||
mod_description=Thresholds Mod
|
||||
mod_description=Only The Essentials
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"pack": {
|
||||
"description": {
|
||||
"text": "Thresholds Server Resource Pack"
|
||||
"text": "OTEMod Server Resource Pack"
|
||||
},
|
||||
"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 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.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.thresholds.effects.ModEffects;
|
||||
import dev.zontreck.thresholds.implementation.CreativeModeTabs;
|
||||
import dev.zontreck.thresholds.implementation.InventoryBackup;
|
||||
import dev.zontreck.thresholds.implementation.Messages;
|
||||
import dev.zontreck.thresholds.implementation.PlayerFirstJoinTag;
|
||||
import dev.zontreck.thresholds.implementation.compressor.CompressionChamberScreen;
|
||||
import dev.zontreck.thresholds.implementation.vault.*;
|
||||
import dev.zontreck.thresholds.integrations.KeyBindings;
|
||||
import dev.zontreck.thresholds.recipe.ModRecipes;
|
||||
import dev.zontreck.otemod.effects.ModEffects;
|
||||
import dev.zontreck.otemod.implementation.CreativeModeTabs;
|
||||
import dev.zontreck.otemod.implementation.InventoryBackup;
|
||||
import dev.zontreck.otemod.implementation.Messages;
|
||||
import dev.zontreck.otemod.implementation.PlayerFirstJoinTag;
|
||||
import dev.zontreck.otemod.implementation.compressor.CompressionChamberScreen;
|
||||
import dev.zontreck.otemod.implementation.vault.*;
|
||||
import dev.zontreck.otemod.integrations.KeyBindings;
|
||||
import dev.zontreck.otemod.recipe.ModRecipes;
|
||||
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.server.MinecraftServer;
|
||||
import net.minecraft.server.commands.GiveCommand;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
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.Items;
|
||||
import net.minecraft.world.level.GameType;
|
||||
|
@ -43,31 +57,32 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
|||
import net.minecraftforge.items.ItemStackHandler;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import dev.zontreck.thresholds.blocks.ModBlocks;
|
||||
import dev.zontreck.thresholds.blocks.entity.ModEntities;
|
||||
import dev.zontreck.thresholds.chat.ChatServerOverride;
|
||||
import dev.zontreck.thresholds.commands.CommandRegistry;
|
||||
import dev.zontreck.thresholds.configs.ThresholdsServerConfig;
|
||||
import dev.zontreck.thresholds.enchantments.ModEnchantments;
|
||||
import dev.zontreck.thresholds.entities.ModEntityTypes;
|
||||
import dev.zontreck.thresholds.events.LoreHandlers;
|
||||
import dev.zontreck.thresholds.implementation.inits.ModMenuTypes;
|
||||
import dev.zontreck.thresholds.implementation.scrubber.ItemScrubberScreen;
|
||||
import dev.zontreck.thresholds.implementation.scrubber.MagicalScrubberScreen;
|
||||
import dev.zontreck.thresholds.items.ModItems;
|
||||
import dev.zontreck.otemod.blocks.ModBlocks;
|
||||
import dev.zontreck.otemod.blocks.entity.ModEntities;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import dev.zontreck.otemod.commands.CommandRegistry;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import dev.zontreck.otemod.enchantments.ModEnchantments;
|
||||
import dev.zontreck.otemod.entities.ModEntityTypes;
|
||||
import dev.zontreck.otemod.entities.monsters.client.PossumRenderer;
|
||||
import dev.zontreck.otemod.events.LoreHandlers;
|
||||
import dev.zontreck.otemod.implementation.inits.ModMenuTypes;
|
||||
import dev.zontreck.otemod.implementation.scrubber.ItemScrubberScreen;
|
||||
import dev.zontreck.otemod.implementation.scrubber.MagicalScrubberScreen;
|
||||
import dev.zontreck.otemod.items.ModItems;
|
||||
//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
|
||||
@Mod(ThresholdsMod.MOD_ID)
|
||||
public class ThresholdsMod
|
||||
@Mod(OTEMod.MOD_ID)
|
||||
public class OTEMod
|
||||
{
|
||||
public static final Vector3 ZERO_VECTOR = new Vector3(0,0,0);
|
||||
// Directly reference a slf4j logger
|
||||
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 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 MinecraftServer THE_SERVER;
|
||||
|
@ -78,23 +93,23 @@ public class ThresholdsMod
|
|||
public static boolean DEVELOPER=false;
|
||||
private static Thread MasterThread;
|
||||
|
||||
public static String ThresholdsPrefix = "";
|
||||
public static String OTEPrefix = "";
|
||||
public static String ONLY_PLAYER = "";
|
||||
public static IEventBus bus;
|
||||
|
||||
|
||||
public ThresholdsMod()
|
||||
public OTEMod()
|
||||
{
|
||||
|
||||
ThresholdsMod.ThresholdsPrefix = ChatColor.doColors("!dark_gray![!dark_green!!bold!Thresholds!reset!!dark_gray!]!reset!");
|
||||
ThresholdsMod.ONLY_PLAYER = ChatColor.doColors("!dark_red!Only a player can execute this command");
|
||||
OTEMod.OTEPrefix = ChatColor.doColors("!dark_gray![!dark_green!!bold!OTEMod!reset!!dark_gray!]!reset!");
|
||||
OTEMod.ONLY_PLAYER = ChatColor.doColors("!dark_red!Only a player can execute this command");
|
||||
|
||||
bus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
// Register the setup method for modloading
|
||||
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 CommandRegistry());
|
||||
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);
|
||||
|
||||
ModBlocks.register(bus);
|
||||
|
@ -173,7 +188,7 @@ public class ThresholdsMod
|
|||
}else {
|
||||
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.save(prof.NBT);
|
||||
|
@ -208,24 +223,24 @@ public class ThresholdsMod
|
|||
public void onServerStarting(ServerStartedEvent event)
|
||||
{
|
||||
// Changed away from Starting event due to multiple calls
|
||||
if(ThresholdsMod.ALIVE){
|
||||
if(OTEMod.ALIVE){
|
||||
// We were called again?
|
||||
// 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;
|
||||
}
|
||||
// Do something when the server starts
|
||||
//LOGGER.info("HELLO from server starting");
|
||||
|
||||
ThresholdsMod.ALIVE=true;
|
||||
OTEMod.ALIVE=true;
|
||||
//HealerQueue.Initialize(); // Set up the queue
|
||||
|
||||
// Set up the repeating task to expire a TeleportContainer
|
||||
ThresholdsMod.THE_SERVER = event.getServer();
|
||||
ThresholdsMod.MasterThread = new Thread(new Runnable(){
|
||||
OTEMod.THE_SERVER = event.getServer();
|
||||
OTEMod.MasterThread = new Thread(new Runnable(){
|
||||
public void run()
|
||||
{
|
||||
while(ThresholdsMod.ALIVE){
|
||||
while(OTEMod.ALIVE){
|
||||
// Check if the teleports have expired
|
||||
try {
|
||||
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(ThresholdsServerConfig.ITEM_DESPAWN_TIMER.get()<=0)return;
|
||||
if(OTEServerConfig.ITEM_DESPAWN_TIMER.get()<=0)return;
|
||||
|
||||
ItemEntity ite = (ItemEntity)ev.getEntity();
|
||||
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()+ " ]");
|
||||
// 1200 ticks per minute
|
||||
// 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");
|
||||
// Hopefully this works?
|
||||
ev.setCanceled(true);
|
||||
|
@ -281,14 +296,14 @@ public class ThresholdsMod
|
|||
@SubscribeEvent
|
||||
public void onStop(final ServerStoppingEvent ev)
|
||||
{
|
||||
ThresholdsMod.ALIVE=false; // Tear down all looping threads that will watch this
|
||||
ThresholdsMod.MasterThread.interrupt();
|
||||
OTEMod.ALIVE=false; // Tear down all looping threads that will watch this
|
||||
OTEMod.MasterThread.interrupt();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 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
|
||||
{
|
||||
@SubscribeEvent
|
|
@ -1,23 +1,24 @@
|
|||
package dev.zontreck.thresholds.blocks;
|
||||
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.DoorBlock;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.properties.BlockSetType;
|
||||
|
||||
public class AuroraDoorBlock extends DoorBlock
|
||||
{
|
||||
public static final BlockBehaviour.Properties DOOR_PROPS;
|
||||
static
|
||||
{
|
||||
DOOR_PROPS = BlockBehaviour.Properties.copy(Blocks.IRON_DOOR).requiresCorrectToolForDrops().strength(10, 100000f).sound(SoundType.NETHERITE_BLOCK);
|
||||
}
|
||||
|
||||
public AuroraDoorBlock() {
|
||||
super(DOOR_PROPS, BlockSetType.IRON);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
package dev.zontreck.otemod.blocks;
|
||||
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.DoorBlock;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.properties.BlockSetType;
|
||||
|
||||
public class AuroraDoorBlock extends DoorBlock
|
||||
{
|
||||
public static final BlockBehaviour.Properties DOOR_PROPS;
|
||||
static
|
||||
{
|
||||
DOOR_PROPS = BlockBehaviour.Properties.copy(Blocks.IRON_DOOR).requiresCorrectToolForDrops().strength(10, 100000f).sound(SoundType.NETHERITE_BLOCK);
|
||||
}
|
||||
|
||||
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.thresholds.blocks.entity.ModEntities;
|
||||
import dev.zontreck.thresholds.networking.ModMessages;
|
||||
import dev.zontreck.thresholds.networking.packets.EnergySyncS2CPacket;
|
||||
import dev.zontreck.otemod.blocks.entity.CompressionChamberBlockEntity;
|
||||
import dev.zontreck.otemod.blocks.entity.ModEntities;
|
||||
import dev.zontreck.otemod.networking.ModMessages;
|
||||
import dev.zontreck.otemod.networking.packets.EnergySyncS2CPacket;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
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.ItemStack;
|
|
@ -1,101 +1,102 @@
|
|||
package dev.zontreck.thresholds.blocks;
|
||||
|
||||
import dev.zontreck.thresholds.blocks.entity.ItemScrubberBlockEntity;
|
||||
import dev.zontreck.thresholds.blocks.entity.ModEntities;
|
||||
import dev.zontreck.thresholds.networking.ModMessages;
|
||||
import dev.zontreck.thresholds.networking.packets.EnergySyncS2CPacket;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ItemScrubberBlock extends HorizontalDirectionalBlock implements EntityBlock
|
||||
{
|
||||
|
||||
public ItemScrubberBlock(Properties p_54120_) {
|
||||
super(p_54120_);
|
||||
//registerDefaultState(defaultBlockState().setValue(FACING, Direction.NORTH));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) {
|
||||
super.createBlockStateDefinition(pBuilder);
|
||||
pBuilder.add(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderShape getRenderShape(BlockState state)
|
||||
{
|
||||
return RenderShape.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level lvl, BlockPos pos, BlockState newState, boolean isMoving)
|
||||
{
|
||||
if(state.getBlock()!=newState.getBlock())
|
||||
{
|
||||
BlockEntity bE = lvl.getBlockEntity(pos);
|
||||
if(bE instanceof ItemScrubberBlockEntity)
|
||||
{
|
||||
((ItemScrubberBlockEntity)bE).doDrop();
|
||||
}
|
||||
}
|
||||
|
||||
super.onRemove(state, lvl, pos, newState, isMoving);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level lvl, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit)
|
||||
{
|
||||
if(!lvl.isClientSide())
|
||||
{
|
||||
BlockEntity be = lvl.getBlockEntity(pos);
|
||||
if(be instanceof ItemScrubberBlockEntity)
|
||||
{
|
||||
ItemScrubberBlockEntity entity = (ItemScrubberBlockEntity)be;
|
||||
NetworkHooks.openScreen(((ServerPlayer)player), entity, pos);
|
||||
|
||||
ModMessages.sendToPlayer(new EnergySyncS2CPacket(entity.getEnergyStorage().getEnergyStored(), entity.getBlockPos()), (ServerPlayer)player);
|
||||
|
||||
}else{
|
||||
throw new IllegalStateException("Our container is missing!");
|
||||
}
|
||||
}
|
||||
|
||||
return InteractionResult.sidedSuccess(lvl.isClientSide);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext pContext) {
|
||||
return defaultBlockState().setValue(FACING, pContext.getHorizontalDirection().getOpposite());
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.blocks;
|
||||
|
||||
import dev.zontreck.otemod.blocks.entity.ItemScrubberBlockEntity;
|
||||
import dev.zontreck.otemod.blocks.entity.ModEntities;
|
||||
import dev.zontreck.otemod.networking.ModMessages;
|
||||
import dev.zontreck.otemod.networking.packets.EnergySyncS2CPacket;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ItemScrubberBlock extends HorizontalDirectionalBlock implements EntityBlock
|
||||
{
|
||||
|
||||
public ItemScrubberBlock(Properties p_54120_) {
|
||||
super(p_54120_);
|
||||
//registerDefaultState(defaultBlockState().setValue(FACING, Direction.NORTH));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) {
|
||||
super.createBlockStateDefinition(pBuilder);
|
||||
pBuilder.add(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderShape getRenderShape(BlockState state)
|
||||
{
|
||||
return RenderShape.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level lvl, BlockPos pos, BlockState newState, boolean isMoving)
|
||||
{
|
||||
if(state.getBlock()!=newState.getBlock())
|
||||
{
|
||||
BlockEntity bE = lvl.getBlockEntity(pos);
|
||||
if(bE instanceof ItemScrubberBlockEntity)
|
||||
{
|
||||
((ItemScrubberBlockEntity)bE).doDrop();
|
||||
}
|
||||
}
|
||||
|
||||
super.onRemove(state, lvl, pos, newState, isMoving);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level lvl, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit)
|
||||
{
|
||||
if(!lvl.isClientSide())
|
||||
{
|
||||
BlockEntity be = lvl.getBlockEntity(pos);
|
||||
if(be instanceof ItemScrubberBlockEntity)
|
||||
{
|
||||
ItemScrubberBlockEntity entity = (ItemScrubberBlockEntity)be;
|
||||
NetworkHooks.openScreen(((ServerPlayer)player), entity, pos);
|
||||
|
||||
ModMessages.sendToPlayer(new EnergySyncS2CPacket(entity.getEnergyStorage().getEnergyStored(), entity.getBlockPos()), (ServerPlayer)player);
|
||||
|
||||
}else{
|
||||
throw new IllegalStateException("Our container is missing!");
|
||||
}
|
||||
}
|
||||
|
||||
return InteractionResult.sidedSuccess(lvl.isClientSide);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext pContext) {
|
||||
return defaultBlockState().setValue(FACING, pContext.getHorizontalDirection().getOpposite());
|
||||
}
|
||||
}
|
|
@ -1,102 +1,102 @@
|
|||
package dev.zontreck.thresholds.blocks;
|
||||
|
||||
import dev.zontreck.thresholds.blocks.entity.MagicalScrubberBlockEntity;
|
||||
import dev.zontreck.thresholds.blocks.entity.ModEntities;
|
||||
import dev.zontreck.thresholds.networking.ModMessages;
|
||||
import dev.zontreck.thresholds.networking.packets.EnergySyncS2CPacket;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class MagicalScrubberBlock extends HorizontalDirectionalBlock implements EntityBlock
|
||||
{
|
||||
|
||||
public MagicalScrubberBlock(Properties p_54120_) {
|
||||
super(p_54120_);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) {
|
||||
super.createBlockStateDefinition(pBuilder);
|
||||
pBuilder.add(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderShape getRenderShape(BlockState state)
|
||||
{
|
||||
return RenderShape.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level lvl, BlockPos pos, BlockState newState, boolean isMoving)
|
||||
{
|
||||
if(state.getBlock()!=newState.getBlock())
|
||||
{
|
||||
BlockEntity bE = lvl.getBlockEntity(pos);
|
||||
if(bE instanceof MagicalScrubberBlockEntity)
|
||||
{
|
||||
((MagicalScrubberBlockEntity)bE).doDrop();
|
||||
}
|
||||
}
|
||||
|
||||
super.onRemove(state, lvl, pos, newState, isMoving);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level lvl, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit)
|
||||
{
|
||||
if(!lvl.isClientSide())
|
||||
{
|
||||
BlockEntity be = lvl.getBlockEntity(pos);
|
||||
if(be instanceof MagicalScrubberBlockEntity)
|
||||
{
|
||||
MagicalScrubberBlockEntity entity = (MagicalScrubberBlockEntity)be;
|
||||
NetworkHooks.openScreen(((ServerPlayer)player), entity, pos);
|
||||
|
||||
ModMessages.sendToPlayer(new EnergySyncS2CPacket(entity.getEnergyStorage().getEnergyStored(), entity.getBlockPos()), (ServerPlayer)player);
|
||||
}else{
|
||||
throw new IllegalStateException("Our container is missing!");
|
||||
}
|
||||
}
|
||||
|
||||
return InteractionResult.sidedSuccess(lvl.isClientSide);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||
return new MagicalScrubberBlockEntity(pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level lvl, BlockState state, BlockEntityType<T> type)
|
||||
{
|
||||
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) {
|
||||
return pClientType == pServerType ? (BlockEntityTicker<A>) pTicker : null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext pContext) {
|
||||
return defaultBlockState().setValue(FACING, pContext.getHorizontalDirection().getOpposite());
|
||||
}
|
||||
|
||||
}
|
||||
package dev.zontreck.otemod.blocks;
|
||||
|
||||
import dev.zontreck.otemod.blocks.entity.MagicalScrubberBlockEntity;
|
||||
import dev.zontreck.otemod.blocks.entity.ModEntities;
|
||||
import dev.zontreck.otemod.networking.ModMessages;
|
||||
import dev.zontreck.otemod.networking.packets.EnergySyncS2CPacket;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class MagicalScrubberBlock extends HorizontalDirectionalBlock implements EntityBlock
|
||||
{
|
||||
|
||||
public MagicalScrubberBlock(Properties p_54120_) {
|
||||
super(p_54120_);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) {
|
||||
super.createBlockStateDefinition(pBuilder);
|
||||
pBuilder.add(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderShape getRenderShape(BlockState state)
|
||||
{
|
||||
return RenderShape.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level lvl, BlockPos pos, BlockState newState, boolean isMoving)
|
||||
{
|
||||
if(state.getBlock()!=newState.getBlock())
|
||||
{
|
||||
BlockEntity bE = lvl.getBlockEntity(pos);
|
||||
if(bE instanceof MagicalScrubberBlockEntity)
|
||||
{
|
||||
((MagicalScrubberBlockEntity)bE).doDrop();
|
||||
}
|
||||
}
|
||||
|
||||
super.onRemove(state, lvl, pos, newState, isMoving);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level lvl, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit)
|
||||
{
|
||||
if(!lvl.isClientSide())
|
||||
{
|
||||
BlockEntity be = lvl.getBlockEntity(pos);
|
||||
if(be instanceof MagicalScrubberBlockEntity)
|
||||
{
|
||||
MagicalScrubberBlockEntity entity = (MagicalScrubberBlockEntity)be;
|
||||
NetworkHooks.openScreen(((ServerPlayer)player), entity, pos);
|
||||
|
||||
ModMessages.sendToPlayer(new EnergySyncS2CPacket(entity.getEnergyStorage().getEnergyStored(), entity.getBlockPos()), (ServerPlayer)player);
|
||||
}else{
|
||||
throw new IllegalStateException("Our container is missing!");
|
||||
}
|
||||
}
|
||||
|
||||
return InteractionResult.sidedSuccess(lvl.isClientSide);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||
return new MagicalScrubberBlockEntity(pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level lvl, BlockState state, BlockEntityType<T> type)
|
||||
{
|
||||
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) {
|
||||
return pClientType == pServerType ? (BlockEntityTicker<A>) pTicker : null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext pContext) {
|
||||
return defaultBlockState().setValue(FACING, pContext.getHorizontalDirection().getOpposite());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,146 +1,147 @@
|
|||
package dev.zontreck.thresholds.blocks;
|
||||
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.implementation.CreativeModeTabs;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
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 static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ThresholdsMod.MOD_ID);
|
||||
|
||||
public static void register(IEventBus bus){
|
||||
BLOCKS.register(bus);
|
||||
ITEMS.register(bus);
|
||||
ThresholdsMod.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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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 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_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;
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.blocks;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.CreativeModeTabs;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.FlintAndSteelItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class ModBlocks {
|
||||
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);
|
||||
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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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<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 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_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;
|
||||
}
|
||||
}
|
|
@ -1,10 +1,12 @@
|
|||
package dev.zontreck.thresholds.blocks;
|
||||
package dev.zontreck.otemod.blocks;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
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;
|
||||
|
||||
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.thresholds.implementation.compressor.CompressionChamberMenu;
|
||||
import dev.zontreck.thresholds.implementation.energy.OTEEnergy;
|
||||
import dev.zontreck.thresholds.networking.ModMessages;
|
||||
import dev.zontreck.thresholds.networking.packets.EnergySyncS2CPacket;
|
||||
import dev.zontreck.thresholds.recipe.CompressionChamberRecipe;
|
||||
import dev.zontreck.otemod.implementation.OutputItemStackHandler;
|
||||
import dev.zontreck.otemod.implementation.compressor.CompressionChamberMenu;
|
||||
import dev.zontreck.otemod.implementation.energy.OTEEnergy;
|
||||
import dev.zontreck.otemod.networking.ModMessages;
|
||||
import dev.zontreck.otemod.networking.packets.EnergySyncS2CPacket;
|
||||
import dev.zontreck.otemod.recipe.CompressionChamberRecipe;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
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.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.ContainerData;
|
||||
import net.minecraft.world.inventory.SimpleContainerData;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.Level;
|
||||
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.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.energy.EnergyStorage;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
|
@ -1,292 +1,292 @@
|
|||
package dev.zontreck.thresholds.blocks.entity;
|
||||
|
||||
import dev.zontreck.thresholds.implementation.OutputItemStackHandler;
|
||||
import dev.zontreck.thresholds.implementation.energy.OTEEnergy;
|
||||
import dev.zontreck.thresholds.implementation.scrubber.ItemScrubberMenu;
|
||||
import dev.zontreck.thresholds.networking.ModMessages;
|
||||
import dev.zontreck.thresholds.networking.packets.EnergySyncS2CPacket;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.Containers;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.ContainerData;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ItemScrubberBlockEntity extends BlockEntity implements MenuProvider
|
||||
{
|
||||
|
||||
protected final ItemStackHandler itemsHandler = new ItemStackHandler(1){
|
||||
@Override
|
||||
protected void onContentsChanged(int slot)
|
||||
{
|
||||
setChanged();
|
||||
}
|
||||
};
|
||||
protected final ItemStackHandler outputItems = new ItemStackHandler(1){
|
||||
@Override
|
||||
protected void onContentsChanged(int slot)
|
||||
{
|
||||
setChanged();
|
||||
}
|
||||
};
|
||||
private ItemStackHandler outputSlot;
|
||||
|
||||
private final OTEEnergy ENERGY_STORAGE = new OTEEnergy(ENERGY_REQ*3, ENERGY_REQ+512) {
|
||||
|
||||
@Override
|
||||
public void onChanged() {
|
||||
setChanged();
|
||||
|
||||
ModMessages.sendToAll(new EnergySyncS2CPacket(energy, getBlockPos()));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private static final int ENERGY_REQ = 1500;
|
||||
private LazyOptional<IEnergyStorage> lazyEnergyHandler = LazyOptional.empty();
|
||||
|
||||
private LazyOptional<IItemHandler> lazyItemHandler = LazyOptional.empty();
|
||||
private LazyOptional<IItemHandler> lazyOutputItems = LazyOptional.empty();
|
||||
|
||||
public ItemScrubberBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(ModEntities.ITEM_SCRUBBER.get(), pos, state);
|
||||
outputSlot = new OutputItemStackHandler(outputItems);
|
||||
|
||||
this.data = new ContainerData() {
|
||||
|
||||
@Override
|
||||
public int get(int p_39284_) {
|
||||
return switch(p_39284_){
|
||||
case 0 -> ItemScrubberBlockEntity.this.progress;
|
||||
default -> 0;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int p_39285_, int p_39286_) {
|
||||
switch(p_39285_)
|
||||
{
|
||||
case 0 -> ItemScrubberBlockEntity.this.progress = p_39286_;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
protected final ContainerData data;
|
||||
private int progress = 0;
|
||||
|
||||
public static final int MAXIMUM_PROCESSING_TICKS = 250;
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public AbstractContainerMenu createMenu(int id, Inventory inv, Player player) {
|
||||
return new ItemScrubberMenu(id, inv, this, this.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getDisplayName() {
|
||||
return Component.translatable("block.otemod.item_scrubber");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side)
|
||||
{
|
||||
if(cap == ForgeCapabilities.ENERGY)
|
||||
{
|
||||
return lazyEnergyHandler.cast();
|
||||
}
|
||||
if(side == Direction.DOWN && cap == ForgeCapabilities.ITEM_HANDLER)
|
||||
{
|
||||
// Return the output slot only
|
||||
return lazyOutputItems.cast();
|
||||
}
|
||||
if(cap == ForgeCapabilities.ITEM_HANDLER)
|
||||
{
|
||||
return lazyItemHandler.cast();
|
||||
}
|
||||
|
||||
return super.getCapability(cap,side);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onLoad()
|
||||
{
|
||||
super.onLoad();
|
||||
lazyItemHandler = LazyOptional.of(()->itemsHandler);
|
||||
lazyOutputItems = LazyOptional.of(()->outputSlot);
|
||||
lazyEnergyHandler = LazyOptional.of(()->ENERGY_STORAGE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void invalidateCaps()
|
||||
{
|
||||
super.invalidateCaps();
|
||||
lazyItemHandler.invalidate();
|
||||
lazyOutputItems.invalidate();
|
||||
lazyEnergyHandler.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveAdditional(CompoundTag nbt)
|
||||
{
|
||||
nbt.put("inventory", itemsHandler.serializeNBT());
|
||||
nbt.put("output", outputItems.serializeNBT());
|
||||
nbt.putInt("prog", progress);
|
||||
nbt.putInt("energy", ENERGY_STORAGE.getEnergyStored());
|
||||
|
||||
super.saveAdditional(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CompoundTag nbt){
|
||||
super.load(nbt);
|
||||
|
||||
itemsHandler.deserializeNBT(nbt.getCompound("inventory"));
|
||||
outputItems.deserializeNBT(nbt.getCompound("output"));
|
||||
progress = nbt.getInt("prog");
|
||||
ENERGY_STORAGE.setEnergy(nbt.getInt("energy"));
|
||||
}
|
||||
|
||||
public void doDrop()
|
||||
{
|
||||
SimpleContainer cont = new SimpleContainer(itemsHandler.getSlots());
|
||||
for (int i = 0; i < itemsHandler.getSlots(); i++) {
|
||||
cont.setItem(i, itemsHandler.getStackInSlot(i));
|
||||
}
|
||||
cont = new SimpleContainer(outputItems.getSlots());
|
||||
for (int i = 0; i < outputItems.getSlots(); i++) {
|
||||
cont.setItem(i, outputItems.getStackInSlot(i));
|
||||
}
|
||||
|
||||
Containers.dropContents(this.level, this.worldPosition, cont);
|
||||
}
|
||||
|
||||
public static void tick(Level lvl, BlockPos pos, BlockState state, ItemScrubberBlockEntity entity)
|
||||
{
|
||||
if(lvl.isClientSide())return;
|
||||
|
||||
|
||||
if(hasRecipe(entity))
|
||||
{
|
||||
if(!hasEnergy(entity))return; // Halt until sufficient energy has been received
|
||||
entity.progress++;
|
||||
setChanged(lvl, pos, state);
|
||||
drain(entity);
|
||||
|
||||
if(entity.progress >= ItemScrubberBlockEntity.MAXIMUM_PROCESSING_TICKS)
|
||||
{
|
||||
craftItem(entity);
|
||||
}
|
||||
}else {
|
||||
if(entity.progress>0){
|
||||
entity.resetProgress();
|
||||
setChanged(lvl, pos, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void drain(ItemScrubberBlockEntity entity) {
|
||||
entity.ENERGY_STORAGE.extractEnergy(ENERGY_REQ, false);
|
||||
}
|
||||
|
||||
private static boolean hasEnergy(ItemScrubberBlockEntity entity) {
|
||||
return (entity.ENERGY_STORAGE.getEnergyStored() >= ENERGY_REQ);
|
||||
}
|
||||
|
||||
private static void craftItem(ItemScrubberBlockEntity entity) {
|
||||
if(hasRecipe(entity))
|
||||
{
|
||||
ItemStack existing = entity.outputItems.getStackInSlot(0);
|
||||
existing.setCount(existing.getCount()+1);
|
||||
if(existing.is(Items.AIR))
|
||||
{
|
||||
existing = makeOutputItem(entity.itemsHandler.getStackInSlot(0));
|
||||
}
|
||||
entity.itemsHandler.extractItem(0, 1, false);
|
||||
entity.outputItems.setStackInSlot(0, existing);
|
||||
|
||||
entity.resetProgress();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasRecipe(ItemScrubberBlockEntity entity) {
|
||||
SimpleContainer inventory = new SimpleContainer(entity.itemsHandler.getSlots());
|
||||
for(int i=0;i<entity.itemsHandler.getSlots();i++)
|
||||
{
|
||||
inventory.setItem(i, entity.itemsHandler.getStackInSlot(i));
|
||||
}
|
||||
SimpleContainer output = new SimpleContainer(entity.outputItems.getSlots());
|
||||
for(int i=0;i<entity.outputItems.getSlots();i++)
|
||||
{
|
||||
output.setItem(i, entity.outputItems.getStackInSlot(i));
|
||||
}
|
||||
|
||||
|
||||
boolean hasAnItem = !entity.itemsHandler.getStackInSlot(0).isEmpty();
|
||||
|
||||
ItemStack result = null;
|
||||
if(hasAnItem)
|
||||
{
|
||||
result = makeOutputItem(entity.itemsHandler.getStackInSlot(0));
|
||||
|
||||
}
|
||||
return hasAnItem && canInsertIntoOutput(output, result);
|
||||
}
|
||||
|
||||
private static boolean canInsertIntoOutput(SimpleContainer inventory, ItemStack result) {
|
||||
ItemStack existing = inventory.getItem(0);
|
||||
boolean stackCompat = (existing.getMaxStackSize() > existing.getCount());
|
||||
boolean sameType = (existing.getItem() == result.getItem());
|
||||
boolean outputEmpty = existing.isEmpty();
|
||||
|
||||
if(outputEmpty)return true;
|
||||
return (stackCompat && sameType);
|
||||
}
|
||||
|
||||
private void resetProgress() {
|
||||
progress=0;
|
||||
|
||||
}
|
||||
|
||||
protected static ItemStack makeOutputItem(ItemStack original)
|
||||
{
|
||||
ItemStack newItem = new ItemStack(original.getItem(),1);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
public IEnergyStorage getEnergyStorage() {
|
||||
return ENERGY_STORAGE;
|
||||
}
|
||||
|
||||
public void setEnergy(int energy) {
|
||||
ENERGY_STORAGE.setEnergy(energy);
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.blocks.entity;
|
||||
|
||||
import dev.zontreck.otemod.implementation.OutputItemStackHandler;
|
||||
import dev.zontreck.otemod.implementation.energy.OTEEnergy;
|
||||
import dev.zontreck.otemod.implementation.scrubber.ItemScrubberMenu;
|
||||
import dev.zontreck.otemod.networking.ModMessages;
|
||||
import dev.zontreck.otemod.networking.packets.EnergySyncS2CPacket;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.Containers;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.ContainerData;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ItemScrubberBlockEntity extends BlockEntity implements MenuProvider
|
||||
{
|
||||
|
||||
protected final ItemStackHandler itemsHandler = new ItemStackHandler(1){
|
||||
@Override
|
||||
protected void onContentsChanged(int slot)
|
||||
{
|
||||
setChanged();
|
||||
}
|
||||
};
|
||||
protected final ItemStackHandler outputItems = new ItemStackHandler(1){
|
||||
@Override
|
||||
protected void onContentsChanged(int slot)
|
||||
{
|
||||
setChanged();
|
||||
}
|
||||
};
|
||||
private ItemStackHandler outputSlot;
|
||||
|
||||
private final OTEEnergy ENERGY_STORAGE = new OTEEnergy(ENERGY_REQ*3, ENERGY_REQ+512) {
|
||||
|
||||
@Override
|
||||
public void onChanged() {
|
||||
setChanged();
|
||||
|
||||
ModMessages.sendToAll(new EnergySyncS2CPacket(energy, getBlockPos()));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private static final int ENERGY_REQ = 1500;
|
||||
private LazyOptional<IEnergyStorage> lazyEnergyHandler = LazyOptional.empty();
|
||||
|
||||
private LazyOptional<IItemHandler> lazyItemHandler = LazyOptional.empty();
|
||||
private LazyOptional<IItemHandler> lazyOutputItems = LazyOptional.empty();
|
||||
|
||||
public ItemScrubberBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(ModEntities.ITEM_SCRUBBER.get(), pos, state);
|
||||
outputSlot = new OutputItemStackHandler(outputItems);
|
||||
|
||||
this.data = new ContainerData() {
|
||||
|
||||
@Override
|
||||
public int get(int p_39284_) {
|
||||
return switch(p_39284_){
|
||||
case 0 -> ItemScrubberBlockEntity.this.progress;
|
||||
default -> 0;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int p_39285_, int p_39286_) {
|
||||
switch(p_39285_)
|
||||
{
|
||||
case 0 -> ItemScrubberBlockEntity.this.progress = p_39286_;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
protected final ContainerData data;
|
||||
private int progress = 0;
|
||||
|
||||
public static final int MAXIMUM_PROCESSING_TICKS = 250;
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public AbstractContainerMenu createMenu(int id, Inventory inv, Player player) {
|
||||
return new ItemScrubberMenu(id, inv, this, this.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getDisplayName() {
|
||||
return Component.translatable("block.otemod.item_scrubber");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side)
|
||||
{
|
||||
if(cap == ForgeCapabilities.ENERGY)
|
||||
{
|
||||
return lazyEnergyHandler.cast();
|
||||
}
|
||||
if(side == Direction.DOWN && cap == ForgeCapabilities.ITEM_HANDLER)
|
||||
{
|
||||
// Return the output slot only
|
||||
return lazyOutputItems.cast();
|
||||
}
|
||||
if(cap == ForgeCapabilities.ITEM_HANDLER)
|
||||
{
|
||||
return lazyItemHandler.cast();
|
||||
}
|
||||
|
||||
return super.getCapability(cap,side);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onLoad()
|
||||
{
|
||||
super.onLoad();
|
||||
lazyItemHandler = LazyOptional.of(()->itemsHandler);
|
||||
lazyOutputItems = LazyOptional.of(()->outputSlot);
|
||||
lazyEnergyHandler = LazyOptional.of(()->ENERGY_STORAGE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void invalidateCaps()
|
||||
{
|
||||
super.invalidateCaps();
|
||||
lazyItemHandler.invalidate();
|
||||
lazyOutputItems.invalidate();
|
||||
lazyEnergyHandler.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveAdditional(CompoundTag nbt)
|
||||
{
|
||||
nbt.put("inventory", itemsHandler.serializeNBT());
|
||||
nbt.put("output", outputItems.serializeNBT());
|
||||
nbt.putInt("prog", progress);
|
||||
nbt.putInt("energy", ENERGY_STORAGE.getEnergyStored());
|
||||
|
||||
super.saveAdditional(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CompoundTag nbt){
|
||||
super.load(nbt);
|
||||
|
||||
itemsHandler.deserializeNBT(nbt.getCompound("inventory"));
|
||||
outputItems.deserializeNBT(nbt.getCompound("output"));
|
||||
progress = nbt.getInt("prog");
|
||||
ENERGY_STORAGE.setEnergy(nbt.getInt("energy"));
|
||||
}
|
||||
|
||||
public void doDrop()
|
||||
{
|
||||
SimpleContainer cont = new SimpleContainer(itemsHandler.getSlots());
|
||||
for (int i = 0; i < itemsHandler.getSlots(); i++) {
|
||||
cont.setItem(i, itemsHandler.getStackInSlot(i));
|
||||
}
|
||||
cont = new SimpleContainer(outputItems.getSlots());
|
||||
for (int i = 0; i < outputItems.getSlots(); i++) {
|
||||
cont.setItem(i, outputItems.getStackInSlot(i));
|
||||
}
|
||||
|
||||
Containers.dropContents(this.level, this.worldPosition, cont);
|
||||
}
|
||||
|
||||
public static void tick(Level lvl, BlockPos pos, BlockState state, ItemScrubberBlockEntity entity)
|
||||
{
|
||||
if(lvl.isClientSide())return;
|
||||
|
||||
|
||||
if(hasRecipe(entity))
|
||||
{
|
||||
if(!hasEnergy(entity))return; // Halt until sufficient energy has been received
|
||||
entity.progress++;
|
||||
setChanged(lvl, pos, state);
|
||||
drain(entity);
|
||||
|
||||
if(entity.progress >= ItemScrubberBlockEntity.MAXIMUM_PROCESSING_TICKS)
|
||||
{
|
||||
craftItem(entity);
|
||||
}
|
||||
}else {
|
||||
if(entity.progress>0){
|
||||
entity.resetProgress();
|
||||
setChanged(lvl, pos, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void drain(ItemScrubberBlockEntity entity) {
|
||||
entity.ENERGY_STORAGE.extractEnergy(ENERGY_REQ, false);
|
||||
}
|
||||
|
||||
private static boolean hasEnergy(ItemScrubberBlockEntity entity) {
|
||||
return (entity.ENERGY_STORAGE.getEnergyStored() >= ENERGY_REQ);
|
||||
}
|
||||
|
||||
private static void craftItem(ItemScrubberBlockEntity entity) {
|
||||
if(hasRecipe(entity))
|
||||
{
|
||||
ItemStack existing = entity.outputItems.getStackInSlot(0);
|
||||
existing.setCount(existing.getCount()+1);
|
||||
if(existing.is(Items.AIR))
|
||||
{
|
||||
existing = makeOutputItem(entity.itemsHandler.getStackInSlot(0));
|
||||
}
|
||||
entity.itemsHandler.extractItem(0, 1, false);
|
||||
entity.outputItems.setStackInSlot(0, existing);
|
||||
|
||||
entity.resetProgress();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasRecipe(ItemScrubberBlockEntity entity) {
|
||||
SimpleContainer inventory = new SimpleContainer(entity.itemsHandler.getSlots());
|
||||
for(int i=0;i<entity.itemsHandler.getSlots();i++)
|
||||
{
|
||||
inventory.setItem(i, entity.itemsHandler.getStackInSlot(i));
|
||||
}
|
||||
SimpleContainer output = new SimpleContainer(entity.outputItems.getSlots());
|
||||
for(int i=0;i<entity.outputItems.getSlots();i++)
|
||||
{
|
||||
output.setItem(i, entity.outputItems.getStackInSlot(i));
|
||||
}
|
||||
|
||||
|
||||
boolean hasAnItem = !entity.itemsHandler.getStackInSlot(0).isEmpty();
|
||||
|
||||
ItemStack result = null;
|
||||
if(hasAnItem)
|
||||
{
|
||||
result = makeOutputItem(entity.itemsHandler.getStackInSlot(0));
|
||||
|
||||
}
|
||||
return hasAnItem && canInsertIntoOutput(output, result);
|
||||
}
|
||||
|
||||
private static boolean canInsertIntoOutput(SimpleContainer inventory, ItemStack result) {
|
||||
ItemStack existing = inventory.getItem(0);
|
||||
boolean stackCompat = (existing.getMaxStackSize() > existing.getCount());
|
||||
boolean sameType = (existing.getItem() == result.getItem());
|
||||
boolean outputEmpty = existing.isEmpty();
|
||||
|
||||
if(outputEmpty)return true;
|
||||
return (stackCompat && sameType);
|
||||
}
|
||||
|
||||
private void resetProgress() {
|
||||
progress=0;
|
||||
|
||||
}
|
||||
|
||||
protected static ItemStack makeOutputItem(ItemStack original)
|
||||
{
|
||||
ItemStack newItem = new ItemStack(original.getItem(),1);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
public IEnergyStorage getEnergyStorage() {
|
||||
return ENERGY_STORAGE;
|
||||
}
|
||||
|
||||
public void setEnergy(int energy) {
|
||||
ENERGY_STORAGE.setEnergy(energy);
|
||||
}
|
||||
}
|
|
@ -1,332 +1,332 @@
|
|||
package dev.zontreck.thresholds.blocks.entity;
|
||||
|
||||
import dev.zontreck.libzontreck.util.ItemUtils;
|
||||
import dev.zontreck.thresholds.implementation.OutputItemStackHandler;
|
||||
import dev.zontreck.thresholds.implementation.energy.OTEEnergy;
|
||||
import dev.zontreck.thresholds.implementation.scrubber.MagicalScrubberMenu;
|
||||
import dev.zontreck.thresholds.networking.ModMessages;
|
||||
import dev.zontreck.thresholds.networking.packets.EnergySyncS2CPacket;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.Containers;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.ContainerData;
|
||||
import net.minecraft.world.item.EnchantedBookItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentInstance;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
public class MagicalScrubberBlockEntity extends BlockEntity implements MenuProvider
|
||||
{
|
||||
|
||||
protected final ItemStackHandler itemsHandler = new ItemStackHandler(1){
|
||||
@Override
|
||||
protected void onContentsChanged(int slot)
|
||||
{
|
||||
setChanged();
|
||||
}
|
||||
};
|
||||
protected final ItemStackHandler outputItems = new ItemStackHandler(1){
|
||||
@Override
|
||||
protected void onContentsChanged(int slot)
|
||||
{
|
||||
setChanged();
|
||||
}
|
||||
};
|
||||
private ItemStackHandler outputSlot;
|
||||
|
||||
private final OTEEnergy ENERGY_STORAGE = new OTEEnergy(ENERGY_REQ*3, ENERGY_REQ+512) {
|
||||
|
||||
@Override
|
||||
public void onChanged() {
|
||||
setChanged();
|
||||
|
||||
ModMessages.sendToAll(new EnergySyncS2CPacket(energy, getBlockPos()));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private static final int ENERGY_REQ = 1000;
|
||||
private LazyOptional<IEnergyStorage> lazyEnergyHandler = LazyOptional.empty();
|
||||
|
||||
private LazyOptional<IItemHandler> lazyItemHandler = LazyOptional.empty();
|
||||
private LazyOptional<IItemHandler> lazyOutputItems = LazyOptional.empty();
|
||||
|
||||
public MagicalScrubberBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(ModEntities.MAGICAL_SCRUBBER.get(), pos, state);
|
||||
outputSlot = new OutputItemStackHandler(outputItems);
|
||||
|
||||
this.data = new ContainerData() {
|
||||
|
||||
@Override
|
||||
public int get(int p_39284_) {
|
||||
return switch(p_39284_){
|
||||
case 0 -> MagicalScrubberBlockEntity.this.progress;
|
||||
default -> 0;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int p_39285_, int p_39286_) {
|
||||
switch(p_39285_)
|
||||
{
|
||||
case 0 -> MagicalScrubberBlockEntity.this.progress = p_39286_;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
protected final ContainerData data;
|
||||
private int progress = 0;
|
||||
|
||||
public static final int MAXIMUM_PROCESSING_TICKS = 175;
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public AbstractContainerMenu createMenu(int id, Inventory inv, Player player) {
|
||||
return new MagicalScrubberMenu(id, inv, this, this.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getDisplayName() {
|
||||
return Component.translatable("block.otemod.magical_scrubber");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side)
|
||||
{
|
||||
if(cap == ForgeCapabilities.ENERGY)
|
||||
{
|
||||
return lazyEnergyHandler.cast();
|
||||
}
|
||||
if(side == Direction.DOWN && cap == ForgeCapabilities.ITEM_HANDLER)
|
||||
{
|
||||
// Return the output slot only
|
||||
return lazyOutputItems.cast();
|
||||
}
|
||||
if(cap == ForgeCapabilities.ITEM_HANDLER)
|
||||
{
|
||||
return lazyItemHandler.cast();
|
||||
}
|
||||
|
||||
return super.getCapability(cap,side);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onLoad()
|
||||
{
|
||||
super.onLoad();
|
||||
lazyItemHandler = LazyOptional.of(()->itemsHandler);
|
||||
lazyOutputItems = LazyOptional.of(()->outputSlot);
|
||||
lazyEnergyHandler = LazyOptional.of(()->ENERGY_STORAGE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void invalidateCaps()
|
||||
{
|
||||
super.invalidateCaps();
|
||||
lazyItemHandler.invalidate();
|
||||
lazyOutputItems.invalidate();
|
||||
lazyEnergyHandler.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveAdditional(CompoundTag nbt)
|
||||
{
|
||||
nbt.put("inventory", itemsHandler.serializeNBT());
|
||||
nbt.put("output", outputItems.serializeNBT());
|
||||
nbt.putInt("prog", progress);
|
||||
nbt.putInt("energy", ENERGY_STORAGE.getEnergyStored());
|
||||
|
||||
super.saveAdditional(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CompoundTag nbt){
|
||||
super.load(nbt);
|
||||
|
||||
itemsHandler.deserializeNBT(nbt.getCompound("inventory"));
|
||||
outputItems.deserializeNBT(nbt.getCompound("output"));
|
||||
progress = nbt.getInt("prog");
|
||||
ENERGY_STORAGE.setEnergy(nbt.getInt("energy"));
|
||||
}
|
||||
|
||||
public void doDrop()
|
||||
{
|
||||
SimpleContainer cont = new SimpleContainer(itemsHandler.getSlots());
|
||||
for (int i = 0; i < itemsHandler.getSlots(); i++) {
|
||||
cont.setItem(i, itemsHandler.getStackInSlot(i));
|
||||
}
|
||||
cont = new SimpleContainer(outputItems.getSlots());
|
||||
for (int i = 0; i < outputItems.getSlots(); i++) {
|
||||
cont.setItem(i, outputItems.getStackInSlot(i));
|
||||
}
|
||||
|
||||
Containers.dropContents(this.level, this.worldPosition, cont);
|
||||
}
|
||||
|
||||
public static void tick(Level lvl, BlockPos pos, BlockState state, MagicalScrubberBlockEntity entity)
|
||||
{
|
||||
if(lvl.isClientSide())return;
|
||||
|
||||
if(hasRecipe(entity))
|
||||
{
|
||||
if(!hasEnergy(entity))return; // Halt until sufficient energy has been received
|
||||
entity.progress++;
|
||||
setChanged(lvl, pos, state);
|
||||
drain(entity);
|
||||
|
||||
if(entity.progress >= MagicalScrubberBlockEntity.MAXIMUM_PROCESSING_TICKS)
|
||||
{
|
||||
craftItem(entity);
|
||||
}
|
||||
}else {
|
||||
if(entity.progress>0){
|
||||
entity.resetProgress();
|
||||
setChanged(lvl, pos, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void drain(MagicalScrubberBlockEntity entity) {
|
||||
entity.ENERGY_STORAGE.extractEnergy(ENERGY_REQ, false);
|
||||
}
|
||||
|
||||
private static boolean hasEnergy(MagicalScrubberBlockEntity entity) {
|
||||
return (entity.ENERGY_STORAGE.getEnergyStored() >= ENERGY_REQ);
|
||||
}
|
||||
|
||||
private static void craftItem(MagicalScrubberBlockEntity entity) {
|
||||
if(hasRecipe(entity))
|
||||
{
|
||||
ItemStack existing = entity.outputItems.getStackInSlot(0);
|
||||
ItemStack main = entity.itemsHandler.getStackInSlot(0);
|
||||
|
||||
//Map<Enchantment, Integer> enchants = main.getAllEnchantments();
|
||||
Map<Enchantment, Integer> enchantments = ItemUtils.getEnchantments(main.copy());
|
||||
|
||||
if(enchantments.size()>0)
|
||||
{
|
||||
Iterator<Map.Entry<Enchantment,Integer>> iEntries = enchantments.entrySet().iterator();
|
||||
try{
|
||||
Map.Entry<Enchantment,Integer> entry = iEntries.next();
|
||||
EnchantmentInstance eInst = new EnchantmentInstance(entry.getKey(), entry.getValue());
|
||||
existing = EnchantedBookItem.createForEnchantment(eInst);
|
||||
iEntries.remove();
|
||||
main = makeOutputItem(main.copy());
|
||||
while(iEntries.hasNext())
|
||||
{
|
||||
entry = iEntries.next();
|
||||
main.enchant(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}catch(Exception E)
|
||||
{
|
||||
entity.outputItems.setStackInSlot(0, main);
|
||||
entity.itemsHandler.extractItem(0, 1, false);
|
||||
entity.resetProgress();
|
||||
return;
|
||||
}
|
||||
|
||||
if(enchantments.size()==0){
|
||||
entity.itemsHandler.extractItem(0, 1, false);
|
||||
}else entity.itemsHandler.setStackInSlot(0, main);
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
existing.setCount(existing.getCount()+1);
|
||||
if(existing.is(Items.AIR))
|
||||
{
|
||||
existing = makeOutputItem(entity.itemsHandler.getStackInSlot(0));
|
||||
}
|
||||
entity.itemsHandler.extractItem(0, 1, false);
|
||||
}
|
||||
|
||||
entity.outputItems.setStackInSlot(0, existing);
|
||||
entity.resetProgress();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasRecipe(MagicalScrubberBlockEntity entity) {
|
||||
SimpleContainer inventory = new SimpleContainer(entity.itemsHandler.getSlots());
|
||||
for(int i=0;i<entity.itemsHandler.getSlots();i++)
|
||||
{
|
||||
inventory.setItem(i, entity.itemsHandler.getStackInSlot(i));
|
||||
}
|
||||
SimpleContainer output = new SimpleContainer(entity.outputItems.getSlots());
|
||||
for(int i=0;i<entity.outputItems.getSlots();i++)
|
||||
{
|
||||
output.setItem(i, entity.outputItems.getStackInSlot(i));
|
||||
}
|
||||
|
||||
|
||||
boolean hasAnItem = !entity.itemsHandler.getStackInSlot(0).isEmpty();
|
||||
|
||||
ItemStack result = null;
|
||||
if(hasAnItem)
|
||||
{
|
||||
result = makeOutputItem(entity.itemsHandler.getStackInSlot(0));
|
||||
|
||||
}
|
||||
return hasAnItem && canInsertIntoOutput(output, result);
|
||||
}
|
||||
|
||||
private static boolean canInsertIntoOutput(SimpleContainer inventory, ItemStack result) {
|
||||
ItemStack existing = inventory.getItem(0);
|
||||
boolean stackCompat = (existing.getMaxStackSize() > existing.getCount());
|
||||
boolean sameType = (existing.getItem() == result.getItem());
|
||||
boolean outputEmpty = existing.isEmpty();
|
||||
|
||||
if(outputEmpty)return true;
|
||||
return (stackCompat && sameType);
|
||||
}
|
||||
|
||||
private void resetProgress() {
|
||||
progress=0;
|
||||
|
||||
}
|
||||
|
||||
protected static ItemStack makeOutputItem(ItemStack original)
|
||||
{
|
||||
ItemStack newItem = new ItemStack(original.getItem(),1);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
public IEnergyStorage getEnergyStorage() {
|
||||
return ENERGY_STORAGE;
|
||||
}
|
||||
|
||||
public void setEnergy(int energy) {
|
||||
ENERGY_STORAGE.setEnergy(energy);
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.blocks.entity;
|
||||
|
||||
import dev.zontreck.libzontreck.util.ItemUtils;
|
||||
import dev.zontreck.otemod.implementation.OutputItemStackHandler;
|
||||
import dev.zontreck.otemod.implementation.energy.OTEEnergy;
|
||||
import dev.zontreck.otemod.implementation.scrubber.MagicalScrubberMenu;
|
||||
import dev.zontreck.otemod.networking.ModMessages;
|
||||
import dev.zontreck.otemod.networking.packets.EnergySyncS2CPacket;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.Containers;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.ContainerData;
|
||||
import net.minecraft.world.item.EnchantedBookItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentInstance;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
public class MagicalScrubberBlockEntity extends BlockEntity implements MenuProvider
|
||||
{
|
||||
|
||||
protected final ItemStackHandler itemsHandler = new ItemStackHandler(1){
|
||||
@Override
|
||||
protected void onContentsChanged(int slot)
|
||||
{
|
||||
setChanged();
|
||||
}
|
||||
};
|
||||
protected final ItemStackHandler outputItems = new ItemStackHandler(1){
|
||||
@Override
|
||||
protected void onContentsChanged(int slot)
|
||||
{
|
||||
setChanged();
|
||||
}
|
||||
};
|
||||
private ItemStackHandler outputSlot;
|
||||
|
||||
private final OTEEnergy ENERGY_STORAGE = new OTEEnergy(ENERGY_REQ*3, ENERGY_REQ+512) {
|
||||
|
||||
@Override
|
||||
public void onChanged() {
|
||||
setChanged();
|
||||
|
||||
ModMessages.sendToAll(new EnergySyncS2CPacket(energy, getBlockPos()));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private static final int ENERGY_REQ = 1000;
|
||||
private LazyOptional<IEnergyStorage> lazyEnergyHandler = LazyOptional.empty();
|
||||
|
||||
private LazyOptional<IItemHandler> lazyItemHandler = LazyOptional.empty();
|
||||
private LazyOptional<IItemHandler> lazyOutputItems = LazyOptional.empty();
|
||||
|
||||
public MagicalScrubberBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(ModEntities.MAGICAL_SCRUBBER.get(), pos, state);
|
||||
outputSlot = new OutputItemStackHandler(outputItems);
|
||||
|
||||
this.data = new ContainerData() {
|
||||
|
||||
@Override
|
||||
public int get(int p_39284_) {
|
||||
return switch(p_39284_){
|
||||
case 0 -> MagicalScrubberBlockEntity.this.progress;
|
||||
default -> 0;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int p_39285_, int p_39286_) {
|
||||
switch(p_39285_)
|
||||
{
|
||||
case 0 -> MagicalScrubberBlockEntity.this.progress = p_39286_;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
protected final ContainerData data;
|
||||
private int progress = 0;
|
||||
|
||||
public static final int MAXIMUM_PROCESSING_TICKS = 175;
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public AbstractContainerMenu createMenu(int id, Inventory inv, Player player) {
|
||||
return new MagicalScrubberMenu(id, inv, this, this.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getDisplayName() {
|
||||
return Component.translatable("block.otemod.magical_scrubber");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side)
|
||||
{
|
||||
if(cap == ForgeCapabilities.ENERGY)
|
||||
{
|
||||
return lazyEnergyHandler.cast();
|
||||
}
|
||||
if(side == Direction.DOWN && cap == ForgeCapabilities.ITEM_HANDLER)
|
||||
{
|
||||
// Return the output slot only
|
||||
return lazyOutputItems.cast();
|
||||
}
|
||||
if(cap == ForgeCapabilities.ITEM_HANDLER)
|
||||
{
|
||||
return lazyItemHandler.cast();
|
||||
}
|
||||
|
||||
return super.getCapability(cap,side);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onLoad()
|
||||
{
|
||||
super.onLoad();
|
||||
lazyItemHandler = LazyOptional.of(()->itemsHandler);
|
||||
lazyOutputItems = LazyOptional.of(()->outputSlot);
|
||||
lazyEnergyHandler = LazyOptional.of(()->ENERGY_STORAGE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void invalidateCaps()
|
||||
{
|
||||
super.invalidateCaps();
|
||||
lazyItemHandler.invalidate();
|
||||
lazyOutputItems.invalidate();
|
||||
lazyEnergyHandler.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveAdditional(CompoundTag nbt)
|
||||
{
|
||||
nbt.put("inventory", itemsHandler.serializeNBT());
|
||||
nbt.put("output", outputItems.serializeNBT());
|
||||
nbt.putInt("prog", progress);
|
||||
nbt.putInt("energy", ENERGY_STORAGE.getEnergyStored());
|
||||
|
||||
super.saveAdditional(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CompoundTag nbt){
|
||||
super.load(nbt);
|
||||
|
||||
itemsHandler.deserializeNBT(nbt.getCompound("inventory"));
|
||||
outputItems.deserializeNBT(nbt.getCompound("output"));
|
||||
progress = nbt.getInt("prog");
|
||||
ENERGY_STORAGE.setEnergy(nbt.getInt("energy"));
|
||||
}
|
||||
|
||||
public void doDrop()
|
||||
{
|
||||
SimpleContainer cont = new SimpleContainer(itemsHandler.getSlots());
|
||||
for (int i = 0; i < itemsHandler.getSlots(); i++) {
|
||||
cont.setItem(i, itemsHandler.getStackInSlot(i));
|
||||
}
|
||||
cont = new SimpleContainer(outputItems.getSlots());
|
||||
for (int i = 0; i < outputItems.getSlots(); i++) {
|
||||
cont.setItem(i, outputItems.getStackInSlot(i));
|
||||
}
|
||||
|
||||
Containers.dropContents(this.level, this.worldPosition, cont);
|
||||
}
|
||||
|
||||
public static void tick(Level lvl, BlockPos pos, BlockState state, MagicalScrubberBlockEntity entity)
|
||||
{
|
||||
if(lvl.isClientSide())return;
|
||||
|
||||
if(hasRecipe(entity))
|
||||
{
|
||||
if(!hasEnergy(entity))return; // Halt until sufficient energy has been received
|
||||
entity.progress++;
|
||||
setChanged(lvl, pos, state);
|
||||
drain(entity);
|
||||
|
||||
if(entity.progress >= MagicalScrubberBlockEntity.MAXIMUM_PROCESSING_TICKS)
|
||||
{
|
||||
craftItem(entity);
|
||||
}
|
||||
}else {
|
||||
if(entity.progress>0){
|
||||
entity.resetProgress();
|
||||
setChanged(lvl, pos, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void drain(MagicalScrubberBlockEntity entity) {
|
||||
entity.ENERGY_STORAGE.extractEnergy(ENERGY_REQ, false);
|
||||
}
|
||||
|
||||
private static boolean hasEnergy(MagicalScrubberBlockEntity entity) {
|
||||
return (entity.ENERGY_STORAGE.getEnergyStored() >= ENERGY_REQ);
|
||||
}
|
||||
|
||||
private static void craftItem(MagicalScrubberBlockEntity entity) {
|
||||
if(hasRecipe(entity))
|
||||
{
|
||||
ItemStack existing = entity.outputItems.getStackInSlot(0);
|
||||
ItemStack main = entity.itemsHandler.getStackInSlot(0);
|
||||
|
||||
//Map<Enchantment, Integer> enchants = main.getAllEnchantments();
|
||||
Map<Enchantment, Integer> enchantments = ItemUtils.getEnchantments(main.copy());
|
||||
|
||||
if(enchantments.size()>0)
|
||||
{
|
||||
Iterator<Map.Entry<Enchantment,Integer>> iEntries = enchantments.entrySet().iterator();
|
||||
try{
|
||||
Map.Entry<Enchantment,Integer> entry = iEntries.next();
|
||||
EnchantmentInstance eInst = new EnchantmentInstance(entry.getKey(), entry.getValue());
|
||||
existing = EnchantedBookItem.createForEnchantment(eInst);
|
||||
iEntries.remove();
|
||||
main = makeOutputItem(main.copy());
|
||||
while(iEntries.hasNext())
|
||||
{
|
||||
entry = iEntries.next();
|
||||
main.enchant(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}catch(Exception E)
|
||||
{
|
||||
entity.outputItems.setStackInSlot(0, main);
|
||||
entity.itemsHandler.extractItem(0, 1, false);
|
||||
entity.resetProgress();
|
||||
return;
|
||||
}
|
||||
|
||||
if(enchantments.size()==0){
|
||||
entity.itemsHandler.extractItem(0, 1, false);
|
||||
}else entity.itemsHandler.setStackInSlot(0, main);
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
existing.setCount(existing.getCount()+1);
|
||||
if(existing.is(Items.AIR))
|
||||
{
|
||||
existing = makeOutputItem(entity.itemsHandler.getStackInSlot(0));
|
||||
}
|
||||
entity.itemsHandler.extractItem(0, 1, false);
|
||||
}
|
||||
|
||||
entity.outputItems.setStackInSlot(0, existing);
|
||||
entity.resetProgress();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasRecipe(MagicalScrubberBlockEntity entity) {
|
||||
SimpleContainer inventory = new SimpleContainer(entity.itemsHandler.getSlots());
|
||||
for(int i=0;i<entity.itemsHandler.getSlots();i++)
|
||||
{
|
||||
inventory.setItem(i, entity.itemsHandler.getStackInSlot(i));
|
||||
}
|
||||
SimpleContainer output = new SimpleContainer(entity.outputItems.getSlots());
|
||||
for(int i=0;i<entity.outputItems.getSlots();i++)
|
||||
{
|
||||
output.setItem(i, entity.outputItems.getStackInSlot(i));
|
||||
}
|
||||
|
||||
|
||||
boolean hasAnItem = !entity.itemsHandler.getStackInSlot(0).isEmpty();
|
||||
|
||||
ItemStack result = null;
|
||||
if(hasAnItem)
|
||||
{
|
||||
result = makeOutputItem(entity.itemsHandler.getStackInSlot(0));
|
||||
|
||||
}
|
||||
return hasAnItem && canInsertIntoOutput(output, result);
|
||||
}
|
||||
|
||||
private static boolean canInsertIntoOutput(SimpleContainer inventory, ItemStack result) {
|
||||
ItemStack existing = inventory.getItem(0);
|
||||
boolean stackCompat = (existing.getMaxStackSize() > existing.getCount());
|
||||
boolean sameType = (existing.getItem() == result.getItem());
|
||||
boolean outputEmpty = existing.isEmpty();
|
||||
|
||||
if(outputEmpty)return true;
|
||||
return (stackCompat && sameType);
|
||||
}
|
||||
|
||||
private void resetProgress() {
|
||||
progress=0;
|
||||
|
||||
}
|
||||
|
||||
protected static ItemStack makeOutputItem(ItemStack original)
|
||||
{
|
||||
ItemStack newItem = new ItemStack(original.getItem(),1);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
public IEnergyStorage getEnergyStorage() {
|
||||
return ENERGY_STORAGE;
|
||||
}
|
||||
|
||||
public void setEnergy(int energy) {
|
||||
ENERGY_STORAGE.setEnergy(energy);
|
||||
}
|
||||
}
|
|
@ -1,31 +1,32 @@
|
|||
package dev.zontreck.thresholds.blocks.entity;
|
||||
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.blocks.ModBlocks;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class ModEntities {
|
||||
|
||||
public static final DeferredRegister<BlockEntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, ThresholdsMod.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 <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 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 void register(IEventBus eventBus)
|
||||
{
|
||||
ENTITIES.register(eventBus);
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.blocks.entity;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.blocks.CompressionChamberBlock;
|
||||
import dev.zontreck.otemod.blocks.ModBlocks;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class ModEntities {
|
||||
|
||||
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 <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(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 <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)
|
||||
{
|
||||
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.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
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 org.joml.Matrix4f;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
|
@ -1,41 +1,41 @@
|
|||
package dev.zontreck.thresholds.blocks.types;
|
||||
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Direction.Plane;
|
||||
import net.minecraft.world.level.block.IronBarsBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
/** Pane block with sensible culling */
|
||||
public class AlternatePaneBlock extends IronBarsBlock {
|
||||
public static final EnumMap<Direction,BooleanProperty> DIRECTIONS;
|
||||
static {
|
||||
DIRECTIONS = new EnumMap<>(Direction.class);
|
||||
DIRECTIONS.put(Direction.NORTH, NORTH);
|
||||
DIRECTIONS.put(Direction.EAST, EAST);
|
||||
DIRECTIONS.put(Direction.SOUTH, SOUTH);
|
||||
DIRECTIONS.put(Direction.WEST, WEST);
|
||||
}
|
||||
|
||||
public AlternatePaneBlock(Properties builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
if (adjacentBlockState.getBlock() == this && side.getAxis().isVertical()) {
|
||||
for (Direction dir : Plane.HORIZONTAL) {
|
||||
BooleanProperty prop = DIRECTIONS.get(dir);
|
||||
if (state.getValue(prop) && !adjacentBlockState.getValue(prop)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return super.skipRendering(state, adjacentBlockState, side);
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.blocks.types;
|
||||
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Direction.Plane;
|
||||
import net.minecraft.world.level.block.IronBarsBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
/** Pane block with sensible culling */
|
||||
public class AlternatePaneBlock extends IronBarsBlock {
|
||||
public static final EnumMap<Direction,BooleanProperty> DIRECTIONS;
|
||||
static {
|
||||
DIRECTIONS = new EnumMap<>(Direction.class);
|
||||
DIRECTIONS.put(Direction.NORTH, NORTH);
|
||||
DIRECTIONS.put(Direction.EAST, EAST);
|
||||
DIRECTIONS.put(Direction.SOUTH, SOUTH);
|
||||
DIRECTIONS.put(Direction.WEST, WEST);
|
||||
}
|
||||
|
||||
public AlternatePaneBlock(Properties builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
if (adjacentBlockState.getBlock() == this && side.getAxis().isVertical()) {
|
||||
for (Direction dir : Plane.HORIZONTAL) {
|
||||
BooleanProperty prop = DIRECTIONS.get(dir);
|
||||
if (state.getValue(prop) && !adjacentBlockState.getValue(prop)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return super.skipRendering(state, adjacentBlockState, side);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,133 +1,133 @@
|
|||
package dev.zontreck.thresholds.chat;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.chat.HoverTip;
|
||||
import dev.zontreck.libzontreck.events.ProfileLoadedEvent;
|
||||
import dev.zontreck.libzontreck.events.ProfileUnloadingEvent;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.util.ItemUtils;
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.configs.ThresholdsServerConfig;
|
||||
import dev.zontreck.thresholds.configs.PlayerFlyCache;
|
||||
import dev.zontreck.thresholds.enchantments.ModEnchantments;
|
||||
import dev.zontreck.thresholds.implementation.vault.StarterProvider;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.player.Abilities;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.event.ServerChatEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
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 ChatServerOverride {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onJoin(final ProfileLoadedEvent ev)
|
||||
{
|
||||
//Player joined, send custom alert
|
||||
ServerPlayer play = ev.player;
|
||||
Profile prof = ev.profile;
|
||||
|
||||
|
||||
if(prof.flying)
|
||||
{
|
||||
play.getAbilities().flying=true;
|
||||
play.onUpdateAbilities();
|
||||
}
|
||||
|
||||
Abilities playerAbilities = play.getAbilities();
|
||||
boolean mayFly = false;
|
||||
ItemStack feet = play.getItemBySlot(EquipmentSlot.FEET);
|
||||
if(ItemUtils.getEnchantmentLevel(ModEnchantments.FLIGHT_ENCHANTMENT.get(), feet)>0)mayFly = true;
|
||||
|
||||
playerAbilities.mayfly=mayFly;
|
||||
PlayerFlyCache c = PlayerFlyCache.cachePlayer(play);
|
||||
c.Flying=prof.flying;
|
||||
c.FlyEnabled = mayFly;
|
||||
c.Assert(play);
|
||||
|
||||
if(StarterProvider.exists())
|
||||
ThresholdsMod.checkFirstJoin(ev.player);
|
||||
|
||||
if(!ThresholdsServerConfig.USE_CUSTOM_JOINLEAVE.get()) return;
|
||||
|
||||
ChatHelpers.broadcast(ChatHelpers.macro("!Dark_Gray![!Dark_Green!+!Dark_Gray!] !Bold!!Dark_Aqua![0]",prof.nickname), ev.level.getServer());
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLeave(ProfileUnloadingEvent ev)
|
||||
{
|
||||
// Get player profile, send disconnect alert, then commit profile and remove it from memory
|
||||
Profile px=ev.profile;
|
||||
|
||||
|
||||
if(px==null)return;
|
||||
|
||||
if(!ThresholdsServerConfig.USE_CUSTOM_JOINLEAVE.get()) return;
|
||||
|
||||
// Send the alert
|
||||
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;
|
||||
ev.setCanceled(true);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onClone(final PlayerEvent.Clone ev)
|
||||
{
|
||||
if(ev.getEntity().level().isClientSide)return;
|
||||
// Fix for fly ability not copying to new instance on death or other circumstances
|
||||
Player old = ev.getOriginal();
|
||||
Player n = ev.getEntity();
|
||||
|
||||
PlayerFlyCache c = PlayerFlyCache.cachePlayer((ServerPlayer)old);
|
||||
c.Assert((ServerPlayer)n);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onChat(final ServerChatEvent ev){
|
||||
if(ev.getPlayer().level().isClientSide)return;
|
||||
// Player has chatted, apply override
|
||||
if(!ThresholdsServerConfig.USE_CUSTOM_CHATREPLACER.get()) return;
|
||||
|
||||
|
||||
ServerPlayer sp = ev.getPlayer();
|
||||
// Get profile
|
||||
Profile XD=null;
|
||||
try {
|
||||
XD = Profile.get_profile_of(sp.getStringUUID());
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Override the chat!
|
||||
String prefixStr = "";
|
||||
if(XD.prefix != ""){
|
||||
prefixStr = ChatColor.DARK_GRAY + "[" + ChatColor.BOLD + XD.prefix_color + XD.prefix + ChatColor.resetChat() + ChatColor.DARK_GRAY + "] ";
|
||||
}
|
||||
|
||||
String msg = ev.getRawText();
|
||||
msg= ChatColor.doColors(msg);
|
||||
|
||||
String nameStr = ChatColor.resetChat() + "< "+ XD.name_color + XD.nickname + ChatColor.resetChat() + " >";
|
||||
String message = ": "+XD.chat_color + msg;
|
||||
Style hover = Style.EMPTY;
|
||||
hover=hover.withFont(Style.DEFAULT_FONT).withHoverEvent(HoverTip.get(ChatColor.MINECOIN_GOLD+"User Name: "+XD.username));
|
||||
ev.setCanceled(true);
|
||||
|
||||
ChatHelpers.broadcast(Component.literal(prefixStr + nameStr + message).setStyle(hover), ev.getPlayer().server);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
package dev.zontreck.otemod.chat;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.chat.HoverTip;
|
||||
import dev.zontreck.libzontreck.events.ProfileLoadedEvent;
|
||||
import dev.zontreck.libzontreck.events.ProfileUnloadingEvent;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.util.ItemUtils;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import dev.zontreck.otemod.configs.PlayerFlyCache;
|
||||
import dev.zontreck.otemod.enchantments.ModEnchantments;
|
||||
import dev.zontreck.otemod.implementation.vault.StarterProvider;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.player.Abilities;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.event.ServerChatEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
|
||||
@EventBusSubscriber(modid=OTEMod.MOD_ID, bus=Mod.EventBusSubscriber.Bus.FORGE)
|
||||
public class ChatServerOverride {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onJoin(final ProfileLoadedEvent ev)
|
||||
{
|
||||
//Player joined, send custom alert
|
||||
ServerPlayer play = ev.player;
|
||||
Profile prof = ev.profile;
|
||||
|
||||
|
||||
if(prof.flying)
|
||||
{
|
||||
play.getAbilities().flying=true;
|
||||
play.onUpdateAbilities();
|
||||
}
|
||||
|
||||
Abilities playerAbilities = play.getAbilities();
|
||||
boolean mayFly = false;
|
||||
ItemStack feet = play.getItemBySlot(EquipmentSlot.FEET);
|
||||
if(ItemUtils.getEnchantmentLevel(ModEnchantments.FLIGHT_ENCHANTMENT.get(), feet)>0)mayFly = true;
|
||||
|
||||
playerAbilities.mayfly=mayFly;
|
||||
PlayerFlyCache c = PlayerFlyCache.cachePlayer(play);
|
||||
c.Flying=prof.flying;
|
||||
c.FlyEnabled = mayFly;
|
||||
c.Assert(play);
|
||||
|
||||
if(StarterProvider.exists())
|
||||
OTEMod.checkFirstJoin(ev.player);
|
||||
|
||||
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());
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLeave(ProfileUnloadingEvent ev)
|
||||
{
|
||||
// Get player profile, send disconnect alert, then commit profile and remove it from memory
|
||||
Profile px=ev.profile;
|
||||
|
||||
|
||||
if(px==null)return;
|
||||
|
||||
if(!OTEServerConfig.USE_CUSTOM_JOINLEAVE.get()) return;
|
||||
|
||||
// Send the alert
|
||||
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;
|
||||
ev.setCanceled(true);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onClone(final PlayerEvent.Clone ev)
|
||||
{
|
||||
if(ev.getEntity().level().isClientSide)return;
|
||||
// Fix for fly ability not copying to new instance on death or other circumstances
|
||||
Player old = ev.getOriginal();
|
||||
Player n = ev.getEntity();
|
||||
|
||||
PlayerFlyCache c = PlayerFlyCache.cachePlayer((ServerPlayer)old);
|
||||
c.Assert((ServerPlayer)n);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onChat(final ServerChatEvent ev){
|
||||
if(ev.getPlayer().level().isClientSide)return;
|
||||
// Player has chatted, apply override
|
||||
if(!OTEServerConfig.USE_CUSTOM_CHATREPLACER.get()) return;
|
||||
|
||||
|
||||
ServerPlayer sp = ev.getPlayer();
|
||||
// Get profile
|
||||
Profile XD=null;
|
||||
try {
|
||||
XD = Profile.get_profile_of(sp.getStringUUID());
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Override the chat!
|
||||
String prefixStr = "";
|
||||
if(XD.prefix != ""){
|
||||
prefixStr = ChatColor.DARK_GRAY + "[" + ChatColor.BOLD + XD.prefix_color + XD.prefix + ChatColor.resetChat() + ChatColor.DARK_GRAY + "] ";
|
||||
}
|
||||
|
||||
String msg = ev.getRawText();
|
||||
msg= ChatColor.doColors(msg);
|
||||
|
||||
String nameStr = ChatColor.resetChat() + "< "+ XD.name_color + XD.nickname + ChatColor.resetChat() + " >";
|
||||
String message = ": "+XD.chat_color + msg;
|
||||
Style hover = Style.EMPTY;
|
||||
hover=hover.withFont(Style.DEFAULT_FONT).withHoverEvent(HoverTip.get(ChatColor.MINECOIN_GOLD+"User Name: "+XD.username));
|
||||
ev.setCanceled(true);
|
||||
|
||||
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.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.RenderType;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
|
@ -1,110 +1,110 @@
|
|||
package dev.zontreck.thresholds.commands;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.commands.items.ShareItemInChatCommand;
|
||||
import dev.zontreck.thresholds.commands.profilecmds.ChatColorCommand;
|
||||
import dev.zontreck.thresholds.commands.profilecmds.NameColorCommand;
|
||||
import dev.zontreck.thresholds.commands.profilecmds.NickCommand;
|
||||
import dev.zontreck.thresholds.commands.profilecmds.PrefixColorCommand;
|
||||
import dev.zontreck.thresholds.commands.profilecmds.PrefixCommand;
|
||||
import dev.zontreck.thresholds.commands.vaults.StarterCommand;
|
||||
import dev.zontreck.thresholds.commands.vaults.TrashCommand;
|
||||
import dev.zontreck.thresholds.commands.vaults.VaultCommand;
|
||||
import dev.zontreck.thresholds.commands.zschem.LoadSchem;
|
||||
import dev.zontreck.thresholds.commands.zschem.Place;
|
||||
import dev.zontreck.thresholds.commands.zschem.PlaceAsAir;
|
||||
import dev.zontreck.thresholds.commands.zschem.SaveSchem;
|
||||
import dev.zontreck.thresholds.commands.zschem.SetPos1;
|
||||
import dev.zontreck.thresholds.commands.zschem.SetPos2;
|
||||
import dev.zontreck.thresholds.configs.ThresholdsServerConfig;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
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 CommandRegistry {
|
||||
public static Map<String,Long> CommandCooldownRegistry = new HashMap<>();
|
||||
|
||||
public static void markUsed(String cmd)
|
||||
{
|
||||
// Command was used, mark the current time
|
||||
CommandCooldownRegistry.put(cmd, Instant.now().getEpochSecond());
|
||||
}
|
||||
|
||||
public static boolean canUse(String cmd)
|
||||
{
|
||||
if(!CommandCooldownRegistry.containsKey(cmd)) return true;
|
||||
long lastUse = CommandCooldownRegistry.get(cmd);
|
||||
switch(cmd)
|
||||
{
|
||||
case "rtp":
|
||||
{
|
||||
if(Instant.now().getEpochSecond() > lastUse+Long.parseLong(String.valueOf(ThresholdsServerConfig.RTP_COOLDOWN))){
|
||||
CommandCooldownRegistry.remove(cmd);
|
||||
return true;
|
||||
}else return false;
|
||||
}
|
||||
default:
|
||||
{
|
||||
CommandCooldownRegistry.remove(cmd);
|
||||
return true; // cooldown not yet made
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public static String getRemaining(String string) {
|
||||
long now = Instant.now().getEpochSecond();
|
||||
if(!CommandCooldownRegistry.containsKey(string))return "0";
|
||||
long used = CommandCooldownRegistry.get(string);
|
||||
long cmd_time = 0L;
|
||||
switch(string)
|
||||
{
|
||||
case "rtp":
|
||||
{
|
||||
cmd_time = Long.parseLong(String.valueOf(ThresholdsServerConfig.RTP_COOLDOWN));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
cmd_time = 0L;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
used+=cmd_time;
|
||||
long diff = used-now;
|
||||
if(diff<0)diff=0L;
|
||||
return String.valueOf(diff);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRegisterCommands(final RegisterCommandsEvent ev)
|
||||
{
|
||||
|
||||
ChatColorCommand.register(ev.getDispatcher());
|
||||
NameColorCommand.register(ev.getDispatcher());
|
||||
PrefixColorCommand.register(ev.getDispatcher());
|
||||
PrefixCommand.register(ev.getDispatcher());
|
||||
NickCommand.register(ev.getDispatcher());
|
||||
|
||||
|
||||
|
||||
VaultCommand.register(ev.getDispatcher());
|
||||
TrashCommand.register(ev.getDispatcher());
|
||||
|
||||
SetPos1.register(ev.getDispatcher());
|
||||
SetPos2.register(ev.getDispatcher());
|
||||
SaveSchem.register(ev.getDispatcher());
|
||||
LoadSchem.register(ev.getDispatcher());
|
||||
Place.register(ev.getDispatcher());
|
||||
PlaceAsAir.register(ev.getDispatcher());
|
||||
|
||||
ShareItemInChatCommand.register(ev.getDispatcher());
|
||||
StarterCommand.register(ev.getDispatcher());
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.commands;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.commands.items.ShareItemInChatCommand;
|
||||
import dev.zontreck.otemod.commands.profilecmds.ChatColorCommand;
|
||||
import dev.zontreck.otemod.commands.profilecmds.NameColorCommand;
|
||||
import dev.zontreck.otemod.commands.profilecmds.NickCommand;
|
||||
import dev.zontreck.otemod.commands.profilecmds.PrefixColorCommand;
|
||||
import dev.zontreck.otemod.commands.profilecmds.PrefixCommand;
|
||||
import dev.zontreck.otemod.commands.vaults.StarterCommand;
|
||||
import dev.zontreck.otemod.commands.vaults.TrashCommand;
|
||||
import dev.zontreck.otemod.commands.vaults.VaultCommand;
|
||||
import dev.zontreck.otemod.commands.zschem.LoadSchem;
|
||||
import dev.zontreck.otemod.commands.zschem.Place;
|
||||
import dev.zontreck.otemod.commands.zschem.PlaceAsAir;
|
||||
import dev.zontreck.otemod.commands.zschem.SaveSchem;
|
||||
import dev.zontreck.otemod.commands.zschem.SetPos1;
|
||||
import dev.zontreck.otemod.commands.zschem.SetPos2;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
|
||||
@EventBusSubscriber(modid=OTEMod.MOD_ID,bus=Mod.EventBusSubscriber.Bus.FORGE)
|
||||
public class CommandRegistry {
|
||||
public static Map<String,Long> CommandCooldownRegistry = new HashMap<>();
|
||||
|
||||
public static void markUsed(String cmd)
|
||||
{
|
||||
// Command was used, mark the current time
|
||||
CommandCooldownRegistry.put(cmd, Instant.now().getEpochSecond());
|
||||
}
|
||||
|
||||
public static boolean canUse(String cmd)
|
||||
{
|
||||
if(!CommandCooldownRegistry.containsKey(cmd)) return true;
|
||||
long lastUse = CommandCooldownRegistry.get(cmd);
|
||||
switch(cmd)
|
||||
{
|
||||
case "rtp":
|
||||
{
|
||||
if(Instant.now().getEpochSecond() > lastUse+Long.parseLong(String.valueOf(OTEServerConfig.RTP_COOLDOWN))){
|
||||
CommandCooldownRegistry.remove(cmd);
|
||||
return true;
|
||||
}else return false;
|
||||
}
|
||||
default:
|
||||
{
|
||||
CommandCooldownRegistry.remove(cmd);
|
||||
return true; // cooldown not yet made
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public static String getRemaining(String string) {
|
||||
long now = Instant.now().getEpochSecond();
|
||||
if(!CommandCooldownRegistry.containsKey(string))return "0";
|
||||
long used = CommandCooldownRegistry.get(string);
|
||||
long cmd_time = 0L;
|
||||
switch(string)
|
||||
{
|
||||
case "rtp":
|
||||
{
|
||||
cmd_time = Long.parseLong(String.valueOf(OTEServerConfig.RTP_COOLDOWN));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
cmd_time = 0L;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
used+=cmd_time;
|
||||
long diff = used-now;
|
||||
if(diff<0)diff=0L;
|
||||
return String.valueOf(diff);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRegisterCommands(final RegisterCommandsEvent ev)
|
||||
{
|
||||
|
||||
ChatColorCommand.register(ev.getDispatcher());
|
||||
NameColorCommand.register(ev.getDispatcher());
|
||||
PrefixColorCommand.register(ev.getDispatcher());
|
||||
PrefixCommand.register(ev.getDispatcher());
|
||||
NickCommand.register(ev.getDispatcher());
|
||||
|
||||
|
||||
|
||||
VaultCommand.register(ev.getDispatcher());
|
||||
TrashCommand.register(ev.getDispatcher());
|
||||
|
||||
SetPos1.register(ev.getDispatcher());
|
||||
SetPos2.register(ev.getDispatcher());
|
||||
SaveSchem.register(ev.getDispatcher());
|
||||
LoadSchem.register(ev.getDispatcher());
|
||||
Place.register(ev.getDispatcher());
|
||||
PlaceAsAir.register(ev.getDispatcher());
|
||||
|
||||
ShareItemInChatCommand.register(ev.getDispatcher());
|
||||
StarterCommand.register(ev.getDispatcher());
|
||||
}
|
||||
}
|
|
@ -1,52 +1,52 @@
|
|||
package dev.zontreck.thresholds.commands;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class FlyCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("fly").executes(FlyCommand::Fly));
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
private static int Fly(CommandContext<CommandSourceStack> ctx2)
|
||||
{
|
||||
// Request homes
|
||||
// String homeName = "";
|
||||
// CommandSourceStack ctx = ctx2.getSource();
|
||||
// homeName = StringArgumentType.getString(ctx2, "nickname");
|
||||
// if(homeName==null)return 0;
|
||||
CommandSourceStack ctx = ctx2.getSource();
|
||||
|
||||
ServerPlayer p = (ServerPlayer)ctx.getEntity();
|
||||
if(p==null)return 1;
|
||||
|
||||
if(p.getAbilities().mayfly){
|
||||
p.getAbilities().mayfly=false;
|
||||
p.getAbilities().flying=false;
|
||||
p.onUpdateAbilities();
|
||||
|
||||
|
||||
ctx.sendSystemMessage(Component.literal(ThresholdsMod.ThresholdsPrefix + ChatColor.DARK_PURPLE + " Your ability to fly has been disabled"));
|
||||
}else {
|
||||
p.getAbilities().mayfly=true;
|
||||
p.onUpdateAbilities();
|
||||
|
||||
ctx.sendSystemMessage(Component.literal(ThresholdsMod.ThresholdsPrefix + ChatColor.DARK_PURPLE + " You can now fly"));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
package dev.zontreck.otemod.commands;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class FlyCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("fly").executes(FlyCommand::Fly));
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
private static int Fly(CommandContext<CommandSourceStack> ctx2)
|
||||
{
|
||||
// Request homes
|
||||
// String homeName = "";
|
||||
// CommandSourceStack ctx = ctx2.getSource();
|
||||
// homeName = StringArgumentType.getString(ctx2, "nickname");
|
||||
// if(homeName==null)return 0;
|
||||
CommandSourceStack ctx = ctx2.getSource();
|
||||
|
||||
ServerPlayer p = (ServerPlayer)ctx.getEntity();
|
||||
if(p==null)return 1;
|
||||
|
||||
if(p.getAbilities().mayfly){
|
||||
p.getAbilities().mayfly=false;
|
||||
p.getAbilities().flying=false;
|
||||
p.onUpdateAbilities();
|
||||
|
||||
|
||||
ctx.sendSystemMessage(Component.literal(OTEMod.OTEPrefix + ChatColor.DARK_PURPLE + " Your ability to fly has been disabled"));
|
||||
}else {
|
||||
p.getAbilities().mayfly=true;
|
||||
p.onUpdateAbilities();
|
||||
|
||||
ctx.sendSystemMessage(Component.literal(OTEMod.OTEPrefix + ChatColor.DARK_PURPLE + " You can now fly"));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
package dev.zontreck.thresholds.commands.antigrief;
|
||||
|
||||
// This will accelerate the healing queue, not do it instantly!
|
||||
// The queue will get processed at a rate of 10* the configured rate.
|
||||
public class HealNow
|
||||
{
|
||||
|
||||
}
|
||||
package dev.zontreck.otemod.commands.antigrief;
|
||||
|
||||
// This will accelerate the healing queue, not do it instantly!
|
||||
// The queue will get processed at a rate of 10* the configured rate.
|
||||
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 dev.zontreck.libzontreck.chat.HoverTip;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
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.Commands;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
@ -36,7 +36,7 @@ public class ShareItemInChatCommand {
|
|||
ItemStack is = play.getItemInHand(InteractionHand.MAIN_HAND);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -47,11 +47,11 @@ public class ShareItemInChatCommand {
|
|||
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);
|
||||
component = component.withStyle(style.withHoverEvent(HoverTip.getItem(is)));
|
||||
|
||||
ChatHelpers.broadcast(component, ThresholdsMod.THE_SERVER);
|
||||
ChatHelpers.broadcast(component, OTEMod.THE_SERVER);
|
||||
|
||||
}else {
|
||||
return 1;
|
|
@ -1,59 +1,60 @@
|
|||
package dev.zontreck.thresholds.commands.profilecmds;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor.ColorOptions;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.thresholds.implementation.Messages;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.server.command.EnumArgument;
|
||||
|
||||
public class ChatColorCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("chat_color")
|
||||
.executes(c->setchatcolor(c.getSource(), ColorOptions.White))
|
||||
.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");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
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
|
||||
String colorcoded = ChatColor.from(string);
|
||||
|
||||
// Get profile
|
||||
if(!(source.getEntity() instanceof Player)){
|
||||
return 1;
|
||||
}
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
Profile p;
|
||||
try {
|
||||
p = Profile.get_profile_of(play.getStringUUID());
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
return 1;
|
||||
}
|
||||
p.chat_color = colorcoded;
|
||||
p.commit();
|
||||
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
||||
|
||||
ChatHelpers.broadcastTo(play, ChatHelpers.macro(Messages.CHAT_COLOR_UPDATED), source.getServer());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.commands.profilecmds;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor.ColorOptions;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.Messages;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.server.command.EnumArgument;
|
||||
|
||||
public class ChatColorCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("chat_color")
|
||||
.executes(c->setchatcolor(c.getSource(), ColorOptions.White))
|
||||
.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");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
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
|
||||
String colorcoded = ChatColor.from(string);
|
||||
|
||||
// Get profile
|
||||
if(!(source.getEntity() instanceof Player)){
|
||||
return 1;
|
||||
}
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
Profile p;
|
||||
try {
|
||||
p = Profile.get_profile_of(play.getStringUUID());
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
return 1;
|
||||
}
|
||||
p.chat_color = colorcoded;
|
||||
p.commit();
|
||||
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
||||
|
||||
ChatHelpers.broadcastTo(play, ChatHelpers.macro(Messages.CHAT_COLOR_UPDATED), source.getServer());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,60 +1,61 @@
|
|||
package dev.zontreck.thresholds.commands.profilecmds;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor.ColorOptions;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.thresholds.implementation.Messages;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.server.command.EnumArgument;
|
||||
|
||||
public class NameColorCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("nick_color")
|
||||
.executes(c->setchatcolor(c.getSource(), ColorOptions.White))
|
||||
.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");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
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
|
||||
String colorcoded = ChatColor.from(string);
|
||||
|
||||
// Get profile
|
||||
if(!(source.getEntity() instanceof Player)){
|
||||
return 1;
|
||||
}
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
Profile p;
|
||||
try {
|
||||
p = Profile.get_profile_of(play.getStringUUID());
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
return 1;
|
||||
}
|
||||
p.name_color = colorcoded;
|
||||
p.commit();
|
||||
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
||||
|
||||
|
||||
ChatHelpers.broadcastTo(play, ChatHelpers.macro(Messages.NAME_COLOR_UPDATED), source.getServer());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.commands.profilecmds;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor.ColorOptions;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.Messages;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.server.command.EnumArgument;
|
||||
|
||||
public class NameColorCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("nick_color")
|
||||
.executes(c->setchatcolor(c.getSource(), ColorOptions.White))
|
||||
.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");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
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
|
||||
String colorcoded = ChatColor.from(string);
|
||||
|
||||
// Get profile
|
||||
if(!(source.getEntity() instanceof Player)){
|
||||
return 1;
|
||||
}
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
Profile p;
|
||||
try {
|
||||
p = Profile.get_profile_of(play.getStringUUID());
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
return 1;
|
||||
}
|
||||
p.name_color = colorcoded;
|
||||
p.commit();
|
||||
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
||||
|
||||
|
||||
ChatHelpers.broadcastTo(play, ChatHelpers.macro(Messages.NAME_COLOR_UPDATED), source.getServer());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,55 +1,57 @@
|
|||
package dev.zontreck.thresholds.commands.profilecmds;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.thresholds.implementation.Messages;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public class NickCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("nick")
|
||||
.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);
|
||||
//}));
|
||||
}
|
||||
|
||||
public static int setchatcolor(CommandSourceStack source, String string) {
|
||||
|
||||
// Get profile
|
||||
if(!(source.getEntity() instanceof Player)){
|
||||
return 1;
|
||||
}
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
|
||||
Profile p;
|
||||
try {
|
||||
p = Profile.get_profile_of(play.getStringUUID());
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
return 1;
|
||||
}
|
||||
p.nickname = string;
|
||||
p.commit();
|
||||
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
||||
|
||||
|
||||
ChatHelpers.broadcastTo(play, ChatHelpers.macro(Messages.NICK_UPDATED), source.getServer());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.commands.profilecmds;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.Messages;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public class NickCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("nick")
|
||||
.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);
|
||||
//}));
|
||||
}
|
||||
|
||||
public static int setchatcolor(CommandSourceStack source, String string) {
|
||||
|
||||
// Get profile
|
||||
if(!(source.getEntity() instanceof Player)){
|
||||
return 1;
|
||||
}
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
|
||||
Profile p;
|
||||
try {
|
||||
p = Profile.get_profile_of(play.getStringUUID());
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
return 1;
|
||||
}
|
||||
p.nickname = string;
|
||||
p.commit();
|
||||
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
||||
|
||||
|
||||
ChatHelpers.broadcastTo(play, ChatHelpers.macro(Messages.NICK_UPDATED), source.getServer());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,60 +1,61 @@
|
|||
package dev.zontreck.thresholds.commands.profilecmds;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor.ColorOptions;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.thresholds.implementation.Messages;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.server.command.EnumArgument;
|
||||
|
||||
public class PrefixColorCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("prefix_color")
|
||||
.executes(c->setchatcolor(c.getSource(), ColorOptions.White))
|
||||
.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");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
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
|
||||
String colorcoded = ChatColor.from(string);
|
||||
|
||||
// Get profile
|
||||
if(!(source.getEntity() instanceof Player)){
|
||||
return 1;
|
||||
}
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
|
||||
Profile p;
|
||||
try {
|
||||
p = Profile.get_profile_of(play.getStringUUID());
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
return 1;
|
||||
}
|
||||
p.prefix_color = colorcoded;
|
||||
p.commit();
|
||||
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
||||
|
||||
ChatHelpers.broadcastTo(play, ChatHelpers.macro(Messages.PREFIX_COLOR_UPDATED), source.getServer());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.commands.profilecmds;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor.ColorOptions;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.Messages;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.server.command.EnumArgument;
|
||||
|
||||
public class PrefixColorCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("prefix_color")
|
||||
.executes(c->setchatcolor(c.getSource(), ColorOptions.White))
|
||||
.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");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
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
|
||||
String colorcoded = ChatColor.from(string);
|
||||
|
||||
// Get profile
|
||||
if(!(source.getEntity() instanceof Player)){
|
||||
return 1;
|
||||
}
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
|
||||
Profile p;
|
||||
try {
|
||||
p = Profile.get_profile_of(play.getStringUUID());
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
return 1;
|
||||
}
|
||||
p.prefix_color = colorcoded;
|
||||
p.commit();
|
||||
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
||||
|
||||
ChatHelpers.broadcastTo(play, ChatHelpers.macro(Messages.PREFIX_COLOR_UPDATED), source.getServer());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,54 +1,56 @@
|
|||
package dev.zontreck.thresholds.commands.profilecmds;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.thresholds.implementation.Messages;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public class PrefixCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("prefix")
|
||||
.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);
|
||||
//}));
|
||||
}
|
||||
|
||||
public static int setchatcolor(CommandSourceStack source, String string) {
|
||||
|
||||
// Get profile
|
||||
if(!(source.getEntity() instanceof Player)){
|
||||
return 1;
|
||||
}
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
|
||||
Profile p;
|
||||
try {
|
||||
p = Profile.get_profile_of(play.getStringUUID());
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
return 1;
|
||||
}
|
||||
p.prefix = string;
|
||||
p.commit();
|
||||
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
||||
|
||||
ChatHelpers.broadcastTo(play, ChatHelpers.macro(Messages.PREFIX_UPDATED), source.getServer());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.commands.profilecmds;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.Messages;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public class PrefixCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("prefix")
|
||||
.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);
|
||||
//}));
|
||||
}
|
||||
|
||||
public static int setchatcolor(CommandSourceStack source, String string) {
|
||||
|
||||
// Get profile
|
||||
if(!(source.getEntity() instanceof Player)){
|
||||
return 1;
|
||||
}
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
|
||||
Profile p;
|
||||
try {
|
||||
p = Profile.get_profile_of(play.getStringUUID());
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
return 1;
|
||||
}
|
||||
p.prefix = string;
|
||||
p.commit();
|
||||
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
||||
|
||||
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.arguments.StringArgumentType;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.implementation.Messages;
|
||||
import dev.zontreck.thresholds.implementation.PlayerFirstJoinTag;
|
||||
import dev.zontreck.thresholds.implementation.vault.NoMoreVaultException;
|
||||
import dev.zontreck.thresholds.implementation.vault.StarterContainer;
|
||||
import dev.zontreck.thresholds.implementation.vault.VaultContainer;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import dev.zontreck.otemod.implementation.Messages;
|
||||
import dev.zontreck.otemod.implementation.PlayerFirstJoinTag;
|
||||
import dev.zontreck.otemod.implementation.vault.NoMoreVaultException;
|
||||
import dev.zontreck.otemod.implementation.vault.StarterContainer;
|
||||
import dev.zontreck.otemod.implementation.vault.VaultContainer;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
|
@ -18,6 +20,8 @@ import net.minecraft.server.level.ServerPlayer;
|
|||
import net.minecraft.world.SimpleMenuProvider;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
public class StarterCommand
|
||||
{
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
|
@ -46,7 +50,7 @@ public class StarterCommand
|
|||
|
||||
PFJT.save(prof.NBT);
|
||||
|
||||
ThresholdsMod.checkFirstJoin(player);
|
||||
OTEMod.checkFirstJoin(player);
|
||||
}
|
||||
|
||||
public static int openStarterMenu(CommandSourceStack ctx)
|
||||
|
@ -85,7 +89,7 @@ public class StarterCommand
|
|||
try {
|
||||
container = new StarterContainer(p);
|
||||
} 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;
|
||||
}
|
||||
|
|
@ -1,48 +1,48 @@
|
|||
package dev.zontreck.thresholds.commands.vaults;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.implementation.vault.NoMoreVaultException;
|
||||
import dev.zontreck.thresholds.implementation.vault.VaultContainer;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.SimpleMenuProvider;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
public class TrashCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("trash").executes(c-> vault(c.getSource())));
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
private static int vault(CommandSourceStack source) {
|
||||
//VaultContainer cont = new VaultContainer(i, source.getPlayer().getUUID());
|
||||
//cont.startOpen(source.getPlayer());
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
|
||||
VaultContainer container;
|
||||
try {
|
||||
container = new VaultContainer(play, -1);
|
||||
} catch (NoMoreVaultException e) {
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Red!You cannot open anymore vaults. Craft a new vault!"), play.server);
|
||||
return 0;
|
||||
}
|
||||
|
||||
NetworkHooks.openScreen(play, new SimpleMenuProvider(container.serverMenu, Component.literal("Trash")));
|
||||
|
||||
// Add to the master vault registry
|
||||
if(VaultContainer.VAULT_REGISTRY.containsKey(play.getUUID()))VaultContainer.VAULT_REGISTRY.remove(play.getUUID());
|
||||
VaultContainer.VAULT_REGISTRY.put(play.getUUID(), container);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.commands.vaults;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.vault.NoMoreVaultException;
|
||||
import dev.zontreck.otemod.implementation.vault.VaultContainer;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.SimpleMenuProvider;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
public class TrashCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("trash").executes(c-> vault(c.getSource())));
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
private static int vault(CommandSourceStack source) {
|
||||
//VaultContainer cont = new VaultContainer(i, source.getPlayer().getUUID());
|
||||
//cont.startOpen(source.getPlayer());
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
|
||||
VaultContainer container;
|
||||
try {
|
||||
container = new VaultContainer(play, -1);
|
||||
} catch (NoMoreVaultException e) {
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Red!You cannot open anymore vaults. Craft a new vault!"), play.server);
|
||||
return 0;
|
||||
}
|
||||
|
||||
NetworkHooks.openScreen(play, new SimpleMenuProvider(container.serverMenu, Component.literal("Trash")));
|
||||
|
||||
// Add to the master vault registry
|
||||
if(VaultContainer.VAULT_REGISTRY.containsKey(play.getUUID()))VaultContainer.VAULT_REGISTRY.remove(play.getUUID());
|
||||
VaultContainer.VAULT_REGISTRY.put(play.getUUID(), container);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,60 +1,60 @@
|
|||
package dev.zontreck.thresholds.commands.vaults;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.implementation.vault.NoMoreVaultException;
|
||||
import dev.zontreck.thresholds.implementation.vault.VaultContainer;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.SimpleMenuProvider;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
public class VaultCommand {
|
||||
|
||||
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("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 -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
private static int vault(CommandSourceStack source, int i) {
|
||||
//VaultContainer cont = new VaultContainer(i, source.getPlayer().getUUID());
|
||||
//cont.startOpen(source.getPlayer());
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
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());
|
||||
return 0;
|
||||
}
|
||||
doOpen(play, i);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void doOpen(ServerPlayer p, int i){
|
||||
|
||||
VaultContainer container;
|
||||
try {
|
||||
container = new VaultContainer(p, i);
|
||||
} catch (NoMoreVaultException e) {
|
||||
ChatHelpers.broadcastTo(p.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Red!You cannot open anymore vaults. Craft a new vault!"), p.server);
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkHooks.openScreen(p, new SimpleMenuProvider(container.serverMenu, Component.literal("Vault " + i)));
|
||||
|
||||
// Add to the master vault registry
|
||||
if(VaultContainer.VAULT_REGISTRY.containsKey(p.getUUID()))VaultContainer.VAULT_REGISTRY.remove(p.getUUID());
|
||||
VaultContainer.VAULT_REGISTRY.put(p.getUUID(), container);
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.commands.vaults;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.vault.NoMoreVaultException;
|
||||
import dev.zontreck.otemod.implementation.vault.VaultContainer;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.SimpleMenuProvider;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
public class VaultCommand {
|
||||
|
||||
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("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 -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
private static int vault(CommandSourceStack source, int i) {
|
||||
//VaultContainer cont = new VaultContainer(i, source.getPlayer().getUUID());
|
||||
//cont.startOpen(source.getPlayer());
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
if(i <0)
|
||||
{
|
||||
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;
|
||||
}
|
||||
doOpen(play, i);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void doOpen(ServerPlayer p, int i){
|
||||
|
||||
VaultContainer container;
|
||||
try {
|
||||
container = new VaultContainer(p, i);
|
||||
} catch (NoMoreVaultException e) {
|
||||
ChatHelpers.broadcastTo(p.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Red!You cannot open anymore vaults. Craft a new vault!"), p.server);
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkHooks.openScreen(p, new SimpleMenuProvider(container.serverMenu, Component.literal("Vault " + i)));
|
||||
|
||||
// Add to the master vault registry
|
||||
if(VaultContainer.VAULT_REGISTRY.containsKey(p.getUUID()))VaultContainer.VAULT_REGISTRY.remove(p.getUUID());
|
||||
VaultContainer.VAULT_REGISTRY.put(p.getUUID(), container);
|
||||
}
|
||||
}
|
|
@ -1,139 +1,139 @@
|
|||
package dev.zontreck.thresholds.commands.zschem;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.libzontreck.vectors.WorldPosition;
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.integrations.LuckPermsHelper;
|
||||
import dev.zontreck.thresholds.permissions.Permissions;
|
||||
import dev.zontreck.thresholds.zschem.MemoryHolder;
|
||||
import dev.zontreck.thresholds.zschem.MemoryHolder.Container;
|
||||
import dev.zontreck.thresholds.zschem.StoredBlock;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.fml.loading.FMLConfig;
|
||||
import net.minecraftforge.fml.loading.FMLPaths;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class LoadSchem {
|
||||
|
||||
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("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
private static int loadSchematic(CommandSourceStack source, String name) {
|
||||
// Perform sanity checks
|
||||
|
||||
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
if(play==null)return 1;
|
||||
|
||||
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_load)){
|
||||
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_load, Permissions.zschem);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(MemoryHolder.hasPlayerCached(play))
|
||||
{
|
||||
Container cont = MemoryHolder.getContainer(play);
|
||||
if(cont == null)
|
||||
{
|
||||
|
||||
loadSchematicUsage(source);
|
||||
}else {
|
||||
if(cont.Pos1 != ThresholdsMod.ZERO_VECTOR)
|
||||
{
|
||||
// Lets go!
|
||||
List<StoredBlock> blocks = new ArrayList<StoredBlock>();
|
||||
// First we calculate every vector between pos1 and pos2.
|
||||
// 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
|
||||
// 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
|
||||
|
||||
Path configDir = FMLPaths.GAMEDIR.get().resolve(FMLConfig.defaultConfigPath());
|
||||
configDir = configDir.resolve("ZSchems");
|
||||
File X = configDir.toFile();
|
||||
if(!X.exists())
|
||||
{
|
||||
X.mkdir();
|
||||
}
|
||||
configDir = configDir.resolve(name+"-zschem.nbt");
|
||||
|
||||
if(configDir.toFile().exists()){
|
||||
CompoundTag CT=new CompoundTag();
|
||||
try {
|
||||
CT = NbtIo.readCompressed(configDir.toFile());
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return 1;
|
||||
}
|
||||
|
||||
ListTag blst = CT.getList("blocks", CompoundTag.TAG_COMPOUND);
|
||||
Iterator<Tag> tags = blst.iterator();
|
||||
while(tags.hasNext())
|
||||
{
|
||||
CompoundTag nxt = (CompoundTag)tags.next();
|
||||
StoredBlock sb = new StoredBlock(nxt);
|
||||
ServerLevel pasteLvl = cont.lvl;
|
||||
sb.updateWorld(pasteLvl);
|
||||
|
||||
WorldPosition wp = sb.getWorldPosition();
|
||||
Vector3 superPos = cont.Pos1;
|
||||
wp.Position = superPos.add(wp.Position);
|
||||
sb.setPosition(wp.Position);
|
||||
|
||||
|
||||
blocks.add(sb);
|
||||
|
||||
}
|
||||
|
||||
MemoryHolder.setBlocks(play, blocks);
|
||||
|
||||
}else {
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix + " !Dark_Red!No such ZSchem exists!"), source.getServer());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Green!ZSchem loaded from disk!"), ThresholdsMod.THE_SERVER);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro("!Dark_Red! You must set the first position"), ThresholdsMod.THE_SERVER);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int loadSchematicUsage(CommandSourceStack source)
|
||||
{
|
||||
String usage = ThresholdsMod.ThresholdsPrefix;
|
||||
usage += "!gold! /loadzschem [string:name]";
|
||||
ServerPlayer play=(ServerPlayer)source.getEntity();
|
||||
if(play==null)return 1;
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(usage), ThresholdsMod.THE_SERVER);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.commands.zschem;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.libzontreck.vectors.WorldPosition;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.integrations.LuckPermsHelper;
|
||||
import dev.zontreck.otemod.permissions.Permissions;
|
||||
import dev.zontreck.otemod.zschem.MemoryHolder;
|
||||
import dev.zontreck.otemod.zschem.MemoryHolder.Container;
|
||||
import dev.zontreck.otemod.zschem.StoredBlock;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.fml.loading.FMLConfig;
|
||||
import net.minecraftforge.fml.loading.FMLPaths;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class LoadSchem {
|
||||
|
||||
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("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
private static int loadSchematic(CommandSourceStack source, String name) {
|
||||
// Perform sanity checks
|
||||
|
||||
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
if(play==null)return 1;
|
||||
|
||||
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_load)){
|
||||
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_load, Permissions.zschem);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(MemoryHolder.hasPlayerCached(play))
|
||||
{
|
||||
Container cont = MemoryHolder.getContainer(play);
|
||||
if(cont == null)
|
||||
{
|
||||
|
||||
loadSchematicUsage(source);
|
||||
}else {
|
||||
if(cont.Pos1 != OTEMod.ZERO_VECTOR)
|
||||
{
|
||||
// Lets go!
|
||||
List<StoredBlock> blocks = new ArrayList<StoredBlock>();
|
||||
// First we calculate every vector between pos1 and pos2.
|
||||
// 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
|
||||
// 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
|
||||
|
||||
Path configDir = FMLPaths.GAMEDIR.get().resolve(FMLConfig.defaultConfigPath());
|
||||
configDir = configDir.resolve("ZSchems");
|
||||
File X = configDir.toFile();
|
||||
if(!X.exists())
|
||||
{
|
||||
X.mkdir();
|
||||
}
|
||||
configDir = configDir.resolve(name+"-zschem.nbt");
|
||||
|
||||
if(configDir.toFile().exists()){
|
||||
CompoundTag CT=new CompoundTag();
|
||||
try {
|
||||
CT = NbtIo.readCompressed(configDir.toFile());
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return 1;
|
||||
}
|
||||
|
||||
ListTag blst = CT.getList("blocks", CompoundTag.TAG_COMPOUND);
|
||||
Iterator<Tag> tags = blst.iterator();
|
||||
while(tags.hasNext())
|
||||
{
|
||||
CompoundTag nxt = (CompoundTag)tags.next();
|
||||
StoredBlock sb = new StoredBlock(nxt);
|
||||
ServerLevel pasteLvl = cont.lvl;
|
||||
sb.updateWorld(pasteLvl);
|
||||
|
||||
WorldPosition wp = sb.getWorldPosition();
|
||||
Vector3 superPos = cont.Pos1;
|
||||
wp.Position = superPos.add(wp.Position);
|
||||
sb.setPosition(wp.Position);
|
||||
|
||||
|
||||
blocks.add(sb);
|
||||
|
||||
}
|
||||
|
||||
MemoryHolder.setBlocks(play, blocks);
|
||||
|
||||
}else {
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix + " !Dark_Red!No such ZSchem exists!"), source.getServer());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Green!ZSchem loaded from disk!"), OTEMod.THE_SERVER);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro("!Dark_Red! You must set the first position"), OTEMod.THE_SERVER);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int loadSchematicUsage(CommandSourceStack source)
|
||||
{
|
||||
String usage = OTEMod.OTEPrefix;
|
||||
usage += "!gold! /loadzschem [string:name]";
|
||||
ServerPlayer play=(ServerPlayer)source.getEntity();
|
||||
if(play==null)return 1;
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(usage), OTEMod.THE_SERVER);
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,75 +1,75 @@
|
|||
package dev.zontreck.thresholds.commands.zschem;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.integrations.LuckPermsHelper;
|
||||
import dev.zontreck.thresholds.permissions.Permissions;
|
||||
import dev.zontreck.thresholds.zschem.MemoryHolder;
|
||||
import dev.zontreck.thresholds.zschem.MemoryHolder.Container;
|
||||
import dev.zontreck.thresholds.zschem.StoredBlock;
|
||||
import dev.zontreck.thresholds.zschem.WorldProp;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
import java.util.Collections;
|
||||
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.
|
||||
public class Place {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("placezschem").executes(c-> place(c.getSource())));
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
private static int place(CommandSourceStack source) {
|
||||
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
if(play==null)return 1;
|
||||
|
||||
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_place)){
|
||||
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_place, Permissions.zschem);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!MemoryHolder.hasPlayerCached(play)){
|
||||
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Red!You must first load the zschem!"), ThresholdsMod.THE_SERVER);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Container cont = MemoryHolder.getContainer(play);
|
||||
List<StoredBlock> blocks = cont.blocks;
|
||||
Collections.shuffle(blocks);
|
||||
|
||||
if(cont.Pos1 != ThresholdsMod.ZERO_VECTOR)
|
||||
{
|
||||
WorldProp system = WorldProp.acquire(cont.lvl);
|
||||
// Begin the process
|
||||
for (StoredBlock storedBlock : blocks) {
|
||||
// alter the stored block and send it off to the queue system for the relevant world!
|
||||
|
||||
system.customEnqueue(storedBlock);
|
||||
}
|
||||
|
||||
}else {
|
||||
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Red!You must first load the zschem!"), ThresholdsMod.THE_SERVER);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Green!Enqueued!"), ThresholdsMod.THE_SERVER);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.commands.zschem;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.integrations.LuckPermsHelper;
|
||||
import dev.zontreck.otemod.permissions.Permissions;
|
||||
import dev.zontreck.otemod.zschem.MemoryHolder;
|
||||
import dev.zontreck.otemod.zschem.MemoryHolder.Container;
|
||||
import dev.zontreck.otemod.zschem.StoredBlock;
|
||||
import dev.zontreck.otemod.zschem.WorldProp;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
import java.util.Collections;
|
||||
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.
|
||||
public class Place {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("placezschem").executes(c-> place(c.getSource())));
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
private static int place(CommandSourceStack source) {
|
||||
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
if(play==null)return 1;
|
||||
|
||||
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_place)){
|
||||
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_place, Permissions.zschem);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!MemoryHolder.hasPlayerCached(play)){
|
||||
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Red!You must first load the zschem!"), OTEMod.THE_SERVER);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Container cont = MemoryHolder.getContainer(play);
|
||||
List<StoredBlock> blocks = cont.blocks;
|
||||
Collections.shuffle(blocks);
|
||||
|
||||
if(cont.Pos1 != OTEMod.ZERO_VECTOR)
|
||||
{
|
||||
WorldProp system = WorldProp.acquire(cont.lvl);
|
||||
// Begin the process
|
||||
for (StoredBlock storedBlock : blocks) {
|
||||
// alter the stored block and send it off to the queue system for the relevant world!
|
||||
|
||||
system.customEnqueue(storedBlock);
|
||||
}
|
||||
|
||||
}else {
|
||||
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Red!You must first load the zschem!"), OTEMod.THE_SERVER);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Green!Enqueued!"), OTEMod.THE_SERVER);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,82 +1,82 @@
|
|||
package dev.zontreck.thresholds.commands.zschem;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.integrations.LuckPermsHelper;
|
||||
import dev.zontreck.thresholds.permissions.Permissions;
|
||||
import dev.zontreck.thresholds.zschem.MemoryHolder;
|
||||
import dev.zontreck.thresholds.zschem.MemoryHolder.Container;
|
||||
import dev.zontreck.thresholds.zschem.StoredBlock;
|
||||
import dev.zontreck.thresholds.zschem.WorldProp;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
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.
|
||||
public class PlaceAsAir {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("zsetair").executes(c-> place(c.getSource())));
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
private static int place(CommandSourceStack source) {
|
||||
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
if(play==null)return 1;
|
||||
|
||||
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_air)){
|
||||
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_air, Permissions.zschem);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!MemoryHolder.hasPlayerCached(play)){
|
||||
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Red!You must first set the positions!"), ThresholdsMod.THE_SERVER);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Container cont = MemoryHolder.getContainer(play);
|
||||
|
||||
if(cont.Pos1 != ThresholdsMod.ZERO_VECTOR && cont.Pos2 != ThresholdsMod.ZERO_VECTOR)
|
||||
{
|
||||
WorldProp system = WorldProp.acquire(cont.lvl);
|
||||
// Begin the process
|
||||
List<Vector3> positions = cont.Pos1.makeCube(cont.Pos2);
|
||||
Collections.shuffle(positions);
|
||||
Iterator<Vector3> v3 = positions.iterator();
|
||||
|
||||
while(v3.hasNext())
|
||||
{
|
||||
Vector3 pos = v3.next();
|
||||
StoredBlock sb = new StoredBlock(pos.asBlockPos(), Blocks.AIR.defaultBlockState(), source.getLevel());
|
||||
system.customEnqueue(sb);
|
||||
}
|
||||
|
||||
|
||||
}else {
|
||||
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Red!You must first set the positions!"), ThresholdsMod.THE_SERVER);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Green!Enqueued!"), ThresholdsMod.THE_SERVER);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.commands.zschem;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.integrations.LuckPermsHelper;
|
||||
import dev.zontreck.otemod.permissions.Permissions;
|
||||
import dev.zontreck.otemod.zschem.MemoryHolder;
|
||||
import dev.zontreck.otemod.zschem.MemoryHolder.Container;
|
||||
import dev.zontreck.otemod.zschem.StoredBlock;
|
||||
import dev.zontreck.otemod.zschem.WorldProp;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
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.
|
||||
public class PlaceAsAir {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("zsetair").executes(c-> place(c.getSource())));
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
private static int place(CommandSourceStack source) {
|
||||
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
if(play==null)return 1;
|
||||
|
||||
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_air)){
|
||||
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_air, Permissions.zschem);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!MemoryHolder.hasPlayerCached(play)){
|
||||
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Red!You must first set the positions!"), OTEMod.THE_SERVER);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Container cont = MemoryHolder.getContainer(play);
|
||||
|
||||
if(cont.Pos1 != OTEMod.ZERO_VECTOR && cont.Pos2 != OTEMod.ZERO_VECTOR)
|
||||
{
|
||||
WorldProp system = WorldProp.acquire(cont.lvl);
|
||||
// Begin the process
|
||||
List<Vector3> positions = cont.Pos1.makeCube(cont.Pos2);
|
||||
Collections.shuffle(positions);
|
||||
Iterator<Vector3> v3 = positions.iterator();
|
||||
|
||||
while(v3.hasNext())
|
||||
{
|
||||
Vector3 pos = v3.next();
|
||||
StoredBlock sb = new StoredBlock(pos.asBlockPos(), Blocks.AIR.defaultBlockState(), source.getLevel());
|
||||
system.customEnqueue(sb);
|
||||
}
|
||||
|
||||
|
||||
}else {
|
||||
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Red!You must first set the positions!"), OTEMod.THE_SERVER);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Green!Enqueued!"), OTEMod.THE_SERVER);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,125 +1,125 @@
|
|||
package dev.zontreck.thresholds.commands.zschem;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.integrations.LuckPermsHelper;
|
||||
import dev.zontreck.thresholds.permissions.Permissions;
|
||||
import dev.zontreck.thresholds.zschem.MemoryHolder;
|
||||
import dev.zontreck.thresholds.zschem.MemoryHolder.Container;
|
||||
import dev.zontreck.thresholds.zschem.StoredBlock;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.fml.loading.FMLConfig;
|
||||
import net.minecraftforge.fml.loading.FMLPaths;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SaveSchem {
|
||||
|
||||
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("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
private static int saveSchematic(CommandSourceStack source, String name) {
|
||||
// Perform sanity checks
|
||||
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
if(play==null)return 1;
|
||||
|
||||
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_save)){
|
||||
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_save, Permissions.zschem);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(MemoryHolder.hasPlayerCached(play))
|
||||
{
|
||||
Container cont = MemoryHolder.getContainer(play);
|
||||
if(cont == null)
|
||||
{
|
||||
|
||||
saveSchematicUsage(source);
|
||||
}else {
|
||||
if(cont.Pos1 != ThresholdsMod.ZERO_VECTOR && cont.Pos2 != ThresholdsMod.ZERO_VECTOR)
|
||||
{
|
||||
// Lets go!
|
||||
List<StoredBlock> blocks = new ArrayList<StoredBlock>();
|
||||
// First we calculate every vector between pos1 and pos2.
|
||||
// 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
|
||||
// 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
|
||||
|
||||
List<Vector3> positions = cont.Pos1.makeCube(cont.Pos2);
|
||||
|
||||
for (Vector3 vector3 : positions) {
|
||||
Vector3 v3 = vector3.subtract(cont.Pos1);
|
||||
|
||||
BlockPos current = vector3.asBlockPos();
|
||||
|
||||
StoredBlock sb = new StoredBlock(current, cont.lvl.getBlockState(current), cont.lvl);
|
||||
sb.setPosition(v3);
|
||||
|
||||
blocks.add(sb);
|
||||
}
|
||||
|
||||
CompoundTag savedSchem = new CompoundTag();
|
||||
ListTag lst = new ListTag();
|
||||
for (StoredBlock sBlock : blocks) {
|
||||
lst.add(sBlock.serialize());
|
||||
}
|
||||
savedSchem.put("blocks", lst);
|
||||
|
||||
|
||||
Path configDir = FMLPaths.GAMEDIR.get().resolve(FMLConfig.defaultConfigPath());
|
||||
configDir = configDir.resolve("ZSchems");
|
||||
File X = configDir.toFile();
|
||||
if(!X.exists())
|
||||
{
|
||||
X.mkdir();
|
||||
}
|
||||
configDir = configDir.resolve(name+"-zschem.nbt");
|
||||
|
||||
// Save file!
|
||||
try {
|
||||
NbtIo.writeCompressed(savedSchem, configDir.toFile());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(ThresholdsMod.ThresholdsPrefix +" !Dark_Green!ZSchem saved to disk!"), ThresholdsMod.THE_SERVER);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro("!Dark_Red! You must first set the positions"), ThresholdsMod.THE_SERVER);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int saveSchematicUsage(CommandSourceStack source)
|
||||
{
|
||||
String usage = ThresholdsMod.ThresholdsPrefix;
|
||||
usage += "!gold! /savezschem [string:name]";
|
||||
ServerPlayer play=(ServerPlayer)source.getEntity();
|
||||
if(play==null)return 1;
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(usage), ThresholdsMod.THE_SERVER);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.commands.zschem;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.integrations.LuckPermsHelper;
|
||||
import dev.zontreck.otemod.permissions.Permissions;
|
||||
import dev.zontreck.otemod.zschem.MemoryHolder;
|
||||
import dev.zontreck.otemod.zschem.MemoryHolder.Container;
|
||||
import dev.zontreck.otemod.zschem.StoredBlock;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.fml.loading.FMLConfig;
|
||||
import net.minecraftforge.fml.loading.FMLPaths;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SaveSchem {
|
||||
|
||||
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("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
private static int saveSchematic(CommandSourceStack source, String name) {
|
||||
// Perform sanity checks
|
||||
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
if(play==null)return 1;
|
||||
|
||||
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_save)){
|
||||
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_save, Permissions.zschem);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(MemoryHolder.hasPlayerCached(play))
|
||||
{
|
||||
Container cont = MemoryHolder.getContainer(play);
|
||||
if(cont == null)
|
||||
{
|
||||
|
||||
saveSchematicUsage(source);
|
||||
}else {
|
||||
if(cont.Pos1 != OTEMod.ZERO_VECTOR && cont.Pos2 != OTEMod.ZERO_VECTOR)
|
||||
{
|
||||
// Lets go!
|
||||
List<StoredBlock> blocks = new ArrayList<StoredBlock>();
|
||||
// First we calculate every vector between pos1 and pos2.
|
||||
// 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
|
||||
// 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
|
||||
|
||||
List<Vector3> positions = cont.Pos1.makeCube(cont.Pos2);
|
||||
|
||||
for (Vector3 vector3 : positions) {
|
||||
Vector3 v3 = vector3.subtract(cont.Pos1);
|
||||
|
||||
BlockPos current = vector3.asBlockPos();
|
||||
|
||||
StoredBlock sb = new StoredBlock(current, cont.lvl.getBlockState(current), cont.lvl);
|
||||
sb.setPosition(v3);
|
||||
|
||||
blocks.add(sb);
|
||||
}
|
||||
|
||||
CompoundTag savedSchem = new CompoundTag();
|
||||
ListTag lst = new ListTag();
|
||||
for (StoredBlock sBlock : blocks) {
|
||||
lst.add(sBlock.serialize());
|
||||
}
|
||||
savedSchem.put("blocks", lst);
|
||||
|
||||
|
||||
Path configDir = FMLPaths.GAMEDIR.get().resolve(FMLConfig.defaultConfigPath());
|
||||
configDir = configDir.resolve("ZSchems");
|
||||
File X = configDir.toFile();
|
||||
if(!X.exists())
|
||||
{
|
||||
X.mkdir();
|
||||
}
|
||||
configDir = configDir.resolve(name+"-zschem.nbt");
|
||||
|
||||
// Save file!
|
||||
try {
|
||||
NbtIo.writeCompressed(savedSchem, configDir.toFile());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Green!ZSchem saved to disk!"), OTEMod.THE_SERVER);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro("!Dark_Red! You must first set the positions"), OTEMod.THE_SERVER);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int saveSchematicUsage(CommandSourceStack source)
|
||||
{
|
||||
String usage = OTEMod.OTEPrefix;
|
||||
usage += "!gold! /savezschem [string:name]";
|
||||
ServerPlayer play=(ServerPlayer)source.getEntity();
|
||||
if(play==null)return 1;
|
||||
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(usage), OTEMod.THE_SERVER);
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,44 +1,44 @@
|
|||
package dev.zontreck.thresholds.commands.zschem;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.integrations.LuckPermsHelper;
|
||||
import dev.zontreck.thresholds.permissions.Permissions;
|
||||
import dev.zontreck.thresholds.zschem.MemoryHolder;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class SetPos1 {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("zpos1").executes(c-> setzPos1(c.getSource())));
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
private static int setzPos1(CommandSourceStack source) {
|
||||
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
if(play==null)return 1;
|
||||
|
||||
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_pos1)){
|
||||
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_pos1, Permissions.zschem);
|
||||
return 1;
|
||||
}
|
||||
MemoryHolder.setPos1(play, new Vector3(source.getPosition()));
|
||||
MemoryHolder.setLevel(play, source.getLevel());
|
||||
|
||||
ChatHelpers.broadcastTo(play.getUUID(), Component.literal(ThresholdsMod.ThresholdsPrefix +ChatColor.doColors(" !Dark_Green!Position 1 set!")), ThresholdsMod.THE_SERVER);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.commands.zschem;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.integrations.LuckPermsHelper;
|
||||
import dev.zontreck.otemod.permissions.Permissions;
|
||||
import dev.zontreck.otemod.zschem.MemoryHolder;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class SetPos1 {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("zpos1").executes(c-> setzPos1(c.getSource())));
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
private static int setzPos1(CommandSourceStack source) {
|
||||
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
if(play==null)return 1;
|
||||
|
||||
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_pos1)){
|
||||
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_pos1, Permissions.zschem);
|
||||
return 1;
|
||||
}
|
||||
MemoryHolder.setPos1(play, new Vector3(source.getPosition()));
|
||||
MemoryHolder.setLevel(play, source.getLevel());
|
||||
|
||||
ChatHelpers.broadcastTo(play.getUUID(), Component.literal(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Position 1 set!")), OTEMod.THE_SERVER);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,44 +1,44 @@
|
|||
package dev.zontreck.thresholds.commands.zschem;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.integrations.LuckPermsHelper;
|
||||
import dev.zontreck.thresholds.permissions.Permissions;
|
||||
import dev.zontreck.thresholds.zschem.MemoryHolder;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class SetPos2 {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("zpos2").executes(c-> setzPos2(c.getSource())));
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
private static int setzPos2(CommandSourceStack source) {
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
if(play==null)return 1;
|
||||
|
||||
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_pos2)){
|
||||
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_pos2, Permissions.zschem);
|
||||
return 1;
|
||||
}
|
||||
|
||||
MemoryHolder.setPos2(play, new Vector3(source.getPosition()));
|
||||
MemoryHolder.setLevel(play, source.getLevel());
|
||||
|
||||
ChatHelpers.broadcastTo(play.getUUID(), Component.literal(ThresholdsMod.ThresholdsPrefix +ChatColor.doColors(" !Dark_Green!Position 2 set!")), ThresholdsMod.THE_SERVER);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.commands.zschem;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.integrations.LuckPermsHelper;
|
||||
import dev.zontreck.otemod.permissions.Permissions;
|
||||
import dev.zontreck.otemod.zschem.MemoryHolder;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class SetPos2 {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("zpos2").executes(c-> setzPos2(c.getSource())));
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
private static int setzPos2(CommandSourceStack source) {
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
if(play==null)return 1;
|
||||
|
||||
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_pos2)){
|
||||
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_pos2, Permissions.zschem);
|
||||
return 1;
|
||||
}
|
||||
|
||||
MemoryHolder.setPos2(play, new Vector3(source.getPosition()));
|
||||
MemoryHolder.setLevel(play, source.getLevel());
|
||||
|
||||
ChatHelpers.broadcastTo(play.getUUID(), Component.literal(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Position 2 set!")), OTEMod.THE_SERVER);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,95 +1,96 @@
|
|||
package dev.zontreck.thresholds.configs;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
|
||||
public class ThresholdsServerConfig {
|
||||
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<Integer> ITEM_DESPAWN_TIMER;
|
||||
|
||||
|
||||
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> TIME_BETWEEN_BLOCKS;
|
||||
public static final ForgeConfigSpec.ConfigValue<Integer> MAX_TRIES_HEAL;
|
||||
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.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> GIVE_KIT_EVERY_CHANGE;
|
||||
|
||||
public static final ForgeConfigSpec.ConfigValue<Boolean> DEBUG;
|
||||
|
||||
static {
|
||||
List<String> defaultExcludeDimensions = new ArrayList<String>();
|
||||
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("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();
|
||||
|
||||
|
||||
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);
|
||||
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);
|
||||
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.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
|
||||
|
||||
BUILDER.pop();
|
||||
BUILDER.push("ANTIGRIEF").comment("AntiGrief Explosion Healing Events");
|
||||
HEALER_TIMER = BUILDER.comment("Time between healing events (In Milliseconds)").define("timer", 250); // Should this be lower?
|
||||
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);
|
||||
|
||||
List<String> defDims = new ArrayList<String>();
|
||||
defDims.add("minecraft:the_end");
|
||||
defDims.add("minecraft:the_nether");
|
||||
defDims.add("thresholds:resource");
|
||||
EXCLUDE_DIMS = BUILDER.comment("Dimension names (ex. minecraft:overworld) to exclude from the explosion healing events").define("exclude_dimensions", defDims);
|
||||
|
||||
BUILDER.pop();
|
||||
|
||||
BUILDER.push("CHATSERVER");
|
||||
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();
|
||||
|
||||
SPEC=BUILDER.build();
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.configs;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
|
||||
public class OTEServerConfig {
|
||||
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<Integer> ITEM_DESPAWN_TIMER;
|
||||
|
||||
|
||||
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> TIME_BETWEEN_BLOCKS;
|
||||
public static final ForgeConfigSpec.ConfigValue<Integer> MAX_TRIES_HEAL;
|
||||
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.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> GIVE_KIT_EVERY_CHANGE;
|
||||
|
||||
public static final ForgeConfigSpec.ConfigValue<Boolean> DEBUG;
|
||||
|
||||
static {
|
||||
List<String> defaultExcludeDimensions = new ArrayList<String>();
|
||||
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("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();
|
||||
|
||||
|
||||
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);
|
||||
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);
|
||||
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.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
|
||||
|
||||
BUILDER.pop();
|
||||
BUILDER.push("ANTIGRIEF").comment("AntiGrief Explosion Healing Events");
|
||||
HEALER_TIMER = BUILDER.comment("Time between healing events (In Milliseconds)").define("timer", 250); // Should this be lower?
|
||||
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);
|
||||
|
||||
List<String> defDims = new ArrayList<String>();
|
||||
defDims.add("minecraft:the_end");
|
||||
defDims.add("minecraft:the_nether");
|
||||
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.push("CHATSERVER");
|
||||
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();
|
||||
|
||||
SPEC=BUILDER.build();
|
||||
}
|
||||
}
|
|
@ -1,27 +1,27 @@
|
|||
package dev.zontreck.thresholds.configs;
|
||||
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Abilities;
|
||||
|
||||
public class PlayerFlyCache
|
||||
{
|
||||
public boolean FlyEnabled;
|
||||
public boolean Flying;
|
||||
public static PlayerFlyCache cachePlayer(ServerPlayer play){
|
||||
PlayerFlyCache cache = new PlayerFlyCache();
|
||||
cache.FlyEnabled = play.getAbilities().mayfly;
|
||||
cache.Flying = play.getAbilities().flying;
|
||||
|
||||
play.onUpdateAbilities();
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
||||
public void Assert(ServerPlayer play){
|
||||
Abilities playerAbilities = play.getAbilities();
|
||||
playerAbilities.flying=Flying;
|
||||
playerAbilities.mayfly=FlyEnabled;
|
||||
|
||||
play.onUpdateAbilities();
|
||||
}
|
||||
package dev.zontreck.otemod.configs;
|
||||
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Abilities;
|
||||
|
||||
public class PlayerFlyCache
|
||||
{
|
||||
public boolean FlyEnabled;
|
||||
public boolean Flying;
|
||||
public static PlayerFlyCache cachePlayer(ServerPlayer play){
|
||||
PlayerFlyCache cache = new PlayerFlyCache();
|
||||
cache.FlyEnabled = play.getAbilities().mayfly;
|
||||
cache.Flying = play.getAbilities().flying;
|
||||
|
||||
play.onUpdateAbilities();
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
||||
public void Assert(ServerPlayer play){
|
||||
Abilities playerAbilities = play.getAbilities();
|
||||
playerAbilities.flying=Flying;
|
||||
playerAbilities.mayfly=FlyEnabled;
|
||||
|
||||
play.onUpdateAbilities();
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package dev.zontreck.thresholds.database;
|
||||
package dev.zontreck.otemod.database;
|
||||
|
||||
import java.io.IOException;
|
||||
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.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.util.ItemUtils;
|
||||
import dev.zontreck.libzontreck.util.ServerUtilities;
|
||||
import dev.zontreck.thresholds.enchantments.ModEnchantments;
|
||||
import dev.zontreck.thresholds.implementation.Messages;
|
||||
import dev.zontreck.otemod.enchantments.ModEnchantments;
|
||||
import dev.zontreck.otemod.implementation.Messages;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectCategory;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
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.Player;
|
||||
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.MobEffectCategory;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
|
@ -10,7 +10,7 @@ import net.minecraftforge.registries.RegistryObject;
|
|||
|
||||
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));
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dev.zontreck.thresholds.enchantments;
|
||||
package dev.zontreck.otemod.enchantments;
|
||||
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
|
@ -1,106 +1,117 @@
|
|||
package dev.zontreck.thresholds.enchantments;
|
||||
|
||||
import dev.zontreck.libzontreck.util.ItemUtils;
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.configs.ThresholdsServerConfig;
|
||||
import dev.zontreck.thresholds.effects.ModEffects;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = ThresholdsMod.MOD_ID)
|
||||
public class FlightEnchantment extends Enchantment
|
||||
{
|
||||
|
||||
public FlightEnchantment(EquipmentSlot... slots)
|
||||
{
|
||||
super(Rarity.VERY_RARE, EnchantmentCategory.ARMOR_FEET, slots);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinCost(int level)
|
||||
{
|
||||
return 28 + (level - 1) * 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxCost(int level)
|
||||
{
|
||||
return this.getMinCost(level) + 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTreasureOnly(){
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isTradeable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// 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
|
||||
public boolean isCurse()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static AtomicInteger TICKS = new AtomicInteger(0);
|
||||
@SubscribeEvent
|
||||
public static void onEnchantmentTick(TickEvent.PlayerTickEvent event)
|
||||
{
|
||||
if(event.side == LogicalSide.CLIENT) return;
|
||||
|
||||
if(TICKS.getAndIncrement() >= (5*20))
|
||||
{
|
||||
TICKS.set(0);
|
||||
|
||||
|
||||
|
||||
if(ThresholdsServerConfig.DEBUG.get())
|
||||
{
|
||||
ThresholdsMod.LOGGER.info("> Flight Enchantment Tick <");
|
||||
}
|
||||
|
||||
if(event.phase == TickEvent.Phase.END)
|
||||
{
|
||||
|
||||
ServerPlayer sp = (ServerPlayer) event.player;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
package dev.zontreck.otemod.enchantments;
|
||||
|
||||
import dev.zontreck.libzontreck.util.ItemUtils;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import dev.zontreck.otemod.effects.ModEffects;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.player.Abilities;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ArmorItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.item.enchantment.SoulSpeedEnchantment;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEquipmentChangeEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = OTEMod.MOD_ID)
|
||||
public class FlightEnchantment extends Enchantment
|
||||
{
|
||||
|
||||
public FlightEnchantment(EquipmentSlot... slots)
|
||||
{
|
||||
super(Rarity.VERY_RARE, EnchantmentCategory.ARMOR_FEET, slots);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinCost(int level)
|
||||
{
|
||||
return 28 + (level - 1) * 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxCost(int level)
|
||||
{
|
||||
return this.getMinCost(level) + 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTreasureOnly(){
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isTradeable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// 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
|
||||
public boolean isCurse()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static AtomicInteger TICKS = new AtomicInteger(0);
|
||||
@SubscribeEvent
|
||||
public static void onEnchantmentTick(TickEvent.PlayerTickEvent event)
|
||||
{
|
||||
if(event.side == LogicalSide.CLIENT) return;
|
||||
|
||||
if(TICKS.getAndIncrement() >= (5*20))
|
||||
{
|
||||
TICKS.set(0);
|
||||
|
||||
|
||||
|
||||
if(OTEServerConfig.DEBUG.get())
|
||||
{
|
||||
OTEMod.LOGGER.info("> Flight Enchantment Tick <");
|
||||
}
|
||||
|
||||
if(event.phase == TickEvent.Phase.END)
|
||||
{
|
||||
|
||||
ServerPlayer sp = (ServerPlayer) event.player;
|
||||
|
||||
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;
|
||||
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.configs.ThresholdsServerConfig;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||
|
||||
public class MobEggEnchantment extends Enchantment
|
||||
{
|
||||
public static final String TAG_BIAS = "mob_egging_bias";
|
||||
|
||||
public MobEggEnchantment()
|
||||
{
|
||||
super(Rarity.VERY_RARE, EnchantmentCategory.WEAPON, new EquipmentSlot[] {EquipmentSlot.MAINHAND});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinCost(int level)
|
||||
{
|
||||
return 28 + (level - 1) * 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 isTreasureOnly(){
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isTradeable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDiscoverable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean givesEgg(int level, int bias)
|
||||
{
|
||||
double CHANCE = ThresholdsServerConfig.SPAWN_EGG_CHANCE.get() * 100;
|
||||
|
||||
CHANCE *= (level / 0.5);
|
||||
CHANCE += bias;
|
||||
|
||||
double rng = Math.random()*100000;
|
||||
|
||||
if(ThresholdsServerConfig.DEBUG.get())
|
||||
{
|
||||
ThresholdsMod.LOGGER.info("Spawn Egg Chance (" + CHANCE + ") [" + rng + "]");
|
||||
}
|
||||
return (rng <= CHANCE);
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.enchantments;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.SwordItem;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||
|
||||
public class MobEggEnchantment extends Enchantment
|
||||
{
|
||||
public static final String TAG_BIAS = "mob_egging_bias";
|
||||
|
||||
public MobEggEnchantment()
|
||||
{
|
||||
super(Rarity.VERY_RARE, EnchantmentCategory.WEAPON, new EquipmentSlot[] {EquipmentSlot.MAINHAND});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinCost(int level)
|
||||
{
|
||||
return 28 + (level - 1) * 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 isTreasureOnly(){
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isTradeable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDiscoverable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean givesEgg(int level, int bias)
|
||||
{
|
||||
double CHANCE = OTEServerConfig.SPAWN_EGG_CHANCE.get() * 100;
|
||||
|
||||
CHANCE *= (level / 0.5);
|
||||
CHANCE += bias;
|
||||
|
||||
double rng = Math.random()*100000;
|
||||
|
||||
if(OTEServerConfig.DEBUG.get())
|
||||
{
|
||||
OTEMod.LOGGER.info("Spawn Egg Chance (" + CHANCE + ") [" + rng + "]");
|
||||
}
|
||||
return (rng <= CHANCE);
|
||||
}
|
||||
}
|
|
@ -1,28 +1,28 @@
|
|||
package dev.zontreck.thresholds.enchantments;
|
||||
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class ModEnchantments {
|
||||
|
||||
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 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> 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 void register(IEventBus bus){
|
||||
REGISTERS.register(bus);
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.enchantments;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class ModEnchantments {
|
||||
|
||||
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, OTEMod.MOD_ID);
|
||||
|
||||
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> 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 void register(IEventBus 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.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.configs.ThresholdsServerConfig;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import dev.zontreck.otemod.effects.ModEffects;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
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.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
@ -17,7 +19,7 @@ import net.minecraftforge.fml.common.Mod;
|
|||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = ThresholdsMod.MOD_ID)
|
||||
@Mod.EventBusSubscriber(modid = OTEMod.MOD_ID)
|
||||
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)
|
|
@ -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.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class ModEntityTypes {
|
||||
//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
|
|
@ -1,4 +1,4 @@
|
|||
package dev.zontreck.thresholds.entities.monsters.client;
|
||||
package dev.zontreck.otemod.entities.monsters.client;
|
||||
|
||||
|
||||
public class PossumModel
|
|
@ -1,4 +1,4 @@
|
|||
package dev.zontreck.thresholds.entities.monsters.client;
|
||||
package dev.zontreck.otemod.entities.monsters.client;
|
||||
|
||||
|
||||
public class PossumRenderer
|
|
@ -1,39 +1,39 @@
|
|||
package dev.zontreck.thresholds.events;
|
||||
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.integrations.KeyBindings;
|
||||
import dev.zontreck.thresholds.networking.ModMessages;
|
||||
import dev.zontreck.thresholds.networking.packets.OpenVaultC2SPacket;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.InputEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
public class ClientEvents {
|
||||
@Mod.EventBusSubscriber(modid = ThresholdsMod.MOD_ID, value = Dist.CLIENT)
|
||||
public static class ForgeEvents
|
||||
{
|
||||
// Timeout!
|
||||
static long lastPress;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onKeyInput(InputEvent.Key event)
|
||||
{
|
||||
//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())
|
||||
{
|
||||
lastPress = Instant.now().getEpochSecond();
|
||||
ModMessages.sendToServer(new OpenVaultC2SPacket(0, false, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Mod.EventBusSubscriber(modid = ThresholdsMod.MOD_ID, value=Dist.CLIENT, bus=Mod.EventBusSubscriber.Bus.MOD)
|
||||
public static class ClientModBus
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.events;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.integrations.KeyBindings;
|
||||
import dev.zontreck.otemod.networking.ModMessages;
|
||||
import dev.zontreck.otemod.networking.packets.OpenVaultC2SPacket;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.InputEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
public class ClientEvents {
|
||||
@Mod.EventBusSubscriber(modid = OTEMod.MOD_ID, value = Dist.CLIENT)
|
||||
public static class ForgeEvents
|
||||
{
|
||||
// Timeout!
|
||||
static long lastPress;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onKeyInput(InputEvent.Key event)
|
||||
{
|
||||
//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())
|
||||
{
|
||||
lastPress = Instant.now().getEpochSecond();
|
||||
ModMessages.sendToServer(new OpenVaultC2SPacket(0, false, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Mod.EventBusSubscriber(modid = OTEMod.MOD_ID, value=Dist.CLIENT, bus=Mod.EventBusSubscriber.Bus.MOD)
|
||||
public static class ClientModBus
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -1,138 +1,143 @@
|
|||
package dev.zontreck.thresholds.events;
|
||||
|
||||
import dev.zontreck.libzontreck.lore.LoreContainer;
|
||||
import dev.zontreck.libzontreck.lore.LoreEntry;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.util.ItemUtils;
|
||||
import dev.zontreck.libzontreck.util.heads.HeadUtilities;
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.configs.ThresholdsServerConfig;
|
||||
import dev.zontreck.thresholds.enchantments.MobEggEnchantment;
|
||||
import dev.zontreck.thresholds.enchantments.ModEnchantments;
|
||||
import dev.zontreck.thresholds.implementation.DeathMessages;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
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.enchantment.Enchantments;
|
||||
import net.minecraftforge.common.ForgeSpawnEggItem;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
|
||||
@Mod.EventBusSubscriber(modid= ThresholdsMod.MOD_ID)
|
||||
public class EventHandler {
|
||||
|
||||
|
||||
@SubscribeEvent (priority = EventPriority.HIGHEST)
|
||||
public static void playerDied(LivingDeathEvent event)
|
||||
{
|
||||
if(!(event.getEntity() instanceof Player))return;
|
||||
|
||||
Profile profile;
|
||||
try {
|
||||
profile = Profile.get_profile_of(event.getEntity().getStringUUID());
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
profile.deaths++;
|
||||
profile.commit();
|
||||
if(!ThresholdsServerConfig.ENABLE_PLAYER_HEAD_DROPS.get())
|
||||
{
|
||||
return;
|
||||
}
|
||||
int looting=0;
|
||||
//ServerPlayer killedPlayer = (ServerPlayer)ent;
|
||||
if(event.getEntity() instanceof Player){
|
||||
ServerPlayer pla = profile.player;
|
||||
looting = ItemUtils.getEnchantmentLevel(Enchantments.MOB_LOOTING, pla.getMainHandItem());
|
||||
|
||||
}
|
||||
|
||||
// Calculate chance
|
||||
double base_chance = ThresholdsServerConfig.CHANCE_OF_PLAYER_HEAD.get();
|
||||
base_chance += looting;
|
||||
base_chance *= 100;
|
||||
|
||||
Random rng = new Random();
|
||||
double num = rng.nextDouble(0,100000);
|
||||
if(num <= base_chance)
|
||||
{
|
||||
ItemStack head = HeadUtilities.get(profile.username, "").setHoverName(ChatHelpers.macro(profile.nickname+"'s Head"));
|
||||
LoreContainer lore = new LoreContainer(head);
|
||||
LoreEntry entry = new LoreEntry.Builder().bold(true).text(ChatHelpers.macroize("!dark_green!Player: " + profile.name_color+profile.username)).build();
|
||||
lore.miscData.loreData.add(entry);
|
||||
|
||||
entry = new LoreEntry.Builder().text(ChatHelpers.macroize("!Dark_Purple!Date: !Dark_Red![0]", Date.from(Instant.now()).toString())).build();
|
||||
lore.miscData.loreData.add(entry);
|
||||
|
||||
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();
|
||||
|
||||
|
||||
event.getEntity().spawnAtLocation(head);
|
||||
}
|
||||
|
||||
try {
|
||||
ChatHelpers.broadcast(Component.literal(DeathMessages.getRandomDeathMessage(Profile.get_profile_of(event.getEntity().getStringUUID()), event.getSource())), event.getEntity().level().getServer());
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEntityKilled(LivingDropsEvent ev){
|
||||
if(ev.getEntity().level().isClientSide)return;
|
||||
|
||||
Entity killedentity = ev.getEntity();
|
||||
Entity ent = ev.getSource().getEntity();
|
||||
if(ent instanceof Player)
|
||||
{
|
||||
ServerPlayer play = (ServerPlayer)ent;
|
||||
LivingEntity killed = ev.getEntity();
|
||||
|
||||
ItemStack stack = play.getMainHandItem();
|
||||
int levelOfEgging = ItemUtils.getEnchantmentLevel(ModEnchantments.MOB_EGGING_ENCHANTMENT.get(),stack);
|
||||
|
||||
if(levelOfEgging==0)return;
|
||||
CompoundTag tag = stack.getTag();
|
||||
int bias = tag.getInt(MobEggEnchantment.TAG_BIAS);
|
||||
|
||||
|
||||
if(MobEggEnchantment.givesEgg(levelOfEgging, bias))
|
||||
{
|
||||
bias=0;
|
||||
tag.putInt(MobEggEnchantment.TAG_BIAS, bias);
|
||||
// .25% chance
|
||||
// Check enchantment level for looting
|
||||
int level = ItemUtils.getEnchantmentLevel (Enchantments.MOB_LOOTING,stack);
|
||||
if(level==3){
|
||||
ItemStack egg = new ItemStack(ForgeSpawnEggItem.fromEntityType(killed.getType()));
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
package dev.zontreck.otemod.events;
|
||||
|
||||
import dev.zontreck.libzontreck.lore.LoreContainer;
|
||||
import dev.zontreck.libzontreck.lore.LoreEntry;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.util.ItemUtils;
|
||||
import dev.zontreck.libzontreck.util.heads.HeadUtilities;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import dev.zontreck.otemod.enchantments.MobEggEnchantment;
|
||||
import dev.zontreck.otemod.enchantments.ModEnchantments;
|
||||
import dev.zontreck.otemod.implementation.DeathMessages;
|
||||
import dev.zontreck.otemod.implementation.InventoryBackup;
|
||||
import dev.zontreck.otemod.items.tags.ItemStatType;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
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.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraftforge.common.ForgeSpawnEggItem;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
|
||||
@Mod.EventBusSubscriber(modid=OTEMod.MOD_ID)
|
||||
public class EventHandler {
|
||||
|
||||
|
||||
@SubscribeEvent (priority = EventPriority.HIGHEST)
|
||||
public static void playerDied(LivingDeathEvent event)
|
||||
{
|
||||
if(!(event.getEntity() instanceof Player))return;
|
||||
|
||||
Profile profile;
|
||||
try {
|
||||
profile = Profile.get_profile_of(event.getEntity().getStringUUID());
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
profile.deaths++;
|
||||
profile.commit();
|
||||
if(!OTEServerConfig.ENABLE_PLAYER_HEAD_DROPS.get())
|
||||
{
|
||||
return;
|
||||
}
|
||||
int looting=0;
|
||||
//ServerPlayer killedPlayer = (ServerPlayer)ent;
|
||||
if(event.getEntity() instanceof Player){
|
||||
ServerPlayer pla = profile.player;
|
||||
looting = ItemUtils.getEnchantmentLevel(Enchantments.MOB_LOOTING, pla.getMainHandItem());
|
||||
|
||||
}
|
||||
|
||||
// Calculate chance
|
||||
double base_chance = OTEServerConfig.CHANCE_OF_PLAYER_HEAD.get();
|
||||
base_chance += looting;
|
||||
base_chance *= 100;
|
||||
|
||||
Random rng = new Random();
|
||||
double num = rng.nextDouble(0,100000);
|
||||
if(num <= base_chance)
|
||||
{
|
||||
ItemStack head = HeadUtilities.get(profile.username, "").setHoverName(ChatHelpers.macro(profile.nickname+"'s Head"));
|
||||
LoreContainer lore = new LoreContainer(head);
|
||||
LoreEntry entry = new LoreEntry.Builder().bold(true).text(ChatHelpers.macroize("!dark_green!Player: " + profile.name_color+profile.username)).build();
|
||||
lore.miscData.loreData.add(entry);
|
||||
|
||||
entry = new LoreEntry.Builder().text(ChatHelpers.macroize("!Dark_Purple!Date: !Dark_Red![0]", Date.from(Instant.now()).toString())).build();
|
||||
lore.miscData.loreData.add(entry);
|
||||
|
||||
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();
|
||||
|
||||
|
||||
event.getEntity().spawnAtLocation(head);
|
||||
}
|
||||
|
||||
try {
|
||||
ChatHelpers.broadcast(Component.literal(DeathMessages.getRandomDeathMessage(Profile.get_profile_of(event.getEntity().getStringUUID()), event.getSource())), event.getEntity().level().getServer());
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEntityKilled(LivingDropsEvent ev){
|
||||
if(ev.getEntity().level().isClientSide)return;
|
||||
|
||||
Entity killedentity = ev.getEntity();
|
||||
Entity ent = ev.getSource().getEntity();
|
||||
if(ent instanceof Player)
|
||||
{
|
||||
ServerPlayer play = (ServerPlayer)ent;
|
||||
LivingEntity killed = ev.getEntity();
|
||||
|
||||
ItemStack stack = play.getMainHandItem();
|
||||
int levelOfEgging = ItemUtils.getEnchantmentLevel(ModEnchantments.MOB_EGGING_ENCHANTMENT.get(),stack);
|
||||
|
||||
if(levelOfEgging==0)return;
|
||||
CompoundTag tag = stack.getTag();
|
||||
int bias = tag.getInt(MobEggEnchantment.TAG_BIAS);
|
||||
|
||||
|
||||
if(MobEggEnchantment.givesEgg(levelOfEgging, bias))
|
||||
{
|
||||
bias=0;
|
||||
tag.putInt(MobEggEnchantment.TAG_BIAS, bias);
|
||||
// .25% chance
|
||||
// Check enchantment level for looting
|
||||
int level = ItemUtils.getEnchantmentLevel (Enchantments.MOB_LOOTING,stack);
|
||||
if(level==3){
|
||||
ItemStack egg = new ItemStack(ForgeSpawnEggItem.fromEntityType(killed.getType()));
|
||||
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;
|
||||
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
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 LoreHandlers {
|
||||
/*
|
||||
@SubscribeEvent
|
||||
public void onBlockMined(BlockEvent.BreakEvent ev)
|
||||
{
|
||||
if(ev.getLevel().isClientSide())return;
|
||||
|
||||
ServerPlayer sp = (ServerPlayer)ev.getPlayer();
|
||||
ItemStack itemUsed = sp.getItemInHand(InteractionHand.MAIN_HAND);
|
||||
ResourceLocation loc = ForgeRegistries.ITEMS.getKey(itemUsed.getItem());
|
||||
String itemModName = ChatHelpers.macroize("[0]:[1]", loc.getNamespace(), loc.getPath());
|
||||
if(itemModName.contains("pickaxe"))
|
||||
{
|
||||
updateItem(itemUsed, ItemStatType.PICK);
|
||||
}else if(itemModName.contains("shovel"))
|
||||
{
|
||||
updateItem(itemUsed, ItemStatType.SHOVEL);
|
||||
} else if(itemModName.contains("axe"))
|
||||
{
|
||||
updateItem(itemUsed, ItemStatType.AXE);
|
||||
} else if(itemModName.contains("pickadze"))
|
||||
{
|
||||
updateItem(itemUsed, ItemStatType.PICK);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onBlock(BlockEvent.BlockToolModificationEvent ev)
|
||||
{
|
||||
|
||||
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();
|
||||
ResourceLocation loc = ForgeRegistries.ITEMS.getKey(itemUsed.getItem());
|
||||
String itemModName = ChatHelpers.macroize("[0]:[1]", loc.getNamespace(), loc.getPath());
|
||||
|
||||
if(itemModName.contains("hoe"))
|
||||
{
|
||||
if(bs.is(Blocks.DIRT) || bs.is(Blocks.GRASS_BLOCK))
|
||||
{
|
||||
OTEMod.LOGGER.info("DIRT!");
|
||||
updateItem(itemUsed, ItemStatType.HOE);
|
||||
}
|
||||
} else if(itemModName.contains("shovel"))
|
||||
{
|
||||
if(bs.is(Blocks.GRASS_BLOCK))
|
||||
{
|
||||
updateItem(itemUsed, ItemStatType.SHOVELPATH);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onShears(PlayerInteractEvent.EntityInteract ev)
|
||||
{
|
||||
|
||||
if(ev.getLevel().isClientSide)return;
|
||||
if(ev.getCancellationResult() == InteractionResult.PASS)
|
||||
{
|
||||
// Check the entity right-clicked, and the item in hand
|
||||
|
||||
OTEMod.LOGGER.info("Success");
|
||||
ServerPlayer sp = (ServerPlayer)ev.getEntity();
|
||||
ItemStack itemUsed = sp.getMainHandItem();
|
||||
Entity target = ev.getTarget();
|
||||
ResourceLocation loc = ForgeRegistries.ITEMS.getKey(itemUsed.getItem());
|
||||
String itemModName = ChatHelpers.macroize("[0]:[1]", loc.getNamespace(), loc.getPath());
|
||||
ResourceLocation locEnt = ForgeRegistries.ENTITY_TYPES.getKey(ev.getTarget().getType());
|
||||
String entityModName = ChatHelpers.macroize("[0]:[1]", locEnt.getNamespace(), locEnt.getPath());
|
||||
if(itemModName.contains("shears"))
|
||||
{
|
||||
if(entityModName.contains("sheep"))
|
||||
{
|
||||
updateItem(itemUsed, ItemStatType.SHEARS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEntityKilled(LivingDeathEvent ev)
|
||||
{
|
||||
if(ev.getEntity().level().isClientSide)return;
|
||||
|
||||
// Handle two things
|
||||
|
||||
// 1. Update mob kill count on a sword if wielded.
|
||||
// 2. If mob, process randomness. If death by player with looting 3, 0.1% chance for a spawn egg to drop
|
||||
Entity source = ev.getSource().getEntity();
|
||||
ServerPlayer sp= null;
|
||||
if(source instanceof Player)
|
||||
{
|
||||
sp = (ServerPlayer)source;
|
||||
}
|
||||
|
||||
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"))
|
||||
{
|
||||
updateItem(weaponUsed, ItemStatType.SWORD);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Only valid to be used by OTEMod
|
||||
protected static void updateItem(ItemStack weaponUsed, ItemStatType type)
|
||||
{
|
||||
|
||||
// Update the mob kill count
|
||||
CompoundTag props = weaponUsed.getTag();
|
||||
if(props==null)props=new CompoundTag();
|
||||
CompoundTag container = props.getCompound(ItemStatTag.STATS_TAG+"_"+type.name().toLowerCase());
|
||||
LoreContainer contain = new LoreContainer(weaponUsed);
|
||||
|
||||
ItemStatTag isTag;
|
||||
try{
|
||||
isTag = new ItemStatTag(type, container.getInt(ItemStatTag.STATS_TAG+"_"+type.name().toLowerCase()));
|
||||
}catch (Exception e){
|
||||
isTag = new ItemStatTag(type, 0);
|
||||
}
|
||||
isTag.increment();
|
||||
LoreEntry entry;
|
||||
|
||||
if(contain.miscData.loreData.size()==0)
|
||||
{
|
||||
// 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();
|
||||
}*/
|
||||
}
|
||||
package dev.zontreck.otemod.events;
|
||||
|
||||
import dev.zontreck.libzontreck.lore.LoreContainer;
|
||||
import dev.zontreck.libzontreck.lore.LoreEntry;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.items.tags.ItemStatTag;
|
||||
import dev.zontreck.otemod.items.tags.ItemStatType;
|
||||
import dev.zontreck.otemod.items.tags.ItemStatistics;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.level.BlockEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
@EventBusSubscriber(modid=OTEMod.MOD_ID, bus=Mod.EventBusSubscriber.Bus.FORGE)
|
||||
public class LoreHandlers {
|
||||
/*
|
||||
@SubscribeEvent
|
||||
public void onBlockMined(BlockEvent.BreakEvent ev)
|
||||
{
|
||||
if(ev.getLevel().isClientSide())return;
|
||||
|
||||
ServerPlayer sp = (ServerPlayer)ev.getPlayer();
|
||||
ItemStack itemUsed = sp.getItemInHand(InteractionHand.MAIN_HAND);
|
||||
ResourceLocation loc = ForgeRegistries.ITEMS.getKey(itemUsed.getItem());
|
||||
String itemModName = ChatHelpers.macroize("[0]:[1]", loc.getNamespace(), loc.getPath());
|
||||
if(itemModName.contains("pickaxe"))
|
||||
{
|
||||
updateItem(itemUsed, ItemStatType.PICK);
|
||||
}else if(itemModName.contains("shovel"))
|
||||
{
|
||||
updateItem(itemUsed, ItemStatType.SHOVEL);
|
||||
} else if(itemModName.contains("axe"))
|
||||
{
|
||||
updateItem(itemUsed, ItemStatType.AXE);
|
||||
} else if(itemModName.contains("pickadze"))
|
||||
{
|
||||
updateItem(itemUsed, ItemStatType.PICK);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onBlock(BlockEvent.BlockToolModificationEvent ev)
|
||||
{
|
||||
|
||||
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();
|
||||
ResourceLocation loc = ForgeRegistries.ITEMS.getKey(itemUsed.getItem());
|
||||
String itemModName = ChatHelpers.macroize("[0]:[1]", loc.getNamespace(), loc.getPath());
|
||||
|
||||
if(itemModName.contains("hoe"))
|
||||
{
|
||||
if(bs.is(Blocks.DIRT) || bs.is(Blocks.GRASS_BLOCK))
|
||||
{
|
||||
OTEMod.LOGGER.info("DIRT!");
|
||||
updateItem(itemUsed, ItemStatType.HOE);
|
||||
}
|
||||
} else if(itemModName.contains("shovel"))
|
||||
{
|
||||
if(bs.is(Blocks.GRASS_BLOCK))
|
||||
{
|
||||
updateItem(itemUsed, ItemStatType.SHOVELPATH);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onShears(PlayerInteractEvent.EntityInteract ev)
|
||||
{
|
||||
|
||||
if(ev.getLevel().isClientSide)return;
|
||||
if(ev.getCancellationResult() == InteractionResult.PASS)
|
||||
{
|
||||
// Check the entity right-clicked, and the item in hand
|
||||
|
||||
OTEMod.LOGGER.info("Success");
|
||||
ServerPlayer sp = (ServerPlayer)ev.getEntity();
|
||||
ItemStack itemUsed = sp.getMainHandItem();
|
||||
Entity target = ev.getTarget();
|
||||
ResourceLocation loc = ForgeRegistries.ITEMS.getKey(itemUsed.getItem());
|
||||
String itemModName = ChatHelpers.macroize("[0]:[1]", loc.getNamespace(), loc.getPath());
|
||||
ResourceLocation locEnt = ForgeRegistries.ENTITY_TYPES.getKey(ev.getTarget().getType());
|
||||
String entityModName = ChatHelpers.macroize("[0]:[1]", locEnt.getNamespace(), locEnt.getPath());
|
||||
if(itemModName.contains("shears"))
|
||||
{
|
||||
if(entityModName.contains("sheep"))
|
||||
{
|
||||
updateItem(itemUsed, ItemStatType.SHEARS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEntityKilled(LivingDeathEvent ev)
|
||||
{
|
||||
if(ev.getEntity().level().isClientSide)return;
|
||||
|
||||
// Handle two things
|
||||
|
||||
// 1. Update mob kill count on a sword if wielded.
|
||||
// 2. If mob, process randomness. If death by player with looting 3, 0.1% chance for a spawn egg to drop
|
||||
Entity source = ev.getSource().getEntity();
|
||||
ServerPlayer sp= null;
|
||||
if(source instanceof Player)
|
||||
{
|
||||
sp = (ServerPlayer)source;
|
||||
}
|
||||
|
||||
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"))
|
||||
{
|
||||
updateItem(weaponUsed, ItemStatType.SWORD);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Only valid to be used by OTEMod
|
||||
protected static void updateItem(ItemStack weaponUsed, ItemStatType type)
|
||||
{
|
||||
|
||||
// Update the mob kill count
|
||||
CompoundTag props = weaponUsed.getTag();
|
||||
if(props==null)props=new CompoundTag();
|
||||
CompoundTag container = props.getCompound(ItemStatTag.STATS_TAG+"_"+type.name().toLowerCase());
|
||||
LoreContainer contain = new LoreContainer(weaponUsed);
|
||||
|
||||
ItemStatTag isTag;
|
||||
try{
|
||||
isTag = new ItemStatTag(type, container.getInt(ItemStatTag.STATS_TAG+"_"+type.name().toLowerCase()));
|
||||
}catch (Exception e){
|
||||
isTag = new ItemStatTag(type, 0);
|
||||
}
|
||||
isTag.increment();
|
||||
LoreEntry entry;
|
||||
|
||||
if(contain.miscData.loreData.size()==0)
|
||||
{
|
||||
// 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.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
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 {
|
||||
@SubscribeEvent
|
||||
public static void onMobAttributeCreation(EntityAttributeCreationEvent ev)
|
||||
{
|
||||
//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.thresholds.items.ModItems;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.items.ModItems;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
|
@ -9,16 +9,17 @@ import net.minecraft.world.item.Item;
|
|||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
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 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<>();
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dev.zontreck.thresholds.implementation;
|
||||
package dev.zontreck.otemod.implementation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -8,6 +8,7 @@ import dev.zontreck.libzontreck.profiles.Profile;
|
|||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.damagesource.DamageTypes;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
public class DeathMessages {
|
||||
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.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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 static boolean isMouseOver(double mouseX, double mouseY, int x, int y, int sizeX, int sizeY)
|
|
@ -1,44 +1,44 @@
|
|||
package dev.zontreck.thresholds.implementation;
|
||||
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
public class OutputItemStackHandler extends ItemStackHandler {
|
||||
private final ItemStackHandler internalSlot;
|
||||
|
||||
public OutputItemStackHandler(ItemStackHandler hidden) {
|
||||
super();
|
||||
internalSlot = hidden;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(int size) {
|
||||
stacks = NonNullList.<ItemStack>withSize(size, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStackInSlot(int slot, ItemStack stack) {
|
||||
internalSlot.setStackInSlot(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlots() {
|
||||
return internalSlot.getSlots();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return internalSlot.getStackInSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack extractItem(int slot, int amount, boolean simulate) {
|
||||
return internalSlot.extractItem(slot, amount, simulate);
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.implementation;
|
||||
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
public class OutputItemStackHandler extends ItemStackHandler {
|
||||
private final ItemStackHandler internalSlot;
|
||||
|
||||
public OutputItemStackHandler(ItemStackHandler hidden) {
|
||||
super();
|
||||
internalSlot = hidden;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(int size) {
|
||||
stacks = NonNullList.<ItemStack>withSize(size, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStackInSlot(int slot, ItemStack stack) {
|
||||
internalSlot.setStackInSlot(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlots() {
|
||||
return internalSlot.getSlots();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return internalSlot.getStackInSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack extractItem(int slot, int amount, boolean 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.LongTag;
|
|
@ -1,4 +1,4 @@
|
|||
package dev.zontreck.thresholds.implementation;
|
||||
package dev.zontreck.otemod.implementation;
|
||||
|
||||
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.thresholds.blocks.entity.CompressionChamberBlockEntity;
|
||||
import dev.zontreck.thresholds.implementation.inits.ModMenuTypes;
|
||||
import dev.zontreck.otemod.blocks.ModBlocks;
|
||||
import dev.zontreck.otemod.blocks.entity.CompressionChamberBlockEntity;
|
||||
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.network.FriendlyByteBuf;
|
||||
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 dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.implementation.MouseHelpers;
|
||||
import dev.zontreck.thresholds.implementation.energy.screenrenderer.EnergyInfoArea;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.MouseHelpers;
|
||||
import dev.zontreck.otemod.implementation.energy.screenrenderer.EnergyInfoArea;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
|
@ -16,7 +16,7 @@ import java.util.Optional;
|
|||
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;
|
||||
|
|
@ -1,42 +1,42 @@
|
|||
package dev.zontreck.thresholds.implementation.energy;
|
||||
|
||||
import net.minecraftforge.energy.EnergyStorage;
|
||||
|
||||
public abstract class OTEEnergy extends EnergyStorage
|
||||
{
|
||||
|
||||
public OTEEnergy(int capacity, int maxTransfer) {
|
||||
super(capacity, maxTransfer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(int max, boolean simulate)
|
||||
{
|
||||
int ex = super.extractEnergy(max, simulate);
|
||||
if(ex != 0){
|
||||
onChanged();
|
||||
}
|
||||
|
||||
return ex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(int max, boolean simulate)
|
||||
{
|
||||
int rcv = super.receiveEnergy(max, simulate);
|
||||
if(rcv!=0){
|
||||
onChanged();
|
||||
}
|
||||
|
||||
return rcv;
|
||||
}
|
||||
|
||||
public int setEnergy(int energy){
|
||||
this.energy=energy;
|
||||
onChanged();
|
||||
return energy;
|
||||
}
|
||||
|
||||
public abstract void onChanged();
|
||||
|
||||
}
|
||||
package dev.zontreck.otemod.implementation.energy;
|
||||
|
||||
import net.minecraftforge.energy.EnergyStorage;
|
||||
|
||||
public abstract class OTEEnergy extends EnergyStorage
|
||||
{
|
||||
|
||||
public OTEEnergy(int capacity, int maxTransfer) {
|
||||
super(capacity, maxTransfer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(int max, boolean simulate)
|
||||
{
|
||||
int ex = super.extractEnergy(max, simulate);
|
||||
if(ex != 0){
|
||||
onChanged();
|
||||
}
|
||||
|
||||
return ex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(int max, boolean simulate)
|
||||
{
|
||||
int rcv = super.receiveEnergy(max, simulate);
|
||||
if(rcv!=0){
|
||||
onChanged();
|
||||
}
|
||||
|
||||
return rcv;
|
||||
}
|
||||
|
||||
public int setEnergy(int energy){
|
||||
this.energy=energy;
|
||||
onChanged();
|
||||
return energy;
|
||||
}
|
||||
|
||||
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.renderer.Rect2i;
|
||||
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.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.thresholds.configs.ThresholdsServerConfig;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public class VaultCreatedEvent extends Event
|
||||
|
@ -16,7 +16,7 @@ public class VaultCreatedEvent extends Event
|
|||
|
||||
public VaultCreatedEvent(int num, Profile user, int vaultsInUse)
|
||||
{
|
||||
max= ThresholdsServerConfig.MAX_VAULTS.get();
|
||||
max=OTEServerConfig.MAX_VAULTS.get();
|
||||
vault_num = num;
|
||||
in_use = vaultsInUse;
|
||||
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;
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package dev.zontreck.thresholds.implementation.events;
|
||||
package dev.zontreck.otemod.implementation.events;
|
||||
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
public class VaultModifiedEvent extends VaultCreatedEvent
|
|
@ -1,41 +1,41 @@
|
|||
package dev.zontreck.thresholds.implementation.inits;
|
||||
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.implementation.compressor.CompressionChamberMenu;
|
||||
import dev.zontreck.thresholds.implementation.scrubber.ItemScrubberMenu;
|
||||
import dev.zontreck.thresholds.implementation.scrubber.MagicalScrubberMenu;
|
||||
import dev.zontreck.thresholds.implementation.vault.StarterMenu;
|
||||
import dev.zontreck.thresholds.implementation.vault.VaultMenu;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraftforge.common.extensions.IForgeMenuType;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.network.IContainerFactory;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public final class ModMenuTypes
|
||||
{
|
||||
public static final DeferredRegister<MenuType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.MENU_TYPES, ThresholdsMod.MOD_ID);
|
||||
|
||||
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<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<CompressionChamberMenu>> COMPRESSION_CHAMBER = registerMenuType(CompressionChamberMenu::new, "compression_chamber");
|
||||
|
||||
|
||||
private static <T extends AbstractContainerMenu> RegistryObject<MenuType<T>> registerMenuType(IContainerFactory<T> factory, String name)
|
||||
{
|
||||
return CONTAINERS.register(name, ()->IForgeMenuType.create(factory));
|
||||
}
|
||||
|
||||
public static void register(IEventBus bus)
|
||||
{
|
||||
CONTAINERS.register(bus);
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.implementation.inits;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.compressor.CompressionChamberMenu;
|
||||
import dev.zontreck.otemod.implementation.scrubber.ItemScrubberMenu;
|
||||
import dev.zontreck.otemod.implementation.scrubber.MagicalScrubberMenu;
|
||||
import dev.zontreck.otemod.implementation.vault.StarterMenu;
|
||||
import dev.zontreck.otemod.implementation.vault.VaultMenu;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraftforge.common.extensions.IForgeMenuType;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.network.IContainerFactory;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public final class ModMenuTypes
|
||||
{
|
||||
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<StarterMenu>> STARTER = registerMenuType(StarterMenu::new, "starter");
|
||||
|
||||
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<CompressionChamberMenu>> COMPRESSION_CHAMBER = registerMenuType(CompressionChamberMenu::new, "compression_chamber");
|
||||
|
||||
|
||||
private static <T extends AbstractContainerMenu> RegistryObject<MenuType<T>> registerMenuType(IContainerFactory<T> factory, String name)
|
||||
{
|
||||
return CONTAINERS.register(name, ()->IForgeMenuType.create(factory));
|
||||
}
|
||||
|
||||
public static void register(IEventBus bus)
|
||||
{
|
||||
CONTAINERS.register(bus);
|
||||
}
|
||||
}
|
|
@ -1,150 +1,150 @@
|
|||
package dev.zontreck.thresholds.implementation.scrubber;
|
||||
|
||||
import dev.zontreck.thresholds.blocks.ModBlocks;
|
||||
import dev.zontreck.thresholds.blocks.entity.ItemScrubberBlockEntity;
|
||||
import dev.zontreck.thresholds.implementation.inits.ModMenuTypes;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.*;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
|
||||
public class ItemScrubberMenu extends AbstractContainerMenu
|
||||
{
|
||||
public final ItemScrubberBlockEntity entity;
|
||||
private final Level level;
|
||||
private final ContainerData data;
|
||||
|
||||
public ItemScrubberMenu(int id, Inventory inv, FriendlyByteBuf buf)
|
||||
{
|
||||
this(id, inv, inv.player.level().getBlockEntity(buf.readBlockPos()), new SimpleContainerData(1));
|
||||
}
|
||||
|
||||
public ItemScrubberMenu(int id, Inventory inv, BlockEntity entity, ContainerData data){
|
||||
super(ModMenuTypes.SCRUBBER.get(), id);
|
||||
|
||||
checkContainerSize(inv, 1);
|
||||
this.entity = (ItemScrubberBlockEntity)entity;
|
||||
this.data=data;
|
||||
this.level = inv.player.level();
|
||||
|
||||
addPlayerInventory(inv);
|
||||
addPlayerHotbar(inv);
|
||||
|
||||
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.UP).ifPresent(handler->{
|
||||
addSlot(new SlotItemHandler(handler, 0, 16, 41));
|
||||
});
|
||||
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.DOWN).ifPresent(handler->{
|
||||
addSlot(new SlotItemHandler(handler, 0, 177, 41));
|
||||
});
|
||||
|
||||
addDataSlots(data);
|
||||
|
||||
}
|
||||
|
||||
public boolean isCrafting()
|
||||
{
|
||||
return data.get(0) > 0;
|
||||
}
|
||||
|
||||
public int getScaledProgress()
|
||||
{
|
||||
if(!isCrafting())return 0;
|
||||
int progress = this.data.get(0);
|
||||
int max = ItemScrubberBlockEntity.MAXIMUM_PROCESSING_TICKS;
|
||||
|
||||
int progressArrow = 125;
|
||||
|
||||
|
||||
if(progress != 0 && max != 0)
|
||||
{
|
||||
int percent = progress * progressArrow / max;
|
||||
return percent;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// CREDIT GOES TO: diesieben07 | https://github.com/diesieben07/SevenCommons
|
||||
// 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.
|
||||
// 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)
|
||||
// 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)
|
||||
private static final int HOTBAR_SLOT_COUNT = 9;
|
||||
private static final int PLAYER_INVENTORY_ROW_COUNT = 3;
|
||||
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 VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_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 = 2; // must be the number of slots you have!
|
||||
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player playerIn, int index) {
|
||||
Slot sourceSlot = slots.get(index);
|
||||
if (sourceSlot == null || !sourceSlot.hasItem()) return ItemStack.EMPTY; //EMPTY_ITEM
|
||||
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) {
|
||||
// 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
|
||||
+ 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
|
||||
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);
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
// If stack size == 0 (the entire stack was moved) set slot contents to null
|
||||
if (sourceStack.getCount() == 0) {
|
||||
sourceSlot.set(ItemStack.EMPTY);
|
||||
} else {
|
||||
sourceSlot.setChanged();
|
||||
}
|
||||
sourceSlot.onTake(playerIn, sourceStack);
|
||||
return copyOfSourceStack;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
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_LEFT = 24;
|
||||
private static final int PLAYER_HOTBAR_FIRST_SLOT = 125;
|
||||
|
||||
private void addPlayerInventory(Inventory inv)
|
||||
{
|
||||
for (int i = 0; i < 3; i++) {
|
||||
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)
|
||||
{
|
||||
for (int index = 0; index < 9; index++) {
|
||||
this.addSlot(new Slot(inv, index, PLAYER_INVENTORY_FIRST_SLOT_LEFT+index*18, PLAYER_HOTBAR_FIRST_SLOT));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
package dev.zontreck.otemod.implementation.scrubber;
|
||||
|
||||
import dev.zontreck.otemod.blocks.ModBlocks;
|
||||
import dev.zontreck.otemod.blocks.entity.ItemScrubberBlockEntity;
|
||||
import dev.zontreck.otemod.implementation.inits.ModMenuTypes;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.*;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
|
||||
public class ItemScrubberMenu extends AbstractContainerMenu
|
||||
{
|
||||
public final ItemScrubberBlockEntity entity;
|
||||
private final Level level;
|
||||
private final ContainerData data;
|
||||
|
||||
public ItemScrubberMenu(int id, Inventory inv, FriendlyByteBuf buf)
|
||||
{
|
||||
this(id, inv, inv.player.level().getBlockEntity(buf.readBlockPos()), new SimpleContainerData(1));
|
||||
}
|
||||
|
||||
public ItemScrubberMenu(int id, Inventory inv, BlockEntity entity, ContainerData data){
|
||||
super(ModMenuTypes.SCRUBBER.get(), id);
|
||||
|
||||
checkContainerSize(inv, 1);
|
||||
this.entity = (ItemScrubberBlockEntity)entity;
|
||||
this.data=data;
|
||||
this.level = inv.player.level();
|
||||
|
||||
addPlayerInventory(inv);
|
||||
addPlayerHotbar(inv);
|
||||
|
||||
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.UP).ifPresent(handler->{
|
||||
addSlot(new SlotItemHandler(handler, 0, 16, 41));
|
||||
});
|
||||
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.DOWN).ifPresent(handler->{
|
||||
addSlot(new SlotItemHandler(handler, 0, 177, 41));
|
||||
});
|
||||
|
||||
addDataSlots(data);
|
||||
|
||||
}
|
||||
|
||||
public boolean isCrafting()
|
||||
{
|
||||
return data.get(0) > 0;
|
||||
}
|
||||
|
||||
public int getScaledProgress()
|
||||
{
|
||||
if(!isCrafting())return 0;
|
||||
int progress = this.data.get(0);
|
||||
int max = ItemScrubberBlockEntity.MAXIMUM_PROCESSING_TICKS;
|
||||
|
||||
int progressArrow = 125;
|
||||
|
||||
|
||||
if(progress != 0 && max != 0)
|
||||
{
|
||||
int percent = progress * progressArrow / max;
|
||||
return percent;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// CREDIT GOES TO: diesieben07 | https://github.com/diesieben07/SevenCommons
|
||||
// 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.
|
||||
// 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)
|
||||
// 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)
|
||||
private static final int HOTBAR_SLOT_COUNT = 9;
|
||||
private static final int PLAYER_INVENTORY_ROW_COUNT = 3;
|
||||
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 VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_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 = 2; // must be the number of slots you have!
|
||||
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player playerIn, int index) {
|
||||
Slot sourceSlot = slots.get(index);
|
||||
if (sourceSlot == null || !sourceSlot.hasItem()) return ItemStack.EMPTY; //EMPTY_ITEM
|
||||
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) {
|
||||
// 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
|
||||
+ 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
|
||||
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);
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
// If stack size == 0 (the entire stack was moved) set slot contents to null
|
||||
if (sourceStack.getCount() == 0) {
|
||||
sourceSlot.set(ItemStack.EMPTY);
|
||||
} else {
|
||||
sourceSlot.setChanged();
|
||||
}
|
||||
sourceSlot.onTake(playerIn, sourceStack);
|
||||
return copyOfSourceStack;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
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_LEFT = 24;
|
||||
private static final int PLAYER_HOTBAR_FIRST_SLOT = 125;
|
||||
|
||||
private void addPlayerInventory(Inventory inv)
|
||||
{
|
||||
for (int i = 0; i < 3; i++) {
|
||||
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)
|
||||
{
|
||||
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,99 +1,100 @@
|
|||
package dev.zontreck.thresholds.implementation.scrubber;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.implementation.MouseHelpers;
|
||||
import dev.zontreck.thresholds.implementation.energy.screenrenderer.EnergyInfoArea;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
|
||||
public class ItemScrubberScreen extends AbstractContainerScreen<ItemScrubberMenu>
|
||||
{
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation(ThresholdsMod.MOD_ID, "textures/gui/item_scrubber_gui.png");
|
||||
|
||||
private EnergyInfoArea EIA;
|
||||
|
||||
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.imageWidth = 208;
|
||||
this.imageHeight = 165;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init()
|
||||
{
|
||||
super.init();
|
||||
assignEnergyArea();
|
||||
}
|
||||
|
||||
private void assignEnergyArea() {
|
||||
int x = (width - imageWidth )/2;
|
||||
int y = (height - imageHeight)/2;
|
||||
|
||||
EIA = new EnergyInfoArea(x+188, y+69, menu.entity.getEnergyStorage(), 7, 72);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(GuiGraphics poseStack, float partialTick, int mouseX, int mouseY) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
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);
|
||||
EIA.draw(poseStack);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void renderLabels(GuiGraphics stack, int mouseX, int mouseY)
|
||||
{
|
||||
stack.drawString(font, this.title.getString(), 63, 12, 0xFFFFFF);
|
||||
|
||||
int x = (width - imageWidth )/2;
|
||||
int y = (height - imageHeight)/2;
|
||||
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)){
|
||||
stack.renderTooltip(font, EIA.getTooltips(), Optional.empty(), mouseX-x, mouseY-y);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderUncraftingProgress(GuiGraphics stack)
|
||||
{
|
||||
if(menu.isCrafting())
|
||||
{
|
||||
stack.blit(TEXTURE, leftPos+42, topPos+45, 1, 168, menu.getScaledProgress(),6);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics stack, int mouseX, int mouseY, float delta)
|
||||
{
|
||||
renderBackground(stack);
|
||||
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)
|
||||
{
|
||||
return MouseHelpers.isMouseOver(mouseX, mouseY, x+offsetX, y+offsetY, width, height);
|
||||
}
|
||||
|
||||
}
|
||||
package dev.zontreck.otemod.implementation.scrubber;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.MouseHelpers;
|
||||
import dev.zontreck.otemod.implementation.energy.screenrenderer.EnergyInfoArea;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
|
||||
public class ItemScrubberScreen extends AbstractContainerScreen<ItemScrubberMenu>
|
||||
{
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation(OTEMod.MOD_ID, "textures/gui/item_scrubber_gui.png");
|
||||
|
||||
private EnergyInfoArea EIA;
|
||||
|
||||
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.imageWidth = 208;
|
||||
this.imageHeight = 165;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init()
|
||||
{
|
||||
super.init();
|
||||
assignEnergyArea();
|
||||
}
|
||||
|
||||
private void assignEnergyArea() {
|
||||
int x = (width - imageWidth )/2;
|
||||
int y = (height - imageHeight)/2;
|
||||
|
||||
EIA = new EnergyInfoArea(x+188, y+69, menu.entity.getEnergyStorage(), 7, 72);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(GuiGraphics poseStack, float partialTick, int mouseX, int mouseY) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
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);
|
||||
EIA.draw(poseStack);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void renderLabels(GuiGraphics stack, int mouseX, int mouseY)
|
||||
{
|
||||
stack.drawString(font, this.title.getString(), 63, 12, 0xFFFFFF);
|
||||
|
||||
int x = (width - imageWidth )/2;
|
||||
int y = (height - imageHeight)/2;
|
||||
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)){
|
||||
stack.renderTooltip(font, EIA.getTooltips(), Optional.empty(), mouseX-x, mouseY-y);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderUncraftingProgress(GuiGraphics stack)
|
||||
{
|
||||
if(menu.isCrafting())
|
||||
{
|
||||
stack.blit(TEXTURE, leftPos+42, topPos+45, 1, 168, menu.getScaledProgress(),6);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics stack, int mouseX, int mouseY, float delta)
|
||||
{
|
||||
renderBackground(stack);
|
||||
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)
|
||||
{
|
||||
return MouseHelpers.isMouseOver(mouseX, mouseY, x+offsetX, y+offsetY, width, height);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,150 +1,150 @@
|
|||
package dev.zontreck.thresholds.implementation.scrubber;
|
||||
|
||||
import dev.zontreck.thresholds.blocks.ModBlocks;
|
||||
import dev.zontreck.thresholds.blocks.entity.MagicalScrubberBlockEntity;
|
||||
import dev.zontreck.thresholds.implementation.inits.ModMenuTypes;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.*;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
|
||||
public class MagicalScrubberMenu extends AbstractContainerMenu
|
||||
{
|
||||
public final MagicalScrubberBlockEntity entity;
|
||||
private final Level level;
|
||||
private final ContainerData data;
|
||||
|
||||
public MagicalScrubberMenu(int id, Inventory inv, FriendlyByteBuf buf)
|
||||
{
|
||||
this(id, inv, inv.player.level().getBlockEntity(buf.readBlockPos()), new SimpleContainerData(1));
|
||||
}
|
||||
|
||||
public MagicalScrubberMenu(int id, Inventory inv, BlockEntity entity, ContainerData data){
|
||||
super(ModMenuTypes.MAGIC_SCRUBBER.get(), id);
|
||||
|
||||
checkContainerSize(inv, 1);
|
||||
this.entity = (MagicalScrubberBlockEntity)entity;
|
||||
this.data=data;
|
||||
this.level = inv.player.level();
|
||||
|
||||
addPlayerInventory(inv);
|
||||
addPlayerHotbar(inv);
|
||||
|
||||
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.UP).ifPresent(handler->{
|
||||
addSlot(new SlotItemHandler(handler, 0, 16, 41));
|
||||
});
|
||||
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.DOWN).ifPresent(handler->{
|
||||
addSlot(new SlotItemHandler(handler, 0, 177, 41));
|
||||
});
|
||||
|
||||
addDataSlots(data);
|
||||
|
||||
}
|
||||
|
||||
public boolean isCrafting()
|
||||
{
|
||||
return data.get(0) > 0;
|
||||
}
|
||||
|
||||
public int getScaledProgress()
|
||||
{
|
||||
if(!isCrafting())return 0;
|
||||
int progress = this.data.get(0);
|
||||
int max = MagicalScrubberBlockEntity.MAXIMUM_PROCESSING_TICKS;
|
||||
|
||||
int progressArrow = 125;
|
||||
|
||||
|
||||
if(progress != 0 && max != 0)
|
||||
{
|
||||
int percent = progress * progressArrow / max;
|
||||
return percent;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// CREDIT GOES TO: diesieben07 | https://github.com/diesieben07/SevenCommons
|
||||
// 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.
|
||||
// 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)
|
||||
// 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)
|
||||
private static final int HOTBAR_SLOT_COUNT = 9;
|
||||
private static final int PLAYER_INVENTORY_ROW_COUNT = 3;
|
||||
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 VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_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 = 2; // must be the number of slots you have!
|
||||
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player playerIn, int index) {
|
||||
Slot sourceSlot = slots.get(index);
|
||||
if (sourceSlot == null || !sourceSlot.hasItem()) return ItemStack.EMPTY; //EMPTY_ITEM
|
||||
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) {
|
||||
// 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
|
||||
+ 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
|
||||
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);
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
// If stack size == 0 (the entire stack was moved) set slot contents to null
|
||||
if (sourceStack.getCount() == 0) {
|
||||
sourceSlot.set(ItemStack.EMPTY);
|
||||
} else {
|
||||
sourceSlot.setChanged();
|
||||
}
|
||||
sourceSlot.onTake(playerIn, sourceStack);
|
||||
return copyOfSourceStack;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
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_LEFT = 24;
|
||||
private static final int PLAYER_HOTBAR_FIRST_SLOT = 125;
|
||||
|
||||
private void addPlayerInventory(Inventory inv)
|
||||
{
|
||||
for (int i = 0; i < 3; i++) {
|
||||
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)
|
||||
{
|
||||
for (int index = 0; index < 9; index++) {
|
||||
this.addSlot(new Slot(inv, index, PLAYER_INVENTORY_FIRST_SLOT_LEFT+index*18, PLAYER_HOTBAR_FIRST_SLOT));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
package dev.zontreck.otemod.implementation.scrubber;
|
||||
|
||||
import dev.zontreck.otemod.blocks.ModBlocks;
|
||||
import dev.zontreck.otemod.blocks.entity.MagicalScrubberBlockEntity;
|
||||
import dev.zontreck.otemod.implementation.inits.ModMenuTypes;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.*;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
|
||||
public class MagicalScrubberMenu extends AbstractContainerMenu
|
||||
{
|
||||
public final MagicalScrubberBlockEntity entity;
|
||||
private final Level level;
|
||||
private final ContainerData data;
|
||||
|
||||
public MagicalScrubberMenu(int id, Inventory inv, FriendlyByteBuf buf)
|
||||
{
|
||||
this(id, inv, inv.player.level().getBlockEntity(buf.readBlockPos()), new SimpleContainerData(1));
|
||||
}
|
||||
|
||||
public MagicalScrubberMenu(int id, Inventory inv, BlockEntity entity, ContainerData data){
|
||||
super(ModMenuTypes.MAGIC_SCRUBBER.get(), id);
|
||||
|
||||
checkContainerSize(inv, 1);
|
||||
this.entity = (MagicalScrubberBlockEntity)entity;
|
||||
this.data=data;
|
||||
this.level = inv.player.level();
|
||||
|
||||
addPlayerInventory(inv);
|
||||
addPlayerHotbar(inv);
|
||||
|
||||
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.UP).ifPresent(handler->{
|
||||
addSlot(new SlotItemHandler(handler, 0, 16, 41));
|
||||
});
|
||||
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.DOWN).ifPresent(handler->{
|
||||
addSlot(new SlotItemHandler(handler, 0, 177, 41));
|
||||
});
|
||||
|
||||
addDataSlots(data);
|
||||
|
||||
}
|
||||
|
||||
public boolean isCrafting()
|
||||
{
|
||||
return data.get(0) > 0;
|
||||
}
|
||||
|
||||
public int getScaledProgress()
|
||||
{
|
||||
if(!isCrafting())return 0;
|
||||
int progress = this.data.get(0);
|
||||
int max = MagicalScrubberBlockEntity.MAXIMUM_PROCESSING_TICKS;
|
||||
|
||||
int progressArrow = 125;
|
||||
|
||||
|
||||
if(progress != 0 && max != 0)
|
||||
{
|
||||
int percent = progress * progressArrow / max;
|
||||
return percent;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// CREDIT GOES TO: diesieben07 | https://github.com/diesieben07/SevenCommons
|
||||
// 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.
|
||||
// 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)
|
||||
// 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)
|
||||
private static final int HOTBAR_SLOT_COUNT = 9;
|
||||
private static final int PLAYER_INVENTORY_ROW_COUNT = 3;
|
||||
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 VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_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 = 2; // must be the number of slots you have!
|
||||
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player playerIn, int index) {
|
||||
Slot sourceSlot = slots.get(index);
|
||||
if (sourceSlot == null || !sourceSlot.hasItem()) return ItemStack.EMPTY; //EMPTY_ITEM
|
||||
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) {
|
||||
// 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
|
||||
+ 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
|
||||
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);
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
// If stack size == 0 (the entire stack was moved) set slot contents to null
|
||||
if (sourceStack.getCount() == 0) {
|
||||
sourceSlot.set(ItemStack.EMPTY);
|
||||
} else {
|
||||
sourceSlot.setChanged();
|
||||
}
|
||||
sourceSlot.onTake(playerIn, sourceStack);
|
||||
return copyOfSourceStack;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
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_LEFT = 24;
|
||||
private static final int PLAYER_HOTBAR_FIRST_SLOT = 125;
|
||||
|
||||
private void addPlayerInventory(Inventory inv)
|
||||
{
|
||||
for (int i = 0; i < 3; i++) {
|
||||
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)
|
||||
{
|
||||
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,99 +1,100 @@
|
|||
package dev.zontreck.thresholds.implementation.scrubber;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.implementation.MouseHelpers;
|
||||
import dev.zontreck.thresholds.implementation.energy.screenrenderer.EnergyInfoArea;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
|
||||
public class MagicalScrubberScreen extends AbstractContainerScreen<MagicalScrubberMenu>
|
||||
{
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation(ThresholdsMod.MOD_ID, "textures/gui/item_scrubber_gui.png");
|
||||
|
||||
private EnergyInfoArea EIA;
|
||||
|
||||
|
||||
@Override
|
||||
protected void init()
|
||||
{
|
||||
super.init();
|
||||
assignEnergyArea();
|
||||
}
|
||||
|
||||
private void assignEnergyArea() {
|
||||
int x = (width - imageWidth )/2;
|
||||
int y = (height - imageHeight)/2;
|
||||
|
||||
EIA = new EnergyInfoArea(x+188, y+69, menu.entity.getEnergyStorage(), 7, 72);
|
||||
}
|
||||
|
||||
|
||||
public MagicalScrubberScreen(MagicalScrubberMenu pMenu, Inventory pPlayerInventory, Component pTitle) {
|
||||
super(pMenu, pPlayerInventory, pTitle);
|
||||
this.topPos=0;
|
||||
this.leftPos=0;
|
||||
|
||||
this.imageWidth = 208;
|
||||
this.imageHeight = 165;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(GuiGraphics poseStack, float partialTick, int mouseX, int mouseY) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
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);
|
||||
EIA.draw(poseStack);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void renderLabels(GuiGraphics stack, int mouseX, int mouseY)
|
||||
{
|
||||
stack.drawString(font, title.getString(), 63, 12, 0xFFFFFF);
|
||||
|
||||
int x = (width - imageWidth )/2;
|
||||
int y = (height - imageHeight)/2;
|
||||
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)){
|
||||
stack.renderTooltip(font, EIA.getTooltips(), Optional.empty(), mouseX-x, mouseY-y);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderUncraftingProgress(GuiGraphics stack)
|
||||
{
|
||||
if(menu.isCrafting())
|
||||
{
|
||||
stack.blit(TEXTURE, leftPos+42, topPos+45, 1, 168, menu.getScaledProgress(), 6);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics stack, int mouseX, int mouseY, float delta)
|
||||
{
|
||||
renderBackground(stack);
|
||||
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)
|
||||
{
|
||||
return MouseHelpers.isMouseOver(mouseX, mouseY, x+offsetX, y+offsetY, width, height);
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.implementation.scrubber;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.MouseHelpers;
|
||||
import dev.zontreck.otemod.implementation.energy.screenrenderer.EnergyInfoArea;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
|
||||
public class MagicalScrubberScreen extends AbstractContainerScreen<MagicalScrubberMenu>
|
||||
{
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation(OTEMod.MOD_ID, "textures/gui/item_scrubber_gui.png");
|
||||
|
||||
private EnergyInfoArea EIA;
|
||||
|
||||
|
||||
@Override
|
||||
protected void init()
|
||||
{
|
||||
super.init();
|
||||
assignEnergyArea();
|
||||
}
|
||||
|
||||
private void assignEnergyArea() {
|
||||
int x = (width - imageWidth )/2;
|
||||
int y = (height - imageHeight)/2;
|
||||
|
||||
EIA = new EnergyInfoArea(x+188, y+69, menu.entity.getEnergyStorage(), 7, 72);
|
||||
}
|
||||
|
||||
|
||||
public MagicalScrubberScreen(MagicalScrubberMenu pMenu, Inventory pPlayerInventory, Component pTitle) {
|
||||
super(pMenu, pPlayerInventory, pTitle);
|
||||
this.topPos=0;
|
||||
this.leftPos=0;
|
||||
|
||||
this.imageWidth = 208;
|
||||
this.imageHeight = 165;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(GuiGraphics poseStack, float partialTick, int mouseX, int mouseY) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
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);
|
||||
EIA.draw(poseStack);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void renderLabels(GuiGraphics stack, int mouseX, int mouseY)
|
||||
{
|
||||
stack.drawString(font, title.getString(), 63, 12, 0xFFFFFF);
|
||||
|
||||
int x = (width - imageWidth )/2;
|
||||
int y = (height - imageHeight)/2;
|
||||
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)){
|
||||
stack.renderTooltip(font, EIA.getTooltips(), Optional.empty(), mouseX-x, mouseY-y);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderUncraftingProgress(GuiGraphics stack)
|
||||
{
|
||||
if(menu.isCrafting())
|
||||
{
|
||||
stack.blit(TEXTURE, leftPos+42, topPos+45, 1, 168, menu.getScaledProgress(), 6);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics stack, int mouseX, int mouseY, float delta)
|
||||
{
|
||||
renderBackground(stack);
|
||||
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)
|
||||
{
|
||||
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
|
|
@ -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.LongTag;
|
||||
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.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import dev.zontreck.otemod.implementation.StarterKitDoesNotExistException;
|
||||
import dev.zontreck.otemod.implementation.events.VaultModifiedEvent;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
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.network.FriendlyByteBuf;
|
||||
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.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
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 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.components.Button;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -19,7 +23,7 @@ public class StarterScreen extends AbstractContainerScreen <StarterMenu>
|
|||
public final Player thePlayer;
|
||||
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){
|
||||
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 net.minecraft.nbt.CompoundTag;
|
|
@ -1,116 +1,116 @@
|
|||
package dev.zontreck.thresholds.implementation.vault;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.implementation.events.VaultModifiedEvent;
|
||||
import dev.zontreck.thresholds.implementation.vault.VaultProvider.VaultAccessStrategy;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.inventory.MenuConstructor;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class VaultContainer
|
||||
{
|
||||
public static Map<UUID, VaultContainer> VAULT_REGISTRY = new HashMap<>();
|
||||
public VaultMenu theContainer;
|
||||
public ItemStackHandler myInventory;
|
||||
public ItemStackHandler startingInventory;
|
||||
public MenuConstructor serverMenu;
|
||||
public UUID owner;
|
||||
private MinecraftServer server;
|
||||
public final int VAULT_NUMBER;
|
||||
public final UUID VaultID;
|
||||
public Vault main_accessor;
|
||||
private boolean invalid;
|
||||
public VaultContainer(ServerPlayer player, int vaultNum) throws NoMoreVaultException {
|
||||
myInventory = new ItemStackHandler(54); // Vaults have a fixed size at the same as a double chest
|
||||
startingInventory = new ItemStackHandler(64);
|
||||
theContainer = new VaultMenu(player.containerCounter+1, player.getInventory(), myInventory, BlockPos.ZERO, player, vaultNum);
|
||||
VaultID = theContainer.VaultMenuID;
|
||||
owner = player.getUUID();
|
||||
server=player.server;
|
||||
serverMenu = theContainer.getServerMenu(myInventory, vaultNum);
|
||||
VAULT_NUMBER=vaultNum;
|
||||
if(VAULT_NUMBER == -1)return; // Trash ID
|
||||
|
||||
// Check database for vault
|
||||
VaultAccessStrategy strategy;
|
||||
try {
|
||||
strategy = VaultProvider.check(Profile.get_profile_of(player.getStringUUID()), vaultNum);
|
||||
if(strategy == VaultAccessStrategy.CREATE || strategy == VaultAccessStrategy.OPEN)
|
||||
{
|
||||
Vault accessor = VaultProvider.get(Profile.get_profile_of(player.getStringUUID()), vaultNum);
|
||||
if(accessor.isNew)
|
||||
{
|
||||
main_accessor=accessor;
|
||||
return;
|
||||
}else {
|
||||
myInventory.deserializeNBT(accessor.getContents());
|
||||
startingInventory.deserializeNBT(accessor.getContents());
|
||||
}
|
||||
main_accessor=accessor;
|
||||
}else {
|
||||
// DENY
|
||||
throw new NoMoreVaultException("No more vaults can be created", vaultNum);
|
||||
}
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
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!
|
||||
}
|
||||
|
||||
public void commit()
|
||||
{
|
||||
if(invalid)return;
|
||||
if(VAULT_NUMBER == -1)return; // We have no need to save the trash
|
||||
boolean isEmpty=true;
|
||||
CompoundTag saved = myInventory.serializeNBT();
|
||||
ChatHelpers.broadcastToAbove(owner, Component.literal(ChatColor.BOLD+ChatColor.DARK_GREEN+"Saving the vault's contents..."), server);
|
||||
|
||||
Profile profile=null;
|
||||
try {
|
||||
profile = Profile.get_profile_of(owner.toString());
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0;i<myInventory.getSlots();i++)
|
||||
{
|
||||
ItemStack is = myInventory.getStackInSlot(i);
|
||||
if(!is.is(Items.AIR))
|
||||
{
|
||||
isEmpty=false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!isEmpty)
|
||||
main_accessor.setContents(saved);
|
||||
else
|
||||
main_accessor.delete();
|
||||
|
||||
|
||||
VaultModifiedEvent vme = new VaultModifiedEvent(VAULT_NUMBER, profile, VaultProvider.getInUse(profile), myInventory, startingInventory);
|
||||
ThresholdsMod.bus.post(vme);
|
||||
}
|
||||
|
||||
public void invalidate()
|
||||
{
|
||||
invalid=true;
|
||||
}
|
||||
|
||||
}
|
||||
package dev.zontreck.otemod.implementation.vault;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.events.VaultModifiedEvent;
|
||||
import dev.zontreck.otemod.implementation.vault.VaultProvider.VaultAccessStrategy;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.inventory.MenuConstructor;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class VaultContainer
|
||||
{
|
||||
public static Map<UUID, VaultContainer> VAULT_REGISTRY = new HashMap<>();
|
||||
public VaultMenu theContainer;
|
||||
public ItemStackHandler myInventory;
|
||||
public ItemStackHandler startingInventory;
|
||||
public MenuConstructor serverMenu;
|
||||
public UUID owner;
|
||||
private MinecraftServer server;
|
||||
public final int VAULT_NUMBER;
|
||||
public final UUID VaultID;
|
||||
public Vault main_accessor;
|
||||
private boolean invalid;
|
||||
public VaultContainer(ServerPlayer player, int vaultNum) throws NoMoreVaultException {
|
||||
myInventory = new ItemStackHandler(54); // Vaults have a fixed size at the same as a double chest
|
||||
startingInventory = new ItemStackHandler(64);
|
||||
theContainer = new VaultMenu(player.containerCounter+1, player.getInventory(), myInventory, BlockPos.ZERO, player, vaultNum);
|
||||
VaultID = theContainer.VaultMenuID;
|
||||
owner = player.getUUID();
|
||||
server=player.server;
|
||||
serverMenu = theContainer.getServerMenu(myInventory, vaultNum);
|
||||
VAULT_NUMBER=vaultNum;
|
||||
if(VAULT_NUMBER == -1)return; // Trash ID
|
||||
|
||||
// Check database for vault
|
||||
VaultAccessStrategy strategy;
|
||||
try {
|
||||
strategy = VaultProvider.check(Profile.get_profile_of(player.getStringUUID()), vaultNum);
|
||||
if(strategy == VaultAccessStrategy.CREATE || strategy == VaultAccessStrategy.OPEN)
|
||||
{
|
||||
Vault accessor = VaultProvider.get(Profile.get_profile_of(player.getStringUUID()), vaultNum);
|
||||
if(accessor.isNew)
|
||||
{
|
||||
main_accessor=accessor;
|
||||
return;
|
||||
}else {
|
||||
myInventory.deserializeNBT(accessor.getContents());
|
||||
startingInventory.deserializeNBT(accessor.getContents());
|
||||
}
|
||||
main_accessor=accessor;
|
||||
}else {
|
||||
// DENY
|
||||
throw new NoMoreVaultException("No more vaults can be created", vaultNum);
|
||||
}
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
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!
|
||||
}
|
||||
|
||||
public void commit()
|
||||
{
|
||||
if(invalid)return;
|
||||
if(VAULT_NUMBER == -1)return; // We have no need to save the trash
|
||||
boolean isEmpty=true;
|
||||
CompoundTag saved = myInventory.serializeNBT();
|
||||
ChatHelpers.broadcastToAbove(owner, Component.literal(ChatColor.BOLD+ChatColor.DARK_GREEN+"Saving the vault's contents..."), server);
|
||||
|
||||
Profile profile=null;
|
||||
try {
|
||||
profile = Profile.get_profile_of(owner.toString());
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0;i<myInventory.getSlots();i++)
|
||||
{
|
||||
ItemStack is = myInventory.getStackInSlot(i);
|
||||
if(!is.is(Items.AIR))
|
||||
{
|
||||
isEmpty=false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!isEmpty)
|
||||
main_accessor.setContents(saved);
|
||||
else
|
||||
main_accessor.delete();
|
||||
|
||||
|
||||
VaultModifiedEvent vme = new VaultModifiedEvent(VAULT_NUMBER, profile, VaultProvider.getInUse(profile), myInventory, startingInventory);
|
||||
OTEMod.bus.post(vme);
|
||||
}
|
||||
|
||||
public void invalidate()
|
||||
{
|
||||
invalid=true;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,152 +1,153 @@
|
|||
package dev.zontreck.thresholds.implementation.vault;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import dev.zontreck.thresholds.implementation.inits.ModMenuTypes;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.MenuConstructor;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
|
||||
public class VaultMenu extends AbstractContainerMenu
|
||||
{
|
||||
//private final ContainerLevelAccess containerAccess;
|
||||
public final UUID VaultMenuID;
|
||||
public final Player thePlayer;
|
||||
public final int VAULT_NUMBER;
|
||||
|
||||
public VaultMenu (int id, Inventory player, FriendlyByteBuf buf)
|
||||
{
|
||||
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)
|
||||
{
|
||||
super(ModMenuTypes.VAULT.get(), id);
|
||||
thePlayer=play;
|
||||
VaultMenuID=UUID.randomUUID();
|
||||
VAULT_NUMBER=vaultNum;
|
||||
//this.containerAccess = ContainerLevelAccess.create(player.player.level, pos);
|
||||
|
||||
final int slotSize = 18;
|
||||
final int startX = 24;
|
||||
final int inventoryY = 38;
|
||||
|
||||
addPlayerInventory(player);
|
||||
addPlayerHotbar(player);
|
||||
|
||||
|
||||
for (int row = 0; row < 6; row++)
|
||||
{
|
||||
for (int column = 0; column < 9; column++)
|
||||
{
|
||||
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.
|
||||
// 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
|
||||
// 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)
|
||||
// 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 PLAYER_INVENTORY_ROW_COUNT = 3;
|
||||
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 VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_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!
|
||||
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player playerIn, int index) {
|
||||
Slot sourceSlot = slots.get(index);
|
||||
if (sourceSlot == null || !sourceSlot.hasItem()) return ItemStack.EMPTY; //EMPTY_ITEM
|
||||
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) {
|
||||
// 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
|
||||
+ 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
|
||||
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);
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
// If stack size == 0 (the entire stack was moved) set slot contents to null
|
||||
if (sourceStack.getCount() == 0) {
|
||||
sourceSlot.set(ItemStack.EMPTY);
|
||||
} else {
|
||||
sourceSlot.setChanged();
|
||||
}
|
||||
sourceSlot.onTake(playerIn, sourceStack);
|
||||
return copyOfSourceStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
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 void doCommitAction()
|
||||
{
|
||||
|
||||
// Locate the Vault in the Vault Registry and commit changes.
|
||||
// Search for myself!
|
||||
for(Map.Entry<UUID,VaultContainer> e : VaultContainer.VAULT_REGISTRY.entrySet())
|
||||
{
|
||||
if(e.getValue().VaultID.equals(VaultMenuID))
|
||||
{
|
||||
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_HOTBAR_FIRST_SLOT = 212;
|
||||
|
||||
private void addPlayerInventory(Inventory inv)
|
||||
{
|
||||
for (int i = 0; i < 3; i++) {
|
||||
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)
|
||||
{
|
||||
for (int index = 0; index < 9; index++) {
|
||||
this.addSlot(new Slot(inv, index, PLAYER_INVENTORY_FIRST_SLOT_LEFT+index*18, PLAYER_HOTBAR_FIRST_SLOT));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
package dev.zontreck.otemod.implementation.vault;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import dev.zontreck.otemod.implementation.inits.ModMenuTypes;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.ClickType;
|
||||
import net.minecraft.world.inventory.MenuConstructor;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
|
||||
public class VaultMenu extends AbstractContainerMenu
|
||||
{
|
||||
//private final ContainerLevelAccess containerAccess;
|
||||
public final UUID VaultMenuID;
|
||||
public final Player thePlayer;
|
||||
public final int VAULT_NUMBER;
|
||||
|
||||
public VaultMenu (int id, Inventory player, FriendlyByteBuf buf)
|
||||
{
|
||||
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)
|
||||
{
|
||||
super(ModMenuTypes.VAULT.get(), id);
|
||||
thePlayer=play;
|
||||
VaultMenuID=UUID.randomUUID();
|
||||
VAULT_NUMBER=vaultNum;
|
||||
//this.containerAccess = ContainerLevelAccess.create(player.player.level, pos);
|
||||
|
||||
final int slotSize = 18;
|
||||
final int startX = 24;
|
||||
final int inventoryY = 38;
|
||||
|
||||
addPlayerInventory(player);
|
||||
addPlayerHotbar(player);
|
||||
|
||||
|
||||
for (int row = 0; row < 6; row++)
|
||||
{
|
||||
for (int column = 0; column < 9; column++)
|
||||
{
|
||||
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.
|
||||
// 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
|
||||
// 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)
|
||||
// 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 PLAYER_INVENTORY_ROW_COUNT = 3;
|
||||
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 VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_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!
|
||||
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player playerIn, int index) {
|
||||
Slot sourceSlot = slots.get(index);
|
||||
if (sourceSlot == null || !sourceSlot.hasItem()) return ItemStack.EMPTY; //EMPTY_ITEM
|
||||
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) {
|
||||
// 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
|
||||
+ 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
|
||||
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);
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
// If stack size == 0 (the entire stack was moved) set slot contents to null
|
||||
if (sourceStack.getCount() == 0) {
|
||||
sourceSlot.set(ItemStack.EMPTY);
|
||||
} else {
|
||||
sourceSlot.setChanged();
|
||||
}
|
||||
sourceSlot.onTake(playerIn, sourceStack);
|
||||
return copyOfSourceStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
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 void doCommitAction()
|
||||
{
|
||||
|
||||
// Locate the Vault in the Vault Registry and commit changes.
|
||||
// Search for myself!
|
||||
for(Map.Entry<UUID,VaultContainer> e : VaultContainer.VAULT_REGISTRY.entrySet())
|
||||
{
|
||||
if(e.getValue().VaultID.equals(VaultMenuID))
|
||||
{
|
||||
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_HOTBAR_FIRST_SLOT = 212;
|
||||
|
||||
private void addPlayerInventory(Inventory inv)
|
||||
{
|
||||
for (int i = 0; i < 3; i++) {
|
||||
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)
|
||||
{
|
||||
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.IOException;
|
||||
|
@ -7,8 +7,8 @@ import java.nio.file.Path;
|
|||
import java.util.List;
|
||||
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.thresholds.configs.ThresholdsServerConfig;
|
||||
import dev.zontreck.thresholds.database.OTEDatastore;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import dev.zontreck.otemod.database.OTEDatastore;
|
||||
|
||||
public class VaultProvider extends OTEDatastore
|
||||
{
|
||||
|
@ -67,12 +67,12 @@ public class VaultProvider extends OTEDatastore
|
|||
|
||||
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){
|
||||
return false;
|
||||
}else return true;
|
||||
}
|
||||
if(prof.available_vaults >= ThresholdsServerConfig.MAX_VAULTS.get())
|
||||
if(prof.available_vaults >= OTEServerConfig.MAX_VAULTS.get())
|
||||
{
|
||||
if(consumed<prof.available_vaults)
|
||||
{
|
|
@ -1,84 +1,91 @@
|
|||
package dev.zontreck.thresholds.implementation.vault;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.networking.ModMessages;
|
||||
import dev.zontreck.thresholds.networking.packets.OpenVaultC2SPacket;
|
||||
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.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public class VaultScreen extends AbstractContainerScreen <VaultMenu>
|
||||
{
|
||||
// 176x224
|
||||
public final UUID VaultMenuID;
|
||||
public final Player thePlayer;
|
||||
public final VaultMenu THE_CONTAINER;
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation(ThresholdsMod.MOD_ID, "textures/gui/vault.png");
|
||||
|
||||
public VaultScreen(VaultMenu container, Inventory playerInv, Component comp){
|
||||
super(container, playerInv, comp);
|
||||
thePlayer=playerInv.player;
|
||||
|
||||
this.VaultMenuID = container.VaultMenuID;
|
||||
this.leftPos = 0;
|
||||
this.topPos = 0;
|
||||
this.THE_CONTAINER=container;
|
||||
|
||||
this.imageWidth = 207;
|
||||
this.imageHeight = 238;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics stack, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.renderBackground(stack);
|
||||
super.render(stack, mouseX, mouseY, partialTicks);
|
||||
this.renderTooltip(stack, mouseX, mouseY);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init()
|
||||
{
|
||||
super.init();
|
||||
this.inventoryLabelY = 12;
|
||||
this.inventoryLabelX = 63;
|
||||
|
||||
|
||||
// This is where custom controls would be added!
|
||||
|
||||
this.addWidget(Button.builder(Component.literal(""), (BTN)->{
|
||||
thePlayer.closeContainer();
|
||||
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)->{
|
||||
thePlayer.closeContainer();
|
||||
ModMessages.sendToServer(new OpenVaultC2SPacket(0, true, 1));
|
||||
}).size(16,16).pos(this.leftPos+187, this.topPos+84).build());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.implementation.vault;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.commands.vaults.VaultCommand;
|
||||
import dev.zontreck.otemod.networking.ModMessages;
|
||||
import dev.zontreck.otemod.networking.packets.OpenVaultC2SPacket;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.Button.OnPress;
|
||||
import net.minecraft.client.gui.font.TextFieldHelper;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
public class VaultScreen extends AbstractContainerScreen <VaultMenu>
|
||||
{
|
||||
// 176x224
|
||||
public final UUID VaultMenuID;
|
||||
public final Player thePlayer;
|
||||
public final VaultMenu THE_CONTAINER;
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation(OTEMod.MOD_ID, "textures/gui/vault.png");
|
||||
|
||||
public VaultScreen(VaultMenu container, Inventory playerInv, Component comp){
|
||||
super(container, playerInv, comp);
|
||||
thePlayer=playerInv.player;
|
||||
|
||||
this.VaultMenuID = container.VaultMenuID;
|
||||
this.leftPos = 0;
|
||||
this.topPos = 0;
|
||||
this.THE_CONTAINER=container;
|
||||
|
||||
this.imageWidth = 207;
|
||||
this.imageHeight = 238;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics stack, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.renderBackground(stack);
|
||||
super.render(stack, mouseX, mouseY, partialTicks);
|
||||
this.renderTooltip(stack, mouseX, mouseY);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init()
|
||||
{
|
||||
super.init();
|
||||
this.inventoryLabelY = 12;
|
||||
this.inventoryLabelX = 63;
|
||||
|
||||
|
||||
// This is where custom controls would be added!
|
||||
|
||||
this.addWidget(Button.builder(Component.literal(""), (BTN)->{
|
||||
thePlayer.closeContainer();
|
||||
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)->{
|
||||
thePlayer.closeContainer();
|
||||
ModMessages.sendToServer(new OpenVaultC2SPacket(0, true, 1));
|
||||
}).size(16,16).pos(this.leftPos+187, this.topPos+84).build());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
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;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import net.minecraftforge.event.entity.player.PlayerContainerEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
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 {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onClosedContainer(PlayerContainerEvent.Close ev)
|
||||
{
|
||||
if(ev.getEntity().level().isClientSide)return;
|
||||
//OTEMod.LOGGER.info("Player closed a container");
|
||||
// Player closed the container
|
||||
// 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()){
|
||||
if(entry.getKey() == ev.getEntity().getUUID())
|
||||
{
|
||||
entry.getValue().commit();
|
||||
entry.getValue().invalidate();
|
||||
}
|
||||
}
|
||||
} else if(ev.getContainer() instanceof StarterMenu)
|
||||
{
|
||||
for(Map.Entry<UUID, StarterContainer> entry : StarterContainer.VAULT_REGISTRY.entrySet())
|
||||
{
|
||||
if(entry.getKey() == ev.getEntity().getUUID())
|
||||
{
|
||||
entry.getValue().commit();
|
||||
entry.getValue().invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.implementation.vault;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import net.minecraftforge.client.event.ContainerScreenEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerContainerEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
|
||||
@EventBusSubscriber(modid=OTEMod.MOD_ID,bus=Mod.EventBusSubscriber.Bus.FORGE)
|
||||
public class VaultWatcher {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onClosedContainer(PlayerContainerEvent.Close ev)
|
||||
{
|
||||
if(ev.getEntity().level().isClientSide)return;
|
||||
//OTEMod.LOGGER.info("Player closed a container");
|
||||
// Player closed the container
|
||||
// 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()){
|
||||
if(entry.getKey() == ev.getEntity().getUUID())
|
||||
{
|
||||
entry.getValue().commit();
|
||||
entry.getValue().invalidate();
|
||||
}
|
||||
}
|
||||
} else if(ev.getContainer() instanceof StarterMenu)
|
||||
{
|
||||
for(Map.Entry<UUID, StarterContainer> entry : StarterContainer.VAULT_REGISTRY.entrySet())
|
||||
{
|
||||
if(entry.getKey() == ev.getEntity().getUUID())
|
||||
{
|
||||
entry.getValue().commit();
|
||||
entry.getValue().invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,28 +1,30 @@
|
|||
package dev.zontreck.thresholds.integrations;
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class KeyBindings {
|
||||
public static final String KEY_CATEGORY_OTEMOD = "key.category.otemod";
|
||||
public static final String KEY_OPEN_VAULT = "key.otemod.open_vault";
|
||||
|
||||
public static final KeyMapping OPEN_VAULT = createKeyMapping(KEY_OPEN_VAULT, InputConstants.KEY_V, KEY_CATEGORY_OTEMOD);
|
||||
|
||||
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)
|
||||
{
|
||||
event.register(OPEN_VAULT);
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.integrations;
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.multiplayer.ClientRegistryLayer;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class KeyBindings {
|
||||
public static final String KEY_CATEGORY_OTEMOD = "key.category.otemod";
|
||||
public static final String KEY_OPEN_VAULT = "key.otemod.open_vault";
|
||||
|
||||
public static final KeyMapping OPEN_VAULT = createKeyMapping(KEY_OPEN_VAULT, InputConstants.KEY_V, KEY_CATEGORY_OTEMOD);
|
||||
|
||||
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)
|
||||
{
|
||||
event.register(OPEN_VAULT);
|
||||
}
|
||||
}
|
|
@ -1,37 +1,40 @@
|
|||
package dev.zontreck.thresholds.integrations;
|
||||
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.thresholds.implementation.Messages;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public class LuckPermsHelper {
|
||||
/*public static LuckPerms getLuckPerms()
|
||||
{
|
||||
return LuckPermsProvider.get();
|
||||
}
|
||||
|
||||
private static User getUserOf(Player p){
|
||||
return getLuckPerms().getPlayerAdapter(Player.class).getUser(p);
|
||||
}
|
||||
|
||||
private static boolean hasPermission(User u, String perm)
|
||||
{
|
||||
return u.getCachedData().getPermissionData().checkPermission(perm).asBoolean();
|
||||
}*/
|
||||
|
||||
public static boolean hasPermission(Player p, String perm)
|
||||
{
|
||||
//User u = getUserOf(p);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean hasGroupOrPerm(Player p, String group, String perm){
|
||||
return hasPermission(p, group) || hasPermission(p, perm);
|
||||
}
|
||||
|
||||
public static void sendNoPermissionsMessage(ServerPlayer play, String perm, String group) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.integrations;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import dev.zontreck.otemod.implementation.Messages;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public class LuckPermsHelper {
|
||||
/*public static LuckPerms getLuckPerms()
|
||||
{
|
||||
return LuckPermsProvider.get();
|
||||
}
|
||||
|
||||
private static User getUserOf(Player p){
|
||||
return getLuckPerms().getPlayerAdapter(Player.class).getUser(p);
|
||||
}
|
||||
|
||||
private static boolean hasPermission(User u, String perm)
|
||||
{
|
||||
return u.getCachedData().getPermissionData().checkPermission(perm).asBoolean();
|
||||
}*/
|
||||
|
||||
public static boolean hasPermission(Player p, String perm)
|
||||
{
|
||||
//User u = getUserOf(p);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean hasGroupOrPerm(Player p, String group, String perm){
|
||||
return hasPermission(p, group) || hasPermission(p, perm);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
public class IhanCrystal extends Item{
|
||||
|
||||
public IhanCrystal(Properties p_41383_) {
|
||||
super(p_41383_);
|
||||
}
|
||||
|
||||
}
|
||||
package dev.zontreck.otemod.items;
|
||||
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
public class IhanCrystal extends Item{
|
||||
|
||||
public IhanCrystal(Properties p_41383_) {
|
||||
super(p_41383_);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,76 +1,79 @@
|
|||
package dev.zontreck.thresholds.items;
|
||||
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.implementation.CreativeModeTabs;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class ModItems {
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ThresholdsMod.MOD_ID);
|
||||
|
||||
public static final RegistryObject<Item> ETERNIUM_FRAGMENT = CreativeModeTabs.addToOTEModTab(ITEMS.register("eternium_fragment", () -> 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> AURORA_COMPOUND = CreativeModeTabs.addToOTEModTab(ITEMS.register("aurora_compound", () -> 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> 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> 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> 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> SCRUBBER_FRAME = CreativeModeTabs.addToOTEModTab(ITEMS.register("scrubber_frame", () -> 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> 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> VAULT_FRAG_L = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_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_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_FRAG_C = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_center", () -> 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_RAW_ORE = CreativeModeTabs.addToOTEModTab(ITEMS.register("raw_vault_steel_ore", () -> new Item(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> 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_DUST = CreativeModeTabs.addToOTEModTab(ITEMS.register("ilusium_dust", () -> 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> 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);
|
||||
}
|
||||
|
||||
}
|
||||
package dev.zontreck.otemod.items;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.blocks.FoiledBlockItem;
|
||||
import dev.zontreck.otemod.entities.ModEntityTypes;
|
||||
import dev.zontreck.otemod.implementation.CreativeModeTabs;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraftforge.common.ForgeSpawnEggItem;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class ModItems {
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, OTEMod.MOD_ID);
|
||||
|
||||
public static final RegistryObject<Item> ETERNIUM_FRAGMENT = CreativeModeTabs.addToOTEModTab(ITEMS.register("eternium_fragment", () -> 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> AURORA_COMPOUND = CreativeModeTabs.addToOTEModTab(ITEMS.register("aurora_compound", () -> 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> 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> 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> 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> SCRUBBER_FRAME = CreativeModeTabs.addToOTEModTab(ITEMS.register("scrubber_frame", () -> 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> 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> VAULT_FRAG_L = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_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_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_FRAG_C = CreativeModeTabs.addToOTEModTab(ITEMS.register("vault_fragment_center", () -> 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_RAW_ORE = CreativeModeTabs.addToOTEModTab(ITEMS.register("raw_vault_steel_ore", () -> new Item(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> 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_DUST = CreativeModeTabs.addToOTEModTab(ITEMS.register("ilusium_dust", () -> 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> 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);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package dev.zontreck.thresholds.items;
|
||||
package dev.zontreck.otemod.items;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
|
@ -6,7 +6,10 @@ import net.minecraft.sounds.SoundSource;
|
|||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.monster.Guardian;
|
||||
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.ItemStack;
|
||||
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.lore.ExtraLore;
|
||||
import dev.zontreck.libzontreck.lore.LoreContainer;
|
||||
import dev.zontreck.libzontreck.lore.LoreEntry;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import net.minecraft.core.particles.ItemParticleOption;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
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.EntityType;
|
||||
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.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.DropperBlock;
|
||||
import net.minecraft.world.phys.EntityHitResult;
|
||||
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.item.SimpleFoiledItem;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
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.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
||||
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.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.thresholds.ThresholdsMod;
|
||||
import dev.zontreck.thresholds.configs.ThresholdsServerConfig;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
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.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.SimpleFoiledItem;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
public class VaultItem extends Item
|
||||
|
@ -37,7 +42,7 @@ public class VaultItem extends Item
|
|||
@Override
|
||||
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)
|
||||
{
|
||||
ItemStack is = pPlayer.getItemInHand(pUsedHand);
|
||||
|
@ -45,16 +50,16 @@ public class VaultItem extends Item
|
|||
Profile p;
|
||||
try {
|
||||
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);
|
||||
} else {
|
||||
p.available_vaults++;
|
||||
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));
|
||||
|
||||
return InteractionResultHolder.consume(is);
|
||||
|
@ -62,7 +67,7 @@ public class VaultItem extends Item
|
|||
}else {
|
||||
p.available_vaults++;
|
||||
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));
|
||||
|
||||
return InteractionResultHolder.consume(is);
|
|
@ -1,28 +1,28 @@
|
|||
package dev.zontreck.thresholds.items.tags;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
public class ItemStatTag {
|
||||
public static final String STATS_TAG = "stat";
|
||||
public ItemStatType type;
|
||||
public int value;
|
||||
|
||||
public ItemStatTag(ItemStatType t, int tag)
|
||||
{
|
||||
type = t;
|
||||
value = tag;
|
||||
}
|
||||
|
||||
public void increment(){
|
||||
value++;
|
||||
}
|
||||
public void decrement()
|
||||
{
|
||||
value--;
|
||||
}
|
||||
|
||||
public void save(CompoundTag tag)
|
||||
{
|
||||
tag.putInt(STATS_TAG+"_"+type.name().toLowerCase(), value);
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.items.tags;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
public class ItemStatTag {
|
||||
public static final String STATS_TAG = "stat";
|
||||
public ItemStatType type;
|
||||
public int value;
|
||||
|
||||
public ItemStatTag(ItemStatType t, int tag)
|
||||
{
|
||||
type = t;
|
||||
value = tag;
|
||||
}
|
||||
|
||||
public void increment(){
|
||||
value++;
|
||||
}
|
||||
public void decrement()
|
||||
{
|
||||
value--;
|
||||
}
|
||||
|
||||
public void save(CompoundTag tag)
|
||||
{
|
||||
tag.putInt(STATS_TAG+"_"+type.name().toLowerCase(), value);
|
||||
}
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package dev.zontreck.thresholds.items.tags;
|
||||
|
||||
public enum ItemStatType {
|
||||
SWORD,
|
||||
ARMOR,
|
||||
PICK,
|
||||
AXE,
|
||||
SHOVEL,
|
||||
SHOVELPATH,
|
||||
HOE,
|
||||
SHEARS,
|
||||
EGGING
|
||||
}
|
||||
package dev.zontreck.otemod.items.tags;
|
||||
|
||||
public enum ItemStatType {
|
||||
SWORD,
|
||||
ARMOR,
|
||||
PICK,
|
||||
AXE,
|
||||
SHOVEL,
|
||||
SHOVELPATH,
|
||||
HOE,
|
||||
SHEARS,
|
||||
EGGING
|
||||
}
|
|
@ -1,47 +1,47 @@
|
|||
package dev.zontreck.thresholds.items.tags;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
|
||||
public class ItemStatistics {
|
||||
|
||||
public static String makeText(ItemStatTag tag)
|
||||
{
|
||||
return makeText(tag.type, tag.value);
|
||||
}
|
||||
public static String makeText(ItemStatType type, int val)
|
||||
{
|
||||
String lore = ChatColor.doColors("!White!");
|
||||
switch(type)
|
||||
{
|
||||
case SWORD -> {
|
||||
lore += "Mobs Killed: ";
|
||||
}
|
||||
case PICK -> {
|
||||
lore += "Blocks Mined: ";
|
||||
}
|
||||
case ARMOR -> {
|
||||
lore += "Damage Taken: ";
|
||||
}
|
||||
case SHOVEL -> {
|
||||
lore += "Blocks Dug Up: ";
|
||||
}
|
||||
case SHOVELPATH -> {
|
||||
lore += "Paths Made: ";
|
||||
}
|
||||
case AXE -> {
|
||||
lore += "Wood Chopped: ";
|
||||
}
|
||||
case HOE -> {
|
||||
lore += "Blocks Hoed: ";
|
||||
}
|
||||
case SHEARS -> {
|
||||
lore += "Sheep Shaved: ";
|
||||
}
|
||||
case EGGING -> {
|
||||
lore += "Mobs Egged: ";
|
||||
}
|
||||
}
|
||||
lore += ChatColor.doColors("!Green!"+val);
|
||||
return lore;
|
||||
}
|
||||
}
|
||||
package dev.zontreck.otemod.items.tags;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
|
||||
public class ItemStatistics {
|
||||
|
||||
public static String makeText(ItemStatTag tag)
|
||||
{
|
||||
return makeText(tag.type, tag.value);
|
||||
}
|
||||
public static String makeText(ItemStatType type, int val)
|
||||
{
|
||||
String lore = ChatColor.doColors("!White!");
|
||||
switch(type)
|
||||
{
|
||||
case SWORD -> {
|
||||
lore += "Mobs Killed: ";
|
||||
}
|
||||
case PICK -> {
|
||||
lore += "Blocks Mined: ";
|
||||
}
|
||||
case ARMOR -> {
|
||||
lore += "Damage Taken: ";
|
||||
}
|
||||
case SHOVEL -> {
|
||||
lore += "Blocks Dug Up: ";
|
||||
}
|
||||
case SHOVELPATH -> {
|
||||
lore += "Paths Made: ";
|
||||
}
|
||||
case AXE -> {
|
||||
lore += "Wood Chopped: ";
|
||||
}
|
||||
case HOE -> {
|
||||
lore += "Blocks Hoed: ";
|
||||
}
|
||||
case SHEARS -> {
|
||||
lore += "Sheep Shaved: ";
|
||||
}
|
||||
case EGGING -> {
|
||||
lore += "Mobs Egged: ";
|
||||
}
|
||||
}
|
||||
lore += ChatColor.doColors("!Green!"+val);
|
||||
return lore;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue