Skip to content

Commit d41058f

Browse files
committed
feat: some patches and injections
1 parent 4852a58 commit d41058f

10 files changed

Lines changed: 249 additions & 5 deletions

File tree

patches/net/minecraft/client/multiplayer/ClientLevel.java.patch

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@
101101
if (p_263514_ == this.minecraft.player) {
102102
this.minecraft.getSoundManager().play(new EntityBoundSoundInstance(p_263518_.value(), p_263487_, p_263538_, p_263524_, p_263536_, p_263509_));
103103
}
104+
@@ -906,7 +_,7 @@
105+
}
106+
107+
@Override
108+
- protected LevelEntityGetter<Entity> getEntities() {
109+
+ public LevelEntityGetter<Entity> getEntities() {
110+
return this.entityStorage.getEntityGetter();
111+
}
112+
104113
@@ -1033,6 +_,7 @@
105114
}
106115

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,12 @@
114114
iterator.remove();
115115
}
116116

117-
@@ -929,11 +_,12 @@
117+
@@ -925,15 +_,16 @@
118+
}
119+
120+
public final boolean addEffect(MobEffectInstance p_21165_) {
121+
- return this.addEffect(p_21165_, null);
122+
+ return this.addEffect(p_21165_, (Entity) null);
118123
}
119124

120125
public boolean addEffect(MobEffectInstance p_147208_, @Nullable Entity p_147209_) {

patches/net/minecraft/world/entity/player/Player.java.patch

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@
121121
if (this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.SWIMMING)) {
122122
Pose pose;
123123
if (this.isFallFlying()) {
124+
@@ -464,7 +_,7 @@
125+
}
126+
127+
@Override
128+
- protected int getFireImmuneTicks() {
129+
+ public int getFireImmuneTicks() {
130+
return 20;
131+
}
132+
124133
@@ -630,6 +_,7 @@
125134

126135
@Override

patches/net/minecraft/world/level/block/ChestBlock.java.patch

Lines changed: 134 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,119 @@
11
--- a/net/minecraft/world/level/block/ChestBlock.java
22
+++ b/net/minecraft/world/level/block/ChestBlock.java
3-
@@ -50,8 +_,9 @@
3+
@@ -2,11 +_,13 @@
4+
5+
import com.mojang.serialization.MapCodec;
6+
import it.unimi.dsi.fastutil.floats.Float2FloatFunction;
7+
+
8+
import java.util.List;
9+
import java.util.Optional;
10+
import java.util.function.BiPredicate;
11+
import java.util.function.Supplier;
12+
import javax.annotation.Nullable;
13+
+
14+
import net.minecraft.core.BlockPos;
15+
import net.minecraft.core.Direction;
16+
import net.minecraft.network.chat.Component;
17+
@@ -50,8 +_,11 @@
418
import net.minecraft.world.phys.BlockHitResult;
519
import net.minecraft.world.phys.shapes.CollisionContext;
620
import net.minecraft.world.phys.shapes.VoxelShape;
21+
+import org.bukkit.inventory.PlayerInventory;
722
+import org.taiyitistmc.injection.world.level.block.InjectionChestBlock;
23+
+import org.taiyitistmc.injection.world.level.block.InjectionChestBlockDoubleInventory;
824

925
-public class ChestBlock extends AbstractChestBlock<ChestBlockEntity> implements SimpleWaterloggedBlock {
1026
+public class ChestBlock extends AbstractChestBlock<ChestBlockEntity> implements SimpleWaterloggedBlock, InjectionChestBlock {
1127
public static final MapCodec<ChestBlock> CODEC = simpleCodec(p_304364_ -> new ChestBlock(p_304364_, () -> BlockEntityType.CHEST));
1228
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
1329
public static final EnumProperty<ChestType> TYPE = BlockStateProperties.CHEST_TYPE;
30+
@@ -98,7 +_,7 @@
31+
if (p_51604_.hasCustomName()) {
32+
return p_51604_.getDisplayName();
33+
} else {
34+
- return (Component)(p_51605_.hasCustomName() ? p_51605_.getDisplayName() : Component.translatable("container.chestDouble"));
35+
+ return (Component) (p_51605_.hasCustomName() ? p_51605_.getDisplayName() : Component.translatable("container.chestDouble"));
36+
}
37+
}
38+
});
39+
@@ -121,7 +_,7 @@
40+
public ChestBlock(BlockBehaviour.Properties p_51490_, Supplier<BlockEntityType<? extends ChestBlockEntity>> p_51491_) {
41+
super(p_51490_, p_51491_);
42+
this.registerDefaultState(
43+
- this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(TYPE, ChestType.SINGLE).setValue(WATERLOGGED, Boolean.valueOf(false))
44+
+ this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(TYPE, ChestType.SINGLE).setValue(WATERLOGGED, Boolean.valueOf(false))
45+
);
46+
}
47+
48+
@@ -148,9 +_,9 @@
49+
if (p_51557_.is(this) && p_51556_.getAxis().isHorizontal()) {
50+
ChestType chesttype = p_51557_.getValue(TYPE);
51+
if (p_51555_.getValue(TYPE) == ChestType.SINGLE
52+
- && chesttype != ChestType.SINGLE
53+
- && p_51555_.getValue(FACING) == p_51557_.getValue(FACING)
54+
- && getConnectedDirection(p_51557_) == p_51556_.getOpposite()) {
55+
+ && chesttype != ChestType.SINGLE
56+
+ && p_51555_.getValue(FACING) == p_51557_.getValue(FACING)
57+
+ && getConnectedDirection(p_51557_) == p_51556_.getOpposite()) {
58+
return p_51555_.setValue(TYPE, chesttype.getOpposite());
59+
}
60+
} else if (getConnectedDirection(p_51555_) == p_51556_) {
61+
@@ -208,9 +_,9 @@
62+
}
63+
64+
return this.defaultBlockState()
65+
- .setValue(FACING, direction)
66+
- .setValue(TYPE, chesttype)
67+
- .setValue(WATERLOGGED, Boolean.valueOf(fluidstate.getType() == Fluids.WATER));
68+
+ .setValue(FACING, direction)
69+
+ .setValue(TYPE, chesttype)
70+
+ .setValue(WATERLOGGED, Boolean.valueOf(fluidstate.getType() == Fluids.WATER));
71+
}
72+
73+
@Override
74+
@@ -261,7 +_,7 @@
75+
76+
@Override
77+
public DoubleBlockCombiner.NeighborCombineResult<? extends ChestBlockEntity> combine(
78+
- BlockState p_51544_, Level p_51545_, BlockPos p_51546_, boolean p_51547_
79+
+ BlockState p_51544_, Level p_51545_, BlockPos p_51546_, boolean p_51547_
80+
) {
81+
BiPredicate<LevelAccessor, BlockPos> bipredicate;
82+
if (p_51547_) {
83+
@@ -271,7 +_,7 @@
84+
}
85+
86+
return DoubleBlockCombiner.combineWithNeigbour(
87+
- this.blockEntityType.get(), ChestBlock::getBlockType, ChestBlock::getConnectedDirection, FACING, p_51544_, p_51545_, p_51546_, bipredicate
88+
+ this.blockEntityType.get(), ChestBlock::getBlockType, ChestBlock::getConnectedDirection, FACING, p_51544_, p_51545_, p_51546_, bipredicate
89+
);
90+
}
91+
92+
@@ -319,15 +_,15 @@
93+
94+
private static boolean isCatSittingOnChest(LevelAccessor p_51564_, BlockPos p_51565_) {
95+
List<Cat> list = p_51564_.getEntitiesOfClass(
96+
- Cat.class,
97+
- new AABB(
98+
- (double)p_51565_.getX(),
99+
- (double)(p_51565_.getY() + 1),
100+
- (double)p_51565_.getZ(),
101+
- (double)(p_51565_.getX() + 1),
102+
- (double)(p_51565_.getY() + 2),
103+
- (double)(p_51565_.getZ() + 1)
104+
- )
105+
+ Cat.class,
106+
+ new AABB(
107+
+ (double) p_51565_.getX(),
108+
+ (double) (p_51565_.getY() + 1),
109+
+ (double) p_51565_.getZ(),
110+
+ (double) (p_51565_.getX() + 1),
111+
+ (double) (p_51565_.getY() + 2),
112+
+ (double) (p_51565_.getZ() + 1)
113+
+ )
114+
);
115+
if (!list.isEmpty()) {
116+
for (Cat cat : list) {
14117
@@ -357,7 +_,8 @@
15118

16119
@Override
@@ -21,3 +124,33 @@
21124
}
22125

23126
@Override
127+
@@ -374,7 +_,26 @@
128+
protected void tick(BlockState p_220958_, ServerLevel p_220959_, BlockPos p_220960_, RandomSource p_220961_) {
129+
BlockEntity blockentity = p_220959_.getBlockEntity(p_220960_);
130+
if (blockentity instanceof ChestBlockEntity) {
131+
- ((ChestBlockEntity)blockentity).recheckOpen();
132+
- }
133+
- }
134+
+ ((ChestBlockEntity) blockentity).recheckOpen();
135+
+ }
136+
+ }
137+
+
138+
+ // CraftBukkit start
139+
+ public static class DoubleInventory implements MenuProvider, InjectionChestBlockDoubleInventory {
140+
+
141+
+ private final ChestBlockEntity tileentitychest;
142+
+
143+
+ private final ChestBlockEntity tileentitychest1;
144+
+
145+
+ public final CompoundContainer inventorylargechest;
146+
+
147+
+ public DoubleInventory(ChestBlockEntity tileentitychest, ChestBlockEntity tileentitychest1, CompoundContainer inventorylargechest) {
148+
+ this.tileentitychest = tileentitychest;
149+
+ this.tileentitychest1 = tileentitychest1;
150+
+ this.inventorylargechest = inventorylargechest;
151+
+
152+
+ }
153+
+
154+
+ }
155+
+ // CraftBukkit end
156+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- a/net/minecraft/world/level/block/entity/BlastFurnaceBlockEntity.java
2+
+++ b/net/minecraft/world/level/block/entity/BlastFurnaceBlockEntity.java
3+
@@ -20,7 +_,7 @@
4+
}
5+
6+
@Override
7+
- protected int getBurnDuration(ItemStack p_58852_) {
8+
+ public int getBurnDuration(ItemStack p_58852_) {
9+
return super.getBurnDuration(p_58852_) / 2;
10+
}
11+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- a/net/minecraft/world/level/block/entity/SmokerBlockEntity.java
2+
+++ b/net/minecraft/world/level/block/entity/SmokerBlockEntity.java
3+
@@ -20,7 +_,7 @@
4+
}
5+
6+
@Override
7+
- protected int getBurnDuration(ItemStack p_59786_) {
8+
+ public int getBurnDuration(ItemStack p_59786_) {
9+
return super.getBurnDuration(p_59786_) / 2;
10+
}
11+
Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,52 @@
11
--- a/net/minecraft/world/level/portal/DimensionTransition.java
22
+++ b/net/minecraft/world/level/portal/DimensionTransition.java
3-
@@ -6,6 +_,7 @@
3+
@@ -6,6 +_,8 @@
44
import net.minecraft.server.level.ServerPlayer;
55
import net.minecraft.world.entity.Entity;
66
import net.minecraft.world.phys.Vec3;
7+
+import org.bukkit.event.player.PlayerTeleportEvent;
78
+import org.taiyitistmc.injection.world.level.portal.InjectionDimensionTransition;
89

910
public record DimensionTransition(
1011
ServerLevel newLevel,
11-
@@ -15,7 +_,7 @@
12+
@@ -14,22 +_,35 @@
13+
float yRot,
1214
float xRot,
1315
boolean missingRespawnBlock,
14-
DimensionTransition.PostDimensionTransition postDimensionTransition
16+
- DimensionTransition.PostDimensionTransition postDimensionTransition
1517
-) {
18+
+ DimensionTransition.PostDimensionTransition postDimensionTransition,
19+
+ PlayerTeleportEvent.TeleportCause teleportCause// CraftBukkit
1620
+) implements InjectionDimensionTransition {
1721
public static final DimensionTransition.PostDimensionTransition DO_NOTHING = p_352417_ -> {
1822
};
1923
public static final DimensionTransition.PostDimensionTransition PLAY_PORTAL_SOUND = DimensionTransition::playPortalSound;
24+
public static final DimensionTransition.PostDimensionTransition PLACE_PORTAL_TICKET = DimensionTransition::placePortalTicket;
25+
26+
+ // CraftBukkit Start
27+
public DimensionTransition(
28+
ServerLevel p_348637_, Vec3 p_348645_, Vec3 p_348472_, float p_348548_, float p_348664_, DimensionTransition.PostDimensionTransition p_352139_
29+
) {
30+
- this(p_348637_, p_348645_, p_348472_, p_348548_, p_348664_, false, p_352139_);
31+
+ this(p_348637_, p_348645_, p_348472_, p_348548_, p_348664_, false, p_352139_, PlayerTeleportEvent.TeleportCause.UNKNOWN);
32+
}
33+
34+
public DimensionTransition(ServerLevel p_348609_, Entity p_352432_, DimensionTransition.PostDimensionTransition p_352373_) {
35+
- this(p_348609_, findAdjustedSharedSpawnPos(p_348609_, p_352432_), Vec3.ZERO, 0.0F, 0.0F, false, p_352373_);
36+
- }
37+
+ this(p_348609_, findAdjustedSharedSpawnPos(p_348609_, p_352432_), Vec3.ZERO, 0.0F, 0.0F, false, p_352373_, PlayerTeleportEvent.TeleportCause.UNKNOWN);
38+
+ }
39+
+
40+
+ public DimensionTransition(ServerLevel p_348609_, Entity p_352432_, DimensionTransition.PostDimensionTransition p_352373_, PlayerTeleportEvent.TeleportCause teleportCause) {
41+
+ this(p_348609_, findAdjustedSharedSpawnPos(p_348609_, p_352432_), Vec3.ZERO, 0.0F, 0.0F, false, p_352373_,teleportCause);
42+
+ }
43+
+
44+
+ public DimensionTransition(
45+
+ ServerLevel p_348637_, Vec3 p_348645_, Vec3 p_348472_, float p_348548_, float p_348664_, DimensionTransition.PostDimensionTransition p_352139_, PlayerTeleportEvent.TeleportCause teleportCause
46+
+ ) {
47+
+ this(p_348637_, p_348645_, p_348472_, p_348548_, p_348664_, false, p_352139_,teleportCause);
48+
+ }
49+
+ // CraftBukkit End
50+
51+
private static void playPortalSound(Entity p_352075_) {
52+
if (p_352075_ instanceof ServerPlayer serverplayer) {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.taiyitistmc.injection.client;
2+
3+
import net.minecraft.resources.ResourceKey;
4+
import net.minecraft.world.level.dimension.LevelStem;
5+
6+
public interface InjectionClientLevel {
7+
8+
default ResourceKey<LevelStem> getTypeKey(){
9+
throw new RuntimeException("Not Implemented");
10+
}
11+
}

src/main/java/org/taiyitistmc/injection/world/entity/InjectionEntity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import java.util.Set;
44
import java.util.UUID;
5+
6+
import net.minecraft.nbt.CompoundTag;
57
import net.minecraft.server.level.ServerLevel;
68
import net.minecraft.server.level.ServerPlayer;
79
import net.minecraft.sounds.SoundEvent;
@@ -107,4 +109,7 @@ default void pushSpawnCause(CreatureSpawnEvent.SpawnReason reason) {
107109
default void igniteForSeconds(float i, boolean callEvent) {
108110
throw new IllegalStateException("Not implemented");
109111
}
112+
default boolean saveAsPassenger(CompoundTag p_20087_,boolean includeAll) {
113+
throw new IllegalStateException("Not implemented");
114+
}
110115
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.taiyitistmc.injection.world.level.block;
2+
3+
import net.minecraft.network.chat.Component;
4+
import net.minecraft.world.entity.player.Inventory;
5+
import net.minecraft.world.entity.player.Player;
6+
import net.minecraft.world.inventory.AbstractContainerMenu;
7+
8+
public interface InjectionChestBlockDoubleInventory {
9+
10+
default AbstractContainerMenu createMenu(int i, Inventory playerinventory, Player entityhuman) {
11+
throw new IllegalStateException("Not implemented");
12+
}
13+
14+
default Component getDisplayName() {
15+
throw new IllegalStateException("Not implemented");
16+
}
17+
}

0 commit comments

Comments
 (0)