Disable a number of amulet effects when in creative mode

This commit is contained in:
Sollace 2022-12-15 11:01:00 +00:00
parent 0bc7c5d233
commit e7d6c22fb4

View file

@ -89,7 +89,7 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab
public void interactWithPlayer(IItemEntity item, PlayerEntity player) { public void interactWithPlayer(IItemEntity item, PlayerEntity player) {
ItemEntity entity = (ItemEntity)item; ItemEntity entity = (ItemEntity)item;
if (!player.world.isClient && !entity.isRemoved()) { if (!player.world.isClient && !entity.isRemoved() && !player.isCreative()) {
if (player.getPos().distanceTo(entity.getPos()) < 0.5) { if (player.getPos().distanceTo(entity.getPos()) < 0.5) {
if (entity.world.random.nextInt(150) == 0) { if (entity.world.random.nextInt(150) == 0) {
entity.setPickupDelay(0); entity.setPickupDelay(0);
@ -115,6 +115,11 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab
@Override @Override
public void onUnequipped(Living<?> wearer, long timeWorn) { public void onUnequipped(Living<?> wearer, long timeWorn) {
if (wearer.getMaster() instanceof PlayerEntity player && player.isCreative()) {
return;
}
float attachedTime = timeWorn / 100F; float attachedTime = timeWorn / 100F;
LocalDifficulty difficulty = wearer.getReferenceWorld().getLocalDifficulty(wearer.getOrigin()); LocalDifficulty difficulty = wearer.getReferenceWorld().getLocalDifficulty(wearer.getOrigin());
@ -188,7 +193,7 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab
reserves.getExertion().add(2); reserves.getExertion().add(2);
} }
if (fullSecond && world.random.nextInt(12) == 0) { if (fullSecond && world.random.nextInt(12) == 0 && !pony.getMaster().isCreative()) {
reserves.getEnergy().add(reserves.getEnergy().getMax() / 10F); reserves.getEnergy().add(reserves.getEnergy().getMax() / 10F);
pony.getCorruption().add((int)MathHelper.clamp(attachedTicks / ItemTracker.HOURS, 1, pony.getCorruption().getMax())); pony.getCorruption().add((int)MathHelper.clamp(attachedTicks / ItemTracker.HOURS, 1, pony.getCorruption().getMax()));
} }