Fix the item expire delay amplifier

Fix aurora door texture
Add trash command
Push 1.3.3.1 alpha
This commit is contained in:
Zontreck 2022-10-07 01:02:44 -07:00
parent 146de39f44
commit d44ffa6342
21 changed files with 110 additions and 88 deletions

View file

@ -3,7 +3,7 @@
org.gradle.jvmargs=-Xmx8G
org.gradle.daemon=false
my_version=1.3.3.0
my_version=1.3.3.1
mc_version=1.19.2
forge_version=43.1.32

View file

@ -14,13 +14,17 @@ import com.mojang.logging.LogUtils;
import com.mojang.serialization.Codec;
import net.minecraft.client.gui.screens.MenuScreens;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity.RemovalReason;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
@ -68,7 +72,6 @@ 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);
@ -113,38 +116,6 @@ public class OTEMod
{
}
/*
* @DISABLED DUE TO PlayerEvent.PlayerLoggedInEvent
* with that event, we just handle this there. This code is kept as a reference until the new player gear functions have been added.
* Prereq for new player gear: OTEMod Vault API
*
@SubscribeEvent
public void onSpawn(EntityJoinLevelEvent ev){
Level w = ev.getLevel();
if(w.isClientSide){
return;
}
Entity e = ev.getEntity();
if(!(e instanceof Player))return;
Player p = (Player)e;
if(firstJoin(p)){
// Do first join actions here
/*for (Entry<String,Integer> ent : SARServerConfig.INITIAL_ITEMS_TO_GIVE_ON_FIRST_JOIN.get().entrySet()) {
Inventory i = p.getInventory();
}
}
}
*
*/
public boolean firstJoin(Player p){
@ -258,48 +229,27 @@ public class OTEMod
}
}
@OnlyIn(Dist.DEDICATED_SERVER)
@SubscribeEvent
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);
if(OTEServerConfig.ITEM_DESPAWN_TIMER.get()<=0)return;
}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);
if(ev.getEntity().getAge() != (1200 * 5)) {
//OTEMod.LOGGER.info("Extra life has already been given to item : "+ev.getEntity().getName().getString());
return; // We already gave it extra life, the default is 6000, or 5 minutes
}
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("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
//OTEMod.LOGGER.info("Item ["+ev.getEntity().getItem().getDisplayName().getString()+"] was given extra life");
// Hopefully this works?
ev.setCanceled(true);
}
@ -326,6 +276,8 @@ public class OTEMod
//LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName());
MenuScreens.register(MenuInitializer.VAULT.get(), VaultScreen::new);
//ItemBlockRenderTypes.setRenderLayer(ModBlocks.AURORA_DOOR.get(), RenderType.translucent());
}
}

View file

@ -0,0 +1,14 @@
package dev.zontreck.otemod.blocks;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.DoorBlock;
public class AuroraDoorBlock extends DoorBlock
{
public AuroraDoorBlock(Properties p_52737_, String name) {
super(p_52737_);
}
}

View file

@ -7,6 +7,7 @@ import dev.zontreck.otemod.items.ModItems;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Item.Properties;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.DoorBlock;
@ -41,7 +42,7 @@ public class ModBlocks {
public static final RegistryObject<Item> AURORA_BLOCK_I = ITEMS.register("aurora_block", () -> new BlockItem(AURORA_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC)));
public static final RegistryObject<Block> AURORA_DOOR = BLOCKS.register("aurora_door", () -> new DoorBlock(BlockBehaviour.Properties.of(Material.STONE).requiresCorrectToolForDrops().strength(9f).explosionResistance(100000f).destroyTime(10).sound(SoundType.NETHERITE_BLOCK)));
public static final RegistryObject<Block> AURORA_DOOR = BLOCKS.register("aurora_door", () -> new DoorBlock(BlockBehaviour.Properties.copy(Blocks.IRON_DOOR).requiresCorrectToolForDrops().strength(9f).explosionResistance(100000f).destroyTime(10).sound(SoundType.NETHERITE_BLOCK)));
public static final RegistryObject<Item> AURORA_DOOR_I = ITEMS.register("aurora_door", () -> new BlockItem(AURORA_DOOR.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC)));

View file

@ -16,6 +16,7 @@ import dev.zontreck.otemod.commands.teleport.TPAHereCommand;
import dev.zontreck.otemod.commands.teleport.TPAcceptCommand;
import dev.zontreck.otemod.commands.teleport.TPCancelCommand;
import dev.zontreck.otemod.commands.teleport.TPDenyCommand;
import dev.zontreck.otemod.commands.vaults.TrashCommand;
import dev.zontreck.otemod.commands.vaults.VaultCommand;
import dev.zontreck.otemod.configs.OTEServerConfig;
import net.minecraftforge.event.RegisterCommandsEvent;
@ -104,6 +105,7 @@ public class CommandRegistry {
VaultCommand.register(ev.getDispatcher());
TrashCommand.register(ev.getDispatcher());
}

View file

@ -0,0 +1,43 @@
package dev.zontreck.otemod.commands.vaults;
import java.util.UUID;
import javax.annotation.Nullable;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import dev.zontreck.otemod.implementation.VaultContainer;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.world.SimpleMenuProvider;
import net.minecraftforge.network.NetworkHooks;
public class TrashCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
{
dispatcher.register(Commands.literal("trash").executes(c-> vault(c.getSource())));
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
//String arg = StringArgumentType.getString(command, "nickname");
//return setHome(command.getSource(), arg);
//}));
}
private static int vault(CommandSourceStack source) {
//VaultContainer cont = new VaultContainer(i, source.getPlayer().getUUID());
//cont.startOpen(source.getPlayer());
VaultContainer container = new VaultContainer(source.getPlayer(), -1);
NetworkHooks.openScreen(source.getPlayer(), new SimpleMenuProvider(container.serverMenu, Component.literal("Trash")));
// Add to the master vault registry
if(VaultContainer.VAULT_REGISTRY.containsKey(source.getPlayer().getUUID()))VaultContainer.VAULT_REGISTRY.remove(source.getPlayer().getUUID());
VaultContainer.VAULT_REGISTRY.put(source.getPlayer().getUUID(), container);
return 0;
}
}

View file

@ -7,31 +7,12 @@ import javax.annotation.Nullable;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import dev.zontreck.otemod.chat.ChatColor;
import dev.zontreck.otemod.chat.ChatServerOverride;
import dev.zontreck.otemod.implementation.VaultContainer;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.CompoundContainer;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.SimpleMenuProvider;
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.ChestMenu;
import net.minecraft.world.inventory.MenuConstructor;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.level.block.ChestBlock;
import net.minecraft.world.level.block.entity.ChestBlockEntity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerContainerEvent;
import net.minecraftforge.network.NetworkConstants;
import net.minecraftforge.network.NetworkHooks;
import net.minecraftforge.network.PlayMessages;
public class VaultCommand {

View file

@ -45,7 +45,7 @@ public class VaultContainer
server=player.server;
serverMenu = theContainer.getServerMenu(myInventory);
VAULT_NUMBER=vaultNum;
if(VAULT_NUMBER == -1)return; // Trash ID
Connection con = OTEMod.DB.getConnection();
// Check database for vault
@ -74,6 +74,7 @@ public class VaultContainer
public void commit()
{
if(VAULT_NUMBER == -1)return; // We have no need to save the trash
CompoundTag saved = myInventory.serializeNBT();
ChatServerOverride.broadcastToAbove(owner, Component.literal(ChatColor.BOLD+ChatColor.DARK_GREEN+"Saving the vault's contents..."), server);

View file

@ -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.3.0" #mandatory
version="1.3.3.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/

View file

@ -1,5 +1,6 @@
{
"parent": "minecraft:block/door_bottom_left",
"render_type": "minecraft:translucent",
"textures": {
"bottom": "otemod:block/aurora_door_bottom",
"top": "otemod:block/aurora_door_top"

View file

@ -1,5 +1,6 @@
{
"parent": "minecraft:block/door_bottom_left_open",
"render_type": "minecraft:translucent",
"textures": {
"bottom": "otemod:block/aurora_door_bottom",
"top": "otemod:block/aurora_door_top"

View file

@ -1,5 +1,6 @@
{
"parent": "minecraft:block/door_bottom_right",
"render_type": "minecraft:translucent",
"textures": {
"bottom": "otemod:block/aurora_door_bottom",
"top": "otemod:block/aurora_door_top"

View file

@ -1,5 +1,6 @@
{
"parent": "minecraft:block/door_bottom_right_open",
"render_type": "minecraft:translucent",
"textures": {
"bottom": "otemod:block/aurora_door_bottom",
"top": "otemod:block/aurora_door_top"

View file

@ -1,5 +1,6 @@
{
"parent": "minecraft:block/door_top_left",
"render_type": "minecraft:translucent",
"textures": {
"bottom": "otemod:block/aurora_door_bottom",
"top": "otemod:block/aurora_door_top"

View file

@ -1,5 +1,6 @@
{
"parent": "minecraft:block/door_top_left_open",
"render_type": "minecraft:translucent",
"textures": {
"bottom": "otemod:block/aurora_door_bottom",
"top": "otemod:block/aurora_door_top"

View file

@ -1,5 +1,6 @@
{
"parent": "minecraft:block/door_top_right",
"render_type": "minecraft:translucent",
"textures": {
"bottom": "otemod:block/aurora_door_bottom",
"top": "otemod:block/aurora_door_top"

View file

@ -1,5 +1,6 @@
{
"parent": "minecraft:block/door_top_right_open",
"render_type": "minecraft:translucent",
"textures": {
"bottom": "otemod:block/aurora_door_bottom",
"top": "otemod:block/aurora_door_top"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 397 B

After

Width:  |  Height:  |  Size: 407 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 458 B

After

Width:  |  Height:  |  Size: 462 B

Before After
Before After

View file

@ -0,0 +1,20 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "otemod:aurora_door"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}