1. Rename chat commands
2. Fix RTP 3. Fix RTP Warps 4. Add a eternium block from 9 ingots 5. Fix nether vault steel ore
This commit is contained in:
parent
5ee0aa47e9
commit
45796de812
48 changed files with 610 additions and 297 deletions
|
@ -3,7 +3,7 @@
|
|||
org.gradle.jvmargs=-Xmx8G
|
||||
org.gradle.daemon=false
|
||||
|
||||
my_version=1.3.7.0224230125
|
||||
my_version=1.3.7.0226231329
|
||||
|
||||
mc_version=1.18.2
|
||||
forge_version=40.2.1
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#Minecraft server properties
|
||||
#Fri Feb 24 01:20:51 MST 2023
|
||||
#Mon Feb 27 02:56:23 MST 2023
|
||||
allow-flight=false
|
||||
allow-nether=true
|
||||
broadcast-console-to-ops=true
|
||||
|
|
|
@ -5,6 +5,7 @@ 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;
|
||||
|
@ -46,6 +47,7 @@ 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.DelayedExecutorService;
|
||||
import dev.zontreck.otemod.implementation.inits.ModMenuTypes;
|
||||
import dev.zontreck.otemod.implementation.profiles.Profile;
|
||||
import dev.zontreck.otemod.implementation.scrubber.ItemScrubberScreen;
|
||||
|
@ -80,6 +82,11 @@ public class OTEMod
|
|||
public static String OTEPrefix = "";
|
||||
public static String ONLY_PLAYER = "";
|
||||
public static IEventBus bus;
|
||||
public static final DelayedExecutorService delayedExecutor;
|
||||
|
||||
static{
|
||||
delayedExecutor = new DelayedExecutorService();
|
||||
}
|
||||
|
||||
public OTEMod()
|
||||
{
|
||||
|
@ -107,6 +114,7 @@ public class OTEMod
|
|||
MinecraftForge.EVENT_BUS.register(new ChatServerOverride());
|
||||
MinecraftForge.EVENT_BUS.register(new CommandRegistry());
|
||||
MinecraftForge.EVENT_BUS.register(new VaultWatcher());
|
||||
MinecraftForge.EVENT_BUS.register(delayedExecutor);
|
||||
MinecraftForge.EVENT_BUS.register(new dev.zontreck.otemod.zschem.EventHandler());
|
||||
ModMenuTypes.CONTAINERS.register(bus);
|
||||
|
||||
|
@ -170,18 +178,15 @@ public class OTEMod
|
|||
//e.printStackTrace();
|
||||
}
|
||||
|
||||
for(TeleportContainer cont : OTEMod.TeleportRegistry){
|
||||
if(cont.has_expired())
|
||||
{
|
||||
try{
|
||||
Component expire = new TextComponent(OTEMod.OTEPrefix + ChatColor.DARK_PURPLE+" Teleport request has expired");
|
||||
ChatServerOverride.broadcastTo(cont.FromPlayer, expire, OTEMod.THE_SERVER);
|
||||
ChatServerOverride.broadcastTo(cont.ToPlayer, expire, OTEMod.THE_SERVER);
|
||||
OTEMod.TeleportRegistry.remove(cont);
|
||||
}catch(Exception e){
|
||||
break;
|
||||
}
|
||||
}
|
||||
Iterator<TeleportContainer> containers = OTEMod.TeleportRegistry.iterator();
|
||||
while(containers.hasNext())
|
||||
{
|
||||
TeleportContainer cont = containers.next();
|
||||
Component expire = new TextComponent(OTEMod.OTEPrefix + ChatColor.DARK_PURPLE+" Teleport request has expired");
|
||||
ChatServerOverride.broadcastTo(cont.FromPlayer, expire, OTEMod.THE_SERVER);
|
||||
ChatServerOverride.broadcastTo(cont.ToPlayer, expire, OTEMod.THE_SERVER);
|
||||
|
||||
containers.remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package dev.zontreck.otemod.blocks;
|
||||
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
public class FoiledBlockItem extends BlockItem {
|
||||
|
||||
public FoiledBlockItem(Block pBlock, Properties pProperties) {
|
||||
super(pBlock, pProperties);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFoil(ItemStack pStack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -45,21 +45,10 @@ public class ModBlocks {
|
|||
|
||||
public static final RegistryObject<Item> NETHER_VAULT_STEEL_ORE_BLOCK_I = ITEMS.register("nether_vault_steel_ore_block", ()->new BlockItem(NETHER_VAULT_STEEL_ORE_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_MATERIALS)));
|
||||
|
||||
//#region TINKERS BLOCKS
|
||||
|
||||
public static final RegistryObject<Block> COBALT_ORE_BLOCK = BLOCKS.register("cobalt_ore", () -> new Block(BlockBehaviour.Properties.of(Material.STONE, MaterialColor.NETHER).sound(SoundType.NETHER_ORE).requiresCorrectToolForDrops().strength(10.0F)));
|
||||
public static final RegistryObject<Block> ETERNIUM_BLOCK = BLOCKS.register("eternium_block", ()->new Block(BlockBehaviour.Properties.of(Material.METAL).requiresCorrectToolForDrops().strength(8F).explosionResistance(1200).destroyTime(100)));
|
||||
|
||||
public static final RegistryObject<Item> COBALT_ORE_ITEM = ITEMS.register("cobalt_ore", ()->new BlockItem(COBALT_ORE_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_MATERIALS)));
|
||||
|
||||
public static final RegistryObject<Block> RAW_COBALT_ORE_BLOCK = BLOCKS.register("raw_cobalt_ore", () -> new Block(BlockBehaviour.Properties.of(Material.STONE, MaterialColor.COLOR_BLUE).sound(SoundType.NETHER_ORE).requiresCorrectToolForDrops().strength(6.0F, 7.0F)));
|
||||
|
||||
public static final RegistryObject<Item> RAW_COBALT_ORE_ITEM = ITEMS.register("raw_cobalt_ore", ()->new BlockItem(RAW_COBALT_ORE_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_MATERIALS)));
|
||||
|
||||
public static final RegistryObject<Block> COBALT_BLOCK = BLOCKS.register("cobalt_block", ()-> new Block(BlockBehaviour.Properties.of(Material.METAL, MaterialColor.COLOR_BLUE).requiresCorrectToolForDrops().strength(3.0F, 6.0F).sound(SoundType.METAL)));
|
||||
|
||||
public static final RegistryObject<Item> COBALT_BLOCK_I = ITEMS.register("cobalt_block", ()-> new BlockItem(COBALT_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_MATERIALS)));
|
||||
|
||||
//#endregion
|
||||
public static final RegistryObject<Item> ETERNIUM_BLOCK_I = ITEMS.register("eternium_block", ()->new FoiledBlockItem(ETERNIUM_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_MATERIALS)));
|
||||
|
||||
|
||||
public static final RegistryObject<Block> DEEPSLATE_ETERNIUM_ORE_BLOCK = BLOCKS.register("deepslate_eternium_ore_block", () -> new Block(BlockBehaviour.Properties.of(Material.METAL).requiresCorrectToolForDrops().strength(5f).explosionResistance(1200).destroyTime(7)));
|
||||
|
|
|
@ -19,7 +19,7 @@ public class ChatColorCommand {
|
|||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("ccolor")
|
||||
dispatcher.register(Commands.literal("chat_color")
|
||||
.executes(c->setchatcolor(c.getSource(), ColorOptions.White))
|
||||
.then(Commands.argument("color", EnumArgument.enumArgument(ChatColor.ColorOptions.class))//StringArgumentType.string())
|
||||
.executes(c -> setchatcolor(c.getSource(), c.getArgument("color", ChatColor.ColorOptions.class)))// EnumArgument.getS(c, "color")))
|
||||
|
|
|
@ -19,7 +19,7 @@ public class NameColorCommand {
|
|||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("ncolor")
|
||||
dispatcher.register(Commands.literal("nick_color")
|
||||
.executes(c->setchatcolor(c.getSource(), ColorOptions.White))
|
||||
.then(Commands.argument("color", EnumArgument.enumArgument(ChatColor.ColorOptions.class))//StringArgumentType.string())
|
||||
.executes(c -> setchatcolor(c.getSource(), c.getArgument("color", ChatColor.ColorOptions.class)))// EnumArgument.getS(c, "color")))
|
||||
|
|
|
@ -19,7 +19,7 @@ public class PrefixColorCommand {
|
|||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("pcolor")
|
||||
dispatcher.register(Commands.literal("prefix_color")
|
||||
.executes(c->setchatcolor(c.getSource(), ColorOptions.White))
|
||||
.then(Commands.argument("color", EnumArgument.enumArgument(ChatColor.ColorOptions.class))//StringArgumentType.string())
|
||||
.executes(c -> setchatcolor(c.getSource(), c.getArgument("color", ChatColor.ColorOptions.class)))// EnumArgument.getS(c, "color")))
|
||||
|
|
|
@ -1,36 +1,22 @@
|
|||
package dev.zontreck.otemod.commands.teleport;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.BoolArgumentType;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
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.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class RTPCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("rtp").executes(c->rtp(c.getSource(), false)).then(Commands.argument("ignorewater", BoolArgumentType.bool()).executes(c->rtp(c.getSource(), BoolArgumentType.getBool(c, "ignorewater")))));
|
||||
dispatcher.register(Commands.literal("rtp").executes(c->rtp(c.getSource())));
|
||||
|
||||
//executes(c -> doCancel(c.getSource())));
|
||||
|
||||
|
@ -40,69 +26,7 @@ public class RTPCommand {
|
|||
//}));
|
||||
}
|
||||
|
||||
public static Vector3 findPosition(ServerLevel lvl, boolean allowWater)
|
||||
{
|
||||
Vector3 v = new Vector3();
|
||||
boolean found_place = false;
|
||||
// We do not care how many tries it takes
|
||||
|
||||
while (!found_place)
|
||||
{
|
||||
|
||||
// Take our current position, and send us in a random direction
|
||||
Random rng = new Random(Instant.now().getEpochSecond());
|
||||
v.y = 300;
|
||||
v.x = rng.nextDouble(0xffff);
|
||||
v.z = rng.nextDouble(0xffff);
|
||||
|
||||
boolean is_invalid_location = false;
|
||||
String block_place="";
|
||||
|
||||
while(v.y!=-30)
|
||||
{
|
||||
|
||||
BlockState b = lvl.getBlockState(new BlockPos(v.asMinecraftVector()));
|
||||
BlockState b2 = lvl.getBlockState(new BlockPos(v.moveUp().asMinecraftVector()));
|
||||
BlockState b3 = lvl.getBlockState(new BlockPos(v.moveDown().asMinecraftVector()));
|
||||
|
||||
if(b.isAir()){
|
||||
if(b2.isAir()){
|
||||
if(!b3.isAir() && !b3.is(Blocks.BEDROCK))
|
||||
{
|
||||
// Check names
|
||||
boolean valid=true;
|
||||
List<Block> blackLists = new ArrayList<>();
|
||||
if(!allowWater)
|
||||
blackLists.add(Blocks.WATER);
|
||||
blackLists.add(Blocks.LAVA);
|
||||
|
||||
block_place = b3.getBlock().getName().getString();
|
||||
OTEMod.LOGGER.info(b3.getBlock().getName().getString());
|
||||
for(Block bx : blackLists)
|
||||
{
|
||||
if(b.is(bx) || b2.is(bx) || b3.is(bx)){
|
||||
valid=false;
|
||||
is_invalid_location=true;
|
||||
}
|
||||
}
|
||||
|
||||
if(valid){
|
||||
|
||||
found_place = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
v=v.moveDown();
|
||||
}
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
private static int rtp(CommandSourceStack source, boolean allowWater) {
|
||||
private static int rtp(CommandSourceStack source) {
|
||||
|
||||
/*if(!CommandRegistry.canUse("rtp")) {
|
||||
ChatServerOverride.broadcastTo(source.getPlayer().getUUID(), Component.translatable("dev.zontreck.otemod.msgs.command_cooling_down").append(Component.literal(""+CommandRegistry.getRemaining("rtp"))).append(Component.translatable("dev.zontreck.otemod.msgs.command_cooling_down_seconds")), source.getServer());
|
||||
|
@ -114,13 +38,14 @@ public class RTPCommand {
|
|||
if(!(source.getEntity() instanceof Player)){
|
||||
return 1;
|
||||
}
|
||||
ServerPlayer pla = (ServerPlayer)source.getEntity();
|
||||
final ServerPlayer pla = (ServerPlayer)source.getEntity();
|
||||
|
||||
TeleportContainer cont = new TeleportContainer(pla, null, pla.getRotationVector(), source.getLevel());
|
||||
final TeleportContainer cont = new TeleportContainer(pla, Vec3.ZERO, pla.getRotationVector(), source.getLevel());
|
||||
|
||||
|
||||
|
||||
Thread tx = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run(){
|
||||
// We can now execute the loop to search for a safe spot!
|
||||
Vector3 v = new Vector3();
|
||||
|
@ -129,96 +54,25 @@ public class RTPCommand {
|
|||
Vec3 pos = pla.position();
|
||||
|
||||
boolean found_place= false;
|
||||
|
||||
int tries=0;
|
||||
ChatServerOverride.broadcastTo(pla.getUUID(), new TextComponent(ChatColor.DARK_GRAY + "["+ChatColor.DARK_GREEN+"OTEMOD"+ChatColor.DARK_GRAY+"] "+ChatColor.GREEN+"Searching for a suitable landing location..."), source.getServer());
|
||||
/*
|
||||
*
|
||||
*
|
||||
while(!found_place){
|
||||
|
||||
// Take our current position, and send us in a random direction
|
||||
Random rng = new Random((long) (pos.x+pos.y+pos.z));
|
||||
v.y = 500;
|
||||
v.x = rng.nextDouble(0xffff);
|
||||
v.z = rng.nextDouble(0xffff);
|
||||
|
||||
boolean is_invalid_location = false;
|
||||
String block_place="";
|
||||
|
||||
// Begin to scan for ground
|
||||
while(v.y != -30)
|
||||
RTPContainer container = RandomPositionFactory.beginRTPSearch(pla, pos, pla.getRotationVector(), pla.getLevel());
|
||||
while(!container.complete)
|
||||
{
|
||||
if(!OTEMod.ALIVE)
|
||||
{
|
||||
// check block above and below
|
||||
BlockState b = source.getLevel().getBlockState(new BlockPos(v.asMinecraftVector()));
|
||||
BlockState b2 = source.getLevel().getBlockState(new BlockPos(v.moveUp().asMinecraftVector()));
|
||||
BlockState b3 = source.getLevel().getBlockState(new BlockPos(v.moveDown().asMinecraftVector()));
|
||||
//Block bx = b.getBlock();
|
||||
|
||||
// Check that none of the blocks are water or lava
|
||||
|
||||
|
||||
if(b.isAir()){
|
||||
if(b2.isAir()){
|
||||
if(!b3.isAir()){
|
||||
|
||||
// Check names
|
||||
boolean valid=true;
|
||||
List<String> blackList = new ArrayList<>();
|
||||
if(!allowWater)
|
||||
blackList.add("Water");
|
||||
blackList.add("Lava");
|
||||
|
||||
block_place = b3.getBlock().getName().getString();
|
||||
OTEMod.LOGGER.info(b3.getBlock().getName().getString());
|
||||
if(blackList.contains(b.getBlock().getName().getString())){
|
||||
valid=false;
|
||||
is_invalid_location=true;
|
||||
}
|
||||
if(blackList.contains(b2.getBlock().getName().getString())){
|
||||
valid=false;
|
||||
is_invalid_location=true;
|
||||
}
|
||||
if(blackList.contains(b3.getBlock().getName().getString())){
|
||||
valid=false;
|
||||
is_invalid_location=true;
|
||||
}
|
||||
|
||||
if(valid){
|
||||
|
||||
found_place = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
v =v.moveDown();
|
||||
|
||||
}
|
||||
if(tries>=30)
|
||||
{
|
||||
// Aborting RTP
|
||||
ChatServerOverride.broadcastTo(pla.getUUID(), Component.literal(ChatColor.DARK_RED+"Could not find a suitable location after 30 tries. Giving up on RTP"), source.getServer());
|
||||
container.aborted=true;
|
||||
container.containingThread.interrupt();
|
||||
return;
|
||||
}
|
||||
tries++;
|
||||
|
||||
String sAppend = "";
|
||||
if(is_invalid_location){
|
||||
sAppend = block_place + " is not valid";
|
||||
if(container.tries>30)
|
||||
{
|
||||
// abort!
|
||||
return;
|
||||
|
||||
}
|
||||
ChatServerOverride.broadcastToAbove(pla.getUUID(), Component.literal(ChatColor.DARK_PURPLE+"Still searching.... Try ["+String.valueOf(tries)+"/30] "+sAppend), source.getServer());
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
v=findPosition(source.getLevel(), allowWater);
|
||||
}
|
||||
v = container.container.world_pos.Position;
|
||||
|
||||
ChatServerOverride.broadcastTo(pla.getUUID(), new TextComponent(ChatColor.DARK_GRAY + "["+ChatColor.DARK_GREEN + "OTEMOD" + ChatColor.DARK_GRAY + "] "+ChatColor.DARK_PURPLE+" A suitable location has been found. Wormhole opening now!"), source.getServer());
|
||||
ChatServerOverride.broadcastTo(pla.getUUID(), new TextComponent(ChatColor.DARK_GRAY + "["+ChatColor.DARK_GREEN + "OTEMOD" + ChatColor.DARK_GRAY + "] "+ChatColor.DARK_PURPLE+" A suitable location has been found. Wormhole opening now!"), OTEMod.THE_SERVER);
|
||||
|
||||
// Apply the effect
|
||||
TeleportActioner.ApplyTeleportEffect(pla);
|
||||
|
@ -235,40 +89,4 @@ public class RTPCommand {
|
|||
return 0;
|
||||
}
|
||||
|
||||
private static int doCancel(CommandSourceStack source, String TPID) {
|
||||
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
UUID teleporter = UUID.fromString(TPID);
|
||||
for(TeleportContainer cont : OTEMod.TeleportRegistry){
|
||||
if(cont.TeleportID.equals(teleporter)){
|
||||
// Accepting!
|
||||
|
||||
ServerPlayer from = source.getServer().getPlayerList().getPlayer(cont.FromPlayer);
|
||||
ServerPlayer to = source.getServer().getPlayerList().getPlayer(cont.ToPlayer);
|
||||
|
||||
Component comp = new TextComponent(ChatColor.DARK_GRAY + "["+ ChatColor.DARK_GREEN+ "OTEMOD" + ChatColor.DARK_GRAY+"] " + ChatColor.DARK_PURPLE+"Teleport request was accepted. Opening wormhole!");
|
||||
|
||||
ChatServerOverride.broadcastTo(cont.FromPlayer, comp, source.getServer());
|
||||
ChatServerOverride.broadcastTo(cont.ToPlayer, comp, source.getServer());
|
||||
|
||||
OTEMod.TeleportRegistry.remove(cont);
|
||||
|
||||
|
||||
cont.PlayerInst = from;
|
||||
cont.Position = to.position();
|
||||
cont.Rotation = to.getRotationVector();
|
||||
cont.Dimension = to.getLevel();
|
||||
|
||||
TeleportActioner.ApplyTeleportEffect(from);
|
||||
TeleportActioner.PerformTeleport(cont);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Component comp = new TextComponent(ChatColor.DARK_RED+"The teleport was not found, perhaps the request expired or was already cancelled/denied");
|
||||
|
||||
ChatServerOverride.broadcastTo(play.getUUID(), comp, source.getServer());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,154 @@
|
|||
package dev.zontreck.otemod.commands.teleport;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
import net.minecraft.world.level.levelgen.Heightmap.Types;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class RTPContainer {
|
||||
public TeleportContainer container;
|
||||
public int tries = -1;
|
||||
public boolean complete = false;
|
||||
public boolean aborted=false;
|
||||
public Thread containingThread;
|
||||
private Types heightMapType;
|
||||
private int SearchDirection;
|
||||
|
||||
public static final List<Block> BLACKLIST;
|
||||
|
||||
static {
|
||||
List<Block> tmp = new ArrayList<>();
|
||||
tmp.add(Blocks.LAVA);
|
||||
tmp.add(Blocks.BEDROCK);
|
||||
tmp.add(Blocks.WATER);
|
||||
|
||||
BLACKLIST = tmp;
|
||||
}
|
||||
|
||||
public void moveDown() {
|
||||
container.world_pos.Position = container.world_pos.Position.moveDown();
|
||||
container.Position = container.world_pos.Position.asMinecraftVector();
|
||||
}
|
||||
|
||||
public void moveUp() {
|
||||
container.world_pos.Position = container.world_pos.Position.moveUp();
|
||||
container.Position = container.world_pos.Position.asMinecraftVector();
|
||||
}
|
||||
|
||||
public void move()
|
||||
{
|
||||
if(SearchDirection==1){
|
||||
moveUp();
|
||||
}else if(SearchDirection==0)
|
||||
{
|
||||
moveDown();
|
||||
}
|
||||
}
|
||||
public void moveOpposite()
|
||||
{
|
||||
if(SearchDirection==1){
|
||||
moveDown();
|
||||
}else if(SearchDirection==0)
|
||||
{
|
||||
moveUp();
|
||||
}
|
||||
}
|
||||
|
||||
public void newPosition() {
|
||||
if(!OTEMod.ALIVE)return;
|
||||
containingThread=Thread.currentThread();
|
||||
Random rng = new Random(Instant.now().getEpochSecond());
|
||||
Vector3 pos = new Vector3(rng.nextDouble(0xFFFF), 0, rng.nextDouble(0xFFFF));
|
||||
BlockPos bpos = pos.asBlockPos();
|
||||
container.Dimension.getChunk(bpos.getX() >> 4, bpos.getZ() >> 4, ChunkStatus.HEIGHTMAPS);
|
||||
pos = new Vector3(
|
||||
container.Dimension.getHeightmapPos(heightMapType, pos.asBlockPos()));
|
||||
while (!container.Dimension.getWorldBorder().isWithinBounds(pos.asBlockPos())) {
|
||||
pos = new Vector3(rng.nextDouble(0xffff), 0, rng.nextDouble(0xffff));
|
||||
bpos = pos.asBlockPos();
|
||||
container.Dimension.getChunk(bpos.getX() >> 4, bpos.getZ() >> 4, ChunkStatus.HEIGHTMAPS);
|
||||
pos = new Vector3(
|
||||
container.Dimension.getHeightmapPos(heightMapType, pos.asBlockPos()));
|
||||
}
|
||||
|
||||
container.world_pos.Position = pos;
|
||||
container.Position = container.world_pos.Position.asMinecraftVector();
|
||||
|
||||
if (pos.y < -60) {
|
||||
newPosition();
|
||||
return;
|
||||
}
|
||||
|
||||
if (pos.y >= container.Dimension.getLogicalHeight()) {
|
||||
spiralPositions(pos);
|
||||
}
|
||||
|
||||
tries++;
|
||||
}
|
||||
|
||||
private void spiralPositions(Vector3 position)
|
||||
{
|
||||
for(BlockPos pos : BlockPos.spiralAround(new BlockPos(position.x, container.Dimension.getSeaLevel(), position.z), 16, Direction.WEST, Direction.NORTH)){
|
||||
if(isSafe(pos)){
|
||||
// Set the new position
|
||||
container.world_pos.Position = new Vector3(pos);
|
||||
container.Position = container.world_pos.Position.asMinecraftVector();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected RTPContainer(ServerPlayer player, Vec3 pos, Vec2 rot, ServerLevel level) {
|
||||
container = new TeleportContainer(player, pos, rot, level);
|
||||
if(container.Dimension.dimensionType().hasCeiling())
|
||||
{
|
||||
heightMapType = Heightmap.Types.MOTION_BLOCKING_NO_LEAVES;
|
||||
SearchDirection=-1;
|
||||
}else {
|
||||
heightMapType = Types.MOTION_BLOCKING_NO_LEAVES;
|
||||
SearchDirection=1;
|
||||
}
|
||||
newPosition();
|
||||
}
|
||||
|
||||
public boolean isSafe(BlockPos blockPos) {
|
||||
containingThread=Thread.currentThread();
|
||||
BlockState b = container.Dimension.getBlockState(blockPos);
|
||||
BlockState b2 = container.Dimension.getBlockState(blockPos.above());
|
||||
BlockState b3 = container.Dimension.getBlockState(blockPos.below());
|
||||
|
||||
if (b.isAir() && b2.isAir()) {
|
||||
if (!b3.isAir()) {
|
||||
if (BLACKLIST.contains(b3.getBlock())) {
|
||||
return false;
|
||||
} else
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
} else
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package dev.zontreck.otemod.commands.teleport;
|
||||
|
||||
import dev.zontreck.otemod.implementation.DelayedExecutorService;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
/**
|
||||
* The factory system used to start searching for a random teleport position
|
||||
*/
|
||||
public class RandomPositionFactory {
|
||||
|
||||
public static RTPContainer beginRTPSearch(ServerPlayer player, Vec3 pos, Vec2 rot, ServerLevel level)
|
||||
{
|
||||
RTPContainer contain= new RTPContainer(player, pos, rot, level);
|
||||
Thread tx = new Thread(new RandomPositionLocator(contain));
|
||||
tx.setName("RTPTask-"+String.valueOf(DelayedExecutorService.getNext()));
|
||||
tx.start();
|
||||
|
||||
return contain;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
package dev.zontreck.otemod.commands.teleport;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import dev.zontreck.otemod.events.RTPEvent;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
/**
|
||||
* This class aims to serve as the Random Position Locate system
|
||||
* It aims to be as non-thread blocking as possible to avoid server lag
|
||||
*
|
||||
* To utilize, initialize a RTPContainer from the RandomPositionFactory and execute from there.
|
||||
*/
|
||||
public class RandomPositionLocator implements Runnable
|
||||
{
|
||||
private final RTPContainer contain;
|
||||
|
||||
public RandomPositionLocator(RTPContainer rtp)
|
||||
{
|
||||
contain=rtp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if(!OTEMod.ALIVE)return;
|
||||
ChatServerOverride.broadcastTo(contain.container.PlayerInst.getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors(" !Dark_Purple!Searching... Attempt "+String.valueOf(contain.tries)+"/30")), OTEMod.THE_SERVER);
|
||||
|
||||
ServerLevel levl = contain.container.Dimension;
|
||||
ChunkAccess chunk = levl.getChunk(contain.container.world_pos.Position.asBlockPos());
|
||||
ChunkPos cpos = chunk.getPos();
|
||||
boolean needsLoading = false;
|
||||
needsLoading = !(levl.getForcedChunks().contains(cpos.toLong()));
|
||||
|
||||
|
||||
if(needsLoading)
|
||||
levl.setChunkForced(cpos.x, cpos.z, true);
|
||||
|
||||
int curChecks=0;
|
||||
while(curChecks<30)
|
||||
{
|
||||
if(contain.isSafe(contain.container.world_pos.Position.asBlockPos()))
|
||||
{
|
||||
contain.complete=true;
|
||||
if(needsLoading)
|
||||
levl.setChunkForced(cpos.x, cpos.z, false);
|
||||
|
||||
if(MinecraftForge.EVENT_BUS.post(new RTPEvent(contain.container.PlayerInst, contain.container.world_pos)))
|
||||
{
|
||||
contain.complete=false;
|
||||
ChatServerOverride.broadcastTo(contain.container.PlayerInst.getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors(" !Dark_Red!Last position checked was probably claimed. Another mod has asked us not to send you to that location, continuing the search")), OTEMod.THE_SERVER);
|
||||
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}else {
|
||||
curChecks++;
|
||||
contain.move();
|
||||
OTEMod.LOGGER.info("[DEBUG] "+ChatColor.doColors("!Dark_Red!Checking position: "+contain.container.world_pos.Position.toString()+"; "+contain.container.Dimension.getBlockState(contain.container.world_pos.Position.asBlockPos()).getBlock().toString()+"; "+contain.container.Dimension.getBlockState(contain.container.world_pos.Position.asBlockPos().below()).getBlock().toString()));
|
||||
}
|
||||
}
|
||||
if(needsLoading)
|
||||
levl.setChunkForced(cpos.x, cpos.z, false);
|
||||
|
||||
contain.newPosition();
|
||||
|
||||
if(contain.tries > 30)
|
||||
{
|
||||
// Abort
|
||||
ChatServerOverride.broadcastTo(contain.container.PlayerInst.getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors(" !Dark_Red!Could not find a suitable location in 30 attempts")), OTEMod.THE_SERVER);
|
||||
contain.aborted=true;
|
||||
return;
|
||||
}else {
|
||||
// Schedule the task to execute
|
||||
//run();
|
||||
RandomPositionLocator next = new RandomPositionLocator(contain);
|
||||
OTEMod.delayedExecutor.schedule(next, 2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package dev.zontreck.otemod.commands.teleport;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
|
@ -8,8 +9,7 @@ public class TeleportActioner
|
|||
{
|
||||
public static void PerformTeleport(TeleportContainer contain){
|
||||
//sub_runnable run = new sub_runnable(contain);
|
||||
Thread t = new Thread(new TeleportRunnable(contain));
|
||||
t.start();
|
||||
OTEMod.delayedExecutor.schedule(new TeleportRunnable(contain), 2);
|
||||
}
|
||||
|
||||
public static void ApplyTeleportEffect(ServerPlayer player){
|
||||
|
@ -19,17 +19,19 @@ public class TeleportActioner
|
|||
player.server.execute(new Runnable(){
|
||||
public void run(){
|
||||
|
||||
MobEffectInstance inst = new MobEffectInstance(MobEffects.BLINDNESS, 200, 1, true, true);
|
||||
MobEffectInstance regen = new MobEffectInstance(MobEffects.REGENERATION, 200, 2, true, true);
|
||||
MobEffectInstance inst = new MobEffectInstance(MobEffects.BLINDNESS, 250, 1, true, true);
|
||||
// 02/26/2023 - Adjusted to 400 due to 1.18.2, the teleport is slightly more delayed, and thus a regen is needed incase levitation runs out too soon
|
||||
MobEffectInstance regen = new MobEffectInstance(MobEffects.REGENERATION, 400, 2, true, true);
|
||||
|
||||
// 10-05-2022 - Adjusted to 100 on duration due to a small issue where it would sometimes stop levitation prior to the teleport taking effect.
|
||||
// 02/26/2023 - Adjusted to 200 on duration due to 1.18.2 causing levitation to run out too quickly before teleport
|
||||
// Small tradeoff is the player now levitates slightly longer at the destination. This is acceptable. Compensated by increasing regen strength by 1
|
||||
MobEffectInstance invul = new MobEffectInstance(MobEffects.LEVITATION, 100, 1, true, true);
|
||||
MobEffectInstance levitate = new MobEffectInstance(MobEffects.LEVITATION, 200, 1, true, true);
|
||||
|
||||
|
||||
player.addEffect(inst);
|
||||
player.addEffect(regen);
|
||||
player.addEffect(invul); // ensure the player can't fall into lava in the short time we are not in control (if the player was silly enough to make a home above lava!!!)
|
||||
player.addEffect(levitate); // ensure the player can't fall into lava in the short time we are not in control (if the player was silly enough to make a home above lava!!!)
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
@ -3,6 +3,9 @@ package dev.zontreck.otemod.commands.teleport;
|
|||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.libzontreck.vectors.WorldPosition;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
|
@ -13,6 +16,7 @@ public class TeleportContainer implements Comparable{
|
|||
public UUID ToPlayer;
|
||||
public long StartedAt;
|
||||
public UUID TeleportID;
|
||||
public WorldPosition world_pos;
|
||||
|
||||
/*
|
||||
* The following variables are only used when actioning the teleport itself, and should only be initialized once the teleport is about to engage
|
||||
|
@ -41,6 +45,7 @@ public class TeleportContainer implements Comparable{
|
|||
|
||||
public TeleportContainer(ServerPlayer f_p, Vec3 f_pos, Vec2 f_rot, ServerLevel f_dim) {
|
||||
SetTeleportDestination(f_p, f_pos, f_rot, f_dim);
|
||||
world_pos = new WorldPosition(new Vector3(f_pos), f_dim);
|
||||
}
|
||||
|
||||
private void SetTeleportDestination(ServerPlayer f_p, Vec3 f_pos, Vec2 f_rot, ServerLevel f_dim) {
|
||||
|
@ -48,6 +53,7 @@ public class TeleportContainer implements Comparable{
|
|||
Position = f_pos;
|
||||
Rotation = f_rot;
|
||||
Dimension = f_dim;
|
||||
world_pos = new WorldPosition(new Vector3(f_pos), f_dim);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package dev.zontreck.otemod.commands.teleport;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.configs.PlayerFlyCache;
|
||||
import dev.zontreck.otemod.implementation.DelayedExecutorService;
|
||||
|
||||
public class TeleportRunnable implements Runnable
|
||||
{
|
||||
|
@ -12,27 +14,19 @@ public class TeleportRunnable implements Runnable
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
PlayerFlyCache c = PlayerFlyCache.cachePlayer(Action.PlayerInst);
|
||||
final PlayerFlyCache c = PlayerFlyCache.cachePlayer(Action.PlayerInst);
|
||||
Action.PlayerInst.teleportTo(Action.Dimension, Action.Position.x, Action.Position.y, Action.Position.z, Action.Rotation.y, Action.Rotation.x);
|
||||
|
||||
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
c.Assert(Action.PlayerInst);
|
||||
|
||||
Action.PlayerInst.setPos(Action.Position);
|
||||
|
||||
Action.PlayerInst.giveExperiencePoints(1); // Attempt to fix experience point bug
|
||||
OTEMod.delayedExecutor.schedule(new Runnable(){
|
||||
public PlayerFlyCache cached = c;
|
||||
public TeleportContainer container=Action;
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
c.Assert(container.PlayerInst);
|
||||
container.PlayerInst.setPos(container.Position);
|
||||
container.PlayerInst.giveExperiencePoints(1);
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,12 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.chat.Clickable;
|
||||
import dev.zontreck.libzontreck.exceptions.InvalidSideException;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import dev.zontreck.otemod.commands.teleport.RTPCommand;
|
||||
import dev.zontreck.otemod.commands.teleport.RTPContainer;
|
||||
import dev.zontreck.otemod.commands.teleport.RandomPositionFactory;
|
||||
import dev.zontreck.otemod.commands.teleport.TeleportActioner;
|
||||
import dev.zontreck.otemod.commands.teleport.TeleportContainer;
|
||||
import dev.zontreck.otemod.database.TeleportDestination;
|
||||
|
@ -29,6 +32,8 @@ import net.minecraft.network.chat.Style;
|
|||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class WarpCommand {
|
||||
|
||||
|
@ -57,11 +62,42 @@ public class WarpCommand {
|
|||
final int type = warp.RTP ? 1 : 0;
|
||||
final ServerLevel f_dim = dimL;
|
||||
|
||||
if(type == 1)
|
||||
{
|
||||
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix+ ChatColor.doColors(" !Dark_Green!Attempting to locate a safe location. This may take a minute or two")), p.server);
|
||||
}else{
|
||||
|
||||
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix+ ChatColor.doColors(" !Dark_Purple!Warping!")), p.server);
|
||||
}
|
||||
|
||||
Thread tx = new Thread(new Runnable(){
|
||||
public void run(){
|
||||
|
||||
if(type==1){
|
||||
dest.Position = RTPCommand.findPosition(source.getLevel(), false);
|
||||
try {
|
||||
dest.Position = Vector3.ZERO;
|
||||
RTPContainer cont = RandomPositionFactory.beginRTPSearch(p, Vec3.ZERO, Vec2.ZERO, f_dim);
|
||||
while(!cont.complete)
|
||||
{
|
||||
if(!OTEMod.ALIVE)
|
||||
{
|
||||
cont.aborted=true;
|
||||
cont.containingThread.interrupt();
|
||||
return;
|
||||
}
|
||||
if(cont.tries>30)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
dest.Position = cont.container.world_pos.Position;
|
||||
|
||||
//RTPCommand.findPosition(source.getLevel(), false, p.getUUID());
|
||||
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Location found, warping!")), p.server);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
TeleportActioner.ApplyTeleportEffect(p);
|
||||
|
|
22
src/main/java/dev/zontreck/otemod/events/RTPEvent.java
Normal file
22
src/main/java/dev/zontreck/otemod/events/RTPEvent.java
Normal file
|
@ -0,0 +1,22 @@
|
|||
package dev.zontreck.otemod.events;
|
||||
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.libzontreck.vectors.WorldPosition;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
@Cancelable
|
||||
public class RTPEvent extends Event
|
||||
{
|
||||
public ServerPlayer player;
|
||||
public WorldPosition position;
|
||||
|
||||
public RTPEvent(ServerPlayer player, WorldPosition position)
|
||||
{
|
||||
this.player=player;
|
||||
this.position=position;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package dev.zontreck.otemod.implementation;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import net.minecraftforge.event.TickEvent.ServerTickEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
|
||||
|
||||
@EventBusSubscriber(modid=OTEMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE)
|
||||
public class DelayedExecutorService {
|
||||
private static int COUNT = 0;
|
||||
public class DelayedExecution
|
||||
{
|
||||
public DelayedExecution(Runnable run, long unix) {
|
||||
scheduled=run;
|
||||
unix_time=unix;
|
||||
}
|
||||
public Runnable scheduled;
|
||||
public long unix_time;
|
||||
}
|
||||
|
||||
public List<DelayedExecution> EXECUTORS = new ArrayList<>();
|
||||
|
||||
public void schedule(Runnable run, int seconds)
|
||||
{
|
||||
long unix = Instant.now().getEpochSecond()+ (seconds);
|
||||
DelayedExecution exe = new DelayedExecution(run,unix);
|
||||
EXECUTORS.add(exe);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTick(ServerTickEvent ev)
|
||||
{
|
||||
if(!OTEMod.ALIVE)
|
||||
{
|
||||
OTEMod.LOGGER.info("Tearing down delayed executor service");
|
||||
|
||||
return;
|
||||
}
|
||||
Iterator<DelayedExecution> it = EXECUTORS.iterator();
|
||||
while(it.hasNext())
|
||||
{
|
||||
DelayedExecution e = it.next();
|
||||
if(e.unix_time < Instant.now().getEpochSecond())
|
||||
{
|
||||
it.remove();
|
||||
Thread tx = new Thread(e.scheduled);
|
||||
tx.setName("DelayedExecutorTask-"+String.valueOf(DelayedExecutorService.getNext()));
|
||||
tx.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int getNext()
|
||||
{
|
||||
COUNT++;
|
||||
return COUNT;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package dev.zontreck.otemod.implementation.warps;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import dev.zontreck.otemod.database.FileTreeDatastore;
|
||||
|
@ -13,6 +14,14 @@ public class WarpsProvider extends FileTreeDatastore
|
|||
|
||||
public static final Warps WARPS_INSTANCE;
|
||||
static{
|
||||
if(!BASE.toFile().exists()){
|
||||
try {
|
||||
Files.createDirectory(BASE);
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
WARPS_INSTANCE = getOrCreate();
|
||||
}
|
||||
|
||||
|
|
|
@ -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.0224230125" #mandatory
|
||||
version="1.3.7.0226231329" #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/
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"": {
|
||||
"model": "otemod:block/eternium_block"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -49,6 +49,7 @@
|
|||
"block.otemod.stable_singularity": "Stable Singularity",
|
||||
"block.otemod.vault_steel_ore_block": "Vault Steel Ore",
|
||||
"block.otemod.nether_vault_steel_ore_block": "Nether Vault Steel Ore",
|
||||
"block.otemod.eternium_block": "Block of Eternium",
|
||||
|
||||
|
||||
"enchantment.otemod.mob_egging": "Mob Egging",
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "otemod:block/eternium_block"
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "otemod:block/vault_steel_ore_block"
|
||||
"all": "otemod:block/nether_vault_steel_ore_block"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "otemod:block/eternium_block"
|
||||
}
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"parent": "otemod:block/vault_steel_ore_block"
|
||||
"parent": "otemod:block/nether_vault_steel_ore_block"
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 534 B |
5
src/main/resources/data/forge/tags/blocks/brimstone.json
Normal file
5
src/main/resources/data/forge/tags/blocks/brimstone.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"values": [
|
||||
"biomesoplenty:brimstone"
|
||||
]
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"values": [
|
||||
"#forge:storage_blocks/raw_cobalt"
|
||||
"#forge:storage_blocks/eternium"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"values": [
|
||||
"otemod:eternium_block"
|
||||
]
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"values": [
|
||||
"otemod:raw_cobalt_ore"
|
||||
]
|
||||
}
|
5
src/main/resources/data/forge/tags/items/brimstone.json
Normal file
5
src/main/resources/data/forge/tags/items/brimstone.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"values": [
|
||||
"biomesoplenty:brimstone"
|
||||
]
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"values": [
|
||||
"#forge:storage_blocks/raw_cobalt"
|
||||
"#forge:storage_blocks/eternium"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"values":[
|
||||
"otemod:eternium_block"
|
||||
]
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"values":[
|
||||
"otemod:raw_cobalt_ore"
|
||||
]
|
||||
}
|
|
@ -11,6 +11,7 @@
|
|||
"otemod:item_scrubber",
|
||||
"otemod:magical_scrubber",
|
||||
|
||||
"otemod:vault_steel_ore_block"
|
||||
"otemod:vault_steel_ore_block",
|
||||
"otemod:eternium_block"
|
||||
]
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
"otemod:aurora_door",
|
||||
"otemod:item_scrubber",
|
||||
"otemod:magical_scrubber",
|
||||
"otemod:vault_steel_ore_block"
|
||||
"otemod:vault_steel_ore_block",
|
||||
"otemod:eternium_block"
|
||||
]
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"type": "minecraft:overworld",
|
||||
"type": "otemod:resource",
|
||||
"generator": {
|
||||
"type": "minecraft:noise",
|
||||
"seed": 0,
|
||||
"settings": "minecraft:overworld",
|
||||
"settings": "otemod:resource",
|
||||
"biome_source": {
|
||||
"type": "minecraft:multi_noise",
|
||||
"biomes": [
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"type": "minecraft:the_nether",
|
||||
"type": "otemod:resource_nether",
|
||||
"generator": {
|
||||
"type": "minecraft:noise",
|
||||
"seed": 0,
|
||||
"settings": "minecraft:nether",
|
||||
"settings": "otemod:resource_nether",
|
||||
"biome_source": {
|
||||
"type": "minecraft:multi_noise",
|
||||
"biomes": [
|
||||
|
|
|
@ -3,18 +3,15 @@
|
|||
"natural": true,
|
||||
"piglin_safe": false,
|
||||
"respawn_anchor_works": false,
|
||||
"bed_works": true,
|
||||
"has_raids": false,
|
||||
"bed_works": false,
|
||||
"has_raids": true,
|
||||
"has_skylight": false,
|
||||
"has_ceiling": false,
|
||||
"coordinate_scale": 12,
|
||||
"coordinate_scale": 16,
|
||||
"ambient_light": 1,
|
||||
"fixed_time": 0,
|
||||
"logical_height": 384,
|
||||
"effects": "minecraft:the_end",
|
||||
"infiniburn": "#minecraft:infiniburn_overworld",
|
||||
"min_y": -64,
|
||||
"height": 384,
|
||||
"monster_spawn_light_level": 0,
|
||||
"monster_spawn_block_light_limit": 0
|
||||
"height": 384
|
||||
}
|
||||
|
|
|
@ -2,19 +2,17 @@
|
|||
"ultrawarm": true,
|
||||
"natural": false,
|
||||
"piglin_safe": true,
|
||||
"respawn_anchor_works": false,
|
||||
"bed_works": true,
|
||||
"respawn_anchor_works": true,
|
||||
"bed_works": false,
|
||||
"has_raids": false,
|
||||
"has_skylight": false,
|
||||
"has_ceiling": false,
|
||||
"coordinate_scale": 12,
|
||||
"has_ceiling": true,
|
||||
"coordinate_scale": 16,
|
||||
"ambient_light": 1,
|
||||
"fixed_time": 0,
|
||||
"logical_height": 384,
|
||||
"fixed_time": 1,
|
||||
"logical_height": 128,
|
||||
"effects": "minecraft:the_end",
|
||||
"infiniburn": "#minecraft:infiniburn_overworld",
|
||||
"min_y": -64,
|
||||
"height": 384,
|
||||
"monster_spawn_light_level": 0,
|
||||
"monster_spawn_block_light_limit": 0
|
||||
"infiniburn": "#minecraft:infiniburn_nether",
|
||||
"min_y": 0,
|
||||
"height": 256
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
A simple file to keep this directory here
|
1
src/main/resources/data/otemod/functions/.placeholder
Normal file
1
src/main/resources/data/otemod/functions/.placeholder
Normal file
|
@ -0,0 +1 @@
|
|||
A simple file to keep this directory here
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"ingredients": [
|
||||
{
|
||||
"tag": "forge:brimstone"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "mekanism:sulfur_dust",
|
||||
"count": 1
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"type": "mekanism:crushing",
|
||||
"input": {
|
||||
"ingredient": {
|
||||
"tag": "forge:brimstone"
|
||||
}
|
||||
},
|
||||
"output": {
|
||||
"item": "mekanism:dust_sulfur",
|
||||
"count": 4
|
||||
}
|
||||
}
|
17
src/main/resources/data/otemod/recipes/eternium_block.json
Normal file
17
src/main/resources/data/otemod/recipes/eternium_block.json
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"CCC",
|
||||
"CCC",
|
||||
"CCC"
|
||||
],
|
||||
"key": {
|
||||
"C": {
|
||||
"item": "otemod:eternium_ingot"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "otemod:eternium_block",
|
||||
"count": 1
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "otemod:eternium_block"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "otemod:eternium_ingot",
|
||||
"count": 9
|
||||
}
|
||||
}
|
Reference in a new issue