-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b39e50c
commit 6d74d18
Showing
29 changed files
with
365 additions
and
50 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/main/java/com/petrolpark/destroy/block/CreativePumpBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.petrolpark.destroy.block; | ||
|
||
import com.petrolpark.destroy.block.entity.DestroyBlockEntityTypes; | ||
import com.petrolpark.destroy.block.shape.DestroyShapes; | ||
import com.simibubi.create.content.fluids.pump.PumpBlock; | ||
import com.simibubi.create.content.fluids.pump.PumpBlockEntity; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.block.entity.BlockEntityType; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.phys.shapes.CollisionContext; | ||
import net.minecraft.world.phys.shapes.VoxelShape; | ||
|
||
public class CreativePumpBlock extends PumpBlock { | ||
|
||
public CreativePumpBlock(Properties properties) { | ||
super(properties); | ||
}; | ||
|
||
@Override | ||
public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { | ||
return DestroyShapes.CREATIVE_PUMP.get(state.getValue(FACING).getAxis()); | ||
}; | ||
|
||
@Override | ||
public BlockEntityType<? extends PumpBlockEntity> getBlockEntityType() { | ||
return DestroyBlockEntityTypes.CREATIVE_PUMP.get(); | ||
}; | ||
|
||
@Override | ||
public boolean isSmallCog() { | ||
return false; | ||
}; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
src/main/java/com/petrolpark/destroy/block/entity/CreativePumpBlockEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package com.petrolpark.destroy.block.entity; | ||
|
||
import java.util.List; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.petrolpark.destroy.block.CreativePumpBlock; | ||
import com.simibubi.create.content.fluids.pump.PumpBlockEntity; | ||
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour; | ||
import com.simibubi.create.foundation.blockEntity.behaviour.ValueBoxTransform; | ||
import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsBoard; | ||
import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsFormatter; | ||
import com.simibubi.create.foundation.blockEntity.behaviour.scrollValue.ScrollValueBehaviour; | ||
import com.simibubi.create.foundation.utility.VecHelper; | ||
import com.simibubi.create.infrastructure.config.AllConfigs; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.level.block.entity.BlockEntityType; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.phys.BlockHitResult; | ||
import net.minecraft.world.phys.Vec3; | ||
|
||
public class CreativePumpBlockEntity extends PumpBlockEntity { | ||
|
||
public ScrollValueBehaviour pumpSpeedBehaviour; | ||
protected int simulatedSpeed = 16; // Can't use KineticBlockEntity speed because this gets set to 0 if there is no source | ||
|
||
public CreativePumpBlockEntity(BlockEntityType<?> typeIn, BlockPos pos, BlockState state) { | ||
super(typeIn, pos, state); | ||
}; | ||
|
||
@Override | ||
public void addBehaviours(List<BlockEntityBehaviour> behaviours) { | ||
super.addBehaviours(behaviours); | ||
pumpSpeedBehaviour = new ScrollValueBehaviour(Component.translatable("block.destroy.creative_pump.speed"), this, new CreativePumpValueSlot()) { | ||
@Override | ||
public ValueSettingsBoard createBoard(Player player, BlockHitResult hitResult) { | ||
return new ValueSettingsBoard(label, max, 16, ImmutableList.of(Component.translatable("block.destroy.creative_pump.speed")), new ValueSettingsFormatter(ValueSettings::format)); | ||
}; | ||
} | ||
.between(0, AllConfigs.server().kinetics.maxRotationSpeed.get()) | ||
.withCallback(i -> { | ||
simulatedSpeed = i; | ||
updatePressureChange(); | ||
}); | ||
pumpSpeedBehaviour.setValue(simulatedSpeed); | ||
behaviours.add(pumpSpeedBehaviour); | ||
}; | ||
|
||
@Override | ||
public float getSpeed() { | ||
return simulatedSpeed; | ||
}; | ||
|
||
@Override | ||
protected void read(CompoundTag compound, boolean clientPacket) { | ||
super.read(compound, clientPacket); | ||
simulatedSpeed = compound.getInt("SimulatedSpeed"); | ||
pumpSpeedBehaviour.setValue(simulatedSpeed); | ||
}; | ||
|
||
@Override | ||
protected void write(CompoundTag compound, boolean clientPacket) { | ||
super.write(compound, clientPacket); | ||
compound.putInt("SimulatedSpeed", simulatedSpeed); | ||
}; | ||
|
||
public class CreativePumpValueSlot extends ValueBoxTransform.Sided { | ||
|
||
@Override | ||
protected boolean isSideActive(BlockState state, Direction direction) { | ||
return state.getValue(CreativePumpBlock.FACING).getAxis() != direction.getAxis(); | ||
}; | ||
|
||
@Override | ||
protected Vec3 getSouthLocation() { | ||
return VecHelper.voxelSpace(8d, 8d, 12.5d); | ||
}; | ||
|
||
}; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.