-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
178 additions
and
101 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
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
29 changes: 0 additions & 29 deletions
29
common/src/main/java/tocraft/remorphed/events/ShapeEventsCallback.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
11 changes: 5 additions & 6 deletions
11
common/src/main/java/tocraft/remorphed/handler/PlayerRespawnHandler.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 |
---|---|---|
@@ -1,16 +1,15 @@ | ||
package tocraft.remorphed.handler; | ||
|
||
import net.minecraft.client.player.LocalPlayer; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import tocraft.craftedcore.event.client.ClientPlayerEvents; | ||
import tocraft.craftedcore.event.common.PlayerEvents; | ||
import tocraft.remorphed.impl.RemorphedPlayerDataProvider; | ||
import tocraft.remorphed.impl.PlayerMorph; | ||
|
||
public class PlayerRespawnHandler implements PlayerEvents.PlayerRespawn { | ||
@Override | ||
public void clone(ServerPlayer oldPlayer, ServerPlayer newPlayer) { | ||
((RemorphedPlayerDataProvider) newPlayer).remorphed$setUnlockedShapes(((RemorphedPlayerDataProvider) oldPlayer).remorphed$getUnlockedShapes()); | ||
((RemorphedPlayerDataProvider) newPlayer).remorphed$getFavorites().clear(); | ||
((RemorphedPlayerDataProvider) newPlayer).remorphed$getFavorites().addAll(((RemorphedPlayerDataProvider) oldPlayer).remorphed$getFavorites()); | ||
PlayerMorph.getUnlockedShapes(newPlayer).clear(); | ||
PlayerMorph.getUnlockedShapes(newPlayer).putAll(PlayerMorph.getUnlockedShapes(oldPlayer)); | ||
PlayerMorph.getFavorites(newPlayer).clear(); | ||
PlayerMorph.getFavorites(newPlayer).addAll(PlayerMorph.getFavorites(oldPlayer)); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
common/src/main/java/tocraft/remorphed/handler/ShapeEventsCallback.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 tocraft.remorphed.handler; | ||
|
||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.InteractionResult; | ||
import net.minecraft.world.entity.EntityType; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.monster.Enemy; | ||
import tocraft.remorphed.Remorphed; | ||
import tocraft.remorphed.impl.PlayerMorph; | ||
import tocraft.walkers.Walkers; | ||
import tocraft.walkers.api.events.ShapeEvents; | ||
import tocraft.walkers.api.variant.ShapeType; | ||
|
||
public class ShapeEventsCallback implements ShapeEvents.UnlockShapeCallback { | ||
@Override | ||
public InteractionResult unlock(ServerPlayer player, ShapeType<?> type) { | ||
if (type != null) { | ||
// check if the walkers unlock mechanic should be used | ||
if (!Remorphed.CONFIG.lockTransform && Remorphed.CONFIG.unlockFriendlyNormal) { | ||
LivingEntity entityToBeUnlocked = type.create(player.level); | ||
if (!(entityToBeUnlocked instanceof Enemy)) { | ||
PlayerMorph.getUnlockedShapes(player).put(type, Remorphed.getKillToUnlock(type.getEntityType())); | ||
} | ||
} | ||
// check if entity is unlocked by remorphed, prevents native unlock mechanic by walkers | ||
else if (!Remorphed.canUseShape(player, type)) { | ||
if (!type.getEntityType().equals(EntityType.WOLF) || !Walkers.hasSpecialShape(player.getUUID())) { | ||
return InteractionResult.FAIL; | ||
} | ||
} | ||
} | ||
|
||
return InteractionResult.PASS; | ||
} | ||
} |
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
Oops, something went wrong.