Skip to content

Commit 6ea640c

Browse files
committed
Merge remote-tracking branch 'upstream/dev' into dev
2 parents 3453aa1 + 177d3c5 commit 6ea640c

24 files changed

Lines changed: 691 additions & 107 deletions

.github/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div align="center">
44
<h1>TerraFirmaGreg-Core - Modern</h1>
55
<a href="https://github.com/TerraFirmaGreg-Team/Core-Modern">
6-
<img src="https://github.com/TerraFirmaGreg-Team/.github/blob/main/branding/icon/v3/1080x_1080p_still_ring.gif?raw=true" alt="Logo" height="120"/>
6+
<img src="https://github.com/TerraFirmaGreg-Team/.github/blob/main/branding/icon/v3/tfg_logo_icon_core_964x_1080p.gif?raw=true" alt="Logo" height="120"/>
77
</a>
88
<br/>
99
<a href="https://discord.terrafirmagreg.su">

src/main/java/su/terrafirmagreg/core/common/data/TFGTags.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public static final class Blocks {
3838
public static final TagKey<Block> Logs = createBlockTag("minecraft:logs");
3939
public static final TagKey<Block> HarvesterHarvestable = createBlockTag("tfg:harvester_harvestable");
4040
public static final TagKey<Block> DoNotDestroyInSpace = createBlockTag("tfg:do_not_destroy_in_space");
41+
public static final TagKey<Block> HeightmapIgnore = createBlockTag("tfg:heightmap_ignore");
4142

4243
public static TagKey<Block> createBlockTag(String path) {
4344
return TagKey.create(ForgeRegistries.BLOCKS.getRegistryKey(), ResourceLocation.parse(path));

src/main/java/su/terrafirmagreg/core/common/data/blocks/DecorativePlantBlock.java

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import net.dries007.tfc.common.blocks.ExtendedBlock;
44
import net.dries007.tfc.common.blocks.ExtendedProperties;
5+
import net.dries007.tfc.common.fluids.FluidProperty;
6+
import net.dries007.tfc.common.fluids.IFluidLoggable;
57
import net.minecraft.core.BlockPos;
68
import net.minecraft.core.Direction;
79
import net.minecraft.world.item.Item;
@@ -13,45 +15,65 @@
1315
import net.minecraft.world.level.block.state.BlockState;
1416
import net.minecraft.world.level.block.state.StateDefinition;
1517
import net.minecraft.world.level.block.state.properties.DirectionProperty;
18+
import net.minecraft.world.level.material.FluidState;
1619
import net.minecraft.world.level.material.Fluids;
1720
import net.minecraft.world.phys.shapes.CollisionContext;
1821
import net.minecraft.world.phys.shapes.VoxelShape;
1922
import org.jetbrains.annotations.Nullable;
23+
import su.terrafirmagreg.core.compat.kjs.TFGBlockProperties;
2024

2125
import java.util.function.Supplier;
2226

23-
public class DecorativePlantBlock extends ExtendedBlock {
27+
public class DecorativePlantBlock extends ExtendedBlock implements IFluidLoggable {
2428

2529
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
30+
public static final FluidProperty FLUID = TFGBlockProperties.SPACE_WATER;
2631
public static final VoxelShape DEFAULT_SHAPE = Block.box(3.0F, 0.0F, 3.0F, 13.0F, 7.0F, 13.0F);
2732

2833
private final VoxelShape shape;
29-
private final @Nullable Supplier<? extends Item> pickBlock;
3034

3135

32-
public DecorativePlantBlock(ExtendedProperties properties, VoxelShape shape, @Nullable Supplier<? extends Item> pickBlock) {
36+
public DecorativePlantBlock(ExtendedProperties properties, VoxelShape shape) {
3337
super(properties);
34-
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH));
3538
this.shape = shape;
36-
this.pickBlock = pickBlock;
39+
40+
this.registerDefaultState(this.stateDefinition.any()
41+
.setValue(FACING, Direction.NORTH)
42+
.setValue(getFluidProperty(), getFluidProperty().keyFor(Fluids.EMPTY)));
3743

3844
getExtendedProperties().offsetType(OffsetType.XZ);
3945
}
4046

4147
@Override
42-
public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext)
43-
{
48+
public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) {
4449
return shape;
4550
}
4651

4752
@Override
4853
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
54+
super.createBlockStateDefinition(builder);
4955
builder.add(FACING);
56+
builder.add(getFluidProperty());
5057
}
5158

5259
@Override
5360
public BlockState getStateForPlacement(BlockPlaceContext context) {
54-
return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite());
61+
BlockPos pos = context.getClickedPos();
62+
FluidState fluidState = context.getLevel().getFluidState(pos);
63+
64+
BlockState state = this.defaultBlockState();
65+
if (getFluidProperty().canContain(fluidState.getType()))
66+
{
67+
state = state.setValue(getFluidProperty(), getFluidProperty().keyForOrEmpty(fluidState.getType()));
68+
}
69+
70+
state = state.setValue(FACING, context.getHorizontalDirection().getOpposite());
71+
return state;
72+
}
73+
74+
@Override
75+
public FluidProperty getFluidProperty() {
76+
return FLUID;
5577
}
5678

5779
@Override
@@ -81,4 +103,11 @@ public void neighborChanged(BlockState state, Level level, BlockPos pos, Block n
81103
Block.updateOrDestroy(state, Blocks.AIR.defaultBlockState(), level, pos, Block.UPDATE_ALL);
82104
}
83105
}
106+
107+
@Override
108+
@SuppressWarnings("deprecation")
109+
public FluidState getFluidState(BlockState state)
110+
{
111+
return IFluidLoggable.super.getFluidLoggedState(state);
112+
}
84113
}

src/main/java/su/terrafirmagreg/core/common/data/blocks/DoubleDecorativePlantBlock.java

Lines changed: 0 additions & 59 deletions
This file was deleted.
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
package su.terrafirmagreg.core.common.data.blocks;
2+
3+
import net.dries007.tfc.common.blocks.ExtendedBlock;
4+
import net.dries007.tfc.common.blocks.ExtendedProperties;
5+
import net.dries007.tfc.common.fluids.FluidProperty;
6+
import net.dries007.tfc.common.fluids.IFluidLoggable;
7+
import net.minecraft.core.BlockPos;
8+
import net.minecraft.core.Direction;
9+
import net.minecraft.world.entity.player.Player;
10+
import net.minecraft.world.item.context.BlockPlaceContext;
11+
import net.minecraft.world.level.BlockGetter;
12+
import net.minecraft.world.level.Level;
13+
import net.minecraft.world.level.LevelReader;
14+
import net.minecraft.world.level.block.Block;
15+
import net.minecraft.world.level.block.Blocks;
16+
import net.minecraft.world.level.block.state.BlockState;
17+
import net.minecraft.world.level.block.state.StateDefinition;
18+
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
19+
import net.minecraft.world.level.block.state.properties.IntegerProperty;
20+
import net.minecraft.world.level.material.FluidState;
21+
import net.minecraft.world.level.material.Fluids;
22+
import net.minecraft.world.phys.shapes.CollisionContext;
23+
import net.minecraft.world.phys.shapes.VoxelShape;
24+
import su.terrafirmagreg.core.compat.kjs.TFGBlockProperties;
25+
26+
public class TallDecorativePlantBlock extends ExtendedBlock implements IFluidLoggable {
27+
28+
public static final FluidProperty FLUID = TFGBlockProperties.SPACE_WATER;
29+
public static final VoxelShape DEFAULT_SHAPE = Block.box(2.0F, 0.0F, 2.0F, 14.0F, 16.0F, 14.0F);
30+
public static final IntegerProperty HEIGHT = TFGBlockProperties.HEIGHT;
31+
private final VoxelShape shape;
32+
private final int maxHeight;
33+
34+
public TallDecorativePlantBlock(ExtendedProperties properties, VoxelShape shape, int maxHeight) {
35+
super(properties);
36+
this.shape = shape;
37+
this.maxHeight = maxHeight;
38+
39+
this.registerDefaultState(this.stateDefinition.any()
40+
.setValue(TFGBlockProperties.HEIGHT, 0)
41+
.setValue(getFluidProperty(), getFluidProperty().keyFor(Fluids.EMPTY)));
42+
43+
getExtendedProperties().offsetType(OffsetType.XZ);
44+
}
45+
46+
@Override
47+
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
48+
super.createBlockStateDefinition(builder);
49+
builder.add(TFGBlockProperties.HEIGHT);
50+
builder.add(getFluidProperty());
51+
}
52+
53+
@Override
54+
public BlockState getStateForPlacement(BlockPlaceContext context) {
55+
BlockPos pos = context.getClickedPos();
56+
FluidState fluidState = context.getLevel().getFluidState(pos);
57+
58+
BlockState state = super.getStateForPlacement(context);
59+
if (getFluidProperty().canContain(fluidState.getType()))
60+
{
61+
state = state.setValue(getFluidProperty(), getFluidProperty().keyForOrEmpty(fluidState.getType()));
62+
}
63+
return state;
64+
}
65+
66+
@Override
67+
public FluidProperty getFluidProperty() {
68+
return FLUID;
69+
}
70+
71+
@Override
72+
public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
73+
return shape != null ? shape : super.getShape(state, level, pos, context);
74+
}
75+
76+
@Override
77+
public boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) {
78+
int h = state.getValue(TFGBlockProperties.HEIGHT);
79+
80+
if (h == 0) {
81+
BlockPos below = pos.below();
82+
BlockState belowState = level.getBlockState(below);
83+
return belowState.isFaceSturdy(level, below, Direction.UP);
84+
} else {
85+
BlockState belowState = level.getBlockState(pos.below());
86+
return belowState.is(this) && belowState.getValue(TFGBlockProperties.HEIGHT) - 1 == h;
87+
}
88+
}
89+
90+
@Override
91+
public void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving) {
92+
if (state.getValue(TFGBlockProperties.HEIGHT) != 0) {
93+
return;
94+
}
95+
96+
BlockPos test = pos.above();
97+
for (int i = 0; i < maxHeight; i++) {
98+
if (!level.getBlockState(test).canBeReplaced()) {
99+
return;
100+
}
101+
test = test.above();
102+
}
103+
104+
test = pos.above();
105+
for (int i = 1; i < maxHeight; i++) {
106+
level.setBlock(test, this.defaultBlockState().setValue(TFGBlockProperties.HEIGHT, i), 3);
107+
test = test.above();
108+
}
109+
}
110+
111+
@Override
112+
public boolean onDestroyedByPlayer(BlockState state, Level level, BlockPos pos, Player player, boolean willHarvest, FluidState fluid) {
113+
playerWillDestroy(level, pos, state, player);
114+
115+
BlockPos toDestroyPos = pos.below();
116+
BlockState nextState = level.getBlockState(toDestroyPos);
117+
118+
while (nextState.is(this)) {
119+
level.destroyBlock(toDestroyPos, false, player);
120+
toDestroyPos = toDestroyPos.below();
121+
nextState = level.getBlockState(toDestroyPos);
122+
}
123+
124+
toDestroyPos = pos.above();
125+
nextState = level.getBlockState(toDestroyPos);
126+
127+
while (nextState.is(this)) {
128+
level.destroyBlock(toDestroyPos, false, player);
129+
toDestroyPos = toDestroyPos.above();
130+
nextState = level.getBlockState(toDestroyPos);
131+
}
132+
133+
return level.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState());
134+
}
135+
136+
@Override
137+
@SuppressWarnings("deprecation")
138+
public FluidState getFluidState(BlockState state) {
139+
return IFluidLoggable.super.getFluidLoggedState(state);
140+
}
141+
}

src/main/java/su/terrafirmagreg/core/common/data/tfgt/TFGRecipeTypes.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.lowdragmc.lowdraglib.gui.texture.ProgressTexture;
1212
import com.lowdragmc.lowdraglib.gui.texture.ProgressTexture.FillDirection;
1313

14+
import com.lowdragmc.lowdraglib.gui.texture.ResourceTexture;
1415
import com.lowdragmc.lowdraglib.gui.widget.LabelWidget;
1516
import net.minecraft.core.registries.BuiltInRegistries;
1617
import net.minecraft.network.chat.Component;
@@ -30,6 +31,15 @@ public static void init() { }
3031
.setProgressBar(GuiTextures.PROGRESS_BAR_ARROW, FillDirection.LEFT_TO_RIGHT)
3132
.setSound(GTSoundEntries.BATH);
3233

34+
public static final ResourceTexture PROGRESS_BAR_DNA = new ResourceTexture(
35+
"tfg:textures/gui/progress_bar/progress_bar_dna.png"); //I might move this later if we end up making/using more custom progress bars.
36+
public static final GTRecipeType BIOREACTOR_RECIPES =
37+
GTRecipeTypes.register("bioreactor", GTRecipeTypes.MULTIBLOCK)
38+
.setEUIO(IO.IN)
39+
.setMaxIOSize(6, 6, 3, 3)
40+
.setProgressBar(PROGRESS_BAR_DNA, FillDirection.LEFT_TO_RIGHT)
41+
.setSound(GTSoundEntries.BATH);
42+
3343
public static final GTRecipeType FOOD_OVEN_RECIPES =
3444
GTRecipeTypes.register("food_oven", GTRecipeTypes.ELECTRIC)
3545
.setEUIO(IO.IN)

src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/TFGMachines.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import su.terrafirmagreg.core.common.data.tfgt.machine.multiblock.part.RailgunAmmoLoaderMachine;
2020
import su.terrafirmagreg.core.common.data.tfgt.machine.multiblock.part.RailgunItemBusMachine;
2121

22+
import java.util.Locale;
2223
import java.util.function.BiFunction;
2324

2425
import static com.gregtechceu.gtceu.common.data.models.GTMachineModels.OVERLAY_ITEM_HATCH;
@@ -155,7 +156,7 @@ public static MachineDefinition[] registerTieredMachines(String name,
155156
MachineDefinition[] definitions = new MachineDefinition[tiers.length];
156157
for (int i = 0; i < tiers.length; i++) {
157158
int tier = tiers[i];
158-
var register = REGISTRATE.machine(GTValues.VN[tier].toLowerCase() + "_" + name,
159+
var register = REGISTRATE.machine(GTValues.VN[tier].toLowerCase(Locale.ROOT) + "_" + name,
159160
holder -> factory.apply(holder, tier)).tier(tier);
160161
definitions[i] = builder.apply(tier, register);
161162
}

0 commit comments

Comments
 (0)