Push 1.3.2.1
Add item despawn time amplifier config value
This commit is contained in:
parent
280b8dbde6
commit
30f4f3deff
9 changed files with 116 additions and 16 deletions
|
@ -7,7 +7,7 @@ plugins {
|
|||
|
||||
|
||||
|
||||
version = '1.3.2'
|
||||
version = '1.3.2.1'
|
||||
group = 'dev.zontreck.otemod' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = 'otemod'
|
||||
|
||||
|
@ -156,7 +156,7 @@ jar {
|
|||
attributes([
|
||||
"Specification-Title" : "otemod",
|
||||
"Specification-Vendor" : "Zontreck",
|
||||
"Specification-Version" : "1.3.2", // We are version 1 of ourselves
|
||||
"Specification-Version" : "1.3.2.1", // We are version 1 of ourselves
|
||||
"Implementation-Title" : project.name,
|
||||
"Implementation-Version" : project.jar.archiveVersion,
|
||||
"Implementation-Vendor" : "Zontreck",
|
||||
|
|
|
@ -3,6 +3,7 @@ package dev.zontreck.otemod;
|
|||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -12,10 +13,15 @@ import java.util.Set;
|
|||
import com.mojang.logging.LogUtils;
|
||||
import com.mojang.serialization.Codec;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.entity.Entity.RemovalReason;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.world.BiomeModifier;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
|
@ -26,6 +32,9 @@ import net.minecraftforge.fml.config.ModConfig;
|
|||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
import net.minecraftforge.event.entity.item.ItemExpireEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent.ItemPickupEvent;
|
||||
import net.minecraftforge.event.server.ServerStartedEvent;
|
||||
import net.minecraftforge.event.server.ServerStartingEvent;
|
||||
import net.minecraftforge.event.server.ServerStoppingEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
@ -34,6 +43,7 @@ import net.minecraftforge.registries.ForgeRegistries;
|
|||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
|
||||
import dev.zontreck.otemod.blocks.ModBlocks;
|
||||
import dev.zontreck.otemod.chat.ChatColor;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
|
@ -54,6 +64,7 @@ public class OTEMod
|
|||
// Directly reference a slf4j logger
|
||||
public static final Logger LOGGER = LogUtils.getLogger();
|
||||
public static final String FIRST_JOIN_TAG = "dev.zontreck.otemod.firstjoin";
|
||||
public static final String ITEM_LIVES_TAG = "dev.zontreck.otemod.entity.extralife";
|
||||
public static final String MOD_ID = "otemod";
|
||||
public static final String MODIFY_BIOMES = "modify_biomes";
|
||||
public static final ResourceLocation MODIFY_BIOMES_RL = new ResourceLocation(OTEMod.MOD_ID, MODIFY_BIOMES);
|
||||
|
@ -62,8 +73,9 @@ public class OTEMod
|
|||
public static List<TeleportContainer> TeleportRegistry = new ArrayList<>();
|
||||
public static MinecraftServer THE_SERVER;
|
||||
private static boolean ALIVE;
|
||||
|
||||
|
||||
public static boolean DEVELOPER=false;
|
||||
private static Thread MasterThread;
|
||||
|
||||
public OTEMod()
|
||||
{
|
||||
|
@ -151,8 +163,15 @@ public class OTEMod
|
|||
|
||||
// You can use SubscribeEvent and let the Event Bus discover methods to call
|
||||
@SubscribeEvent
|
||||
public void onServerStarting(ServerStartingEvent event)
|
||||
public void onServerStarting(ServerStartedEvent event)
|
||||
{
|
||||
// Changed away from Starting event due to multiple calls
|
||||
if(OTEMod.ALIVE){
|
||||
// We were called again?
|
||||
// Wtf... return
|
||||
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");
|
||||
|
||||
|
@ -191,7 +210,7 @@ public class OTEMod
|
|||
|
||||
// Set up the repeating task to expire a TeleportContainer
|
||||
OTEMod.THE_SERVER = event.getServer();
|
||||
Thread th = new Thread(new Runnable(){
|
||||
OTEMod.MasterThread = new Thread(new Runnable(){
|
||||
public void run()
|
||||
{
|
||||
while(OTEMod.ALIVE){
|
||||
|
@ -199,7 +218,7 @@ public class OTEMod
|
|||
try {
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
//e.printStackTrace();
|
||||
}
|
||||
|
||||
for(TeleportContainer cont : OTEMod.TeleportRegistry){
|
||||
|
@ -220,7 +239,7 @@ public class OTEMod
|
|||
OTEMod.LOGGER.info("Tearing down OTEMod teleport queue - The server is going down");
|
||||
}
|
||||
});
|
||||
th.start();
|
||||
OTEMod.MasterThread.start();
|
||||
} catch (DatabaseConnectionException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
|
@ -228,12 +247,62 @@ public class OTEMod
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.DEDICATED_SERVER)
|
||||
@SubscribeEvent
|
||||
public static void onStop(final ServerStoppingEvent ev)
|
||||
public void onItemPickup(final ItemPickupEvent ev){
|
||||
// Remove the expire tag
|
||||
if(ev.getStack().getTagElement(OTEMod.ITEM_LIVES_TAG) != null)
|
||||
{
|
||||
ev.getStack().removeTagKey(OTEMod.ITEM_LIVES_TAG);
|
||||
//OTEMod.LOGGER.info("Removed the item expire tag as the item was picked up");
|
||||
}
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.DEDICATED_SERVER)
|
||||
@SubscribeEvent
|
||||
public void onItemExpire(final ItemExpireEvent ev)
|
||||
{
|
||||
CompoundTag ct = ev.getEntity().getItem().getTagElement(OTEMod.ITEM_LIVES_TAG);
|
||||
if(ct == null){
|
||||
int life =0;
|
||||
ct = new CompoundTag();
|
||||
|
||||
ct.putInt("live", life);
|
||||
|
||||
|
||||
}else {
|
||||
int life = ct.getInt("live");
|
||||
if(life >= OTEServerConfig.ITEM_DESPAWN_TIMER.get()){
|
||||
// Item has expired. we should let it die
|
||||
//OTEMod.LOGGER.info("Item ["+ev.getEntity().getItem().getDisplayName().getString()+"] has expired");
|
||||
ev.setCanceled(false);
|
||||
return;
|
||||
}
|
||||
life++;
|
||||
ct.putInt("live", life);
|
||||
}
|
||||
|
||||
|
||||
ev.getEntity().getItem().removeTagKey(OTEMod.ITEM_LIVES_TAG); // Remove just incase it gets duplicated
|
||||
ev.getEntity().getItem().addTagElement(OTEMod.ITEM_LIVES_TAG, ct);
|
||||
|
||||
|
||||
//ev.setExtraLife(0); // reset the life count
|
||||
//OTEMod.LOGGER.info("Item ["+ev.getEntity().getItem().getDisplayName().getString()+"] was given extra life");
|
||||
ev.setCanceled(true);
|
||||
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.DEDICATED_SERVER)
|
||||
@SubscribeEvent
|
||||
public void onStop(final ServerStoppingEvent ev)
|
||||
{
|
||||
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 = OTEMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public static class ClientModEvents
|
||||
|
|
|
@ -116,8 +116,14 @@ public class ChatServerOverride {
|
|||
if(XD.prefix != ""){
|
||||
prefixStr = ChatColor.DARK_GRAY + "[" + ChatColor.BOLD + XD.prefix_color + XD.prefix + ChatColor.resetChat() + ChatColor.DARK_GRAY + "] ";
|
||||
}
|
||||
|
||||
String msg = ev.getMessage().getString();
|
||||
for(ChatColor.ColorOptions color : ChatColor.ColorOptions.values()){
|
||||
msg = msg.replace("!"+color.toString()+"!", ChatColor.from(color));
|
||||
}
|
||||
|
||||
String nameStr = ChatColor.resetChat() + "< "+ XD.name_color + XD.nickname + ChatColor.resetChat() + " >";
|
||||
String message = ": "+XD.chat_color + ev.getMessage().getString();
|
||||
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);
|
||||
|
@ -133,6 +139,11 @@ public class ChatServerOverride {
|
|||
{
|
||||
play.displayClientMessage(message, true); // Send the message!
|
||||
}
|
||||
LogToConsole(Component.literal("[all] ").append(message));
|
||||
}
|
||||
public static void LogToConsole(Component Message)
|
||||
{
|
||||
OTEMod.LOGGER.info(Message.getString());
|
||||
}
|
||||
public static void broadcast(Component message, MinecraftServer s)
|
||||
{
|
||||
|
@ -141,17 +152,20 @@ public class ChatServerOverride {
|
|||
{
|
||||
play.displayClientMessage(message, false); // Send the message!
|
||||
}
|
||||
LogToConsole(Component.literal("[all] ").append(message));
|
||||
}
|
||||
public static void broadcastTo(UUID ID, Component message, MinecraftServer s)
|
||||
{
|
||||
ServerPlayer play = s.getPlayerList().getPlayer(ID);
|
||||
play.displayClientMessage(message, false); // Send the message!
|
||||
|
||||
LogToConsole(Component.literal("[server] -> ["+play.getName().toString()+"] ").append(message));
|
||||
}
|
||||
public static void broadcastToAbove(UUID ID, Component message, MinecraftServer s)
|
||||
{
|
||||
ServerPlayer play = s.getPlayerList().getPlayer(ID);
|
||||
play.displayClientMessage(message, true); // Send the message!
|
||||
|
||||
LogToConsole(Component.literal("[server] -> ["+play.getName().toString()+"] ").append(message));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ public class OTEServerConfig {
|
|||
public static final ForgeConfigSpec.ConfigValue<String> USERNAME;
|
||||
public static final ForgeConfigSpec.ConfigValue<String> PASSWORD;
|
||||
public static final ForgeConfigSpec.ConfigValue<String> DATABASE;
|
||||
public static final ForgeConfigSpec.ConfigValue<Integer> ITEM_DESPAWN_TIMER;
|
||||
|
||||
static {
|
||||
List<ItemStack> defaults = new ArrayList<ItemStack>();
|
||||
|
@ -31,6 +32,7 @@ public class OTEServerConfig {
|
|||
USERNAME = BUILDER.comment("Database Username (MySQL)").define("user", "ote");
|
||||
PASSWORD = BUILDER.comment("Database Password (MySQL)").define("password", "password");
|
||||
DATABASE = BUILDER.comment("Database Name (MySQL)").define("database", "otemod");
|
||||
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", (60/5));
|
||||
|
||||
|
||||
BUILDER.pop();
|
||||
|
|
|
@ -19,7 +19,7 @@ modId="otemod" #mandatory
|
|||
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
|
||||
# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata
|
||||
# see the associated build.gradle script for how to populate this completely automatically during a build
|
||||
version="1.3.2" #mandatory
|
||||
version="1.3.2.1" #mandatory
|
||||
# A display name for the mod
|
||||
displayName="OTEMod Resources" #mandatory
|
||||
# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
{
|
||||
"type": "minecraft:smelting",
|
||||
"ingredient": {
|
||||
"item": "otemod:eternium_fragment"
|
||||
},
|
||||
"result": "otemod:eternium_dust",
|
||||
"type": "mekanism:enriching",
|
||||
"input": "otemod:eternium_ore",
|
||||
"output": "otemod:eternium_dust",
|
||||
"experience": 25,
|
||||
"cookingtime": 60
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"type": "mekanism:enriching",
|
||||
"input": "otemod:eternium_ore_block",
|
||||
"output": "otemod:eternium_dust",
|
||||
"experience": 25,
|
||||
"cookingtime": 60
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"type": "mekanism:enriching",
|
||||
"input": "otemod:deepslate_eternium_ore_block",
|
||||
"output": "otemod:eternium_dust",
|
||||
"experience": 25,
|
||||
"cookingtime": 60
|
||||
}
|
|
@ -9,6 +9,9 @@
|
|||
},
|
||||
{
|
||||
"item": "otemod:deepslate_eternium_ore_block"
|
||||
},
|
||||
{
|
||||
"item": "otemod:eternium_dust"
|
||||
}
|
||||
],
|
||||
"result": "otemod:eternium_fragment",
|
||||
|
|
Reference in a new issue