diff options
author | Tec <daniel112092@gmail.com> | 2019-07-15 20:06:58 +0200 |
---|---|---|
committer | Tec <daniel112092@gmail.com> | 2019-07-15 20:06:58 +0200 |
commit | a696ad3aa1660fb74b4b8a2ea792cc0cde86f595 (patch) | |
tree | a7f677efcfec1c1126bedb8bd4ea7128a4bb8137 | |
parent | 0f367b0d1d46c93ea39ae191d37d2359a6dc2d4c (diff) | |
download | GT5-Unofficial-a696ad3aa1660fb74b4b8a2ea792cc0cde86f595.tar.gz GT5-Unofficial-a696ad3aa1660fb74b4b8a2ea792cc0cde86f595.tar.bz2 GT5-Unofficial-a696ad3aa1660fb74b4b8a2ea792cc0cde86f595.zip |
Sanser command
3 files changed, 94 insertions, 5 deletions
diff --git a/src/main/java/com/github/technus/tectech/TecTech.java b/src/main/java/com/github/technus/tectech/TecTech.java index 493d3aa115..096aafc468 100644 --- a/src/main/java/com/github/technus/tectech/TecTech.java +++ b/src/main/java/com/github/technus/tectech/TecTech.java @@ -2,6 +2,7 @@ package com.github.technus.tectech; import com.github.technus.tectech.loader.MainLoader; import com.github.technus.tectech.loader.TecTechConfig; +import com.github.technus.tectech.mechanics.commands.CancerCommand; import com.github.technus.tectech.mechanics.commands.ConvertFloat; import com.github.technus.tectech.mechanics.commands.ConvertInteger; import com.github.technus.tectech.mechanics.anomaly.AnomalyHandler; @@ -205,6 +206,7 @@ public class TecTech { pEvent.registerServerCommand(new ListEM()); if(DEBUG_MODE) { pEvent.registerServerCommand(new GiveEM()); + pEvent.registerServerCommand(new CancerCommand()); } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java b/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java index 4f76b22279..01c028bf40 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java +++ b/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java @@ -33,11 +33,11 @@ import java.util.HashMap; import java.util.List; public class AnomalyHandler implements IChunkMetaDataHandler { - private static final double SWAP_THRESHOLD = dAtomDefinition.getSomethingHeavy().getMass() * 10000D; - private static final int COUNT_DIV=32; - private static final double PER_PARTICLE=SWAP_THRESHOLD/COUNT_DIV; - private static final String INTENSITY = "intensity",SPACE_CANCER="space_cancer"; - private static final int MEAN_DELAY =50; + public static final double SWAP_THRESHOLD = dAtomDefinition.getSomethingHeavy().getMass() * 10000D; + public static final int COUNT_DIV=32; + public static final double PER_PARTICLE=SWAP_THRESHOLD/COUNT_DIV; + public static final String INTENSITY = "intensity",SPACE_CANCER="space_cancer"; + public static final int MEAN_DELAY =50; private boolean fixMe=false; diff --git a/src/main/java/com/github/technus/tectech/mechanics/commands/CancerCommand.java b/src/main/java/com/github/technus/tectech/mechanics/commands/CancerCommand.java new file mode 100644 index 0000000000..64caeb1caf --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/commands/CancerCommand.java @@ -0,0 +1,87 @@ +package com.github.technus.tectech.mechanics.commands; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.loader.NetworkDispatcher; +import com.github.technus.tectech.mechanics.data.PlayerDataMessage; +import net.minecraft.command.ICommand; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChatComponentText; + +import java.util.ArrayList; +import java.util.List; + +import static com.github.technus.tectech.mechanics.anomaly.AnomalyHandler.SPACE_CANCER; + +public class CancerCommand implements ICommand { + ArrayList<String> aliases=new ArrayList<>(); + + public CancerCommand(){ + aliases.add("cancer"); + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + if (sender instanceof EntityPlayerMP && !sender.getEntityWorld().isRemote) { + double amount; + try { + amount = Double.parseDouble(args[0]); + }catch (NumberFormatException e){ + sender.addChatMessage(new ChatComponentText("Cannot parse amount!")); + return; + } + if(amount<0||amount>2){ + sender.addChatMessage(new ChatComponentText("Invalid amount provided!")); + return; + } + EntityPlayerMP player=(EntityPlayerMP)sender; + NBTTagCompound playerTag = TecTech.playerPersistence.getDataOrSetToNewTag(player); + if(player.capabilities.isCreativeMode){ + sender.addChatMessage(new ChatComponentText("Doesn't really work in creative mode!")); + }else { + playerTag.setDouble(SPACE_CANCER, amount); + TecTech.playerPersistence.saveData(player); + NetworkDispatcher.INSTANCE.sendTo(new PlayerDataMessage.PlayerDataData(player), player); + } + } + } + + @Override + public boolean isUsernameIndex(String[] p_82358_1_, int p_82358_2_) { + return false; + } + + @Override + public List<String> getCommandAliases() { + return aliases; + } + + @Override + public String getCommandName() { + return aliases.get(0); + } + + @Override + public List<String> addTabCompletionOptions(ICommandSender sender, String[] args) { + return null; + } + + @Override + public String getCommandUsage(ICommandSender p_71518_1_) { + return "cancer [Amount 0.0-2.0]"; + } + + @Override + public int compareTo(Object o) { + if(o instanceof ICommand){ + return getCommandName().compareTo(((ICommand) o).getCommandName()); + } + return 0; + } + + @Override + public boolean canCommandSenderUseCommand(ICommandSender sender) { + return true; + } +} |