Skip to content

Commit

Permalink
Fix some obfuscation when dealing with head yaw.
Browse files Browse the repository at this point in the history
  • Loading branch information
aufdemrand committed Mar 18, 2013
1 parent 654fddc commit bdfce5a
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 7 deletions.
Expand Up @@ -147,7 +147,9 @@ public void NPCCompleteDestination (NavigationCompleteEvent event) {
EntityLiving handle = ((CraftLivingEntity) npc.getBukkitEntity()).getHandle();
handle.yaw = returnLocation.getYaw();
handle.pitch = returnLocation.getPitch();
handle.az = handle.yaw;
// !--- START NMS OBFUSCATED
handle.aA = handle.yaw; // The head's yaw
// !--- END NMS OBFUSCATED
pushed = false;
// Push Return action
DenizenAPI.getDenizenNPC(npc).action("push return", null);
Expand Down
Expand Up @@ -8,6 +8,7 @@
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizen.utilities.debugging.dB.DebugElement;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.AbstractNPC;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
Expand Down Expand Up @@ -36,7 +37,7 @@ public boolean execute(ScriptEntry scriptEntry) {
return false;
}

// Get the command instance ready for the execution of the scriptEntry
// Get the command instance ready for the execution of the scriptEntry
AbstractCommand command = plugin.getCommandRegistry().get(scriptEntry.getCommandName());

// Debugger information
Expand Down
@@ -0,0 +1,154 @@
package net.aufdemrand.denizen.scripts.commands.core;

import net.aufdemrand.denizen.exceptions.CommandExecutionException;
import net.aufdemrand.denizen.exceptions.InvalidArgumentsException;
import net.aufdemrand.denizen.scripts.ScriptEntry;
import net.aufdemrand.denizen.scripts.commands.AbstractCommand;
import net.aufdemrand.denizen.utilities.arguments.aH;
import net.aufdemrand.denizen.utilities.arguments.aH.ArgumentType;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizen.utilities.debugging.dB.Messages;

import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;

/**
* Modifies blocks based based of single block location.
* Possibility to do faux animations with blocks.
*
* @author Mason Adkins
*/

public class CopyBlockCommand extends AbstractCommand{

@Override
public void onEnable() {
//nothing to do here
}

/* MODIFYBLOCK [LOCATION:x,y,z,world] [MATERIAL:DATA VALUE] (RADIUS:##) (HEIGHT:##) (DEPTH:##) */

/*
* Arguments: [] - Required, () - Optional
* [LOCATION:x,y,z,world] Block location
* [MATERIAL|M] Material/ID to change block(s) to
* (RADIUS|R) Radius of the selection, default is zero (only changes the one block)
* (DEPTH|D) Depth of the selection, default is zero
* (HEIGHT|H) Height of the selection, default is zero
*
* Example Usage:
* MODIFYBLOCK LOCATION:??? MATERIAL:GRASS RADIUS:2 DEPTH:1 HEIGHT:1
* MODIFYBLOCK LOCATION:??? M:STONE R:2 D:3 H:2
*
*/

private World theWorld;
private Player thePlayer;
private Material material;
private Location location;

private int radius;
private int height;
private int depth;

@Override
public void parseArgs(ScriptEntry scriptEntry)throws InvalidArgumentsException {

thePlayer = scriptEntry.getPlayer();
material = null;
location = null;
radius = 0;
height = 0;
depth = 0;

for (String arg : scriptEntry.getArguments()) {
if (aH.matchesLocation(arg)){
location = aH.getLocationFrom(arg);
dB.echoDebug("...location set to: " + location);

}

else if (aH.matchesValueArg("MATERIAL, M", arg, ArgumentType.Custom)) {
if (aH.matchesValueArg("MATERIAL", arg, ArgumentType.Integer)) material = Material.getMaterial(aH.getIntegerFrom(arg));
else material = Material.getMaterial(aH.getStringFrom(arg));

if (material != null) dB.echoDebug("...material set to " + material);
else dB.echoDebug("...material not valid.");

}

else if (aH.matchesValueArg("RADIUS, R", arg, ArgumentType.Integer)) {
radius = aH.getIntegerFrom(arg);
dB.echoDebug("...radius set to " + radius);

}

else if (aH.matchesValueArg("HEIGHT, H", arg, ArgumentType.Integer)) {
height = aH.getIntegerFrom(arg);
dB.echoDebug("...height set to " + height);

}

else if (aH.matchesValueArg("DEPTH, D", arg, ArgumentType.Integer)) {
depth = aH.getIntegerFrom(arg);
dB.echoDebug("...depth set to " + depth);

} else throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg);
}
}

@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {

if (location == null || material == null){
dB.echoDebug("...can not exectue");
return;
}

theWorld = thePlayer.getWorld();
Block startBlock = location.getBlock();
Block currentBlock;

startBlock.setType(material);

if (radius != 0){
for (int x = 0; x < 2*radius+1; x++){
for (int z = 0; z < 2*radius+1; z++){
currentBlock = theWorld.getBlockAt(startBlock.getX() + x - radius, startBlock.getY(), startBlock.getZ() + z - radius);
if (currentBlock.getType() != material){
currentBlock.setType(material);
}
}
}
}

if (height != 0){
for (int x = 0; x < 2*radius+1; x++){
for (int z = 0; z < 2*radius+1; z++){
for (int y = 1; y < height + 1; y++){
currentBlock = theWorld.getBlockAt(startBlock.getX() + x - radius, startBlock.getY() + y, startBlock.getZ() + z - radius);
if (currentBlock.getType() != material){
currentBlock.setType(material);
}
}
}
}
}

if (depth != 0){
for (int x = 0; x < 2*radius+1; x++){
for (int z = 0; z < 2*radius+1; z++){
for (int y = 1; y < depth + 1; y++){
currentBlock = theWorld.getBlockAt(startBlock.getX() + x - radius, startBlock.getY() - y, startBlock.getZ() + z - radius);
if (currentBlock.getType() != material){
currentBlock.setType(material);
}
}
}
}
}
}
}
9 changes: 4 additions & 5 deletions src/main/java/net/aufdemrand/denizen/utilities/Utilities.java
Expand Up @@ -9,8 +9,6 @@
import net.aufdemrand.denizen.scripts.ScriptRegistry;
import net.aufdemrand.denizen.scripts.containers.core.TaskScriptContainer;
import net.aufdemrand.denizen.utilities.arguments.aH;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.citizensnpcs.trait.Poses;
import net.minecraft.server.v1_5_R1.EntityLiving;
import org.bukkit.Bukkit;
import org.bukkit.Location;
Expand Down Expand Up @@ -237,8 +235,10 @@ public static void rotate(Entity entity, float yaw, float pitch)
EntityLiving handle = ((CraftLivingEntity) entity).getHandle();
handle.yaw = (float) yaw;
handle.pitch = (float) pitch;
handle.az = handle.yaw; // The head's yaw

// !--- START NMS OBFUSCATED
handle.aA = handle.yaw; // The head's yaw
// !--- END NMS OBFUSCATED

if (!(entity instanceof Player))
{
// Obfuscated variable used in head turning. If not set to
Expand Down Expand Up @@ -559,7 +559,6 @@ public boolean accept(File file, String fileName) {
* Lists all files in the given directory.
*
* @param dir The directory to search in
* @param filter The filename filter to apply
* @param recursive If true subfolders will also get checked
* @return A {@link File} collection
*/
Expand Down

0 comments on commit bdfce5a

Please sign in to comment.