2020-05-23 14:02:38 +02:00
|
|
|
package com.simibubi.create.content.contraptions.components.actors;
|
2020-02-12 01:36:18 +01:00
|
|
|
|
2021-03-31 15:22:41 +02:00
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
2021-12-10 00:27:56 +01:00
|
|
|
import com.jozufozu.flywheel.api.MaterialManager;
|
2021-12-25 10:01:48 +01:00
|
|
|
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
|
2023-05-09 18:23:47 +02:00
|
|
|
import com.simibubi.create.AllTags;
|
2020-05-23 14:02:38 +02:00
|
|
|
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
2021-03-16 23:52:37 +01:00
|
|
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
2021-05-17 03:42:56 +02:00
|
|
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
2022-06-20 18:23:54 +02:00
|
|
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
|
2020-02-12 01:36:18 +01:00
|
|
|
import com.simibubi.create.foundation.utility.VecHelper;
|
2021-04-08 19:22:11 +02:00
|
|
|
|
2021-11-02 00:08:20 +01:00
|
|
|
import net.minecraft.client.renderer.MultiBufferSource;
|
|
|
|
import net.minecraft.core.BlockPos;
|
2021-11-02 06:18:30 +01:00
|
|
|
import net.minecraft.world.damagesource.DamageSource;
|
2021-11-02 00:08:20 +01:00
|
|
|
import net.minecraft.world.level.Level;
|
2021-11-02 06:18:30 +01:00
|
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
|
|
import net.minecraft.world.phys.Vec3;
|
2020-02-12 01:36:18 +01:00
|
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
|
|
|
|
|
|
public class DrillMovementBehaviour extends BlockBreakingMovementBehaviour {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isActive(MovementContext context) {
|
2021-07-15 11:32:03 +02:00
|
|
|
return !VecHelper.isVecPointingTowards(context.relativeMotion, context.state.getValue(DrillBlock.FACING)
|
2020-05-25 19:58:13 +02:00
|
|
|
.getOpposite());
|
2020-02-12 01:36:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-11-02 00:08:20 +01:00
|
|
|
public Vec3 getActiveAreaOffset(MovementContext context) {
|
|
|
|
return Vec3.atLowerCornerOf(context.state.getValue(DrillBlock.FACING)
|
2021-07-15 11:32:03 +02:00
|
|
|
.getNormal()).scale(.65f);
|
2020-02-12 01:36:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@OnlyIn(value = Dist.CLIENT)
|
2021-12-25 10:01:48 +01:00
|
|
|
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
|
2021-11-02 00:08:20 +01:00
|
|
|
ContraptionMatrices matrices, MultiBufferSource buffer) {
|
2022-06-20 18:23:54 +02:00
|
|
|
if (!ContraptionRenderDispatcher.canInstance())
|
2021-05-17 03:42:56 +02:00
|
|
|
DrillRenderer.renderInContraption(context, renderWorld, matrices, buffer);
|
2020-02-12 01:36:18 +01:00
|
|
|
}
|
2020-04-29 19:12:42 +02:00
|
|
|
|
2021-01-24 01:39:11 +01:00
|
|
|
@Override
|
|
|
|
public boolean hasSpecialInstancedRendering() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-03-16 23:52:37 +01:00
|
|
|
@Nullable
|
2021-01-22 20:28:39 +01:00
|
|
|
@Override
|
2021-12-25 10:01:48 +01:00
|
|
|
public ActorInstance createInstance(MaterialManager materialManager, VirtualRenderWorld simulationWorld, MovementContext context) {
|
2021-06-04 06:23:06 +02:00
|
|
|
return new DrillActorInstance(materialManager, simulationWorld, context);
|
2020-02-12 01:36:18 +01:00
|
|
|
}
|
2020-04-29 19:12:42 +02:00
|
|
|
|
2020-03-13 00:51:25 +01:00
|
|
|
@Override
|
|
|
|
protected DamageSource getDamageSource() {
|
|
|
|
return DrillBlock.damageSourceDrill;
|
|
|
|
}
|
2020-02-12 01:36:18 +01:00
|
|
|
|
2020-04-29 19:12:42 +02:00
|
|
|
@Override
|
2021-11-02 00:08:20 +01:00
|
|
|
public boolean canBreak(Level world, BlockPos breakingPos, BlockState state) {
|
2020-05-25 19:58:13 +02:00
|
|
|
return super.canBreak(world, breakingPos, state) && !state.getCollisionShape(world, breakingPos)
|
2023-05-09 18:23:47 +02:00
|
|
|
.isEmpty() && !AllTags.AllBlockTags.TRACKS.matches(state);
|
2020-04-29 19:12:42 +02:00
|
|
|
}
|
|
|
|
|
2020-02-12 01:36:18 +01:00
|
|
|
}
|