Skip to content

Commit 1104833

Browse files
author
pidoras
committed
Teleporter working now. added 2 raw block entities (Crusher, Pounder).
reworked recipe system in MachineFrameBlockEntity. Added russian lang and finished english land. deleted old portal. and some changes in beta generator
1 parent f796b67 commit 1104833

45 files changed

Lines changed: 1839 additions & 196 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.gradle

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ dependencies {
4343

4444
include modApi('teamreborn:energy:3.0.0')
4545

46-
modImplementation 'net.kyrptonaught:customportalapi:0.0.1-beta64-1.20.2'
47-
include 'net.kyrptonaught:customportalapi:0.0.1-beta64-1.20.2'
48-
4946
modImplementation include("eu.pb4:polymer-core:0.7.10+1.20.4")
5047
modImplementation include("eu.pb4:polymer-blocks:0.7.10+1.20.4")
5148
modImplementation include("eu.pb4:polymer-resource-pack:0.7.10+1.20.4")

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Done to increase the memory available to gradle.
2-
org.gradle.jvmargs=-Xmx6G
2+
org.gradle.jvmargs=-Xmx4G
33
org.gradle.parallel=true
44

55
# Fabric Properties

src/main/java/net/infugogr/barracuda/Barracuda.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import net.infugogr.barracuda.screenhandler.ModScreenHandlerType;
2323
import net.infugogr.barracuda.sound.ModSounds;
2424
import net.infugogr.barracuda.util.ModTags;
25-
import net.kyrptonaught.customportalapi.api.CustomPortalBuilder;
2625
import net.minecraft.particle.ParticleTypes;
2726
import net.minecraft.text.Text;
2827
import net.minecraft.util.Identifier;
@@ -61,6 +60,9 @@ public void onInitialize() {
6160
EnergyStorage.SIDED.registerForBlockEntity(FuelGeneratorBlockEntity::getEnergyProvider, ModBlockEntityType.FUEL_GENERATOR);
6261
ItemStorage.SIDED.registerForBlockEntity(FuelGeneratorBlockEntity::getInventoryProvider, ModBlockEntityType.FUEL_GENERATOR);
6362

63+
EnergyStorage.SIDED.registerForBlockEntity(CrusherBlockEntity::getEnergyProvider, ModBlockEntityType.CRUSHER);
64+
ItemStorage.SIDED.registerForBlockEntity(CrusherBlockEntity::getInventoryProvider, ModBlockEntityType.CRUSHER);
65+
6466
ItemStorage.SIDED.registerForBlockEntity(FishingNetBlockEntity::getInventoryProvider, ModBlockEntityType.FISHING_NET);
6567

6668
EnergyStorage.SIDED.registerForBlockEntity(SMESblockEntity::getEnergyProvider, ModBlockEntityType.SMES);
@@ -83,13 +85,6 @@ public void onInitialize() {
8385
FabricDefaultAttributeRegistry.register(ModEntities.BARRACUDA, BarracudaEntity.setAttributes());
8486
FabricDefaultAttributeRegistry.register(ModEntities.AZUER_REAPER, BarracudaEntity.setAttributes());
8587

86-
CustomPortalBuilder.beginPortal()
87-
.frameBlock(ModBlocks.CHARGED_REDSTONEIUM_BLOCK)
88-
.lightWithItem(ModItems.CAPACITOR)
89-
.destDimID(Barracuda.id("beta92"))
90-
.tintColor(0xc76efa)
91-
.registerPortal();
92-
9388
// Fluid Properties
9489
var commonFluidAttributes = new FluidVariantAttributeHandler() {
9590
@Override

src/main/java/net/infugogr/barracuda/BarracudaClient.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
55
import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry;
66
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
7+
import net.infugogr.barracuda.block.ModBlocks;
8+
import net.infugogr.barracuda.block.entity.ModBlockEntityType;
9+
import net.infugogr.barracuda.block.entity.client.TeleporterBlockRenderer;
710
import net.infugogr.barracuda.entity.ModEntities;
811
import net.infugogr.barracuda.entity.client.*;
912
import net.infugogr.barracuda.fluid.ModFluids;
1013
import net.infugogr.barracuda.fluid.RenderFluidHandler;
1114
import net.infugogr.barracuda.screenhandler.*;
1215
import net.minecraft.client.gui.screen.ingame.HandledScreens;
1316
import net.minecraft.client.render.RenderLayer;
17+
import net.minecraft.client.render.block.entity.BlockEntityRendererFactories;
1418
import net.minecraft.util.Identifier;
1519

1620
public class BarracudaClient implements ClientModInitializer {
@@ -23,6 +27,11 @@ public void onInitializeClient() {
2327
HandledScreens.register(ModScreenHandlerType.SMES, SMESScreen::new);
2428
HandledScreens.register(ModScreenHandlerType.FISHING_NET, FishingNetScreen::new);
2529
HandledScreens.register(ModScreenHandlerType.OIL_REFINERY, OilRefineryScreen::new);
30+
HandledScreens.register(ModScreenHandlerType.CRUSHER, CrusherScreen::new);
31+
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.POUNDER, RenderLayer.getCutout());
32+
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.FISHING_NET, RenderLayer.getCutout());
33+
34+
BlockEntityRendererFactories.register(ModBlockEntityType.TELEPORTER, TeleporterBlockRenderer::new);
2635

2736
EntityRendererRegistry.register(ModEntities.GIANT, GiantRenderer::new);
2837
EntityModelLayerRegistry.registerModelLayer(ModModelLayers.GIANT, GiantModel::getTexturedModelData);
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package net.infugogr.barracuda.block;
2+
3+
import com.mojang.serialization.MapCodec;
4+
import net.infugogr.barracuda.block.entity.CrusherBlockEntity;
5+
import net.infugogr.barracuda.block.entity.ModBlockEntityType;
6+
import net.infugogr.barracuda.util.TickableBlockEntity;
7+
import net.minecraft.block.*;
8+
import net.minecraft.block.entity.BlockEntity;
9+
import net.minecraft.block.entity.BlockEntityTicker;
10+
import net.minecraft.block.entity.BlockEntityType;
11+
import net.minecraft.entity.player.PlayerEntity;
12+
import net.minecraft.item.ItemPlacementContext;
13+
import net.minecraft.screen.NamedScreenHandlerFactory;
14+
import net.minecraft.state.StateManager;
15+
import net.minecraft.state.property.DirectionProperty;
16+
import net.minecraft.state.property.Properties;
17+
import net.minecraft.util.ActionResult;
18+
import net.minecraft.util.Hand;
19+
import net.minecraft.util.hit.BlockHitResult;
20+
import net.minecraft.util.math.BlockPos;
21+
import net.minecraft.util.math.Direction;
22+
import net.minecraft.world.World;
23+
import org.jetbrains.annotations.Nullable;
24+
25+
public class CrusherBlock extends BlockWithEntity implements BlockEntityProvider{
26+
private static final MapCodec<CrusherBlock> CODEC = createCodec(CrusherBlock::new);
27+
public static final DirectionProperty FACING = Properties.HORIZONTAL_FACING;
28+
protected CrusherBlock(Settings settings) {
29+
super(settings);
30+
setDefaultState(getDefaultState().with(FACING, Direction.NORTH));
31+
}
32+
33+
@Override
34+
protected MapCodec<? extends BlockWithEntity> getCodec() {
35+
return CODEC;
36+
}
37+
38+
@Override
39+
public BlockRenderType getRenderType(BlockState state) {
40+
return BlockRenderType.MODEL;
41+
}
42+
43+
@Override
44+
public @Nullable BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
45+
return ModBlockEntityType.CRUSHER.instantiate(pos, state);
46+
}
47+
48+
@Override
49+
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
50+
if (!world.isClient) {
51+
NamedScreenHandlerFactory screenHandlerFactory = ((CrusherBlockEntity) world.getBlockEntity(pos));
52+
53+
if (screenHandlerFactory != null) {
54+
player.openHandledScreen(screenHandlerFactory);
55+
}
56+
}
57+
58+
return ActionResult.SUCCESS;
59+
}
60+
61+
@Nullable
62+
@Override
63+
public BlockState getPlacementState(ItemPlacementContext ctx) {
64+
return getDefaultState().with(FACING, ctx.getHorizontalPlayerFacing().getOpposite());
65+
}
66+
67+
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
68+
builder.add(FACING);
69+
}
70+
71+
@Nullable
72+
@Override
73+
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
74+
return TickableBlockEntity.createTicker(world);
75+
}
76+
}

src/main/java/net/infugogr/barracuda/block/FishingNetBlock.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
import net.minecraft.state.property.Properties;
2929
import org.jetbrains.annotations.Nullable;
3030

31-
public class FishingNetBlock extends BlockWithEntity implements BlockEntityProvider {
32-
private static final MapCodec<FishingNetBlock> CODEC = createCodec(FishingNetBlock::new);
31+
public class FishingNetBlock extends TranslucentBlock implements BlockEntityProvider {
3332
public static final DirectionProperty FACING = Properties.HORIZONTAL_FACING;
3433
private static final VoxelShape SHAPE = Block.createCuboidShape(0, 0, 0, 16, 12, 16);
3534
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
@@ -49,11 +48,6 @@ public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos po
4948
return type == NavigationType.WATER;
5049
}
5150

52-
@Override
53-
protected MapCodec<? extends BlockWithEntity> getCodec() {
54-
return CODEC;
55-
}
56-
5751
@Override
5852
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
5953
return SHAPE;

src/main/java/net/infugogr/barracuda/block/ModBlocks.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ public class ModBlocks {
7878
new WallBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK)));
7979
public static final Block FISHING_NET = registerWithItemCopy("fishing_net",
8080
new FishingNetBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque()));
81+
public static final Block CRUSHER = registerWithItemCopy("crusher",
82+
new CrusherBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque()));
83+
public static final Block POUNDER = registerWithItemCopy("pounder",
84+
new PounderBlock(FabricBlockSettings.copyOf(Blocks.STONE).nonOpaque()));
8185

8286

8387
private static Block registerWithItemCopy(String name, Block block) {
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package net.infugogr.barracuda.block;
2+
3+
import com.mojang.serialization.MapCodec;
4+
import net.infugogr.barracuda.block.entity.ModBlockEntityType;
5+
import net.infugogr.barracuda.util.TickableBlockEntity;
6+
import net.minecraft.block.*;
7+
import net.minecraft.block.entity.BlockEntity;
8+
import net.minecraft.block.entity.BlockEntityTicker;
9+
import net.minecraft.block.entity.BlockEntityType;
10+
import net.minecraft.entity.player.PlayerEntity;
11+
import net.minecraft.item.ItemPlacementContext;
12+
import net.minecraft.state.StateManager;
13+
import net.minecraft.state.property.DirectionProperty;
14+
import net.minecraft.state.property.Properties;
15+
import net.minecraft.util.ActionResult;
16+
import net.minecraft.util.Hand;
17+
import net.minecraft.util.hit.BlockHitResult;
18+
import net.minecraft.util.math.BlockPos;
19+
import net.minecraft.util.math.Direction;
20+
import net.minecraft.util.shape.VoxelShape;
21+
import net.minecraft.util.shape.VoxelShapes;
22+
import net.minecraft.world.BlockView;
23+
import net.minecraft.world.World;
24+
import org.jetbrains.annotations.Nullable;
25+
26+
public class PounderBlock extends TranslucentBlock implements BlockEntityProvider {
27+
private static final MapCodec<PounderBlock> CODEC = createCodec(PounderBlock::new);
28+
public static final DirectionProperty FACING = Properties.HORIZONTAL_FACING;
29+
protected PounderBlock(Settings settings) {
30+
super(settings);
31+
setDefaultState(getDefaultState().with(FACING, Direction.NORTH));
32+
}
33+
34+
@Override
35+
protected MapCodec<PounderBlock> getCodec() {
36+
return CODEC;
37+
}
38+
39+
@Override
40+
public @Nullable BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
41+
return ModBlockEntityType.POUNDER.instantiate(pos, state);
42+
}
43+
44+
@Override
45+
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
46+
47+
return ActionResult.SUCCESS;
48+
}
49+
50+
51+
@Override
52+
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
53+
return VoxelShapes.cuboid(0.1875, 0, 0.1875, 0.8125, 0.375, 0.8125);
54+
}
55+
56+
@Nullable
57+
@Override
58+
public BlockState getPlacementState(ItemPlacementContext ctx) {
59+
return getDefaultState().with(FACING, ctx.getHorizontalPlayerFacing().getOpposite());
60+
}
61+
62+
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
63+
builder.add(FACING);
64+
}
65+
66+
}
Lines changed: 70 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,43 @@
11
package net.infugogr.barracuda.block;
22

33
import com.mojang.serialization.MapCodec;
4-
import net.infugogr.barracuda.Barracuda;
54
import net.infugogr.barracuda.block.entity.ModBlockEntityType;
65
import net.infugogr.barracuda.util.TickableBlockEntity;
6+
import net.infugogr.barracuda.world.dimension.ModDimensions;
77
import net.minecraft.block.*;
88
import net.minecraft.block.entity.BlockEntity;
99
import net.minecraft.block.entity.BlockEntityTicker;
1010
import net.minecraft.block.entity.BlockEntityType;
1111
import net.minecraft.entity.Entity;
12+
import net.minecraft.entity.LivingEntity;
1213
import net.minecraft.item.ItemPlacementContext;
14+
import net.minecraft.item.ItemStack;
15+
import net.minecraft.registry.RegistryKey;
16+
import net.minecraft.server.MinecraftServer;
17+
import net.minecraft.server.network.ServerPlayerEntity;
18+
import net.minecraft.server.world.ServerWorld;
1319
import net.minecraft.state.StateManager;
20+
import net.minecraft.state.property.DirectionProperty;
21+
import net.minecraft.state.property.Properties;
22+
import net.minecraft.util.BlockRotation;
1423
import net.minecraft.util.math.BlockPos;
1524
import net.minecraft.util.math.Direction;
25+
import net.minecraft.util.math.Vec3d;
26+
import net.minecraft.util.shape.VoxelShape;
27+
import net.minecraft.util.shape.VoxelShapes;
1628
import net.minecraft.world.*;
1729
import org.jetbrains.annotations.Nullable;
1830

1931
public class TeleporterBlock extends HorizontalFacingBlock implements BlockEntityProvider{
20-
private static final MapCodec<TeleporterBlock> CODEC = createCodec(TeleporterBlock::new);
32+
public static final MapCodec<TeleporterBlock> CODEC = createCodec(TeleporterBlock::new);
33+
public static final DirectionProperty FACING = Properties.HORIZONTAL_FACING;
2134
protected TeleporterBlock(Settings settings) {
2235
super(settings);
2336
setDefaultState(getDefaultState().with(FACING, Direction.NORTH));
2437
}
2538

2639
@Override
27-
protected MapCodec<? extends HorizontalFacingBlock> getCodec() {
40+
public MapCodec<TeleporterBlock> getCodec() {
2841
return CODEC;
2942
}
3043

@@ -33,11 +46,6 @@ protected MapCodec<? extends HorizontalFacingBlock> getCodec() {
3346
return ModBlockEntityType.TELEPORTER.instantiate(pos, state);
3447
}
3548

36-
@Override
37-
public void onEntityLand(BlockView world, Entity entity) {
38-
super.onEntityLand(world, entity);
39-
}
40-
4149
@Nullable
4250
@Override
4351
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
@@ -52,8 +60,61 @@ public BlockState getPlacementState(ItemPlacementContext ctx) {
5260

5361
@Override
5462
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
55-
super.appendProperties(builder);
5663
builder.add(FACING);
5764
}
5865

66+
67+
@Override
68+
public void onEntityLand(BlockView world1, Entity entity) {
69+
World world = entity.getWorld();
70+
if (!world.isClient && entity instanceof ServerPlayerEntity serverPlayer) {
71+
Vec3d currentPos = entity.getPos();
72+
BlockPos baseXZ = new BlockPos((int) currentPos.x, 0, (int) currentPos.z);
73+
RegistryKey<World> currentDim = world.getRegistryKey();
74+
ServerWorld targetWorld = null;
75+
76+
if (currentDim == World.OVERWORLD) {
77+
targetWorld = serverPlayer.getServer().getWorld(ModDimensions.BETA_LEVEL_KEY);
78+
} else if (currentDim == ModDimensions.BETA_LEVEL_KEY) {
79+
targetWorld = serverPlayer.getServer().getWorld(World.OVERWORLD);
80+
}
81+
82+
if (targetWorld != null) {
83+
BlockPos targetPos = findHighestSafePosition(targetWorld, baseXZ);
84+
if (targetPos != null) {
85+
serverPlayer.teleport(
86+
targetWorld,
87+
targetPos.getX() + 0.5,
88+
targetPos.getY(),
89+
targetPos.getZ() + 0.5,
90+
entity.getYaw(),
91+
entity.getPitch()
92+
);
93+
}
94+
}
95+
}
96+
}
97+
98+
private BlockPos findHighestSafePosition(ServerWorld world, BlockPos baseXZ) {
99+
int topY = world.getTopY();
100+
int bottomY = world.getBottomY();
101+
102+
for (int y = topY - 2; y > bottomY; y--) {
103+
BlockPos feet = new BlockPos(baseXZ.getX(), y, baseXZ.getZ());
104+
BlockPos head = feet.up();
105+
BlockPos ground = feet.down();
106+
107+
if (world.isAir(feet) && world.isAir(head) && !world.isAir(ground)) {
108+
return feet;
109+
}
110+
}
111+
112+
// Если не нашли безопасное место — fallback на world spawn
113+
return world.getSpawnPos();
114+
}
115+
116+
@Override
117+
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
118+
return VoxelShapes.cuboid(0, 0, 0, 1, 0.6875, 1);
119+
}
59120
}

0 commit comments

Comments
 (0)