mirror of
https://github.com/barkeser2002/CatServer.git
synced 2026-09-25 01:39:52 +03:00
242 lines
10 KiB
Diff
242 lines
10 KiB
Diff
--- ../src-base/minecraft/net/minecraft/tileentity/TileEntityBeacon.java
|
|
+++ ../src-work/minecraft/net/minecraft/tileentity/TileEntityBeacon.java
|
|
@@ -34,28 +34,61 @@
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
|
|
-public class TileEntityBeacon extends TileEntityLockable implements ITickable, ISidedInventory
|
|
-{
|
|
- public static final Potion[][] EFFECTS_LIST = new Potion[][] {{MobEffects.SPEED, MobEffects.HASTE}, {MobEffects.RESISTANCE, MobEffects.JUMP_BOOST}, {MobEffects.STRENGTH}, {MobEffects.REGENERATION}};
|
|
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
|
+import org.bukkit.craftbukkit.potion.CraftPotionUtil;
|
|
+import org.bukkit.entity.HumanEntity;
|
|
+
|
|
+public class TileEntityBeacon extends TileEntityLockable implements ITickable, ISidedInventory {
|
|
+ public static final Potion[][] EFFECTS_LIST = new Potion[][]{{MobEffects.SPEED, MobEffects.HASTE}, {MobEffects.RESISTANCE, MobEffects.JUMP_BOOST}, {MobEffects.STRENGTH}, {MobEffects.REGENERATION}};
|
|
private static final Set<Potion> VALID_EFFECTS = Sets.<Potion>newHashSet();
|
|
- private final List<TileEntityBeacon.BeamSegment> beamSegments = Lists.<TileEntityBeacon.BeamSegment>newArrayList();
|
|
+ private final List<BeamSegment> beamSegments = Lists.<BeamSegment>newArrayList();
|
|
@SideOnly(Side.CLIENT)
|
|
private long beamRenderCounter;
|
|
@SideOnly(Side.CLIENT)
|
|
private float beamRenderScale;
|
|
private boolean isComplete;
|
|
- private int levels = -1;
|
|
+ public int levels = -1;
|
|
@Nullable
|
|
- private Potion primaryEffect;
|
|
+ public Potion primaryEffect;
|
|
@Nullable
|
|
- private Potion secondaryEffect;
|
|
+ public Potion secondaryEffect;
|
|
private ItemStack payment = ItemStack.EMPTY;
|
|
private String customName;
|
|
+ // CraftBukkit start - add fields and methods
|
|
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
|
+ private int maxStack = MAX_STACK;
|
|
+
|
|
+ public List<ItemStack> getContents() {
|
|
+ return Arrays.asList(this.payment);
|
|
+ }
|
|
+
|
|
+ public void onOpen(CraftHumanEntity who) {
|
|
+ transaction.add(who);
|
|
+ }
|
|
+
|
|
+ public void onClose(CraftHumanEntity who) {
|
|
+ transaction.remove(who);
|
|
+ }
|
|
+
|
|
+ public List<HumanEntity> getViewers() {
|
|
+ return transaction;
|
|
+ }
|
|
+
|
|
+ public void setMaxStackSize(int size) {
|
|
+ maxStack = size;
|
|
+ }
|
|
+
|
|
+ public org.bukkit.potion.PotionEffect getPrimaryEffect() {
|
|
+ return (this.primaryEffect != null) ? CraftPotionUtil.toBukkit(new net.minecraft.potion.PotionEffect(this.primaryEffect, this.getLevel(), this.getAmplification(), true, true)) : null;
|
|
+ }
|
|
+
|
|
+ public org.bukkit.potion.PotionEffect getSecondaryEffect() {
|
|
+ return (hasSecondaryEffect()) ? CraftPotionUtil.toBukkit(new net.minecraft.potion.PotionEffect(this.secondaryEffect, this.getLevel(), this.getAmplification(), true, true)) : null;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
|
|
- public void update()
|
|
- {
|
|
- if (this.world.getTotalWorldTime() % 80L == 0L)
|
|
- {
|
|
+ public void update() {
|
|
+ if (this.world.getTotalWorldTime() % 80L == 0L) {
|
|
this.updateBeacon();
|
|
}
|
|
}
|
|
@@ -69,39 +102,54 @@
|
|
}
|
|
}
|
|
|
|
- private void addEffectsToPlayers()
|
|
- {
|
|
- if (this.isComplete && this.levels > 0 && !this.world.isRemote && this.primaryEffect != null)
|
|
- {
|
|
- double d0 = (double)(this.levels * 10 + 10);
|
|
- int i = 0;
|
|
+ // CraftBukkit start - split into components
|
|
+ private byte getAmplification() {
|
|
+ byte i = 0;
|
|
|
|
- if (this.levels >= 4 && this.primaryEffect == this.secondaryEffect)
|
|
- {
|
|
- i = 1;
|
|
- }
|
|
+ if (this.levels >= 4 && this.primaryEffect == this.secondaryEffect) {
|
|
+ i = 1;
|
|
+ }
|
|
|
|
- int j = (9 + this.levels * 2) * 20;
|
|
- int k = this.pos.getX();
|
|
- int l = this.pos.getY();
|
|
- int i1 = this.pos.getZ();
|
|
- AxisAlignedBB axisalignedbb = (new AxisAlignedBB((double)k, (double)l, (double)i1, (double)(k + 1), (double)(l + 1), (double)(i1 + 1))).grow(d0).expand(0.0D, (double)this.world.getHeight(), 0.0D);
|
|
- List<EntityPlayer> list = this.world.<EntityPlayer>getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb);
|
|
+ return i;
|
|
+ }
|
|
|
|
- for (EntityPlayer entityplayer : list)
|
|
- {
|
|
- entityplayer.addPotionEffect(new PotionEffect(this.primaryEffect, j, i, true, true));
|
|
- }
|
|
+ private int getLevel() {
|
|
+ return (9 + this.levels * 2) * 20;
|
|
+ }
|
|
|
|
- if (this.levels >= 4 && this.primaryEffect != this.secondaryEffect && this.secondaryEffect != null)
|
|
- {
|
|
- for (EntityPlayer entityplayer1 : list)
|
|
- {
|
|
- entityplayer1.addPotionEffect(new PotionEffect(this.secondaryEffect, j, 0, true, true));
|
|
- }
|
|
+ public List<EntityPlayer> getHumansInRange() {
|
|
+ double d0 = (double) (this.levels * 10 + 10);
|
|
+ int k = this.pos.getX();
|
|
+ int l = this.pos.getY();
|
|
+ int i1 = this.pos.getZ();
|
|
+ AxisAlignedBB axisalignedbb = (new AxisAlignedBB((double)k, (double)l, (double)i1, (double)(k + 1), (double)(l + 1), (double)(i1 + 1))).grow(d0).expand(0.0D, (double)this.world.getHeight(), 0.0D);
|
|
+ return this.world.getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb);
|
|
+ }
|
|
+
|
|
+ private void applyEffect(List<EntityPlayer> list, Potion effects, int i, int b0) {
|
|
+ for (EntityPlayer entityplayer : list)
|
|
+ entityplayer.addPotionEffect(new PotionEffect(effects, i, b0, true, true));
|
|
+ }
|
|
+
|
|
+ private boolean hasSecondaryEffect() {
|
|
+ return this.levels >= 4 && this.primaryEffect != this.secondaryEffect && this.secondaryEffect != null;
|
|
+ }
|
|
+
|
|
+ private void addEffectsToPlayers() {
|
|
+ if (this.isComplete && this.levels > 0 && !this.world.isRemote && this.primaryEffect != null) {
|
|
+ byte b0 = getAmplification();
|
|
+
|
|
+ int i = getLevel();
|
|
+ List list = getHumansInRange();
|
|
+
|
|
+ applyEffect(list, this.primaryEffect, i, b0);
|
|
+
|
|
+ if (hasSecondaryEffect()) {
|
|
+ applyEffect(list, this.secondaryEffect, i, 0);
|
|
}
|
|
}
|
|
}
|
|
+ // CraftBukkit end
|
|
|
|
private void updateSegmentColors()
|
|
{
|
|
@@ -112,7 +160,7 @@
|
|
this.levels = 0;
|
|
this.beamSegments.clear();
|
|
this.isComplete = true;
|
|
- TileEntityBeacon.BeamSegment tileentitybeacon$beamsegment = new TileEntityBeacon.BeamSegment(EnumDyeColor.WHITE.getColorComponentValues());
|
|
+ BeamSegment tileentitybeacon$beamsegment = new BeamSegment(EnumDyeColor.WHITE.getColorComponentValues());
|
|
this.beamSegments.add(tileentitybeacon$beamsegment);
|
|
boolean flag = true;
|
|
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
|
@@ -130,17 +178,21 @@
|
|
{
|
|
if (iblockstate.getBlock() != Blocks.STAINED_GLASS_PANE)
|
|
{
|
|
- if (iblockstate.getLightOpacity() >= 15 && iblockstate.getBlock() != Blocks.BEDROCK)
|
|
+ if (iblockstate.getLightOpacity(world, blockpos$mutableblockpos) >= 15 && iblockstate.getBlock() != Blocks.BEDROCK)
|
|
{
|
|
this.isComplete = false;
|
|
this.beamSegments.clear();
|
|
break;
|
|
}
|
|
-
|
|
+ float[] customColor = iblockstate.getBlock().getBeaconColorMultiplier(iblockstate, this.world, blockpos$mutableblockpos, getPos());
|
|
+ if (customColor != null)
|
|
+ afloat = customColor;
|
|
+ else {
|
|
tileentitybeacon$beamsegment.incrementHeight();
|
|
continue;
|
|
+ }
|
|
}
|
|
-
|
|
+ else
|
|
afloat = ((EnumDyeColor)iblockstate.getValue(BlockStainedGlassPane.COLOR)).getColorComponentValues();
|
|
}
|
|
|
|
@@ -155,7 +207,7 @@
|
|
}
|
|
else
|
|
{
|
|
- tileentitybeacon$beamsegment = new TileEntityBeacon.BeamSegment(afloat);
|
|
+ tileentitybeacon$beamsegment = new BeamSegment(afloat);
|
|
this.beamSegments.add(tileentitybeacon$beamsegment);
|
|
}
|
|
|
|
@@ -181,7 +233,7 @@
|
|
{
|
|
Block block = this.world.getBlockState(new BlockPos(j1, i2, k1)).getBlock();
|
|
|
|
- if (block != Blocks.EMERALD_BLOCK && block != Blocks.GOLD_BLOCK && block != Blocks.DIAMOND_BLOCK && block != Blocks.IRON_BLOCK)
|
|
+ if (!block.isBeaconBase(this.world, new BlockPos(j1, i2, k1), getPos()))
|
|
{
|
|
flag1 = false;
|
|
break;
|
|
@@ -211,7 +263,7 @@
|
|
}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
- public List<TileEntityBeacon.BeamSegment> getBeamSegments()
|
|
+ public List<BeamSegment> getBeamSegments()
|
|
{
|
|
return this.beamSegments;
|
|
}
|
|
@@ -281,8 +333,12 @@
|
|
public void readFromNBT(NBTTagCompound compound)
|
|
{
|
|
super.readFromNBT(compound);
|
|
- this.primaryEffect = isBeaconEffect(compound.getInteger("Primary"));
|
|
- this.secondaryEffect = isBeaconEffect(compound.getInteger("Secondary"));
|
|
+ // Craftbukkit start - persist manually set non-default beacon effects (SPIGOT-3598)
|
|
+ // this.primaryEffect = isBeaconEffect(compound.getInteger("Primary"));
|
|
+ // this.secondaryEffect = isBeaconEffect(compound.getInteger("Secondary"));
|
|
+ this.primaryEffect = Potion.getPotionById(compound.getInteger("Primary"));
|
|
+ this.secondaryEffect = Potion.getPotionById(compound.getInteger("Secondary"));
|
|
+ // Craftbukkit end
|
|
this.levels = compound.getInteger("Levels");
|
|
}
|
|
|
|
@@ -395,7 +451,7 @@
|
|
|
|
public boolean isItemValidForSlot(int index, ItemStack stack)
|
|
{
|
|
- return stack.getItem() == Items.EMERALD || stack.getItem() == Items.DIAMOND || stack.getItem() == Items.GOLD_INGOT || stack.getItem() == Items.IRON_INGOT;
|
|
+ return stack.getItem() != null && stack.getItem().isBeaconPayment(stack);
|
|
}
|
|
|
|
public String getGuiID()
|