0.7.0 update :3
This commit is contained in:
50
trash_bin/old/base/PumpjackBaseRenderer.java
Normal file
50
trash_bin/old/base/PumpjackBaseRenderer.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package com.drmangotea.createindustry.blocks.machines.oil_processing.pumpjack.old.base;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.registry.TFMGPartialModels;
|
||||
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.simibubi.create.foundation.blockEntity.renderer.SafeBlockEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class PumpjackBaseRenderer extends SafeBlockEntityRenderer<PumpjackBaseBlockEntity> {
|
||||
|
||||
public PumpjackBaseRenderer(BlockEntityRendererProvider.Context context) {}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(PumpjackBaseBlockEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
BlockState blockState = te.getBlockState();
|
||||
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
|
||||
ms.pushPose();
|
||||
TransformStack msr = TransformStack.cast(ms);
|
||||
msr.translate(1 / 2f, 0.5, 1 / 2f);
|
||||
float dialPivot = 5.75f / 16;
|
||||
if(te.isComplete()) {
|
||||
|
||||
CachedBufferer.partial(TFMGPartialModels.PUMPJACK_FRONT_ROPE, blockState)
|
||||
// .rotateY(d.toYRot())
|
||||
.unCentre()
|
||||
.translateY(1)
|
||||
.light(light)
|
||||
.renderInto(ms, vb);
|
||||
}
|
||||
|
||||
|
||||
|
||||
ms.popPose();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderOffScreen(PumpjackBaseBlockEntity te) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
112
trash_bin/old/crank/PumpjackCrankInstance.java
Normal file
112
trash_bin/old/crank/PumpjackCrankInstance.java
Normal file
@@ -0,0 +1,112 @@
|
||||
package com.drmangotea.createindustry.blocks.machines.oil_processing.pumpjack.old.crank;
|
||||
|
||||
|
||||
import com.jozufozu.flywheel.api.MaterialManager;
|
||||
import com.jozufozu.flywheel.api.instance.DynamicInstance;
|
||||
import com.jozufozu.flywheel.core.materials.model.ModelData;
|
||||
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.content.kinetics.base.KineticBlockEntityInstance;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import net.minecraft.core.Direction;
|
||||
|
||||
|
||||
public class PumpjackCrankInstance extends KineticBlockEntityInstance<PumpjackCrankBlockEntity> implements DynamicInstance {
|
||||
|
||||
|
||||
protected final ModelData hammer;
|
||||
protected float lastAngle = Float.NaN;
|
||||
static float originOffset = 1 / 16f;
|
||||
|
||||
public PumpjackCrankInstance(MaterialManager modelManager, PumpjackCrankBlockEntity tile) {
|
||||
super(modelManager, tile);
|
||||
|
||||
|
||||
hammer = getTransformMaterial().getModel(blockState)
|
||||
.createInstance();
|
||||
|
||||
animate(tile.angle);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beginFrame() {
|
||||
|
||||
|
||||
|
||||
float angle = blockEntity.angle;
|
||||
|
||||
|
||||
animate(angle);
|
||||
|
||||
lastAngle = angle;
|
||||
}
|
||||
|
||||
private void animate(float angle) {
|
||||
PoseStack ms = new PoseStack();
|
||||
TransformStack msr = TransformStack.cast(ms);
|
||||
|
||||
msr.translate(getInstancePosition());
|
||||
|
||||
|
||||
|
||||
// msr.centre()
|
||||
// .rotateCentered(Direction.EAST, AngleHelper.rad(angle))
|
||||
// .unCentre();
|
||||
if(blockEntity.direction==Direction.EAST) {
|
||||
msr.translateY(-0.5);
|
||||
msr
|
||||
.centre()
|
||||
.translate(0, .25, 0)
|
||||
.rotate(Direction.SOUTH, AngleHelper.rad(angle))
|
||||
.translateBack(0, -.25, 0)
|
||||
.unCentre();
|
||||
}
|
||||
if(blockEntity.direction==Direction.WEST) {
|
||||
msr.translateY(-0.5);
|
||||
msr
|
||||
.centre()
|
||||
.translate(0, .25, 0)
|
||||
.rotate(Direction.NORTH, AngleHelper.rad(angle))
|
||||
.translateBack(0, -.25, 0)
|
||||
.unCentre();
|
||||
}
|
||||
if(blockEntity.direction==Direction.NORTH) {
|
||||
msr.translateY(-0.5);
|
||||
msr
|
||||
.centre()
|
||||
.translate(0, .25, 0)
|
||||
.rotate(Direction.EAST, AngleHelper.rad(angle))
|
||||
.translateBack(0, -.25, 0)
|
||||
.unCentre();
|
||||
}
|
||||
if(blockEntity.direction==Direction.SOUTH) {
|
||||
msr.translateY(-0.5);
|
||||
msr
|
||||
.centre()
|
||||
.translate(0, .25, 0)
|
||||
.rotate(Direction.WEST, AngleHelper.rad(angle))
|
||||
.translateBack(0, -.25, 0)
|
||||
.unCentre();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
hammer.setTransform(ms);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void updateLight() {
|
||||
relight(pos, hammer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
hammer.delete();
|
||||
}
|
||||
|
||||
}
|
||||
45
trash_bin/old/hammer_holder/PumpjackHammerHolderBlock.java
Normal file
45
trash_bin/old/hammer_holder/PumpjackHammerHolderBlock.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package com.drmangotea.createindustry.blocks.machines.oil_processing.pumpjack.old.hammer_holder;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.registry.TFMGBlockEntities;
|
||||
import com.simibubi.create.foundation.block.IBE;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
|
||||
public class PumpjackHammerHolderBlock extends HorizontalDirectionalBlock implements IBE<PumpjackHammerHolderBlockEntity> {
|
||||
|
||||
public PumpjackHammerHolderBlock(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> p_54794_) {
|
||||
p_54794_.add(HorizontalDirectionalBlock.FACING);
|
||||
}
|
||||
public BlockState getStateForPlacement(BlockPlaceContext p_54779_) {
|
||||
return this.defaultBlockState().setValue(HorizontalDirectionalBlock.FACING, p_54779_.getHorizontalDirection());
|
||||
}
|
||||
@Override
|
||||
public RenderShape getRenderShape(BlockState pState) {
|
||||
return RenderShape.ENTITYBLOCK_ANIMATED;
|
||||
}
|
||||
@Override
|
||||
public Class<PumpjackHammerHolderBlockEntity> getBlockEntityClass() {
|
||||
return PumpjackHammerHolderBlockEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends PumpjackHammerHolderBlockEntity> getBlockEntityType() {
|
||||
return TFMGBlockEntities.PUMPJACK_HAMMER_HOLDER.get();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
162
trash_bin/old/hammer_holder/PumpjackHammerHolderBlockEntity.java
Normal file
162
trash_bin/old/hammer_holder/PumpjackHammerHolderBlockEntity.java
Normal file
@@ -0,0 +1,162 @@
|
||||
package com.drmangotea.createindustry.blocks.machines.oil_processing.pumpjack.old.hammer_holder;
|
||||
|
||||
import com.drmangotea.createindustry.blocks.machines.oil_processing.pumpjack.old.crank.PumpjackCrankBlockEntity;
|
||||
import com.drmangotea.createindustry.blocks.machines.oil_processing.pumpjack.machine_input.MachineInputBlockEntity;
|
||||
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
|
||||
import com.simibubi.create.content.kinetics.base.KineticBlockEntity;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
|
||||
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
|
||||
import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class PumpjackHammerHolderBlockEntity extends KineticBlockEntity implements IHaveGoggleInformation {
|
||||
float targetSpeed;
|
||||
LerpedFloat visualSpeed = LerpedFloat.linear();
|
||||
LerpedFloat angle = LerpedFloat.angular();
|
||||
float debugMogus = 0.4f;
|
||||
float speedModifier=0;
|
||||
public BlockPos crankPos;
|
||||
public PumpjackCrankBlockEntity crank;
|
||||
|
||||
|
||||
public float crankAngle;
|
||||
public Direction direction = this.getBlockState().getValue(HorizontalDirectionalBlock.FACING);;
|
||||
public Direction direction2 = this.getBlockState().getValue(HorizontalDirectionalBlock.FACING).getCounterClockWise();;
|
||||
public PumpjackHammerHolderBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
angle.setValue(14);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AABB createRenderBoundingBox() {
|
||||
return new AABB(this.getBlockPos()).inflate(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
|
||||
|
||||
}
|
||||
public boolean hasCrank(){
|
||||
BlockPos theoreticalPos;
|
||||
if(direction == Direction.NORTH){
|
||||
theoreticalPos = this.getBlockPos().south(2).below();
|
||||
if(level.getBlockEntity(theoreticalPos) instanceof PumpjackCrankBlockEntity){
|
||||
crankPos = theoreticalPos;
|
||||
crank = (PumpjackCrankBlockEntity) level.getBlockEntity(crankPos);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(direction == Direction.SOUTH){
|
||||
theoreticalPos = this.getBlockPos().north(2).below();
|
||||
if(level.getBlockEntity(theoreticalPos) instanceof PumpjackCrankBlockEntity){
|
||||
crankPos = theoreticalPos;
|
||||
crank = (PumpjackCrankBlockEntity) level.getBlockEntity(crankPos);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(direction == Direction.WEST){
|
||||
theoreticalPos = this.getBlockPos().east(2).below();
|
||||
if(level.getBlockEntity(theoreticalPos) instanceof PumpjackCrankBlockEntity){
|
||||
crankPos = theoreticalPos;
|
||||
crank = (PumpjackCrankBlockEntity) level.getBlockEntity(crankPos);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(direction == Direction.EAST){
|
||||
theoreticalPos = this.getBlockPos().west(2).below();
|
||||
if(level.getBlockEntity(theoreticalPos) instanceof PumpjackCrankBlockEntity) {
|
||||
crankPos = theoreticalPos;
|
||||
crank = (PumpjackCrankBlockEntity) level.getBlockEntity(crankPos);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
direction = this.getBlockState().getValue(HorizontalDirectionalBlock.FACING);
|
||||
if (!level.isClientSide)
|
||||
return;
|
||||
if(!hasCrank()) {
|
||||
angle.setValue(14);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!(level.getBlockEntity(crankPos.below()) instanceof MachineInputBlockEntity)){
|
||||
angle.setValue(14);
|
||||
return;
|
||||
}
|
||||
if(((MachineInputBlockEntity) level.getBlockEntity(crankPos.below())).powerLevel==0) {
|
||||
angle.setValue(14);
|
||||
return;
|
||||
}
|
||||
if(!(crank.isValid())){
|
||||
angle.setValue(14);
|
||||
return;
|
||||
}
|
||||
angle.tickChaser();
|
||||
|
||||
if(angle.getValue()>0){
|
||||
speedModifier=(angle.getValue()/25)*-1;
|
||||
}else
|
||||
speedModifier=angle.getValue()/25;
|
||||
|
||||
crankAngle=crank.angle;
|
||||
|
||||
//if(crankAngle==90||crankAngle==270) {
|
||||
// angle.chase(13, 0.125f, Chaser.EXP);
|
||||
//}
|
||||
|
||||
angle.updateChaseSpeed(.8f+speedModifier);
|
||||
if(crankAngle==180){
|
||||
angle.chase(-14, .8f+speedModifier, Chaser.LINEAR);
|
||||
|
||||
}
|
||||
|
||||
if(crankAngle==0) {
|
||||
angle.chase(14, .8f+speedModifier, Chaser.LINEAR);
|
||||
//angle.updateChaseSpeed(angle.getValue());
|
||||
}
|
||||
}
|
||||
/*
|
||||
public boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneaking) {
|
||||
if(hasCrank()){
|
||||
Lang.translate("goggles.surface_scanner.no_rotation")
|
||||
.style(ChatFormatting.GREEN)
|
||||
.forGoggles(tooltip);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
*/
|
||||
@Override
|
||||
public void write(CompoundTag compound, boolean clientPacket) {
|
||||
super.write(compound, clientPacket);
|
||||
if (clientPacket) {
|
||||
compound.putFloat("Angle", angle.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void read(CompoundTag compound, boolean clientPacket) {
|
||||
super.read(compound, clientPacket);
|
||||
if (clientPacket) {
|
||||
|
||||
angle.setValue(compound.getFloat("Angle"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.drmangotea.createindustry.blocks.machines.oil_processing.pumpjack.old.hammer_holder;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.registry.TFMGPartialModels;
|
||||
import com.jozufozu.flywheel.api.MaterialManager;
|
||||
import com.jozufozu.flywheel.api.instance.DynamicInstance;
|
||||
import com.jozufozu.flywheel.core.materials.model.ModelData;
|
||||
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.content.kinetics.base.KineticBlockEntityInstance;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
||||
public class PumpjackHammerHolderInstance extends KineticBlockEntityInstance<PumpjackHammerHolderBlockEntity> implements DynamicInstance {
|
||||
|
||||
|
||||
protected final ModelData hammer;
|
||||
protected final ModelData holder;
|
||||
protected float lastAngle = Float.NaN;
|
||||
|
||||
public PumpjackHammerHolderInstance(MaterialManager modelManager, PumpjackHammerHolderBlockEntity tile) {
|
||||
super(modelManager, tile);
|
||||
|
||||
|
||||
hammer = getTransformMaterial()
|
||||
.getModel(TFMGPartialModels.PUMPJACK_HAMMER,blockState,tile.direction)
|
||||
.createInstance();
|
||||
|
||||
holder = getTransformMaterial()
|
||||
.getModel(blockState)
|
||||
.createInstance();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beginFrame() {
|
||||
|
||||
float partialTicks = AnimationTickHolder.getPartialTicks();
|
||||
|
||||
float speed = blockEntity.visualSpeed.getValue(partialTicks) * 3 / 10f;
|
||||
float angle = blockEntity.angle.getValue() + speed * partialTicks;
|
||||
|
||||
if (Math.abs(angle - lastAngle) < 0.001)
|
||||
return;
|
||||
|
||||
animate(angle);
|
||||
|
||||
lastAngle = angle;
|
||||
}
|
||||
|
||||
private void animate(float angle) {
|
||||
PoseStack ms = new PoseStack();
|
||||
TransformStack msr = TransformStack.cast(ms);
|
||||
|
||||
msr.translate(getInstancePosition());
|
||||
msr.centre()
|
||||
.rotate(blockEntity.direction.getClockWise(), AngleHelper.rad(angle))
|
||||
.unCentre();
|
||||
PoseStack ms2 = new PoseStack();
|
||||
TransformStack msr2 = TransformStack.cast(ms2);
|
||||
|
||||
msr2.translate(getInstancePosition());
|
||||
//msr.centre()
|
||||
// .rotate(blockEntity.direction.getClockWise(), AngleHelper.rad(angle))
|
||||
// .unCentre();
|
||||
|
||||
|
||||
hammer.setTransform(ms);
|
||||
holder.setTransform(ms2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void updateLight() {
|
||||
relight(pos, hammer,holder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
hammer.delete();
|
||||
holder.delete();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.drmangotea.createindustry.blocks.machines.oil_processing.pumpjack.old.hammer_holder;
|
||||
|
||||
|
||||
import com.drmangotea.createindustry.registry.TFMGPartialModels;
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import static net.minecraft.world.level.block.HorizontalDirectionalBlock.FACING;
|
||||
|
||||
public class PumpjackHammerHolderRenderer extends KineticBlockEntityRenderer<PumpjackHammerHolderBlockEntity> {
|
||||
|
||||
protected float lastAngle = Float.NaN;
|
||||
public PumpjackHammerHolderRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(PumpjackHammerHolderBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
|
||||
// super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||
|
||||
|
||||
if (Backend.canUseInstancing(be.getLevel()))
|
||||
return;
|
||||
|
||||
BlockState blockState = be.getBlockState();
|
||||
PumpjackHammerHolderBlockEntity wte = (PumpjackHammerHolderBlockEntity) be;
|
||||
|
||||
|
||||
float speed = be.visualSpeed.getValue(partialTicks) * 3 / 10f;
|
||||
float angle = be.angle.getValue() + speed * partialTicks;
|
||||
|
||||
//if (Math.abs(angle - lastAngle) < 0.001)
|
||||
// return;
|
||||
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
|
||||
renderHammer(be, ms, light, blockState, angle, vb);
|
||||
|
||||
lastAngle = angle;
|
||||
}
|
||||
|
||||
private void renderHammer(PumpjackHammerHolderBlockEntity be, PoseStack ms, int light, BlockState blockState, float angle,
|
||||
VertexConsumer vb) {
|
||||
|
||||
|
||||
SuperByteBuffer hammer =
|
||||
CachedBufferer.partialFacing(TFMGPartialModels.PUMPJACK_HAMMER, be.getBlockState(), be.direction);
|
||||
int lightInFront = LevelRenderer.getLightColor(be.getLevel(), be.getBlockPos());
|
||||
|
||||
Direction.Axis axis = blockState.getValue(HorizontalDirectionalBlock.FACING).getAxis();
|
||||
|
||||
hammer.centre();
|
||||
|
||||
hammer.rotate(be.direction.getClockWise(), (float) Math.toRadians(angle));
|
||||
|
||||
hammer.unCentre();
|
||||
|
||||
|
||||
hammer.renderInto(ms, vb);
|
||||
//kineticRotationTransform(hammer, be, be.direction2.getAxis(), angle, lightInFront).renderInto(ms, vb);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user