Added the spectral clock for tracking the zap apple tree's season and make the zap apple tree cyce faster
BIN
assets/spectral_clock_0.xcf
Normal file
|
@ -116,6 +116,7 @@ public interface URenderers {
|
||||||
PolearmRenderer.register(UItems.WOODEN_POLEARM, UItems.STONE_POLEARM, UItems.IRON_POLEARM, UItems.GOLDEN_POLEARM, UItems.DIAMOND_POLEARM, UItems.NETHERITE_POLEARM);
|
PolearmRenderer.register(UItems.WOODEN_POLEARM, UItems.STONE_POLEARM, UItems.IRON_POLEARM, UItems.GOLDEN_POLEARM, UItems.DIAMOND_POLEARM, UItems.NETHERITE_POLEARM);
|
||||||
ModelPredicateProviderRegistry.register(UItems.GEMSTONE, new Identifier("affinity"), (stack, world, entity, seed) -> EnchantableItem.isEnchanted(stack) ? EnchantableItem.getSpellKey(stack).getAffinity().getAlignment() : 0);
|
ModelPredicateProviderRegistry.register(UItems.GEMSTONE, new Identifier("affinity"), (stack, world, entity, seed) -> EnchantableItem.isEnchanted(stack) ? EnchantableItem.getSpellKey(stack).getAffinity().getAlignment() : 0);
|
||||||
ModelPredicateProviderRegistry.register(UItems.ROCK_CANDY, new Identifier("count"), (stack, world, entity, seed) -> stack.getCount() / (float)stack.getMaxCount());
|
ModelPredicateProviderRegistry.register(UItems.ROCK_CANDY, new Identifier("count"), (stack, world, entity, seed) -> stack.getCount() / (float)stack.getMaxCount());
|
||||||
|
ModelPredicateProviderRegistry.register(Unicopia.id("zap_cycle"), (stack, world, entity, seed) -> UnicopiaClient.getInstance().getZapStageDelta());
|
||||||
|
|
||||||
ColorProviderRegistry.BLOCK.register(URenderers::getTintedBlockColor, TintedBlock.REGISTRY.stream().toArray(Block[]::new));
|
ColorProviderRegistry.BLOCK.register(URenderers::getTintedBlockColor, TintedBlock.REGISTRY.stream().toArray(Block[]::new));
|
||||||
ColorProviderRegistry.ITEM.register((stack, i) -> getTintedBlockColor(Block.getBlockFromItem(stack.getItem()).getDefaultState(), null, null, i), TintedBlock.REGISTRY.stream().map(Block::asItem).filter(i -> i != Items.AIR).toArray(Item[]::new));
|
ColorProviderRegistry.ITEM.register((stack, i) -> getTintedBlockColor(Block.getBlockFromItem(stack.getItem()).getDefaultState(), null, null, i), TintedBlock.REGISTRY.stream().map(Block::asItem).filter(i -> i != Items.AIR).toArray(Item[]::new));
|
||||||
|
|
|
@ -22,6 +22,7 @@ import com.minelittlepony.unicopia.entity.player.PlayerCamera;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
import com.minelittlepony.unicopia.network.handler.ClientNetworkHandlerImpl;
|
import com.minelittlepony.unicopia.network.handler.ClientNetworkHandlerImpl;
|
||||||
import com.minelittlepony.unicopia.server.world.WeatherConditions;
|
import com.minelittlepony.unicopia.server.world.WeatherConditions;
|
||||||
|
import com.minelittlepony.unicopia.server.world.ZapAppleStageStore;
|
||||||
import com.minelittlepony.unicopia.util.Lerp;
|
import com.minelittlepony.unicopia.util.Lerp;
|
||||||
|
|
||||||
import net.fabricmc.api.ClientModInitializer;
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
|
@ -53,6 +54,9 @@ public class UnicopiaClient implements ClientModInitializer {
|
||||||
public final Lerp tangentalSkyAngle = new Lerp(0, true);
|
public final Lerp tangentalSkyAngle = new Lerp(0, true);
|
||||||
public final Lerp skyAngle = new Lerp(0, true);
|
public final Lerp skyAngle = new Lerp(0, true);
|
||||||
|
|
||||||
|
private ZapAppleStageStore.Stage zapAppleStage = ZapAppleStageStore.Stage.HIBERNATING;
|
||||||
|
private long zapStageTime;
|
||||||
|
|
||||||
public static Optional<PlayerCamera> getCamera() {
|
public static Optional<PlayerCamera> getCamera() {
|
||||||
PlayerEntity player = MinecraftClient.getInstance().player;
|
PlayerEntity player = MinecraftClient.getInstance().player;
|
||||||
|
|
||||||
|
@ -84,6 +88,15 @@ public class UnicopiaClient implements ClientModInitializer {
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setZapAppleStage(ZapAppleStageStore.Stage stage, long delta) {
|
||||||
|
zapAppleStage = stage;
|
||||||
|
zapStageTime = delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getZapStageDelta() {
|
||||||
|
return zapAppleStage.getCycleProgress(zapStageTime);
|
||||||
|
}
|
||||||
|
|
||||||
public float getSkyAngleDelta(float tickDelta) {
|
public float getSkyAngleDelta(float tickDelta) {
|
||||||
if (MinecraftClient.getInstance().world == null) {
|
if (MinecraftClient.getInstance().world == null) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -135,6 +148,8 @@ public class UnicopiaClient implements ClientModInitializer {
|
||||||
world.setRainGradient(gradient);
|
world.setRainGradient(gradient);
|
||||||
world.setThunderGradient(gradient);
|
world.setThunderGradient(gradient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
zapStageTime++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Float getTargetRainGradient(ClientWorld world, BlockPos pos, float tickDelta) {
|
private Float getTargetRainGradient(ClientWorld world, BlockPos pos, float tickDelta) {
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class SpellbookChapterLoader extends JsonDataLoader implements Identifiab
|
||||||
dirty = false;
|
dirty = false;
|
||||||
MsgServerResources msg = new MsgServerResources();
|
MsgServerResources msg = new MsgServerResources();
|
||||||
server.getWorlds().forEach(world -> {
|
server.getWorlds().forEach(world -> {
|
||||||
Channel.SERVER_RESOURCES_SEND.sendToAllPlayers(msg, world);
|
Channel.SERVER_RESOURCES.sendToAllPlayers(msg, world);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,6 +164,7 @@ public interface UItems {
|
||||||
Item PALM_BASKET = register("palm_basket", new BasketItem(AirBalloonEntity.BasketType.of(UWoodTypes.PALM_BOAT_TYPE), new Item.Settings().maxCount(1)), ItemGroups.TOOLS);
|
Item PALM_BASKET = register("palm_basket", new BasketItem(AirBalloonEntity.BasketType.of(UWoodTypes.PALM_BOAT_TYPE), new Item.Settings().maxCount(1)), ItemGroups.TOOLS);
|
||||||
|
|
||||||
Item GIANT_BALLOON = register("giant_balloon", new HotAirBalloonItem(new Item.Settings().maxCount(1)), ItemGroups.TOOLS);
|
Item GIANT_BALLOON = register("giant_balloon", new HotAirBalloonItem(new Item.Settings().maxCount(1)), ItemGroups.TOOLS);
|
||||||
|
Item SPECTRAL_CLOCK = register("spectral_clock", new Item(new Item.Settings()), ItemGroups.TOOLS);
|
||||||
|
|
||||||
Item LIGHT_GRAY_BED_SHEETS = register(CloudBedBlock.SheetPattern.LIGHT_GRAY);
|
Item LIGHT_GRAY_BED_SHEETS = register(CloudBedBlock.SheetPattern.LIGHT_GRAY);
|
||||||
Item GRAY_BED_SHEETS = register(CloudBedBlock.SheetPattern.GRAY);
|
Item GRAY_BED_SHEETS = register(CloudBedBlock.SheetPattern.GRAY);
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.minelittlepony.unicopia.network;
|
||||||
import com.minelittlepony.unicopia.*;
|
import com.minelittlepony.unicopia.*;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
import com.minelittlepony.unicopia.server.world.UnicopiaWorldProperties;
|
import com.minelittlepony.unicopia.server.world.UnicopiaWorldProperties;
|
||||||
|
import com.minelittlepony.unicopia.server.world.ZapAppleStageStore;
|
||||||
import com.sollace.fabwork.api.packets.*;
|
import com.sollace.fabwork.api.packets.*;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||||
|
@ -29,11 +30,12 @@ public interface Channel {
|
||||||
S2CPacketType<MsgSpellbookStateChanged<PlayerEntity>> SERVER_SPELLBOOK_UPDATE = SimpleNetworking.serverToClient(Unicopia.id("server_spellbook_update"), MsgSpellbookStateChanged::new);
|
S2CPacketType<MsgSpellbookStateChanged<PlayerEntity>> SERVER_SPELLBOOK_UPDATE = SimpleNetworking.serverToClient(Unicopia.id("server_spellbook_update"), MsgSpellbookStateChanged::new);
|
||||||
C2SPacketType<MsgSpellbookStateChanged<ServerPlayerEntity>> CLIENT_SPELLBOOK_UPDATE = SimpleNetworking.clientToServer(Unicopia.id("client_spellbook_update"), MsgSpellbookStateChanged::new);
|
C2SPacketType<MsgSpellbookStateChanged<ServerPlayerEntity>> CLIENT_SPELLBOOK_UPDATE = SimpleNetworking.clientToServer(Unicopia.id("client_spellbook_update"), MsgSpellbookStateChanged::new);
|
||||||
|
|
||||||
S2CPacketType<MsgServerResources> SERVER_RESOURCES_SEND = SimpleNetworking.serverToClient(Unicopia.id("resources_send"), MsgServerResources::new);
|
S2CPacketType<MsgServerResources> SERVER_RESOURCES = SimpleNetworking.serverToClient(Unicopia.id("resources"), MsgServerResources::new);
|
||||||
|
|
||||||
S2CPacketType<MsgOtherPlayerCapabilities> SERVER_OTHER_PLAYER_CAPABILITIES = SimpleNetworking.serverToClient(Unicopia.id("other_player_capabilities"), MsgOtherPlayerCapabilities::new);
|
S2CPacketType<MsgOtherPlayerCapabilities> SERVER_OTHER_PLAYER_CAPABILITIES = SimpleNetworking.serverToClient(Unicopia.id("other_player_capabilities"), MsgOtherPlayerCapabilities::new);
|
||||||
S2CPacketType<MsgPlayerAnimationChange> SERVER_PLAYER_ANIMATION_CHANGE = SimpleNetworking.serverToClient(Unicopia.id("other_player_animation_change"), MsgPlayerAnimationChange::new);
|
S2CPacketType<MsgPlayerAnimationChange> SERVER_PLAYER_ANIMATION_CHANGE = SimpleNetworking.serverToClient(Unicopia.id("other_player_animation_change"), MsgPlayerAnimationChange::new);
|
||||||
S2CPacketType<MsgSkyAngle> SERVER_SKY_ANGLE = SimpleNetworking.serverToClient(Unicopia.id("sky_angle"), MsgSkyAngle::new);
|
S2CPacketType<MsgSkyAngle> SERVER_SKY_ANGLE = SimpleNetworking.serverToClient(Unicopia.id("sky_angle"), MsgSkyAngle::new);
|
||||||
|
S2CPacketType<MsgZapAppleStage> SERVER_ZAP_STAGE = SimpleNetworking.serverToClient(Unicopia.id("zap_stage"), MsgZapAppleStage::new);
|
||||||
|
|
||||||
static void bootstrap() {
|
static void bootstrap() {
|
||||||
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
|
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
|
||||||
|
@ -50,8 +52,10 @@ public interface Channel {
|
||||||
Unicopia.LOGGER.info("Setting {}'s race to {} due to host setting", handler.player.getDisplayName().getString(), Race.REGISTRY.getId(race).toString());
|
Unicopia.LOGGER.info("Setting {}'s race to {} due to host setting", handler.player.getDisplayName().getString(), Race.REGISTRY.getId(race).toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sender.sendPacket(SERVER_RESOURCES_SEND.id(), new MsgServerResources().toBuffer());
|
sender.sendPacket(SERVER_RESOURCES.id(), new MsgServerResources().toBuffer());
|
||||||
sender.sendPacket(SERVER_SKY_ANGLE.id(), new MsgSkyAngle(UnicopiaWorldProperties.forWorld(handler.getPlayer().getServerWorld()).getTangentalSkyAngle()).toBuffer());
|
sender.sendPacket(SERVER_SKY_ANGLE.id(), new MsgSkyAngle(UnicopiaWorldProperties.forWorld(handler.getPlayer().getServerWorld()).getTangentalSkyAngle()).toBuffer());
|
||||||
|
ZapAppleStageStore store = ZapAppleStageStore.get(handler.player.getServerWorld());
|
||||||
|
sender.sendPacket(SERVER_ZAP_STAGE.id(), new MsgZapAppleStage(store.getStage(), store.getStageDelta()).toBuffer());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.minelittlepony.unicopia.network;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.server.world.ZapAppleStageStore;
|
||||||
|
import com.sollace.fabwork.api.packets.Packet;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.network.PacketByteBuf;
|
||||||
|
|
||||||
|
public record MsgZapAppleStage (
|
||||||
|
ZapAppleStageStore.Stage stage,
|
||||||
|
long delta
|
||||||
|
) implements Packet<PlayerEntity> {
|
||||||
|
|
||||||
|
public MsgZapAppleStage(PacketByteBuf buffer) {
|
||||||
|
this(buffer.readEnumConstant(ZapAppleStageStore.Stage.class), buffer.readLong());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toBuffer(PacketByteBuf buffer) {
|
||||||
|
buffer.writeEnumConstant(stage);
|
||||||
|
buffer.writeLong(delta);
|
||||||
|
}
|
||||||
|
}
|
|
@ -36,8 +36,9 @@ public class ClientNetworkHandlerImpl {
|
||||||
Channel.SERVER_BLOCK_DESTRUCTION.receiver().addPersistentListener(this::handleBlockDestruction);
|
Channel.SERVER_BLOCK_DESTRUCTION.receiver().addPersistentListener(this::handleBlockDestruction);
|
||||||
Channel.CANCEL_PLAYER_ABILITY.receiver().addPersistentListener(this::handleCancelAbility);
|
Channel.CANCEL_PLAYER_ABILITY.receiver().addPersistentListener(this::handleCancelAbility);
|
||||||
Channel.UNLOCK_TRAITS.receiver().addPersistentListener(this::handleUnlockTraits);
|
Channel.UNLOCK_TRAITS.receiver().addPersistentListener(this::handleUnlockTraits);
|
||||||
Channel.SERVER_RESOURCES_SEND.receiver().addPersistentListener(this::handleServerResources);
|
Channel.SERVER_RESOURCES.receiver().addPersistentListener(this::handleServerResources);
|
||||||
Channel.SERVER_SKY_ANGLE.receiver().addPersistentListener(this::handleSkyAngle);
|
Channel.SERVER_SKY_ANGLE.receiver().addPersistentListener(this::handleSkyAngle);
|
||||||
|
Channel.SERVER_ZAP_STAGE.receiver().addPersistentListener(this::handleZapStage);
|
||||||
Channel.SERVER_PLAYER_ANIMATION_CHANGE.receiver().addPersistentListener(this::handlePlayerAnimation);
|
Channel.SERVER_PLAYER_ANIMATION_CHANGE.receiver().addPersistentListener(this::handlePlayerAnimation);
|
||||||
Channel.SERVER_REQUEST_PLAYER_LOOK.receiver().addPersistentListener(this::handleCasterLookRequest);
|
Channel.SERVER_REQUEST_PLAYER_LOOK.receiver().addPersistentListener(this::handleCasterLookRequest);
|
||||||
}
|
}
|
||||||
|
@ -93,6 +94,10 @@ public class ClientNetworkHandlerImpl {
|
||||||
UnicopiaClient.getInstance().tangentalSkyAngle.update(packet.tangentalSkyAngle(), 200);
|
UnicopiaClient.getInstance().tangentalSkyAngle.update(packet.tangentalSkyAngle(), 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleZapStage(PlayerEntity sender, MsgZapAppleStage packet) {
|
||||||
|
UnicopiaClient.getInstance().setZapAppleStage(packet.stage(), packet.delta());
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void handleServerResources(PlayerEntity sender, MsgServerResources packet) {
|
private void handleServerResources(PlayerEntity sender, MsgServerResources packet) {
|
||||||
SpellTraits.load(packet.traits());
|
SpellTraits.load(packet.traits());
|
||||||
|
|
|
@ -5,6 +5,8 @@ import java.util.stream.StreamSupport;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.USounds;
|
import com.minelittlepony.unicopia.USounds;
|
||||||
import com.minelittlepony.unicopia.Unicopia;
|
import com.minelittlepony.unicopia.Unicopia;
|
||||||
|
import com.minelittlepony.unicopia.network.Channel;
|
||||||
|
import com.minelittlepony.unicopia.network.MsgZapAppleStage;
|
||||||
import com.minelittlepony.unicopia.particle.LightningBoltParticleEffect;
|
import com.minelittlepony.unicopia.particle.LightningBoltParticleEffect;
|
||||||
import com.minelittlepony.unicopia.particle.ParticleUtils;
|
import com.minelittlepony.unicopia.particle.ParticleUtils;
|
||||||
import com.minelittlepony.unicopia.util.Tickable;
|
import com.minelittlepony.unicopia.util.Tickable;
|
||||||
|
@ -20,10 +22,13 @@ import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.PersistentState;
|
import net.minecraft.world.PersistentState;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
import net.minecraft.world.event.GameEvent;
|
import net.minecraft.world.event.GameEvent;
|
||||||
|
|
||||||
public class ZapAppleStageStore extends PersistentState implements Tickable {
|
public class ZapAppleStageStore extends PersistentState implements Tickable {
|
||||||
private static final Identifier ID = Unicopia.id("zap_apple_stage");
|
private static final Identifier ID = Unicopia.id("zap_apple_stage");
|
||||||
|
static final long DAY_LENGTH = World.field_30969;
|
||||||
|
static final long MOON_PHASES = DimensionType.MOON_SIZES.length;
|
||||||
|
|
||||||
public static ZapAppleStageStore get(World world) {
|
public static ZapAppleStageStore get(World world) {
|
||||||
return WorldOverlay.getPersistableStorage(world, ID, ZapAppleStageStore::new, ZapAppleStageStore::new);
|
return WorldOverlay.getPersistableStorage(world, ID, ZapAppleStageStore::new, ZapAppleStageStore::new);
|
||||||
|
@ -32,7 +37,9 @@ public class ZapAppleStageStore extends PersistentState implements Tickable {
|
||||||
private final World world;
|
private final World world;
|
||||||
|
|
||||||
private Stage lastStage = Stage.HIBERNATING;
|
private Stage lastStage = Stage.HIBERNATING;
|
||||||
private int countdown;
|
private long stageDelta;
|
||||||
|
private long lastTime;
|
||||||
|
|
||||||
private boolean stageChanged;
|
private boolean stageChanged;
|
||||||
private boolean playedMoonEffect;
|
private boolean playedMoonEffect;
|
||||||
private int nextLightningEvent = 1200;
|
private int nextLightningEvent = 1200;
|
||||||
|
@ -40,8 +47,8 @@ public class ZapAppleStageStore extends PersistentState implements Tickable {
|
||||||
ZapAppleStageStore(World world, NbtCompound compound) {
|
ZapAppleStageStore(World world, NbtCompound compound) {
|
||||||
this(world);
|
this(world);
|
||||||
lastStage = Stage.VALUES[Math.max(0, compound.getInt("stage")) % Stage.VALUES.length];
|
lastStage = Stage.VALUES[Math.max(0, compound.getInt("stage")) % Stage.VALUES.length];
|
||||||
|
stageDelta = compound.getLong("stageDelta");
|
||||||
stageChanged = compound.getBoolean("stageChanged");
|
stageChanged = compound.getBoolean("stageChanged");
|
||||||
countdown = compound.getInt("countdown");
|
|
||||||
playedMoonEffect = compound.getBoolean("playedMoonEffect");
|
playedMoonEffect = compound.getBoolean("playedMoonEffect");
|
||||||
nextLightningEvent = compound.getInt("nextLightningEvent");
|
nextLightningEvent = compound.getInt("nextLightningEvent");
|
||||||
}
|
}
|
||||||
|
@ -55,32 +62,38 @@ public class ZapAppleStageStore extends PersistentState implements Tickable {
|
||||||
if (!world.isDay()) {
|
if (!world.isDay()) {
|
||||||
if (nextLightningEvent > 0) {
|
if (nextLightningEvent > 0) {
|
||||||
nextLightningEvent--;
|
nextLightningEvent--;
|
||||||
markDirty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stageChanged && (lastStage != Stage.HIBERNATING || (world.getMoonPhase() == 0))) {
|
if (!stageChanged && (lastStage != Stage.HIBERNATING || (world.getMoonPhase() == 0))) {
|
||||||
stageChanged = true;
|
stageChanged = true;
|
||||||
if (countDay()) {
|
lastStage = lastStage.getNext();
|
||||||
lastStage = lastStage.getNext();
|
stageDelta = 0;
|
||||||
countdown = 1;
|
playedMoonEffect = false;
|
||||||
playedMoonEffect = false;
|
sendUpdate();
|
||||||
markDirty();
|
|
||||||
onStageChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (stageChanged) {
|
} else if (stageChanged) {
|
||||||
stageChanged = false;
|
stageChanged = false;
|
||||||
markDirty();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private boolean countDay() {
|
long timeOfDay = world.getTimeOfDay();
|
||||||
|
if (stageDelta != 0 && (timeOfDay < lastTime || timeOfDay > lastTime + 10)) {
|
||||||
|
long timeDifference = timeOfDay - lastTime;
|
||||||
|
Unicopia.LOGGER.info("Times a changing {}!", timeDifference);
|
||||||
|
while (timeDifference < 0) {
|
||||||
|
timeDifference += DAY_LENGTH;
|
||||||
|
}
|
||||||
|
stageDelta += timeDifference;
|
||||||
|
sendUpdate();
|
||||||
|
}
|
||||||
|
lastTime = timeOfDay;
|
||||||
|
|
||||||
|
|
||||||
|
stageDelta++;
|
||||||
markDirty();
|
markDirty();
|
||||||
return countdown-- <= 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onStageChanged() {
|
protected void sendUpdate() {
|
||||||
//world.setRainGradient(0.5F);
|
Channel.SERVER_ZAP_STAGE.sendToAllPlayers(new MsgZapAppleStage(getStage(), stageDelta), world);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playMoonEffect(BlockPos pos) {
|
public void playMoonEffect(BlockPos pos) {
|
||||||
|
@ -112,7 +125,6 @@ public class ZapAppleStageStore extends PersistentState implements Tickable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true during nights that the zap apples must change their states.
|
* Returns true during nights that the zap apples must change their states.
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public boolean hasStageChanged() {
|
public boolean hasStageChanged() {
|
||||||
return stageChanged;
|
return stageChanged;
|
||||||
|
@ -125,30 +137,60 @@ public class ZapAppleStageStore extends PersistentState implements Tickable {
|
||||||
return lastStage;
|
return lastStage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getStageDelta() {
|
||||||
|
return stageDelta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getStageProgress() {
|
||||||
|
return getStage().getStageProgress(getStageDelta());
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getCycleProgress() {
|
||||||
|
return getStage().getCycleProgress(getStageDelta());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NbtCompound writeNbt(NbtCompound compound) {
|
public NbtCompound writeNbt(NbtCompound compound) {
|
||||||
compound.putInt("stage", lastStage.ordinal());
|
compound.putInt("stage", lastStage.ordinal());
|
||||||
|
compound.putLong("stageDelta", stageDelta);
|
||||||
compound.putBoolean("stageChanged", stageChanged);
|
compound.putBoolean("stageChanged", stageChanged);
|
||||||
compound.putInt("countdown", countdown);
|
|
||||||
compound.putBoolean("playedMoonEffect", playedMoonEffect);
|
compound.putBoolean("playedMoonEffect", playedMoonEffect);
|
||||||
compound.putInt("nextLightningEvent", nextLightningEvent);
|
compound.putInt("nextLightningEvent", nextLightningEvent);
|
||||||
return compound;
|
return compound;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Stage implements StringIdentifiable {
|
public enum Stage implements StringIdentifiable {
|
||||||
HIBERNATING,
|
HIBERNATING(MOON_PHASES * DAY_LENGTH),
|
||||||
GREENING,
|
GREENING(DAY_LENGTH),
|
||||||
FLOWERING,
|
FLOWERING(DAY_LENGTH),
|
||||||
FRUITING,
|
FRUITING(DAY_LENGTH),
|
||||||
RIPE;
|
RIPE(DAY_LENGTH);
|
||||||
|
|
||||||
static final long DAY_LENGTH = 24000;
|
|
||||||
static final Stage[] VALUES = values();
|
static final Stage[] VALUES = values();
|
||||||
|
|
||||||
|
private final long duration;
|
||||||
|
|
||||||
|
Stage(long duration) {
|
||||||
|
this.duration = duration;
|
||||||
|
}
|
||||||
|
|
||||||
public Stage getNext() {
|
public Stage getNext() {
|
||||||
return byId((ordinal() + 1) % VALUES.length);
|
return byId((ordinal() + 1) % VALUES.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Stage getPrevious() {
|
||||||
|
return byId(((ordinal() - 1) + VALUES.length) % VALUES.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getStageProgress(long time) {
|
||||||
|
return (time % duration) / (float)duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getCycleProgress(long time) {
|
||||||
|
float ordinal = ordinal();
|
||||||
|
return MathHelper.lerp(getStageProgress(time), ordinal, ordinal + 1) / 5F;
|
||||||
|
}
|
||||||
|
|
||||||
public static Stage byId(int id) {
|
public static Stage byId(int id) {
|
||||||
return VALUES[MathHelper.clamp(id, 0, VALUES.length)];
|
return VALUES[MathHelper.clamp(id, 0, VALUES.length)];
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,8 @@
|
||||||
"item.unicopia.palm_chest_boat": "Palm Boat with Chest",
|
"item.unicopia.palm_chest_boat": "Palm Boat with Chest",
|
||||||
|
|
||||||
"item.unicopia.spellbook": "Spellbook",
|
"item.unicopia.spellbook": "Spellbook",
|
||||||
|
"item.unicopia.spectral_clock": "Spectral Clock",
|
||||||
|
|
||||||
"emi.category.unicopia.spellbook": "Spellbook",
|
"emi.category.unicopia.spellbook": "Spellbook",
|
||||||
"emi.category.unicopia.cloud_shaping": "Shaping",
|
"emi.category.unicopia.cloud_shaping": "Shaping",
|
||||||
"emi.category.unicopia.growing": "Growing",
|
"emi.category.unicopia.growing": "Growing",
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "unicopia:item/spectral_clock_0"
|
||||||
|
},
|
||||||
|
"overrides": [
|
||||||
|
{ "predicate": { "unicopia:zap_cycle": 0.00}, "model": "unicopia:item/spectral_clock" },
|
||||||
|
{ "predicate": { "unicopia:zap_cycle": 0.05}, "model": "unicopia:item/spectral_clock_1" },
|
||||||
|
{ "predicate": { "unicopia:zap_cycle": 0.10}, "model": "unicopia:item/spectral_clock_2" },
|
||||||
|
{ "predicate": { "unicopia:zap_cycle": 0.15}, "model": "unicopia:item/spectral_clock_3" },
|
||||||
|
{ "predicate": { "unicopia:zap_cycle": 0.20}, "model": "unicopia:item/spectral_clock_greening_0" },
|
||||||
|
{ "predicate": { "unicopia:zap_cycle": 0.25}, "model": "unicopia:item/spectral_clock_greening_1" },
|
||||||
|
{ "predicate": { "unicopia:zap_cycle": 0.30}, "model": "unicopia:item/spectral_clock_greening_2" },
|
||||||
|
{ "predicate": { "unicopia:zap_cycle": 0.35}, "model": "unicopia:item/spectral_clock_greening_3" },
|
||||||
|
{ "predicate": { "unicopia:zap_cycle": 0.40}, "model": "unicopia:item/spectral_clock_flowering_0" },
|
||||||
|
{ "predicate": { "unicopia:zap_cycle": 0.45}, "model": "unicopia:item/spectral_clock_flowering_1" },
|
||||||
|
{ "predicate": { "unicopia:zap_cycle": 0.50}, "model": "unicopia:item/spectral_clock_flowering_2" },
|
||||||
|
{ "predicate": { "unicopia:zap_cycle": 0.55}, "model": "unicopia:item/spectral_clock_flowering_3" },
|
||||||
|
{ "predicate": { "unicopia:zap_cycle": 0.60}, "model": "unicopia:item/spectral_clock_fruiting_0" },
|
||||||
|
{ "predicate": { "unicopia:zap_cycle": 0.65}, "model": "unicopia:item/spectral_clock_fruiting_1" },
|
||||||
|
{ "predicate": { "unicopia:zap_cycle": 0.70}, "model": "unicopia:item/spectral_clock_fruiting_2" },
|
||||||
|
{ "predicate": { "unicopia:zap_cycle": 0.75}, "model": "unicopia:item/spectral_clock_fruiting_3" },
|
||||||
|
{ "predicate": { "unicopia:zap_cycle": 0.80}, "model": "unicopia:item/spectral_clock_ripe_0" },
|
||||||
|
{ "predicate": { "unicopia:zap_cycle": 0.85}, "model": "unicopia:item/spectral_clock_ripe_1" },
|
||||||
|
{ "predicate": { "unicopia:zap_cycle": 0.90}, "model": "unicopia:item/spectral_clock_ripe_2" },
|
||||||
|
{ "predicate": { "unicopia:zap_cycle": 0.95}, "model": "unicopia:item/spectral_clock_ripe_3" },
|
||||||
|
{ "predicate": { "unicopia:zap_cycle": 1.00}, "model": "unicopia:item/spectral_clock" }
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "unicopia:item/spectral_clock_1"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "unicopia:item/spectral_clock_2"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "unicopia:item/spectral_clock_3"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "unicopia:item/spectral_clock_flowering_0"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "unicopia:item/spectral_clock_flowering_1"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "unicopia:item/spectral_clock_flowering_2"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "unicopia:item/spectral_clock_flowering_3"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "unicopia:item/spectral_clock_fruiting_0"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "unicopia:item/spectral_clock_fruiting_1"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "unicopia:item/spectral_clock_fruiting_2"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "unicopia:item/spectral_clock_fruiting_3"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "unicopia:item/spectral_clock_greening_0"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "unicopia:item/spectral_clock_greening_1"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "unicopia:item/spectral_clock_greening_2"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "unicopia:item/spectral_clock_greening_3"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "unicopia:item/spectral_clock_ripe_0"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "unicopia:item/spectral_clock_ripe_1"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "unicopia:item/spectral_clock_ripe_2"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "unicopia:item/spectral_clock_ripe_3"
|
||||||
|
}
|
||||||
|
}
|
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.6 KiB |