diff --git a/.gitignore b/.gitignore index 3c37caf..1ba734e 100644 --- a/.gitignore +++ b/.gitignore @@ -116,3 +116,4 @@ run/ # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) !gradle-wrapper.jar +/output/ diff --git a/build.gradle b/build.gradle index 45eccf5..9f26703 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { id 'maven-publish' } -version = project.mod_version +version = project.mod_version + project.mod_suffix group = project.maven_group repositories { @@ -92,3 +92,48 @@ publishing { // retrieving dependencies. } } + +def buildnumber = 1 + +tasks.register("updateBuildNumber") { + doLast { + Properties props = new Properties() + + File propsFile = new File('build.properties') + + props.load(propsFile.newDataInputStream()) + + String prevVersion = (props.getProperty('mod_version')) + + if (prevVersion.equals(project.mod_version)) { + + buildnumber = (((props.getProperty('mod_buildnumber')) as Integer) + 1) + + } + + props.setProperty('mod_buildnumber', buildnumber.toString()) + props.setProperty('mod_version', project.mod_version.toString()) + + props.store(propsFile.newWriter(), null) + + props.load(propsFile.newDataInputStream()) + + } + outputs.upToDateWhen { false } +} + +tasks.register("FinalizeBuild", Copy){ + from "$buildDir/libs" + into "output/libs" + include "${project.archives_base_name}-${project.version}.jar" + rename { String filename -> + return "${project.archives_base_name}-${project.version} build ${buildnumber}.jar" + } + doLast { + mkdir "output/libs" + } +} + +tasks.build.finalizedBy updateBuildNumber +tasks.updateBuildNumber.shouldRunAfter build +tasks.updateBuildNumber.finalizedBy FinalizeBuild \ No newline at end of file diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..6b0e57e --- /dev/null +++ b/build.properties @@ -0,0 +1,3 @@ +#Tue Nov 09 14:01:36 CET 2021 +mod_version=1.4.1 +mod_buildnumber=17 diff --git a/gradle.properties b/gradle.properties index df125ba..23c3b9d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,8 @@ yarn_mappings=1.17.1+build.63 loader_version=0.12.4 carpet_core_version=1.4.52+v211104 # Mod Properties -mod_version=1.4.1-BETA +mod_version=1.4.2 +mod_suffix=-BETA maven_group=carpet-shadow-item archives_base_name=carpet-shadow # Dependencies diff --git a/src/main/java/com/carpet_shadow/mixins/fragility/CreativeInventoryActionC2SPacketMixin.java b/src/main/java/com/carpet_shadow/mixins/fragility/CreativeInventoryActionC2SPacketMixin.java deleted file mode 100644 index 38c9ed8..0000000 --- a/src/main/java/com/carpet_shadow/mixins/fragility/CreativeInventoryActionC2SPacketMixin.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.carpet_shadow.mixins.fragility; - -import com.carpet_shadow.CarpetShadow; -import com.carpet_shadow.CarpetShadowSettings; -import com.carpet_shadow.interfaces.ShadowItem; -import net.minecraft.item.ItemStack; -import net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.lang.ref.Reference; - -@Mixin(CreativeInventoryActionC2SPacket.class) -public class CreativeInventoryActionC2SPacketMixin { - - @Redirect(method = "(ILnet/minecraft/item/ItemStack;)V", at=@At(value = "INVOKE",target = "Lnet/minecraft/item/ItemStack;copy()Lnet/minecraft/item/ItemStack;")) - public ItemStack copy_redirect(ItemStack stack){ - if(CarpetShadowSettings.shadowItemFragilityFixes && ((ShadowItem)(Object)stack).getShadowId()!=null){ - Reference reference = CarpetShadow.shadowMap.get(((ShadowItem)(Object)stack).getShadowId()); - if (reference!=null && !reference.refersTo(null)) { - return reference.get(); - } - } - return stack.copy(); - } -} diff --git a/src/main/java/com/carpet_shadow/mixins/fragility/SlotMixin.java b/src/main/java/com/carpet_shadow/mixins/fragility/SlotMixin.java index 4a879a6..7451b8d 100644 --- a/src/main/java/com/carpet_shadow/mixins/fragility/SlotMixin.java +++ b/src/main/java/com/carpet_shadow/mixins/fragility/SlotMixin.java @@ -14,23 +14,19 @@ @Mixin(Slot.class) public abstract class SlotMixin { - @Shadow public abstract ItemStack getStack(); - - @Shadow public abstract ItemStack takeStack(int amount); - @Shadow public abstract void setStack(ItemStack stack); @Redirect(method = "tryTakeStackRange", at=@At(value = "INVOKE",target = "Lnet/minecraft/screen/slot/Slot;takeStack(I)Lnet/minecraft/item/ItemStack;")) public ItemStack fixFragility_tryTakeStackRange(Slot instance, int amount){ - if(CarpetShadowSettings.shadowItemFragilityFixes && ((ShadowItem)(Object)this.getStack()).getShadowId()!=null && - amount == this.getStack().getCount()){ - ItemStack ret = this.getStack(); + if(CarpetShadowSettings.shadowItemFragilityFixes && ((ShadowItem)(Object)instance.getStack()).getShadowId()!=null && + amount == instance.getStack().getCount()){ + ItemStack ret = instance.getStack(); ItemStack res = ret.copy(); res.setCount(0); - this.setStack(res); + instance.setStack(res); return ret; } - return takeStack(amount); + return instance.takeStack(amount); } @Inject(method = "insertStack(Lnet/minecraft/item/ItemStack;I)Lnet/minecraft/item/ItemStack;", diff --git a/src/main/java/com/carpet_shadow/mixins/general/InventoryS2CPacketMixin.java b/src/main/java/com/carpet_shadow/mixins/tooltip/InventoryS2CPacketMixin.java similarity index 70% rename from src/main/java/com/carpet_shadow/mixins/general/InventoryS2CPacketMixin.java rename to src/main/java/com/carpet_shadow/mixins/tooltip/InventoryS2CPacketMixin.java index f3534ad..5a82db1 100644 --- a/src/main/java/com/carpet_shadow/mixins/general/InventoryS2CPacketMixin.java +++ b/src/main/java/com/carpet_shadow/mixins/tooltip/InventoryS2CPacketMixin.java @@ -1,4 +1,4 @@ -package com.carpet_shadow.mixins.general; +package com.carpet_shadow.mixins.tooltip; import com.carpet_shadow.CarpetShadow; import com.carpet_shadow.CarpetShadowSettings; @@ -19,12 +19,6 @@ public abstract class InventoryS2CPacketMixin { @Redirect(method = "(IILnet/minecraft/util/collection/DefaultedList;Lnet/minecraft/item/ItemStack;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;copy()Lnet/minecraft/item/ItemStack;")) public ItemStack copy_redirect(ItemStack instance){ - if(CarpetShadowSettings.shadowItemFragilityFixes && ((ShadowItem)(Object)instance).getShadowId()!=null){ - Reference reference = CarpetShadow.shadowMap.get(((ShadowItem)(Object)instance).getShadowId()); - if (reference!=null && !reference.refersTo(null)) { - return reference.get(); - } - } if(CarpetShadowSettings.shadowItemTooltip){ return ShadowItem.copy_redirect(instance); } diff --git a/src/main/java/com/carpet_shadow/mixins/general/ScreenHandlerSlotUpdateS2CPacketMixin.java b/src/main/java/com/carpet_shadow/mixins/tooltip/ScreenHandlerSlotUpdateS2CPacketMixin.java similarity index 84% rename from src/main/java/com/carpet_shadow/mixins/general/ScreenHandlerSlotUpdateS2CPacketMixin.java rename to src/main/java/com/carpet_shadow/mixins/tooltip/ScreenHandlerSlotUpdateS2CPacketMixin.java index 6ab5d48..6346428 100644 --- a/src/main/java/com/carpet_shadow/mixins/general/ScreenHandlerSlotUpdateS2CPacketMixin.java +++ b/src/main/java/com/carpet_shadow/mixins/tooltip/ScreenHandlerSlotUpdateS2CPacketMixin.java @@ -1,4 +1,4 @@ -package com.carpet_shadow.mixins.general; +package com.carpet_shadow.mixins.tooltip; import com.carpet_shadow.CarpetShadowSettings; import com.carpet_shadow.interfaces.ShadowItem; @@ -12,7 +12,7 @@ public abstract class ScreenHandlerSlotUpdateS2CPacketMixin { @Redirect(method ="(IIILnet/minecraft/item/ItemStack;)V", at=@At(value = "INVOKE",target = "Lnet/minecraft/item/ItemStack;copy()Lnet/minecraft/item/ItemStack;")) public ItemStack copy_redirect(ItemStack instance){ - if(CarpetShadowSettings.shadowItemTooltip || CarpetShadowSettings.shadowItemFragilityFixes){ + if(CarpetShadowSettings.shadowItemTooltip ){ return ShadowItem.copy_redirect(instance); } return instance.copy(); diff --git a/src/main/resources/carpet-shadow.mixins.json b/src/main/resources/carpet-shadow.mixins.json index c3ba934..52ed413 100644 --- a/src/main/resources/carpet-shadow.mixins.json +++ b/src/main/resources/carpet-shadow.mixins.json @@ -4,7 +4,6 @@ "package": "com.carpet_shadow.mixins", "compatibilityLevel": "JAVA_16", "mixins": [ - "fragility.CreativeInventoryActionC2SPacketMixin", "fragility.DropperBlockMixin", "fragility.HopperBlockEntityMixin", "fragility.ItemEntityMixin", @@ -14,11 +13,11 @@ "general.ItemStackMixin", "general.ScreenHandlerMixin", "persistence.ItemStackMixin", - "general.InventoryS2CPacketMixin", + "tooltip.InventoryS2CPacketMixin", "tooltip.ItemStackMixin", "tooltip.PacketByteBufMixin", "tooltip.ScreenHandlerMixin", - "general.ScreenHandlerSlotUpdateS2CPacketMixin" + "tooltip.ScreenHandlerSlotUpdateS2CPacketMixin" ], "client": [ ],