generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made water vision of Merling togglable
- Loading branch information
Showing
3 changed files
with
38 additions
and
3 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
35 changes: 35 additions & 0 deletions
35
src/main/java/io/github/apace100/origins/power/ToggleNightVisionPower.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 io.github.apace100.origins.power; | ||
|
||
import io.github.apace100.origins.component.OriginComponent; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.nbt.ByteTag; | ||
import net.minecraft.nbt.Tag; | ||
|
||
public class ToggleNightVisionPower extends NightVisionPower implements Active { | ||
private boolean isActive; | ||
|
||
public ToggleNightVisionPower(PowerType<?> type, PlayerEntity player) { | ||
super(type, player); | ||
this.isActive = true; | ||
} | ||
|
||
@Override | ||
public void onUse() { | ||
this.isActive = !this.isActive; | ||
OriginComponent.sync(player); | ||
} | ||
|
||
public boolean isActive() { | ||
return this.isActive && super.isActive(); | ||
} | ||
|
||
@Override | ||
public Tag toTag() { | ||
return ByteTag.of(isActive); | ||
} | ||
|
||
@Override | ||
public void fromTag(Tag tag) { | ||
isActive = ((ByteTag)tag).getByte() > 0; | ||
} | ||
} |