Skip to content

Commit

Permalink
Added Fireworks and Smite
Browse files Browse the repository at this point in the history
  • Loading branch information
dries007 committed Mar 27, 2016
1 parent 4a0b0ea commit 7095f36
Show file tree
Hide file tree
Showing 7 changed files with 270 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -20,6 +20,8 @@ Commands currently included:
* /top [target player]
* /tps [worldID]
* /tpx <target player> <destination player> OR /tp <target player> [Dimension ID] [x] [y] [z]
* /smite [target player] [radius] [rockets]
* /fireworks [target player] [radius] [rockets]

Since v1.2 you can add custom **give item** commands, like we had `/key` for spectre keys.
Look at the config for an example.
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -28,7 +28,7 @@ apply plugin: "maven"
apply plugin: "idea-utils"

group = "net.doubledoordev.d3commands"
version = "1.2.0"
version = "1.2.1"

targetCompatibility = 1.7
sourceCompatibility = 1.7
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/doubledoordev/d3commands/D3Commands.java
Expand Up @@ -91,6 +91,8 @@ public void syncConfig()
commands.add(new CommandEntry(new CommandSpawn(), configuration.getBoolean("spawn", MODID, true, "Teleport to spawn")));
commands.add(new CommandEntry(new CommandPos(), configuration.getBoolean("pos", MODID, true, "Get other players coordinates.")));
commands.add(new CommandEntry(new CommandExplorers(), configuration.getBoolean("analiselocations", MODID, true, "Analise locations of online players.")));
commands.add(new CommandEntry(new CommandSmite(), configuration.getBoolean("smite", MODID, true, "Power! UNLIMITED POWER.")));
commands.add(new CommandEntry(new CommandFireworks(), configuration.getBoolean("fireworks", MODID, true, "Needs more fireworks.")));

configuration.setCategoryLanguageKey(MODID, "d3.cmd.config.cmd");
configuration.addCustomCategoryComment(MODID, "Set any value to false to disable the command.");
Expand Down
@@ -0,0 +1,138 @@
/*
* Copyright (c) 2014-2016, Dries007 & DoubleDoorDevelopment
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package net.doubledoordev.d3commands.commands;

import net.doubledoordev.d3commands.util.Constants;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.item.EntityFireworkRocket;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.server.MinecraftServer;

import java.util.List;

public class CommandFireworks extends CommandBase
{
@Override
public String getCommandName()
{
return "fireworks";
}

@Override
public String getCommandUsage(ICommandSender icommandsender)
{
return "/fireworks [player] [radius] [rockets]";
}

@Override
public int getRequiredPermissionLevel()
{
return 2;
}

@Override
public boolean isUsernameIndex(final String[] args, final int userIndex)
{
return userIndex == 0;
}

@Override
public List addTabCompletionOptions(final ICommandSender sender, final String[] args)
{
if (args.length == 1) return getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames());
return null;
}

@Override
public void processCommand(ICommandSender sender, String[] args)
{
EntityPlayerMP target;

if (args.length == 0) target = getCommandSenderAsPlayer(sender);
else target = getPlayer(sender, args[0]);

double x = target.posX;
double z = target.posZ;

int rad = 1;
if (args.length > 1) rad = parseIntWithMin(sender, args[1], 1);

int rockets = 1;
if (args.length > 2) rockets = parseIntWithMin(sender, args[2], 1);

while (rockets -- > 0)
{
ItemStack itemStack = new ItemStack(Items.fireworks);
NBTTagCompound fireworks = new NBTTagCompound();
NBTTagList explosions = new NBTTagList();

int charges = 1 + Constants.RANDOM.nextInt(3);
while (charges -- > 0)
{
NBTTagCompound explosion = new NBTTagCompound();

if (Constants.RANDOM.nextBoolean()) explosion.setBoolean("Flicker", true);
if (Constants.RANDOM.nextBoolean()) explosion.setBoolean("Trail", true);

int[] colors = new int[1 + Constants.RANDOM.nextInt(3)];

for (int i = 0; i < colors.length; i++)
{
colors[i] = (Constants.RANDOM.nextInt(256) << 16) + (Constants.RANDOM.nextInt(256) << 8) + Constants.RANDOM.nextInt(256);
}

explosion.setIntArray("Colors", colors);
explosion.setByte("Type", (byte) Constants.RANDOM.nextInt(5));

if (Constants.RANDOM.nextBoolean())
{
int[] fadeColors = new int[1 + Constants.RANDOM.nextInt(3)];

for (int i = 0; i < fadeColors.length; i++)
{
fadeColors[i] = (Constants.RANDOM.nextInt(256) << 16) + (Constants.RANDOM.nextInt(256) << 8) + Constants.RANDOM.nextInt(256);
}
explosion.setIntArray("FadeColors", fadeColors);
}

explosions.appendTag(explosion);
}
fireworks.setTag("Explosions", explosions);
fireworks.setByte("Flight", (byte) (Constants.RANDOM.nextInt(2)));

NBTTagCompound root = new NBTTagCompound();
root.setTag("Fireworks", fireworks);
itemStack.setTagCompound(root);
target.worldObj.spawnEntityInWorld(new EntityFireworkRocket(target.worldObj, x + Constants.RANDOM.nextInt(rad) - rad / 2.0, target.posY, z + Constants.RANDOM.nextInt(rad) - rad / 2.0, itemStack));
}
}
}
@@ -0,0 +1,93 @@
/*
* Copyright (c) 2014-2016, Dries007 & DoubleDoorDevelopment
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package net.doubledoordev.d3commands.commands;

import net.doubledoordev.d3commands.util.Constants;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;

import java.util.List;

public class CommandSmite extends CommandBase
{
@Override
public String getCommandName()
{
return "smite";
}

@Override
public String getCommandUsage(ICommandSender icommandsender)
{
return "/smite [player] [radius] [strikes]";
}

@Override
public int getRequiredPermissionLevel()
{
return 2;
}

@Override
public boolean isUsernameIndex(final String[] args, final int userIndex)
{
return userIndex == 0;
}

@Override
public List addTabCompletionOptions(final ICommandSender sender, final String[] args)
{
if (args.length == 1) return getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames());
return null;
}

@Override
public void processCommand(ICommandSender sender, String[] args)
{
EntityPlayerMP target;

if (args.length == 0) target = getCommandSenderAsPlayer(sender);
else target = getPlayer(sender, args[0]);

double x = target.posX;
double z = target.posZ;

int rad = 1;
if (args.length > 1) rad = parseIntWithMin(sender, args[1], 1);

int stikes = 1;
if (args.length > 2) stikes = parseIntWithMin(sender, args[2], 1);

while (stikes -- > 0)
{
target.worldObj.addWeatherEffect(new EntityLightningBolt(target.worldObj, x + Constants.RANDOM.nextInt(rad) - rad / 2.0, target.posY, z + Constants.RANDOM.nextInt(rad) - rad / 2.0));
}
}
}
Expand Up @@ -26,11 +26,14 @@

package net.doubledoordev.d3commands.util;

import java.util.Random;

/**
* @author Dries007
*/
public class Constants
{
public static final Random RANDOM = new Random();
public static final String MODID = "D3Commands";
public static final String NAME = "D³ Commands";
}
32 changes: 31 additions & 1 deletion src/main/java/net/doubledoordev/d3commands/util/Location.java
Expand Up @@ -53,7 +53,7 @@ public Location(int x, int y, int z, int dimensionId)

public Location(Entity entity)
{
this(MathHelper.floor_double(entity.posX), MathHelper.floor_double(entity.posY + 0.5D), MathHelper.floor_double(entity.posZ), entity.dimension);
this(MathHelper.floor_double(entity.posX), MathHelper.floor_double(entity.posY), MathHelper.floor_double(entity.posZ), entity.dimension);
}

public ChunkCoordinates getCoordinates()
Expand Down Expand Up @@ -99,6 +99,21 @@ public void set(int x, int y, int z)
this.coordinates.posZ = z;
}

public void setX(int x)
{
this.coordinates.posX = x;
}

public void setY(int y)
{
this.coordinates.posY = y;
}

public void setZ(int z)
{
this.coordinates.posZ = z;
}

public int getX()
{
return coordinates.posX;
Expand All @@ -113,4 +128,19 @@ public int getZ()
{
return coordinates.posZ;
}

public int deltaX(int delta)
{
return (this.coordinates.posX += delta);
}

public int deltaY(int delta)
{
return (this.coordinates.posY += delta);
}

public int deltaZ(int delta)
{
return (this.coordinates.posZ += delta);
}
}

0 comments on commit 7095f36

Please sign in to comment.