Skip to content

Commit

Permalink
Break speed fix, Colorful commands
Browse files Browse the repository at this point in the history
  • Loading branch information
DuchLord committed Sep 3, 2016
1 parent e8e1ed9 commit 8b3edcf
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 13 deletions.
29 changes: 18 additions & 11 deletions src/main/java/treechopper/common/command/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import treechopper.core.ConfigHandler;
import treechopper.core.ServerMessage;
import treechopper.core.TreeChopper;
Expand Down Expand Up @@ -46,36 +47,42 @@ public void execute(MinecraftServer server, ICommandSender sender, String[] args
throw new WrongUsageException("/treechop <ignoredur|plantsap|decayleaves|breakspeed> [value]");

else if (args[0].equals("ignoredur")) {
if (args.length != 2) {
if (args.length != 2)
throw new WrongUsageException("/treechop ignoredur [0,1]");
}

ConfigHandler.setIgnoreDurability(parseBoolean(args[1]));
sender.addChatMessage(new TextComponentTranslation("Ignore axe durability set to " + ConfigHandler.ignoreDurability));
if (ConfigHandler.ignoreDurability)
sender.addChatMessage(new TextComponentTranslation("[" + TextFormatting.GOLD + "TCH" + TextFormatting.RESET + "]Ignore axe durability has been switched " + TextFormatting.GREEN + "ON"));
else
sender.addChatMessage(new TextComponentTranslation("[" + TextFormatting.GOLD + "TCH" + TextFormatting.RESET + "]Ignore axe durability has been switched " + TextFormatting.RED + "OFF"));

} else if (args[0].equals("plantsap")) {
if (args.length != 2) {
if (args.length != 2)
throw new WrongUsageException("/treechop plantsap [0,1]");
}

ConfigHandler.setPlantSapling(parseBoolean(args[1]));
sender.addChatMessage(new TextComponentTranslation("Plant sapling automatically set to " + ConfigHandler.plantSapling));
if (ConfigHandler.plantSapling)
sender.addChatMessage(new TextComponentTranslation("[" + TextFormatting.GOLD + "TCH" + TextFormatting.RESET + "]Auto sapling has been switched " + TextFormatting.GREEN + "ON"));
else
sender.addChatMessage(new TextComponentTranslation("[" + TextFormatting.GOLD + "TCH" + TextFormatting.RESET + "]Auto sapling has been switched " + TextFormatting.RED + "OFF"));

} else if (args[0].equals("decayleaves")) {
if (args.length != 2) {
if (args.length != 2)
throw new WrongUsageException("/treechop decayleaves [0,1]");
}

ConfigHandler.setDecayLeaves(parseBoolean(args[1]));
sender.addChatMessage(new TextComponentTranslation("Decay leaves set to " + ConfigHandler.decayLeaves));
if (ConfigHandler.decayLeaves)
sender.addChatMessage(new TextComponentTranslation("[" + TextFormatting.GOLD + "TCH" + TextFormatting.RESET + "]Decay leaves has been switched " + TextFormatting.GREEN + "ON"));
else
sender.addChatMessage(new TextComponentTranslation("[" + TextFormatting.GOLD + "TCH" + TextFormatting.RESET + "]Decay leaves has been switched " + TextFormatting.RED + "OFF"));

} else if (args[0].equals("breakspeed")) {
if (args.length != 2) {
if (args.length != 2)
throw new WrongUsageException("/treechop breakspeed [value]");
}

ConfigHandler.setBreakSpeed(parseInt(args[1], 1, 1000));
sender.addChatMessage(new TextComponentTranslation("Break speed [DEFAULT: 10] set to " + ConfigHandler.breakSpeed + " be careful!"));
sender.addChatMessage(new TextComponentTranslation("[" + TextFormatting.GOLD + "TCH" + TextFormatting.RESET + "]Break speed has been set to " + ConfigHandler.breakSpeed + ", [DEFAULT: 10]"));

TreeChopper.network.sendToAll(new ServerMessage(ConfigHandler.breakSpeed));
} else
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/treechopper/common/command/CommandsInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package treechopper.common.command;

import com.google.common.collect.Lists;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.server.MinecraftServer;

import java.util.List;

/**
* Created by Duchy on 9/3/2016.
*/
public class CommandsInfo extends CommandBase {

@Override
public String getCommandName() {
return "treechop";
}

@Override
public String getCommandUsage(ICommandSender sender) {
return "/treechop <info>";
}

@Override
public List getCommandAliases() {
return Lists.newArrayList("tch");
}

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {

// TODO

}
}
5 changes: 3 additions & 2 deletions src/main/java/treechopper/core/EventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.mojang.realmsclient.gui.ChatFormatting;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
Expand Down Expand Up @@ -120,8 +119,10 @@ public void interactWithTree(PlayerInteractEvent event) {
StaticHandler.control = false;
ClientProxy.logCount = 0;
}
} else
} else {
StaticHandler.control = false;
ClientProxy.logCount = 0;
}

if (StaticHandler.serverSide)
StaticHandler.playerHoldShift.put(event.getEntityPlayer().getEntityId(), event.getEntityPlayer().isSneaking());
Expand Down
1 change: 1 addition & 0 deletions src/main/java/treechopper/proxy/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class ClientProxy extends CommonProxy {

@Override
public void breakSpeedPlayer(net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed event) {

if (logCount > 1) {

if (event.getOriginalSpeed() <= 4.0f)
Expand Down

0 comments on commit 8b3edcf

Please sign in to comment.