Skip to content

Commit

Permalink
Merge branch 'kettingpowered:1.20.x' into 1.20.x
Browse files Browse the repository at this point in the history
  • Loading branch information
C0D3-M4513R authored Nov 12, 2023
2 parents 2325311 + 91558af commit 5809c24
Show file tree
Hide file tree
Showing 11 changed files with 1,335 additions and 49 deletions.
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ that enables the use of Bukkit plugins on Forge servers.
Ketting is still in development and is not ready for production use.

### PATCHES DONE
Bukkit: 251 / 530
Bukkit: 260 / 530
<br>
CraftBukkit: 0 / 685

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

- entity.teleportTo(p_138731_, (double)Mth.floor(spreadplayerscommand$position.x) + 0.5D, (double)spreadplayerscommand$position.getSpawnY(p_138731_, p_138733_), (double)Mth.floor(spreadplayerscommand$position.z) + 0.5D, Set.of(), entity.getYRot(), entity.getXRot());
+ net.minecraftforge.event.entity.EntityTeleportEvent.SpreadPlayersCommand event = net.minecraftforge.event.ForgeEventFactory.onEntityTeleportSpreadPlayersCommand(entity, (double)Mth.floor(spreadplayerscommand$position.x) + 0.5D, (double)spreadplayerscommand$position.getSpawnY(p_138731_, p_138733_), (double)Mth.floor(spreadplayerscommand$position.z) + 0.5D);
+ if (!event.isCanceled()) entity.teleportToWithTicket(event.getTargetX(), event.getTargetY(), event.getTargetZ(), org.bukkit.event.player.PlayerSpawnChangeEvent.Cause.COMMAND); // CraftBukkit - handle teleport reason //Ketting - modified for forge compat
+ if (!event.isCanceled()) entity.teleportTo(p_138731_, event.getTargetX(), event.getTargetY(), event.getTargetZ(), Set.of(), entity.getYRot(), entity.getXRot(), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit - handle teleport reason //Ketting - modified for forge compat
double d2 = Double.MAX_VALUE;

for(SpreadPlayersCommand.Position spreadplayerscommand$position1 : p_138732_) {
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
--- a/net/minecraft/world/entity/AreaEffectCloud.java
+++ b/net/minecraft/world/entity/AreaEffectCloud.java
@@ -5,6 +_,8 @@
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.logging.LogUtils;
+
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@@ -20,12 +_,14 @@
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.Mth;
+import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.item.alchemy.Potion;
import net.minecraft.world.item.alchemy.PotionUtils;
import net.minecraft.world.item.alchemy.Potions;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.material.PushReaction;
+import org.bukkit.craftbukkit.v1_20_R2.entity.CraftLivingEntity;
import org.slf4j.Logger;

public class AreaEffectCloud extends Entity implements TraceableEntity {
@@ -41,16 +_,16 @@
public static final float DEFAULT_WIDTH = 6.0F;
public static final float HEIGHT = 0.5F;
private static final String TAG_EFFECTS = "effects";
- private Potion potion = Potions.EMPTY;
- private final List<MobEffectInstance> effects = Lists.newArrayList();
+ public Potion potion = Potions.EMPTY;
+ public final List<MobEffectInstance> effects = Lists.newArrayList();
private final Map<Entity, Integer> victims = Maps.newHashMap();
private int duration = 600;
private int waitTime = 20;
- private int reapplicationDelay = 20;
+ public int reapplicationDelay = 20;
private boolean fixedColor;
- private int durationOnUse;
- private float radiusOnUse;
- private float radiusPerTick;
+ public int durationOnUse;
+ public float radiusOnUse;
+ public float radiusPerTick;
@Nullable
private LivingEntity owner;
@Nullable
@@ -150,6 +_,18 @@
this.duration = p_19735_;
}

+ // Spigot start - copied from below
+ @Override
+ public void inactiveTick() {
+ super.inactiveTick();
+
+ if (this.tickCount >= this.waitTime + this.duration) {
+ this.discard();
+ return;
+ }
+ }
+ // Spigot end
+
public void tick() {
super.tick();
boolean flag = this.isWaiting();
@@ -239,19 +_,35 @@
} else {
List<LivingEntity> list1 = this.level().getEntitiesOfClass(LivingEntity.class, this.getBoundingBox());
if (!list1.isEmpty()) {
+ List<org.bukkit.entity.LivingEntity> entities = new java.util.ArrayList<org.bukkit.entity.LivingEntity>(); // CraftBukkit
for(LivingEntity livingentity : list1) {
if (!this.victims.containsKey(livingentity) && livingentity.isAffectedByPotions()) {
double d8 = livingentity.getX() - this.getX();
double d1 = livingentity.getZ() - this.getZ();
double d3 = d8 * d8 + d1 * d1;
if (d3 <= (double)(f * f)) {
- this.victims.put(livingentity, this.tickCount + this.reapplicationDelay);
-
- for(MobEffectInstance mobeffectinstance1 : list) {
- if (mobeffectinstance1.getEffect().isInstantenous()) {
- mobeffectinstance1.getEffect().applyInstantenousEffect(this, this.getOwner(), livingentity, mobeffectinstance1.getAmplifier(), 0.5D);
+ // CraftBukkit start
+ entities.add((org.bukkit.entity.LivingEntity) livingentity.getBukkitEntity());
+ }
+ }
+ }
+
+ org.bukkit.event.entity.AreaEffectCloudApplyEvent event = org.bukkit.craftbukkit.v1_20_R2.event.CraftEventFactory.callAreaEffectCloudApplyEvent(this, entities);
+ if (!event.isCancelled()) {
+ for (org.bukkit.entity.LivingEntity entity : event.getAffectedEntities()) {
+ if (entity instanceof CraftLivingEntity) {
+ LivingEntity entityliving = ((CraftLivingEntity) entity).getHandle();
+ // CraftBukkit end
+ this.victims.put(entityliving, this.tickCount + this.reapplicationDelay);
+ Iterator iterator2 = list.iterator();
+
+ while (iterator2.hasNext()) {
+ MobEffectInstance mobeffect1 = (MobEffectInstance) iterator2.next();
+
+ if (mobeffect1.getEffect().isInstantenous()) {
+ mobeffect1.getEffect().applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect1.getAmplifier(), 0.5D);
} else {
- livingentity.addEffect(new MobEffectInstance(mobeffectinstance1), this);
+ entityliving.addEffect(new MobEffectInstance(mobeffect1), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit
}
}

Loading

0 comments on commit 5809c24

Please sign in to comment.