Made constant BlockPos calculateLogBaseTwo calculation explicit, enabled player events by default.

This commit is contained in:
luisc committed 2021-10-12 04:20:33 -05:00
1 parent 699182f4c0
commit 047552d9e5
7 files changed
+12 -30

No files matched your search

@@ -4,7 +4,6 @@ import com.google.common.collect.AbstractIterator;
import java.util.Iterator;
import net.minecraft.entity.Entity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraft.util.Vec3i;
@@ -13,7 +12,7 @@ import net.minecraft.util.Vec3i;
public class BlockPos extends Vec3i{
/** The BlockPos with all coordinates 0 */
public static final BlockPos ORIGIN = new BlockPos(0, 0, 0);
private static final int NUM_X_BITS = 1 + MathHelper.calculateLogBaseTwo(MathHelper.roundUpToPowerOfTwo(30000000));
private static final int NUM_X_BITS = 1 + 25;//MathHelper.calculateLogBaseTwo(MathHelper.roundUpToPowerOfTwo(30000000));
private static final int NUM_Z_BITS = NUM_X_BITS;
private static final int NUM_Y_BITS = 64 - NUM_X_BITS - NUM_Z_BITS;
private static final int Y_SHIFT = 0 + NUM_Z_BITS;
+2 -23
View File
@@ -111,29 +111,9 @@ public class DataScript {
script.engine.put(obs[i].toString(), ob);
}
//return callScript(script);
ScriptEngine engine = script.engine;
engine.put("npc", dummyNpc);
engine.put("world", dummyWorld);
ScriptEvent result = (ScriptEvent) engine.get("event");
if(result == null)
engine.put("event", result = new ScriptEvent());
engine.put("EntityType", entities);
engine.put("RoleType", roles);
engine.put("JobType", jobs);
script.run(engine);
if(clientNeedsUpdate){
npc.updateClient = true;
clientNeedsUpdate = false;
}
if(aiNeedsUpdate){
npc.updateAI = true;
aiNeedsUpdate = false;
}
return result.isCancelled();
return callScript(script);
}
/*
private boolean callScript(ScriptContainer script){
ScriptEngine engine = script.engine;
engine.put("npc", dummyNpc);
@@ -156,7 +136,6 @@ public class DataScript {
}
return result.isCancelled();
}
*/
public boolean isEnabled(){
return enabled && ScriptController.HasStart && !npc.worldObj.isRemote && !scripts.isEmpty();
@@ -107,7 +107,7 @@ public class PacketHandlerServer{
else if(item.getItem() == CustomItems.teleporter)
featherPackets(type, buffer, player);
else if(type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave)
playerScriptPackets(type, buffer, player, npc);
playerScriptPackets(type, buffer, player);
else if(item.getItem() == CustomItems.scripter)
scriptPackets(type, buffer, player, npc);
else if(item.getItem() == Item.getItemFromBlock(CustomItems.waypoint) || item.getItem() == Item.getItemFromBlock(CustomItems.border) || item.getItem() == Item.getItemFromBlock(CustomItems.redstoneBlock))
@@ -130,7 +130,7 @@ public class PacketHandlerServer{
}
}
private void playerScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player, EntityNPCInterface npc) throws Exception {
private void playerScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception {
NBTTagCompound compound;
if(type == EnumPacketServer.ScriptPlayerGet) {
compound = ScriptController.Instance.playerScripts.writeToNBT(new NBTTagCompound());
@@ -70,6 +70,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
}
List<String> list = new ArrayList<String>();
list.add("playerscript.disabled");
list.add("playerscript.init");
list.add("playerscript.tick");
list.add("playerscript.interact");
@@ -16,7 +16,8 @@ public class GuiScriptPlayers extends GuiScriptInterface {
public GuiScriptPlayers() {
this.handler = this.script;
Client.sendData(EnumPacketServer.ScriptPlayerGet, new Object[0]);
//Client.sendData(EnumPacketServer.ScriptPlayerGet, new Object[0]);
Client.sendData(EnumPacketServer.ScriptPlayerGet);
}
public void setGuiData(NBTTagCompound compound) {
@@ -26,6 +27,7 @@ public class GuiScriptPlayers extends GuiScriptInterface {
public void save() {
super.save();
Client.sendData(EnumPacketServer.ScriptPlayerSave, new Object[]{this.script.writeToNBT(new NBTTagCompound())});
//Client.sendData(EnumPacketServer.ScriptPlayerSave, new Object[]{this.script.writeToNBT(new NBTTagCompound())});
Client.sendData(EnumPacketServer.ScriptPlayerSave, script.writeToNBT(new NBTTagCompound()));
}
}
@@ -41,7 +41,7 @@ public class PlayerDataScript implements IScriptHandler {
private long lastPlayerUpdate = 0L;
public long lastInited = -1L;
public boolean hadInteract = true;
private boolean enabled = false;
public boolean enabled = true;
private static Map<Long, String> console = new TreeMap();
private static List<Integer> errored = new ArrayList();