This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
You may now generate power using this mod! Runtime tests now load with Mekanism for integration testing.
- Loading branch information
1 parent
06556ee
commit bfdd27a
Showing
32 changed files
with
798 additions
and
20 deletions.
There are no files selected for viewing
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
34 changes: 34 additions & 0 deletions
34
src/generated/resources/assets/nucleartech/blockstates/combustion_generator.json
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,34 @@ | ||
{ | ||
"variants": { | ||
"facing=north,lit=false": { | ||
"model": "nucleartech:block/combustion_generator" | ||
}, | ||
"facing=south,lit=false": { | ||
"model": "nucleartech:block/combustion_generator", | ||
"y": 180 | ||
}, | ||
"facing=west,lit=false": { | ||
"model": "nucleartech:block/combustion_generator", | ||
"y": 270 | ||
}, | ||
"facing=east,lit=false": { | ||
"model": "nucleartech:block/combustion_generator", | ||
"y": 90 | ||
}, | ||
"facing=north,lit=true": { | ||
"model": "nucleartech:block/combustion_generator_on" | ||
}, | ||
"facing=south,lit=true": { | ||
"model": "nucleartech:block/combustion_generator_on", | ||
"y": 180 | ||
}, | ||
"facing=west,lit=true": { | ||
"model": "nucleartech:block/combustion_generator_on", | ||
"y": 270 | ||
}, | ||
"facing=east,lit=true": { | ||
"model": "nucleartech:block/combustion_generator_on", | ||
"y": 90 | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/generated/resources/assets/nucleartech/models/block/combustion_generator.json
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,8 @@ | ||
{ | ||
"parent": "minecraft:block/orientable", | ||
"textures": { | ||
"side": "nucleartech:block/combustion_generator_side", | ||
"front": "nucleartech:block/combustion_generator_front", | ||
"top": "nucleartech:block/combustion_generator_side" | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/generated/resources/assets/nucleartech/models/block/combustion_generator_on.json
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,8 @@ | ||
{ | ||
"parent": "minecraft:block/orientable", | ||
"textures": { | ||
"side": "nucleartech:block/combustion_generator_side", | ||
"front": "nucleartech:block/combustion_generator_front_on", | ||
"top": "nucleartech:block/combustion_generator_side" | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/generated/resources/assets/nucleartech/models/item/combustion_generator.json
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,3 @@ | ||
{ | ||
"parent": "nucleartech:block/combustion_generator" | ||
} |
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
19 changes: 19 additions & 0 deletions
19
src/generated/resources/data/nucleartech/loot_tables/blocks/combustion_generator.json
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,19 @@ | ||
{ | ||
"type": "minecraft:block", | ||
"pools": [ | ||
{ | ||
"rolls": 1, | ||
"entries": [ | ||
{ | ||
"type": "minecraft:item", | ||
"name": "nucleartech:combustion_generator" | ||
} | ||
], | ||
"conditions": [ | ||
{ | ||
"condition": "minecraft:survives_explosion" | ||
} | ||
] | ||
} | ||
] | ||
} |
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
123 changes: 123 additions & 0 deletions
123
src/main/kotlin/at/martinthedragon/nucleartech/blocks/CombustionGenerator.kt
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,123 @@ | ||
package at.martinthedragon.nucleartech.blocks | ||
|
||
import at.martinthedragon.nucleartech.tileentities.CombustionGeneratorTileEntity | ||
import net.minecraft.block.Block | ||
import net.minecraft.block.BlockState | ||
import net.minecraft.block.HorizontalBlock | ||
import net.minecraft.block.material.PushReaction | ||
import net.minecraft.entity.LivingEntity | ||
import net.minecraft.entity.player.PlayerEntity | ||
import net.minecraft.entity.player.ServerPlayerEntity | ||
import net.minecraft.inventory.InventoryHelper | ||
import net.minecraft.inventory.container.Container | ||
import net.minecraft.item.BlockItemUseContext | ||
import net.minecraft.item.ItemStack | ||
import net.minecraft.particles.ParticleTypes | ||
import net.minecraft.state.BooleanProperty | ||
import net.minecraft.state.DirectionProperty | ||
import net.minecraft.state.StateContainer | ||
import net.minecraft.state.properties.BlockStateProperties | ||
import net.minecraft.util.* | ||
import net.minecraft.util.math.BlockPos | ||
import net.minecraft.util.math.BlockRayTraceResult | ||
import net.minecraft.world.IBlockReader | ||
import net.minecraft.world.World | ||
import net.minecraftforge.fluids.FluidUtil | ||
import net.minecraftforge.fml.network.NetworkHooks | ||
import java.util.* | ||
|
||
class CombustionGenerator(properties: Properties) : Block(properties) { | ||
init { | ||
registerDefaultState(stateDefinition.any().setValue(LIT, false)) | ||
} | ||
|
||
override fun getPistonPushReaction(state: BlockState) = PushReaction.BLOCK | ||
|
||
override fun createBlockStateDefinition(builder: StateContainer.Builder<Block, BlockState>) { | ||
builder.add(FACING, LIT) | ||
} | ||
|
||
override fun getStateForPlacement(context: BlockItemUseContext): BlockState = | ||
defaultBlockState().setValue(FACING, context.horizontalDirection.opposite) | ||
|
||
override fun setPlacedBy(world: World, pos: BlockPos, state: BlockState, entity: LivingEntity?, stack: ItemStack) { | ||
if (stack.hasCustomHoverName()) { | ||
val tileEntity = world.getBlockEntity(pos) | ||
if (tileEntity is CombustionGeneratorTileEntity) | ||
tileEntity.customName = stack.hoverName | ||
} | ||
} | ||
|
||
override fun onRemove( | ||
state: BlockState, | ||
world: World, | ||
pos: BlockPos, | ||
newState: BlockState, | ||
p_196243_5_: Boolean | ||
) { | ||
if (!state.`is`(newState.block)) { | ||
val tileEntity = world.getBlockEntity(pos) | ||
if (tileEntity is CombustionGeneratorTileEntity) InventoryHelper.dropContents(world, pos, tileEntity) | ||
} | ||
@Suppress("DEPRECATION") | ||
super.onRemove(state, world, pos, newState, p_196243_5_) | ||
} | ||
|
||
override fun use(state: BlockState, world: World, pos: BlockPos, player: PlayerEntity, hand: Hand, hit: BlockRayTraceResult): ActionResultType { | ||
if (!world.isClientSide) { | ||
if (!FluidUtil.interactWithFluidHandler(player, hand, world, pos, hit.direction)) { | ||
val tileEntity = world.getBlockEntity(pos) | ||
if (tileEntity is CombustionGeneratorTileEntity) NetworkHooks.openGui(player as ServerPlayerEntity, tileEntity, pos) | ||
} | ||
} | ||
return ActionResultType.sidedSuccess(world.isClientSide) | ||
} | ||
|
||
override fun animateTick(state: BlockState, world: World, pos: BlockPos, random: Random) { | ||
if (state.getValue(LIT)) { | ||
val posX = pos.x + 0.5 | ||
val posY = pos.y.toDouble() | ||
val posZ = pos.z + 0.5 | ||
if (random.nextDouble() < 0.1) { | ||
world.playLocalSound( | ||
posX, posY, posZ, | ||
SoundEvents.FURNACE_FIRE_CRACKLE, | ||
SoundCategory.BLOCKS, | ||
1.0f, 1.0f, false | ||
) | ||
} | ||
val direction = state.getValue(FACING) | ||
val axis = direction.axis | ||
val d4 = random.nextDouble() * 0.6 - 0.3 | ||
val d5 = if (axis == Direction.Axis.X) direction.stepX.toDouble() * 0.52 else d4 | ||
val d6 = random.nextDouble() * 6.0 / 16.0 | ||
val d7 = if (axis == Direction.Axis.Z) direction.stepZ.toDouble() * 0.52 else d4 | ||
world.addParticle(ParticleTypes.SMOKE, posX + d5, posY + d6, posZ + d7, 0.0, 0.0, 0.0) | ||
world.addParticle(ParticleTypes.FLAME, posX + d5, posY + d6, posZ + d7, 0.0, 0.0, 0.0) | ||
} | ||
} | ||
|
||
override fun hasAnalogOutputSignal(state: BlockState) = true | ||
|
||
override fun getAnalogOutputSignal(state: BlockState, world: World, pos: BlockPos) = | ||
Container.getRedstoneSignalFromBlockEntity(world.getBlockEntity(pos)) | ||
|
||
override fun getLightValue(state: BlockState, world: IBlockReader, pos: BlockPos) = | ||
if (state.getValue(LIT)) 13 else 0 | ||
|
||
override fun rotate(state: BlockState, direction: Rotation): BlockState = | ||
state.setValue(FACING, direction.rotate(state.getValue(FACING))) | ||
|
||
@Suppress("DEPRECATION") | ||
override fun mirror(state: BlockState, mirror: Mirror): BlockState = | ||
state.rotate(mirror.getRotation(state.getValue(FACING))) | ||
|
||
override fun hasTileEntity(state: BlockState?) = true | ||
|
||
override fun createTileEntity(state: BlockState?, world: IBlockReader?) = CombustionGeneratorTileEntity() | ||
|
||
companion object { | ||
val FACING: DirectionProperty = HorizontalBlock.FACING | ||
val LIT: BooleanProperty = BlockStateProperties.LIT | ||
} | ||
} |
Oops, something went wrong.