-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #273 from ZsoltMolnarrr/rwa-compat
Update workspace to 1.20.1, add RWA compat
- Loading branch information
Showing
9 changed files
with
56 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/chronosacaria/mcdw/compat/RangedWeaponAPICompat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package chronosacaria.mcdw.compat; | ||
|
||
import chronosacaria.mcdw.enums.*; | ||
import net.fabric_extras.ranged_weapon.api.CustomRangedWeapon; | ||
import net.fabric_extras.ranged_weapon.api.RangedConfig; | ||
import net.minecraft.item.Item; | ||
|
||
import java.util.HashMap; | ||
|
||
public class RangedWeaponAPICompat { | ||
public static void init() { | ||
var items = new HashMap<IRangedWeaponID, Item>(); | ||
items.putAll(BowsID.getItemsEnum()); | ||
items.putAll(ShortbowsID.getItemsEnum()); | ||
items.putAll(LongbowsID.getItemsEnum()); | ||
items.putAll(CrossbowsID.getItemsEnum()); | ||
|
||
for (var entry: items.entrySet()) { | ||
var id = entry.getKey(); | ||
if (!id.getIsEnabled()) { | ||
continue; | ||
} | ||
var isCrossbow = id instanceof CrossbowsID; | ||
var item = entry.getValue(); | ||
var damage = id.getWeaponItemStats().projectileDamage; | ||
var speed = id.getWeaponItemStats().drawSpeed; | ||
float standardPullTime = isCrossbow ? 25F : 20F; | ||
var pullTime = isCrossbow // Speed seems to have inverse effects on crossbows compared to bows | ||
? speed | ||
: standardPullTime * (20.0 / (float)speed); | ||
var velocity = (id.getWeaponItemStats().range / 15.0f) * 3.0; | ||
((CustomRangedWeapon)item).setRangedWeaponConfig(new RangedConfig((int) pullTime, (float) damage, (float) velocity)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters