mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-25 20:16:19 +01:00
Fix event for unlucky composts
This commit is contained in:
parent
b567cb433d
commit
fdf6017fa9
@ -19,7 +19,7 @@
|
|||||||
for (int i = 0; i < 8; ++i) {
|
for (int i = 0; i < 8; ++i) {
|
||||||
avoxelshape[i] = VoxelShapes.a(BlockComposter.c, Block.a(2.0D, (double) Math.max(2, 1 + i * 2), 2.0D, 14.0D, 16.0D, 14.0D), OperatorBoolean.ONLY_FIRST);
|
avoxelshape[i] = VoxelShapes.a(BlockComposter.c, Block.a(2.0D, (double) Math.max(2, 1 + i * 2), 2.0D, 14.0D, 16.0D, 14.0D), OperatorBoolean.ONLY_FIRST);
|
||||||
}
|
}
|
||||||
@@ -163,11 +167,17 @@
|
@@ -163,11 +167,18 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,16 +30,35 @@
|
|||||||
if (i < 7 && BlockComposter.b.containsKey(itemstack.getItem())) {
|
if (i < 7 && BlockComposter.b.containsKey(itemstack.getItem())) {
|
||||||
- IBlockData iblockdata1 = b(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack);
|
- IBlockData iblockdata1 = b(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack);
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ IBlockData iblockdata1 = b(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition, itemstack);
|
+ double rand = worldserver.getRandom().nextDouble();
|
||||||
|
+ IBlockData iblockdata1 = b(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition, itemstack, rand);
|
||||||
+ if (iblockdata == iblockdata1 || org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1).isCancelled()) {
|
+ if (iblockdata == iblockdata1 || org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1).isCancelled()) {
|
||||||
+ return iblockdata;
|
+ return iblockdata;
|
||||||
+ }
|
+ }
|
||||||
+ iblockdata1 = b(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack);
|
+ iblockdata1 = b(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack, rand);
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
|
||||||
itemstack.subtract(1);
|
itemstack.subtract(1);
|
||||||
worldserver.triggerEffect(1500, blockposition, iblockdata != iblockdata1 ? 1 : 0);
|
worldserver.triggerEffect(1500, blockposition, iblockdata != iblockdata1 ? 1 : 0);
|
||||||
@@ -254,7 +264,8 @@
|
@@ -203,10 +214,16 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IBlockData b(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack) {
|
||||||
|
+ // CraftBukkit start
|
||||||
|
+ return b(iblockdata, generatoraccess, blockposition, itemstack, generatoraccess.getRandom().nextDouble());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static IBlockData b(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack, double rand) {
|
||||||
|
+ // CraftBukkit end
|
||||||
|
int i = (Integer) iblockdata.get(BlockComposter.a);
|
||||||
|
float f = BlockComposter.b.getFloat(itemstack.getItem());
|
||||||
|
|
||||||
|
- if ((i != 0 || f <= 0.0F) && generatoraccess.getRandom().nextDouble() >= (double) f) {
|
||||||
|
+ if ((i != 0 || f <= 0.0F) && rand >= (double) f) {
|
||||||
|
return iblockdata;
|
||||||
|
} else {
|
||||||
|
int j = i + 1;
|
||||||
|
@@ -254,7 +271,8 @@
|
||||||
public IWorldInventory a(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
|
public IWorldInventory a(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
|
||||||
int i = (Integer) iblockdata.get(BlockComposter.a);
|
int i = (Integer) iblockdata.get(BlockComposter.a);
|
||||||
|
|
||||||
@ -49,7 +68,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
static class ContainerInput extends InventorySubcontainer implements IWorldInventory {
|
static class ContainerInput extends InventorySubcontainer implements IWorldInventory {
|
||||||
@@ -266,6 +277,7 @@
|
@@ -266,6 +284,7 @@
|
||||||
|
|
||||||
public ContainerInput(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
|
public ContainerInput(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
|
||||||
super(1);
|
super(1);
|
||||||
@ -57,7 +76,7 @@
|
|||||||
this.a = iblockdata;
|
this.a = iblockdata;
|
||||||
this.b = generatoraccess;
|
this.b = generatoraccess;
|
||||||
this.c = blockposition;
|
this.c = blockposition;
|
||||||
@@ -318,6 +330,7 @@
|
@@ -318,6 +337,7 @@
|
||||||
this.blockData = iblockdata;
|
this.blockData = iblockdata;
|
||||||
this.generatorAccess = generatoraccess;
|
this.generatorAccess = generatoraccess;
|
||||||
this.blockPosition = blockposition;
|
this.blockPosition = blockposition;
|
||||||
@ -65,7 +84,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -342,15 +355,23 @@
|
@@ -342,15 +362,23 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
|
@ -2,7 +2,6 @@ package org.bukkit.craftbukkit.util;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import net.minecraft.server.AxisAlignedBB;
|
import net.minecraft.server.AxisAlignedBB;
|
||||||
import net.minecraft.server.BiomeBase;
|
import net.minecraft.server.BiomeBase;
|
||||||
@ -71,7 +70,7 @@ public class DummyGeneratorAccess implements GeneratorAccess {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Random getRandom() {
|
public Random getRandom() {
|
||||||
return ThreadLocalRandom.current();
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user