Skip to content

Commit

Permalink
Initial obfuscated mod: [1.9.2]v1.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Cubitect committed Apr 16, 2016
1 parent 1b7e8b9 commit 7fa69ff
Show file tree
Hide file tree
Showing 31 changed files with 9,261 additions and 12,749 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ Cubitick 1.4.X+ comes bundled with a packet analysis tool which lets you view th
## Source
The source code [here](https://github.com/Cubitect/Cubitick/tree/master) contains the modified classes in the decompiled minecraft code from [Mod Coder Pack](http://www.modcoderpack.com). The unmodified classes are not included.

Some versions of this mod are written by modifying minecraft's obfuscated code (for minecraft versions were MCP is unavailable). For those version I used the [CFR java decompiler](http://www.benf.org/other/cfr/) to get the source code. However, it turns out that it is not possible to modify the MinecraftServer class this way, as only classes in the default directory are accessible this way. To work around this issue I used [Krakatau Bytecode Tools](https://github.com/Storyyeller/Krakatau) to move the MinecraftServer class into the default directory.

30 changes: 30 additions & 0 deletions fixvers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# To use, place this file inside the minecraft version directory, and run:
# ./fixvers.sh [VERSION_DIR]
# Where the actual minecraft jar file should be located at "./VERSION_DIR/VERSION_DIR.jar"

# This script disassembles and fixes the internal name of net/minecraft/server/MinecraftServer
# such that it becomes accessable to the modded classes. The 'fixed' classes are placed in '$out'.
# The disassembler used here is the "Krakatau Bytecode Tools" by Robert Grosse.

tmp="./tmp_deasm"
out="./$1/fixclasses"
krakatauDir="./Krakatau-master"

unzip -q ./$1/$1.jar -d $out
python $krakatauDir/disassemble.py -r $out -out $tmp 1>/dev/null
rm -r $out/*
rm $(grep -rL 'MinecraftServer' $tmp/* 2>/dev/null) 2>/dev/null
mv $tmp/net/minecraft/server/MinecraftServer* $tmp
find $tmp -type f -print0 | xargs -0 sed -i 's#net/minecraft/server/MinecraftServer#MinecraftServer#g'
python $krakatauDir/assemble.py -q -r $tmp -out $out
rm -r $tmp
if [ ! -e ./$1/$1_ori.jar ]
then
cp ./$1/$1.jar ./$1/$1_ori.jar
fi
wdir=$(pwd)
cd $out
jar uf $wdir/$1/$1.jar ./*.class
cd $wdir
59 changes: 59 additions & 0 deletions src/CommandRerender.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import java.util.List;

public class CommandRerender extends i
{
@Override
public String c()
{
return "rerender";
}

@Override
public int a()
{
return 0;
}

@Override
public String b(m sender)
{
return "/rerender [fromX fromY fromZ toX toY toZ]\n§7Marks a region to be rendered again (without reloading)\n§7Specifying no arguments will also reload and do the same as F3+A";
}

@Override
public void a(MinecraftServer server, m sender, String[] args) throws bz
{
if(args.length == 0) {
bcc.z().scheduledReload = true;
}
else if(args.length <= 5) {
a(sender, this, "§cUsage:\n§c"+b(sender));
return;
} else {
cj pos1 = a(sender, args, 0, false);
cj pos2 = a(sender, args, 3, false);

cj from = new cj(Math.min(pos1.p(), pos2.p()), Math.min(pos1.q(), pos2.q()), Math.min(pos1.r(), pos2.r()));
cj to = new cj(Math.max(pos1.p(), pos2.p()), Math.max(pos1.q(), pos2.q()), Math.max(pos1.r(), pos2.r()));
sender.e().b(from, to);
}
}

@Override
public List<String> a(MinecraftServer server, m sender, String[] args, cj pos)
{
return null;
}

@Override
public boolean b(String[] args, int index)
{
return index == 0;
}

@Override
public int compareTo(k o) {
// TODO Auto-generated method stub
return 0;
}
}
41 changes: 41 additions & 0 deletions src/CommandTickSync.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
public class CommandTickSync extends i
{
public String c()
{
return "ticksync";
}

public int a()
{
return 2;
}

public String b(m sender)
{
return "/ticksync [true/false]";
}

public void a(MinecraftServer server, m sender, String[] args) throws bz
{
if(args.length < 1) {
a(sender, this, (Cubitick.synctick) ? "Tickrate is currently synchronised" : "Tickrate is currently desynchronised");
return;
} else {
if(args[0].equals("true") || args[0].equals("on")) {
Cubitick.synctick = true;
a(sender, this, "Tickrate is now synchronised");
} else if(args[0].equals("false") || args[0].equals("off")) {
Cubitick.synctick = false;
a(sender, this, "Tickrate is now desynchronised");
} else {
a(sender, this, "Tickrate synchronisation can only be true/on or false/off");
}
}
}

@Override
public int compareTo(k o) {
// TODO Auto-generated method stub
return 0;
}
}
41 changes: 41 additions & 0 deletions src/CommandTickrate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
public class CommandTickrate extends i
{
public String c()
{
return "tickrate";
}

public int a()
{
return 2;
}

public String b(m sender)
{
return "/tickrate [rate]";
}

public void a(MinecraftServer server, m sender, String[] args) throws bz
{
if(args.length < 1) {
a(sender, this, "Tickrate is " + Cubitick.tickrateWorld + " ticks per second");
return;
} else {
float tickspeed = (float)a(args[0], 0F);
if(tickspeed >= 0) {
Cubitick.setTickWorld(tickspeed);
a(sender, this, "Tickrate set to " + tickspeed);
} else {
a(sender, this, "Tickrate should be a non-negative floating point number");
return;
}
}
}

@Override
public int compareTo(k o) {
// TODO Auto-generated method stub
return 0;
}
}

38 changes: 17 additions & 21 deletions src/minecraft/cubimod/Cubitick.java → src/Cubitick.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
package cubimod;

import java.io.IOException;
import java.net.URL;
import java.util.Arrays;
import java.util.Scanner;

import cubimod.settings.ServerPacketData;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.Timer;

public class Cubitick
{
public static Cubitick instance = new Cubitick();
public static Cubitick instance;
public static boolean initialised = false;

private String author = "Cubitect";
private String name = "Cubitick";
private String versionName = "[1.8]v1.5.1";
private String versionName = "[1.9.2]v1.5.1";
private String versionType = "main";
private String mcVersion = "1.8";
private String mcVersion = "1.9";
private String mcType = "release";

public static final float tickrate = 20F;
Expand All @@ -29,6 +22,9 @@ public class Cubitick

public Cubitick()
{
System.out.println("[" + name + "] Initializing...");

instance = this;
ServerPacketData.init();
initialised = false;
}
Expand Down Expand Up @@ -84,18 +80,18 @@ public static void setTickWorld(float rate)

private static void setTimerWorld(float rate)
{
Minecraft mc = Minecraft.getMinecraft();
float elapsedPartialTicks = mc.timerWorld.elapsedPartialTicks;
int elapsedTicks = mc.timerWorld.elapsedTicks;
float renderPartialTicks = mc.timerWorld.renderPartialTicks;
bcc mc = bcc.z();
float elapsedPartialTicks = mc.timerWorld.e;
int elapsedTicks = mc.timerWorld.b;
float renderPartialTicks = mc.timerWorld.c;

mc.timerWorld = new Timer(rate);
mc.timerWorld = new bci(rate);

mc.timerWorld.elapsedPartialTicks = elapsedPartialTicks;
mc.timerWorld.elapsedTicks = elapsedTicks;
mc.timerWorld.renderPartialTicks = renderPartialTicks;
mc.timerWorld.e = elapsedPartialTicks;
mc.timerWorld.b = elapsedTicks;
mc.timerWorld.c = renderPartialTicks;

mc.timer = new Timer(tickrate);
mc.timer = new bci(tickrate);
}

public static float getTickms()
Expand All @@ -106,7 +102,7 @@ public static float getTickms()

public static void playerChat(String str)
{
if(Minecraft.getMinecraft().thePlayer == null) return;
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(str));
if(bcc.z().h == null) return;
bcc.z().h.b(new fa(str));
}
}
139 changes: 139 additions & 0 deletions src/GuiPacketOptionsList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
public class GuiPacketOptionsList extends bdi
{
private final GuiServerPackets guiServerPackets;
private final bcc mc;
private final bdi.a listEntries[];
private int maxListLabelWidth = 0;
public static int lastBtnIndex;

public boolean isActive[];

public GuiPacketOptionsList(GuiServerPackets guiServerPackets, bcc mcIn)
{
super(mcIn, guiServerPackets.l, guiServerPackets.m, 63, guiServerPackets.m - 32, 20);
this.guiServerPackets = guiServerPackets;
this.mc = mcIn;
this.listEntries = new bdi.a[ServerPacketData.isActive.length];

isActive = new boolean[this.listEntries.length];
isActive = ServerPacketData.isActive.clone();

for(int packetID = 0; packetID < this.listEntries.length; packetID++)
{
this.listEntries[packetID] = new PacketOptionEntry(packetID);
}
}

// getSize()
@Override
protected int b()
{
return this.listEntries.length;
}

// getListEntry()
@Override
public bdi.a b(int idx)
{
if(idx < 0 || idx >= this.b()) {
System.err.println("[Cubitick]: index out of bounds in GuiPacketOptionsList.getListEntry()");
return null;
}
return this.listEntries[idx];
}

// getScrollBarX()
@Override
protected int d()
{
return super.d() + 15;
}

// getListWidth()
@Override
public int c()
{
return super.c() + 32;
}

public void setAll(boolean state)
{
for(int i = 0; i < listEntries.length; i++)
{
isActive[i] = state;
}
}



public class PacketOptionEntry implements bdi.a
{
public final String baseLabel;
public final bcw btn;
public final int packetID;

private PacketOptionEntry(int packetID)
{
this.packetID = packetID;
this.baseLabel = ServerPacketData.packetName[packetID];
this.btn = new bcw(0, 0, 0, 250, 18, this.baseLabel);
}

// drawEntry(..)
public void a(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected)
{
if(this.baseLabel == null)
{
this.btn.j = "";
this.btn.l = false;
}
else
{
this.btn.j = this.baseLabel + ": " + (isActive[this.packetID] ? "§aactive":"§cinactive");
this.btn.l = guiServerPackets.enabled;
}

this.btn.h = x;
this.btn.i = y;

this.btn.a(GuiPacketOptionsList.this.mc, mouseX, mouseY);
}

// mousePressed(..)
public boolean a(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY)
{
if(this.btn.l && this.btn.c(GuiPacketOptionsList.this.mc, x, y))
{
if(GuiPacketOptionsList.lastBtnIndex != slotIndex)
{
GuiPacketOptionsList.lastBtnIndex = slotIndex;
isActive[slotIndex] = !isActive[slotIndex];
}
else {
GuiPacketOptionsList.lastBtnIndex = -1;
return false;
}
//GuiPacketOptionsList.this.guiServerPackets.buttonId = this.packetID;

return true;
}
else
{
return false;
}
}

// mouseReleased(..)
public void b(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY)
{
this.btn.a(x, y);
System.out.println("Release- Slot: " + slotIndex + ", Event: " + mouseEvent);
}

// setSelected
@Override
public void a(int arg0, int arg1, int arg2) {
// TODO Auto-generated method stub
}
}
}
Loading

0 comments on commit 7fa69ff

Please sign in to comment.