mirror of
https://github.com/barkeser2002/CatServer.git
synced 2026-09-25 08:39:58 +03:00
178 lines
6.6 KiB
Diff
178 lines
6.6 KiB
Diff
--- ../src-base/minecraft/net/minecraft/tileentity/TileEntityBeacon.java
|
|
+++ ../src-work/minecraft/net/minecraft/tileentity/TileEntityBeacon.java
|
|
@@ -15,10 +15,10 @@
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
|
import net.minecraft.init.Blocks;
|
|
-import net.minecraft.init.Items;
|
|
import net.minecraft.init.MobEffects;
|
|
import net.minecraft.inventory.Container;
|
|
import net.minecraft.inventory.ContainerBeacon;
|
|
+import net.minecraft.inventory.IInventory;
|
|
import net.minecraft.inventory.ISidedInventory;
|
|
import net.minecraft.item.EnumDyeColor;
|
|
import net.minecraft.item.ItemStack;
|
|
@@ -33,9 +33,17 @@
|
|
import net.minecraft.util.math.BlockPos;
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
+import luohuayu.CatServer.tileentity.CBTileEntityLockable;
|
|
|
|
-public class TileEntityBeacon extends TileEntityLockable implements ITickable, ISidedInventory
|
|
-{
|
|
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
|
+import org.bukkit.craftbukkit.potion.CraftPotionUtil;
|
|
+import org.bukkit.entity.HumanEntity;
|
|
+
|
|
+//CraftBukkit start
|
|
+
|
|
+//CraftBukkit end
|
|
+
|
|
+public class TileEntityBeacon extends CBTileEntityLockable implements ITickable, IInventory, 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();
|
|
@@ -44,13 +52,45 @@
|
|
@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;
|
|
private String customName;
|
|
+ // CraftBukkit start - add fields and methods
|
|
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
|
+ private int maxStack = MAX_STACK;
|
|
+
|
|
+ public ItemStack[] getContents() {
|
|
+ return new ItemStack[] { 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()
|
|
{
|
|
@@ -68,41 +108,66 @@
|
|
this.addEffectsToPlayers();
|
|
}
|
|
}
|
|
-
|
|
- private void addEffectsToPlayers()
|
|
- {
|
|
- if (this.isComplete && this.levels > 0 && !this.worldObj.isRemote && this.primaryEffect != null)
|
|
- {
|
|
- double d0 = (double)(this.levels * 10 + 10);
|
|
+ private byte getAmplification() {
|
|
+ //if (this.isComplete && this.levels > 0 && !this.worldObj.isRemote && this.primaryEffect != null)
|
|
+ //{
|
|
+ // double d0 = (double)(this.levels * 10 + 10);
|
|
int i = 0;
|
|
|
|
if (this.levels >= 4 && this.primaryEffect == this.secondaryEffect)
|
|
{
|
|
i = 1;
|
|
}
|
|
-
|
|
- int j = (9 + this.levels * 2) * 20;
|
|
+ return (byte) i;
|
|
+ //}
|
|
+ //return 0;
|
|
+ }
|
|
+ private int getLevel() {
|
|
+ {
|
|
+ return (9 + this.levels * 2) * 20;
|
|
+ }
|
|
+ }
|
|
+ public List 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))).expandXyz(d0).addCoord(0.0D, (double)this.worldObj.getHeight(), 0.0D);
|
|
List<EntityPlayer> list = this.worldObj.<EntityPlayer>getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb);
|
|
-
|
|
+ return list;
|
|
+ }
|
|
+ }
|
|
+ private void applyEffect(List<EntityPlayer> list, Potion effects, int i, int b0) {
|
|
+ {
|
|
for (EntityPlayer entityplayer : list)
|
|
{
|
|
- entityplayer.addPotionEffect(new PotionEffect(this.primaryEffect, j, i, true, true));
|
|
+ entityplayer.addPotionEffect(new PotionEffect(effects, i, b0, true, true));
|
|
}
|
|
-
|
|
- 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));
|
|
- }
|
|
+ }
|
|
+ }
|
|
+ private boolean hasSecondaryEffect() {
|
|
+ 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));
|
|
+ //}
|
|
+ return true;
|
|
+ }
|
|
+ return false;
|
|
+ }
|
|
+ private void addEffectsToPlayers() {
|
|
+ if (this.isComplete && this.levels > 0 && !this.worldObj.isRemote && this.primaryEffect != null) {
|
|
+ final byte b0 = this.getAmplification();
|
|
+ final int i = this.getLevel();
|
|
+ final List list = this.getHumansInRange();
|
|
+ this.applyEffect(list, this.primaryEffect, i, b0);
|
|
+ if (this.hasSecondaryEffect()) {
|
|
+ this.applyEffect(list, this.secondaryEffect, i, 0);
|
|
}
|
|
}
|
|
}
|
|
-
|
|
private void updateSegmentColors()
|
|
{
|
|
int i = this.levels;
|
|
@@ -298,7 +363,7 @@
|
|
|
|
public int getSizeInventory()
|
|
{
|
|
- return 1;
|
|
+ return maxStack; // CraftBukkit
|
|
}
|
|
|
|
@Nullable
|