-
Notifications
You must be signed in to change notification settings - Fork 672
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement a crystal resonance generator (passive power generation for…
… AE)
- Loading branch information
Showing
29 changed files
with
898 additions
and
14 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/generated/resources/assets/ae2/blockstates/crystal_resonance_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,31 @@ | ||
{ | ||
"variants": { | ||
"facing=down": { | ||
"model": "ae2:block/crystal_resonance_generator", | ||
"x": 180 | ||
}, | ||
"facing=east": { | ||
"model": "ae2:block/crystal_resonance_generator", | ||
"x": 90, | ||
"y": 90 | ||
}, | ||
"facing=north": { | ||
"model": "ae2:block/crystal_resonance_generator", | ||
"x": 90 | ||
}, | ||
"facing=south": { | ||
"model": "ae2:block/crystal_resonance_generator", | ||
"x": 90, | ||
"y": 180 | ||
}, | ||
"facing=up": { | ||
"model": "ae2:block/crystal_resonance_generator", | ||
"x": 360 | ||
}, | ||
"facing=west": { | ||
"model": "ae2:block/crystal_resonance_generator", | ||
"x": 90, | ||
"y": 270 | ||
} | ||
} | ||
} |
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
3 changes: 3 additions & 0 deletions
3
src/generated/resources/assets/ae2/models/item/crystal_resonance_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": "ae2:block/crystal_resonance_generator" | ||
} |
34 changes: 34 additions & 0 deletions
34
...ted/resources/data/ae2/advancements/recipes/misc/network/crystal_resonance_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 @@ | ||
{ | ||
"parent": "minecraft:recipes/root", | ||
"criteria": { | ||
"has_fluix_block": { | ||
"conditions": { | ||
"items": [ | ||
{ | ||
"items": [ | ||
"ae2:fluix_block" | ||
] | ||
} | ||
] | ||
}, | ||
"trigger": "minecraft:inventory_changed" | ||
}, | ||
"has_the_recipe": { | ||
"conditions": { | ||
"recipe": "ae2:network/crystal_resonance_generator" | ||
}, | ||
"trigger": "minecraft:recipe_unlocked" | ||
} | ||
}, | ||
"requirements": [ | ||
[ | ||
"has_the_recipe", | ||
"has_fluix_block" | ||
] | ||
], | ||
"rewards": { | ||
"recipes": [ | ||
"ae2:network/crystal_resonance_generator" | ||
] | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/generated/resources/data/ae2/loot_tables/blocks/crystal_resonance_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,20 @@ | ||
{ | ||
"type": "minecraft:block", | ||
"pools": [ | ||
{ | ||
"bonus_rolls": 0.0, | ||
"conditions": [ | ||
{ | ||
"condition": "minecraft:survives_explosion" | ||
} | ||
], | ||
"entries": [ | ||
{ | ||
"type": "minecraft:item", | ||
"name": "ae2:crystal_resonance_generator" | ||
} | ||
], | ||
"rolls": 1.0 | ||
} | ||
] | ||
} |
26 changes: 26 additions & 0 deletions
26
src/generated/resources/data/ae2/recipes/network/crystal_resonance_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,26 @@ | ||
{ | ||
"type": "minecraft:crafting_shaped", | ||
"category": "misc", | ||
"key": { | ||
"c": { | ||
"tag": "forge:ingots/copper" | ||
}, | ||
"f": { | ||
"item": "ae2:fluix_block" | ||
}, | ||
"i": { | ||
"tag": "forge:ingots/iron" | ||
}, | ||
"q": { | ||
"item": "ae2:charged_certus_quartz_crystal" | ||
} | ||
}, | ||
"pattern": [ | ||
"cfc", | ||
"cqc", | ||
"iii" | ||
], | ||
"result": { | ||
"item": "ae2:crystal_resonance_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
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
44 changes: 44 additions & 0 deletions
44
src/main/java/appeng/api/networking/energy/IPassiveEnergyGenerator.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,44 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2013 AlgorithmX2 | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
* this software and associated documentation files (the "Software"), to deal in | ||
* the Software without restriction, including without limitation the rights to | ||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
* the Software, and to permit persons to whom the Software is furnished to do so, | ||
* subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
package appeng.api.networking.energy; | ||
|
||
import appeng.api.networking.IGridNodeService; | ||
|
||
/** | ||
* Passively provide power to the system. This happens at a constant rate, and is usually restricted to one generator | ||
* per energy grid (which reaches past the normal grid due to quartz fiber). | ||
*/ | ||
public interface IPassiveEnergyGenerator extends IGridNodeService { | ||
|
||
/** | ||
* AE per tick that is generated by this passive generator. | ||
*/ | ||
double getRate(); | ||
|
||
/** | ||
* Set to true to indicate this generator is supressed by another on the same energy grid. | ||
*/ | ||
void setSuppressed(boolean suppressed); | ||
|
||
} |
177 changes: 177 additions & 0 deletions
177
src/main/java/appeng/block/networking/CrystalResonanceGeneratorBlock.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,177 @@ | ||
/* | ||
* This file is part of Applied Energistics 2. | ||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. | ||
* | ||
* Applied Energistics 2 is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Applied Energistics 2 is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. | ||
*/ | ||
|
||
package appeng.block.networking; | ||
|
||
import java.util.Locale; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.util.StringRepresentable; | ||
import net.minecraft.world.item.context.BlockPlaceContext; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.LevelAccessor; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.SimpleWaterloggedBlock; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.block.state.StateDefinition.Builder; | ||
import net.minecraft.world.level.block.state.properties.BlockStateProperties; | ||
import net.minecraft.world.level.block.state.properties.BooleanProperty; | ||
import net.minecraft.world.level.material.FluidState; | ||
import net.minecraft.world.level.material.Fluids; | ||
import net.minecraft.world.phys.AABB; | ||
import net.minecraft.world.phys.shapes.CollisionContext; | ||
import net.minecraft.world.phys.shapes.Shapes; | ||
import net.minecraft.world.phys.shapes.VoxelShape; | ||
|
||
import appeng.api.orientation.IOrientationStrategy; | ||
import appeng.api.orientation.OrientationStrategies; | ||
import appeng.api.orientation.RelativeSide; | ||
import appeng.block.AEBaseEntityBlock; | ||
import appeng.blockentity.networking.CrystalResonanceGeneratorBlockEntity; | ||
|
||
public class CrystalResonanceGeneratorBlock extends AEBaseEntityBlock<CrystalResonanceGeneratorBlockEntity> | ||
implements SimpleWaterloggedBlock { | ||
|
||
public enum State implements StringRepresentable { | ||
OFF, ON, HAS_CHANNEL; | ||
|
||
@Override | ||
public String getSerializedName() { | ||
return this.name().toLowerCase(Locale.ROOT); | ||
} | ||
} | ||
|
||
private static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; | ||
|
||
public CrystalResonanceGeneratorBlock() { | ||
super(glassProps().noOcclusion().forceSolidOn()); | ||
this.registerDefaultState(this.defaultBlockState().setValue(WATERLOGGED, false)); | ||
} | ||
|
||
@Override | ||
protected void createBlockStateDefinition(Builder<Block, BlockState> builder) { | ||
super.createBlockStateDefinition(builder); | ||
builder.add(WATERLOGGED); | ||
} | ||
|
||
@Override | ||
public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { | ||
return getVoxelShape(state); | ||
} | ||
|
||
@Override | ||
public VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { | ||
return getVoxelShape(state); | ||
} | ||
|
||
@NotNull | ||
private VoxelShape getVoxelShape(BlockState state) { | ||
var orientation = getOrientation(state); | ||
var forward = orientation.getSide(RelativeSide.FRONT); | ||
|
||
double minX = 0; | ||
double minY = 0; | ||
double minZ = 0; | ||
double maxX = 1; | ||
double maxY = 1; | ||
double maxZ = 1; | ||
|
||
switch (forward) { | ||
case DOWN -> { | ||
minZ = minX = 3.0 / 16.0; | ||
maxZ = maxX = 13.0 / 16.0; | ||
maxY = 1.0; | ||
minY = 5.0 / 16.0; | ||
} | ||
case EAST -> { | ||
minZ = minY = 3.0 / 16.0; | ||
maxZ = maxY = 13.0 / 16.0; | ||
maxX = 11.0 / 16.0; | ||
minX = 0.0; | ||
} | ||
case NORTH -> { | ||
minY = minX = 3.0 / 16.0; | ||
maxY = maxX = 13.0 / 16.0; | ||
maxZ = 1.0; | ||
minZ = 5.0 / 16.0; | ||
} | ||
case SOUTH -> { | ||
minY = minX = 3.0 / 16.0; | ||
maxY = maxX = 13.0 / 16.0; | ||
maxZ = 11.0 / 16.0; | ||
minZ = 0.0; | ||
} | ||
case UP -> { | ||
minZ = minX = 3.0 / 16.0; | ||
maxZ = maxX = 13.0 / 16.0; | ||
maxY = 11.0 / 16.0; | ||
minY = 0.0; | ||
} | ||
case WEST -> { | ||
minZ = minY = 3.0 / 16.0; | ||
maxZ = maxY = 13.0 / 16.0; | ||
maxX = 1.0; | ||
minX = 5.0 / 16.0; | ||
} | ||
default -> { | ||
} | ||
} | ||
|
||
return Shapes.create(new AABB(minX, minY, minZ, maxX, maxY, maxZ)); | ||
} | ||
|
||
@Override | ||
public boolean propagatesSkylightDown(BlockState state, BlockGetter reader, BlockPos pos) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public IOrientationStrategy getOrientationStrategy() { | ||
return OrientationStrategies.facing(); | ||
} | ||
|
||
@Override | ||
@Nullable | ||
public BlockState getStateForPlacement(BlockPlaceContext context) { | ||
var fluidState = context.getLevel().getFluidState(context.getClickedPos()); | ||
return super.getStateForPlacement(context) | ||
.setValue(WATERLOGGED, fluidState.getType() == Fluids.WATER); | ||
} | ||
|
||
@Override | ||
public FluidState getFluidState(BlockState blockState) { | ||
return blockState.getValue(WATERLOGGED).booleanValue() | ||
? Fluids.WATER.getSource(false) | ||
: super.getFluidState(blockState); | ||
} | ||
|
||
@Override | ||
public BlockState updateShape(BlockState blockState, Direction facing, BlockState facingState, LevelAccessor level, | ||
BlockPos currentPos, BlockPos facingPos) { | ||
if (blockState.getValue(WATERLOGGED).booleanValue()) { | ||
level.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(level)); | ||
} | ||
|
||
return super.updateShape(blockState, facing, facingState, level, currentPos, facingPos); | ||
} | ||
|
||
} |
Oops, something went wrong.