Skip to content

Commit

Permalink
✨ DanmakuStateModifier to modify state easier
Browse files Browse the repository at this point in the history
  • Loading branch information
H2Sxxa committed Sep 10, 2023
1 parent 704d37d commit 50829ab
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@EventBusSubscriber(modid = KekkaiModInfo.MODID)
public class HanderDeclear {
public class DeclearBus {
public static List<String> SPELLCARD_PACKAGES = new ArrayList<>();

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package io.github.teamgensouspark.kekkai.danmaku;

import net.katsstuff.teamnightclipse.danmakucore.danmaku.DanmakuEntityData;
import net.katsstuff.teamnightclipse.danmakucore.danmaku.TrackerData;
import net.katsstuff.teamnightclipse.danmakucore.danmaku.subentity.SubEntity;
import net.katsstuff.teamnightclipse.danmakucore.data.MovementData;
import net.katsstuff.teamnightclipse.danmakucore.data.RotationData;
import net.katsstuff.teamnightclipse.danmakucore.data.ShotData;
import net.katsstuff.teamnightclipse.mirror.data.Vector3;
import net.katsstuff.teamnightclipse.danmakucore.danmaku.DanmakuState;
import net.katsstuff.teamnightclipse.danmakucore.danmaku.ExtraDanmakuData;

public class DanmakuStateModifier {
DanmakuState danmaku;

DanmakuEntityData entityData;
ExtraDanmakuData extra;
TrackerData tracker;

public DanmakuStateModifier(DanmakuState danmaku) {
this.danmaku = danmaku;
this.entityData = danmaku.entity();
this.extra = danmaku.extra();
this.tracker = danmaku.tracking();
}

public DanmakuEntityData getEntityData() {
return entityData;
}

public ExtraDanmakuData getExtraData() {
return extra;
}

public TrackerData getTrackerData() {
return tracker;
}

public DanmakuStateModifier setDirection(Vector3 direction) {
this.entityData.setDirection(direction);
return this;
}

public DanmakuStateModifier setMovement(MovementData movement) {
this.extra = this.extra.copy(extra.user(), extra.source(), extra.shot(), extra.subEntity(), movement,
extra.rotation());
return this;
}

public DanmakuStateModifier setShot(ShotData shot) {
this.extra = this.extra.copy(extra.user(), extra.source(), shot, extra.subEntity(), extra.movement(),
extra.rotation());
return this;
}

public DanmakuStateModifier setRotation(RotationData rotation) {
this.extra = this.extra.copy(extra.user(), extra.source(), extra.shot(), extra.subEntity(), extra.movement(),
rotation);
return this;
}

public DanmakuStateModifier setSubEntity(SubEntity entity) {
this.extra = this.extra.copy(extra.user(), extra.source(), extra.shot(), entity, extra.movement(),
extra.rotation());
return this;
}

public DanmakuState getDanmaku() {
return danmaku.copy(entityData, extra, tracker);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@

@EventBusSubscriber(modid = KekkaiModInfo.MODID)
public class KekkaiSubEntities {
public static final SubEntityType TRACKING = new SubEntityBase<TrackingTargetSubEntity>("tracking_target", TrackingTargetSubEntity.class);
public static final SubEntityType TRACKING = new SubEntityBase<TrackingTargetSubEntity>("tracking_target",
TrackingTargetSubEntity.class);
public static final SubEntityType TOSELF = new SubEntityBase<ShotToSelfSubEntity>("shot_to_self",
ShotToSelfSubEntity.class);

@SubscribeEvent
public static void onSubEntityRegister(RegistryEvent.Register<SubEntityType> event) {
event.getRegistry().registerAll(TRACKING);
event.getRegistry().registerAll(TRACKING, TOSELF);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.github.teamgensouspark.kekkai.danmaku.subentity.impl;

import net.katsstuff.teamnightclipse.danmakucore.danmaku.DanmakuState;
import net.katsstuff.teamnightclipse.danmakucore.impl.subentity.SubEntityDefault;
import net.katsstuff.teamnightclipse.mirror.data.Vector3;

public class ShotToSelfSubEntity extends SubEntityDefault {

@Override
public DanmakuState onCreate(DanmakuState danmaku) {
return super.onCreate(danmaku).copy(
danmaku.entity()
.setDirection(
(Vector3) Vector3.directionToPos(danmaku.pos(), new Vector3(danmaku.user().get()))),
danmaku.extra(), danmaku.tracking());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.github.teamgensouspark.kekkai.utils;

import net.katsstuff.teamnightclipse.mirror.data.AbstractVector3;
import net.katsstuff.teamnightclipse.mirror.data.Vector3;

public class Vector3Utils {
public static Vector3 pos2pos(AbstractVector3 from, AbstractVector3 to) {
return (Vector3) Vector3.directionToPos(from, to);
}
}

0 comments on commit 50829ab

Please sign in to comment.