Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 12:30:06 +01:00
Fixed Material
Dieser Commit ist enthalten in:
Ursprung
c7d680163f
Commit
49b225ac08
@ -1,252 +1,252 @@
|
|||||||
package net.minecraft.server;
|
package net.minecraft.server;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.BlockFace;
|
import org.bukkit.BlockFace;
|
||||||
import org.bukkit.craftbukkit.CraftBlock;
|
import org.bukkit.craftbukkit.CraftBlock;
|
||||||
import org.bukkit.event.Event.Type;
|
import org.bukkit.event.Event.Type;
|
||||||
import org.bukkit.event.block.BlockFromToEvent;
|
import org.bukkit.event.block.BlockFromToEvent;
|
||||||
|
|
||||||
public class BlockFlowing extends BlockFluids
|
public class BlockFlowing extends BlockFluids
|
||||||
{
|
{
|
||||||
|
|
||||||
protected BlockFlowing(int i1, Material material)
|
protected BlockFlowing(int i1, Material material)
|
||||||
{
|
{
|
||||||
super(i1, material);
|
super(i1, material);
|
||||||
a = 0;
|
a = 0;
|
||||||
b = new boolean[4];
|
b = new boolean[4];
|
||||||
c = new int[4];
|
c = new int[4];
|
||||||
}
|
}
|
||||||
|
|
||||||
private void i(World world, int i1, int j1, int k1)
|
private void i(World world, int i1, int j1, int k1)
|
||||||
{
|
{
|
||||||
int l1 = world.b(i1, j1, k1);
|
int l1 = world.b(i1, j1, k1);
|
||||||
world.a(i1, j1, k1, bh + 1, l1);
|
world.a(i1, j1, k1, bh + 1, l1);
|
||||||
world.b(i1, j1, k1, i1, j1, k1);
|
world.b(i1, j1, k1, i1, j1, k1);
|
||||||
world.g(i1, j1, k1);
|
world.g(i1, j1, k1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void a(World world, int i1, int j1, int k1, Random random)
|
public void a(World world, int i1, int j1, int k1, Random random)
|
||||||
{
|
{
|
||||||
int l1 = g(world, i1, j1, k1);
|
int l1 = g(world, i1, j1, k1);
|
||||||
byte byte0 = 1;
|
byte byte0 = 1;
|
||||||
if(bs == Material.g && !world.q.d)
|
if(bs == Material.g && !world.q.d)
|
||||||
byte0 = 2;
|
byte0 = 2;
|
||||||
boolean flag = true;
|
boolean flag = true;
|
||||||
if(l1 > 0)
|
if(l1 > 0)
|
||||||
{
|
{
|
||||||
int i2 = -100;
|
int i2 = -100;
|
||||||
a = 0;
|
a = 0;
|
||||||
i2 = e(world, i1 - 1, j1, k1, i2);
|
i2 = e(world, i1 - 1, j1, k1, i2);
|
||||||
i2 = e(world, i1 + 1, j1, k1, i2);
|
i2 = e(world, i1 + 1, j1, k1, i2);
|
||||||
i2 = e(world, i1, j1, k1 - 1, i2);
|
i2 = e(world, i1, j1, k1 - 1, i2);
|
||||||
i2 = e(world, i1, j1, k1 + 1, i2);
|
i2 = e(world, i1, j1, k1 + 1, i2);
|
||||||
int j2 = i2 + byte0;
|
int j2 = i2 + byte0;
|
||||||
if(j2 >= 8 || i2 < 0)
|
if(j2 >= 8 || i2 < 0)
|
||||||
j2 = -1;
|
j2 = -1;
|
||||||
if(g(world, i1, j1 + 1, k1) >= 0)
|
if(g(world, i1, j1 + 1, k1) >= 0)
|
||||||
{
|
{
|
||||||
int l2 = g(world, i1, j1 + 1, k1);
|
int l2 = g(world, i1, j1 + 1, k1);
|
||||||
if(l2 >= 8)
|
if(l2 >= 8)
|
||||||
j2 = l2;
|
j2 = l2;
|
||||||
else
|
else
|
||||||
j2 = l2 + 8;
|
j2 = l2 + 8;
|
||||||
}
|
}
|
||||||
if(a >= 2 && bs == Material.f)
|
if(a >= 2 && bs == Material.f)
|
||||||
if(world.d(i1, j1 - 1, k1))
|
if(world.d(i1, j1 - 1, k1))
|
||||||
j2 = 0;
|
j2 = 0;
|
||||||
else
|
else
|
||||||
if(world.c(i1, j1 - 1, k1) == bs && world.b(i1, j1, k1) == 0)
|
if(world.c(i1, j1 - 1, k1) == bs && world.b(i1, j1, k1) == 0)
|
||||||
j2 = 0;
|
j2 = 0;
|
||||||
if(bs == Material.g && l1 < 8 && j2 < 8 && j2 > l1 && random.nextInt(4) != 0)
|
if(bs == Material.g && l1 < 8 && j2 < 8 && j2 > l1 && random.nextInt(4) != 0)
|
||||||
{
|
{
|
||||||
j2 = l1;
|
j2 = l1;
|
||||||
flag = false;
|
flag = false;
|
||||||
}
|
}
|
||||||
if(j2 != l1)
|
if(j2 != l1)
|
||||||
{
|
{
|
||||||
l1 = j2;
|
l1 = j2;
|
||||||
if(l1 < 0)
|
if(l1 < 0)
|
||||||
{
|
{
|
||||||
world.d(i1, j1, k1, 0);
|
world.d(i1, j1, k1, 0);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
world.b(i1, j1, k1, l1);
|
world.b(i1, j1, k1, l1);
|
||||||
world.h(i1, j1, k1, bh);
|
world.h(i1, j1, k1, bh);
|
||||||
world.g(i1, j1, k1, bh);
|
world.g(i1, j1, k1, bh);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
if(flag)
|
if(flag)
|
||||||
i(world, i1, j1, k1);
|
i(world, i1, j1, k1);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
i(world, i1, j1, k1);
|
i(world, i1, j1, k1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Craftbukkit start
|
// Craftbukkit start
|
||||||
CraftBlock source = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i1, j1, k1);
|
CraftBlock source = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i1, j1, k1);
|
||||||
|
|
||||||
if(l(world, i1, j1 - 1, k1))
|
if(l(world, i1, j1 - 1, k1))
|
||||||
{
|
{
|
||||||
// Craftbucket send "down" to the server
|
// Craftbucket send "down" to the server
|
||||||
BlockFromToEvent blockFlow = new BlockFromToEvent(Type.BLOCK_FLOW, source, BlockFace.Down);
|
BlockFromToEvent blockFlow = new BlockFromToEvent(Type.BLOCK_FLOW, source, BlockFace.Down);
|
||||||
((WorldServer) world).getServer().getPluginManager().callEvent(blockFlow);
|
((WorldServer) world).getServer().getPluginManager().callEvent(blockFlow);
|
||||||
|
|
||||||
if (!blockFlow.isCancelled()) {
|
if (!blockFlow.isCancelled()) {
|
||||||
if(l1 >= 8)
|
if(l1 >= 8)
|
||||||
world.b(i1, j1 - 1, k1, bh, l1);
|
world.b(i1, j1 - 1, k1, bh, l1);
|
||||||
else
|
else
|
||||||
world.b(i1, j1 - 1, k1, bh, l1 + 8);
|
world.b(i1, j1 - 1, k1, bh, l1 + 8);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
if(l1 >= 0 && (l1 == 0 || k(world, i1, j1 - 1, k1)))
|
if(l1 >= 0 && (l1 == 0 || k(world, i1, j1 - 1, k1)))
|
||||||
{
|
{
|
||||||
boolean aflag[] = j(world, i1, j1, k1);
|
boolean aflag[] = j(world, i1, j1, k1);
|
||||||
int k2 = l1 + byte0;
|
int k2 = l1 + byte0;
|
||||||
if(l1 >= 8)
|
if(l1 >= 8)
|
||||||
k2 = 1;
|
k2 = 1;
|
||||||
if(k2 >= 8)
|
if(k2 >= 8)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Craftbukkit start
|
// Craftbukkit start
|
||||||
BlockFace[] faces = new BlockFace[]{ BlockFace.North, BlockFace.South, BlockFace.East, BlockFace.West };
|
BlockFace[] faces = new BlockFace[]{ BlockFace.North, BlockFace.South, BlockFace.East, BlockFace.West };
|
||||||
for (BlockFace currentFace : faces) {
|
for (BlockFace currentFace : faces) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
if (aflag[index]) {
|
if (aflag[index]) {
|
||||||
BlockFromToEvent event = new BlockFromToEvent(Type.BLOCK_FLOW, source, currentFace);
|
BlockFromToEvent event = new BlockFromToEvent(Type.BLOCK_FLOW, source, currentFace);
|
||||||
((WorldServer) world).getServer().getPluginManager().callEvent(event);
|
((WorldServer) world).getServer().getPluginManager().callEvent(event);
|
||||||
if (!event.isCancelled())
|
if (!event.isCancelled())
|
||||||
f(world, i1 + currentFace.getModX(), j1, k1 + currentFace.getModZ(), k2);
|
f(world, i1 + currentFace.getModX(), j1, k1 + currentFace.getModZ(), k2);
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
// Craftbukkit stop
|
// Craftbukkit stop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void f(World world, int i1, int j1, int k1, int l1)
|
private void f(World world, int i1, int j1, int k1, int l1)
|
||||||
{
|
{
|
||||||
if(l(world, i1, j1, k1))
|
if(l(world, i1, j1, k1))
|
||||||
{
|
{
|
||||||
int i2 = world.a(i1, j1, k1);
|
int i2 = world.a(i1, j1, k1);
|
||||||
if(i2 > 0)
|
if(i2 > 0)
|
||||||
if(bs == Material.g)
|
if(bs == Material.g)
|
||||||
h(world, i1, j1, k1);
|
h(world, i1, j1, k1);
|
||||||
else
|
else
|
||||||
Block.m[i2].a_(world, i1, j1, k1, world.b(i1, j1, k1));
|
Block.m[i2].a_(world, i1, j1, k1, world.b(i1, j1, k1));
|
||||||
world.b(i1, j1, k1, bh, l1);
|
world.b(i1, j1, k1, bh, l1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int a(World world, int i1, int j1, int k1, int l1, int i2)
|
private int a(World world, int i1, int j1, int k1, int l1, int i2)
|
||||||
{
|
{
|
||||||
int j2 = 1000;
|
int j2 = 1000;
|
||||||
for(int k2 = 0; k2 < 4; k2++)
|
for(int k2 = 0; k2 < 4; k2++)
|
||||||
{
|
{
|
||||||
if(k2 == 0 && i2 == 1 || k2 == 1 && i2 == 0 || k2 == 2 && i2 == 3 || k2 == 3 && i2 == 2)
|
if(k2 == 0 && i2 == 1 || k2 == 1 && i2 == 0 || k2 == 2 && i2 == 3 || k2 == 3 && i2 == 2)
|
||||||
continue;
|
continue;
|
||||||
int l2 = i1;
|
int l2 = i1;
|
||||||
int i3 = j1;
|
int i3 = j1;
|
||||||
int j3 = k1;
|
int j3 = k1;
|
||||||
if(k2 == 0)
|
if(k2 == 0)
|
||||||
l2--;
|
l2--;
|
||||||
if(k2 == 1)
|
if(k2 == 1)
|
||||||
l2++;
|
l2++;
|
||||||
if(k2 == 2)
|
if(k2 == 2)
|
||||||
j3--;
|
j3--;
|
||||||
if(k2 == 3)
|
if(k2 == 3)
|
||||||
j3++;
|
j3++;
|
||||||
if(k(world, l2, i3, j3) || world.c(l2, i3, j3) == bs && world.b(l2, i3, j3) == 0)
|
if(k(world, l2, i3, j3) || world.c(l2, i3, j3) == bs && world.b(l2, i3, j3) == 0)
|
||||||
continue;
|
continue;
|
||||||
if(!k(world, l2, i3 - 1, j3))
|
if(!k(world, l2, i3 - 1, j3))
|
||||||
return l1;
|
return l1;
|
||||||
if(l1 >= 4)
|
if(l1 >= 4)
|
||||||
continue;
|
continue;
|
||||||
int k3 = a(world, l2, i3, j3, l1 + 1, k2);
|
int k3 = a(world, l2, i3, j3, l1 + 1, k2);
|
||||||
if(k3 < j2)
|
if(k3 < j2)
|
||||||
j2 = k3;
|
j2 = k3;
|
||||||
}
|
}
|
||||||
|
|
||||||
return j2;
|
return j2;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean[] j(World world, int i1, int j1, int k1)
|
private boolean[] j(World world, int i1, int j1, int k1)
|
||||||
{
|
{
|
||||||
for(int l1 = 0; l1 < 4; l1++)
|
for(int l1 = 0; l1 < 4; l1++)
|
||||||
{
|
{
|
||||||
c[l1] = 1000;
|
c[l1] = 1000;
|
||||||
int j2 = i1;
|
int j2 = i1;
|
||||||
int i3 = j1;
|
int i3 = j1;
|
||||||
int j3 = k1;
|
int j3 = k1;
|
||||||
if(l1 == 0)
|
if(l1 == 0)
|
||||||
j2--;
|
j2--;
|
||||||
if(l1 == 1)
|
if(l1 == 1)
|
||||||
j2++;
|
j2++;
|
||||||
if(l1 == 2)
|
if(l1 == 2)
|
||||||
j3--;
|
j3--;
|
||||||
if(l1 == 3)
|
if(l1 == 3)
|
||||||
j3++;
|
j3++;
|
||||||
if(k(world, j2, i3, j3) || world.c(j2, i3, j3) == bs && world.b(j2, i3, j3) == 0)
|
if(k(world, j2, i3, j3) || world.c(j2, i3, j3) == bs && world.b(j2, i3, j3) == 0)
|
||||||
continue;
|
continue;
|
||||||
if(!k(world, j2, i3 - 1, j3))
|
if(!k(world, j2, i3 - 1, j3))
|
||||||
c[l1] = 0;
|
c[l1] = 0;
|
||||||
else
|
else
|
||||||
c[l1] = a(world, j2, i3, j3, 1, l1);
|
c[l1] = a(world, j2, i3, j3, 1, l1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int i2 = c[0];
|
int i2 = c[0];
|
||||||
for(int k2 = 1; k2 < 4; k2++)
|
for(int k2 = 1; k2 < 4; k2++)
|
||||||
if(c[k2] < i2)
|
if(c[k2] < i2)
|
||||||
i2 = c[k2];
|
i2 = c[k2];
|
||||||
|
|
||||||
for(int l2 = 0; l2 < 4; l2++)
|
for(int l2 = 0; l2 < 4; l2++)
|
||||||
b[l2] = c[l2] == i2;
|
b[l2] = c[l2] == i2;
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean k(World world, int i1, int j1, int k1)
|
private boolean k(World world, int i1, int j1, int k1)
|
||||||
{
|
{
|
||||||
int l1 = world.a(i1, j1, k1);
|
int l1 = world.a(i1, j1, k1);
|
||||||
if(l1 == Block.aE.bh || l1 == Block.aL.bh || l1 == Block.aD.bh || l1 == Block.aF.bh || l1 == Block.aX.bh)
|
if(l1 == Block.aE.bh || l1 == Block.aL.bh || l1 == Block.aD.bh || l1 == Block.aF.bh || l1 == Block.aX.bh)
|
||||||
return true;
|
return true;
|
||||||
if(l1 == 0)
|
if(l1 == 0)
|
||||||
return false;
|
return false;
|
||||||
Material material = Block.m[l1].bs;
|
Material material = Block.m[l1].bs;
|
||||||
return material.a();
|
return material.a();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int e(World world, int i1, int j1, int k1, int l1)
|
protected int e(World world, int i1, int j1, int k1, int l1)
|
||||||
{
|
{
|
||||||
int i2 = g(world, i1, j1, k1);
|
int i2 = g(world, i1, j1, k1);
|
||||||
if(i2 < 0)
|
if(i2 < 0)
|
||||||
return l1;
|
return l1;
|
||||||
if(i2 == 0)
|
if(i2 == 0)
|
||||||
a++;
|
a++;
|
||||||
if(i2 >= 8)
|
if(i2 >= 8)
|
||||||
i2 = 0;
|
i2 = 0;
|
||||||
return l1 >= 0 && i2 >= l1 ? l1 : i2;
|
return l1 >= 0 && i2 >= l1 ? l1 : i2;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean l(World world, int i1, int j1, int k1)
|
private boolean l(World world, int i1, int j1, int k1)
|
||||||
{
|
{
|
||||||
Material material = world.c(i1, j1, k1);
|
Material material = world.c(i1, j1, k1);
|
||||||
if(material == bs)
|
if(material == bs)
|
||||||
return false;
|
return false;
|
||||||
if(material == Material.g)
|
if(material == Material.g)
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
return !k(world, i1, j1, k1);
|
return !k(world, i1, j1, k1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void e(World world, int i1, int j1, int k1)
|
public void e(World world, int i1, int j1, int k1)
|
||||||
{
|
{
|
||||||
super.e(world, i1, j1, k1);
|
super.e(world, i1, j1, k1);
|
||||||
if(world.a(i1, j1, k1) == bh)
|
if(world.a(i1, j1, k1) == bh)
|
||||||
world.h(i1, j1, k1, bh);
|
world.h(i1, j1, k1, bh);
|
||||||
}
|
}
|
||||||
|
|
||||||
int a;
|
int a;
|
||||||
boolean b[];
|
boolean b[];
|
||||||
int c[];
|
int c[];
|
||||||
}
|
}
|
@ -86,22 +86,40 @@ public class CraftBlock implements Block {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the type of this block
|
||||||
|
*
|
||||||
|
* @param type Material to change this block to
|
||||||
|
*/
|
||||||
|
public void setType(final Material type) {
|
||||||
|
setTypeID(type.getID());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the type-ID of this block
|
* Sets the type-ID of this block
|
||||||
*
|
*
|
||||||
* @param type Type-ID to change this block to
|
* @param type Type-ID to change this block to
|
||||||
*/
|
*/
|
||||||
public void setType(final int type) {
|
public void setTypeID(final int type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
world.getHandle().d(x, y, z, type);
|
world.getHandle().d(x, y, z, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the type of this block
|
||||||
|
*
|
||||||
|
* @return block type
|
||||||
|
*/
|
||||||
|
public Material getType() {
|
||||||
|
return Material.getMaterial(getTypeID());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the type-ID of this block
|
* Gets the type-ID of this block
|
||||||
*
|
*
|
||||||
* @return block type-ID
|
* @return block type-ID
|
||||||
*/
|
*/
|
||||||
public int getType() {
|
public int getTypeID() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren