Publish changes to OTEMod

This commit is contained in:
Aria 2023-03-06 02:14:57 -07:00
parent 07dc947967
commit 52a9f68f39
20 changed files with 886 additions and 70 deletions

View file

@ -34,6 +34,8 @@ public class OTEServerConfig {
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;
static {
List<ItemStack> defaults = new ArrayList<ItemStack>();
@ -45,6 +47,7 @@ public class OTEServerConfig {
INITIAL_ITEMS_TO_GIVE_ON_FIRST_JOIN = BUILDER.comment("What items, identified by modid:item, to give to a brand new user on the server").define("New Player Gear", defaults);
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);

View file

@ -4,6 +4,8 @@ import java.time.Instant;
import java.util.Date;
import java.util.Random;
import org.antlr.v4.parse.ANTLRParser.id_return;
import dev.zontreck.libzontreck.items.lore.LoreContainer;
import dev.zontreck.libzontreck.items.lore.LoreEntry;
import dev.zontreck.libzontreck.profiles.Profile;
@ -15,12 +17,14 @@ 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.items.tags.ItemStatType;
import dev.zontreck.otemod.ore.OreGenerator;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
@ -29,7 +33,9 @@ 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.event.entity.player.PlayerEvent;
import net.minecraftforge.event.world.BiomeLoadingEvent;
@Mod.EventBusSubscriber(modid=OTEMod.MOD_ID)
@ -42,6 +48,18 @@ public class EventHandler {
OreGenerator.generateOres(ev);
}
@SubscribeEvent
public static void playerDied(LivingDeathEvent event)
{
if(!(event.getEntity() instanceof Player))return;
try {
ChatHelpers.broadcast(new TextComponent(DeathMessages.getRandomDeathMessage(Profile.get_profile_of(event.getEntity().getStringUUID()), event.getSource().getEntity())), 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;
@ -118,10 +136,16 @@ public class EventHandler {
entry.text = ChatHelpers.macroize("!dark_green!Player: " + profile.name_color+profile.username);
entry.bold=true;
lore.miscData.LoreData.add(entry);
entry = new LoreEntry();
entry.text = "!Dark_Purple!Date: !Dark_Red!" + Date.from(Instant.now()).toString();
entry.text = ChatHelpers.macroize("!Dark_Purple!Date: !Dark_Red![0]", Date.from(Instant.now()).toString());
lore.miscData.LoreData.add(entry);
entry = new LoreEntry();
entry.text = ChatHelpers.macroize("!Dark_Purple!Total Deaths: !Dark_Red![0]", String.valueOf(profile.deaths));
lore.miscData.LoreData.add(entry);
lore.commitLore();
ev.getDrops().add(new ItemEntity(killedentity.level, killedentity.getX(), killedentity.getY(), killedentity.getZ(), head));
}

View file

@ -2,11 +2,13 @@ package dev.zontreck.otemod.events;
import dev.zontreck.libzontreck.items.lore.LoreContainer;
import dev.zontreck.libzontreck.items.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;
@ -39,15 +41,20 @@ public class LoreHandlers {
ServerPlayer sp = (ServerPlayer)ev.getPlayer();
ItemStack itemUsed = sp.getItemInHand(InteractionHand.MAIN_HAND);
if(itemUsed.getItem() instanceof PickaxeItem)
ResourceLocation loc = itemUsed.getItem().getRegistryName();
String itemModName = ChatHelpers.macroize("[0]:[1]", loc.getNamespace(), loc.getPath());
if(itemModName.contains("pickaxe"))
{
updateItem(itemUsed, ItemStatType.PICK);
}else if(itemUsed.getItem() instanceof ShovelItem)
}else if(itemModName.contains("shovel"))
{
updateItem(itemUsed, ItemStatType.SHOVEL);
} else if(itemUsed.getItem() instanceof AxeItem)
} else if(itemModName.contains("axe"))
{
updateItem(itemUsed, ItemStatType.AXE);
} else if(itemModName.contains("pickadze"))
{
updateItem(itemUsed, ItemStatType.PICK);
}
}
@ -62,15 +69,17 @@ public class LoreHandlers {
ServerPlayer sp = (ServerPlayer)ev.getPlayer();
ItemStack itemUsed = sp.getMainHandItem();
BlockState bs = ev.getState();
ResourceLocation loc = itemUsed.getItem().getRegistryName();
String itemModName = ChatHelpers.macroize("[0]:[1]", loc.getNamespace(), loc.getPath());
if(itemUsed.getItem() instanceof HoeItem)
if(itemModName.contains("hoe"))
{
if(bs.is(Blocks.DIRT) || bs.is(Blocks.GRASS_BLOCK))
{
OTEMod.LOGGER.info("DIRT!");
updateItem(itemUsed, ItemStatType.HOE);
}
} else if(itemUsed.getItem() instanceof ShovelItem)
} else if(itemModName.contains("shovel"))
{
if(bs.is(Blocks.GRASS_BLOCK))
{
@ -94,12 +103,14 @@ public class LoreHandlers {
ServerPlayer sp = (ServerPlayer)ev.getEntity();
ItemStack itemUsed = sp.getMainHandItem();
Entity target = ev.getTarget();
if(itemUsed.getItem() instanceof ShearsItem)
ResourceLocation loc = itemUsed.getItem().getRegistryName();
String itemModName = ChatHelpers.macroize("[0]:[1]", loc.getNamespace(), loc.getPath());
ResourceLocation locEnt = itemUsed.getItem().getRegistryName();
String entityModName = ChatHelpers.macroize("[0]:[1]", locEnt.getNamespace(), locEnt.getPath());
if(itemModName.contains("shears"))
{
OTEMod.LOGGER.info("Shears");
if(target instanceof Sheep)
if(entityModName.contains("sheep"))
{
OTEMod.LOGGER.info("Sheep");
updateItem(itemUsed, ItemStatType.SHEARS);
}
}
@ -126,7 +137,9 @@ public class LoreHandlers {
if(sp==null)return;
ItemStack weaponUsed = sp.getItemInHand(InteractionHand.MAIN_HAND);
if(weaponUsed.getItem() instanceof SwordItem)
ResourceLocation loc = weaponUsed.getItem().getRegistryName();
String itemModName = ChatHelpers.macroize("[0]:[1]", loc.getNamespace(), loc.getPath());
if(itemModName.contains("sword"))
{
updateItem(weaponUsed, ItemStatType.SWORD);

View file

@ -0,0 +1,29 @@
package dev.zontreck.otemod.implementation;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import dev.zontreck.libzontreck.profiles.Profile;
import dev.zontreck.libzontreck.util.ChatHelpers;
import net.minecraft.world.entity.Entity;
public class DeathMessages {
private static final List<String> messages;
static{
messages=new ArrayList<>();
messages.add("!Dark_Red!On their [0] death, [1] was reduced to a jittering flesh pile");
messages.add("!Dark_Red![1] experienced their [0] death, while running away in fear from [2]");
messages.add("!Dark_Red![1] was eaten alive by [2]");
messages.add("!Dark_Red!For their [0] death, [1] got a little bit too careless!");
}
public static String getRandomDeathMessage(Profile playerWhoDied, Entity runningFrom)
{
Random rng = new Random();
int msg = rng.nextInt(0, messages.size()-1);
return ChatHelpers.macroize(messages.get(msg), String.valueOf(playerWhoDied.deaths), playerWhoDied.name_color + playerWhoDied.nickname, runningFrom.getName().getContents());
}
}

View file

@ -9,7 +9,7 @@ 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 = registerKeyMapping(KEY_OPEN_VAULT, InputConstants.KEY_V | InputConstants.KEY_LSHIFT, KEY_CATEGORY_OTEMOD);
public static final KeyMapping OPEN_VAULT = registerKeyMapping(KEY_OPEN_VAULT, InputConstants.KEY_V, KEY_CATEGORY_OTEMOD);
private static KeyMapping registerKeyMapping(String name, int keycode, String category){
final KeyMapping key = new KeyMapping(name, keycode, category);

View file

@ -9,7 +9,7 @@ modLoader="javafml" #mandatory
loaderVersion="[40,]" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
license="GPL 2.0"
license="GPL 3.0"
# A URL to refer people to when problems occur with this mod
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
# A list of mods - how many allowed here is determined by the individual mod loader
@ -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.7.0226231329" #mandatory
version="${file.jarVersion}" #mandatory
# A display name for the mod
displayName="OTEMod" #mandatory
# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/

View file

@ -0,0 +1,49 @@
{
"fallbacks": [
"metal"
],
"color": "33cccc",
"luminosity": 0,
"generator": {
"transformer": {
"type": "tconstruct:recolor_sprite",
"color_mapping": {
"type": "tconstruct:grey_to_color",
"palette": [
{
"grey": 0,
"color": "051414"
},
{
"grey": 63,
"color": "0f3d3d"
},
{
"grey": 102,
"color": "145252"
},
{
"grey": 140,
"color": "196666"
},
{
"grey": 178,
"color": "248f8f"
},
{
"grey": 216,
"color": "29a3a3"
},
{
"grey": 255,
"color": "33cccc"
}
]
}
},
"supportedStats": [
"tconstruct:handle"
],
"ignoreMaterialStats": false
}
}

View file

@ -0,0 +1,20 @@
{
"type": "tconstruct:modifier",
"inputs": [
{
"tag": "forge:ingots/eternium"
}
],
"tools": {
"tag": "otemod:modifiable/eternium"
},
"slots": {
"upgrades": 1
},
"allow_crystal": true,
"result": {
"name": "otemod:eggables",
"level": 1
},
"max_level": 6
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"tconstruct:sword"
]
}

View file

@ -0,0 +1,9 @@
{
"replace": false,
"values": [
{
"id": "otemod:eternium_ingot",
"required": false
}
]
}

View file

@ -0,0 +1,3 @@
{
"otemod:mob_egging": "otemod:eggables"
}

View file

@ -0,0 +1,6 @@
{
"default":{
"name": "otemod:eggables",
"level": 1
}
}

View file

@ -0,0 +1,8 @@
{
"type": "tconstruct:loot",
"level_display": "tconstruct:default",
"enchantment": {
"name": "otemod:mob_egging",
"level": 1
}
}