mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-25 02:17:35 +01:00
Add new DispenseBehavior files from mc-dev for diff visibility.
This commit is contained in:
parent
ff1c1daf69
commit
fbe609bdbe
@ -0,0 +1,32 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
final class DispenseBehaviorArmor extends DispenseBehaviorItem {
|
||||
|
||||
DispenseBehaviorArmor() {}
|
||||
|
||||
protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
|
||||
EnumFacing enumfacing = BlockDispenser.j_(isourceblock.h());
|
||||
int i = isourceblock.getBlockX() + enumfacing.c();
|
||||
int j = isourceblock.getBlockY() + enumfacing.d();
|
||||
int k = isourceblock.getBlockZ() + enumfacing.e();
|
||||
AxisAlignedBB axisalignedbb = AxisAlignedBB.a().a((double) i, (double) j, (double) k, (double) (i + 1), (double) (j + 1), (double) (k + 1));
|
||||
List list = isourceblock.k().a(EntityLiving.class, axisalignedbb, (IEntitySelector) (new EntitySelectorEquipable(itemstack)));
|
||||
|
||||
if (list.size() > 0) {
|
||||
EntityLiving entityliving = (EntityLiving) list.get(0);
|
||||
int l = entityliving instanceof EntityHuman ? 1 : 0;
|
||||
int i1 = EntityLiving.b(itemstack);
|
||||
ItemStack itemstack1 = itemstack.cloneItemStack();
|
||||
|
||||
itemstack1.count = 1;
|
||||
entityliving.setEquipment(i1 - l, itemstack1);
|
||||
entityliving.a(i1, 2.0F);
|
||||
--itemstack.count;
|
||||
return itemstack;
|
||||
} else {
|
||||
return super.b(isourceblock, itemstack);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
final class DispenseBehaviorBonemeal extends DispenseBehaviorItem {
|
||||
|
||||
private boolean b = true;
|
||||
|
||||
DispenseBehaviorBonemeal() {}
|
||||
|
||||
protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
|
||||
if (itemstack.getData() == 15) {
|
||||
EnumFacing enumfacing = BlockDispenser.j_(isourceblock.h());
|
||||
World world = isourceblock.k();
|
||||
int i = isourceblock.getBlockX() + enumfacing.c();
|
||||
int j = isourceblock.getBlockY() + enumfacing.d();
|
||||
int k = isourceblock.getBlockZ() + enumfacing.e();
|
||||
|
||||
if (ItemDye.a(itemstack, world, i, j, k)) {
|
||||
if (!world.isStatic) {
|
||||
world.triggerEffect(2005, i, j, k, 0);
|
||||
}
|
||||
} else {
|
||||
this.b = false;
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
} else {
|
||||
return super.b(isourceblock, itemstack);
|
||||
}
|
||||
}
|
||||
|
||||
protected void a(ISourceBlock isourceblock) {
|
||||
if (this.b) {
|
||||
isourceblock.k().triggerEffect(1000, isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ(), 0);
|
||||
} else {
|
||||
isourceblock.k().triggerEffect(1001, isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ(), 0);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
final class DispenseBehaviorFlintAndSteel extends DispenseBehaviorItem {
|
||||
|
||||
private boolean b = true;
|
||||
|
||||
DispenseBehaviorFlintAndSteel() {}
|
||||
|
||||
protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
|
||||
EnumFacing enumfacing = BlockDispenser.j_(isourceblock.h());
|
||||
World world = isourceblock.k();
|
||||
int i = isourceblock.getBlockX() + enumfacing.c();
|
||||
int j = isourceblock.getBlockY() + enumfacing.d();
|
||||
int k = isourceblock.getBlockZ() + enumfacing.e();
|
||||
|
||||
if (world.isEmpty(i, j, k)) {
|
||||
world.setTypeIdUpdate(i, j, k, Block.FIRE.id);
|
||||
if (itemstack.isDamaged(1, world.random)) {
|
||||
itemstack.count = 0;
|
||||
}
|
||||
} else if (world.getTypeId(i, j, k) == Block.TNT.id) {
|
||||
Block.TNT.postBreak(world, i, j, k, 1);
|
||||
world.setAir(i, j, k);
|
||||
} else {
|
||||
this.b = false;
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
protected void a(ISourceBlock isourceblock) {
|
||||
if (this.b) {
|
||||
isourceblock.k().triggerEffect(1000, isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ(), 0);
|
||||
} else {
|
||||
isourceblock.k().triggerEffect(1001, isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ(), 0);
|
||||
}
|
||||
}
|
||||
}
|
19
src/main/java/net/minecraft/server/DispenseBehaviorTNT.java
Normal file
19
src/main/java/net/minecraft/server/DispenseBehaviorTNT.java
Normal file
@ -0,0 +1,19 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
final class DispenseBehaviorTNT extends DispenseBehaviorItem {
|
||||
|
||||
DispenseBehaviorTNT() {}
|
||||
|
||||
protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
|
||||
EnumFacing enumfacing = BlockDispenser.j_(isourceblock.h());
|
||||
World world = isourceblock.k();
|
||||
int i = isourceblock.getBlockX() + enumfacing.c();
|
||||
int j = isourceblock.getBlockY() + enumfacing.d();
|
||||
int k = isourceblock.getBlockZ() + enumfacing.e();
|
||||
EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), (EntityLiving) null);
|
||||
|
||||
world.addEntity(entitytntprimed);
|
||||
--itemstack.count;
|
||||
return itemstack;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user