Skip to content

Commit f41986a

Browse files
Version 1.1.1-forge-119
- Finally added the ability to take advantage of multishot 2 in crossbows - Fixed the mod version mistmatch menu text - Made Inherit and precison not able to be applied in a etable
1 parent df9fc19 commit f41986a

File tree

10 files changed

+129
-8
lines changed

10 files changed

+129
-8
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ plugins {
1919
apply plugin: 'org.spongepowered.mixin'
2020
apply plugin: 'org.parchmentmc.librarian.forgegradle'
2121

22-
version = '1.1.0-patch2'
22+
version = '1.1.1'
2323
group = 'com.thaddev.iw2thshortbows' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
2424
archivesBaseName = 'iw2thshortbows'
2525

src/main/java/com/thaddev/iw2thshortbows/IWant2TryHardsShortbows.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import com.thaddev.iw2thshortbows.mechanics.inits.PotionInit;
1313
import com.thaddev.iw2thshortbows.mechanics.inits.PotionRecipeInit;
1414
import com.thaddev.iw2thshortbows.mechanics.inits.RecipeSerializerInit;
15-
import net.minecraft.SharedConstants;
1615
import net.minecraft.client.Minecraft;
1716
import net.minecraftforge.eventbus.api.IEventBus;
1817
import net.minecraftforge.fml.common.Mod;
@@ -26,7 +25,7 @@ public class IWant2TryHardsShortbows {
2625
public static final String MODID = "iw2thshortbows";
2726
public static final Logger LOGGER = LogUtils.getLogger();
2827
public static IWant2TryHardsShortbows instance;
29-
public static String VERSION = "1.1.0-patch2";
28+
public static String VERSION = "1.1.1";
3029

3130
public static final String MESSAGE_WELCOME = "message.iw2thshortbows.welcome";
3231
public static final String SCREEN_VERSION_MISMATCH = "menu.iw2thshortbows.modmismatch";
@@ -60,6 +59,6 @@ public void setup(final FMLCommonSetupEvent event) {
6059
}
6160

6261
public static String buildVersionString(String modLoader) {
63-
return modLoader + "-mc" + SharedConstants.VERSION_STRING + "-" + VERSION;
62+
return modLoader + "-" + VERSION;
6463
}
6564
}

src/main/java/com/thaddev/iw2thshortbows/client/gui/ModMismatchScreen.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ protected void init() {
6161
this.minecraft.setScreen(this);
6262
}, "https://www.curseforge.com/minecraft/mc-mods/iwant2tryhards-shortbows/files", false)),
6363
(pButton, pPoseStack, pMouseX, pMouseY) ->
64-
renderTooltip(pPoseStack, Component.translatable(NO_DOWNLOAD), pMouseX, pMouseY)
64+
renderTooltip(pPoseStack, Component.translatable(OPEN_GITHUB), pMouseX, pMouseY)
6565
)
6666
);
6767
this.addRenderableWidget(drawCenteredButton((this.width / 2), pos + 25, 150, 20, true, Component.translatable(OPEN_MODRINTH),
@@ -76,7 +76,7 @@ protected void init() {
7676
this.minecraft.setScreen(this);
7777
}, "https://modrinth.com/mod/iwant2tryhards-shortbows/version/" + IWant2TryHardsShortbows.buildVersionString(ClientBrandRetriever.getClientModName()), false)),
7878
(pButton, pPoseStack, pMouseX, pMouseY) ->
79-
renderTooltip(pPoseStack, Component.translatable(NO_DOWNLOAD), pMouseX, pMouseY)
79+
renderTooltip(pPoseStack, Component.translatable(OPEN_MODRINTH), pMouseX, pMouseY)
8080
)
8181
);
8282
this.addRenderableWidget(drawCenteredButton((this.width / 2) + 160, pos + 25, 150, 20, true, Component.translatable(OPEN_GITHUB),

src/main/java/com/thaddev/iw2thshortbows/content/enchantments/InheritEnchantment.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,9 @@ protected boolean checkCompatibility(@NotNull Enchantment enchantment) {
3737
public boolean canEnchant(ItemStack stack) {
3838
return stack.getItem() instanceof IronShortBowItem || stack.getItem() instanceof DiamondShortBowItem;
3939
}
40+
41+
@Override
42+
public boolean canApplyAtEnchantingTable(ItemStack stack) {
43+
return (stack.getItem() instanceof IronShortBowItem || stack.getItem() instanceof DiamondShortBowItem);
44+
}
4045
}

src/main/java/com/thaddev/iw2thshortbows/content/enchantments/PrecisionEnchantment.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,9 @@ protected boolean checkCompatibility(@NotNull Enchantment enchantment) {
3737
public boolean canEnchant(ItemStack stack) {
3838
return stack.getItem() instanceof IronShortBowItem || stack.getItem() instanceof DiamondShortBowItem;
3939
}
40+
41+
@Override
42+
public boolean canApplyAtEnchantingTable(ItemStack stack) {
43+
return (stack.getItem() instanceof IronShortBowItem || stack.getItem() instanceof DiamondShortBowItem);
44+
}
4045
}

src/main/java/com/thaddev/iw2thshortbows/content/items/weapons/ShortBowBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ private void summonAndShoot(ItemStack itemstack, ItemStack stack, Level world, P
195195
}
196196

197197
shortBowArrow.setBaseDamage(shortBowArrow.getBaseDamage() * 0.75D);
198-
shortBowArrow.shootFromRotation(player, player.getXRot(), player.getYRot() + (j * 8), 0.0F, strength * 3.0F, 1.0F);
198+
shortBowArrow.shootFromRotation(player, player.getXRot(), player.getYRot() + (j * 15), 0.0F, strength * 3.0F, 1.0F);
199199
if (crit) {
200200
shortBowArrow.setCritArrow(true);
201201
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.thaddev.iw2thshortbows.mixins;
2+
3+
import net.minecraft.util.RandomSource;
4+
import net.minecraft.world.InteractionHand;
5+
import net.minecraft.world.entity.LivingEntity;
6+
import net.minecraft.world.item.CrossbowItem;
7+
import net.minecraft.world.item.ItemStack;
8+
import net.minecraft.world.level.Level;
9+
import org.spongepowered.asm.mixin.Mixin;
10+
import org.spongepowered.asm.mixin.gen.Invoker;
11+
12+
import java.util.List;
13+
14+
@Mixin(CrossbowItem.class)
15+
public interface CrossbowItemAccessor {
16+
@Invoker
17+
static boolean callLoadProjectile(LivingEntity pShooter, ItemStack pCrossbowStack, ItemStack pAmmoStack, boolean pHasAmmo, boolean pIsCreative) {
18+
throw new UnsupportedOperationException();
19+
}
20+
21+
@Invoker
22+
static List<ItemStack> callGetChargedProjectiles(ItemStack pCrossbowStack) {
23+
throw new UnsupportedOperationException();
24+
}
25+
26+
@Invoker
27+
static float callGetRandomShotPitch(boolean p_220026_, RandomSource p_220027_) {
28+
throw new UnsupportedOperationException();
29+
}
30+
31+
@Invoker
32+
static float[] callGetShotPitches(RandomSource p_220024_) {
33+
throw new UnsupportedOperationException();
34+
}
35+
36+
@Invoker
37+
static void callShootProjectile(Level pLevel, LivingEntity pShooter, InteractionHand pHand, ItemStack pCrossbowStack, ItemStack pAmmoStack, float pSoundPitch, boolean pIsCreativeMode, float pVelocity, float pInaccuracy, float pProjectileAngle) {
38+
throw new UnsupportedOperationException();
39+
}
40+
41+
@Invoker
42+
static void callOnCrossbowShot(Level pLevel, LivingEntity pShooter, ItemStack pCrossbowStack) {
43+
throw new UnsupportedOperationException();
44+
}
45+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package com.thaddev.iw2thshortbows.mixins;
2+
3+
import net.minecraft.util.RandomSource;
4+
import net.minecraft.world.InteractionHand;
5+
import net.minecraft.world.entity.LivingEntity;
6+
import net.minecraft.world.entity.player.Player;
7+
import net.minecraft.world.item.CrossbowItem;
8+
import net.minecraft.world.item.ItemStack;
9+
import net.minecraft.world.item.Items;
10+
import net.minecraft.world.item.enchantment.EnchantmentHelper;
11+
import net.minecraft.world.item.enchantment.Enchantments;
12+
import net.minecraft.world.level.Level;
13+
import org.spongepowered.asm.mixin.Mixin;
14+
import org.spongepowered.asm.mixin.injection.At;
15+
import org.spongepowered.asm.mixin.injection.Inject;
16+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
17+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
18+
19+
import java.util.List;
20+
21+
@Mixin(CrossbowItem.class)
22+
public class CrossbowItemMixin {
23+
@Inject(method = "tryLoadProjectiles", at = @At("HEAD"), cancellable = true)
24+
private static void loadProjectiles(LivingEntity shooter, ItemStack projectile, CallbackInfoReturnable<Boolean> cir) {
25+
int i = EnchantmentHelper.getTagEnchantmentLevel(Enchantments.MULTISHOT, projectile);
26+
int j = 1 + (i * 2);
27+
boolean bl = shooter instanceof Player && ((Player) shooter).getAbilities().instabuild;
28+
ItemStack itemStack = shooter.getProjectile(projectile);
29+
ItemStack itemStack2 = itemStack.copy();
30+
for (int k = 0; k < j; ++k) {
31+
if (k > 0) {
32+
itemStack = itemStack2.copy();
33+
}
34+
if (itemStack.isEmpty() && bl) {
35+
itemStack = new ItemStack(Items.ARROW);
36+
itemStack2 = itemStack.copy();
37+
}
38+
if (CrossbowItemAccessor.callLoadProjectile(shooter, projectile, itemStack, k > 0, bl)) continue;
39+
cir.setReturnValue(false);
40+
}
41+
cir.setReturnValue(true);
42+
}
43+
44+
@Inject(method = "performShooting", at = @At("HEAD"), cancellable = true)
45+
private static void shootAll(Level world, LivingEntity entity, InteractionHand hand, ItemStack stack, float speed, float divergence, CallbackInfo ci) {
46+
if (entity instanceof Player player && net.minecraftforge.event.ForgeEventFactory.onArrowLoose(stack, entity.level, player, 1, true) < 0) return;
47+
List<ItemStack> list = CrossbowItemAccessor.callGetChargedProjectiles(stack);
48+
float[] fs = CrossbowItemAccessor.callGetShotPitches(entity.getRandom());
49+
for (int i = 0; i < list.size(); i++) {
50+
int rotation = i - ((list.size() - 1) / 2);
51+
boolean bl = entity instanceof Player && ((Player) entity).getAbilities().instabuild;
52+
ItemStack itemStack = list.get(i);
53+
if (itemStack.isEmpty()) continue;
54+
CrossbowItemAccessor.callShootProjectile(world, entity, hand, stack, itemStack, fs[i], bl, speed, divergence, rotation * 10f);
55+
}
56+
CrossbowItemAccessor.callOnCrossbowShot(world, entity, stack);
57+
ci.cancel();
58+
}
59+
60+
@Inject(method = "getShotPitches", at = @At("HEAD"), cancellable = true)
61+
private static void getSoundPitches(RandomSource random, CallbackInfoReturnable<float[]> cir) {
62+
boolean bl = random.nextBoolean();
63+
cir.setReturnValue(new float[]{1.0f, CrossbowItemAccessor.callGetRandomShotPitch(bl, random), CrossbowItemAccessor.callGetRandomShotPitch(!bl, random), CrossbowItemAccessor.callGetRandomShotPitch(bl, random), CrossbowItemAccessor.callGetRandomShotPitch(!bl, random)});
64+
}
65+
}

src/main/resources/META-INF/mods.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ license="MIT"
44

55
[[mods]]
66
modId = "iw2thshortbows"
7-
version = "1.1.0-patch2" #mandatory
7+
version = "1.1.1" #mandatory
88
displayName = "IWant2TryHard's Shortbows" #mandatory
99
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
1010
displayURL = "https://github.com/MyNameTsThad/IW2THs-Shortbows" #optional

src/main/resources/mixins.iw2thshortbows.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
},
99
"refmap": "iw2thshortbows.mixin-refmap.json",
1010
"mixins": [
11+
"CrossbowItemAccessor",
12+
"CrossbowItemMixin",
1113
"MultiShotEnchantmentMixin"
1214
],
1315
"client": [

0 commit comments

Comments
 (0)