Compare commits
40 Commits
dependabot
...
Build-scri
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cabf1dda1a | ||
|
|
c132250098 | ||
|
|
66d6e7eb7c | ||
|
|
d718012cd5 | ||
|
|
1da3db747f | ||
|
|
42ab8edd6f | ||
|
|
22b00a1ac1 | ||
|
|
0660893d10 | ||
|
|
7b1a11a7cb | ||
|
|
d99ff899e9 | ||
|
|
48bc7a76a6 | ||
|
|
c52b1a2464 | ||
|
|
8b617ed169 | ||
|
|
b6d360e399 | ||
|
|
ea47663e3c | ||
|
|
baf64bb7a0 | ||
|
|
13b6dd77c8 | ||
|
|
8e0d49c722 | ||
|
|
88f3d2bb91 | ||
|
|
561b80c7fa | ||
|
|
752fc2981a | ||
|
|
b66854b35a | ||
|
|
d6400a0a68 | ||
|
|
9680395435 | ||
|
|
9e71f569dc | ||
|
|
104045e04d | ||
|
|
c398827cba | ||
|
|
1746d7b012 | ||
|
|
8a5d8fdaea | ||
|
|
09136ba60d | ||
|
|
7bec837bdb | ||
|
|
cfb02cf611 | ||
|
|
4d9c01aa87 | ||
|
|
39670d24e1 | ||
|
|
dd01cae8fe | ||
|
|
0098d0c20d | ||
|
|
d8ea0f157a | ||
|
|
13d3cb28e4 | ||
|
|
a15099f9e8 | ||
|
|
490ae739a4 |
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -1,3 +1,3 @@
|
||||
[submodule "work/Paper"]
|
||||
path = work/Paper
|
||||
url = https://github.com/Akarin-project/Paper.git
|
||||
url = https://github.com/LegacyGamerHD/Paper.git
|
||||
|
||||
3
Jenkinsfile
vendored
3
Jenkinsfile
vendored
@@ -9,8 +9,9 @@ pipeline {
|
||||
|
||||
stage('Build') {
|
||||
steps {
|
||||
sh 'update-alternatives --set java /usr/lib/jvm/zulu8/jre/bin/java'
|
||||
sh 'chmod +x scripts/inst.sh'
|
||||
sh './scripts/inst.sh --setup --fast --remote'
|
||||
sh './scripts/inst.sh --setup'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<version>4.13.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -136,16 +136,41 @@
|
||||
</dependency>
|
||||
|
||||
<!-- Akarin -->
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm</artifactId>
|
||||
<version>9.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-tree</artifactId>
|
||||
<version>9.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-analysis</artifactId>
|
||||
<version>9.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-util</artifactId>
|
||||
<version>9.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-commons</artifactId>
|
||||
<version>9.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.akarin</groupId>
|
||||
<artifactId>mixin</artifactId>
|
||||
<version>0.8.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.akarin</groupId>
|
||||
<artifactId>legacylauncher</artifactId>
|
||||
<version>1.26</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spongepowered</groupId>
|
||||
<artifactId>mixin</artifactId>
|
||||
<version>0.7.11-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.concurrent-locks</groupId>
|
||||
<artifactId>concurrent-locks</artifactId>
|
||||
@@ -177,7 +202,7 @@
|
||||
</repository>
|
||||
<repository>
|
||||
<id>josephworks</id>
|
||||
<url>http://repo.josephworks.net/repository/maven-public/</url>
|
||||
<url>https://repo.josephworks.net/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sonatype-nexusg</id>
|
||||
@@ -287,6 +312,18 @@
|
||||
<exclude>org/apache/logging/log4j/**</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
<filter>
|
||||
<artifact>io.akarin:legacylauncher:**</artifact>
|
||||
<excludes>
|
||||
<exclude>org/objectweb/**</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
<filter>
|
||||
<artifact>com.destroystokyo.paper:paper-api:**</artifact>
|
||||
<excludes>
|
||||
<exclude>org/objectweb/**</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package io.akarin.server.mixin.optimization;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import net.minecraft.server.Block;
|
||||
import net.minecraft.server.BlockChest;
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.EnumDirection;
|
||||
import net.minecraft.server.IBlockData;
|
||||
import net.minecraft.server.Material;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
@Mixin(value = BlockChest.class, remap = false)
|
||||
public abstract class MixinBlockChest extends Block {
|
||||
protected MixinBlockChest(Material material) {
|
||||
super(material);
|
||||
}
|
||||
@Shadow public abstract IBlockData e(World world, BlockPosition blockposition, IBlockData iblockdata);
|
||||
@Overwrite
|
||||
public void onPlace(World world, BlockPosition blockposition, IBlockData iblockdata) {
|
||||
//((BlockChest)(Object)this).e(world, blockposition, iblockdata);
|
||||
e(world, blockposition, iblockdata);
|
||||
Iterator<EnumDirection> iterator = EnumDirection.EnumDirectionLimit.HORIZONTAL.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
EnumDirection enumdirection = iterator.next();
|
||||
BlockPosition blockposition1 = blockposition.shift(enumdirection);
|
||||
// NeonPaper start - Dont load chunks for chests
|
||||
final IBlockData iblockdata1 = world.isLoaded(blockposition1) ? world.getType(blockposition1) : null;
|
||||
if (iblockdata1 == null) {
|
||||
continue;
|
||||
}
|
||||
// NeonPaper end
|
||||
|
||||
if (iblockdata1.getBlock() == this) {
|
||||
//((BlockChest)(Object)this).e(world, blockposition1, iblockdata1);
|
||||
e(world, blockposition1, iblockdata1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package io.akarin.server.mixin.optimization;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
|
||||
import net.minecraft.server.BlockFluids;
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.BlockStationary;
|
||||
import net.minecraft.server.IBlockData;
|
||||
import net.minecraft.server.Material;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
@Mixin(value = BlockStationary.class, remap = false)
|
||||
public abstract class MixinBlockStationary extends BlockFluids {
|
||||
protected MixinBlockStationary(Material material) {
|
||||
super(material);
|
||||
}
|
||||
@Overwrite
|
||||
private boolean d(World world, BlockPosition blockposition) {
|
||||
if (blockposition.getY() >= 0 && blockposition.getY() < 256) {
|
||||
IBlockData blockData = world.getTypeIfLoaded(blockposition);
|
||||
|
||||
if (blockData != null) {
|
||||
return blockData.getMaterial().isBurnable();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package io.akarin.server.mixin.optimization;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import net.minecraft.server.Container;
|
||||
import net.minecraft.server.ContainerHorse;
|
||||
import net.minecraft.server.Entity;
|
||||
import net.minecraft.server.EntityHorseAbstract;
|
||||
import net.minecraft.server.EntityHuman;
|
||||
import net.minecraft.server.IInventory;
|
||||
|
||||
@Mixin(value = ContainerHorse.class, remap = false)
|
||||
public abstract class MixinContainerHorse extends Container {
|
||||
@Shadow private IInventory a;
|
||||
@Shadow private EntityHorseAbstract f;
|
||||
|
||||
@Overwrite
|
||||
public boolean canUse(EntityHuman entityhuman) {
|
||||
return this.a.a(entityhuman) && this.f.isAlive() && this.f.valid && this.f.g((Entity) entityhuman) < 8.0F; // NeonPaper! - Fix MC-161754
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||
import net.minecraft.server.AxisAlignedBB;
|
||||
import net.minecraft.server.Entity;
|
||||
import net.minecraft.server.Material;
|
||||
import net.minecraft.server.MathHelper;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
@@ -15,6 +16,14 @@ public abstract class MixinEntity {
|
||||
@Shadow public World world;
|
||||
@Shadow public abstract AxisAlignedBB getBoundingBox();
|
||||
|
||||
@Shadow public boolean noclip;
|
||||
@Shadow public float R;
|
||||
@Shadow public double locX;
|
||||
@Shadow public double locZ;
|
||||
@Shadow public abstract boolean x(Entity entity);
|
||||
@Shadow public abstract boolean isVehicle();
|
||||
@Shadow public abstract void f(double d0, double d1, double d2);
|
||||
|
||||
private boolean isInLava;
|
||||
private int lastLavaCheck = Integer.MIN_VALUE;
|
||||
|
||||
@@ -31,4 +40,36 @@ public abstract class MixinEntity {
|
||||
}
|
||||
return this.isInLava;
|
||||
}
|
||||
@Overwrite
|
||||
public void collide(Entity entity) {
|
||||
if (entity.noclip || this.noclip || this.x(entity)) return; // NeonPaper - Test this earlier
|
||||
double d0 = entity.locX - this.locX;
|
||||
double d1 = entity.locZ - this.locZ;
|
||||
double d2 = MathHelper.a(d0, d1);
|
||||
|
||||
if (d2 >= 0.009999999776482582D) {
|
||||
d2 = (double) MathHelper.sqrt(d2);
|
||||
d0 /= d2;
|
||||
d1 /= d2;
|
||||
double d3 = 1.0D / d2;
|
||||
|
||||
if (d3 > 1.0D) {
|
||||
d3 = 1.0D;
|
||||
}
|
||||
|
||||
d0 *= d3;
|
||||
d1 *= d3;
|
||||
d0 *= 0.05000000074505806D;
|
||||
d1 *= 0.05000000074505806D;
|
||||
d0 *= (double) (1.0F - this.R);
|
||||
d1 *= (double) (1.0F - this.R);
|
||||
if (!this.isVehicle()) {
|
||||
this.f(-d0, 0.0D, -d1);
|
||||
}
|
||||
|
||||
if (!entity.isVehicle()) {
|
||||
entity.f(d0, 0.0D, d1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,30 @@
|
||||
package net.minecraft.server;
|
||||
package io.akarin.server.mixin.optimization;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import org.bukkit.event.player.PlayerShearEntityEvent; // CraftBukkit
|
||||
import org.bukkit.event.player.PlayerShearEntityEvent;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
|
||||
public class EntityMushroomCow extends EntityCow {
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.EntityCow;
|
||||
import net.minecraft.server.EntityHuman;
|
||||
import net.minecraft.server.EntityItem;
|
||||
import net.minecraft.server.EntityMushroomCow;
|
||||
import net.minecraft.server.EnumHand;
|
||||
import net.minecraft.server.EnumParticle;
|
||||
import net.minecraft.server.ItemStack;
|
||||
import net.minecraft.server.Items;
|
||||
import net.minecraft.server.SoundEffects;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
public EntityMushroomCow(World world) {
|
||||
super(world);
|
||||
this.setSize(0.9F, 1.4F);
|
||||
this.bA = Blocks.MYCELIUM;
|
||||
}
|
||||
@Mixin(value = EntityMushroomCow.class, remap = false)
|
||||
public abstract class MixinEntityMushroomCow extends EntityCow {
|
||||
|
||||
public static void c(DataConverterManager dataconvertermanager) {
|
||||
EntityInsentient.a(dataconvertermanager, EntityMushroomCow.class);
|
||||
}
|
||||
|
||||
public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
|
||||
public MixinEntityMushroomCow(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
@Overwrite
|
||||
public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
|
||||
ItemStack itemstack = entityhuman.b(enumhand);
|
||||
|
||||
if (itemstack.getItem() == Items.BOWL && this.getAge() >= 0 && !entityhuman.abilities.canInstantlyBuild) {
|
||||
@@ -65,20 +74,4 @@ public class EntityMushroomCow extends EntityCow {
|
||||
}
|
||||
}
|
||||
|
||||
public EntityMushroomCow c(EntityAgeable entityageable) {
|
||||
return new EntityMushroomCow(this.world);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected MinecraftKey J() {
|
||||
return LootTables.M;
|
||||
}
|
||||
|
||||
public EntityCow b(EntityAgeable entityageable) {
|
||||
return this.c(entityageable);
|
||||
}
|
||||
|
||||
public EntityAgeable createChild(EntityAgeable entityageable) {
|
||||
return this.c(entityageable);
|
||||
}
|
||||
}
|
||||
@@ -1,58 +1,68 @@
|
||||
package net.minecraft.server;
|
||||
package io.akarin.server.mixin.optimization;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
import org.bukkit.event.block.BlockExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
import net.minecraft.server.AxisAlignedBB;
|
||||
import net.minecraft.server.Block;
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.Chunk;
|
||||
import net.minecraft.server.ChunkSection;
|
||||
import net.minecraft.server.DamageSource;
|
||||
import net.minecraft.server.EnchantmentProtection;
|
||||
import net.minecraft.server.Entity;
|
||||
import net.minecraft.server.EntityFallingBlock;
|
||||
import net.minecraft.server.EntityHuman;
|
||||
import net.minecraft.server.EntityLiving;
|
||||
import net.minecraft.server.EntityTNTPrimed;
|
||||
import net.minecraft.server.EnumParticle;
|
||||
import net.minecraft.server.Explosion;
|
||||
import net.minecraft.server.IBlockData;
|
||||
import net.minecraft.server.Material;
|
||||
import net.minecraft.server.MathHelper;
|
||||
import net.minecraft.server.SoundCategory;
|
||||
import net.minecraft.server.SoundEffects;
|
||||
import net.minecraft.server.Vec3D;
|
||||
import net.minecraft.server.World;
|
||||
import net.minecraft.server.IEntitySelector;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.block.BlockExplodeEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
public class Explosion {
|
||||
|
||||
private final boolean a;
|
||||
private final boolean b;
|
||||
private final Random c = new Random();
|
||||
private final World world;
|
||||
private final double posX;
|
||||
private final double posY;
|
||||
private final double posZ;
|
||||
public final Entity source;
|
||||
private final float size;
|
||||
private final ArrayList<BlockPosition> blocks = Lists.newArrayList();
|
||||
private final Map<EntityHuman, Vec3D> k = Maps.newHashMap();
|
||||
public boolean wasCanceled = false; // CraftBukkit - add field
|
||||
|
||||
// Dionysus start
|
||||
@Mixin(value = Explosion.class, remap = false)
|
||||
public abstract class MixinExplosion {
|
||||
@Shadow private boolean a;
|
||||
@Shadow private boolean b;
|
||||
@Shadow private Random c = new Random();
|
||||
@Shadow private World world;
|
||||
@Shadow private double posX;
|
||||
@Shadow private double posY;
|
||||
@Shadow private double posZ;
|
||||
@Shadow public Entity source;
|
||||
@Shadow private float size;
|
||||
@Shadow private Map<EntityHuman, Vec3D> k;
|
||||
@Shadow public boolean wasCanceled = false; // CraftBukkit - add field
|
||||
@Shadow private List<BlockPosition> blocks;
|
||||
private final BlockPosition.MutableBlockPosition cachedPos = new BlockPosition.MutableBlockPosition();
|
||||
// The chunk coordinate of the most recently stepped through block.
|
||||
private int prevChunkX = Integer.MIN_VALUE;
|
||||
private int prevChunkZ = Integer.MIN_VALUE;
|
||||
|
||||
// The chunk belonging to prevChunkPos.
|
||||
private Chunk prevChunk;
|
||||
|
||||
private static final com.google.common.base.Predicate<Entity> hitPredicate = entity -> IEntitySelector.d.apply(entity) && !entity.dead; // Dionysus - Paper - don't hit dead entities
|
||||
// Dionysus end
|
||||
|
||||
public Explosion(World world, Entity entity, double d0, double d1, double d2, float f, boolean flag, boolean flag1) {
|
||||
this.world = world;
|
||||
this.source = entity;
|
||||
this.size = (float) Math.max(f, 0.0); // CraftBukkit - clamp bad values
|
||||
this.posX = d0;
|
||||
this.posY = d1;
|
||||
this.posZ = d2;
|
||||
this.a = flag;
|
||||
this.b = flag1;
|
||||
}
|
||||
|
||||
|
||||
@Overwrite
|
||||
public void a() {
|
||||
// CraftBukkit start
|
||||
if (this.size < 0.1F) {
|
||||
@@ -94,9 +104,9 @@ public class Explosion {
|
||||
// We can now iterate back over the set of positions we modified and re-build BlockPos objects from them
|
||||
// This will only allocate as many objects as there are in the set, where otherwise we would allocate them
|
||||
// each step of a every ray.
|
||||
blocks.ensureCapacity(touched.size());
|
||||
((ArrayList<BlockPosition>)this.blocks).ensureCapacity(touched.size());
|
||||
for (Long longPos : touched) {
|
||||
blocks.add(BlockPosition.fromLong(longPos));
|
||||
this.blocks.add(BlockPosition.fromLong(longPos));
|
||||
}
|
||||
float f3 = this.size * 2.0F;
|
||||
|
||||
@@ -133,7 +143,7 @@ public class Explosion {
|
||||
// entity.damageEntity(DamageSource.explosion(this), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f3 + 1.0D)));
|
||||
CraftEventFactory.entityDamage = source;
|
||||
entity.forceExplosionKnockback = false;
|
||||
boolean wasDamaged = entity.damageEntity(DamageSource.explosion(this), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f3 + 1.0D)));
|
||||
boolean wasDamaged = entity.damageEntity(DamageSource.explosion((Explosion)(Object)this), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f3 + 1.0D)));
|
||||
CraftEventFactory.entityDamage = null;
|
||||
if (!wasDamaged && !(entity instanceof EntityTNTPrimed || entity instanceof EntityFallingBlock) && !entity.forceExplosionKnockback) {
|
||||
continue;
|
||||
@@ -161,7 +171,6 @@ public class Explosion {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void performRayCast(Random random, double vecX, double vecY, double vecZ, LongOpenHashSet touched) {
|
||||
double dist = Math.sqrt((vecX * vecX) + (vecY * vecY) + (vecZ * vecZ));
|
||||
|
||||
@@ -214,7 +223,6 @@ public class Explosion {
|
||||
stepZ += normZ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called for every step made by a ray being cast by an explosion.
|
||||
*
|
||||
@@ -231,7 +239,7 @@ public class Explosion {
|
||||
// Early-exit if the y-coordinate is out of bounds.
|
||||
if (cachedPos.isInvalidYLocation()) {
|
||||
if (iblockdata.getMaterial() != Material.AIR) {
|
||||
float blastResistance = this.source != null ? this.source.a(this, this.world, cachedPos, iblockdata) : iblockdata.getBlock().a((Entity) null);
|
||||
float blastResistance = this.source != null ? this.source.a((Explosion)(Object)this, this.world, cachedPos, iblockdata) : iblockdata.getBlock().a((Entity) null);
|
||||
return (blastResistance + 0.3F) * 0.3F;
|
||||
}
|
||||
return 0.0F;
|
||||
@@ -268,7 +276,7 @@ public class Explosion {
|
||||
// If the block state is air, it cannot have fluid or any kind of resistance, so just leave
|
||||
if (blockState.getBlock() != Blocks.AIR) {
|
||||
// Get the explosion resistance like vanilla
|
||||
blastResistance = Optional.of(this.source != null ? this.source.a(this, this.world, cachedPos, iblockdata) : iblockdata.getBlock().a((Entity) null));
|
||||
blastResistance = Optional.of(this.source != null ? this.source.a((Explosion)(Object)this, this.world, cachedPos, iblockdata) : iblockdata.getBlock().a((Entity) null));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -282,16 +290,14 @@ public class Explosion {
|
||||
// of positions to destroy
|
||||
float reducedStrength = strength - totalResistance;
|
||||
if (reducedStrength > 0.0F && (this.a || iblockdata.getMaterial() != Material.AIR)) {
|
||||
if ((this.source == null || this.source.a(this, this.world, cachedPos, iblockdata, reducedStrength)) && cachedPos.getY() < 256 && cachedPos.getY() >= 0) {
|
||||
if ((this.source == null || this.source.a((Explosion)(Object)this, this.world, cachedPos, iblockdata, reducedStrength)) && cachedPos.getY() < 256 && cachedPos.getY() >= 0) {
|
||||
touched.add(cachedPos.asLong());
|
||||
}
|
||||
}
|
||||
|
||||
return totalResistance;
|
||||
}
|
||||
// Dionysus end
|
||||
|
||||
|
||||
@Overwrite
|
||||
public void a(boolean flag) {
|
||||
this.world.a((EntityHuman) null, this.posX, this.posY, this.posZ, SoundEffects.bV, SoundCategory.BLOCKS, 4.0F, (1.0F + (this.world.random.nextFloat() - this.world.random.nextFloat()) * 0.2F) * 0.7F);
|
||||
if (this.size >= 2.0F && this.b) {
|
||||
@@ -300,7 +306,7 @@ public class Explosion {
|
||||
this.world.addParticle(EnumParticle.EXPLOSION_LARGE, this.posX, this.posY, this.posZ, 1.0D, 0.0D, 0.0D);
|
||||
}
|
||||
|
||||
Iterator iterator;
|
||||
Iterator<BlockPosition> iterator;
|
||||
BlockPosition blockposition;
|
||||
|
||||
if (this.b) {
|
||||
@@ -338,7 +344,7 @@ public class Explosion {
|
||||
|
||||
this.blocks.clear();
|
||||
|
||||
this.blocks.ensureCapacity(bukkitBlocks.size());
|
||||
((ArrayList<BlockPosition>)this.blocks).ensureCapacity(bukkitBlocks.size());
|
||||
for (org.bukkit.block.Block bblock : bukkitBlocks) {
|
||||
BlockPosition coords = new BlockPosition(bblock.getX(), bblock.getY(), bblock.getZ());
|
||||
blocks.add(coords);
|
||||
@@ -380,13 +386,13 @@ public class Explosion {
|
||||
}
|
||||
|
||||
if (iblockdata.getMaterial() != Material.AIR) {
|
||||
if (block.a(this)) {
|
||||
if (block.a((Explosion)(Object)this)) {
|
||||
// CraftBukkit - add yield
|
||||
block.dropNaturally(this.world, blockposition, this.world.getType(blockposition), yield, 0);
|
||||
}
|
||||
|
||||
this.world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3);
|
||||
block.wasExploded(this.world, blockposition, this);
|
||||
block.wasExploded(this.world, blockposition, (Explosion)(Object)this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -398,7 +404,7 @@ public class Explosion {
|
||||
blockposition = (BlockPosition) iterator.next();
|
||||
if (this.world.getType(blockposition).getMaterial() == Material.AIR && this.world.getType(blockposition.down()).b() && this.c.nextInt(3) == 0) {
|
||||
// CraftBukkit start - Ignition by explosion
|
||||
if (!CraftEventFactory.callBlockIgniteEvent(this.world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this).isCancelled()) {
|
||||
if (!CraftEventFactory.callBlockIgniteEvent(this.world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), (Explosion)(Object)this).isCancelled()) {
|
||||
this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
|
||||
}
|
||||
// CraftBukkit end
|
||||
@@ -407,98 +413,14 @@ public class Explosion {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Map<EntityHuman, Vec3D> b() {
|
||||
return this.k;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EntityLiving getSource() {
|
||||
// CraftBukkit start - obtain Fireball shooter for explosion tracking
|
||||
return this.source == null ? null : (this.source instanceof EntityTNTPrimed ? ((EntityTNTPrimed) this.source).getSource() : (this.source instanceof EntityLiving ? (EntityLiving) this.source : (this.source instanceof EntityFireball ? ((EntityFireball) this.source).shooter : null)));
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
public void clearBlocks() {
|
||||
this.blocks.clear();
|
||||
}
|
||||
|
||||
public List<BlockPosition> getBlocks() {
|
||||
return this.blocks;
|
||||
}
|
||||
|
||||
// Paper start - Optimize explosions
|
||||
private float getBlockDensity(Vec3D vec3d, AxisAlignedBB aabb) {
|
||||
if (!this.world.paperConfig.optimizeExplosions) {
|
||||
return this.world.a(vec3d, aabb);
|
||||
}
|
||||
CacheKey key = new CacheKey(this, aabb);
|
||||
return this.world.explosionDensityCache.computeIfAbsent(key, k1 -> this.world.a(vec3d, aabb));
|
||||
}
|
||||
|
||||
static class CacheKey {
|
||||
private final World world;
|
||||
private final double posX, posY, posZ;
|
||||
private final double minX, minY, minZ;
|
||||
private final double maxX, maxY, maxZ;
|
||||
|
||||
public CacheKey(Explosion explosion, AxisAlignedBB aabb) {
|
||||
this.world = explosion.world;
|
||||
this.posX = explosion.posX;
|
||||
this.posY = explosion.posY;
|
||||
this.posZ = explosion.posZ;
|
||||
this.minX = aabb.a;
|
||||
this.minY = aabb.b;
|
||||
this.minZ = aabb.c;
|
||||
this.maxX = aabb.d;
|
||||
this.maxY = aabb.e;
|
||||
this.maxZ = aabb.f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
CacheKey cacheKey = (CacheKey) o;
|
||||
|
||||
if (Double.compare(cacheKey.posX, posX) != 0) return false;
|
||||
if (Double.compare(cacheKey.posY, posY) != 0) return false;
|
||||
if (Double.compare(cacheKey.posZ, posZ) != 0) return false;
|
||||
if (Double.compare(cacheKey.minX, minX) != 0) return false;
|
||||
if (Double.compare(cacheKey.minY, minY) != 0) return false;
|
||||
if (Double.compare(cacheKey.minZ, minZ) != 0) return false;
|
||||
if (Double.compare(cacheKey.maxX, maxX) != 0) return false;
|
||||
if (Double.compare(cacheKey.maxY, maxY) != 0) return false;
|
||||
if (Double.compare(cacheKey.maxZ, maxZ) != 0) return false;
|
||||
return world.equals(cacheKey.world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result;
|
||||
long temp;
|
||||
result = world.hashCode();
|
||||
temp = Double.doubleToLongBits(posX);
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(posY);
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(posZ);
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(minX);
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(minY);
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(minZ);
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(maxX);
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(maxY);
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(maxZ);
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@Shadow protected abstract float getBlockDensity(Vec3D vec3d, AxisAlignedBB aabb);
|
||||
//private float getBlockDensity(Vec3D vec3d, AxisAlignedBB aabb) {
|
||||
//if (!this.world.paperConfig.optimizeExplosions) {
|
||||
// return this.world.a(vec3d, aabb);
|
||||
//}
|
||||
//CacheKey key = new CacheKey((Explosion)(Object)this, aabb);
|
||||
//return this.world.explosionDensityCache.computeIfAbsent(key, k1 -> this.world.a(vec3d, aabb));
|
||||
//}
|
||||
// Paper end
|
||||
// Dionysus end
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package io.akarin.server.mixin.optimization;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
|
||||
import net.minecraft.server.MathHelper;
|
||||
|
||||
@Mixin(value = MathHelper.class, remap = false)
|
||||
public abstract class MixinMathHelper {
|
||||
private static final int[] SINE_TABLE_INT = new int[16384 + 1];
|
||||
private static final float SINE_TABLE_MIDPOINT;
|
||||
@Overwrite
|
||||
public static float sin(float f) {
|
||||
return lookup((int) (f * 10430.38) & 0xFFFF);
|
||||
}
|
||||
@Overwrite
|
||||
public static float cos(float f) {
|
||||
return lookup((int) (f * 10430.38 + 16384.0) & 0xFFFF);
|
||||
}
|
||||
private static float lookup(int index) {
|
||||
if (index == 32768) {
|
||||
return SINE_TABLE_MIDPOINT;
|
||||
}
|
||||
int neg = (index & 0x8000) << 16;
|
||||
int mask = (index << 17) >> 31;
|
||||
int pos = (0x8001 & mask) + (index ^ mask);
|
||||
pos &= 0x7fff;
|
||||
return Float.intBitsToFloat(SINE_TABLE_INT[pos] ^ neg);
|
||||
}
|
||||
static {
|
||||
int i;
|
||||
|
||||
final float[] SINE_TABLE = new float[65536];
|
||||
for (i = 0; i < 65536; ++i) {
|
||||
SINE_TABLE[i] = (float) Math.sin((double) i * 3.141592653589793D * 2.0D / 65536.0D);
|
||||
}
|
||||
for (i = 0; i < SINE_TABLE_INT.length; i++) {
|
||||
SINE_TABLE_INT[i] = Float.floatToRawIntBits(SINE_TABLE[i]);
|
||||
}
|
||||
|
||||
SINE_TABLE_MIDPOINT = SINE_TABLE[SINE_TABLE.length / 2];
|
||||
for (i = 0; i < SINE_TABLE.length; i++) {
|
||||
float expected = SINE_TABLE[i];
|
||||
float value = lookup(i);
|
||||
|
||||
if (expected != value) {
|
||||
throw new IllegalArgumentException(String.format("LUT error at index %d (expected: %s, found: %s)", i, expected, value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,479 +0,0 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import java.util.Iterator;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BlockChest extends BlockTileEntity {
|
||||
|
||||
public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING;
|
||||
protected static final AxisAlignedBB b = new AxisAlignedBB(0.0625D, 0.0D, 0.0D, 0.9375D, 0.875D, 0.9375D);
|
||||
protected static final AxisAlignedBB c = new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 0.875D, 1.0D);
|
||||
protected static final AxisAlignedBB d = new AxisAlignedBB(0.0D, 0.0D, 0.0625D, 0.9375D, 0.875D, 0.9375D);
|
||||
protected static final AxisAlignedBB e = new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 1.0D, 0.875D, 0.9375D);
|
||||
protected static final AxisAlignedBB f = new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 0.875D, 0.9375D);
|
||||
public final BlockChest.Type g;
|
||||
|
||||
protected BlockChest(BlockChest.Type blockchest_type) {
|
||||
super(Material.WOOD);
|
||||
this.w(this.blockStateList.getBlockData().set(BlockChest.FACING, EnumDirection.NORTH));
|
||||
this.g = blockchest_type;
|
||||
this.a(blockchest_type == BlockChest.Type.TRAP ? CreativeModeTab.d : CreativeModeTab.c);
|
||||
}
|
||||
|
||||
public boolean b(IBlockData iblockdata) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean c(IBlockData iblockdata) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public EnumRenderType a(IBlockData iblockdata) {
|
||||
return EnumRenderType.ENTITYBLOCK_ANIMATED;
|
||||
}
|
||||
|
||||
public AxisAlignedBB b(IBlockData iblockdata, IBlockAccess iblockaccess, BlockPosition blockposition) {
|
||||
return iblockaccess.getType(blockposition.north()).getBlock() == this ? BlockChest.b : (iblockaccess.getType(blockposition.south()).getBlock() == this ? BlockChest.c : (iblockaccess.getType(blockposition.west()).getBlock() == this ? BlockChest.d : (iblockaccess.getType(blockposition.east()).getBlock() == this ? BlockChest.e : BlockChest.f)));
|
||||
}
|
||||
|
||||
public void onPlace(World world, BlockPosition blockposition, IBlockData iblockdata) {
|
||||
this.e(world, blockposition, iblockdata);
|
||||
Iterator iterator = EnumDirection.EnumDirectionLimit.HORIZONTAL.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
EnumDirection enumdirection = (EnumDirection) iterator.next();
|
||||
BlockPosition blockposition1 = blockposition.shift(enumdirection);
|
||||
// NeonPaper start - Dont load chunks for chests
|
||||
final IBlockData iblockdata1 = world.isLoaded(blockposition1) ? world.getType(blockposition1) : null;
|
||||
if (iblockdata1 == null) {
|
||||
continue;
|
||||
}
|
||||
// NeonPaper end
|
||||
|
||||
if (iblockdata1.getBlock() == this) {
|
||||
this.e(world, blockposition1, iblockdata1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public IBlockData getPlacedState(World world, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2, int i, EntityLiving entityliving) {
|
||||
return this.getBlockData().set(BlockChest.FACING, entityliving.getDirection());
|
||||
}
|
||||
|
||||
public void postPlace(World world, BlockPosition blockposition, IBlockData iblockdata, EntityLiving entityliving, ItemStack itemstack) {
|
||||
EnumDirection enumdirection = EnumDirection.fromType2(MathHelper.floor((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3).opposite();
|
||||
|
||||
iblockdata = iblockdata.set(BlockChest.FACING, enumdirection);
|
||||
BlockPosition blockposition1 = blockposition.north();
|
||||
BlockPosition blockposition2 = blockposition.south();
|
||||
BlockPosition blockposition3 = blockposition.west();
|
||||
BlockPosition blockposition4 = blockposition.east();
|
||||
boolean flag = this == world.getType(blockposition1).getBlock();
|
||||
boolean flag1 = this == world.getType(blockposition2).getBlock();
|
||||
boolean flag2 = this == world.getType(blockposition3).getBlock();
|
||||
boolean flag3 = this == world.getType(blockposition4).getBlock();
|
||||
|
||||
if (!flag && !flag1 && !flag2 && !flag3) {
|
||||
world.setTypeAndData(blockposition, iblockdata, 3);
|
||||
} else if (enumdirection.k() == EnumDirection.EnumAxis.X && (flag || flag1)) {
|
||||
if (flag) {
|
||||
world.setTypeAndData(blockposition1, iblockdata, 3);
|
||||
} else {
|
||||
world.setTypeAndData(blockposition2, iblockdata, 3);
|
||||
}
|
||||
|
||||
world.setTypeAndData(blockposition, iblockdata, 3);
|
||||
} else if (enumdirection.k() == EnumDirection.EnumAxis.Z && (flag2 || flag3)) {
|
||||
if (flag2) {
|
||||
world.setTypeAndData(blockposition3, iblockdata, 3);
|
||||
} else {
|
||||
world.setTypeAndData(blockposition4, iblockdata, 3);
|
||||
}
|
||||
|
||||
world.setTypeAndData(blockposition, iblockdata, 3);
|
||||
}
|
||||
|
||||
if (itemstack.hasName()) {
|
||||
TileEntity tileentity = world.getTileEntity(blockposition);
|
||||
|
||||
if (tileentity instanceof TileEntityChest) {
|
||||
((TileEntityChest) tileentity).setCustomName(itemstack.getName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public IBlockData e(World world, BlockPosition blockposition, IBlockData iblockdata) {
|
||||
if (world.isClientSide) {
|
||||
return iblockdata;
|
||||
} else {
|
||||
IBlockData iblockdata1 = world.getType(blockposition.north());
|
||||
IBlockData iblockdata2 = world.getType(blockposition.south());
|
||||
IBlockData iblockdata3 = world.getType(blockposition.west());
|
||||
IBlockData iblockdata4 = world.getType(blockposition.east());
|
||||
EnumDirection enumdirection = (EnumDirection) iblockdata.get(BlockChest.FACING);
|
||||
|
||||
if (iblockdata1.getBlock() != this && iblockdata2.getBlock() != this) {
|
||||
boolean flag = iblockdata1.b();
|
||||
boolean flag1 = iblockdata2.b();
|
||||
|
||||
if (iblockdata3.getBlock() == this || iblockdata4.getBlock() == this) {
|
||||
BlockPosition blockposition1 = iblockdata3.getBlock() == this ? blockposition.west() : blockposition.east();
|
||||
IBlockData iblockdata5 = world.getType(blockposition1.north());
|
||||
IBlockData iblockdata6 = world.getType(blockposition1.south());
|
||||
|
||||
enumdirection = EnumDirection.SOUTH;
|
||||
EnumDirection enumdirection1;
|
||||
|
||||
if (iblockdata3.getBlock() == this) {
|
||||
enumdirection1 = (EnumDirection) iblockdata3.get(BlockChest.FACING);
|
||||
} else {
|
||||
enumdirection1 = (EnumDirection) iblockdata4.get(BlockChest.FACING);
|
||||
}
|
||||
|
||||
if (enumdirection1 == EnumDirection.NORTH) {
|
||||
enumdirection = EnumDirection.NORTH;
|
||||
}
|
||||
|
||||
if ((flag || iblockdata5.b()) && !flag1 && !iblockdata6.b()) {
|
||||
enumdirection = EnumDirection.SOUTH;
|
||||
}
|
||||
|
||||
if ((flag1 || iblockdata6.b()) && !flag && !iblockdata5.b()) {
|
||||
enumdirection = EnumDirection.NORTH;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
BlockPosition blockposition2 = iblockdata1.getBlock() == this ? blockposition.north() : blockposition.south();
|
||||
IBlockData iblockdata7 = world.getType(blockposition2.west());
|
||||
IBlockData iblockdata8 = world.getType(blockposition2.east());
|
||||
|
||||
enumdirection = EnumDirection.EAST;
|
||||
EnumDirection enumdirection2;
|
||||
|
||||
if (iblockdata1.getBlock() == this) {
|
||||
enumdirection2 = (EnumDirection) iblockdata1.get(BlockChest.FACING);
|
||||
} else {
|
||||
enumdirection2 = (EnumDirection) iblockdata2.get(BlockChest.FACING);
|
||||
}
|
||||
|
||||
if (enumdirection2 == EnumDirection.WEST) {
|
||||
enumdirection = EnumDirection.WEST;
|
||||
}
|
||||
|
||||
if ((iblockdata3.b() || iblockdata7.b()) && !iblockdata4.b() && !iblockdata8.b()) {
|
||||
enumdirection = EnumDirection.EAST;
|
||||
}
|
||||
|
||||
if ((iblockdata4.b() || iblockdata8.b()) && !iblockdata3.b() && !iblockdata7.b()) {
|
||||
enumdirection = EnumDirection.WEST;
|
||||
}
|
||||
}
|
||||
|
||||
iblockdata = iblockdata.set(BlockChest.FACING, enumdirection);
|
||||
world.setTypeAndData(blockposition, iblockdata, 3);
|
||||
return iblockdata;
|
||||
}
|
||||
}
|
||||
|
||||
public IBlockData f(World world, BlockPosition blockposition, IBlockData iblockdata) {
|
||||
EnumDirection enumdirection = null;
|
||||
Iterator iterator = EnumDirection.EnumDirectionLimit.HORIZONTAL.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
EnumDirection enumdirection1 = (EnumDirection) iterator.next();
|
||||
IBlockData iblockdata1 = world.getType(blockposition.shift(enumdirection1));
|
||||
|
||||
if (iblockdata1.getBlock() == this) {
|
||||
return iblockdata;
|
||||
}
|
||||
|
||||
if (iblockdata1.b()) {
|
||||
if (enumdirection != null) {
|
||||
enumdirection = null;
|
||||
break;
|
||||
}
|
||||
|
||||
enumdirection = enumdirection1;
|
||||
}
|
||||
}
|
||||
|
||||
if (enumdirection != null) {
|
||||
return iblockdata.set(BlockChest.FACING, enumdirection.opposite());
|
||||
} else {
|
||||
EnumDirection enumdirection2 = (EnumDirection) iblockdata.get(BlockChest.FACING);
|
||||
|
||||
if (world.getType(blockposition.shift(enumdirection2)).b()) {
|
||||
enumdirection2 = enumdirection2.opposite();
|
||||
}
|
||||
|
||||
if (world.getType(blockposition.shift(enumdirection2)).b()) {
|
||||
enumdirection2 = enumdirection2.e();
|
||||
}
|
||||
|
||||
if (world.getType(blockposition.shift(enumdirection2)).b()) {
|
||||
enumdirection2 = enumdirection2.opposite();
|
||||
}
|
||||
|
||||
return iblockdata.set(BlockChest.FACING, enumdirection2);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canPlace(World world, BlockPosition blockposition) {
|
||||
int i = 0;
|
||||
BlockPosition blockposition1 = blockposition.west();
|
||||
BlockPosition blockposition2 = blockposition.east();
|
||||
BlockPosition blockposition3 = blockposition.north();
|
||||
BlockPosition blockposition4 = blockposition.south();
|
||||
|
||||
if (world.getType(blockposition1).getBlock() == this) {
|
||||
if (this.d(world, blockposition1)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
if (world.getType(blockposition2).getBlock() == this) {
|
||||
if (this.d(world, blockposition2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
if (world.getType(blockposition3).getBlock() == this) {
|
||||
if (this.d(world, blockposition3)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
if (world.getType(blockposition4).getBlock() == this) {
|
||||
if (this.d(world, blockposition4)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
return i <= 1;
|
||||
}
|
||||
|
||||
private boolean d(World world, BlockPosition blockposition) {
|
||||
if (world.getType(blockposition).getBlock() != this) {
|
||||
return false;
|
||||
} else {
|
||||
Iterator iterator = EnumDirection.EnumDirectionLimit.HORIZONTAL.iterator();
|
||||
|
||||
EnumDirection enumdirection;
|
||||
|
||||
do {
|
||||
if (!iterator.hasNext()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
enumdirection = (EnumDirection) iterator.next();
|
||||
} while (world.getType(blockposition.shift(enumdirection)).getBlock() != this);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1) {
|
||||
super.a(iblockdata, world, blockposition, block, blockposition1);
|
||||
TileEntity tileentity = world.getTileEntity(blockposition);
|
||||
|
||||
if (tileentity instanceof TileEntityChest) {
|
||||
tileentity.invalidateBlockCache();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) {
|
||||
TileEntity tileentity = world.getTileEntity(blockposition);
|
||||
|
||||
if (tileentity instanceof IInventory) {
|
||||
InventoryUtils.dropInventory(world, blockposition, (IInventory) tileentity);
|
||||
world.updateAdjacentComparators(blockposition, this);
|
||||
}
|
||||
|
||||
super.remove(world, blockposition, iblockdata);
|
||||
}
|
||||
|
||||
public boolean interact(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman, EnumHand enumhand, EnumDirection enumdirection, float f, float f1, float f2) {
|
||||
if (world.isClientSide) {
|
||||
return true;
|
||||
} else {
|
||||
ITileInventory itileinventory = this.getInventory(world, blockposition);
|
||||
|
||||
if (itileinventory != null) {
|
||||
entityhuman.openContainer(itileinventory);
|
||||
if (this.g == BlockChest.Type.BASIC) {
|
||||
entityhuman.b(StatisticList.aa);
|
||||
} else if (this.g == BlockChest.Type.TRAP) {
|
||||
entityhuman.b(StatisticList.U);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ITileInventory getInventory(World world, BlockPosition blockposition) {
|
||||
return this.a(world, blockposition, false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ITileInventory a(World world, BlockPosition blockposition, boolean flag) {
|
||||
TileEntity tileentity = world.getTileEntity(blockposition);
|
||||
|
||||
if (!(tileentity instanceof TileEntityChest)) {
|
||||
return null;
|
||||
} else {
|
||||
Object object = (TileEntityChest) tileentity;
|
||||
|
||||
if (!flag && this.e(world, blockposition)) {
|
||||
return null;
|
||||
} else {
|
||||
Iterator iterator = EnumDirection.EnumDirectionLimit.HORIZONTAL.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
EnumDirection enumdirection = (EnumDirection) iterator.next();
|
||||
BlockPosition blockposition1 = blockposition.shift(enumdirection);
|
||||
// Paper start - don't load chunks if the other side of the chest is in unloaded chunk
|
||||
final IBlockData type = world.getTypeIfLoaded(blockposition1); // Paper
|
||||
if (type == null) {
|
||||
continue;
|
||||
}
|
||||
Block block = type.getBlock();
|
||||
// Paper end
|
||||
|
||||
if (block == this) {
|
||||
if (!flag && this.e(world, blockposition1)) { // Paper - check for allowBlocked flag - MC-99321
|
||||
return null;
|
||||
}
|
||||
|
||||
TileEntity tileentity1 = world.getTileEntity(blockposition1);
|
||||
|
||||
if (tileentity1 instanceof TileEntityChest) {
|
||||
if (enumdirection != EnumDirection.WEST && enumdirection != EnumDirection.NORTH) {
|
||||
object = new InventoryLargeChest("container.chestDouble", (ITileInventory) object, (TileEntityChest) tileentity1);
|
||||
} else {
|
||||
object = new InventoryLargeChest("container.chestDouble", (TileEntityChest) tileentity1, (ITileInventory) object);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (ITileInventory) object;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TileEntity a(World world, int i) {
|
||||
return new TileEntityChest();
|
||||
}
|
||||
|
||||
public boolean isPowerSource(IBlockData iblockdata) {
|
||||
return this.g == BlockChest.Type.TRAP;
|
||||
}
|
||||
|
||||
public int b(IBlockData iblockdata, IBlockAccess iblockaccess, BlockPosition blockposition, EnumDirection enumdirection) {
|
||||
if (!iblockdata.m()) {
|
||||
return 0;
|
||||
} else {
|
||||
int i = 0;
|
||||
TileEntity tileentity = iblockaccess.getTileEntity(blockposition);
|
||||
|
||||
if (tileentity instanceof TileEntityChest) {
|
||||
i = ((TileEntityChest) tileentity).l;
|
||||
}
|
||||
|
||||
return MathHelper.clamp(i, 0, 15);
|
||||
}
|
||||
}
|
||||
|
||||
public int c(IBlockData iblockdata, IBlockAccess iblockaccess, BlockPosition blockposition, EnumDirection enumdirection) {
|
||||
return enumdirection == EnumDirection.UP ? iblockdata.a(iblockaccess, blockposition, enumdirection) : 0;
|
||||
}
|
||||
|
||||
private boolean e(World world, BlockPosition blockposition) {
|
||||
return this.i(world, blockposition) || this.j(world, blockposition);
|
||||
}
|
||||
|
||||
private boolean i(World world, BlockPosition blockposition) {
|
||||
return world.getType(blockposition.up()).l();
|
||||
}
|
||||
|
||||
private boolean j(World world, BlockPosition blockposition) {
|
||||
// Paper start - Option ti dsiable chest cat detection
|
||||
if (world.paperConfig.disableChestCatDetection) {
|
||||
return false;
|
||||
}
|
||||
// Paper end
|
||||
Iterator iterator = world.a(EntityOcelot.class, new AxisAlignedBB((double) blockposition.getX(), (double) (blockposition.getY() + 1), (double) blockposition.getZ(), (double) (blockposition.getX() + 1), (double) (blockposition.getY() + 2), (double) (blockposition.getZ() + 1))).iterator();
|
||||
|
||||
EntityOcelot entityocelot;
|
||||
|
||||
do {
|
||||
if (!iterator.hasNext()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) iterator.next();
|
||||
|
||||
entityocelot = (EntityOcelot) entity;
|
||||
} while (!entityocelot.isSitting());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isComplexRedstone(IBlockData iblockdata) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public int c(IBlockData iblockdata, World world, BlockPosition blockposition) {
|
||||
return Container.b((IInventory) this.getInventory(world, blockposition));
|
||||
}
|
||||
|
||||
public IBlockData fromLegacyData(int i) {
|
||||
EnumDirection enumdirection = EnumDirection.fromType1(i);
|
||||
|
||||
if (enumdirection.k() == EnumDirection.EnumAxis.Y) {
|
||||
enumdirection = EnumDirection.NORTH;
|
||||
}
|
||||
|
||||
return this.getBlockData().set(BlockChest.FACING, enumdirection);
|
||||
}
|
||||
|
||||
public int toLegacyData(IBlockData iblockdata) {
|
||||
return ((EnumDirection) iblockdata.get(BlockChest.FACING)).a();
|
||||
}
|
||||
|
||||
public IBlockData a(IBlockData iblockdata, EnumBlockRotation enumblockrotation) {
|
||||
return iblockdata.set(BlockChest.FACING, enumblockrotation.a((EnumDirection) iblockdata.get(BlockChest.FACING)));
|
||||
}
|
||||
|
||||
public IBlockData a(IBlockData iblockdata, EnumBlockMirror enumblockmirror) {
|
||||
return iblockdata.a(enumblockmirror.a((EnumDirection) iblockdata.get(BlockChest.FACING)));
|
||||
}
|
||||
|
||||
protected BlockStateList getStateList() {
|
||||
return new BlockStateList(this, new IBlockState[] { BlockChest.FACING});
|
||||
}
|
||||
|
||||
public EnumBlockFaceShape a(IBlockAccess iblockaccess, IBlockData iblockdata, BlockPosition blockposition, EnumDirection enumdirection) {
|
||||
return EnumBlockFaceShape.UNDEFINED;
|
||||
}
|
||||
|
||||
public static enum Type {
|
||||
|
||||
BASIC, TRAP;
|
||||
|
||||
private Type() {}
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
||||
|
||||
public class BlockStationary extends BlockFluids {
|
||||
|
||||
protected BlockStationary(Material material) {
|
||||
super(material);
|
||||
this.a(false);
|
||||
if (material == Material.LAVA) {
|
||||
this.a(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1) {
|
||||
if (!this.e(world, blockposition, iblockdata)) {
|
||||
this.f(world, blockposition, iblockdata);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void f(World world, BlockPosition blockposition, IBlockData iblockdata) {
|
||||
BlockFlowing blockflowing = a(this.material);
|
||||
|
||||
world.setTypeAndData(blockposition, blockflowing.getBlockData().set(BlockStationary.LEVEL, iblockdata.get(BlockStationary.LEVEL)), 2);
|
||||
world.a(blockposition, (Block) blockflowing, this.a(world));
|
||||
}
|
||||
|
||||
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
|
||||
if (this.material == Material.LAVA) {
|
||||
if (world.getGameRules().getBoolean("doFireTick")) {
|
||||
int i = random.nextInt(3);
|
||||
|
||||
if (i > 0) {
|
||||
BlockPosition blockposition1 = blockposition;
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
blockposition1 = blockposition1.a(random.nextInt(3) - 1, 1, random.nextInt(3) - 1);
|
||||
if (blockposition1.getY() >= 0 && blockposition1.getY() < 256 && !world.isLoaded(blockposition1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = world.getType(blockposition1).getBlock();
|
||||
|
||||
if (block.material == Material.AIR) {
|
||||
if (this.c(world, blockposition1)) {
|
||||
// CraftBukkit start - Prevent lava putting something on fire
|
||||
if (world.getType(blockposition1) != Blocks.FIRE) {
|
||||
if (CraftEventFactory.callBlockIgniteEvent(world, blockposition1.getX(), blockposition1.getY(), blockposition1.getZ(), blockposition.getX(), blockposition.getY(), blockposition.getZ()).isCancelled()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// CraftBukkit end
|
||||
world.setTypeUpdate(blockposition1, Blocks.FIRE.getBlockData());
|
||||
return;
|
||||
}
|
||||
} else if (block.material.isSolid()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int k = 0; k < 3; ++k) {
|
||||
BlockPosition blockposition2 = blockposition.a(random.nextInt(3) - 1, 0, random.nextInt(3) - 1);
|
||||
|
||||
if (blockposition2.getY() >= 0 && blockposition2.getY() < 256 && !world.isLoaded(blockposition2)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (world.isEmpty(blockposition2.up()) && this.d(world, blockposition2)) {
|
||||
// CraftBukkit start - Prevent lava putting something on fire
|
||||
BlockPosition up = blockposition2.up();
|
||||
if (world.getType(up) != Blocks.FIRE) {
|
||||
if (CraftEventFactory.callBlockIgniteEvent(world, up.getX(), up.getY(), up.getZ(), blockposition.getX(), blockposition.getY(), blockposition.getZ()).isCancelled()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// CraftBukkit end
|
||||
world.setTypeUpdate(blockposition2.up(), Blocks.FIRE.getBlockData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean c(World world, BlockPosition blockposition) {
|
||||
EnumDirection[] aenumdirection = EnumDirection.values();
|
||||
int i = aenumdirection.length;
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
EnumDirection enumdirection = aenumdirection[j];
|
||||
|
||||
if (this.d(world, blockposition.shift(enumdirection))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean d(World world, BlockPosition blockposition) {
|
||||
// Dionysus start - improve fire spread checks
|
||||
if (blockposition.getY() >= 0 && blockposition.getY() < 256) {
|
||||
IBlockData blockData = world.getTypeIfLoaded(blockposition);
|
||||
|
||||
if (blockData != null) {
|
||||
return blockData.getMaterial().isBurnable();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
// Dionysus end
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,16 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutput;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue; // Paper
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -89,8 +94,22 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
|
||||
return nbttagcompound != null ? true : RegionFileCache.chunkExists(this.d, i, j);
|
||||
}
|
||||
|
||||
// Paper start
|
||||
private static final int CURRENT_DATA_VERSION = 1343; // Paper
|
||||
private static final boolean JUST_CORRUPT_IT = Boolean.valueOf("Paper.ignoreWorldDataVersion");
|
||||
// Paper end
|
||||
|
||||
@Nullable
|
||||
protected Object[] a(World world, int i, int j, NBTTagCompound nbttagcompound) { // CraftBukkit - return Chunk -> Object[]
|
||||
// Paper start - Do NOT attempt to load chunks saved with newer versions
|
||||
if (nbttagcompound.hasKeyOfType("DataVersion", 3)) {
|
||||
int dataVersion = nbttagcompound.getInt("DataVersion");
|
||||
if (!JUST_CORRUPT_IT && dataVersion > CURRENT_DATA_VERSION) {
|
||||
new RuntimeException("Server attempted to load chunk saved with newer version of minecraft! " + dataVersion + " > " + CURRENT_DATA_VERSION).printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
// Paper end
|
||||
if (!nbttagcompound.hasKeyOfType("Level", 10)) {
|
||||
ChunkRegionLoader.a.error("Chunk file at {},{} is missing level data, skipping", Integer.valueOf(i), Integer.valueOf(j));
|
||||
return null;
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
// CraftBukkit end
|
||||
|
||||
public class ContainerHorse extends Container {
|
||||
|
||||
private final IInventory a;
|
||||
private final EntityHorseAbstract f;
|
||||
|
||||
// CraftBukkit start
|
||||
org.bukkit.craftbukkit.inventory.CraftInventoryView bukkitEntity;
|
||||
PlayerInventory player;
|
||||
|
||||
@Override
|
||||
public InventoryView getBukkitView() {
|
||||
if (bukkitEntity != null) {
|
||||
return bukkitEntity;
|
||||
}
|
||||
|
||||
return bukkitEntity = new CraftInventoryView(player.player.getBukkitEntity(), a.getOwner().getInventory(), this);
|
||||
}
|
||||
|
||||
public ContainerHorse(IInventory iinventory, final IInventory iinventory1, final EntityHorseAbstract entityhorseabstract, EntityHuman entityhuman) {
|
||||
player = (PlayerInventory) iinventory;
|
||||
// CraftBukkit end
|
||||
this.a = iinventory1;
|
||||
this.f = entityhorseabstract;
|
||||
boolean flag = true;
|
||||
|
||||
iinventory1.startOpen(entityhuman);
|
||||
boolean flag1 = true;
|
||||
|
||||
this.a(new Slot(iinventory1, 0, 8, 18) {
|
||||
public boolean isAllowed(ItemStack itemstack) {
|
||||
return itemstack.getItem() == Items.SADDLE && !this.hasItem() && entityhorseabstract.dF();
|
||||
}
|
||||
});
|
||||
this.a(new Slot(iinventory1, 1, 8, 36) {
|
||||
public boolean isAllowed(ItemStack itemstack) {
|
||||
return entityhorseabstract.f(itemstack);
|
||||
}
|
||||
|
||||
public int getMaxStackSize() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
int i;
|
||||
int j;
|
||||
|
||||
if (entityhorseabstract instanceof EntityHorseChestedAbstract && ((EntityHorseChestedAbstract) entityhorseabstract).isCarryingChest()) {
|
||||
for (i = 0; i < 3; ++i) {
|
||||
for (j = 0; j < ((EntityHorseChestedAbstract) entityhorseabstract).dt(); ++j) {
|
||||
this.a(new Slot(iinventory1, 2 + j + i * ((EntityHorseChestedAbstract) entityhorseabstract).dt(), 80 + j * 18, 18 + i * 18));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
for (j = 0; j < 9; ++j) {
|
||||
this.a(new Slot(iinventory, j + i * 9 + 9, 8 + j * 18, 102 + i * 18 + -18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i) {
|
||||
this.a(new Slot(iinventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean canUse(EntityHuman entityhuman) {
|
||||
return this.a.a(entityhuman) && this.f.isAlive() && this.f.valid && this.f.g((Entity) entityhuman) < 8.0F; // NeonPaper! - Fix MC-161754
|
||||
}
|
||||
|
||||
public ItemStack shiftClick(EntityHuman entityhuman, int i) {
|
||||
ItemStack itemstack = ItemStack.a;
|
||||
Slot slot = (Slot) this.slots.get(i);
|
||||
|
||||
if (slot != null && slot.hasItem()) {
|
||||
ItemStack itemstack1 = slot.getItem();
|
||||
|
||||
itemstack = itemstack1.cloneItemStack();
|
||||
if (i < this.a.getSize()) {
|
||||
if (!this.a(itemstack1, this.a.getSize(), this.slots.size(), true)) {
|
||||
return ItemStack.a;
|
||||
}
|
||||
} else if (this.getSlot(1).isAllowed(itemstack1) && !this.getSlot(1).hasItem()) {
|
||||
if (!this.a(itemstack1, 1, 2, false)) {
|
||||
return ItemStack.a;
|
||||
}
|
||||
} else if (this.getSlot(0).isAllowed(itemstack1)) {
|
||||
if (!this.a(itemstack1, 0, 1, false)) {
|
||||
return ItemStack.a;
|
||||
}
|
||||
} else if (this.a.getSize() <= 2 || !this.a(itemstack1, 2, this.a.getSize(), false)) {
|
||||
return ItemStack.a;
|
||||
}
|
||||
|
||||
if (itemstack1.isEmpty()) {
|
||||
slot.set(ItemStack.a);
|
||||
} else {
|
||||
slot.f();
|
||||
}
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
public void b(EntityHuman entityhuman) {
|
||||
super.b(entityhuman);
|
||||
this.a.closeContainer(entityhuman);
|
||||
}
|
||||
}
|
||||
@@ -1387,33 +1387,37 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
public void d(EntityHuman entityhuman) {}
|
||||
|
||||
public void collide(Entity entity) {
|
||||
if (entity.noclip || this.noclip || this.x(entity)) return; // NeonPaper - Test this earlier
|
||||
double d0 = entity.locX - this.locX;
|
||||
double d1 = entity.locZ - this.locZ;
|
||||
double d2 = MathHelper.a(d0, d1);
|
||||
if (!this.x(entity)) {
|
||||
if (!entity.noclip && !this.noclip) {
|
||||
double d0 = entity.locX - this.locX;
|
||||
double d1 = entity.locZ - this.locZ;
|
||||
double d2 = MathHelper.a(d0, d1);
|
||||
|
||||
if (d2 >= 0.009999999776482582D) {
|
||||
d2 = (double) MathHelper.sqrt(d2);
|
||||
d0 /= d2;
|
||||
d1 /= d2;
|
||||
double d3 = 1.0D / d2;
|
||||
if (d2 >= 0.009999999776482582D) {
|
||||
d2 = (double) MathHelper.sqrt(d2);
|
||||
d0 /= d2;
|
||||
d1 /= d2;
|
||||
double d3 = 1.0D / d2;
|
||||
|
||||
if (d3 > 1.0D) {
|
||||
d3 = 1.0D;
|
||||
}
|
||||
if (d3 > 1.0D) {
|
||||
d3 = 1.0D;
|
||||
}
|
||||
|
||||
d0 *= d3;
|
||||
d1 *= d3;
|
||||
d0 *= 0.05000000074505806D;
|
||||
d1 *= 0.05000000074505806D;
|
||||
d0 *= (double) (1.0F - this.R);
|
||||
d1 *= (double) (1.0F - this.R);
|
||||
if (!this.isVehicle()) {
|
||||
this.f(-d0, 0.0D, -d1);
|
||||
}
|
||||
d0 *= d3;
|
||||
d1 *= d3;
|
||||
d0 *= 0.05000000074505806D;
|
||||
d1 *= 0.05000000074505806D;
|
||||
d0 *= (double) (1.0F - this.R);
|
||||
d1 *= (double) (1.0F - this.R);
|
||||
if (!this.isVehicle()) {
|
||||
this.f(-d0, 0.0D, -d1);
|
||||
}
|
||||
|
||||
if (!entity.isVehicle()) {
|
||||
entity.f(d0, 0.0D, d1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!entity.isVehicle()) {
|
||||
entity.f(d0, 0.0D, d1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2965,7 +2969,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
return entity instanceof EntityHuman ? ((EntityHuman) entity).cZ() : !this.world.isClientSide;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Nullable Entity getVehicleDirect() { return this.bJ(); } // Paper - OBFHELPER
|
||||
public Entity bJ() {
|
||||
return this.au;
|
||||
}
|
||||
|
||||
@@ -1096,6 +1096,13 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
public void s() {
|
||||
this.cu = true;
|
||||
this.ejectPassengers();
|
||||
|
||||
// Paper start - "Fixes" an issue where the vehicle doesn't track the passenger disconnection dismount.
|
||||
if (this.isPassenger() && this.getVehicleDirect() instanceof EntityLiving) {
|
||||
this.stopRiding();
|
||||
}
|
||||
// Paper end
|
||||
|
||||
if (this.sleeping) {
|
||||
this.a(true, false, false);
|
||||
}
|
||||
|
||||
@@ -1,370 +0,0 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
public class MathHelper {
|
||||
|
||||
public static final float a = c(2.0F);
|
||||
private static final int[] SINE_TABLE_INT = new int[16384 + 1];
|
||||
private static final float SINE_TABLE_MIDPOINT;
|
||||
private static final Random c = new Random();
|
||||
private static final int[] d;
|
||||
private static final double e;
|
||||
private static final double[] f;
|
||||
private static final double[] g;
|
||||
|
||||
public static float sin(float f) {
|
||||
return lookup((int) (f * 10430.38) & 0xFFFF);
|
||||
}
|
||||
|
||||
public static float cos(float f) {
|
||||
return lookup((int) (f * 10430.38 + 16384.0) & 0xFFFF);
|
||||
}
|
||||
|
||||
private static float lookup(int index) {
|
||||
if (index == 32768) {
|
||||
return SINE_TABLE_MIDPOINT;
|
||||
}
|
||||
int neg = (index & 0x8000) << 16;
|
||||
int mask = (index << 17) >> 31;
|
||||
int pos = (0x8001 & mask) + (index ^ mask);
|
||||
pos &= 0x7fff;
|
||||
return Float.intBitsToFloat(SINE_TABLE_INT[pos] ^ neg);
|
||||
}
|
||||
|
||||
public static float c(float f) {
|
||||
return (float) Math.sqrt((double) f);
|
||||
}
|
||||
|
||||
public static float sqrt(double d0) {
|
||||
return (float) Math.sqrt(d0);
|
||||
}
|
||||
|
||||
public static int d(float f) {
|
||||
int i = (int) f;
|
||||
|
||||
return f < (float) i ? i - 1 : i;
|
||||
}
|
||||
|
||||
public static int floor(double d0) {
|
||||
int i = (int) d0;
|
||||
|
||||
return d0 < (double) i ? i - 1 : i;
|
||||
}
|
||||
|
||||
public static long d(double d0) {
|
||||
long i = (long) d0;
|
||||
|
||||
return d0 < (double) i ? i - 1L : i;
|
||||
}
|
||||
|
||||
public static float e(float f) {
|
||||
return f >= 0.0F ? f : -f;
|
||||
}
|
||||
|
||||
public static int a(int i) {
|
||||
return i >= 0 ? i : -i;
|
||||
}
|
||||
|
||||
public static int f(float f) {
|
||||
int i = (int) f;
|
||||
|
||||
return f > (float) i ? i + 1 : i;
|
||||
}
|
||||
|
||||
public static int f(double d0) {
|
||||
int i = (int) d0;
|
||||
|
||||
return d0 > (double) i ? i + 1 : i;
|
||||
}
|
||||
|
||||
public static int clamp(int i, int j, int k) {
|
||||
return i < j ? j : (i > k ? k : i);
|
||||
}
|
||||
|
||||
public static float a(float f, float f1, float f2) {
|
||||
return f < f1 ? f1 : (f > f2 ? f2 : f);
|
||||
}
|
||||
|
||||
public static double a(double d0, double d1, double d2) {
|
||||
return d0 < d1 ? d1 : (d0 > d2 ? d2 : d0);
|
||||
}
|
||||
|
||||
public static double b(double d0, double d1, double d2) {
|
||||
return d2 < 0.0D ? d0 : (d2 > 1.0D ? d1 : d0 + (d1 - d0) * d2);
|
||||
}
|
||||
|
||||
public static double a(double d0, double d1) {
|
||||
if (d0 < 0.0D) {
|
||||
d0 = -d0;
|
||||
}
|
||||
|
||||
if (d1 < 0.0D) {
|
||||
d1 = -d1;
|
||||
}
|
||||
|
||||
return d0 > d1 ? d0 : d1;
|
||||
}
|
||||
|
||||
public static int nextInt(Random random, int i, int j) {
|
||||
return i >= j ? i : random.nextInt(j - i + 1) + i;
|
||||
}
|
||||
|
||||
public static float a(Random random, float f, float f1) {
|
||||
return f >= f1 ? f : random.nextFloat() * (f1 - f) + f;
|
||||
}
|
||||
|
||||
public static double a(Random random, double d0, double d1) {
|
||||
return d0 >= d1 ? d0 : random.nextDouble() * (d1 - d0) + d0;
|
||||
}
|
||||
|
||||
public static double a(long[] along) {
|
||||
long i = 0L;
|
||||
long[] along1 = along;
|
||||
int j = along.length;
|
||||
|
||||
for (int k = 0; k < j; ++k) {
|
||||
long l = along1[k];
|
||||
|
||||
i += l;
|
||||
}
|
||||
|
||||
return (double) i / (double) along.length;
|
||||
}
|
||||
|
||||
public static float g(float f) {
|
||||
f %= 360.0F;
|
||||
if (f >= 180.0F) {
|
||||
f -= 360.0F;
|
||||
}
|
||||
|
||||
if (f < -180.0F) {
|
||||
f += 360.0F;
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
public static double g(double d0) {
|
||||
d0 %= 360.0D;
|
||||
if (d0 >= 180.0D) {
|
||||
d0 -= 360.0D;
|
||||
}
|
||||
|
||||
if (d0 < -180.0D) {
|
||||
d0 += 360.0D;
|
||||
}
|
||||
|
||||
return d0;
|
||||
}
|
||||
|
||||
public static int b(int i) {
|
||||
i %= 360;
|
||||
if (i >= 180) {
|
||||
i -= 360;
|
||||
}
|
||||
|
||||
if (i < -180) {
|
||||
i += 360;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public static int a(String s, int i) {
|
||||
try {
|
||||
return Integer.parseInt(s);
|
||||
} catch (Throwable throwable) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
public static int a(String s, int i, int j) {
|
||||
return Math.max(j, a(s, i));
|
||||
}
|
||||
|
||||
public static double a(String s, double d0) {
|
||||
try {
|
||||
return Double.parseDouble(s);
|
||||
} catch (Throwable throwable) {
|
||||
return d0;
|
||||
}
|
||||
}
|
||||
|
||||
public static double a(String s, double d0, double d1) {
|
||||
return Math.max(d1, a(s, d0));
|
||||
}
|
||||
|
||||
public static int c(int i) {
|
||||
int j = i - 1;
|
||||
|
||||
j |= j >> 1;
|
||||
j |= j >> 2;
|
||||
j |= j >> 4;
|
||||
j |= j >> 8;
|
||||
j |= j >> 16;
|
||||
return j + 1;
|
||||
}
|
||||
|
||||
private static boolean g(int i) {
|
||||
return i != 0 && (i & i - 1) == 0;
|
||||
}
|
||||
|
||||
public static int d(int i) {
|
||||
i = g(i) ? i : c(i);
|
||||
return MathHelper.d[(int) ((long) i * 125613361L >> 27) & 31];
|
||||
}
|
||||
|
||||
public static int e(int i) {
|
||||
return d(i) - (g(i) ? 0 : 1);
|
||||
}
|
||||
|
||||
public static int c(int i, int j) {
|
||||
if (j == 0) {
|
||||
return 0;
|
||||
} else if (i == 0) {
|
||||
return j;
|
||||
} else {
|
||||
if (i < 0) {
|
||||
j *= -1;
|
||||
}
|
||||
|
||||
int k = i % j;
|
||||
|
||||
return k == 0 ? i : i + j - k;
|
||||
}
|
||||
}
|
||||
|
||||
public static long c(int i, int j, int k) {
|
||||
long l = (long) (i * 3129871) ^ (long) k * 116129781L ^ (long) j;
|
||||
|
||||
l = l * l * 42317861L + l * 11L;
|
||||
return l;
|
||||
}
|
||||
|
||||
public static UUID a(Random random) {
|
||||
long i = random.nextLong() & -61441L | 16384L;
|
||||
long j = random.nextLong() & 4611686018427387903L | Long.MIN_VALUE;
|
||||
|
||||
return new UUID(i, j);
|
||||
}
|
||||
|
||||
public static UUID a() {
|
||||
return a(MathHelper.c);
|
||||
}
|
||||
|
||||
public static double c(double d0, double d1, double d2) {
|
||||
return (d0 - d1) / (d2 - d1);
|
||||
}
|
||||
|
||||
public static double c(double d0, double d1) {
|
||||
double d2 = d1 * d1 + d0 * d0;
|
||||
|
||||
if (Double.isNaN(d2)) {
|
||||
return Double.NaN;
|
||||
} else {
|
||||
boolean flag = d0 < 0.0D;
|
||||
|
||||
if (flag) {
|
||||
d0 = -d0;
|
||||
}
|
||||
|
||||
boolean flag1 = d1 < 0.0D;
|
||||
|
||||
if (flag1) {
|
||||
d1 = -d1;
|
||||
}
|
||||
|
||||
boolean flag2 = d0 > d1;
|
||||
double d3;
|
||||
|
||||
if (flag2) {
|
||||
d3 = d1;
|
||||
d1 = d0;
|
||||
d0 = d3;
|
||||
}
|
||||
|
||||
d3 = i(d2);
|
||||
d1 *= d3;
|
||||
d0 *= d3;
|
||||
double d4 = MathHelper.e + d0;
|
||||
int i = (int) Double.doubleToRawLongBits(d4);
|
||||
double d5 = MathHelper.f[i];
|
||||
double d6 = MathHelper.g[i];
|
||||
double d7 = d4 - MathHelper.e;
|
||||
double d8 = d0 * d6 - d1 * d7;
|
||||
double d9 = (6.0D + d8 * d8) * d8 * 0.16666666666666666D;
|
||||
double d10 = d5 + d9;
|
||||
|
||||
if (flag2) {
|
||||
d10 = 1.5707963267948966D - d10;
|
||||
}
|
||||
|
||||
if (flag1) {
|
||||
d10 = 3.141592653589793D - d10;
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
d10 = -d10;
|
||||
}
|
||||
|
||||
return d10;
|
||||
}
|
||||
}
|
||||
|
||||
public static double i(double d0) {
|
||||
double d1 = 0.5D * d0;
|
||||
long i = Double.doubleToRawLongBits(d0);
|
||||
|
||||
i = 6910469410427058090L - (i >> 1);
|
||||
d0 = Double.longBitsToDouble(i);
|
||||
d0 *= 1.5D - d1 * d0 * d0;
|
||||
return d0;
|
||||
}
|
||||
|
||||
public static int f(int i) {
|
||||
i ^= i >>> 16;
|
||||
i *= -2048144789;
|
||||
i ^= i >>> 13;
|
||||
i *= -1028477387;
|
||||
i ^= i >>> 16;
|
||||
return i;
|
||||
}
|
||||
|
||||
static {
|
||||
int i;
|
||||
|
||||
final float[] SINE_TABLE = new float[65536];
|
||||
for (i = 0; i < 65536; ++i) {
|
||||
SINE_TABLE[i] = (float) Math.sin((double) i * 3.141592653589793D * 2.0D / 65536.0D);
|
||||
}
|
||||
for (i = 0; i < SINE_TABLE_INT.length; i++) {
|
||||
SINE_TABLE_INT[i] = Float.floatToRawIntBits(SINE_TABLE[i]);
|
||||
}
|
||||
|
||||
SINE_TABLE_MIDPOINT = SINE_TABLE[SINE_TABLE.length / 2];
|
||||
for (i = 0; i < SINE_TABLE.length; i++) {
|
||||
float expected = SINE_TABLE[i];
|
||||
float value = lookup(i);
|
||||
|
||||
if (expected != value) {
|
||||
throw new IllegalArgumentException(String.format("LUT error at index %d (expected: %s, found: %s)", i, expected, value));
|
||||
}
|
||||
}
|
||||
|
||||
d = new int[] { 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9};
|
||||
e = Double.longBitsToDouble(4805340802404319232L);
|
||||
f = new double[257];
|
||||
g = new double[257];
|
||||
|
||||
for (i = 0; i < 257; ++i) {
|
||||
double d0 = (double) i / 256.0D;
|
||||
double d1 = Math.asin(d0);
|
||||
|
||||
MathHelper.g[i] = Math.cos(d1);
|
||||
MathHelper.f[i] = d1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import com.googlecode.concurentlocks.ReentrantReadWriteUpdateLock;
|
||||
|
||||
import io.akarin.api.internal.utils.CheckedConcurrentLinkedQueue;
|
||||
|
||||
import com.google.common.collect.Queues;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
@@ -18,9 +19,9 @@ import io.netty.handler.timeout.TimeoutException;
|
||||
import io.netty.util.AttributeKey;
|
||||
import io.netty.util.concurrent.Future;
|
||||
import io.netty.util.concurrent.GenericFutureListener;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.crypto.SecretKey;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
@@ -29,7 +30,6 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
import org.apache.logging.log4j.MarkerManager;
|
||||
|
||||
/**
|
||||
* Akarin Changes Note
|
||||
* 2) Expose private members (nsc)
|
||||
@@ -47,7 +47,6 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
return new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Client IO #%d").setDaemon(true).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object init() {
|
||||
return this.a();
|
||||
}
|
||||
@@ -57,7 +56,6 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
return new EpollEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Epoll Client IO #%d").setDaemon(true).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object init() {
|
||||
return this.a();
|
||||
}
|
||||
@@ -67,7 +65,6 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
return new LocalEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Local Client IO #%d").setDaemon(true).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object init() {
|
||||
return this.a();
|
||||
}
|
||||
@@ -96,7 +93,6 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
this.h = enumprotocoldirection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext channelhandlercontext) throws Exception {
|
||||
super.channelActive(channelhandlercontext);
|
||||
this.channel = channelhandlercontext.channel();
|
||||
@@ -119,13 +115,20 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
NetworkManager.g.debug("Enabled auto read");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext channelhandlercontext) throws Exception {
|
||||
this.close(new ChatMessage("disconnect.endOfStream", new Object[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext channelhandlercontext, Throwable throwable) throws Exception {
|
||||
// Paper start
|
||||
if (throwable instanceof io.netty.handler.codec.EncoderException && throwable.getCause() instanceof PacketEncoder.PacketTooLargeException) {
|
||||
if (((PacketEncoder.PacketTooLargeException) throwable.getCause()).getPacket().packetTooLarge(this)) {
|
||||
return;
|
||||
} else {
|
||||
throwable = throwable.getCause();
|
||||
}
|
||||
}
|
||||
// Paper end
|
||||
ChatMessage chatmessage;
|
||||
|
||||
if (throwable instanceof TimeoutException) {
|
||||
@@ -212,7 +215,6 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
channelfuture.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||
} else {
|
||||
this.channel.eventLoop().execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (enumprotocol != enumprotocol1) {
|
||||
NetworkManager.this.setProtocol(enumprotocol);
|
||||
@@ -229,6 +231,15 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
});
|
||||
}
|
||||
|
||||
// Paper start
|
||||
java.util.List<Packet> extraPackets = packet.getExtraPackets();
|
||||
if (extraPackets != null && !extraPackets.isEmpty()) {
|
||||
for (Packet extraPacket : extraPackets) {
|
||||
this.dispatchPacket(extraPacket, agenericfuturelistener);
|
||||
}
|
||||
}
|
||||
// Paper end
|
||||
|
||||
}
|
||||
|
||||
// Paper start - Async-Anti-Xray - Stop dispatching further packets and return false if the peeked packet is a chunk packet which is not ready
|
||||
@@ -363,7 +374,6 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext channelhandlercontext, Packet object) throws Exception { // CraftBukkit - fix decompile error
|
||||
// FlamePaper - Check if channel is opened before reading packet
|
||||
if (isConnected()) {
|
||||
|
||||
@@ -355,6 +355,13 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
}
|
||||
speed *= 2f; // TODO: Get the speed of the vehicle instead of the player
|
||||
|
||||
// Paper start - Prevent moving into unloaded chunks
|
||||
if (player.world.paperConfig.preventMovingIntoUnloadedChunks && !worldserver.isChunkLoaded((int) Math.floor(packetplayinvehiclemove.getX()) >> 4, (int) Math.floor(packetplayinvehiclemove.getZ()) >> 4, false)) {
|
||||
this.networkManager.sendPacket(new PacketPlayOutVehicleMove(entity));
|
||||
return;
|
||||
}
|
||||
// Paper end
|
||||
|
||||
if (d10 - d9 > Math.max(100.0D, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && (!this.minecraftServer.R() || !this.minecraftServer.Q().equals(entity.getName()))) { // Spigot
|
||||
// CraftBukkit end
|
||||
PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getName(), this.player.getName(), Double.valueOf(d6), Double.valueOf(d7), Double.valueOf(d8));
|
||||
@@ -386,13 +393,13 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
}
|
||||
|
||||
entity.setLocation(d3, d4, d5, f, f1);
|
||||
Location curPos = getPlayer().getLocation(); // Paper
|
||||
player.setLocation(d3, d4, d5, f, f1); // Paper
|
||||
Location curPos = getPlayer().getLocation(); // Paper
|
||||
player.setLocation(d3, d4, d5, player.yaw, player.pitch); // CraftBukkit // Paper
|
||||
boolean flag2 = worldserver.getCubes(entity, entity.getBoundingBox().shrink(0.0625D)).isEmpty();
|
||||
|
||||
if (flag && (flag1 || !flag2)) {
|
||||
entity.setLocation(d0, d1, d2, f, f1);
|
||||
player.setLocation(d0, d1, d2, f, f1); // Paper
|
||||
player.setLocation(d3, d4, d5, player.yaw, player.pitch); // CraftBukkit // Paper
|
||||
this.networkManager.sendPacket(new PacketPlayOutVehicleMove(entity));
|
||||
return;
|
||||
}
|
||||
@@ -552,9 +559,9 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
double d1 = this.player.locY;
|
||||
double d2 = this.player.locZ;
|
||||
double d3 = this.player.locY;
|
||||
double d4 = packetplayinflying.a(this.player.locX);
|
||||
double d4 = packetplayinflying.a(this.player.locX); double toX = d4; // Paper - OBFHELPER
|
||||
double d5 = packetplayinflying.b(this.player.locY);
|
||||
double d6 = packetplayinflying.c(this.player.locZ);
|
||||
double d6 = packetplayinflying.c(this.player.locZ); double toZ = d6; // Paper - OBFHELPER
|
||||
float f = packetplayinflying.a(this.player.yaw);
|
||||
float f1 = packetplayinflying.b(this.player.pitch);
|
||||
double d7 = d4 - this.l;
|
||||
@@ -594,6 +601,13 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
speed = player.abilities.walkSpeed * 10f;
|
||||
}
|
||||
|
||||
// Paper start - Prevent moving into unloaded chunks
|
||||
if (player.world.paperConfig.preventMovingIntoUnloadedChunks && (this.player.locX != toX || this.player.locZ != toZ) && !worldserver.isChunkLoaded((int) Math.floor(toX) >> 4, (int) Math.floor(toZ) >> 4, false)) {
|
||||
this.internalTeleport(this.player.locX, this.player.locY, this.player.locZ, this.player.yaw, this.player.pitch, Collections.emptySet());
|
||||
return;
|
||||
}
|
||||
// Paper end
|
||||
|
||||
if (!this.player.L() && (!this.player.x().getGameRules().getBoolean("disableElytraMovementCheck") || !this.player.cP())) {
|
||||
float f2 = this.player.cP() ? 300.0F : 100.0F;
|
||||
|
||||
@@ -1695,7 +1709,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
|
||||
if (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != origItem) {
|
||||
// Refresh the current entity metadata
|
||||
this.sendPacket(new PacketPlayOutEntityMetadata(entity.getId(), entity.datawatcher, true));
|
||||
entity.tracker.broadcast(new PacketPlayOutEntityMetadata(entity.getId(), entity.datawatcher, true)); // Paper - update entity for all players
|
||||
}
|
||||
|
||||
if (event.isCancelled()) {
|
||||
@@ -2232,7 +2246,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
|
||||
TileEntitySign tileentitysign = (TileEntitySign) tileentity;
|
||||
|
||||
if (!tileentitysign.a() || tileentitysign.e() != this.player) {
|
||||
if (!tileentitysign.a() || tileentitysign.signEditor == null || !tileentitysign.signEditor.equals(this.player.getUniqueID())) { // Paper
|
||||
this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign");
|
||||
this.sendPacket(tileentity.getUpdatePacket()); // CraftBukkit
|
||||
return;
|
||||
@@ -2248,6 +2262,14 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
String[] lines = new String[4];
|
||||
|
||||
for (int i = 0; i < astring.length; ++i) {
|
||||
// Paper start - cap line length - modified clients can send longer data than normal
|
||||
if (astring[i].length() > TileEntitySign.MAX_SIGN_LINE_LENGTH && TileEntitySign.MAX_SIGN_LINE_LENGTH > 0) {
|
||||
int offset = astring[i].codePoints().limit(TileEntitySign.MAX_SIGN_LINE_LENGTH).map(Character::charCount).sum();
|
||||
if (offset > astring.length) {
|
||||
astring[i] = astring[i].substring(0, offset);
|
||||
}
|
||||
}
|
||||
// Paper end
|
||||
lines[i] = SharedConstants.a(astring[i]); //Paper - Replaced with anvil color stripping method to stop exploits that allow colored signs to be created.
|
||||
}
|
||||
SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.server.getPlayer(this.player), lines);
|
||||
@@ -2350,6 +2372,45 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
this.player.a(packetplayinsettings);
|
||||
}
|
||||
|
||||
// Paper start
|
||||
private boolean validateBook(ItemStack testStack) {
|
||||
NBTTagList pageList = testStack.getTag().getList("pages", 8);
|
||||
long byteTotal = 0;
|
||||
int maxBookPageSize = com.destroystokyo.paper.PaperConfig.maxBookPageSize;
|
||||
double multiplier = Math.max(0.3D, Math.min(1D, com.destroystokyo.paper.PaperConfig.maxBookTotalSizeMultiplier));
|
||||
long byteAllowed = maxBookPageSize;
|
||||
for (int i = 0; i < pageList.size(); ++i) {
|
||||
String testString = pageList.getString(i);
|
||||
int byteLength = testString.getBytes(java.nio.charset.StandardCharsets.UTF_8).length;
|
||||
byteTotal += byteLength;
|
||||
|
||||
int length = testString.length();
|
||||
int multibytes = 0;
|
||||
if (length != byteLength) {
|
||||
for (char c : testString.toCharArray()) {
|
||||
if (c > 127) {
|
||||
multibytes++;
|
||||
}
|
||||
}
|
||||
}
|
||||
byteAllowed += (maxBookPageSize * Math.min(1, Math.max(0.1D, (double) length / 255D))) * multiplier;
|
||||
|
||||
if (multibytes > 1) {
|
||||
// penalize MB
|
||||
byteAllowed -= multibytes;
|
||||
}
|
||||
}
|
||||
|
||||
if (byteTotal > byteAllowed) {
|
||||
PlayerConnection.LOGGER.warn(this.player.getName() + " tried to send too large of a book. Book Size: " + byteTotal + " - Allowed: "+ byteAllowed + " - Pages: " + pageList.size());
|
||||
minecraftServer.postToMainThread(() -> this.disconnect("Book too large!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
// Paper end
|
||||
|
||||
public void a(PacketPlayInCustomPayload packetplayincustompayload) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayincustompayload, this, this.player.x());
|
||||
String s = packetplayincustompayload.a();
|
||||
@@ -2383,6 +2444,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
}
|
||||
|
||||
if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) {
|
||||
if (!validateBook(itemstack)) return; // Paper
|
||||
itemstack1.a("pages", (NBTBase) itemstack.getTag().getList("pages", 8));
|
||||
CraftEventFactory.handleEditBookEvent(player, itemstack1); // CraftBukkit
|
||||
}
|
||||
@@ -2418,6 +2480,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
}
|
||||
|
||||
if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack1.getItem() == Items.WRITABLE_BOOK) {
|
||||
if (!validateBook(itemstack)) return; // Paper
|
||||
ItemStack itemstack2 = new ItemStack(Items.WRITTEN_BOOK);
|
||||
|
||||
itemstack2.a("author", (NBTBase) (new NBTTagString(this.player.getName())));
|
||||
|
||||
@@ -71,7 +71,7 @@ public abstract class PlayerList {
|
||||
// private final Map<UUID, AdvancementDataPlayer> p;
|
||||
// CraftBukkit end
|
||||
public IPlayerFileData playerFileData;
|
||||
private boolean hasWhitelist;
|
||||
//private boolean hasWhitelist; // Paper - moved to whitelist object so not duplicated
|
||||
protected int maxPlayers;
|
||||
private int s;
|
||||
private EnumGamemode t;
|
||||
@@ -1241,9 +1241,9 @@ public abstract class PlayerList {
|
||||
}
|
||||
public boolean isWhitelisted(GameProfile gameprofile, org.bukkit.event.player.PlayerLoginEvent loginEvent) {
|
||||
boolean isOp = this.operators.d(gameprofile);
|
||||
boolean isWhitelisted = !this.hasWhitelist || isOp || this.whitelist.d(gameprofile);
|
||||
boolean isWhitelisted = !this.getHasWhitelist() || isOp || this.whitelist.d(gameprofile);
|
||||
final com.destroystokyo.paper.event.profile.ProfileWhitelistVerifyEvent event;
|
||||
event = new com.destroystokyo.paper.event.profile.ProfileWhitelistVerifyEvent(MCUtil.toBukkit(gameprofile), this.hasWhitelist, isWhitelisted, isOp, org.spigotmc.SpigotConfig.whitelistMessage);
|
||||
event = new com.destroystokyo.paper.event.profile.ProfileWhitelistVerifyEvent(MCUtil.toBukkit(gameprofile), this.getHasWhitelist(), isWhitelisted, isOp, org.spigotmc.SpigotConfig.whitelistMessage);
|
||||
event.callEvent();
|
||||
if (!event.isWhitelisted()) {
|
||||
if (loginEvent != null) {
|
||||
@@ -1392,11 +1392,11 @@ public abstract class PlayerList {
|
||||
}
|
||||
|
||||
public boolean getHasWhitelist() {
|
||||
return this.hasWhitelist;
|
||||
return this.whitelist.isEnabled(); // Paper
|
||||
}
|
||||
|
||||
public void setHasWhitelist(boolean flag) {
|
||||
this.hasWhitelist = flag;
|
||||
this.whitelist.setEnabled(flag); // Paper
|
||||
}
|
||||
|
||||
public List<EntityPlayer> b(String s) {
|
||||
|
||||
@@ -936,7 +936,8 @@ public abstract class World implements IBlockAccess {
|
||||
int i1 = MathHelper.floor(vec3d.y);
|
||||
int j1 = MathHelper.floor(vec3d.z);
|
||||
BlockPosition blockposition = new BlockPosition(l, i1, j1);
|
||||
IBlockData iblockdata = this.getType(blockposition);
|
||||
IBlockData iblockdata = this.getTypeIfLoaded(blockposition); // Paper
|
||||
if (iblockdata == null) return null; // Paper
|
||||
Block block = iblockdata.getBlock();
|
||||
|
||||
if ((!flag1 || iblockdata.d(this, blockposition) != Block.k) && block.a(iblockdata, flag)) {
|
||||
@@ -1038,7 +1039,8 @@ public abstract class World implements IBlockAccess {
|
||||
i1 = MathHelper.floor(vec3d.y) - (enumdirection == EnumDirection.UP ? 1 : 0);
|
||||
j1 = MathHelper.floor(vec3d.z) - (enumdirection == EnumDirection.SOUTH ? 1 : 0);
|
||||
blockposition = new BlockPosition(l, i1, j1);
|
||||
IBlockData iblockdata1 = this.getType(blockposition);
|
||||
IBlockData iblockdata1 = this.getTypeIfLoaded(blockposition); // Paper
|
||||
if (iblockdata1 == null) return null; // Paper
|
||||
Block block1 = iblockdata1.getBlock();
|
||||
|
||||
if (!flag1 || iblockdata1.getMaterial() == Material.PORTAL || iblockdata1.d(this, blockposition) != Block.k) {
|
||||
|
||||
@@ -337,7 +337,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
||||
this.methodProfiler.c("village");
|
||||
timings.doVillages.startTiming(); // Spigot
|
||||
this.villages.tick();
|
||||
this.siegeManager.a();
|
||||
if (paperConfig.villageSiegesEnabled) { this.siegeManager.a(); } // Paper - Allow disabling village sieges
|
||||
timings.doVillages.stopTiming(); // Spigot
|
||||
this.methodProfiler.c("portalForcer");
|
||||
timings.doPortalForcer.startTiming(); // Spigot
|
||||
|
||||
@@ -1781,7 +1781,7 @@ public final class CraftServer implements Server {
|
||||
ImageIO.write(image, "PNG", new ByteBufOutputStream(bytebuf));
|
||||
ByteBuf bytebuf1 = Base64.encode(bytebuf);
|
||||
|
||||
return new CraftIconCache("data:image/png;base64," + bytebuf1.toString(Charsets.UTF_8));
|
||||
return new CraftIconCache("data:image/png;base64," + bytebuf1.toString(Charsets.UTF_8).replace("\n", "")); // Paper - Fix encoding for 1.13+ clients, still compat w/ 1.12 clients
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,6 +38,12 @@
|
||||
"optimization.MixinEntityHorseAbstract",
|
||||
"optimization.MixinEntityTameableAnimal",
|
||||
"optimization.MixinPersistentCollection",
|
||||
"optimization.MixinTileEntityEnchantTable"
|
||||
"optimization.MixinTileEntityEnchantTable",
|
||||
"optimization.MixinBlockChest",
|
||||
"optimization.MixinEntityMushroomCow",
|
||||
"optimization.MixinContainerHorse",
|
||||
"optimization.MixinExplosion",
|
||||
"optimization.MixinMathHelper",
|
||||
"optimization.MixinBlockStationary"
|
||||
]
|
||||
}
|
||||
|
||||
Submodule work/Paper updated: e39995d213...2d4dfa5803
Reference in New Issue
Block a user