Bug Fix for Chests staying open on MP Servers

Implemented reach distance variable
This commit is contained in:
LexManos 2012-01-17 03:44:52 +00:00
parent 43a89e61e9
commit 3b5b9c5d1e
7 changed files with 143 additions and 17 deletions

View file

@ -18,6 +18,15 @@
protected Item(int i) protected Item(int i)
{ {
maxStackSize = 64; maxStackSize = 64;
@@ -449,7 +453,7 @@
float f7 = f4 * f5;
float f8 = f6;
float f9 = f3 * f5;
- double d3 = 5D;
+ double d3 = ModLoader.getMinecraftInstance().playerController.getBlockReachDistance();
Vec3D vec3d1 = vec3d.addVector((double)f7 * d3, (double)f8 * d3, (double)f9 * d3);
MovingObjectPosition movingobjectposition = world.rayTraceBlocks_do_do(vec3d, vec3d1, flag, !flag);
return movingobjectposition;
@@ -469,6 +473,109 @@ @@ -469,6 +473,109 @@
{ {
return getIconFromDamage(i); return getIconFromDamage(i);

View file

@ -19,7 +19,15 @@
if (itemInUseCount <= 25 && itemInUseCount % 4 == 0) if (itemInUseCount <= 25 && itemInUseCount % 4 == 0)
{ {
func_35208_b(itemstack, 5); func_35208_b(itemstack, 5);
@@ -433,7 +438,16 @@ @@ -274,6 +279,7 @@
protected void usePersonalCraftingInventory()
{
+ currentCraftingInventory.onCraftGuiClosed(this);
currentCraftingInventory = personalCraftingInventory;
}
@@ -433,7 +439,16 @@
public void dropCurrentItem() public void dropCurrentItem()
{ {
@ -37,7 +45,7 @@
} }
public void dropPlayerItem(ItemStack itemstack) public void dropPlayerItem(ItemStack itemstack)
@@ -480,6 +494,8 @@ @@ -480,6 +495,8 @@
worldObj.spawnEntityInWorld(entityitem); worldObj.spawnEntityInWorld(entityitem);
} }
@ -46,7 +54,7 @@
public float getCurrentPlayerStrVsBlock(Block block) public float getCurrentPlayerStrVsBlock(Block block)
{ {
float f = inventory.getStrVsBlock(block); float f = inventory.getStrVsBlock(block);
@@ -508,6 +524,45 @@ @@ -508,6 +525,45 @@
return f1; return f1;
} }
@ -92,7 +100,7 @@
public boolean canHarvestBlock(Block block) public boolean canHarvestBlock(Block block)
{ {
return inventory.canHarvestBlock(block); return inventory.canHarvestBlock(block);
@@ -707,6 +762,26 @@ @@ -707,6 +763,26 @@
protected void damageEntity(DamageSource damagesource, int i) protected void damageEntity(DamageSource damagesource, int i)
{ {
@ -119,7 +127,7 @@
if (!damagesource.isUnblockable() && isBlocking()) if (!damagesource.isUnblockable() && isBlocking())
{ {
i = 1 + i >> 1; i = 1 + i >> 1;
@@ -758,7 +833,9 @@ @@ -758,7 +834,9 @@
public void destroyCurrentEquippedItem() public void destroyCurrentEquippedItem()
{ {
@ -129,7 +137,7 @@
} }
public double getYOffset() public double getYOffset()
@@ -884,6 +961,11 @@ @@ -884,6 +962,11 @@
public EnumStatus sleepInBedAt(int i, int j, int k) public EnumStatus sleepInBedAt(int i, int j, int k)
{ {

View file

@ -0,0 +1,50 @@
--- ../src_base/minecraft_server/net/minecraft/src/EntityPlayerMP.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src_work/minecraft_server/net/minecraft/src/EntityPlayerMP.java 0000-00-00 00:00:00.000000000 -0000
@@ -405,6 +405,7 @@
public void displayWorkbenchGUI(int i, int j, int k)
{
getNextWidowId();
+ closeCraftingGui();
playerNetServerHandler.sendPacket(new Packet100OpenWindow(currentWindowId, 1, "Crafting", 9));
currentCraftingInventory = new ContainerWorkbench(inventory, worldObj, i, j, k);
currentCraftingInventory.windowId = currentWindowId;
@@ -414,6 +415,7 @@
public void displayGUIEnchantment(int i, int j, int k)
{
getNextWidowId();
+ closeCraftingGui();
playerNetServerHandler.sendPacket(new Packet100OpenWindow(currentWindowId, 4, "Enchanting", 9));
currentCraftingInventory = new ContainerEnchantment(inventory, worldObj, i, j, k);
currentCraftingInventory.windowId = currentWindowId;
@@ -423,6 +425,7 @@
public void displayGUIChest(IInventory iinventory)
{
getNextWidowId();
+ closeCraftingGui();
playerNetServerHandler.sendPacket(new Packet100OpenWindow(currentWindowId, 0, iinventory.getInvName(), iinventory.getSizeInventory()));
currentCraftingInventory = new ContainerChest(inventory, iinventory);
currentCraftingInventory.windowId = currentWindowId;
@@ -432,6 +435,7 @@
public void displayGUIFurnace(TileEntityFurnace tileentityfurnace)
{
getNextWidowId();
+ closeCraftingGui();
playerNetServerHandler.sendPacket(new Packet100OpenWindow(currentWindowId, 2, tileentityfurnace.getInvName(), tileentityfurnace.getSizeInventory()));
currentCraftingInventory = new ContainerFurnace(inventory, tileentityfurnace);
currentCraftingInventory.windowId = currentWindowId;
@@ -441,6 +445,7 @@
public void displayGUIDispenser(TileEntityDispenser tileentitydispenser)
{
getNextWidowId();
+ closeCraftingGui();
playerNetServerHandler.sendPacket(new Packet100OpenWindow(currentWindowId, 3, tileentitydispenser.getInvName(), tileentitydispenser.getSizeInventory()));
currentCraftingInventory = new ContainerDispenser(inventory, tileentitydispenser);
currentCraftingInventory.windowId = currentWindowId;
@@ -450,6 +455,7 @@
public void displayGUIBrewingStand(TileEntityBrewingStand tileentitybrewingstand)
{
getNextWidowId();
+ closeCraftingGui();
playerNetServerHandler.sendPacket(new Packet100OpenWindow(currentWindowId, 5, tileentitybrewingstand.getInvName(), tileentitybrewingstand.getSizeInventory()));
currentCraftingInventory = new ContainerBrewingStand(inventory, tileentitybrewingstand);
currentCraftingInventory.windowId = currentWindowId;

View file

@ -18,7 +18,15 @@
protected Item(int i) protected Item(int i)
{ {
maxStackSize = 64; maxStackSize = 64;
@@ -393,6 +397,109 @@ @@ -389,10 +393,117 @@
float f8 = f6;
float f9 = f3 * f5;
double d3 = 5D;
+ if (entityplayer instanceof EntityPlayerMP)
+ {
+ d3 = ((EntityPlayerMP)entityplayer).itemInWorldManager.getBlockReachDistance();
+ }
Vec3D vec3d1 = vec3d.addVector((double)f7 * d3, (double)f8 * d3, (double)f9 * d3);
MovingObjectPosition movingobjectposition = world.rayTraceBlocks_do_do(vec3d, vec3d1, flag, !flag); MovingObjectPosition movingobjectposition = world.rayTraceBlocks_do_do(vec3d, vec3d1, flag, !flag);
return movingobjectposition; return movingobjectposition;
} }

View file

@ -1,14 +1,17 @@
--- ../src_base/minecraft_server/net/minecraft/src/ItemInWorldManager.java 0000-00-00 00:00:00.000000000 -0000 --- ../src_base/minecraft_server/net/minecraft/src/ItemInWorldManager.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src_work/minecraft_server/net/minecraft/src/ItemInWorldManager.java 0000-00-00 00:00:00.000000000 -0000 +++ ../src_work/minecraft_server/net/minecraft/src/ItemInWorldManager.java 0000-00-00 00:00:00.000000000 -0000
@@ -1,5 +1,7 @@ @@ -1,7 +1,10 @@
package net.minecraft.src; package net.minecraft.src;
+import net.minecraft.src.forge.ForgeHooks; +import net.minecraft.src.forge.ForgeHooks;
+ +
public class ItemInWorldManager public class ItemInWorldManager
{ {
+ private double blockReachDistance;
public World thisWorld; public World thisWorld;
@@ -71,7 +73,7 @@ public EntityPlayer thisPlayer;
private int gameType;
@@ -71,7 +74,7 @@
if (j != 0) if (j != 0)
{ {
Block block = Block.blocksList[j]; Block block = Block.blocksList[j];
@ -17,7 +20,7 @@
if (f >= 1.0F) if (f >= 1.0F)
{ {
field_22050_k = false; field_22050_k = false;
@@ -99,7 +101,7 @@ @@ -99,7 +102,7 @@
{ {
Block.blocksList[i1].onBlockClicked(thisWorld, i, j, k, thisPlayer); Block.blocksList[i1].onBlockClicked(thisWorld, i, j, k, thisPlayer);
} }
@ -26,7 +29,7 @@
{ {
blockHarvessted(i, j, k); blockHarvessted(i, j, k);
} }
@@ -120,7 +122,7 @@ @@ -120,7 +123,7 @@
if (i1 != 0) if (i1 != 0)
{ {
Block block = Block.blocksList[i1]; Block block = Block.blocksList[i1];
@ -35,7 +38,7 @@
if (f >= 0.7F) if (f >= 0.7F)
{ {
blockHarvessted(i, j, k); blockHarvessted(i, j, k);
@@ -142,8 +144,13 @@ @@ -142,8 +145,13 @@
{ {
Block block = Block.blocksList[thisWorld.getBlockId(i, j, k)]; Block block = Block.blocksList[thisWorld.getBlockId(i, j, k)];
int l = thisWorld.getBlockMetadata(i, j, k); int l = thisWorld.getBlockMetadata(i, j, k);
@ -51,7 +54,7 @@
{ {
block.onBlockDestroyedByPlayer(thisWorld, i, j, k, l); block.onBlockDestroyedByPlayer(thisWorld, i, j, k, l);
} }
@@ -152,6 +159,11 @@ @@ -152,6 +160,11 @@
public boolean blockHarvessted(int i, int j, int k) public boolean blockHarvessted(int i, int j, int k)
{ {
@ -63,7 +66,7 @@
int l = thisWorld.getBlockId(i, j, k); int l = thisWorld.getBlockId(i, j, k);
int i1 = thisWorld.getBlockMetadata(i, j, k); int i1 = thisWorld.getBlockMetadata(i, j, k);
thisWorld.playAuxSFXAtEntity(thisPlayer, 2001, i, j, k, l + thisWorld.getBlockMetadata(i, j, k) * 256); thisWorld.playAuxSFXAtEntity(thisPlayer, 2001, i, j, k, l + thisWorld.getBlockMetadata(i, j, k) * 256);
@@ -162,8 +174,7 @@ @@ -162,8 +175,7 @@
} }
else else
{ {
@ -73,7 +76,7 @@
if (itemstack != null) if (itemstack != null)
{ {
itemstack.onDestroyBlock(l, i, j, k, thisPlayer); itemstack.onDestroyBlock(l, i, j, k, thisPlayer);
@@ -197,6 +208,7 @@ @@ -197,6 +209,7 @@
if (itemstack1.stackSize == 0) if (itemstack1.stackSize == 0)
{ {
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = null; entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = null;
@ -81,7 +84,7 @@
} }
return true; return true;
} }
@@ -208,6 +220,14 @@ @@ -208,6 +221,14 @@
public boolean activeBlockOrUseItem(EntityPlayer entityplayer, World world, ItemStack itemstack, int i, int j, int k, int l) public boolean activeBlockOrUseItem(EntityPlayer entityplayer, World world, ItemStack itemstack, int i, int j, int k, int l)
{ {
@ -96,7 +99,7 @@
int i1 = world.getBlockId(i, j, k); int i1 = world.getBlockId(i, j, k);
if (i1 > 0 && Block.blocksList[i1].blockActivated(world, i, j, k, entityplayer)) if (i1 > 0 && Block.blocksList[i1].blockActivated(world, i, j, k, entityplayer))
{ {
@@ -228,7 +248,15 @@ @@ -228,7 +249,15 @@
} }
else else
{ {
@ -113,3 +116,17 @@
} }
} }
@@ -236,4 +265,13 @@
{
thisWorld = worldserver;
}
+
+ public double getBlockReachDistance()
+ {
+ return blockReachDistance;
+ }
+ public void setBlockReachDistance(double distance)
+ {
+ blockReachDistance = distance;
+ }
}

View file

@ -0,0 +1,10 @@
--- ../src_base/minecraft_server/net/minecraft/src/ModLoader.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src_work/minecraft_server/net/minecraft/src/ModLoader.java 0000-00-00 00:00:00.000000000 -0000
@@ -1317,6 +1317,7 @@
{
method_getNextWindowId.invoke(entityplayermp, new Object[0]);
int j = field_currentWindowId.getInt(entityplayermp);
+ entityplayermp.closeCraftingGui();
entityplayermp.playerNetServerHandler.sendPacket(new Packet100OpenWindow(j, i, iinventory.getInvName(), iinventory.getSizeInventory()));
entityplayermp.currentCraftingInventory = container;
entityplayermp.currentCraftingInventory.windowId = j;

View file

@ -0,0 +1,24 @@
--- ../src_base/minecraft_server/net/minecraft/src/NetServerHandler.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src_work/minecraft_server/net/minecraft/src/NetServerHandler.java 0000-00-00 00:00:00.000000000 -0000
@@ -295,7 +295,9 @@
double d1 = (playerEntity.posY - ((double)j + 0.5D)) + 1.5D;
double d3 = playerEntity.posZ - ((double)k + 0.5D);
double d5 = d * d + d1 * d1 + d3 * d3;
- if (d5 > 36D)
+ double dist = playerEntity.itemInWorldManager.getBlockReachDistance() + 1;
+ dist *= dist;
+ if (d5 > dist)
{
return;
}
@@ -366,7 +368,9 @@
{
j1 = i1;
}
- if (hasMoved && playerEntity.getDistanceSq((double)i + 0.5D, (double)j + 0.5D, (double)k + 0.5D) < 64D && (j1 > 16 || flag))
+ double dist = playerEntity.itemInWorldManager.getBlockReachDistance() + 3;
+ dist *= dist;
+ if (hasMoved && playerEntity.getDistanceSq((double)i + 0.5D, (double)j + 0.5D, (double)k + 0.5D) < dist && (j1 > 16 || flag))
{
playerEntity.itemInWorldManager.activeBlockOrUseItem(playerEntity, worldserver, itemstack, i, j, k, l);
}