Skip to content

Commit eb9a18a

Browse files
committed
1.18-pre1
1 parent 7a0b46c commit eb9a18a

File tree

8 files changed

+71
-25
lines changed

8 files changed

+71
-25
lines changed

build.gradle

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import com.modrinth.minotaur.TaskModrinthUpload
22

33

44
plugins {
5-
id 'fabric-loom' version '0.8-SNAPSHOT'
5+
id 'fabric-loom' version '0.10-SNAPSHOT'
66
id 'com.matthewprenger.cursegradle' version '1.4.0'
77
id "com.modrinth.minotaur" version "1.1.0"
88
id 'maven-publish'
@@ -32,14 +32,6 @@ dependencies {
3232

3333
// Fabric API. This is technically optional, but you probably want it anyway.
3434
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
35-
36-
//modRuntime "com.github.CaffeineMC:hydrogen-fabric:mc1.16.5-v0.2.0"
37-
modRuntime "com.github.astei:lazydfu:0.1.2"
38-
modRuntime 'com.github.samolego.Taterzens:taterzens-fabric:1.3.0'
39-
40-
//modImplementation 'com.github.jellysquid3:lithium-fabric:1.16.x-0.4.5'
41-
//modRuntime "com.github.gnembon:fabric-carpet:master-SNAPSHOT"
42-
//modImplementation 'com.github.jellysquid3:cadmium-fabric:1.15.x/dev-SNAPSHOT'
4335
}
4436

4537
processResources {

gradle.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
org.gradle.jvmargs=-Xmx1G
33

44
# Fabric Properties
5-
minecraft_version=1.17.1
6-
yarn_mappings=1.17.1+build.39
7-
loader_version=0.11.6
5+
minecraft_version=1.18-pre1
6+
yarn_mappings=1.18-pre1+build.3
7+
loader_version=0.12.5
88

99
#Fabric api
10-
fabric_version=0.37.2+1.17
10+
fabric_version=0.42.2+1.18
1111

1212
# Mod Properties
1313
mod_version = 0.4.1
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package org.samo_lego.golfiv.mixin.duplication;
2+
3+
import net.minecraft.item.Item;
4+
import net.minecraft.item.ItemStack;
5+
import net.minecraft.nbt.NbtCompound;
6+
import net.minecraft.util.Identifier;
7+
import net.minecraft.util.registry.Registry;
8+
import org.spongepowered.asm.mixin.Mixin;
9+
import org.spongepowered.asm.mixin.Shadow;
10+
import org.spongepowered.asm.mixin.injection.At;
11+
import org.spongepowered.asm.mixin.injection.Inject;
12+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
13+
14+
import static org.samo_lego.golfiv.GolfIV.golfConfig;
15+
16+
@Mixin(ItemStack.class)
17+
public abstract class ItemStackMixin_SavePatch {
18+
@Shadow public abstract void setCount(int count);
19+
20+
@Shadow public abstract String getTranslationKey();
21+
22+
@Shadow public abstract Item getItem();
23+
24+
@Shadow public abstract int getCount();
25+
26+
@Inject(method = "writeNbt(Lnet/minecraft/nbt/NbtCompound;)Lnet/minecraft/nbt/NbtCompound;", at = @At("HEAD"), cancellable = true)
27+
private void writeStack(NbtCompound nbt, CallbackInfoReturnable<NbtCompound> cir) {
28+
if(golfConfig.duplication.patchItemSave) {
29+
System.out.println("Saving " + this.getTranslationKey());
30+
31+
ItemStack copy = ((ItemStack) (Object) this).copy();
32+
this.setCount(0);
33+
34+
System.out.println("This: " + this.getCount() + " vs copy: " + copy);
35+
36+
Identifier identifier = Registry.ITEM.getId(copy.getItem());
37+
nbt.putString("id", identifier.toString());
38+
nbt.putByte("Count", (byte)copy.getCount());
39+
if (copy.getNbt() != null) {
40+
nbt.put("tag", copy.getNbt().copy());
41+
}
42+
43+
System.out.println(nbt);
44+
45+
cir.setReturnValue(nbt);
46+
}
47+
}
48+
}

src/main/java/org/samo_lego/golfiv/mixin/illegal_actions/ServerPlayNetworkHandlerMixin_MessageCheck.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ public class ServerPlayNetworkHandlerMixin_MessageCheck {
2727
* while in nether portals / having GUI open.
2828
*/
2929
@Inject(
30-
method = "onGameMessage(Lnet/minecraft/network/packet/c2s/play/ChatMessageC2SPacket;)V",
30+
method = "onChatMessage(Lnet/minecraft/network/packet/c2s/play/ChatMessageC2SPacket;)V",
3131
at = @At("HEAD"),
3232
cancellable = true
3333
)
3434
private void stopMessageSend(ChatMessageC2SPacket packet, CallbackInfo ci) {
35-
if ((golfConfig.main.checkInventoryActions && ((Golfer) player).hasOpenGui()) || (golfConfig.packet.checkPortalHack &&((EntityAccessor) player).inNetherPortal())) {
35+
if ((golfConfig.main.checkInventoryActions && ((Golfer) player).hasOpenGui()) || (golfConfig.packet.checkPortalHack && ((EntityAccessor) player).inNetherPortal())) {
3636
ci.cancel();
3737
}
3838
}

src/main/java/org/samo_lego/golfiv/mixin/illegal_items/ServerPlayNetworkHandlerMixin_CreativeItemsCheck.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public abstract class ServerPlayNetworkHandlerMixin_CreativeItemsCheck {
2626
method = "onCreativeInventoryAction(Lnet/minecraft/network/packet/c2s/play/CreativeInventoryActionC2SPacket;)V",
2727
at = @At(
2828
value = "INVOKE",
29-
target = "Lnet/minecraft/item/ItemStack;getSubNbt(Ljava/lang/String;)Lnet/minecraft/nbt/NbtCompound;"
29+
target = "Lnet/minecraft/item/BlockItem;getBlockEntityNbt(Lnet/minecraft/item/ItemStack;)Lnet/minecraft/nbt/NbtCompound;"
3030
)
3131
)
3232
private ItemStack checkCreativeItem(ItemStack itemStack) {

src/main/java/org/samo_lego/golfiv/mixin/movement/ServerPlayNetworkHandler_OnGroundCheck.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.spongepowered.asm.mixin.injection.Inject;
1515
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1616

17+
import java.util.List;
1718
import java.util.stream.Stream;
1819

1920
import static org.samo_lego.golfiv.GolfIV.golfConfig;
@@ -37,32 +38,31 @@ public class ServerPlayNetworkHandler_OnGroundCheck {
3738
)
3839
)
3940
private void checkOnGround(PlayerMoveC2SPacket packet, CallbackInfo ci) {
40-
if(golfConfig.movement.yesFall) {
41+
if(golfConfig.movement.yesFall && packet.isOnGround()) {
4142
Entity bottomEntity = player.getRootVehicle();
4243
if(bottomEntity == null) {
4344
bottomEntity = player;
4445
}
4546
final Box bBox = bottomEntity.getBoundingBox().expand(0, 0.25005D, 0).offset(0, packet.getY(player.getY()) - player.getY() - 0.25005D, 0);
4647

47-
Stream<VoxelShape> collidingBlocks = player.getEntityWorld().getBlockCollisions(bottomEntity, bBox);
48-
long blockCollisions = collidingBlocks.count();
48+
Iterable<VoxelShape> collidingBlocks = player.getEntityWorld().getBlockCollisions(bottomEntity, bBox);
49+
boolean blockCollisions = collidingBlocks.iterator().hasNext();
4950

50-
if(blockCollisions != 0) {
51+
if(blockCollisions) {
5152
// Preferring block collisions over entity ones
5253
((Golfer) player).setEntityCollisions(false);
5354
((Golfer) player).setBlockCollisions(true);
5455
}
5556
else {
5657
Entity finalBottomEntity = bottomEntity;
57-
Stream<VoxelShape> collidingEntities = player.getEntityWorld().getEntityCollisions(bottomEntity, bBox, entity -> !finalBottomEntity.equals(entity));
58-
long entityCollisions = collidingEntities.count();
58+
List<Entity> collidingEntities = player.getEntityWorld().getOtherEntities(bottomEntity, bBox, entity -> !finalBottomEntity.equals(entity));
5959

60-
((Golfer) player).setEntityCollisions(entityCollisions != 0);
60+
((Golfer) player).setEntityCollisions(!collidingEntities.isEmpty());
6161
((Golfer) player).setBlockCollisions(false);
6262
}
6363

64-
if(!((Golfer) player).isNearGround() && packet.isOnGround()) {
65-
// Player isn't on ground packets but client says it is
64+
if(!((Golfer) player).isNearGround()) {
65+
// Player isn't on ground but client packet says it is
6666
((PlayerMoveC2SPacketAccessor) packet).setOnGround(false);
6767
}
6868
}

src/main/java/org/samo_lego/golfiv/storage/GolfConfig.java

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

33
import com.google.gson.Gson;
44
import com.google.gson.GsonBuilder;
5+
import com.google.gson.annotations.SerializedName;
56

67
import java.io.*;
78
import java.nio.charset.StandardCharsets;
@@ -170,6 +171,10 @@ public static class Duplication {
170171
public final String _comment_patchDeathDuplication1 = "// Checks if player is connected before applying damage.";
171172
public final String _comment_patchDeathDuplication2 = "// Prevents duplicating inventory if player dies after disconnect.";
172173
public boolean patchDeathDuplication = true;
174+
175+
@SerializedName("// Whether to set item stack size to 0 after writing it on disk.")
176+
public final String _comment_patchItemSave = "";
177+
public boolean patchItemSave = true;
173178
}
174179

175180
/**

src/main/resources/golfiv.mixins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"accessors.PlaySoundS2CPacketAccessor",
1919
"accessors.ScreenHandlerSlotUpdateS2CPacketAccessor",
2020
"duplication.FallingBlockEntityMixin_GravityBlockDupe",
21+
"duplication.ItemStackMixin_SavePatch",
2122
"duplication.ServerPlayerEntityMixin_NoConnectionDeath",
2223
"duplication.StringTagMixin_StringWriteLimit",
2324
"illegal_actions.ServerPlayerEntityMixin_InventoryClose",

0 commit comments

Comments
 (0)