Skip to content

Commit

Permalink
Rewrite Beam Former rendering initialization
Browse files Browse the repository at this point in the history
Closes #34
  • Loading branch information
NotMyWing committed Dec 11, 2023
1 parent 63f3847 commit 3bbcfa3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package co.neeve.nae2.common.interfaces;

public interface IBeamFormerHost {
void notifyBeamFormerState();

boolean hasBeamFormers();
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@
import appeng.core.AELog;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import appeng.parts.ICableBusContainer;
import appeng.parts.PartModel;
import appeng.util.Platform;
import co.neeve.nae2.Tags;
import co.neeve.nae2.client.rendering.BeamRenderer;
import co.neeve.nae2.common.features.subfeatures.BeamFeatures;
import co.neeve.nae2.common.interfaces.IBeamFormerHost;
import co.neeve.nae2.common.parts.NAEBasePartState;
import co.neeve.nae2.server.IBlockStateListener;
import co.neeve.nae2.server.WorldListener;
Expand Down Expand Up @@ -569,9 +567,6 @@ private void drawBeamGT(double x, double y, double z, int dx, int dy, int dz, Bu
@Override
@SideOnly(Side.CLIENT)
public boolean requireDynamicRender() {
if (this.getHost() instanceof ICableBusContainer bc && bc instanceof IBeamFormerHost beamFormerHost) {
beamFormerHost.notifyBeamFormerState();
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
package co.neeve.nae2.mixin.beamformer.client;

import appeng.api.parts.IPart;
import appeng.parts.CableBusContainer;
import co.neeve.nae2.common.interfaces.IBeamFormerHost;
import co.neeve.nae2.common.parts.implementations.PartBeamFormer;
import net.minecraft.util.EnumFacing;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(CableBusContainer.class)
public abstract class MixinCableBusContainer implements IBeamFormerHost {

@Unique
private boolean nae2$hasBeamFormers = false;

@Override
public void notifyBeamFormerState() {
this.nae2$hasBeamFormers = true;
}
@Shadow(remap = false)
public abstract IPart getPart(EnumFacing side);

@Override
public boolean hasBeamFormers() {
Expand All @@ -27,5 +28,12 @@ public boolean hasBeamFormers() {
@Inject(method = "partChanged", at = @At("HEAD"), remap = false)
public void injectPartChanged(CallbackInfo ci) {
this.nae2$hasBeamFormers = false;
for (var facing : EnumFacing.values()) {
var part = this.getPart(facing);
if (part instanceof PartBeamFormer) {
this.nae2$hasBeamFormers = true;
break;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(value = TileCableBus.class, remap = false)
@Mixin(value = TileCableBus.class)
public abstract class MixinTileCableBus {
@Shadow
@Shadow(remap = false)
public abstract CableBusContainer getCableBus();

@Inject(method = "getMaxRenderDistanceSquared", at = @At("HEAD"), cancellable = true)
Expand Down

0 comments on commit 3bbcfa3

Please sign in to comment.