-
Notifications
You must be signed in to change notification settings - Fork 11
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
1 parent
a9d9ab9
commit 3c2925e
Showing
16 changed files
with
216 additions
and
16 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
7 changes: 0 additions & 7 deletions
7
src/main/java/net/zepalesque/redux/attachment/AttachmentModule.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
102 changes: 102 additions & 0 deletions
102
src/main/java/net/zepalesque/redux/attachment/SliderSignalAttachment.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,102 @@ | ||
package net.zepalesque.redux.attachment; | ||
|
||
import com.aetherteam.aether.entity.monster.dungeon.boss.Slider; | ||
import com.aetherteam.nitrogen.attachment.INBTSynchable; | ||
import com.aetherteam.nitrogen.network.packet.SyncPacket; | ||
import net.minecraft.sounds.SoundSource; | ||
import net.zepalesque.redux.client.audio.ReduxSounds; | ||
import org.apache.commons.lang3.tuple.Triple; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Map; | ||
import java.util.function.Consumer; | ||
import java.util.function.Supplier; | ||
|
||
public class SliderSignalAttachment implements INBTSynchable { | ||
|
||
private final Map<String, Triple<INBTSynchable.Type, Consumer<Object>, Supplier<Object>>> synchableFunctions = Map.ofEntries( | ||
Map.entry("signal_tick", Triple.of(INBTSynchable.Type.INT, (object) -> this.setSignalTick((int) object), this::getSignalTick)), | ||
Map.entry("move_trajectory", Triple.of(INBTSynchable.Type.INT, (object) -> this.setMoveTrajectory((int) object), this::getMoveTrajectoryIndex)) | ||
); | ||
|
||
protected int signalTick = 0; | ||
|
||
@Nullable | ||
protected net.minecraft.core.Direction moveTrajectory = null; | ||
|
||
|
||
public void onUpdate(Slider slider) { | ||
this.tickSignal(slider); | ||
} | ||
|
||
protected void tickSignal(Slider slider) { | ||
if (this.signalTick > 0) { | ||
this.signalTick--; | ||
} | ||
} | ||
|
||
public boolean shouldGlow(Slider slider) { | ||
return this.signalTick == 6 || this.signalTick == 1; | ||
} | ||
|
||
public void doBeep(Slider slider) { | ||
if (!slider.level().isClientSide()) { | ||
this.setSynched(slider.getId(), Direction.NEAR, "signal_tick", 6);; | ||
slider.level().playSound(null, slider.getX(), slider.getY(), slider.getZ(), ReduxSounds.SLIDER_SIGNAL, SoundSource.HOSTILE, 1F, 1F); | ||
} | ||
} | ||
|
||
public void syncMoveDirection(Slider slider) { | ||
if (!slider.level().isClientSide()) { | ||
this.setSynched(slider.getId(), Direction.NEAR, "move_trajectory", slider.getMoveDirection()); | ||
} | ||
} | ||
|
||
public static @NotNull SliderSignalAttachment get(@NotNull Slider slider) { | ||
return slider.getData(ReduxDataAttachments.SLIDER_SIGNAL.get()); | ||
} | ||
|
||
public int getSignalTick() { | ||
return signalTick; | ||
} | ||
|
||
public void setSignalTick(int signalTick) { | ||
this.signalTick = signalTick; | ||
} | ||
|
||
|
||
public net.minecraft.core.Direction getMoveTrajectory() { | ||
return moveTrajectory; | ||
} | ||
|
||
public int getMoveTrajectoryIndex() { | ||
return moveTrajectory == null ? -1 : moveTrajectory.ordinal(); | ||
} | ||
|
||
public void setMoveTrajectory(net.minecraft.core.Direction moveTrajectory) { | ||
this.moveTrajectory = moveTrajectory; | ||
} | ||
|
||
public void setMoveTrajectory(int index) { | ||
net.minecraft.core.Direction[] array = net.minecraft.core.Direction.values(); | ||
if (index >= array.length || index < 0) return; | ||
this.moveTrajectory = net.minecraft.core.Direction.values()[index]; | ||
} | ||
|
||
|
||
@Override | ||
public Map<String, Triple<Type, Consumer<Object>, Supplier<Object>>> getSynchableFunctions() { | ||
return synchableFunctions; | ||
} | ||
|
||
@Override | ||
public SyncPacket getSyncPacket(int entityID, String key, Type type, Object value) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void setSynched(int entityID, Direction direction, String key, Object value) { | ||
INBTSynchable.super.setSynched(entityID, direction, key, value); | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
src/main/java/net/zepalesque/redux/mixin/mixins/common/entity/EntityMixin.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,11 @@ | ||
package net.zepalesque.redux.mixin.mixins.common.entity; | ||
|
||
import net.minecraft.util.RandomSource; | ||
import net.minecraft.world.entity.Entity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
|
||
@Mixin(Entity.class) | ||
public abstract class EntityMixin { | ||
@Shadow public abstract RandomSource getRandom(); | ||
} |
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
8 changes: 8 additions & 0 deletions
8
src/main/java/net/zepalesque/redux/mixin/mixins/common/entity/ai/SliderMoveMixin.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,8 @@ | ||
package net.zepalesque.redux.mixin.mixins.common.entity.ai; | ||
|
||
import com.aetherteam.aether.entity.monster.dungeon.boss.goal.SliderMoveGoal; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
|
||
@Mixin(SliderMoveGoal.class) | ||
public class SliderMoveMixin { | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/net/zepalesque/redux/network/packet/SliderSignalSyncPacket.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,52 @@ | ||
package net.zepalesque.redux.network.packet; | ||
|
||
import com.aetherteam.nitrogen.attachment.INBTSynchable; | ||
import com.aetherteam.nitrogen.network.packet.SyncEntityPacket; | ||
import net.minecraft.network.RegistryFriendlyByteBuf; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload; | ||
import net.neoforged.neoforge.attachment.AttachmentType; | ||
import net.neoforged.neoforge.network.handling.IPayloadContext; | ||
import net.zepalesque.redux.Redux; | ||
import net.zepalesque.redux.attachment.ReduxDataAttachments; | ||
import net.zepalesque.redux.attachment.ReduxPlayerAttachment; | ||
import net.zepalesque.redux.attachment.SliderSignalAttachment; | ||
import oshi.util.tuples.Quartet; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class SliderSignalSyncPacket extends SyncEntityPacket<SliderSignalAttachment> { | ||
|
||
public static final Type<SliderSignalSyncPacket> TYPE = new Type<>(Redux.loc("sync_slider_signal_attachment")); | ||
|
||
public static final StreamCodec<RegistryFriendlyByteBuf, SliderSignalSyncPacket> STREAM_CODEC = CustomPacketPayload.codec( | ||
SliderSignalSyncPacket::write, | ||
SliderSignalSyncPacket::decode); | ||
|
||
public SliderSignalSyncPacket(Quartet<Integer, String, INBTSynchable.Type, Object> values) { | ||
super(values); | ||
} | ||
|
||
public SliderSignalSyncPacket(int entityID, String key, INBTSynchable.Type type, Object value) { | ||
super(entityID, key, type, value); | ||
} | ||
|
||
|
||
public static SliderSignalSyncPacket decode(RegistryFriendlyByteBuf buf) { | ||
return new SliderSignalSyncPacket(SyncEntityPacket.decodeEntityValues(buf)); | ||
} | ||
|
||
@Override | ||
public Supplier<AttachmentType<SliderSignalAttachment>> getAttachment() { | ||
return ReduxDataAttachments.SLIDER_SIGNAL; | ||
} | ||
|
||
@Override | ||
public Type<? extends CustomPacketPayload> type() { | ||
return TYPE; | ||
} | ||
|
||
public static void execute(SliderSignalSyncPacket payload, IPayloadContext context) { | ||
SyncEntityPacket.execute(payload, context.player()); | ||
} | ||
} |
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
Binary file added
BIN
+14.9 KB
src/main/resources/assets/aether_redux/sounds/entity/slider/signal.ogg
Binary file not shown.