Do some packaging for easier maintenance

This commit is contained in:
grimmauld 2021-04-20 23:55:17 +02:00
parent 838eeeee10
commit 19fa27c54b
7 changed files with 35 additions and 24 deletions

View file

@ -1,5 +1,11 @@
package com.simibubi.create.content.optics; package com.simibubi.create.content.optics;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.Nullable;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
@ -8,12 +14,6 @@ import net.minecraft.item.DyeColor;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.math.vector.Vector3d;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
public class Beam extends ArrayList<BeamSegment> { public class Beam extends ArrayList<BeamSegment> {
private final Set<ILightHandler> lightEventListeners; private final Set<ILightHandler> lightEventListeners;
@Nullable @Nullable

View file

@ -1,6 +1,19 @@
package com.simibubi.create.content.optics; package com.simibubi.create.content.optics.behaviour;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Objects;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Stream;
import javax.annotation.Nullable;
import com.google.common.collect.Iterators; import com.google.common.collect.Iterators;
import com.simibubi.create.content.optics.Beam;
import com.simibubi.create.content.optics.ILightHandler;
import com.simibubi.create.content.optics.ILightHandlerProvider;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.BeaconHelper; import com.simibubi.create.foundation.utility.BeaconHelper;
@ -9,12 +22,6 @@ import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.tileentity.BeaconTileEntity; import net.minecraft.tileentity.BeaconTileEntity;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import javax.annotation.Nullable;
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Stream;
public abstract class LightHandlingBehaviour<T extends SmartTileEntity & ILightHandlerProvider> extends TileEntityBehaviour implements ILightHandler { public abstract class LightHandlingBehaviour<T extends SmartTileEntity & ILightHandlerProvider> extends TileEntityBehaviour implements ILightHandler {
protected final T handler; protected final T handler;
public Set<Beam> beams; public Set<Beam> beams;

View file

@ -1,7 +1,7 @@
package com.simibubi.create.content.optics; package com.simibubi.create.content.optics.behaviour;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.optics.mirror.RotationMode; import com.simibubi.create.content.optics.ILightHandlerProvider;
import com.simibubi.create.foundation.utility.ServerSpeedProvider; import com.simibubi.create.foundation.utility.ServerSpeedProvider;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;

View file

@ -1,4 +1,4 @@
package com.simibubi.create.content.optics.mirror; package com.simibubi.create.content.optics.behaviour;
import com.simibubi.create.foundation.gui.AllIcons; import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.INamedIconOptions; import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.INamedIconOptions;

View file

@ -1,7 +1,11 @@
package com.simibubi.create.content.optics.mirror; package com.simibubi.create.content.optics.mirror;
import java.util.stream.Stream;
import javax.annotation.Nonnull;
import com.simibubi.create.content.optics.Beam; import com.simibubi.create.content.optics.Beam;
import com.simibubi.create.content.optics.RotatedLightHandlingBehaviour; import com.simibubi.create.content.optics.behaviour.RotatedLightHandlingBehaviour;
import com.simibubi.create.foundation.collision.Matrix3d; import com.simibubi.create.foundation.collision.Matrix3d;
import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
@ -10,10 +14,6 @@ import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.math.vector.Vector3d;
import javax.annotation.Nonnull;
import java.util.stream.Stream;
public class MirrorBehaviour extends RotatedLightHandlingBehaviour<MirrorTileEntity> { public class MirrorBehaviour extends RotatedLightHandlingBehaviour<MirrorTileEntity> {
public static final BehaviourType<MirrorBehaviour> TYPE = new BehaviourType<>(); public static final BehaviourType<MirrorBehaviour> TYPE = new BehaviourType<>();

View file

@ -28,7 +28,8 @@ public class MirrorRenderer extends KineticTileEntityRenderer {
MirrorTileEntity mirrorTe = (MirrorTileEntity) te; MirrorTileEntity mirrorTe = (MirrorTileEntity) te;
renderMirror(mirrorTe, partialTicks, ms, buffer, light); renderMirror(mirrorTe, partialTicks, ms, buffer, light);
((MirrorTileEntity) te).getHandler().getRenderBeams() ((MirrorTileEntity) te).getHandler()
.getRenderBeams()
.forEachRemaining(beam -> beam.render(ms, buffer, partialTicks)); .forEachRemaining(beam -> beam.render(ms, buffer, partialTicks));
} }
@ -36,9 +37,11 @@ public class MirrorRenderer extends KineticTileEntityRenderer {
final Direction.Axis facing = te.getBlockState() final Direction.Axis facing = te.getBlockState()
.get(BlockStateProperties.AXIS); .get(BlockStateProperties.AXIS);
SuperByteBuffer superBuffer = AllBlockPartials.MIRROR_PLANE.renderOnDirectionalSouth(te.getBlockState(), te.getHandler().getBeamRotationAround()); SuperByteBuffer superBuffer = AllBlockPartials.MIRROR_PLANE.renderOnDirectionalSouth(te.getBlockState(), te.getHandler()
.getBeamRotationAround());
float interpolatedAngle = te.getHandler().getInterpolatedAngle(partialTicks - 1); float interpolatedAngle = te.getHandler()
.getInterpolatedAngle(partialTicks - 1);
kineticRotationTransform(superBuffer, te, facing, (float) (interpolatedAngle / 180 * Math.PI), light); kineticRotationTransform(superBuffer, te, facing, (float) (interpolatedAngle / 180 * Math.PI), light);
superBuffer.renderInto(ms, buffer.getBuffer(RenderType.getTranslucent())); superBuffer.renderInto(ms, buffer.getBuffer(RenderType.getTranslucent()));
} }

View file

@ -5,6 +5,7 @@ import java.util.List;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.optics.ILightHandler; import com.simibubi.create.content.optics.ILightHandler;
import com.simibubi.create.content.optics.ILightHandlerProvider; import com.simibubi.create.content.optics.ILightHandlerProvider;
import com.simibubi.create.content.optics.behaviour.RotationMode;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.CenteredSideValueBoxTransform; import com.simibubi.create.foundation.tileEntity.behaviour.CenteredSideValueBoxTransform;
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollOptionBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollOptionBehaviour;