Skip to content

Commit

Permalink
Resolved Crash, Seemingly fixed #41, Version Bump
Browse files Browse the repository at this point in the history
 - Resolved Crash related to trying to cast `ClientWorld` to `ServerWorld`
 - Resolving this appears to have resolved the issue present in Issue #41
  • Loading branch information
chronosacaria committed Aug 19, 2024
1 parent 2b591f2 commit eaef0d9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ minecraft_version=1.20.1
yarn_mappings=1.20.1+build.9
loader_version=0.14.21
# Mod Properties
mod_version=4.0.3
mod_version=4.0.4
maven_group=chronosacaria
archives_base_name=mcdar
# Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import chronosacaria.mcdar.api.McdarEnchantmentHelper;
import chronosacaria.mcdar.enums.StatusInflictingArtifactID;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;

import java.util.List;
Expand All @@ -25,22 +25,30 @@ public SatchelOfElementsItem() {
);
}

public TypedActionResult<ItemStack> use (World world, PlayerEntity user, Hand hand){
ItemStack itemStack = user.getStackInHand(hand);
@Override
public ActionResult useOnBlock (ItemUsageContext context) {
if (context.getPlayer() != null && context.getPlayer().getWorld().getServer() != null) {
ServerPlayerEntity user = context.getPlayer().getWorld().getServer().getPlayerManager().getPlayer(context.getPlayer().getUuid());
if (user != null) {
Hand hand = user.getActiveHand();
ItemStack itemStack = user.getStackInHand(hand);

if (user.totalExperience >= 15 || user.isCreative()) {
AOEHelper.satchelOfElementsEffects(user);
if (user.totalExperience >= 15 || user.isCreative()) {
AOEHelper.satchelOfElementsEffects(user);

if (!user.isCreative()) {
user.addExperience(-15);
itemStack.damage(1, user, (entity) -> entity.sendToolBreakStatus(hand));
if (!user.isCreative()) {
user.addExperience(-15);
itemStack.damage(1, user, (entity) -> entity.sendToolBreakStatus(hand));
}
McdarEnchantmentHelper.mcdar$cooldownHelper(
user,
this
);
return ActionResult.CONSUME;
}
}
McdarEnchantmentHelper.mcdar$cooldownHelper(
user,
this
);
}
return new TypedActionResult<>(ActionResult.SUCCESS, itemStack);
return ActionResult.PASS;
}

@Override
Expand Down

0 comments on commit eaef0d9

Please sign in to comment.