Skip to content

Commit 92cd566

Browse files
committed
some patches extras
1 parent e852e4a commit 92cd566

16 files changed

Lines changed: 397 additions & 68 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,5 @@ build
4646

4747
**/out/
4848
/projects/cb-base/
49-
/projects/neotenet-base/src/
49+
/projects/neotenet-base/src/
50+
/projects/neotenet-base/other-src/

build.gradle

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,20 @@ tasks.register('applyCBPatches') {
154154
}
155155
}
156156

157+
tasks.register("prepareNeoForgeOtherSrc", Copy) {
158+
group = 'neotenet'
159+
from('src/main/java')
160+
from('projects/neotenet/src/main/java')
161+
into('projects/neotenet-base/other-src/main/java')
162+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
163+
}
164+
157165
tasks.register('prepareNeoForgeBase', Copy) {
158166
group = 'neotenet'
167+
dependsOn 'prepareNeoForgeOtherSrc'
159168

160169
from('projects/neoforge/src/main/java')
161170
into('projects/neotenet-base/src/main/java')
162-
from('projects/neotenet/src/main/java')
163-
into('projects/neotenet-base/src/main/java')
164-
from('src/main/java')
165-
into('projects/neotenet-base/src/main/java')
166171

167172
duplicatesStrategy = DuplicatesStrategy.INCLUDE
168173
}

patches/net/minecraft/commands/CommandSourceStack.java.patch

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
--- a/net/minecraft/commands/CommandSourceStack.java
22
+++ b/net/minecraft/commands/CommandSourceStack.java
3+
@@ -17,6 +_,8 @@
4+
import java.util.function.BinaryOperator;
5+
import java.util.function.Supplier;
6+
import java.util.stream.Stream;
7+
+
8+
+import com.mojang.brigadier.tree.CommandNode;
9+
import net.minecraft.ChatFormatting;
10+
import net.minecraft.advancements.AdvancementHolder;
11+
import net.minecraft.commands.arguments.EntityAnchorArgument;
12+
@@ -35,7 +_,9 @@
13+
import net.minecraft.server.MinecraftServer;
14+
import net.minecraft.server.level.ServerLevel;
15+
import net.minecraft.server.level.ServerPlayer;
16+
+import net.minecraft.server.permissions.Permission;
17+
import net.minecraft.server.permissions.PermissionSet;
18+
+import net.minecraft.server.permissions.Permissions;
19+
import net.minecraft.sounds.SoundEvent;
20+
import net.minecraft.util.Mth;
21+
import net.minecraft.util.TaskChainer;
322
@@ -49,8 +_,9 @@
423
import org.jspecify.annotations.Nullable;
524

@@ -11,3 +30,49 @@
1130
public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(Component.translatable("permissions.requires.player"));
1231
public static final SimpleCommandExceptionType ERROR_NOT_ENTITY = new SimpleCommandExceptionType(Component.translatable("permissions.requires.entity"));
1332
public final CommandSource source;
33+
@@ -67,6 +_,7 @@
34+
private final Vec2 rotation;
35+
private final CommandSigningContext signingContext;
36+
private final TaskChainer chatMessageChainer;
37+
+ public volatile CommandNode currentCommand;
38+
39+
public CommandSourceStack(
40+
CommandSource source,
41+
@@ -128,6 +_,37 @@
42+
this.signingContext = signingContext;
43+
this.chatMessageChainer = chatMessageChainer;
44+
}
45+
+
46+
+ public class DelegatePermissionSet implements PermissionSet {
47+
+
48+
+ private final PermissionSet handle;
49+
+
50+
+ public DelegatePermissionSet(PermissionSet handle) {
51+
+ this.handle = handle;
52+
+ }
53+
+
54+
+ @Override
55+
+ public boolean hasPermission(Permission permission) {
56+
+ boolean hasPermission = handle.hasPermission(permission);
57+
+
58+
+ CommandNode currentCommand = CommandSourceStack.this.currentCommand;
59+
+ if (currentCommand != null) {
60+
+ return hasPermission(hasPermission, org.bukkit.craftbukkit.command.VanillaCommandWrapper.getPermission(currentCommand));
61+
+ }
62+
+
63+
+ if (permission.equals(Permissions.COMMANDS_ENTITY_SELECTORS)) {
64+
+ return hasPermission(hasPermission, "minecraft.command.selector");
65+
+ }
66+
+
67+
+ return hasPermission;
68+
+ }
69+
+
70+
+ public boolean hasPermission(boolean hasPermission, String bukkitPermission) {
71+
+ // World is null when loading functions
72+
+ return ((getLevel() == null || !getLevel().getCraftServer().ignoreVanillaPermissions) && hasPermission) || getBukkitSender().hasPermission(bukkitPermission);
73+
+ }
74+
+ }
75+
+ // CraftBukkit end
76+
77+
public CommandSourceStack withSource(CommandSource source) {
78+
return this.source == source

patches/net/minecraft/network/Connection.java.patch

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
private volatile @Nullable PacketListener disconnectListener;
1212
private volatile @Nullable PacketListener packetListener;
1313
private @Nullable DisconnectionDetails disconnectionDetails;
14-
@@ -81,6 +_,8 @@
14+
@@ -81,6 +_,9 @@
1515
private volatile @Nullable DisconnectionDetails delayedDisconnect;
1616
private @Nullable BandwidthDebugMonitor bandwidthDebugMonitor;
1717
private @Nullable UUID intendedProfileId;
1818
+ @Nullable
1919
+ private ProtocolInfo<?> inboundProtocol;
20+
+ public String hostname = ""; // CraftBukkit - add field
2021

2122
public Connection(PacketFlow receiving) {
2223
this.receiving = receiving;

patches/net/minecraft/network/chat/TextColor.java.patch

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,33 @@
1111
private static final String CUSTOM_COLOR_PREFIX = "#";
1212
public static final Codec<TextColor> CODEC = Codec.STRING.comapFlatMap(TextColor::parseColor, TextColor::serialize);
1313
private static final Map<String, TextColor> NAMED_COLORS = new HashMap<>();
14-
@@ -31,7 +_,7 @@
14+
@@ -31,16 +_,28 @@
1515
public static final TextColor YELLOW = named("yellow", 16777045);
1616
public static final TextColor WHITE = named("white", 16777215);
1717
private final int value;
1818
- public final @Nullable String name;
1919
+ private final @Nullable String name;
20+
+ // CraftBukkit start
21+
+ @Nullable
22+
+ public final ChatFormatting format;
23+
+
24+
+ private TextColor(int value, String name, ChatFormatting format) {
25+
+ this.format = format;
26+
+ // CraftBukkit end
27+
+ this.value = value & 16777215;
28+
+ this.name = name;
29+
+ }
2030

2131
private TextColor(int value, String name) {
2232
this.value = value & 16777215;
33+
this.name = name;
34+
+ this.format = null;
35+
}
36+
37+
private TextColor(int value) {
38+
this.value = value & 16777215;
39+
this.name = null;
40+
+ this.format = null;
41+
}
42+
43+
private static TextColor named(String name, int rgb) {

patches/net/minecraft/server/level/ServerLevel.java.patch

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
private final GameEventDispatcher gameEventDispatcher;
2626
public boolean noSave;
2727
private final SleepStatus sleepStatus;
28-
@@ -216,11 +_,17 @@
28+
@@ -216,11 +_,19 @@
2929
private boolean handlingTick;
3030
private final List<CustomSpawner> customSpawners;
3131
private @Nullable EnderDragonFight dragonFight;
@@ -41,6 +41,8 @@
4141
+ public java.util.OptionalLong getSeedOverride() {
4242
+ return this.seedOverride;
4343
+ }
44+
+ public LevelStorageSource.LevelStorageAccess storageSource;
45+
+ public UUID uuid;
4446

4547
public ServerLevel(
4648
MinecraftServer server,
@@ -250,7 +252,7 @@
250252
this.neighborUpdater.updateNeighborsAtExceptFromFacing(pos, blockObject, skipDirection, orientation);
251253
}
252254

253-
@@ -1206,7 +_,7 @@
255+
@@ -1206,14 +_,16 @@
254256
Explosion.BlockInteraction blockInteraction = switch (interactionType) {
255257
case NONE -> Explosion.BlockInteraction.KEEP;
256258
case BLOCK -> this.getDestroyType(GameRules.BLOCK_EXPLOSION_DROP_DECAY);
@@ -259,7 +261,8 @@
259261
? this.getDestroyType(GameRules.MOB_EXPLOSION_DROP_DECAY)
260262
: Explosion.BlockInteraction.KEEP;
261263
case TNT -> this.getDestroyType(GameRules.TNT_EXPLOSION_DROP_DECAY);
262-
@@ -1214,6 +_,7 @@
264+
case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK;
265+
+ case STANDARD -> Explosion.BlockInteraction.DESTROY;
263266
};
264267
Vec3 center = new Vec3(x, y, z);
265268
ServerExplosion explosion = new ServerExplosion(this, source, damageSource, damageCalculator, center, r, fire, blockInteraction);
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
--- a/net/minecraft/world/CompoundContainer.java
22
+++ b/net/minecraft/world/CompoundContainer.java
3-
@@ -5,8 +_,8 @@
3+
@@ -3,10 +_,14 @@
4+
import net.minecraft.world.entity.ContainerUser;
5+
import net.minecraft.world.entity.player.Player;
46
import net.minecraft.world.item.ItemStack;
7+
+import org.bukkit.entity.HumanEntity;
8+
+
9+
+import java.util.List;
510

611
public class CompoundContainer implements Container {
712
- public final Container container1;
813
- public final Container container2;
914
+ private final Container container1;
1015
+ private final Container container2;
16+
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
1117

1218
public CompoundContainer(Container container1, Container container2) {
1319
this.container1 = container1;

patches/net/minecraft/world/SimpleContainer.java.patch

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,35 @@
11
--- a/net/minecraft/world/SimpleContainer.java
22
+++ b/net/minecraft/world/SimpleContainer.java
3-
@@ -13,7 +_,7 @@
3+
@@ -10,12 +_,28 @@
4+
import net.minecraft.world.item.ItemStack;
5+
import net.minecraft.world.level.storage.ValueInput;
6+
import net.minecraft.world.level.storage.ValueOutput;
7+
+import org.bukkit.entity.HumanEntity;
48

59
public class SimpleContainer implements Container, StackedContentsCompatible {
610
private final int size;
711
- public final NonNullList<ItemStack> items;
812
+ private final NonNullList<ItemStack> items;
13+
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
14+
+ protected org.bukkit.inventory.InventoryHolder bukkitOwner;
15+
+
16+
+ public SimpleContainer(SimpleContainer original) {
17+
+ this(original.size);
18+
+ for (int slot = 0; slot < original.size; slot++) {
19+
+ this.items.set(slot, original.items.get(slot).copy());
20+
+ }
21+
+ }
922

1023
public SimpleContainer(int size) {
24+
+ this(size, null);
25+
+ }
26+
+
27+
+ public SimpleContainer(int size, org.bukkit.inventory.InventoryHolder owner) {
28+
+ this.bukkitOwner = owner;
29+
+ // CraftBukkit end
1130
this.size = size;
31+
this.items = NonNullList.withSize(size, ItemStack.EMPTY);
32+
}
1233
@@ -109,8 +_,14 @@
1334

1435
@Override

patches/net/minecraft/world/entity/Entity.java.patch

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
--- a/net/minecraft/world/entity/Entity.java
22
+++ b/net/minecraft/world/entity/Entity.java
3-
@@ -158,6 +_,7 @@
3+
@@ -156,8 +_,10 @@
4+
import org.slf4j.Logger;
5+
46
import net.neoforged.neoforge.common.extensions.IEntityExtension;
7+
+import org.teneted.neotenet.injection.world.entity.EntityInjection;
58

69
public abstract class Entity
710
+ extends net.neoforged.neoforge.attachment.AttachmentHolder
811
implements Nameable,
912
EntityAccess,
1013
ScoreHolder,
14+
@@ -166,7 +_,7 @@
15+
ItemOwner,
16+
SlotProvider,
17+
DebugValueSource,
18+
- TypedInstance<EntityType<?>>, IEntityExtension {
19+
+ TypedInstance<EntityType<?>>, IEntityExtension, EntityInjection {
20+
private static final Logger LOGGER = LogUtils.getLogger();
21+
public static final String TAG_ID = "id";
22+
public static final String TAG_UUID = "UUID";
1123
@@ -207,11 +_,13 @@
1224
private static final int MAX_BLOCK_ITERATIONS_ALONG_TRAVEL_PER_TICK = 16;
1325
private static final double MAX_MOVEMENT_RESETTING_TRACE_DISTANCE = 8.0;
@@ -64,6 +76,28 @@
6476
private Vec3 lastKnownSpeed = Vec3.ZERO;
6577
private @Nullable Vec3 lastKnownPosition;
6678
private @Nullable BlockState inBlockState = null;
79+
@@ -302,6 +_,21 @@
80+
private final LongSet visitedBlocks = new LongOpenHashSet();
81+
private final InsideBlockEffectApplier.StepBasedCollector insideEffectCollector = new InsideBlockEffectApplier.StepBasedCollector();
82+
private CustomData customData = CustomData.EMPTY;
83+
+ // CraftBukkit start
84+
+ public boolean forceDrops;
85+
+ public boolean persist = true;
86+
+ public boolean visibleByDefault = true;
87+
+ public boolean valid;
88+
+ public boolean inWorld = false;
89+
+ public boolean generation;
90+
+ public int maxAirTicks = getDefaultMaxAirSupply(); // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
91+
+ public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only
92+
+ public boolean lastDamageCancelled; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled
93+
+ public boolean persistentInvisibility = false;
94+
+ public BlockPos lastLavaContact;
95+
+ // Marks an entity, that it was removed by a plugin via Entity#remove
96+
+ // Main use case currently is for SPIGOT-7487, preventing dropping of leash when leash is removed
97+
+ public boolean pluginRemoved = false;
98+
99+
public Entity(EntityType<?> type, Level level) {
100+
this.type = type;
67101
@@ -323,7 +_,10 @@
68102
this.defineSynchedData(entityDataBuilder);
69103
this.entityData = entityDataBuilder.build();

patches/net/minecraft/world/entity/LivingEntity.java.patch

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
--- a/net/minecraft/world/entity/LivingEntity.java
22
+++ b/net/minecraft/world/entity/LivingEntity.java
3+
@@ -12,9 +_,12 @@
4+
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
5+
import it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap;
6+
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
7+
+
8+
+import java.util.ArrayList;
9+
import java.util.Collection;
10+
import java.util.ConcurrentModificationException;
11+
import java.util.EnumMap;
12+
+import java.util.HashSet;
13+
import java.util.Iterator;
14+
import java.util.List;
15+
import java.util.Map;
316
@@ -177,14 +_,14 @@
417
private static final double MAX_LINE_OF_SIGHT_TEST_RANGE = 128.0;
518
protected static final int LIVING_ENTITY_FLAG_IS_USING = 1;
@@ -78,7 +91,7 @@
7891
protected int fallFlyTicks;
7992
private long lastKineticHitFeedbackTime = -2147483648L;
8093
private BlockPos lastPos;
81-
@@ -277,13 +_,20 @@
94+
@@ -277,13 +_,28 @@
8295
private float swimAmount;
8396
private float swimAmountO;
8497
protected Brain<?> brain;
@@ -98,6 +111,14 @@
98111
+ * the stack before the method's return.
99112
+ **/
100113
+ protected java.util.@Nullable Stack<net.neoforged.neoforge.common.damagesource.DamageContainer> damageContainers = new java.util.Stack<>();
114+
+ // CraftBukkit start
115+
+ public int expToDrop;
116+
+ public ArrayList<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>();
117+
+ public org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes;
118+
+ public boolean collides = true;
119+
+ public Set<UUID> collidableExemptions = new HashSet<>();
120+
+ public boolean bukkitPickUpLoot;
121+
+ public int invulnerableDuration = 20;
101122

102123
protected LivingEntity(EntityType<? extends LivingEntity> type, Level level) {
103124
super(type, level);

0 commit comments

Comments
 (0)