Skip to content

Commit

Permalink
Merge pull request #4 from kettingpowered/1.20.x
Browse files Browse the repository at this point in the history
Upstream
  • Loading branch information
TonimatasDEV authored Nov 17, 2023
2 parents 1d89af2 + 890e8ec commit be0b45a
Show file tree
Hide file tree
Showing 23 changed files with 871 additions and 13,653 deletions.
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,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: 314 / 530
Bukkit: 348 / 530
<br>
CraftBukkit: 0 / 685

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
--- a/net/minecraft/server/ReloadableServerResources.java
+++ b/net/minecraft/server/ReloadableServerResources.java
@@ -29,10 +_,10 @@
@@ -28,11 +_,11 @@
private static final Logger LOGGER = LogUtils.getLogger();
private static final CompletableFuture<Unit> DATA_RELOAD_INITIAL_TASK = CompletableFuture.completedFuture(Unit.INSTANCE);
private final CommandBuildContext.Configurable commandBuildContext;
private final Commands commands;
- private final Commands commands;
- private final RecipeManager recipes = new RecipeManager();
+ public final Commands commands;
+ private final RecipeManager recipes;
private final TagManager tagManager;
private final LootDataManager lootData = new LootDataManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@

public abstract class Animal extends AgeableMob {
protected static final int PARENT_AGE_AFTER_BREEDING = 6000;
private int inLove;
- private int inLove;
+ public int inLove;
@Nullable
private UUID loveCause;
- private UUID loveCause;
+ public UUID loveCause;
+ public ItemStack breedItem; // CraftBukkit - Add breedItem variable

protected Animal(EntityType<? extends Animal> p_27557_, Level p_27558_) {
super(p_27557_, p_27558_);
@@ -72,8 +_,14 @@
@@ -72,8 +_,13 @@
if (this.isInvulnerableTo(p_27567_)) {
return false;
} else {
Expand All @@ -27,14 +29,13 @@
+ boolean result = super.hurt(p_27567_, p_27568_);
+ if (result) {
+ this.inLove = 0;
+ return super.hurt(p_27567_, p_27568_);
+ }
+ return result;
+ // CraftBukkit end
}
}

@@ -156,7 +_,13 @@
@@ -156,10 +_,17 @@
}

public void setInLove(@Nullable Player p_27596_) {
Expand All @@ -49,6 +50,10 @@
if (p_27596_ != null) {
this.loveCause = p_27596_.getUUID();
}
+ this.breedItem = p_27596_.getInventory().getSelected(); // CraftBukkit

this.level().broadcastEntityEvent(this, (byte)18);
}
@@ -202,15 +_,43 @@

public void spawnChildFromBreeding(ServerLevel p_27564_, Animal p_27565_) {
Expand All @@ -67,7 +72,7 @@
if (ageablemob != null) {
ageablemob.setBaby(true);
ageablemob.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F);
this.finalizeSpawnChildFromBreeding(p_27564_, p_27565_, ageablemob);
- this.finalizeSpawnChildFromBreeding(p_27564_, p_27565_, ageablemob);
- p_27564_.addFreshEntityWithPassengers(ageablemob);
+ // CraftBukkit start - call EntityBreedEvent
+ ServerPlayer breeder = Optional.ofNullable(this.getLoveCause()).or(() -> {
Expand All @@ -91,6 +96,7 @@
+ }
+
+ public void finalizeSpawnChildFromBreeding(ServerLevel p_277963_, Animal p_277357_, @Nullable AgeableMob p_277516_, int experience) {
+ // CraftBukkit end
Optional.ofNullable(this.getLoveCause()).or(() -> {
return Optional.ofNullable(p_277357_.getLoveCause());
}).ifPresent((p_277486_) -> {
Expand Down
18 changes: 18 additions & 0 deletions patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@

public class Bee extends Animal implements NeutralMob, FlyingAnimal {
public static final float FLAP_DEGREES_PER_TICK = 120.32113F;
@@ -121,7 +_,7 @@
private float rollAmountO;
private int timeSinceSting;
int ticksWithoutNectarSinceExitingHive;
- private int stayOutOfHiveCountdown;
+ public int stayOutOfHiveCountdown;
private int numCropsGrownSincePollination;
private static final int COOLDOWN_BEFORE_LOCATING_NEW_HIVE = 200;
int remainingCooldownBeforeLocatingNewHive;
@@ -130,7 +_,7 @@
@Nullable
BlockPos savedFlowerPos;
@Nullable
- BlockPos hivePos;
+ public BlockPos hivePos;
Bee.BeePollinateGoal beePollinateGoal;
Bee.BeeGoToHiveGoal goToHiveGoal;
private Bee.BeeGoToKnownFlowerGoal goToKnownFlowerGoal;
@@ -230,7 +_,7 @@
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
+ p_148831_.getEntityData().refresh((ServerPlayer) p_148829_); // Need to send data such as the display name to client
+ return Optional.of(InteractionResult.FAIL);
+ }
+ p_148831_.playSound(((Bucketable) p_148831_).getPickupSound(), 1.0F, 1.0F);
+ p_148831_.playSound(p_148831_.getPickupSound(), 1.0F, 1.0F);
+ // CraftBukkit end
+
ItemStack itemstack2 = ItemUtils.createFilledResult(itemstack, p_148829_, itemstack1, false);
Expand Down
17 changes: 15 additions & 2 deletions patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
--- a/net/minecraft/world/entity/animal/Fox.java
+++ b/net/minecraft/world/entity/animal/Fox.java
@@ -103,8 +_,8 @@
private static final int FLAG_SLEEPING = 32;
private static final int FLAG_FACEPLANTED = 64;
private static final int FLAG_DEFENDING = 128;
- private static final EntityDataAccessor<Optional<UUID>> DATA_TRUSTED_ID_0 = SynchedEntityData.defineId(Fox.class, EntityDataSerializers.OPTIONAL_UUID);
- private static final EntityDataAccessor<Optional<UUID>> DATA_TRUSTED_ID_1 = SynchedEntityData.defineId(Fox.class, EntityDataSerializers.OPTIONAL_UUID);
+ public static final EntityDataAccessor<Optional<UUID>> DATA_TRUSTED_ID_0 = SynchedEntityData.defineId(Fox.class, EntityDataSerializers.OPTIONAL_UUID);
+ public static final EntityDataAccessor<Optional<UUID>> DATA_TRUSTED_ID_1 = SynchedEntityData.defineId(Fox.class, EntityDataSerializers.OPTIONAL_UUID);
static final Predicate<ItemEntity> ALLOWED_ITEMS = (p_296798_) -> {
return !p_296798_.hasPickUpDelay() && p_296798_.isAlive();
};
@@ -482,7 +_,8 @@

protected void pickUpItem(ItemEntity p_28514_) {
Expand Down Expand Up @@ -92,10 +103,12 @@
BlockState blockstate = Fox.this.level().getBlockState(this.blockPos);
if (blockstate.is(Blocks.SWEET_BERRY_BUSH)) {
this.pickSweetBerries(blockstate);
@@ -904,6 +_,11 @@
@@ -903,7 +_,12 @@

private void pickSweetBerries(BlockState p_148929_) {
int i = p_148929_.getValue(SweetBerryBushBlock.AGE);
p_148929_.setValue(SweetBerryBushBlock.AGE, Integer.valueOf(1));
- p_148929_.setValue(SweetBerryBushBlock.AGE, Integer.valueOf(1));
+ p_148929_.setValue(SweetBerryBushBlock.AGE, 1);
+ // CraftBukkit start - call EntityChangeBlockEvent
+ if (!org.bukkit.craftbukkit.v1_20_R2.event.CraftEventFactory.callEntityChangeBlockEvent(Fox.this, this.blockPos, p_148929_.setValue(SweetBerryBushBlock.AGE, 1))) {
+ return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
protected void doPush(Entity p_28839_) {
if (p_28839_ instanceof Enemy && !(p_28839_ instanceof Creeper) && this.getRandom().nextInt(20) == 0) {
- this.setTarget((LivingEntity)p_28839_);
+ this.setTarget((LivingEntity)p_28839_, org.bukkit.event.entity.EntityTargetLivingEntityEvent.TargetReason.COLLISION, true); // CraftBukkit - set reason;
+ this.setTarget((LivingEntity)p_28839_, org.bukkit.event.entity.EntityTargetLivingEntityEvent.TargetReason.COLLISION, true); // CraftBukkit - set reason
}

super.doPush(p_28839_);
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,12 @@
private static final EntityDataAccessor<String> DATA_TYPE = SynchedEntityData.defineId(MushroomCow.class, EntityDataSerializers.STRING);
private static final int MUTATE_CHANCE = 1024;
private static final String TAG_STEW_EFFECTS = "stew_effects";
@@ -102,7 +_,12 @@
@@ -102,7 +_,7 @@

this.playSound(soundevent, 1.0F, 1.0F);
return InteractionResult.sidedSuccess(this.level().isClientSide);
- } else if (itemstack.is(Items.SHEARS) && this.readyForShearing()) {
+ } else if (false && itemstack.getItem() == Items.SHEARS && this.readyForShearing()) { //Forge: Moved to onSheared
+ // CraftBukkit start
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(p_28941_, this, itemstack, p_28942_)) {
+ return InteractionResult.PASS;
+ }
+ // CraftBukkit end
this.shear(SoundSource.PLAYERS);
this.gameEvent(GameEvent.SHEAR, p_28941_);
if (!this.level().isClientSide) {
Expand Down
12 changes: 10 additions & 2 deletions patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
--- a/net/minecraft/world/entity/animal/Pig.java
+++ b/net/minecraft/world/entity/animal/Pig.java
@@ -47,6 +_,7 @@
@@ -47,13 +_,14 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
+import org.bukkit.craftbukkit.v1_20_R2.event.CraftEventFactory;
import org.joml.Vector3f;

public class Pig extends Animal implements ItemSteerable, Saddleable {
private static final EntityDataAccessor<Boolean> DATA_SADDLE_ID = SynchedEntityData.defineId(Pig.class, EntityDataSerializers.BOOLEAN);
private static final EntityDataAccessor<Integer> DATA_BOOST_TIME = SynchedEntityData.defineId(Pig.class, EntityDataSerializers.INT);
private static final Ingredient FOOD_ITEMS = Ingredient.of(Items.CARROT, Items.POTATO, Items.BEETROOT);
- private final ItemBasedSteering steering = new ItemBasedSteering(this.entityData, DATA_BOOST_TIME, DATA_SADDLE_ID);
+ public final ItemBasedSteering steering = new ItemBasedSteering(this.entityData, DATA_BOOST_TIME, DATA_SADDLE_ID);

public Pig(EntityType<? extends Pig> p_29462_, Level p_29463_) {
super(p_29462_, p_29463_);
@@ -203,7 +_,7 @@
}

Expand All @@ -22,11 +30,11 @@

zombifiedpiglin.setPersistenceRequired();
- p_29473_.addFreshEntity(zombifiedpiglin);
+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, zombifiedpiglin);
+ // CraftBukkit start
+ if (CraftEventFactory.callPigZapEvent(this, p_29474_, zombifiedpiglin).isCancelled()) {
+ return;
+ }
+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, zombifiedpiglin); //Ketting
+ // CraftBukkit - added a reason for spawning this creature
+ p_29473_.addFreshEntity(zombifiedpiglin, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
+ // CraftBukkit end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,15 @@
private static final int EAT_ANIMATION_TICKS = 40;
private static final EntityDataAccessor<Byte> DATA_WOOL_ID = SynchedEntityData.defineId(Sheep.class, EntityDataSerializers.BYTE);
private static final Map<DyeColor, ItemLike> ITEM_BY_DYE = Util.make(Maps.newEnumMap(DyeColor.class), (p_29841_) -> {
@@ -235,8 +_,13 @@
@@ -235,7 +_,7 @@

public InteractionResult mobInteract(Player p_29853_, InteractionHand p_29854_) {
ItemStack itemstack = p_29853_.getItemInHand(p_29854_);
- if (itemstack.is(Items.SHEARS)) {
+ if (false && itemstack.getItem() == Items.SHEARS) { //Forge: Moved to onSheared
if (!this.level().isClientSide && this.readyForShearing()) {
+ // CraftBukkit start
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(p_29853_, this, itemstack, p_29854_)) {
+ return InteractionResult.PASS;
+ }
+ // CraftBukkit end
this.shear(SoundSource.PLAYERS);
this.gameEvent(GameEvent.SHEAR, p_29853_);
itemstack.hurtAndBreak(1, p_29853_, (p_29822_) -> {
@@ -257,7 +_,9 @@
int i = 1 + this.random.nextInt(3);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,12 @@
this.level().gameEvent(GameEvent.BLOCK_PLACE, blockpos, GameEvent.Context.of(this, blockstate));
}
}
@@ -130,7 +_,12 @@
@@ -130,7 +_,7 @@

protected InteractionResult mobInteract(Player p_29920_, InteractionHand p_29921_) {
ItemStack itemstack = p_29920_.getItemInHand(p_29921_);
- if (itemstack.is(Items.SHEARS) && this.readyForShearing()) {
+ if (false && itemstack.getItem() == Items.SHEARS && this.readyForShearing()) { //Forge: Moved to onSheared
+ // CraftBukkit start
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(p_29920_, this, itemstack, p_29921_)) {
+ return InteractionResult.PASS;
+ }
+ // CraftBukkit end
this.shear(SoundSource.PLAYERS);
this.gameEvent(GameEvent.SHEAR, p_29920_);
if (!this.level().isClientSide) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@
return InteractionResult.SUCCESS;
} else {
if (item instanceof DyeItem) {
@@ -354,7 +_,7 @@
this.setOrderedToSit(!this.isOrderedToSit());
this.jumping = false;
this.navigation.stop();
- this.setTarget((LivingEntity)null);
+ this.setTarget((LivingEntity)null, EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason
return InteractionResult.SUCCESS;
} else {
return interactionresult;
@@ -365,10 +_,11 @@
itemstack.shrink(1);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
--- a/net/minecraft/world/entity/animal/allay/Allay.java
+++ b/net/minecraft/world/entity/animal/allay/Allay.java
@@ -95,6 +_,7 @@
@@ -88,13 +_,14 @@
private final DynamicGameEventListener<Allay.JukeboxListener> dynamicJukeboxListener;
private final SimpleContainer inventory = new SimpleContainer(1);
@Nullable
- private BlockPos jukeboxPos;
- private long duplicationCooldown;
+ public BlockPos jukeboxPos;
+ public long duplicationCooldown;
private float holdingItemAnimationTicks;
private float holdingItemAnimationTicks0;
private float dancingAnimationTicks;
private float spinningAnimationTicks;
private float spinningAnimationTicks0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
--- a/net/minecraft/world/entity/animal/frog/Tadpole.java
+++ b/net/minecraft/world/entity/animal/frog/Tadpole.java
@@ -40,7 +_,7 @@
public static int ticksToBeFrog = Math.abs(-24000);
public static float HITBOX_WIDTH = 0.4F;
public static float HITBOX_HEIGHT = 0.3F;
- private int age;
+ public int age;
protected static final ImmutableList<SensorType<? extends Sensor<? super Tadpole>>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.HURT_BY, SensorType.FROG_TEMPTATIONS);
protected static final ImmutableList<MemoryModuleType<?>> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.LOOK_TARGET, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.NEAREST_VISIBLE_ADULT, MemoryModuleType.TEMPTATION_COOLDOWN_TICKS, MemoryModuleType.IS_TEMPTED, MemoryModuleType.TEMPTING_PLAYER, MemoryModuleType.BREED_TARGET, MemoryModuleType.IS_PANICKING);

@@ -208,8 +_,14 @@
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@
import org.joml.Vector3f;

public class Goat extends Animal {
@@ -64,8 +_,8 @@
public static final double GOAT_SCREAMING_CHANCE = 0.02D;
public static final double UNIHORN_CHANCE = (double)0.1F;
private static final EntityDataAccessor<Boolean> DATA_IS_SCREAMING_GOAT = SynchedEntityData.defineId(Goat.class, EntityDataSerializers.BOOLEAN);
- private static final EntityDataAccessor<Boolean> DATA_HAS_LEFT_HORN = SynchedEntityData.defineId(Goat.class, EntityDataSerializers.BOOLEAN);
- private static final EntityDataAccessor<Boolean> DATA_HAS_RIGHT_HORN = SynchedEntityData.defineId(Goat.class, EntityDataSerializers.BOOLEAN);
+ public static final EntityDataAccessor<Boolean> DATA_HAS_LEFT_HORN = SynchedEntityData.defineId(Goat.class, EntityDataSerializers.BOOLEAN);
+ public static final EntityDataAccessor<Boolean> DATA_HAS_RIGHT_HORN = SynchedEntityData.defineId(Goat.class, EntityDataSerializers.BOOLEAN);
private boolean isLoweringHead;
private int lowerHeadTick;

@@ -194,8 +_,15 @@
public InteractionResult mobInteract(Player p_149379_, InteractionHand p_149380_) {
ItemStack itemstack = p_149379_.getItemInHand(p_149380_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
import org.joml.Vector3f;

public abstract class AbstractHorse extends Animal implements ContainerListener, HasCustomInventoryScreen, OwnableEntity, PlayerRideableJumping, Saddleable {
@@ -123,7 +_,7 @@
public int tailCounter;
public int sprintCounter;
protected boolean isJumping;
- protected SimpleContainer inventory;
+ public SimpleContainer inventory;
protected int temper;
protected float playerJumpPendingScale;
protected boolean allowStandSliding;
@@ -137,6 +_,7 @@
protected int gallopSoundCounter;
@Nullable
Expand Down
Loading

0 comments on commit be0b45a

Please sign in to comment.