Skip to content

Commit

Permalink
Re-implement ME Source Jar
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Oct 19, 2024
1 parent 46daa72 commit 71aecdd
Show file tree
Hide file tree
Showing 24 changed files with 294 additions and 342 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ class BlockStateModelProvider extends BlockStateProvider {
protected void registerStatesAndModels() {
simpleBlockWithItem(ArsEngBlocks.SOURCE_CONVERTER.block(), cubeAll(ArsEngBlocks.SOURCE_CONVERTER.block()));

/*
var sourceJarModel = models().getExistingFile(ArsEngBlocks.ME_SOURCE_JAR.id());
horizontalBlock(ArsEngBlocks.ME_SOURCE_JAR.block(), sourceJarModel);
simpleBlockItem(ArsEngBlocks.ME_SOURCE_JAR.block(), sourceJarModel);
*/

var sourceCell = "block/source_drive_cell";
models().getBuilder(sourceCell)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// 1.21.1 2024-10-14T21:07:58.035430925 vanilla/Block States: arseng
// 1.21.1 2024-10-18T00:10:31.298280066 vanilla/Block States: arseng
033c77e1eb6e243c4608298264f64d871e85d679 assets/arseng/blockstates/me_source_jar.json
94a8fae2322409c17c531d3989ceea1aa2f7191e assets/arseng/blockstates/source_acceptor.json
821c5fb18cca5d0d181e91a63fdb7877b196fb48 assets/arseng/models/block/source_acceptor.json
552de94536df33865cfe7006c7066ce274af9ec5 assets/arseng/models/block/source_drive_cell.json
b0f89e6ffd2035c66861fb5dd2124481919b1e24 assets/arseng/models/item/me_source_jar.json
05fc388fbf75b3ac43eca97e7c98a1fb04d4a802 assets/arseng/models/item/source_acceptor.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// 1.21.1 2024-10-14T21:07:58.034855988 vanilla/Loot Tables
// 1.21.1 2024-10-18T00:02:21.810695807 vanilla/Loot Tables
d6826098b19175f540ad57a343ec966d671ce92e data/arseng/loot_table/blocks/me_source_jar.json
2ec1d5c4ba32184edc99e1cb2ee9ac2c9d43944b data/arseng/loot_table/blocks/source_acceptor.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.21.1 2024-10-14T21:07:58.033953033 vanilla/Tags for minecraft:block mod id arseng
// 1.21.1 2024-10-18T00:02:21.810518688 vanilla/Tags for minecraft:block mod id arseng
064ea0fcc730133840f3764718cfa113df816c15 data/ars_nouveau/tags/block/golem/budding.json
c5a033d890f5a75b85002e83c39474334c51aded data/ars_nouveau/tags/block/golem/cluster.json
bdca504fe50f3b532d06d249b4708e3a578a676c data/minecraft/tags/block/mineable/pickaxe.json
4f5425cef36aa4ff2514a30f8d19972e44094181 data/minecraft/tags/block/mineable/pickaxe.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.21.1 2024-10-14T21:07:58.035096727 vanilla/Languages: en_us for mod: arseng
2c663dad738b6eed69ebf09da7fd3eaef394a8a5 assets/arseng/lang/en_us.json
// 1.21.1 2024-10-18T00:02:21.810868127 vanilla/Languages: en_us for mod: arseng
33caf0bea4e6e6fa8c1192f6a4202f576f4662ef assets/arseng/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"variants": {
"facing=east,waterlogged=false": {
"model": "arseng:block/me_source_jar",
"y": 90
},
"facing=east,waterlogged=true": {
"model": "arseng:block/me_source_jar",
"y": 90
},
"facing=north,waterlogged=false": {
"model": "arseng:block/me_source_jar"
},
"facing=north,waterlogged=true": {
"model": "arseng:block/me_source_jar"
},
"facing=south,waterlogged=false": {
"model": "arseng:block/me_source_jar",
"y": 180
},
"facing=south,waterlogged=true": {
"model": "arseng:block/me_source_jar",
"y": 180
},
"facing=west,waterlogged=false": {
"model": "arseng:block/me_source_jar",
"y": 270
},
"facing=west,waterlogged=true": {
"model": "arseng:block/me_source_jar",
"y": 270
}
}
}
1 change: 1 addition & 0 deletions src/generated/resources/assets/arseng/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"arseng.page.source_acceptor": "The ME Source Converter converts source into AE energy. Attach it to an ME network and feed it source with a relay in order to power the network itself simply using source.",
"arseng.page.source_acceptor_description": "The Source Converter comes in both block and cable part form.",
"arseng.page.source_cell_housing": "ME Source Cells can be crafted with an ME Source Cell Housing. They will store many jars' worth of source within an Applied Energistics 2 ME system.",
"block.arseng.me_source_jar": "ME Source Jar",
"block.arseng.source_acceptor": "ME Source Converter",
"item.arseng.cable_source_acceptor": "ME Source Acceptor",
"item.arseng.creative_source_cell": "Creative ME Source Cell",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "arseng:block/me_source_jar"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "arseng:me_source_jar"
}
],
"rolls": 1.0
}
],
"random_sequence": "arseng:blocks/me_source_jar"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"values": [
"arseng:me_source_jar",
"arseng:source_acceptor"
]
}
4 changes: 3 additions & 1 deletion src/main/java/gripe/_90/arseng/ArsEnergistique.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import appeng.api.storage.StorageCells;
import appeng.parts.automation.StackWorldBehaviors;

import gripe._90.arseng.block.entity.MESourceJarBlockEntity;
import gripe._90.arseng.block.entity.SourceConverterBlockEntity;
import gripe._90.arseng.definition.ArsEngBlockEntities;
import gripe._90.arseng.definition.ArsEngBlocks;
Expand Down Expand Up @@ -59,9 +60,10 @@ public ArsEnergistique(ModContainer container, IEventBus modEventBus) {
StackWorldBehaviors.registerExternalStorageStrategy(SourceKeyType.TYPE, SourceExternalStorageStrategy::new);

ContainerItemStrategies.register(SourceKeyType.TYPE, SourceKey.class, SourceContainerItemStrategy.INSTANCE);
GenericSlotCapacities.register(SourceKeyType.TYPE, (long) SourceKeyType.MAX_SOURCE);
GenericSlotCapacities.register(SourceKeyType.TYPE, (long) SourceKey.MAX_SOURCE);

modEventBus.addListener(GenericStackSourceStorage::registerCapability);
modEventBus.addListener(MESourceJarBlockEntity::registerCapability);
modEventBus.addListener(SourceConverterBlockEntity::registerCapability);
modEventBus.addListener(SourceConverterPart::registerCapability);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
Expand All @@ -31,24 +27,22 @@
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;

import appeng.api.orientation.IOrientableBlock;
import appeng.api.orientation.IOrientationStrategy;
import appeng.api.orientation.OrientationStrategies;
import appeng.block.AEBaseEntityBlock;
import appeng.hooks.WrenchHook;

import gripe._90.arseng.block.entity.MESourceJarBlockEntity;
import gripe._90.arseng.me.key.SourceKey;

@ParametersAreNonnullByDefault
public class MESourceJarBlock extends Block implements EntityBlock, SimpleWaterloggedBlock, IOrientableBlock {
public class MESourceJarBlock extends AEBaseEntityBlock<MESourceJarBlockEntity> implements SimpleWaterloggedBlock {
private static final VoxelShape SHAPE = Stream.of(
Block.box(4, 13, 4, 12, 14, 12),
Block.box(0, 0, 0, 16, 1, 16),
Block.box(2, 1, 2, 14, 2, 14),
Block.box(3, 2, 3, 13, 13, 13),
Block.box(3, 14, 3, 13, 16, 13),
Block.box(6, 1, 14, 10, 16, 16),
Block.box(6, 14, 13, 10, 16, 16),
Block.box(5, 5, 13, 11, 11, 16))
Block.box(3, 14, 3, 13, 16, 13))
.reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR))
.get();

Expand All @@ -61,28 +55,16 @@ public MESourceJarBlock() {
registerDefaultState(defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, false));
}

@Override
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return new MESourceJarBlockEntity(pos, state);
}

@Override
public void setPlacedBy(
Level level, BlockPos pos, BlockState state, @Nullable LivingEntity entity, ItemStack stack) {
if (entity instanceof Player player && level.getBlockEntity(pos) instanceof MESourceJarBlockEntity jar) {
jar.getMainNode().setOwningPlayer(player);
}
}

@Override
public boolean hasAnalogOutputSignal(BlockState pState) {
return true;
}

@Override
public int getAnalogOutputSignal(BlockState state, Level level, BlockPos pos) {
var jar = (MESourceJarBlockEntity) level.getBlockEntity(pos);
return jar != null ? jar.calculateComparatorLevel() : 0;
return level.getBlockEntity(pos) instanceof MESourceJarBlockEntity jar
? (int) Math.floor((double) jar.clampedFill() / SourceKey.MAX_SOURCE * 15)
: 0;
}

@NotNull
Expand All @@ -93,27 +75,23 @@ public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, Co

@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
super.createBlockStateDefinition(builder);
builder.add(BlockStateProperties.WATERLOGGED);
builder.add(BlockStateProperties.HORIZONTAL_FACING);
}

@NotNull
@Override
public FluidState getFluidState(BlockState state) {
return state.getValue(BlockStateProperties.WATERLOGGED)
? Fluids.WATER.getSource(false)
: Fluids.EMPTY.defaultFluidState();
: super.getFluidState(state);
}

@Nullable
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
var fluidState = context.getLevel().getFluidState(context.getClickedPos());
return defaultBlockState()
.setValue(BlockStateProperties.WATERLOGGED, fluidState.getType() == Fluids.WATER)
.setValue(
BlockStateProperties.HORIZONTAL_FACING,
context.getHorizontalDirection().getOpposite());
return defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, fluidState.getType() == Fluids.WATER);
}

@NotNull
Expand Down
Loading

0 comments on commit 71aecdd

Please sign in to comment.