Skip to content

Commit

Permalink
Added Rule: giveCommandDupeFix
Browse files Browse the repository at this point in the history
  • Loading branch information
FxMorin committed Jun 23, 2021
1 parent c831642 commit 7c3f8af
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,14 @@ Fixes being able to fish outside of water
* Categories: `CARPETFIXES`,`BUGFIX`
* Fixes: [MC-175544](https://bugs.mojang.com/browse/MC-175544)

## giveCommandDupeFix
Fixes being able to dupe items using the /give command
* Type: `boolean`
* Default value: `false`
* Required options: `false`,`true`
* Categories: `CARPETFIXES`,`BUGFIX`
* Fixes: [MC-120507](https://bugs.mojang.com/browse/MC-120507)

## drownedEnchantedTridentsFix
Makes enchantments work on tridents thrown by drowned
* Type: `boolean`
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/carpetfixes/CarpetFixesSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,14 @@ public enum PresetSettings {
)
public static boolean fishingOutsideWaterFix = false;

//by FX - PR0CESS
@Rule(
desc = "Fixes being able to dupe items using the /give command",
extra = "Fixes [MC-120507](https://bugs.mojang.com/browse/MC-120507)",
category = {CARPETFIXES,BUGFIX}
)
public static boolean giveCommandDupeFix = false;

/*
BACKPORTS
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package carpetfixes.mixins.dupeFixes;

import carpetfixes.CarpetFixesSettings;
import net.minecraft.block.entity.HopperBlockEntity;
import net.minecraft.entity.ItemEntity;
import net.minecraft.inventory.Inventory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(HopperBlockEntity.class)
public class HopperBlockEntity_giveMixin {

@Inject(method="extract(Lnet/minecraft/inventory/Inventory;Lnet/minecraft/entity/ItemEntity;)Z",at=@At("HEAD"),cancellable = true)
private static void extract(Inventory inventory, ItemEntity itemEntity, CallbackInfoReturnable<Boolean> cir) {
if (CarpetFixesSettings.giveCommandDupeFix && itemEntity.pickupDelay == 32767) {
cir.setReturnValue(true);
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/carpetfixes.accesswidener
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
accessWidener v1 named
extendable class net/minecraft/entity/projectile/FishingBobberEntity$State
accessible field net/minecraft/entity/ItemEntity pickupDelay I
1 change: 1 addition & 0 deletions src/main/resources/carpetfixes.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"coreSystemFixes.World_seaLevelMixin",
"dupeFixes.AbstractRailBlock_duplicationMixin",
"dupeFixes.FallingBlockEntity_duplicationMixin",
"dupeFixes.HopperBlockEntity_giveMixin",
"dupeFixes.MobEntity_portalGeneralItemMixin",
"dupeFixes.PistonBlock_tntDupingFixMixin",
"entityFixes.CatEntity$SleepWithOwnerGoal_breakLeashMixin",
Expand Down

0 comments on commit 7c3f8af

Please sign in to comment.