Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Added item tooltips
Browse files Browse the repository at this point in the history
Also:
- Improved networking stack a little by making client not send Flying
(10) and removing 11 spam by limiting percision of delta between
cordinates.
- Limited Rosepad-exclusive fixes&features to Rosepad servers only
- Added coordinates display
- Added Entity Damage (35) packet for future damage&death implementation
- Made debug menu a little bit more colorful
  • Loading branch information
Buj Itself committed Jul 12, 2022
1 parent 6497cf1 commit f160a8c
Show file tree
Hide file tree
Showing 51 changed files with 1,726 additions and 155 deletions.
9 changes: 8 additions & 1 deletion .idea/Rosepad.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ tasks.register("deletePatches", DeletePatches) {
}

tasks.register("injectClasses", InjectClasses) {
source = "${projectDir}/inject"
dest = "${projectDir}/src/main"
source = "${projectDir}/inject/java"
dest = "${projectDir}/src/main/java"
}

tasks.register("ejectClasses", CreateInjectClasses) {
source = "${projectDir}/src/main"
orig = "${projectDir}/src/orig"
dest = "${projectDir}/inject"
source = "${projectDir}/src/main/java"
orig = "${projectDir}/src/orig/java"
dest = "${projectDir}/inject/java"
}

processPatches {
Expand Down
66 changes: 58 additions & 8 deletions client/inject/java/net/minecraft/src/Packet130RosepadMeta.java
Original file line number Diff line number Diff line change
@@ -1,33 +1,83 @@
package net.minecraft.src;

import net.minecraft.client.Minecraft;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

// Reserved for future modifications
public class Packet130RosepadMeta extends Packet {
public List<ULPPExtension> extensions = new ArrayList<>();
public String clientName = "Rosepad";
public int[] version = Minecraft.getVersion();
public String tag = Minecraft.getVersionTag();
public long flags = 0;

@Override
public void readPacketData(DataInputStream dataInputStream) throws IOException {
// TODO Auto-generated method stub

clientName = dataInputStream.readUTF();
short verLen = dataInputStream.readShort();
version = new int[verLen];
for (short i = 0; i < verLen; i++)
version[i] = dataInputStream.readShort();
int count = dataInputStream.readInt();
extensions.clear();
for (int i = 0; i < count; i++) {
ULPPExtension ext = new ULPPExtension(
dataInputStream.readUTF(),
dataInputStream.readInt()
);
extensions.add(ext);
}
flags = dataInputStream.readLong();
}

@Override
public void writePacket(DataOutputStream dataOutputStream) throws IOException {
// TODO Auto-generated method stub
dataOutputStream.writeUTF(clientName);
dataOutputStream.writeShort(version.length);
for (int i : version) {
dataOutputStream.writeShort(i);
}
dataOutputStream.writeInt(extensions.size());
for (ULPPExtension ext : extensions) {
dataOutputStream.writeUTF(ext.getName());
dataOutputStream.writeInt(ext.getVersion());
}
dataOutputStream.writeLong(flags);
}

public Packet130RosepadMeta Default() {
this.extensions.clear();
this.extensions.add(new ULPPExtension("ULPP", 1));
this.extensions.add(new ULPPExtension("ROSE", 1));

this.version = Minecraft.getVersion();
this.tag = Minecraft.getVersionString();

this.clientName = "Rosepad";
this.flags = 0;

return this;
}

@Override
public void processPacket(NetHandler netHandler) {
// TODO Auto-generated method stub

netHandler.handleRosepadMeta(this);
}

@Override
public int getPacketSize() {
// TODO Auto-generated method stub
return 0;
int len = 18 + clientName.length() + tag.length() + version.length * 2;
for (ULPPExtension ext : extensions) {
len += 6 + ext.getName().length();
}
return len;
}

public RosepadMeta getMeta() {
return new RosepadMeta(clientName, version, tag, flags);
}
}
48 changes: 48 additions & 0 deletions client/inject/java/net/minecraft/src/Packet35EntityDamage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package net.minecraft.src;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

public class Packet35EntityDamage extends Packet {
public int entityId;
public int damage;
public boolean dead;

public Packet35EntityDamage() {
this.entityId = 0;
this.damage = 0;
this.dead = false;
}

@Override
public void readPacketData(DataInputStream dataInputStream) throws IOException {
this.entityId = dataInputStream.readInt();
this.damage = dataInputStream.readInt();
this.dead = dataInputStream.readBoolean();
}

@Override
public void writePacket(DataOutputStream dataOutputStream) throws IOException {
dataOutputStream.writeInt(entityId);
dataOutputStream.writeInt(damage);
dataOutputStream.writeBoolean(dead);
}

@Override
public void processPacket(NetHandler netHandler) {

}

@Override
public int getPacketSize() {
return 9;
}

public Packet35EntityDamage hit(Entity entity, int damage) {
this.entityId = entity.entityID;
this.damage = damage;
this.dead = entity.isDead;
return this;
}
}
46 changes: 46 additions & 0 deletions client/inject/java/net/minecraft/src/RosepadMeta.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package net.minecraft.src;

public class RosepadMeta {
public static final long USES_USER_SCRIPTS = 1;

public RosepadMeta(String brandName, int[] version, String versionTag, long flags) {
this.brandName = brandName;
this.version = version;
this.versionTag = versionTag;
this.flags = flags;
}

private final String brandName;
private final int[] version;
private final String versionTag;
private final long flags;

public String getBrandName() {
return brandName;
}

public int[] getVersion() {
return version.clone();
}

public String getVersionTag() {
return versionTag;
}

public long getFlags() {
return flags;
}

public String getVersionString() {
StringBuilder str = new StringBuilder();
for (int v : getVersion()) {
if (str.length() > 0) str.append(".");
str.append(v);
}
String tag;
if ((tag = getVersionTag()).length() > 0) {
str.append("-").append(tag);
}
return str.toString();
}
}
19 changes: 14 additions & 5 deletions client/patches/net/minecraft/client/Minecraft.java.diff
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
@@ -136,4 +136,24 @@
private int joinPlayerCounter;

+ public int[] getVersion() {
+ public static int[] getVersion() {
+ return new int[] { 1, 1, 0, 5 };
+ }
+
+ public String getVersionTag() {
+ public static String getVersionTag() {
+ return "dev";
+ }
+
+ public String getVersionString() {
+ public static String getVersionString() {
+ int[] version = getVersion();
+ StringBuilder str = new StringBuilder();
+ for (int i = 0; i < version.length; i++) {
+ if (i != 0) str.append(".");
+ str.append(version[i]);
+ }
+ String tag = getVersionTag();
+ if (tag != null) str.append("-").append(tag);
+ if (tag.length() > 0) str.append("-").append(tag);
+ return str.toString();
+ }
+
Expand Down Expand Up @@ -83,7 +83,16 @@
+}
if (this.isMultiplayerWorld() && InputHandler.GetKBEventKey() == this.gameSettings.keyBindChat.keyCode) {
this.displayGuiScreen(new GuiChat());
@@ -1093,5 +1113,5 @@
@@ -1003,7 +1023,5 @@
else if (this.thePlayer != null) {
this.thePlayer.preparePlayerToSpawn();
- if (world != null) {
- world.spawnEntityInWorld(this.thePlayer);
- }
+ world.spawnEntityInWorld(this.thePlayer);
}
if (!world.multiplayerWorld) {
@@ -1093,5 +1111,5 @@

public String debugLoadedEntities() {
- return new StringBuilder("P: ").append(this.effectRenderer.getStatistics()).append(". T: ").append(this.theWorld.getDebugLoadedEntities()).toString();
Expand Down
7 changes: 7 additions & 0 deletions client/patches/net/minecraft/src/Block.java.diff
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,10 @@
+ throw new IllegalArgumentException("Slot " + id + " is already occupied by \"" + Block.BLOCKS_LIST[id].getName() + "\" when adding \"" + this.getName() + "\"");
}
this.material = material;
@@ -452,5 +473,5 @@
}
else {
- if (!entityPlayer.canHarvestBlock(this)) {
+ if (!entityPlayer.canHarvestBlock(this, entityPlayer.worldObj)) {
return 1.0f / this.hardness / 100.0f;
}
8 changes: 8 additions & 0 deletions client/patches/net/minecraft/src/BlockHidable.java.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--- BlockHidable.java
+++ BlockHidable.java
@@ -22,4 +22,5 @@
if (entityPlayer.inventory.getCurrentItem() == null) {
this.render = !this.render;
+ world.setBlockWithNotify(x, y, z, 0);
world.setBlockWithNotify(x, y, z, this.id);
return true;
9 changes: 9 additions & 0 deletions client/patches/net/minecraft/src/BlockJukebox.java.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--- BlockJukebox.java
+++ BlockJukebox.java
@@ -28,5 +28,5 @@
final EntityItem entity = new EntityItem(world, x + (world.rand.nextFloat() * 0.7f + 0.15000000596046448), y + (world.rand.nextFloat() * 0.7f + 0.06000000238418579 + 0.6), z + (world.rand.nextFloat() * 0.7f + 0.15000000596046448), new ItemStack(itemID));
entity.delayBeforeCanPickup = 10;
- world.spawnEntityInWorld(entity);
+ if (!world.multiplayerWorld) world.spawnEntityInWorld(entity);
}

2 changes: 1 addition & 1 deletion client/patches/net/minecraft/src/BlockSafe.java.diff
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
+ return true;
}
- return true;
+ return false;
+ return !world.rosepadContentEnabled();
}
}
14 changes: 9 additions & 5 deletions client/patches/net/minecraft/src/BlockSponge.java.diff
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
--- BlockSponge.java
+++ BlockSponge.java
@@ -12,6 +12,8 @@
@@ -9,9 +9,12 @@
@Override
public void onBlockAdded(final World world, final int x, final int y, final int z) {
+ if (!world.rosepadContentEnabled()) return;
for (int n = 2, i = x - n; i <= x + n; ++i) {
for (int j = y - n; j <= y + n; ++j) {
for (int k = z - n; k <= z + n; ++k) {
- world.getBlockMaterial(i, j, k);
- final Material water = Material.WATER;
+if (world.getBlockMaterial(i, j, k) == Material.WATER) {
+world.setBlock(i, j, k, 0);
+world.notifyBlocksOfNeighborChange(i, j, k, 0);
+}
+ if (world.getBlockMaterial(i, j, k) == Material.WATER) {
+ world.setBlock(i, j, k, 0);
+ world.notifyBlocksOfNeighborChange(i, j, k, 0);
+ }
}
}
Loading

0 comments on commit f160a8c

Please sign in to comment.