Ported all block related patches

master
Wynd 2025-04-07 00:12:52 +03:00
parent a4019d4721
commit 276bdde2b1
17 changed files with 349 additions and 14 deletions

View File

@ -56,5 +56,5 @@ build:
just create-patches
./recompile.sh
./reobfuscate.sh
for file in $(fd . ./lib ".jar"); do unzip -qo "$file" -d "./reobf/minecraft/"; done
for file in $(fd . ./lib -e "jar"); do unzip -qo "$file" -d "./reobf/minecraft/"; done
(cd ./reobf/minecraft && zip -qr "../../builds/${modName}-${modVersion}-modloader.zip" ./*)

View File

@ -1,5 +1,5 @@
--- src/BlockBed.java.bak 2025-04-04 22:37:36.783594000 +0300
+++ src/BlockBed.java 2025-04-05 20:34:45.887405008 +0300
+++ src/BlockBed.java 2025-04-06 19:19:53.678033888 +0300
@@ -5,6 +5,7 @@
package net.minecraft.src;

View File

@ -0,0 +1,28 @@
--- src/BlockBookshelf.java.bak 2025-04-06 19:12:33.595626811 +0300
+++ src/BlockBookshelf.java 2025-04-06 19:19:53.692033710 +0300
@@ -5,6 +5,7 @@
package net.minecraft.src;
import java.util.Random;
+import net.minecraft.src.finalbeta.ModConfig;
// Referenced classes of package net.minecraft.src:
// Block, Material
@@ -30,6 +31,16 @@
public int quantityDropped(Random random)
{
- return 0;
+ if (ModConfig.FIX_BOOKSHELVES_DROP.get()) {
+ return 3;
+ }
+ return 0;
}
+
+ public int idDropped(int i, Random random) {
+ if (ModConfig.FIX_BOOKSHELVES_DROP.get()) {
+ return Item.book.shiftedIndex;
+ }
+ return super.idDropped(i, random);
+ }
}

View File

@ -0,0 +1,154 @@
--- src/BlockFence.java.bak 2025-04-06 23:48:31.263368036 +0300
+++ src/BlockFence.java 2025-04-07 00:04:26.917150258 +0300
@@ -4,6 +4,10 @@
package net.minecraft.src;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Set;
+import net.minecraft.src.finalbeta.ModConfig;
// Referenced classes of package net.minecraft.src:
// Block, Material, World, AxisAlignedBB
@@ -18,24 +22,128 @@
public boolean canPlaceBlockAt(World world, int i, int j, int k)
{
- if(world.getBlockId(i, j - 1, k) == blockID)
- {
- return true;
- }
- if(!world.getBlockMaterial(i, j - 1, k).isSolid())
- {
- return false;
- } else
- {
- return super.canPlaceBlockAt(world, i, j, k);
- }
+ return true;
+// if(world.getBlockId(i, j - 1, k) == blockID)
+// {
+// return true;
+// }
+// if(!world.getBlockMaterial(i, j - 1, k).isSolid())
+// {
+// return false;
+// } else
+// {
+// return super.canPlaceBlockAt(world, i, j, k);
+// }
}
+ public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int i, int j, int k) {
+ if (ModConfig.FENCE_SLIM_HITBOX.get()) {
+ return this.createVanillaFenceBox(world, i, j, k, true);
+ }
+ return super.getSelectedBoundingBoxFromPool(world, i, j, k);
+ }
+
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
{
- return AxisAlignedBB.getBoundingBoxFromPool(i, j, k, i + 1, (float)j + 1.5F, k + 1);
+ if (ModConfig.FENCE_SLIM_HITBOX.get()) {
+ return this.createVanillaFenceBox(world, i, j, k, false);
+ }
+ return AxisAlignedBB.getBoundingBoxFromPool(i, j, k, i + 1, (float)j + 1.5F, k + 1);
}
+ private AxisAlignedBB createVanillaFenceBox(World level, int x, int y, int z, boolean isOutline) {
+ Block xpTile = Block.blocksList[level.getBlockId(x + 1, y, z)];
+ Block xnTile = Block.blocksList[level.getBlockId(x - 1, y, z)];
+ Block zpTile = Block.blocksList[level.getBlockId(x, y, z + 1)];
+ Block znTile = Block.blocksList[level.getBlockId(x, y, z - 1)];
+
+ boolean xpCheck = xpTile != null && (xpTile.renderAsNormalBlock() || xpTile.blockID == Block.fence.blockID);
+ boolean xnCheck = xnTile != null && (xnTile.renderAsNormalBlock() || xnTile.blockID == Block.fence.blockID);
+ boolean zpCheck = zpTile != null && (zpTile.renderAsNormalBlock() || zpTile.blockID == Block.fence.blockID);
+ boolean znCheck = znTile != null && (znTile.renderAsNormalBlock() || znTile.blockID == Block.fence.blockID);
+
+ boolean eastCheck = level.getBlockMaterial(x + 1, y, z).isSolid() && xpCheck;
+ boolean westCheck = level.getBlockMaterial(x - 1, y, z).isSolid() && xnCheck;
+ boolean southCheck = level.getBlockMaterial(x, y, z + 1).isSolid() && zpCheck;
+ boolean northCheck = level.getBlockMaterial(x, y, z - 1).isSolid() && znCheck;
+
+ AxisAlignedBB box = AxisAlignedBB.getBoundingBoxFromPool(westCheck ? 0 : 0.375f, 0.0f, northCheck ? 0.0f : 0.375f, eastCheck ? 1.0f : 0.625f, 1.0F, southCheck ? 1.0f : 0.625f);
+
+ this.minX = westCheck ? 0 : 0.375f;
+ this.minY = 0.0;
+ this.minZ = northCheck ? 0.0f : 0.375f;
+ this.maxX = eastCheck ? 1.0f : 0.625f;
+ this.maxY = 1.0f;
+ this.maxZ = southCheck ? 1.0f : 0.625f;
+
+ box.minX += x;
+ box.minY += y;
+ box.minZ += z;
+ box.maxX += x;
+ box.maxY += y;
+ box.maxZ += z;
+
+ if (!isOutline) {
+ box.maxY += 0.5f;
+ }
+
+ return box;
+ }
+
+ public void getCollidingBoundingBoxes(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, ArrayList arraylist) {
+ if(ModConfig.FENCE_SLIM_HITBOX.get()) {
+ Set<AxisAlignedBB> collisions = this.getNewFenceBox(world, i, j, k);
+ for (AxisAlignedBB other : collisions) {
+ if (other != null && axisalignedbb.intersectsWith(other)) {
+ arraylist.add(other);
+ }
+ }
+ return;
+ }
+ super.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
+ }
+
+ private Set<AxisAlignedBB> getNewFenceBox(World world, int x, int y, int z) {
+ Set<AxisAlignedBB> collisions = new HashSet<AxisAlignedBB>();
+
+ Block xpTile = Block.blocksList[world.getBlockId(x + 1, y, z)];
+ Block xnTile = Block.blocksList[world.getBlockId(x - 1, y, z)];
+ Block zpTile = Block.blocksList[world.getBlockId(x, y, z + 1)];
+ Block znTile = Block.blocksList[world.getBlockId(x, y, z - 1)];
+
+ boolean xpCheck = xpTile != null && (xpTile.renderAsNormalBlock() || xpTile.blockID == Block.fence.blockID);
+ boolean xnCheck = xnTile != null && (xnTile.renderAsNormalBlock() || xnTile.blockID == Block.fence.blockID);
+ boolean zpCheck = zpTile != null && (zpTile.renderAsNormalBlock() || zpTile.blockID == Block.fence.blockID);
+ boolean znCheck = znTile != null && (znTile.renderAsNormalBlock() || znTile.blockID == Block.fence.blockID);
+
+ boolean eastCheck = world.getBlockMaterial(x + 1, y, z).isSolid() && xpCheck;
+ boolean westCheck = world.getBlockMaterial(x - 1, y, z).isSolid() && xnCheck;
+ boolean southCheck = world.getBlockMaterial(x, y, z + 1).isSolid() && zpCheck;
+ boolean northCheck = world.getBlockMaterial(x, y, z - 1).isSolid() && znCheck;
+
+ if (eastCheck) {
+ collisions.add(AxisAlignedBB.getBoundingBoxFromPool(x + 0.375f, y + 0.0f, z + 0.375f, x + 1.0f, y + 1.5F, z + 0.625f));
+ }
+
+ if (westCheck) {
+ collisions.add(AxisAlignedBB.getBoundingBoxFromPool(x + 0.0f, y + 0.0f, z + 0.375f, x + 0.625f, y + 1.5F, z + 0.625f));
+ }
+
+ if (northCheck) {
+ collisions.add(AxisAlignedBB.getBoundingBoxFromPool(x + 0.375f, y + 0.0f, z + 0.0f, x + 0.625f, y + 1.5F, z + 0.625f));
+ }
+
+ if (southCheck) {
+ collisions.add(AxisAlignedBB.getBoundingBoxFromPool(x + 0.375f, y + 0.0f, z + 0.375f, x + 0.625f, y + 1.5F, z + 1.0f));
+ }
+
+ if (collisions.isEmpty()) {
+ collisions.add(AxisAlignedBB.getBoundingBoxFromPool(x + 0.375f, y + 0.0f, z + 0.375f, x + 0.625f, y + 1.5F, z + 0.625f));
+ }
+
+ return collisions;
+ }
+
public boolean isOpaqueCube()
{
return false;

View File

@ -0,0 +1,11 @@
--- src/BlockFlowing.java.bak 2025-04-06 23:16:31.319957113 +0300
+++ src/BlockFlowing.java 2025-04-06 23:17:55.044975801 +0300
@@ -68,7 +68,7 @@
{
j1 = 0;
} else
- if(world.getBlockMaterial(i, j - 1, k) == blockMaterial && world.getBlockMetadata(i, j, k) == 0)
+ if(world.getBlockMaterial(i, j - 1, k) == blockMaterial && world.getBlockMetadata(i, j - 1, k) == 0)
{
j1 = 0;
}

View File

@ -0,0 +1,20 @@
--- src/BlockGrass.java.bak 2025-04-06 19:15:07.180674925 +0300
+++ src/BlockGrass.java 2025-04-06 19:15:45.798184141 +0300
@@ -20,6 +20,17 @@
setTickOnLoad(true);
}
+ public int getBlockTextureFromSide(int i)
+ {
+ if (i == 1) {
+ return 0;
+ } else if (i == 0) {
+ return 2;
+ } else {
+ return this.blockIndexInTexture;
+ }
+ }
+
public int getBlockTexture(IBlockAccess iblockaccess, int i, int j, int k, int l)
{
if(l == 1)

View File

@ -0,0 +1,24 @@
--- src/BlockLeaves.java.bak 2025-04-06 19:22:52.639759517 +0300
+++ src/BlockLeaves.java 2025-04-06 19:25:05.950065302 +0300
@@ -5,6 +5,7 @@
package net.minecraft.src;
import java.util.Random;
+import net.minecraft.src.finalbeta.ModConfig;
// Referenced classes of package net.minecraft.src:
// BlockLeavesBase, Material, ColorizerFoliage, IBlockAccess,
@@ -208,6 +209,13 @@
dropBlockAsItem_do(world, i, j, k, new ItemStack(Block.leaves.blockID, 1, l & 3));
} else
{
+ boolean dropItem = world.rand.nextDouble() <= ModConfig.APPLE_DROP_RATE.get();
+ if (dropItem) {
+ EntityItem appleItem = new EntityItem(world, i + 0.5, j - 0.5, k + 0.5, new ItemStack(Item.appleRed));
+ appleItem.delayBeforeCanPickup = 20;
+ world.entityJoinedWorld(appleItem);
+ }
+
super.harvestBlock(world, entityplayer, i, j, k, l);
}
}

View File

@ -0,0 +1,26 @@
--- src/BlockPressurePlate.java.bak 2025-04-06 19:28:45.824412655 +0300
+++ src/BlockPressurePlate.java 2025-04-06 19:30:10.625388981 +0300
@@ -46,6 +46,11 @@
public boolean canPlaceBlockAt(World world, int i, int j, int k)
{
+ int blockId = world.getBlockId(i, j - 1, k);
+ if (blockId == Block.fence.blockID) {
+ return true;
+ }
+
return world.isBlockNormalCube(i, j - 1, k);
}
@@ -55,6 +60,11 @@
public void onNeighborBlockChange(World world, int i, int j, int k, int l)
{
+ int blockId = world.getBlockId(i, j - 1, k);
+ if (blockId == Block.fence.blockID) {
+ return;
+ }
+
boolean flag = false;
if(!world.isBlockNormalCube(i, j - 1, k))
{

View File

@ -1,5 +1,5 @@
--- src/BlockReed.java.bak 2025-04-04 22:55:28.995768000 +0300
+++ src/BlockReed.java 2025-04-05 20:34:20.143731179 +0300
+++ src/BlockReed.java 2025-04-06 19:19:53.695033672 +0300
@@ -5,6 +5,7 @@
package net.minecraft.src;

View File

@ -0,0 +1,21 @@
--- src/BlockStairs.java.bak 2025-04-06 19:33:07.094258706 +0300
+++ src/BlockStairs.java 2025-04-06 23:00:51.722970976 +0300
@@ -6,6 +6,7 @@
import java.util.ArrayList;
import java.util.Random;
+import net.minecraft.src.finalbeta.ModConfig;
// Referenced classes of package net.minecraft.src:
// Block, World, EntityLiving, MathHelper,
@@ -187,6 +188,10 @@
public void dropBlockAsItemWithChance(World world, int i, int j, int k, int l, float f)
{
+ if(ModConfig.FIX_STAIRS_DROPS.get()) {
+ this.dropBlockAsItem_do(world, i, j, k, new ItemStack(this));
+ return;
+ }
modelBlock.dropBlockAsItemWithChance(world, i, j, k, l, f);
}

View File

@ -0,0 +1,16 @@
--- src/BlockStationary.java.bak 2025-04-06 23:16:22.506060418 +0300
+++ src/BlockStationary.java 2025-04-06 23:17:28.160290908 +0300
@@ -46,6 +46,13 @@
{
if(blockMaterial == Material.lava)
{
+ if (world.rand.nextInt(10) == 1) {
+ world.playSoundEffect(i, j, k, "sound3.liquid.lava", 0.5f, 1.0f);
+ }
+ else {
+ world.playSoundEffect(i, j, k, "sound3.liquid.lavapop", 0.5f, 1.0f);
+ }
+
int l = random.nextInt(3);
for(int i1 = 0; i1 < l; i1++)
{

View File

@ -1,4 +1,4 @@
--- src/GuiGameOver.java.bak 2025-04-05 23:00:50.099286718 +0300
--- src/GuiGameOver.java.bak 2025-04-05 23:20:15.027374865 +0300
+++ src/GuiGameOver.java 2025-04-05 23:03:44.980201062 +0300
@@ -55,7 +55,7 @@
GL11.glScalef(2.0F, 2.0F, 2.0F);

View File

@ -1,5 +1,5 @@
--- src/GuiIngame.java.bak 2025-04-05 21:59:28.543494774 +0300
+++ src/GuiIngame.java 2025-04-05 22:01:02.702349083 +0300
+++ src/GuiIngame.java 2025-04-06 19:19:53.698033634 +0300
@@ -7,8 +7,11 @@
import java.awt.Color;
import java.util.ArrayList;

View File

@ -1,5 +1,5 @@
--- src/RenderGlobal.java.bak 2025-04-05 22:12:27.557016177 +0300
+++ src/RenderGlobal.java 2025-04-05 22:12:39.943865458 +0300
+++ src/RenderGlobal.java 2025-04-06 19:19:53.715033418 +0300
@@ -7,6 +7,7 @@
import java.nio.IntBuffer;
import java.util.*;

View File

@ -47,7 +47,8 @@ public class ModConfig {
public static final Option<Boolean> DISABLE_EATING_WHEN_MAX_HP =
make("Disable eating when at max HP", false, "Makes it so players can no longer eat if they're at max HP so they don't accidently waste food");
public static final Option<Double> APPLE_DROP_RATE = make("Apple Drop Rate", 0.0, "Chance for apples to drop from leaves (decimal between 0.0 and 1.0)");
public static final Option<Boolean> EDIT_SIGNS = make("Edit Signs", true, "Enables sign editing");
public static final Option<Boolean> FIX_BOW_MODEL = make("Fix bow model", true, "Makes the box model held by players and skeletons bigger and facing forward");
public static final Option<Boolean> FIX_MINECART_FLICKERING = make("Fix minecart flickering", true, "Fixes minecarts flickering when looking at their backs as a passanger");
public static final Option<Boolean> FIX_MINECART_STOPPING_ON_ITEMS =
@ -93,8 +94,6 @@ public class ModConfig {
this.fileConfig.setComment(o.name, o.description);
}
}
this.fileConfig.close();
}
public static <T> Option<T> make(String name, T defaultValue, String description) {

View File

@ -25,8 +25,7 @@ public class WyHelper {
return null;
}
public static void setField(Object obj, Object value, String... names) {
Field field = getField(obj.getClass(), names);
public static void setField(Field field, Object obj, Object value) {
try {
field.set(obj, value);
}

View File

@ -1,27 +1,64 @@
package net.minecraft.src;
import java.lang.reflect.Field;
import java.util.logging.Logger;
import net.minecraft.client.Minecraft;
import net.minecraft.src.finalbeta.ModConfig;
import net.minecraft.src.finalbeta.WyHelper;
public class mod_FinalBeta extends BaseMod {
public static final Logger LOGGER = Logger.getLogger("FinalBeta");
private static final Block[] PICKAXE_BLOCKS = new Block[]{Block.cobblestone, Block.stairDouble, Block.stairSingle,
Block.stone, Block.sandStone, Block.cobblestoneMossy, Block.oreIron, Block.blockSteel, Block.oreCoal, Block.blockGold,
Block.oreGold, Block.oreDiamond, Block.blockDiamond, Block.ice, Block.netherrack, Block.oreLapis, Block.blockLapis,
// Here starts the list of blocks that are not affected by default
Block.stairCompactCobblestone, Block.oreRedstone, Block.oreRedstoneGlowing, Block.doorSteel, Block.brick, Block.stoneOvenIdle, Block.stoneOvenActive,
Block.dispenser, Block.pressurePlateStone, Block.rail, Block.railDetector, Block.railPowered, Block.pistonBase, Block.pistonStickyBase};
//ModBlock.COAL_BLOCK, ModBlock.REDSTONE_BLOCK};
private static final Block[] HATCHET_BLOCKS = new Block[]{Block.planks, Block.bookShelf, Block.wood, Block.chest,
// Here starts the list of blocks that are not affected by default
Block.stairSingle, Block.stairCompactPlanks, Block.doorWood, Block.pressurePlatePlanks, Block.jukebox, Block.musicBlock, Block.pumpkin,
Block.pumpkinLantern, Block.signPost, Block.signWall, Block.trapdoor, Block.ladder, Block.workbench, Block.fence};
private static final Block[] SHOVEL_BLOCKS = new Block[]{Block.grass, Block.dirt, Block.sand, Block.gravel, Block.snow, Block.blockSnow,
Block.blockClay, Block.tilledField,
// Here starts the list of blocks that are not affected by default
Block.slowSand};
public mod_FinalBeta() {
ModConfig.instance();
ModLoader.SetInGameHook(this, true, false);
Minecraft mc = ModLoader.getMinecraftInstance();
Minecraft mc = ModLoader.getMinecraftInstance();
mc.hideQuitButton = false;
Minecraft.field_28006_b = null;
ModLoader.SetInGameHook(this, true, true);
if (ModConfig.FIX_PICKAXE_EFFECTIVENESS.get()) {
this.addEffectiveTool(PICKAXE_BLOCKS, Item.pickaxeDiamond, Item.pickaxeGold, Item.pickaxeSteel, Item.pickaxeStone, Item.pickaxeWood);
}
if (ModConfig.FIX_AXE_EFFECTIVENESS.get()) {
this.addEffectiveTool(HATCHET_BLOCKS, Item.axeDiamond, Item.axeGold, Item.axeSteel, Item.axeStone, Item.axeWood);
}
if (ModConfig.FIX_SHOVEL_EFFECTIVENESS.get()) {
this.addEffectiveTool(SHOVEL_BLOCKS, Item.shovelDiamond, Item.shovelGold, Item.shovelSteel, Item.shovelStone, Item.shovelWood);
}
}
public boolean OnTickInGame(Minecraft minecraft) {
return true;
}
private void addEffectiveTool(Block[] blocks, Item... tools) {
Field field = WyHelper.getField(ItemTool.class, "bk", "blocksEffectiveAgainst");
for (Item tool : tools) {
WyHelper.setField(field, tool, blocks);
}
}
@Override
public String Version() {
return "1.4.0";