Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/upstream/v5.0-Recode' into…
Browse files Browse the repository at this point in the history
… Folia-v5.0-Recode

# Conflicts:
#	nms/master/src/simplepets/brainsynder/nms/entity/EntityPet.java
#	plugin-distribution/pom.xml
#	resources/plugin.yml
  • Loading branch information
NahuLD committed Dec 5, 2024
2 parents 15ca4b9 + d2c419c commit ab22305
Show file tree
Hide file tree
Showing 69 changed files with 1,668 additions and 257 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:
# The branches below must be a subset of the branches above
branches: [ v5.0-Recode ]
schedule:
- cron: '0 */24 * * *'
- cron: '0 0 * * *'

jobs:
analyze:
Expand All @@ -38,15 +38,15 @@ jobs:

steps:
- name: Setup Java JDK
uses: actions/setup-java@v2.5.0
uses: actions/setup-java@v4.5.0
with:
# The Java version to set up. Takes a whole or semver Java version. See examples of supported syntax in README file
java-version: 21
# Java distribution. See the list of supported distributions in README file
distribution: microsoft

- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4.2.2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
2 changes: 1 addition & 1 deletion nms/master/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<properties>
<module.info>-NMS_Master-IGNORE</module.info>
<java.version>17</java.version>
<java.version>21</java.version>
</properties>

<dependencies>
Expand Down
18 changes: 18 additions & 0 deletions nms/master/src/simplepets/brainsynder/nms/VersionTranslator.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
import lib.brainsynder.ServerVersion;
import lib.brainsynder.nbt.StorageTagCompound;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.core.Vec3i;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket;
import net.minecraft.network.syncher.EntityDataSerializer;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerEntity;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.EquipmentSlot;
Expand All @@ -21,6 +24,7 @@
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.v1_21_R2.util.CraftNamespacedKey;
import org.bukkit.event.entity.CreatureSpawnEvent;
import simplepets.brainsynder.nms.entity.EntityPet;

Expand Down Expand Up @@ -175,4 +179,18 @@ public static boolean isWalkable (EntityPet entity, BlockPos.MutableBlockPos blo
public static void overrideAttributeMap (EntityPet entityPet) {
throw new UnsupportedOperationException ("Missing support for "+ ServerVersion.getVersion().name());
}

// ADDED DURING 1.21.3 DEVELOPMENT
public static <T> T getRegistryValue (Registry<T> registry, NamespacedKey key) {
registry.get(CraftNamespacedKey.toMinecraft(key));
throw new UnsupportedOperationException ("Missing support for "+ ServerVersion.getVersion().name());
}

public static void killEntity (Entity entity, ServerLevel level) {
throw new UnsupportedOperationException ("Missing support for "+ ServerVersion.getVersion().name());
}

public static ClientboundTeleportEntityPacket getTeleportPacket (Entity entity) {
throw new UnsupportedOperationException ("Missing support for "+ ServerVersion.getVersion().name());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import simplepets.brainsynder.api.user.PetUser;
import simplepets.brainsynder.nms.utils.PetDataAccess;

public abstract class EntityAgeablePet extends EntityPet implements IAgeablePet {
public abstract class EntityAgeablePet extends EntityPetOverride implements IAgeablePet {
private static final EntityDataAccessor<Boolean> BABY = SynchedEntityData.defineId(EntityAgeablePet.class, EntityDataSerializers.BOOLEAN);

public EntityAgeablePet(EntityType<? extends Mob> entitytypes, PetType type, PetUser user) {
Expand Down
20 changes: 1 addition & 19 deletions nms/master/src/simplepets/brainsynder/nms/entity/EntityBase.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package simplepets.brainsynder.nms.entity;

import lib.brainsynder.ServerVersion;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import simplepets.brainsynder.api.pet.PetType;
Expand All @@ -13,9 +11,6 @@
import simplepets.brainsynder.nms.entity.list.EntityRabbitPet;
import simplepets.brainsynder.nms.entity.list.EntitySlimePet;
import simplepets.brainsynder.nms.utils.PetDataAccess;
import simplepets.brainsynder.utils.VersionFields;

import java.lang.reflect.Field;

public class EntityBase extends Mob {
protected final EntityType<? extends Mob> entityType;
Expand Down Expand Up @@ -89,19 +84,6 @@ public PetUser getUser() {
}

EntityType<? extends Mob> getEntityType(EntityType<? extends Mob> originalType) {
try {
Field field = EntityType.class.getDeclaredField(VersionFields.fromServerVersion(ServerVersion.getVersion()).getEntityFactoryField());
field.setAccessible(true);
EntityType.Builder<? extends Mob> builder = EntityType.Builder.of((EntityType.EntityFactory<? extends Mob>) field.get(originalType), MobCategory.AMBIENT);
builder.sized(0.1f, 0.1f);
return builder.build(petType.name().toLowerCase());
} catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
return originalType;
}
}

public boolean alwaysAccepts() {
return super.alwaysAccepts();
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

// Implement Bucketable so the server resends the entity when the client tries
// to pick it up with a bucket
public class EntityFishPet extends EntityPet implements IEntityFishPet, Bucketable {
public class EntityFishPet extends EntityPetOverride implements IEntityFishPet, Bucketable {
private static final EntityDataAccessor<Boolean> FROM_BUCKET = SynchedEntityData.defineId(EntityFishPet.class, EntityDataSerializers.BOOLEAN);

public EntityFishPet(EntityType<? extends Mob> entitytypes, PetType type, PetUser user) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import simplepets.brainsynder.api.user.PetUser;
import simplepets.brainsynder.nms.VersionTranslator;

public abstract class EntityFlyablePet extends EntityPet implements IFlyableEntity {
public abstract class EntityFlyablePet extends EntityPetOverride implements IFlyableEntity {
public EntityFlyablePet(EntityType<? extends Mob> entitytypes, PetType type, PetUser user) {
super(entitytypes, type, user);
this.moveControl = new FlyingMoveControl(this, 20, false);
Expand Down
Loading

0 comments on commit ab22305

Please sign in to comment.