Add new datagenned resources

This commit is contained in:
Zontreck 2024-02-28 04:08:13 -07:00
parent 9e61a85498
commit f63f250e3b
309 changed files with 16088 additions and 300 deletions

View file

@ -1,22 +1,15 @@
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;
import dev.zontreck.libzontreck.edlibmc.Auxiliaries;
import dev.zontreck.libzontreck.edlibmc.Registries;
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.otemod.blocks.DeprecatedModBlocks;
import dev.zontreck.otemod.configs.snbt.ServerConfig;
import dev.zontreck.otemod.effects.ModEffects;
import dev.zontreck.otemod.enchantments.FlightEnchantment;
import dev.zontreck.otemod.enchantments.NightVisionEnchantment;
@ -28,28 +21,18 @@ import dev.zontreck.otemod.integrations.KeyBindings;
import dev.zontreck.otemod.items.DeprecatedModItems;
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.DyeColor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.GameType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.event.entity.item.ItemExpireEvent;
@ -64,10 +47,8 @@ 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;
@ -97,6 +78,7 @@ public class OTEMod
public static String OTEPrefix = "";
public static String ONLY_PLAYER = "";
public static IEventBus bus;
public OTEMod()
@ -110,9 +92,10 @@ public class OTEMod
// Register the setup method for modloading
bus.addListener(this::setup);
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, OTEServerConfig.SPEC, "otemod-rss-server.toml");
ServerConfig.load();
Auxiliaries.init(MOD_ID, LOGGER, null);
Registries.init(MOD_ID, null, bus);
// Register ourselves for server and other game events we are interested in
//final DeferredRegister<Codec<? extends BiomeModifier>> serializers = DeferredRegister.create(ForgeRegistries.Keys.BIOME_MODIFIER_SERIALIZERS, OTEMod.MOD_ID);
@ -177,7 +160,7 @@ public class OTEMod
}else {
Starter data = StarterProvider.getStarter();
if(data.getLastChanged() > tag.LastGiven && OTEServerConfig.GIVE_KIT_EVERY_CHANGE.get())
if(data.getLastChanged() > tag.LastGiven && ServerConfig.general.givesStarterKitOnChanged)
{
tag = PlayerFirstJoinTag.now();
tag.save(prof.NBT);
@ -262,7 +245,7 @@ public class OTEMod
{
if(ev.getEntity().level().isClientSide)return;
if(OTEServerConfig.ITEM_DESPAWN_TIMER.get()<=0)return;
if(ServerConfig.general.itemDespawnTimer<=0)return;
ItemEntity ite = (ItemEntity)ev.getEntity();
if(ite.getAge() != (1200 * 5)) {
@ -274,7 +257,7 @@ public class OTEMod
//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) * OTEServerConfig.ITEM_DESPAWN_TIMER.get())); // reset the life count
ev.setExtraLife((1200 * 5)+ ((1200 * 5) * ServerConfig.general.itemDespawnTimer)); // reset the life count
//OTEMod.LOGGER.info("Item ["+ev.getEntity().getItem().getDisplayName().getString()+"] was given extra life");
// Hopefully this works?
ev.setCanceled(true);

View file

@ -1,5 +1,7 @@
package dev.zontreck.otemod.blocks;
import dev.zontreck.libzontreck.edlibmc.Auxiliaries;
import dev.zontreck.libzontreck.edlibmc.StandardBlocks;
import dev.zontreck.otemod.OTEMod;
import dev.zontreck.otemod.implementation.CreativeModeTabs;
import net.minecraft.core.BlockPos;
@ -14,6 +16,7 @@ import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BedPart;
import net.minecraft.world.level.material.MapColor;
import net.minecraft.world.phys.AABB;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
@ -235,6 +238,53 @@ public class ModBlocks {
public static final RegistryObject<Block> DIRTY_GREEN_POOL_TILE_SLAB = registerWithItem(BLOCKS.register("dirty_green_pool_tile_slab", ()->new SlabBlock(stone)), new Item.Properties());
public static final RegistryObject<Block> UNCRAFTER = registerWithItem(BLOCKS.register("uncrafter", ()->new UncrafterBlock(BlockBehaviour.Properties.of().noOcclusion().requiresCorrectToolForDrops().strength(6))), new Item.Properties());
public static final RegistryObject<Block> CLINKER_BRICK_BLOCK = registerWithItem(BLOCKS.register("clinker_brick_block", ()->new StandardBlocks.BaseBlock(
StandardBlocks.CFG_DEFAULT,
BlockBehaviour.Properties.of().strength(0.5f, 7f).sound(SoundType.STONE)
)), new Item.Properties());
public static final RegistryObject<Block> CLINKER_BRICK_RECESSED = registerWithItem(BLOCKS.register("clinker_brick_recessed", ()->new StandardBlocks.HorizontalWaterLoggable(
StandardBlocks.CFG_CUTOUT|StandardBlocks.CFG_HORIZIONTAL|StandardBlocks.CFG_LOOK_PLACEMENT,
BlockBehaviour.Properties.of().strength(0.5f, 7f).sound(SoundType.STONE),
new AABB[] {
Auxiliaries.getPixeledAABB( 3,0, 0, 13,16, 1),
Auxiliaries.getPixeledAABB( 0,0, 1, 16,16,11),
Auxiliaries.getPixeledAABB( 4,0,11, 12,16,13)
}
)), new Item.Properties());
public static final RegistryObject<Block> CLINKER_BRICK_VERTICALLY_SLIT = registerWithItem(BLOCKS.register("clinker_brick_vertically_slit", ()->new StandardBlocks.HorizontalWaterLoggable(
StandardBlocks.CFG_CUTOUT|StandardBlocks.CFG_HORIZIONTAL|StandardBlocks.CFG_LOOK_PLACEMENT,
BlockBehaviour.Properties.of().strength(0.5f, 7f).sound(SoundType.STONE),
new AABB[] {
Auxiliaries.getPixeledAABB( 3,0, 0, 13,16, 1),
Auxiliaries.getPixeledAABB( 3,0,15, 13,16,16),
Auxiliaries.getPixeledAABB( 0,0, 1, 16,16,15)
}
)), new Item.Properties());
public static final RegistryObject<Block> CLINKER_BRICK_SLAB = registerWithItem(BLOCKS.register("clinker_brick_slab", ()->new SlabBlock(BlockBehaviour.Properties.copy(Blocks.STONE_SLAB))), new Item.Properties());
public static final RegistryObject<Block> CLINKER_BRICK_STAIRS = registerWithItem(BLOCKS.register("clinker_brick_stairs", ()->new StairBlock(CLINKER_BRICK_BLOCK.get()::defaultBlockState, BlockBehaviour.Properties.copy(Blocks.STONE_STAIRS))), new Item.Properties());
public static final RegistryObject<Block> CLINKER_BRICK_WALL = registerWithItem(BLOCKS.register("clinker_brick_wall", ()->new WallBlock(BlockBehaviour.Properties.copy(Blocks.STONE_BRICK_WALL))), new Item.Properties());
public static final RegistryObject<Block> CLINKER_BRICK_STAINED_BLOCK = registerWithItem(BLOCKS.register("clinker_brick_stained_block", ()->new Block(BlockBehaviour.Properties.copy(Blocks.STONE))), new Item.Properties());
public static final RegistryObject<Block> CLINKER_BRICK_STAINED_SLAB = registerWithItem(BLOCKS.register("clinker_brick_stained_slab", ()-> new SlabBlock(BlockBehaviour.Properties.copy(Blocks.STONE))), new Item.Properties());
public static final RegistryObject<Block> CLINKER_BRICK_STAINED_STAIRS = registerWithItem(BLOCKS.register("clinker_brick_stained_stairs", ()-> new StairBlock(CLINKER_BRICK_STAINED_BLOCK.get()::defaultBlockState, BlockBehaviour.Properties.copy(Blocks.STONE))), new Item.Properties());
public static final RegistryObject<Block> CLINKER_BRICK_SASTOR_CORNER_BLOCK = registerWithItem(BLOCKS.register("clinker_brick_sastor_corner_block", ()-> new RotatableBlock(BlockBehaviour.Properties.copy(Blocks.STONE))), new Item.Properties());
public static final RegistryObject<Block> SLAG_BRICK_BLOCK = registerWithItem(BLOCKS.register("slag_brick_block", ()-> new Block(BlockBehaviour.Properties.copy(Blocks.STONE))), new Item.Properties());
public static final RegistryObject<Block> SLAG_BRICK_SLAB = registerWithItem(BLOCKS.register("slag_brick_slab", ()-> new SlabBlock(BlockBehaviour.Properties.copy(Blocks.STONE))), new Item.Properties());
public static final RegistryObject<Block> SLAG_BRICK_STAIRS = registerWithItem(BLOCKS.register("slag_brick_stairs", ()-> new StairBlock(SLAG_BRICK_BLOCK.get()::defaultBlockState, BlockBehaviour.Properties.copy(Blocks.STONE))), new Item.Properties());
public static final RegistryObject<Block> SLAG_BRICK_WALL = registerWithItem(BLOCKS.register("slag_brick_wall", ()-> new WallBlock(BlockBehaviour.Properties.copy(Blocks.STONE_BRICK_WALL))), new Item.Properties());
}

View file

@ -0,0 +1,22 @@
package dev.zontreck.otemod.blocks;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;
public class UncrafterBlock extends HorizontalDirectionalBlock implements EntityBlock
{
public UncrafterBlock(Properties p_49795_) {
super(p_49795_);
}
@Nullable
@Override
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
return null;
}
}

View file

@ -22,6 +22,8 @@ public class ModEntities {
public static final RegistryObject<BlockEntityType<CompressionChamberBlockEntity>> COMPRESSION_CHAMBER = ENTITIES.register("compression_chamber", ()->BlockEntityType.Builder.of(CompressionChamberBlockEntity::new, ModBlocks.COMPRESSION_CHAMBER.get()).build(null));
public static final RegistryObject<BlockEntityType<UncrafterBlockEntity>> UNCRAFTER = ENTITIES.register("uncrafter", ()-> BlockEntityType.Builder.of(UncrafterBlockEntity::new, ModBlocks.UNCRAFTER.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));

View file

@ -0,0 +1,289 @@
package dev.zontreck.otemod.blocks.entity;
import dev.zontreck.otemod.implementation.OutputItemStackHandler;
import dev.zontreck.otemod.implementation.energy.OTEEnergy;
import dev.zontreck.otemod.implementation.uncrafting.UncrafterMenu;
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.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.IEnergyStorage;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemStackHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class UncrafterBlockEntity extends BlockEntity implements MenuProvider
{
public UncrafterBlockEntity(BlockPos position, BlockState state) {
super(ModEntities.UNCRAFTER.get(), position, state);
outputSlots = new OutputItemStackHandler(outputItems);
this.data = new ContainerData() {
@Override
public int get(int i) {
switch (i)
{
case 0: {
return UncrafterBlockEntity.this.progress;
}
default: return 0;
}
}
@Override
public void set(int i, int i1) {
switch (i)
{
case 0: {
UncrafterBlockEntity.this.progress = i1;
}
}
}
@Override
public int getCount() {
return 1;
}
};
}
protected final ContainerData data;
protected int progress = 0;
private static final int ENERGY_REQUIREMENT = 250;
public static int PROCESSING_TICKS = (3 * 20); // 3 seconds to uncraft
protected final ItemStackHandler itemHandler = new ItemStackHandler(1) {
@Override
protected void onContentsChanged(int slot) {
setChanged();
}
};
protected final ItemStackHandler outputItems = new ItemStackHandler((3*9)){
@Override
protected void onContentsChanged(int slot) {
setChanged();
}
};
private ItemStackHandler outputSlots;
private LazyOptional<IEnergyStorage> lazyEnergyHandler = LazyOptional.empty();
private LazyOptional<IItemHandler> lazyItemHandler = LazyOptional.empty();
private LazyOptional<IItemHandler> lazyOutputItems = LazyOptional.empty();
private final OTEEnergy ENERGY_STORAGE = new OTEEnergy(ENERGY_REQUIREMENT * 10, ENERGY_REQUIREMENT*2) {
@Override
public void onChanged() {
setChanged();
ModMessages.sendToAll(new EnergySyncS2CPacket(energy, getBlockPos()));
}
};
@Override
public Component getDisplayName() {
return Component.literal("Uncrafter");
}
@Nullable
@Override
public AbstractContainerMenu createMenu(int i, Inventory inventory, Player player) {
return new UncrafterMenu(i, inventory, this, data);
}
@Override
public void onLoad()
{
super.onLoad();
lazyItemHandler = LazyOptional.of(()->itemHandler);
lazyOutputItems = LazyOptional.of(()->outputSlots);
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", itemHandler.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);
itemHandler.deserializeNBT(nbt.getCompound("inventory"));
outputItems.deserializeNBT(nbt.getCompound("output"));
progress = nbt.getInt("prog");
ENERGY_STORAGE.setEnergy(nbt.getInt("energy"));
}
@Override
public @NotNull <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, @Nullable Direction side) {
if(cap == ForgeCapabilities.ENERGY) // all sides accept power
{
return lazyEnergyHandler.cast();
}
if(cap == ForgeCapabilities.FLUID_HANDLER)
{
//return lazyFluidHandler.cast(); // TODO: Implement a fluid storage, and add a spot for it on the GUI
}
if(cap == ForgeCapabilities.ITEM_HANDLER && side == Direction.DOWN)
{
return lazyOutputItems.cast();
}else return lazyItemHandler.cast(); // all sides except bottom of block
}
public void doDrop()
{
SimpleContainer cont = new SimpleContainer(itemHandler.getSlots());
for (int i = 0; i < itemHandler.getSlots(); i++) {
cont.setItem(i, itemHandler.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, UncrafterBlockEntity 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 >= UncrafterBlockEntity.PROCESSING_TICKS)
{
uncraftItem(entity);
}
}else {
if(entity.progress>0){
entity.resetProgress();
setChanged(lvl, pos, state);
}
}
}
private static void drain(UncrafterBlockEntity entity) {
entity.ENERGY_STORAGE.extractEnergy(ENERGY_REQUIREMENT, false);
}
private static boolean hasEnergy(UncrafterBlockEntity entity) {
return (entity.ENERGY_STORAGE.getEnergyStored() >= ENERGY_REQUIREMENT);
}
private static void uncraftItem(UncrafterBlockEntity entity) {
if(hasRecipe(entity))
{
ItemStack existing = entity.outputItems.getStackInSlot(0);
existing.setCount(existing.getCount()+1);
if(existing.is(Items.AIR))
{
existing = makeOutputItems(entity.itemHandler.getStackInSlot(0));
}
entity.itemHandler.extractItem(0, 1, false);
entity.outputItems.setStackInSlot(0, existing);
entity.resetProgress();
}
}
protected static ItemStack makeOutputItems(ItemStack original)
{
ItemStack newItem = new ItemStack(original.getItem(),1);
return newItem;
}
private void resetProgress() {
progress=0;
}
public IEnergyStorage getEnergyStorage() {
return ENERGY_STORAGE;
}
public void setEnergy(int energy) {
ENERGY_STORAGE.setEnergy(energy);
}
private static boolean hasRecipe(UncrafterBlockEntity entity) {
SimpleContainer inventory = new SimpleContainer(entity.itemHandler.getSlots());
for(int i=0;i<entity.itemHandler.getSlots();i++)
{
inventory.setItem(i, entity.itemHandler.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.itemHandler.getStackInSlot(0).isEmpty();
ItemStack result = null;
if(hasAnItem)
{
result = makeOutputItems(entity.itemHandler.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);
}
}

View file

@ -9,11 +9,10 @@ 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.configs.snbt.ServerConfig;
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;
@ -69,7 +68,7 @@ public class ChatServerOverride {
if(StarterProvider.exists())
OTEMod.checkFirstJoin(ev.player);
if(!OTEServerConfig.USE_CUSTOM_JOINLEAVE.get()) return;
if(!ServerConfig.chatOverrides.enableJoinLeave) return;
ChatHelpers.broadcast(ChatHelpers.macro("!Dark_Gray![!Dark_Green!+!Dark_Gray!] !Bold!!Dark_Aqua![0]",prof.nickname), ev.level.getServer());
@ -84,7 +83,7 @@ public class ChatServerOverride {
if(px==null)return;
if(!OTEServerConfig.USE_CUSTOM_JOINLEAVE.get()) return;
if(!ServerConfig.chatOverrides.enableJoinLeave) return;
// Send the alert
ChatHelpers.broadcast(ChatHelpers.macro("!Dark_Gray![!Dark_Red!-!Dark_Gray!] !Bold!!Dark_Aqua![0]", px.nickname), px.player.server);
@ -110,7 +109,7 @@ public class ChatServerOverride {
public void onChat(final ServerChatEvent ev){
if(ev.getPlayer().level().isClientSide)return;
// Player has chatted, apply override
if(!OTEServerConfig.USE_CUSTOM_CHATREPLACER.get()) return;
if(!ServerConfig.chatOverrides.enablePrettifier) return;
ServerPlayer sp = ev.getPlayer();

View file

@ -21,7 +21,6 @@ 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;
@ -36,52 +35,6 @@ public class CommandRegistry {
// 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)

View file

@ -6,17 +6,15 @@ import dev.zontreck.libzontreck.exceptions.InvalidDeserialization;
import dev.zontreck.libzontreck.util.ChatHelpers;
import dev.zontreck.libzontreck.vectors.Vector3;
import dev.zontreck.libzontreck.vectors.WorldPosition;
import dev.zontreck.otemod.configs.OTEServerConfig;
import dev.zontreck.otemod.configs.snbt.ServerConfig;
import dev.zontreck.otemod.implementation.Messages;
import dev.zontreck.otemod.registry.ModDimensions;
import dev.zontreck.otemod.registry.PerPlayerDataRegistry;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.commands.ExperienceCommand;
import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.server.command.EnumArgument;
public class BuildCommand
{
@ -39,7 +37,7 @@ public class BuildCommand
ServerPlayer sp = stack.getPlayer();
boolean playerIsOp = sp.hasPermissions(stack.getServer().getOperatorUserPermissionLevel());
if(playerIsOp || OTEServerConfig.ALLOW_BUILDER_DIM.get())
if(playerIsOp || ServerConfig.general.allowBuilder)
{
if(direction == Options.enter)

View file

@ -1,99 +0,0 @@
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.BooleanValue ALLOW_BUILDER_DIM;
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();
ALLOW_BUILDER_DIM = BUILDER.comment("Allow the builder dimension for non-opped players. This could be dangerous as the builder dimension swaps players into creative").define("allow_non_op_builder", false);
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();
}
}

View file

@ -0,0 +1,115 @@
package dev.zontreck.otemod.configs.snbt;
import dev.zontreck.libzontreck.util.SNbtIo;
import dev.zontreck.otemod.configs.snbt.sections.*;
import dev.zontreck.otemod.database.OTEDatastore;
import net.minecraft.nbt.CompoundTag;
import java.nio.file.Path;
public class ServerConfig
{
public static final String TAG_VERSION = "revision";
public static final Path FILE = OTEDatastore.of("server.snbt");
public static General general = new General();
public static Drops drops = new Drops();
public static Cooldowns cooldowns = new Cooldowns();
public static AntiGrief antigrief = new AntiGrief();
public static ChatOverrides chatOverrides = new ChatOverrides();
public static int revision = 0;
private static final int CURRENT_VERSION = 1;
public static void load()
{
CompoundTag tag = SNbtIo.loadSnbt(FILE);
deserialize(tag);
}
public static void commit()
{
SNbtIo.writeSnbt(FILE, serialize());
}
private static void migrate(int from, int to)
{
if(from == to)
{
return;
} else if(from > to)
{
throw new ArithmeticException("Cannot downgrade");
} else {
migration(from+1);
migrate(from+1,to);
}
}
private static void migration(int newVer)
{
revision = newVer;
switch (newVer)
{
case 1:
{
general = new General();
drops = new Drops();
cooldowns = new Cooldowns();
antigrief = new AntiGrief();
chatOverrides = new ChatOverrides();
break;
}
}
commit();
}
public static CompoundTag serialize()
{
CompoundTag tag = new CompoundTag();
tag.putInt(TAG_VERSION, revision);
tag.put(General.TAG_NAME, general.save());
tag.put(Cooldowns.TAG_NAME, cooldowns.save());
tag.put(AntiGrief.TAG_NAME, antigrief.save());
tag.put(ChatOverrides.TAG_NAME, chatOverrides.save());
return tag;
}
public static void deserialize(CompoundTag tag)
{
revision = tag.getInt(TAG_VERSION);
migrate(revision, CURRENT_VERSION);
if(tag.contains(General.TAG_NAME))
general = General.load(tag.getCompound(General.TAG_NAME));
if(tag.contains(Drops.TAG_NAME))
drops = Drops.load(tag.getCompound(Drops.TAG_NAME));
if(tag.contains(Cooldowns.TAG_NAME))
cooldowns = Cooldowns.load(tag.getCompound(Cooldowns.TAG_NAME));
if(tag.contains(AntiGrief.TAG_NAME))
antigrief = AntiGrief.load(tag.getCompound(AntiGrief.TAG_NAME));
if(tag.contains(ChatOverrides.TAG_NAME))
chatOverrides = ChatOverrides.load(tag.getCompound(ChatOverrides.TAG_NAME));
}
}

View file

@ -0,0 +1,81 @@
package dev.zontreck.otemod.configs.snbt.sections;
import dev.zontreck.ariaslib.util.Lists;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.StringTag;
import net.minecraft.nbt.Tag;
import java.util.ArrayList;
import java.util.List;
public class AntiGrief
{
public static final String TAG_NAME = "antigrief";
public static final String TAG_HEALER_TIMER = "healerTimer";
public static final String TAG_DEBUG = "debug";
public static final String TAG_HEALER_TIME_BETWEEN = "timeBetween";
public static final String TAG_MAX_TRIES = "maxTries";
public static final String TAG_EXCLUDE_DIMS = "excludeDimensions";
public int healerTimer = 250;
public boolean debug = false;
public int timeBetween = 20;
public int maxTries = 10;
public List<String> blacklistedDimensions = Lists.of("minecraft:the_nether", "minecraft:the_end", "otemod:resource", "otemod:threshold");
public CompoundTag save()
{
CompoundTag tag = new CompoundTag();
tag.putInt(TAG_HEALER_TIMER, healerTimer);
tag.putBoolean(TAG_DEBUG, debug);
tag.putInt(TAG_HEALER_TIME_BETWEEN, timeBetween);
tag.putInt(TAG_MAX_TRIES, maxTries);
ListTag blacklist = new ListTag();
for(String str : blacklistedDimensions)
{
blacklist.add(StringTag.valueOf(str));
}
tag.put(TAG_EXCLUDE_DIMS, blacklist);
return tag;
}
public static AntiGrief load(CompoundTag tag)
{
AntiGrief ag = new AntiGrief();
if(tag.contains(TAG_HEALER_TIMER))
ag.healerTimer = tag.getInt(TAG_HEALER_TIMER);
if(tag.contains(TAG_DEBUG))
ag.debug = tag.getBoolean(TAG_DEBUG);
if(tag.contains(TAG_HEALER_TIME_BETWEEN))
ag.timeBetween = tag.getInt(TAG_HEALER_TIME_BETWEEN);
if(tag.contains(TAG_MAX_TRIES))
ag.maxTries = tag.getInt(TAG_MAX_TRIES);
if(tag.contains(TAG_EXCLUDE_DIMS))
{
ag.blacklistedDimensions = new ArrayList<>();
ListTag blacklist = tag.getList(TAG_EXCLUDE_DIMS, ListTag.TAG_STRING);
for(Tag entry : blacklist)
{
StringTag stringTag = (StringTag) entry;
ag.blacklistedDimensions.add(stringTag.getAsString());
}
}
return ag;
}
}

View file

@ -0,0 +1,46 @@
package dev.zontreck.otemod.configs.snbt.sections;
import dev.zontreck.ariaslib.util.Lists;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.StringTag;
import net.minecraft.nbt.Tag;
import java.util.ArrayList;
import java.util.List;
public class ChatOverrides
{
public static final String TAG_NAME = "chatOverride";
public static final String TAG_PRETTIFIER = "enablePrettifier";
public static final String TAG_JOIN_LEAVE = "enableJoinLeaveMessages";
public boolean enablePrettifier = true;
public boolean enableJoinLeave = true;
public CompoundTag save()
{
CompoundTag tag = new CompoundTag();
tag.putBoolean(TAG_PRETTIFIER, enablePrettifier);
tag.putBoolean(TAG_JOIN_LEAVE, enableJoinLeave);
return tag;
}
public static ChatOverrides load(CompoundTag tag)
{
ChatOverrides ag = new ChatOverrides();
if(tag.contains(TAG_PRETTIFIER))
ag.enablePrettifier = tag.getBoolean(TAG_PRETTIFIER);
if(tag.contains(TAG_JOIN_LEAVE))
ag.enableJoinLeave = tag.getBoolean(TAG_JOIN_LEAVE);
return ag;
}
}

View file

@ -0,0 +1,95 @@
package dev.zontreck.otemod.configs.snbt.sections;
import dev.zontreck.ariaslib.util.Maps;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Cooldowns
{
public static final String TAG_NAME = "cooldowns";
public static final String TAG_LIST = "commands";
public Map<String, Integer> commands = Maps.of();
public CompoundTag save()
{
CompoundTag tag = new CompoundTag();
ListTag lst = new ListTag();
for(Map.Entry<String, Integer> entry : commands.entrySet())
{
Command cmd = new Command(entry.getKey(), entry.getValue());
lst.add(cmd.save());
}
tag.put(TAG_LIST, lst);
return tag;
}
public static Cooldowns load(CompoundTag tag)
{
Cooldowns cd = new Cooldowns();
ListTag lst = tag.getList(TAG_LIST, ListTag.TAG_COMPOUND);
for(Tag entry : lst)
{
CompoundTag compoundTag = (CompoundTag) entry;
Command cmd = Command.load(compoundTag);
cd.commands.put(cmd.command, cmd.seconds);
}
return cd;
}
public static class Command
{
public static final String TAG_COMMAND = "command";
public static final String TAG_SECONDS = "seconds";
public String command;
public int seconds;
private Command()
{
}
public Command(String cmd, int sec)
{
command=cmd;
seconds=sec;
}
public CompoundTag save()
{
CompoundTag tag = new CompoundTag();
tag.putString(TAG_COMMAND, command);
tag.putInt(TAG_SECONDS, seconds);
return tag;
}
public static Command load(CompoundTag tag)
{
Command cmd = new Command();
if(tag.contains(TAG_COMMAND))
cmd.command = tag.getString(TAG_COMMAND);
if(tag.contains(TAG_SECONDS))
cmd.seconds = tag.getInt(TAG_SECONDS);
return cmd;
}
}
}

View file

@ -0,0 +1,42 @@
package dev.zontreck.otemod.configs.snbt.sections;
import net.minecraft.nbt.CompoundTag;
public class Drops
{
public static final String TAG_NAME = "drops";
public static final String TAG_PLAYER_HEAD_DROPS = "enablePlayerHeadDrops";
public static final String TAG_SPAWN_EGG_CHANCE = "mobEggingChance";
public static final String TAG_PLAYER_HEAD_CHANCE = "playerHeadChance";
public boolean enablePlayerHeadChance = true;
public float mobEggingChance = 0.25f;
public float playerHeadChance=0.5f;
public CompoundTag save()
{
CompoundTag tag = new CompoundTag();
tag.putBoolean(TAG_PLAYER_HEAD_DROPS, enablePlayerHeadChance);
tag.putFloat(TAG_SPAWN_EGG_CHANCE, mobEggingChance);
tag.putFloat(TAG_PLAYER_HEAD_CHANCE, playerHeadChance);
return tag;
}
public static Drops load(CompoundTag tag)
{
Drops drops = new Drops();
if(tag.contains(TAG_PLAYER_HEAD_DROPS))
drops.enablePlayerHeadChance = tag.getBoolean(TAG_PLAYER_HEAD_DROPS);
if(tag.contains(TAG_SPAWN_EGG_CHANCE))
drops.mobEggingChance = tag.getFloat(TAG_SPAWN_EGG_CHANCE);
if(tag.contains(TAG_PLAYER_HEAD_CHANCE))
drops.playerHeadChance = tag.getFloat(TAG_PLAYER_HEAD_CHANCE);
return drops;
}
}

View file

@ -0,0 +1,71 @@
package dev.zontreck.otemod.configs.snbt.sections;
import net.minecraft.nbt.CompoundTag;
public class General
{
public static final String TAG_NAME = "general";
public static final String TAG_DEBUG = "debug";
public static final String TAG_STARTER_KIT = "givesStarterKitOnChange";
public static final String TAG_ALLOW_BUILDER_DIM = "allowNonOppedBuilders";
public static final String TAG_MAX_VAULTS = "maxVaults";
public static final String TAG_INFINITE_VAULTS = "infiniteVaults";
public static final String TAG_ITEM_DESPAWN_TIMER = "itemDespawnTimer";
public static final String TAG_DEATH_MESSAGES = "enableDeathMessages";
public boolean debug = false;
public boolean givesStarterKitOnChanged = false;
public boolean allowBuilder = false;
public int maxVaults = 27;
public boolean infiniteVaults = false;
public int itemDespawnTimer = 2;
public boolean enableDeathMessages = true;
public CompoundTag save()
{
CompoundTag tag = new CompoundTag();
tag.putBoolean(TAG_DEBUG, debug);
tag.putBoolean(TAG_STARTER_KIT, givesStarterKitOnChanged);
tag.putBoolean(TAG_ALLOW_BUILDER_DIM, allowBuilder);
tag.putInt(TAG_MAX_VAULTS, maxVaults);
tag.putBoolean(TAG_INFINITE_VAULTS, infiniteVaults);
tag.putInt(TAG_ITEM_DESPAWN_TIMER, itemDespawnTimer);
tag.putBoolean(TAG_DEATH_MESSAGES, enableDeathMessages);
return tag;
}
public static General load(CompoundTag tag)
{
General general = new General();
if(tag.contains(TAG_DEBUG))
general.debug = tag.getBoolean(TAG_DEBUG);
if(tag.contains(TAG_STARTER_KIT))
general.givesStarterKitOnChanged = tag.getBoolean(TAG_STARTER_KIT);
if(tag.contains(TAG_ALLOW_BUILDER_DIM))
general.allowBuilder = tag.getBoolean(TAG_ALLOW_BUILDER_DIM);
if(tag.contains(TAG_MAX_VAULTS))
general.maxVaults = tag.getInt(TAG_MAX_VAULTS);
if(tag.contains(TAG_INFINITE_VAULTS))
general.infiniteVaults = tag.getBoolean(TAG_INFINITE_VAULTS);
if(tag.contains(TAG_ITEM_DESPAWN_TIMER))
general.itemDespawnTimer = tag.getInt(TAG_ITEM_DESPAWN_TIMER);
if(tag.contains(TAG_DEATH_MESSAGES))
general.enableDeathMessages = tag.getBoolean(TAG_DEATH_MESSAGES);
return general;
}
}

View file

@ -1,22 +1,23 @@
package dev.zontreck.otemod.data;
import dev.zontreck.otemod.OTEMod;
import dev.zontreck.otemod.blocks.*;
import dev.zontreck.otemod.items.DeprecatedModItems;
import dev.zontreck.otemod.blocks.ModBlocks;
import net.minecraft.core.Direction;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.properties.*;
import net.minecraftforge.client.model.generators.BlockStateProvider;
import net.minecraftforge.client.model.generators.ConfiguredModel;
import net.minecraftforge.client.model.generators.ModelFile;
import net.minecraftforge.client.model.generators.VariantBlockStateBuilder;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class ModBlockStatesProvider extends BlockStateProvider
{
import java.util.concurrent.atomic.AtomicReference;
public class ModBlockStatesProvider extends BlockStateProvider {
public ModBlockStatesProvider(PackOutput output, ExistingFileHelper existingFileHelper) {
super(output, OTEMod.MOD_ID, existingFileHelper);
}
@ -74,45 +75,226 @@ public class ModBlockStatesProvider extends BlockStateProvider
stairBlock(ModBlocks.DIRTY_GREEN_POOL_TILE_STAIRS, ModBlocks.DIRTY_GREEN_POOL_TILE);
slabBlock(ModBlocks.DIRTY_GREEN_POOL_TILE_SLAB, ModBlocks.DIRTY_GREEN_POOL_TILE);
ResourceLocation[] clinkerBlock = new ResourceLocation[]{
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture0"),
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture1"),
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture2"),
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture3"),
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture4"),
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture5"),
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture6"),
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture7")
};
ResourceLocation[] clinkerStainedBlock = new ResourceLocation[]{
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture0"),
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture1"),
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture2"),
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture3"),
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture4"),
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture5"),
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture6"),
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture7")
};
ResourceLocation[] slagBricks = new ResourceLocation[]{
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture0"),
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture1"),
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture2"),
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture3"),
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture4"),
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture5"),
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture6"),
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture7")
};
variantCubeBlock(ModBlocks.CLINKER_BRICK_BLOCK, clinkerBlock);
customSlabBlock(ModBlocks.CLINKER_BRICK_SLAB, clinkerBlock);
customStairBlock(ModBlocks.CLINKER_BRICK_STAIRS, clinkerBlock);
variantCubeBlock(ModBlocks.CLINKER_BRICK_STAINED_BLOCK, clinkerStainedBlock);
customSlabBlock(ModBlocks.CLINKER_BRICK_STAINED_SLAB, clinkerStainedBlock);
customStairBlock(ModBlocks.CLINKER_BRICK_STAINED_STAIRS, clinkerStainedBlock);
wallBlock(ModBlocks.CLINKER_BRICK_WALL, new ResourceLocation(OTEMod.MOD_ID, "block/engineersdecor/clinker_brick/clinker_brick_wall0"));
variantCubeBlock(ModBlocks.SLAG_BRICK_BLOCK, slagBricks);
customSlabBlock(ModBlocks.SLAG_BRICK_SLAB, slagBricks);
customStairBlock(ModBlocks.SLAG_BRICK_STAIRS, slagBricks);
wallBlock(ModBlocks.SLAG_BRICK_WALL, new ResourceLocation(OTEMod.MOD_ID, "block/engineersdecor/slag_brick/slag_brick_wall0"));
}
private void blockWithItem(RegistryObject<Block> blockRegistryObject)
private void wallBlock(RegistryObject<Block> blk, ResourceLocation texture)
{
wallBlock((WallBlock) blk.get(), texture);
simpleBlockItem(blk.get(), models().withExistingParent(name(blk.get()), blk.getId()));
}
private void blockWithItem(RegistryObject<Block> blockRegistryObject) {
simpleBlockWithItem(blockRegistryObject.get(), cubeAll(blockRegistryObject.get()));
}
private void blockWithItem(RegistryObject<Block> blockRegistryObject, ModelFile model)
{
private void blockWithItem(RegistryObject<Block> blockRegistryObject, ModelFile model) {
simpleBlockWithItem(blockRegistryObject.get(), model);
}
private void stairBlock(RegistryObject<Block> blk, RegistryObject<Block> texture)
{
private void stairBlock(RegistryObject<Block> blk, RegistryObject<Block> texture) {
stairsBlock((StairBlock) blk.get(), blockTexture(texture.get()));
simpleBlockItem(blk.get(), stairsModel(blk.get(), texture.get()));
}
private void carpetBlock(RegistryObject<Block> blk, RegistryObject<Block> texture)
{
private void carpetBlock(RegistryObject<Block> blk, RegistryObject<Block> texture) {
simpleBlockWithItem(blk.get(), carpetModel(blk.get(), texture.get()));
}
private String name(Block block) {
return this.key(block).getPath();
}
private ResourceLocation key(Block block) {
return ForgeRegistries.BLOCKS.getKey(block);
}
public ModelFile stairsModel(Block block, Block texture) {
return this.models().stairs(name(block), blockTexture(texture), blockTexture(texture), blockTexture(texture));
}
public ModelFile carpetModel(Block block, Block texture) {
return this.models().carpet(name(block), blockTexture(texture));
}
public ModelFile slabModel(Block block, Block texture) {
return this.models().slab(name(block), blockTexture(texture), blockTexture(texture), blockTexture(texture));
}
private void slabBlock(RegistryObject<Block> blk, RegistryObject<Block> texture)
{
private void slabBlock(RegistryObject<Block> blk, RegistryObject<Block> texture) {
slabBlock((SlabBlock) blk.get(), blockTexture(texture.get()), blockTexture(texture.get()));
simpleBlockItem(blk.get(), slabModel(blk.get(), texture.get()));
}
private void customSlabBlock(RegistryObject<Block> blockId, ResourceLocation... variations) {
VariantBlockStateBuilder builder = getVariantBuilder(blockId.get());
AtomicReference<ModelFile> model0 = new AtomicReference<>();
builder.forAllStates((state)->{
ConfiguredModel[] models = new ConfiguredModel[variations.length];
String appendName = "";
SlabType type = state.getValue(SlabBlock.TYPE);
if(type == SlabType.BOTTOM)
appendName = "_bottom";
else if(type == SlabType.TOP)
appendName = "_top";
else if(type == SlabType.DOUBLE)
appendName = "_double";
for (int i = 0; i < variations.length; i++) {
ResourceLocation texture = variations[i];
ResourceLocation rss = new ResourceLocation(texture.getNamespace(), "block/" + texture.getPath());
ModelFile model = null;
if(type == SlabType.TOP)
model = models().slabTop(name(blockId.get()) + "_model" + i + appendName, rss, rss, rss);
else if(type == SlabType.BOTTOM)
model = models().slab(name(blockId.get()) + "_model" + i + appendName, rss, rss, rss);
else if(type == SlabType.DOUBLE)
model = models().cubeAll(name(blockId.get()) + "_model" + i + appendName, rss);
ConfiguredModel[] cfgModel = ConfiguredModel.builder().modelFile(model).build();
if(i==0 && model0.get()==null && type == SlabType.BOTTOM) model0.set(model);
models[i] = cfgModel[0];
//builder.partialState().addModels(cfgModel);
}
return models;
});
simpleBlockItem(blockId.get(), model0.get());
}
private void customStairBlock(RegistryObject<Block> blockId, ResourceLocation... variations) {
VariantBlockStateBuilder builder = getVariantBuilder(blockId.get());
ResourceLocation blockDefault = blockTexture(blockId.get());
AtomicReference<ModelFile> model0 = new AtomicReference<>();
builder.forAllStates((state)->{
ConfiguredModel[] models = new ConfiguredModel[variations.length];
Direction facing = (Direction)state.getValue(StairBlock.FACING);
Half half = (Half)state.getValue(StairBlock.HALF);
StairsShape shape = (StairsShape)state.getValue(StairBlock.SHAPE);
int yRot = (int)facing.getClockWise().toYRot();
if (shape == StairsShape.INNER_LEFT || shape == StairsShape.OUTER_LEFT) {
yRot += 270;
}
if (shape != StairsShape.STRAIGHT && half == Half.TOP) {
yRot += 90;
}
yRot %= 360;
boolean uvlock = yRot != 0 || half == Half.TOP;
String modelName = (shape == StairsShape.STRAIGHT) ? "" : (shape != StairsShape.INNER_LEFT && shape != StairsShape.INNER_RIGHT) ? "_outer":"_inner";
boolean straight = (shape == StairsShape.STRAIGHT);
boolean inner = (shape == StairsShape.INNER_LEFT || shape == StairsShape.INNER_RIGHT);
for (int i = 0; i < variations.length; i++) {
ResourceLocation texture = variations[i];
ResourceLocation rss = new ResourceLocation(texture.getNamespace(), "block/" + texture.getPath());
ModelFile cubeModel = null;
if(straight)
cubeModel = models().stairs(
blockId.getId().getPath() + "_model"+i + modelName, // Model name
rss, rss, rss // Texture location
);
if(inner)
cubeModel = models().stairsInner(blockId.getId().getPath()+"_model"+i + modelName, rss, rss, rss);
else if(!inner && !straight)
cubeModel = models().stairsOuter(blockId.getId().getPath() + "_model"+i+modelName, rss, rss, rss);
ConfiguredModel[] cfgModel = ConfiguredModel.builder().modelFile(cubeModel).rotationX(half == Half.BOTTOM ? 0 : 180).rotationY(yRot).uvLock(uvlock).build();
if(i==0 && model0.get()==null) model0.set(cubeModel);
models[i] = cfgModel[0];
//builder.partialState().addModels(cfgModel);
}
return models;
});
simpleBlockItem(blockId.get(), model0.get());
}
public void variantCubeBlock(RegistryObject<Block> blockId, ResourceLocation... variations) {
VariantBlockStateBuilder builder = getVariantBuilder(blockId.get());
ResourceLocation blockDefault = blockTexture(blockId.get());
ModelFile model0 = null;
for (int i = 0; i < variations.length; i++) {
ResourceLocation texture = variations[i];
ResourceLocation rss = new ResourceLocation(texture.getNamespace(), "block/" + texture.getPath());
ModelFile cubeModel = models().cubeAll(
blockId.getId().getPath() + "_model"+i, // Model name
rss // Texture location
);
var cfgModel = ConfiguredModel.builder().modelFile(cubeModel).build();
if(i==0)model0 = cubeModel;
builder.partialState().addModels(cfgModel);
}
simpleBlockItem(blockId.get(), model0);
}
}

View file

@ -61,6 +61,11 @@ public class ModItemModelsProvider extends ItemModelProvider
item(ModItems.LIME_BRICK);
item(ModItems.GREEN_BRICK);
/*
Engineer's Decor Items
*/
item(ModItems.METAL_BAR);
/*

View file

@ -107,6 +107,26 @@ public class ModBlockLootTablesProvider extends BlockLootSubProvider
dropSelf(ModBlocks.DIRTY_GREEN_POOL_TILE_SLAB.get());
dropSelf(ModBlocks.DIRTY_GREEN_POOL_TILE_STAIRS.get());
dropSelf(ModBlocks.FILTHY_GREEN_POOL_LIGHT.get());
dropSelf(ModBlocks.UNCRAFTER.get());
/*
Engineer's Decor Blocks
*/
dropSelf(ModBlocks.CLINKER_BRICK_BLOCK.get());
dropSelf(ModBlocks.CLINKER_BRICK_RECESSED.get());
dropSelf(ModBlocks.CLINKER_BRICK_VERTICALLY_SLIT.get());
dropSelf(ModBlocks.CLINKER_BRICK_SLAB.get());
dropSelf(ModBlocks.CLINKER_BRICK_STAIRS.get());
dropSelf(ModBlocks.CLINKER_BRICK_STAINED_BLOCK.get());
dropSelf(ModBlocks.CLINKER_BRICK_STAINED_SLAB.get());
dropSelf(ModBlocks.CLINKER_BRICK_STAINED_STAIRS.get());
dropSelf(ModBlocks.CLINKER_BRICK_SASTOR_CORNER_BLOCK.get());
dropSelf(ModBlocks.CLINKER_BRICK_WALL.get());
dropSelf(ModBlocks.SLAG_BRICK_BLOCK.get());
dropSelf(ModBlocks.SLAG_BRICK_SLAB.get());
dropSelf(ModBlocks.SLAG_BRICK_WALL.get());
dropSelf(ModBlocks.SLAG_BRICK_STAIRS.get());

View file

@ -3,29 +3,14 @@ package dev.zontreck.otemod.enchantments;
import dev.zontreck.libzontreck.util.ItemUtils;
import dev.zontreck.libzontreck.util.ServerUtilities;
import dev.zontreck.otemod.OTEMod;
import dev.zontreck.otemod.configs.OTEServerConfig;
import dev.zontreck.otemod.configs.snbt.ServerConfig;
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;
@ -86,7 +71,7 @@ public class FlightEnchantment extends Enchantment
if(OTEServerConfig.DEBUG.get())
if(ServerConfig.general.debug)
{
OTEMod.LOGGER.info("> Flight Enchantment Tick <");
}

View file

@ -1,12 +1,9 @@
package dev.zontreck.otemod.enchantments;
import java.util.Random;
import dev.zontreck.otemod.OTEMod;
import dev.zontreck.otemod.configs.OTEServerConfig;
import dev.zontreck.otemod.configs.snbt.ServerConfig;
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;
@ -62,14 +59,14 @@ public class MobEggEnchantment extends Enchantment
public static boolean givesEgg(int level, int bias)
{
double CHANCE = OTEServerConfig.SPAWN_EGG_CHANCE.get() * 100;
double CHANCE = ServerConfig.drops.mobEggingChance * 100;
CHANCE *= (level / 0.5);
CHANCE += bias;
double rng = Math.random()*100000;
if(OTEServerConfig.DEBUG.get())
if(ServerConfig.general.debug)
{
OTEMod.LOGGER.info("Spawn Egg Chance (" + CHANCE + ") [" + rng + "]");
}

View file

@ -3,8 +3,7 @@ package dev.zontreck.otemod.enchantments;
import dev.zontreck.libzontreck.util.ItemUtils;
import dev.zontreck.libzontreck.util.ServerUtilities;
import dev.zontreck.otemod.OTEMod;
import dev.zontreck.otemod.configs.OTEServerConfig;
import dev.zontreck.otemod.effects.ModEffects;
import dev.zontreck.otemod.configs.snbt.ServerConfig;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
@ -12,11 +11,6 @@ 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;
import net.minecraftforge.fml.common.Mod;
import java.util.concurrent.atomic.AtomicInteger;
@ -64,7 +58,7 @@ public class NightVisionEnchantment extends Enchantment
if(OTEServerConfig.DEBUG.get())
if(ServerConfig.general.debug)
{
OTEMod.LOGGER.info("> NVision Enchantment Tick <");
}

View file

@ -11,21 +11,17 @@ import dev.zontreck.libzontreck.util.heads.HeadUtilities;
import dev.zontreck.libzontreck.vectors.Vector3;
import dev.zontreck.libzontreck.vectors.WorldPosition;
import dev.zontreck.otemod.OTEMod;
import dev.zontreck.otemod.configs.OTEServerConfig;
import dev.zontreck.otemod.configs.snbt.ServerConfig;
import dev.zontreck.otemod.enchantments.MobEggEnchantment;
import dev.zontreck.otemod.enchantments.ModEnchantments;
import dev.zontreck.otemod.implementation.DeathMessages;
import dev.zontreck.otemod.implementation.InventoryBackup;
import dev.zontreck.otemod.implementation.Messages;
import dev.zontreck.otemod.items.tags.ItemStatType;
import dev.zontreck.otemod.registry.ModDimensions;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.level.ServerPlayerGameMode;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.DamageSources;
import net.minecraft.world.damagesource.DamageTypes;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
@ -42,8 +38,6 @@ import net.minecraftforge.event.entity.living.LivingHurtEvent;
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;
@ -66,7 +60,7 @@ public class EventHandler {
}
profile.deaths++;
profile.commit();
if(!OTEServerConfig.ENABLE_PLAYER_HEAD_DROPS.get())
if(!ServerConfig.drops.enablePlayerHeadChance)
{
return;
}
@ -79,7 +73,7 @@ public class EventHandler {
}
// Calculate chance
double base_chance = OTEServerConfig.CHANCE_OF_PLAYER_HEAD.get();
double base_chance = ServerConfig.drops.playerHeadChance;
base_chance += looting;
base_chance *= 100;
@ -103,7 +97,7 @@ public class EventHandler {
event.getEntity().spawnAtLocation(head);
}
if(OTEServerConfig.ENABLE_DEATH_MESSAGES.get())
if(ServerConfig.general.enableDeathMessages)
{
try {

View file

@ -1,7 +1,7 @@
package dev.zontreck.otemod.implementation.events;
import dev.zontreck.libzontreck.profiles.Profile;
import dev.zontreck.otemod.configs.OTEServerConfig;
import dev.zontreck.otemod.configs.snbt.ServerConfig;
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=OTEServerConfig.MAX_VAULTS.get();
max = ServerConfig.general.maxVaults;
vault_num = num;
in_use = vaultsInUse;
playerMax=user.available_vaults;

View file

@ -4,6 +4,7 @@ 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.uncrafting.UncrafterMenu;
import dev.zontreck.otemod.implementation.vault.StarterMenu;
import dev.zontreck.otemod.implementation.vault.VaultMenu;
import net.minecraft.world.inventory.AbstractContainerMenu;
@ -28,6 +29,8 @@ public final class ModMenuTypes
public static final RegistryObject<MenuType<CompressionChamberMenu>> COMPRESSION_CHAMBER = registerMenuType(CompressionChamberMenu::new, "compression_chamber");
public static final RegistryObject<MenuType<UncrafterMenu>> UNCRAFTER = registerMenuType(UncrafterMenu::new, "uncrafter");
private static <T extends AbstractContainerMenu> RegistryObject<MenuType<T>> registerMenuType(IContainerFactory<T> factory, String name)
{

View file

@ -0,0 +1,165 @@
package dev.zontreck.otemod.implementation.uncrafting;
import dev.zontreck.otemod.blocks.ModBlocks;
import dev.zontreck.otemod.blocks.entity.CompressionChamberBlockEntity;
import dev.zontreck.otemod.blocks.entity.UncrafterBlockEntity;
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 UncrafterMenu extends AbstractContainerMenu
{
public final UncrafterBlockEntity entity;
public final Level level;
public final ContainerData data;
public UncrafterMenu(int id, Inventory inv, FriendlyByteBuf buf)
{
this(id, inv, inv.player.level().getBlockEntity(buf.readBlockPos()), new SimpleContainerData(1));
}
public UncrafterMenu(int id, Inventory inv, BlockEntity entity, ContainerData data)
{
super(ModMenuTypes.UNCRAFTER.get(), id);
checkContainerSize(inv, 1);
this.data=data;
this.level = entity.getLevel();
this.entity = (UncrafterBlockEntity) entity;
addPlayerInventory(inv);
addPlayerHotbar(inv);
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.UP).ifPresent(handler->{
addSlot(new SlotItemHandler(handler, 0, 87,39));
});
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.DOWN).ifPresent(handler->{
for(int Y = 0; Y < 2; Y ++)
{
for(int X = 0; X < 9; X++)
{
addSlot(new SlotItemHandler(handler, X + Y * 9 + 9, UNCRAFTER_STORAGE_LEFT * X * 18, UNCRAFTER_STORAGE_HEIGHT*Y*18));
}
}
});
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 = UncrafterBlockEntity.PROCESSING_TICKS;
int progressArrow = 69;
if(progress != 0 && max != 0)
{
int percent = progress * progressArrow / max;
return percent;
}
return 0;
}
private static final int UNCRAFTER_STORAGE_LEFT = 15;
private static final int UNCRAFTER_STORAGE_HEIGHT = 63;
// 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.COMPRESSION_CHAMBER.get());
}
private static final int PLAYER_INVENTORY_FIRST_SLOT_HEIGHT = 107;
private static final int PLAYER_INVENTORY_FIRST_SLOT_LEFT = 15;
private static final int PLAYER_HOTBAR_FIRST_SLOT = 164;
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));
}
}
}

View file

@ -0,0 +1,98 @@
package dev.zontreck.otemod.implementation.uncrafting;
import com.mojang.blaze3d.systems.RenderSystem;
import dev.zontreck.otemod.OTEMod;
import dev.zontreck.otemod.implementation.MouseHelpers;
import dev.zontreck.otemod.implementation.compressor.CompressionChamberMenu;
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;
import java.util.Optional;
public class UncrafterScreen extends AbstractContainerScreen<UncrafterMenu>
{
private static final ResourceLocation TEXTURE = new ResourceLocation(OTEMod.MOD_ID, "textures/gui/uncrafter.png");
private EnergyInfoArea EIA;
public UncrafterScreen(UncrafterMenu pMenu, Inventory pPlayerInventory, Component pTitle) {
super(pMenu, pPlayerInventory, pTitle);
this.topPos=0;
this.leftPos=0;
this.imageWidth=198;
this.imageHeight=204;
}
@Override
protected void init() {
super.init();
assignEnergyArea();
}
private void assignEnergyArea() {
int x = (width - imageWidth )/2;
int y = (height - imageHeight)/2;
EIA = new EnergyInfoArea(x+182, y+126, menu.entity.getEnergyStorage(), 5, 63);
}
@Override
protected void renderBg(GuiGraphics guiGraphics, float v, int i, int i1) {
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderTexture(0, TEXTURE);
guiGraphics.blit(TEXTURE, this.leftPos, this.topPos, 0,0, imageWidth, imageHeight);
renderCraftingProgress(guiGraphics);
EIA.draw(guiGraphics);
}
@Override
protected void renderLabels(GuiGraphics stack, int mouseX, int mouseY)
{
stack.drawString(font, this.title.getString(), 32, 4, 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, 182, 126, 5, 63)){
stack.renderTooltip(font, EIA.getTooltips(), Optional.empty(), mouseX-x, mouseY-y);
}
}
private void renderCraftingProgress(GuiGraphics stack)
{
if(menu.isCrafting())
{
stack.blit(TEXTURE, leftPos+116, topPos+44, 179, 11, menu.getScaledProgress(),7);
}
}
@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);
}
}

View file

@ -4,10 +4,6 @@ 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;

View file

@ -1,14 +1,11 @@
package dev.zontreck.otemod.implementation.vault;
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
{

View file

@ -7,7 +7,7 @@ import java.nio.file.Path;
import java.util.List;
import dev.zontreck.libzontreck.profiles.Profile;
import dev.zontreck.otemod.configs.OTEServerConfig;
import dev.zontreck.otemod.configs.snbt.ServerConfig;
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(OTEServerConfig.MAX_VAULTS.get()==0){
if(ServerConfig.general.maxVaults ==0){
if(consumed < prof.available_vaults){
return false;
}else return true;
}
if(prof.available_vaults >= OTEServerConfig.MAX_VAULTS.get())
if(prof.available_vaults >= ServerConfig.general.maxVaults)
{
if(consumed<prof.available_vaults)
{

View file

@ -78,6 +78,9 @@ public class ModItems {
public static final RegistryObject<Item> GREEN_BRICK = CreativeModeTabs.addToOTEModTab(ITEMS.register("green_brick", ()->new Item(new Item.Properties())));
public static final RegistryObject<Item> METAL_BAR = CreativeModeTabs.addToOTEModTab(ITEMS.register("metal_bar", ()->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())));

View file

@ -1,22 +1,17 @@
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.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 dev.zontreck.otemod.configs.snbt.ServerConfig;
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
@ -50,9 +45,9 @@ public class VaultItem extends Item
Profile p;
try {
p = Profile.get_profile_of(pPlayer.getStringUUID());
if(OTEServerConfig.MAX_VAULTS.get()>0)
if(ServerConfig.general.maxVaults >0)
{
if(p.available_vaults >= OTEServerConfig.MAX_VAULTS.get())
if(p.available_vaults >= ServerConfig.general.maxVaults)
{
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);

View file

@ -7,9 +7,8 @@ import java.util.ListIterator;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import dev.zontreck.libzontreck.exceptions.InvalidSideException;
import dev.zontreck.libzontreck.vectors.WorldPosition;
import dev.zontreck.otemod.configs.OTEServerConfig;
import dev.zontreck.otemod.configs.snbt.ServerConfig;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
@ -34,7 +33,7 @@ public class BlockContainerList {
public int getNewLongestTick()
{
//Random rng = new Random();
int newLonger = OTEServerConfig.TIME_BETWEEN_BLOCKS.get();
int newLonger = ServerConfig.antigrief.timeBetween;
int cur = 0;
for (StoredBlock storedBlock : containers) {
@ -42,7 +41,7 @@ public class BlockContainerList {
cur = storedBlock.getTickValue();
}
}
if(cur == 0)cur = OTEServerConfig.HEALER_TIMER.get();
if(cur == 0)cur = ServerConfig.antigrief.healerTimer;
return cur + newLonger;
}
@ -78,7 +77,7 @@ public class BlockContainerList {
WorldPosition wp = storedBlock.getWorldPosition();
BlockState bs = wp.getActualDimension().getBlockState(wp.Position.asBlockPos());
if(bs.is(storedBlock.getState().getBlock()) || storedBlock.getTries() >= OTEServerConfig.MAX_TRIES_HEAL.get())
if(bs.is(storedBlock.getState().getBlock()) || storedBlock.getTries() >= ServerConfig.antigrief.maxTries)
{
//HealRunner.scheduleHeal(storedBlock);

View file

@ -1,17 +1,15 @@
package dev.zontreck.otemod.zschem;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Path;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import dev.zontreck.otemod.configs.OTEServerConfig;
import dev.zontreck.libzontreck.util.SNbtIo;
import dev.zontreck.otemod.configs.snbt.ServerConfig;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtIo;
import net.minecraft.nbt.NbtUtils;
import net.minecraftforge.fml.loading.FMLConfig;
import net.minecraftforge.fml.loading.FMLPaths;
@ -33,20 +31,10 @@ public class BlockSaver {
File x = getPath().toFile();
if(OTEServerConfig.DEBUG_HEALER.get())
if(ServerConfig.antigrief.debug)
{
// Save as sNBT
String prettyFormat = NbtUtils.structureToSnbt(primary);
BufferedWriter bw;
try {
bw = new BufferedWriter(new FileWriter(x));
bw.write(prettyFormat);
bw.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
SNbtIo.writeSnbt(x.toPath(), primary);
}else{
try {
NbtIo.writeCompressed(primary, x);
@ -63,7 +51,7 @@ public class BlockSaver {
// Healer Queue's data source is a NBT File in the config folder
public static final String HealerQueueFile = ".nbt";
public static final String HealerQueueDebugFile = ".dev.nbt";
public static final String HealerQueueDebugFile = ".dev.snbt";
public static Path getPath()
{
@ -76,7 +64,7 @@ public class BlockSaver {
public static String getExtension()
{
if(OTEServerConfig.DEBUG_HEALER.get())
if(ServerConfig.antigrief.debug)
{
return BlockSaver.HealerQueueDebugFile;

View file

@ -5,8 +5,7 @@ import java.util.Map;
import dev.zontreck.libzontreck.vectors.Vector3;
import dev.zontreck.libzontreck.vectors.WorldPosition;
import dev.zontreck.otemod.configs.OTEServerConfig;
import net.minecraft.client.telemetry.events.WorldLoadEvent;
import dev.zontreck.otemod.configs.snbt.ServerConfig;
import net.minecraft.server.level.ServerLevel;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.level.ExplosionEvent;
@ -25,7 +24,7 @@ public class EventHandler {
// Register blocks to be healed
WorldPosition wpos = new WorldPosition(new Vector3(ev.getExplosion().getPosition()), (ServerLevel) ev.getLevel());
if(OTEServerConfig.EXCLUDE_DIMS.get().contains(wpos.Dimension)){
if(ServerConfig.antigrief.blacklistedDimensions.contains(wpos.Dimension)){
// Dimension is on the exclusion list. Do not process.
return;
}
@ -44,16 +43,6 @@ public class EventHandler {
return healers;
}
@SubscribeEvent
public void onLoadLevel(LevelEvent.Load ev)
{
if(!ev.getLevel().isClientSide() && ev.getLevel() instanceof ServerLevel)
{
healers.put((ServerLevel)ev.getLevel(), WorldProp.acquire((ServerLevel)ev.getLevel()));
}
}
@SubscribeEvent
public void onUnload(LevelEvent.Unload ev)
{
@ -82,6 +71,9 @@ public class EventHandler {
WorldProp wp = WorldProp.acquire((ServerLevel)ev.level);
if(wp!=null){
wp.onTick();
} else {
if(!healers.containsKey((ServerLevel) ev.level))
healers.put((ServerLevel) ev.level, wp);
}
MemoryHolder.tick();