mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
Added configurable portable teleport delay
This commit is contained in:
1 parent
bacd97f44a
commit
b0dd7a10e7
6 files changed
+63
-2
No files matched your search
@@ -10,6 +10,8 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.IClientTicker;
|
||||
@@ -20,6 +22,8 @@ import mekanism.common.KeySync;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.ObfuscatedNames;
|
||||
import mekanism.common.config.MekanismConfig.client;
|
||||
import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.frequency.Frequency;
|
||||
import mekanism.common.item.ItemFlamethrower;
|
||||
import mekanism.common.item.ItemFreeRunners;
|
||||
import mekanism.common.item.ItemGasMask;
|
||||
@@ -30,6 +34,8 @@ import mekanism.common.network.PacketFlamethrowerData;
|
||||
import mekanism.common.network.PacketFlamethrowerData.FlamethrowerDataMessage;
|
||||
import mekanism.common.network.PacketJetpackData.JetpackDataMessage;
|
||||
import mekanism.common.network.PacketJetpackData.JetpackPacket;
|
||||
import mekanism.common.network.PacketPortableTeleporter.PortableTeleporterMessage;
|
||||
import mekanism.common.network.PacketPortableTeleporter.PortableTeleporterPacketType;
|
||||
import mekanism.common.network.PacketScubaTankData.ScubaTankDataMessage;
|
||||
import mekanism.common.network.PacketScubaTankData.ScubaTankPacket;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
@@ -41,6 +47,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StringUtils;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
@@ -70,6 +78,7 @@ public class ClientTickHandler
|
||||
public boolean shouldReset = false;
|
||||
|
||||
public static Minecraft mc = FMLClientHandler.instance().getClient();
|
||||
public static Random rand = new Random();
|
||||
|
||||
public static final String MIKE_CAPE = "https://dl.dropboxusercontent.com/s/ji06yflixnszcby/cape.png";
|
||||
public static final String DONATE_CAPE = "https://dl.dropboxusercontent.com/u/90411166/donate.png";
|
||||
@@ -80,6 +89,7 @@ public class ClientTickHandler
|
||||
private Map<String, CapeBufferDownload> aidanDownload = new HashMap<String, CapeBufferDownload>();
|
||||
|
||||
public static Set<IClientTicker> tickingSet = new HashSet<IClientTicker>();
|
||||
public static Map<EntityPlayer, TeleportData> portableTeleports = new HashMap<>();
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTick(ClientTickEvent event)
|
||||
@@ -300,6 +310,26 @@ public class ClientTickHandler
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(Iterator<Entry<EntityPlayer, TeleportData>> iter = portableTeleports.entrySet().iterator(); iter.hasNext();)
|
||||
{
|
||||
Entry<EntityPlayer, TeleportData> entry = iter.next();
|
||||
|
||||
for(int i = 0; i < 100; i++)
|
||||
{
|
||||
double x = entry.getKey().posX + rand.nextDouble()-0.5D;
|
||||
double y = entry.getKey().posY + rand.nextDouble()*2-2D;
|
||||
double z = entry.getKey().posZ + rand.nextDouble()-0.5D;
|
||||
|
||||
mc.world.spawnParticle(EnumParticleTypes.PORTAL, x, y, z, 0, 1, 0);
|
||||
}
|
||||
|
||||
if(mc.world.getWorldTime() == entry.getValue().teleportTime)
|
||||
{
|
||||
Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage(PortableTeleporterPacketType.TELEPORT, entry.getValue().hand, entry.getValue().freq));
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack chestStack = mc.player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
|
||||
@@ -523,4 +553,29 @@ public class ClientTickHandler
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void portableTeleport(EntityPlayer player, EnumHand hand, Frequency freq)
|
||||
{
|
||||
if(general.portableTeleporterDelay == 0)
|
||||
{
|
||||
Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage(PortableTeleporterPacketType.TELEPORT, hand, freq));
|
||||
}
|
||||
else {
|
||||
portableTeleports.put(player, new TeleportData(hand, freq, mc.world.getWorldTime()+general.portableTeleporterDelay));
|
||||
}
|
||||
}
|
||||
|
||||
private static class TeleportData
|
||||
{
|
||||
private EnumHand hand;
|
||||
private Frequency freq;
|
||||
private long teleportTime;
|
||||
|
||||
public TeleportData(EnumHand h, Frequency f, long t)
|
||||
{
|
||||
hand = h;
|
||||
freq = f;
|
||||
teleportTime = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,7 @@ public class MekanismClient extends Mekanism
|
||||
}
|
||||
|
||||
ClientTickHandler.tickingSet.clear();
|
||||
ClientTickHandler.portableTeleports.clear();
|
||||
|
||||
TransmitterModel.clearCache();
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.UUID;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.client.ClientTickHandler;
|
||||
import mekanism.client.MekanismClient;
|
||||
import mekanism.client.gui.element.GuiPowerBar;
|
||||
import mekanism.client.gui.element.GuiPowerBar.IPowerInfoHandler;
|
||||
@@ -406,7 +407,7 @@ public class GuiTeleporter extends GuiMekanism
|
||||
if(clientFreq != null && clientStatus == 1)
|
||||
{
|
||||
mc.setIngameFocus();
|
||||
Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage(PortableTeleporterPacketType.TELEPORT, currentHand, clientFreq));
|
||||
ClientTickHandler.portableTeleport(entityPlayer, currentHand, clientFreq);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ import mekanism.common.base.IGuiProvider;
|
||||
import mekanism.common.base.IUpgradeTile;
|
||||
import mekanism.common.block.states.BlockStateMachine;
|
||||
import mekanism.common.block.states.BlockStateMachine.MachineType;
|
||||
import mekanism.common.config.TypeConfigManager;
|
||||
import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.config.MekanismConfig.usage;
|
||||
import mekanism.common.config.TypeConfigManager;
|
||||
import mekanism.common.entity.EntityRobit;
|
||||
import mekanism.common.inventory.container.ContainerAdvancedElectricMachine;
|
||||
import mekanism.common.inventory.container.ContainerChanceMachine;
|
||||
@@ -282,6 +282,7 @@ public class CommonProxy implements IGuiProvider
|
||||
general.allowTransmitterAlloyUpgrade = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "AllowTransmitterAlloyUpgrade", true).getBoolean();
|
||||
general.allowChunkloading = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "AllowChunkloading", true).getBoolean();
|
||||
general.allowProtection = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "AllowProtection", true).getBoolean();
|
||||
general.portableTeleporterDelay = 100;//Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "PortableTeleporterDelay", 0).getInt();
|
||||
|
||||
general.blacklistIC2 = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "BlacklistIC2Power", false).getBoolean();
|
||||
general.blacklistRF = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "BlacklistRFPower", false).getBoolean();
|
||||
|
||||
@@ -72,6 +72,7 @@ public class MekanismConfig
|
||||
public static boolean allowTransmitterAlloyUpgrade;
|
||||
public static boolean allowChunkloading;
|
||||
public static boolean allowProtection = true;
|
||||
public static int portableTeleporterDelay;
|
||||
}
|
||||
|
||||
public static class client
|
||||
|
||||
@@ -80,6 +80,7 @@ public class PacketConfigSync implements IMessageHandler<ConfigSyncMessage, IMes
|
||||
dataStream.writeBoolean(general.allowTransmitterAlloyUpgrade);
|
||||
dataStream.writeBoolean(general.allowChunkloading);
|
||||
dataStream.writeBoolean(general.allowProtection);
|
||||
dataStream.writeInt(general.portableTeleporterDelay);
|
||||
|
||||
for(MachineType type : BlockStateMachine.MachineType.getValidMachines())
|
||||
{
|
||||
@@ -176,6 +177,7 @@ public class PacketConfigSync implements IMessageHandler<ConfigSyncMessage, IMes
|
||||
general.allowTransmitterAlloyUpgrade = dataStream.readBoolean();
|
||||
general.allowChunkloading = dataStream.readBoolean();
|
||||
general.allowProtection = dataStream.readBoolean();
|
||||
general.portableTeleporterDelay = dataStream.readInt();
|
||||
|
||||
for(MachineType type : BlockStateMachine.MachineType.getValidMachines())
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user