-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: util methods in SuitSet
- Loading branch information
Showing
6 changed files
with
84 additions
and
25 deletions.
There are no files selected for viewing
23 changes: 0 additions & 23 deletions
23
src/main/java/mc/duzo/timeless/mixin/PlayerEntityMixin.java
This file was deleted.
Oops, something went wrong.
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
53 changes: 53 additions & 0 deletions
53
src/main/java/mc/duzo/timeless/suit/ironman/mk5/MarkFiveCase.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,53 @@ | ||
package mc.duzo.timeless.suit.ironman.mk5; | ||
|
||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings; | ||
|
||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.util.Hand; | ||
import net.minecraft.util.TypedActionResult; | ||
import net.minecraft.world.World; | ||
|
||
import mc.duzo.timeless.registry.Register; | ||
import mc.duzo.timeless.suit.set.SetRegistry; | ||
import mc.duzo.timeless.suit.set.SuitSet; | ||
|
||
public class MarkFiveCase extends Item { | ||
public MarkFiveCase() { | ||
super(new FabricItemSettings().maxCount(1)); | ||
} | ||
|
||
@Override | ||
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) { | ||
if (world.isClient()) return TypedActionResult.consume(user.getStackInHand(hand)); | ||
|
||
boolean success = fromCase((ServerPlayerEntity) user, false); | ||
return (success) ? TypedActionResult.consume(user.getStackInHand(hand)) : TypedActionResult.fail(user.getStackInHand(hand)); | ||
} | ||
|
||
public static boolean toCase(ServerPlayerEntity player, boolean force) { | ||
if (!force) { | ||
if (!(getSet().isWearing(player))) return false; | ||
} | ||
|
||
player.getInventory().offerOrDrop(new ItemStack(Register.Items.MARK_FIVE_CASE)); | ||
return true; | ||
} | ||
public static boolean fromCase(ServerPlayerEntity player, boolean force) { | ||
if (!force) { | ||
if (!player.getMainHandStack().isOf(Register.Items.MARK_FIVE_CASE)) return false; // not holding | ||
if (getSet().isWearing(player)) return false; // already wearing | ||
|
||
player.getMainHandStack().setCount(0); | ||
} | ||
|
||
getSet().wear(player); | ||
return true; | ||
} | ||
|
||
private static SuitSet getSet() { | ||
return SetRegistry.MARK_FIVE; | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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