Skip to content

Commit acdf98b

Browse files
committed
Fix breakable tunnels, update Tunnel Wall en_us lang
1 parent 9f985dc commit acdf98b

File tree

4 files changed

+47
-57
lines changed

4 files changed

+47
-57
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.robotgryphon.compactmachines.block.walls;
2+
3+
import net.minecraft.block.Block;
4+
import net.minecraft.block.BlockState;
5+
import net.minecraft.entity.Entity;
6+
import net.minecraft.entity.player.PlayerEntity;
7+
import net.minecraft.util.math.BlockPos;
8+
import net.minecraft.world.Explosion;
9+
import net.minecraft.world.IBlockReader;
10+
import net.minecraft.world.IWorldReader;
11+
import net.minecraft.world.World;
12+
13+
public abstract class ProtectedWallBlock extends Block {
14+
protected ProtectedWallBlock(Properties properties) {
15+
super(properties);
16+
}
17+
18+
@Override
19+
public void onBlockExploded(BlockState state, World world, BlockPos pos, Explosion explosion) {
20+
// NO-Op, do not destroy on explosions
21+
}
22+
23+
@Override
24+
public boolean canHarvestBlock(BlockState state, IBlockReader world, BlockPos pos, PlayerEntity player) {
25+
return false;
26+
}
27+
28+
@Override
29+
public boolean canEntityDestroy(BlockState state, IBlockReader world, BlockPos pos, Entity entity) {
30+
return false;
31+
}
32+
33+
@Override
34+
public boolean canBeReplacedByLeaves(BlockState state, IWorldReader world, BlockPos pos) {
35+
return false;
36+
}
37+
38+
@Override
39+
public boolean canDropFromExplosion(BlockState state, IBlockReader world, BlockPos pos, Explosion explosion) {
40+
return false;
41+
}
42+
}
Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,21 @@
11
package com.robotgryphon.compactmachines.block.walls;
22

3-
import com.robotgryphon.compactmachines.core.Registration;
4-
import net.minecraft.block.Block;
3+
import com.robotgryphon.compactmachines.config.ServerConfig;
54
import net.minecraft.block.BlockState;
6-
import net.minecraft.entity.Entity;
75
import net.minecraft.entity.EntitySpawnPlacementRegistry;
86
import net.minecraft.entity.EntityType;
9-
import net.minecraft.entity.player.PlayerEntity;
10-
import net.minecraft.entity.player.ServerPlayerEntity;
11-
import net.minecraft.fluid.FluidState;
12-
import net.minecraft.item.ItemStack;
13-
import net.minecraft.util.ActionResultType;
14-
import net.minecraft.util.Hand;
157
import net.minecraft.util.math.BlockPos;
16-
import net.minecraft.util.math.BlockRayTraceResult;
17-
import net.minecraft.world.Explosion;
188
import net.minecraft.world.IBlockReader;
19-
import net.minecraft.world.IWorldReader;
20-
import net.minecraft.world.World;
219

2210
import javax.annotation.Nullable;
2311

24-
public class SolidWallBlock extends Block {
12+
public class SolidWallBlock extends ProtectedWallBlock {
2513
public SolidWallBlock(Properties props) {
2614
super(props);
2715
}
2816

29-
@Override
30-
public void onBlockExploded(BlockState state, World world, BlockPos pos, Explosion explosion) {
31-
// NO-Op, do not destroy on explosions
32-
}
33-
34-
@Override
35-
public boolean canHarvestBlock(BlockState state, IBlockReader world, BlockPos pos, PlayerEntity player) {
36-
return false;
37-
}
38-
39-
@Override
40-
public boolean canEntityDestroy(BlockState state, IBlockReader world, BlockPos pos, Entity entity) {
41-
return false;
42-
}
43-
44-
@Override
45-
public boolean canBeReplacedByLeaves(BlockState state, IWorldReader world, BlockPos pos) {
46-
return false;
47-
}
48-
49-
@Override
50-
public boolean canDropFromExplosion(BlockState state, IBlockReader world, BlockPos pos, Explosion explosion) {
51-
return false;
52-
}
53-
5417
@Override
5518
public boolean canCreatureSpawn(BlockState state, IBlockReader world, BlockPos pos, EntitySpawnPlacementRegistry.PlacementType type, @Nullable EntityType<?> entityType) {
56-
return pos.getY() == 40;
57-
}
58-
59-
@Override
60-
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
61-
ItemStack held = player.getHeldItemMainhand();
62-
63-
if (held.isEmpty())
64-
return ActionResultType.PASS;
65-
66-
if (player.isSneaking())
67-
return ActionResultType.PASS;
68-
69-
// TODO: Tunnels and Personal Shrinking Device
70-
71-
return super.onBlockActivated(state, worldIn, pos, player, handIn, hit);
19+
return pos.getY() == ServerConfig.MACHINE_FLOOR_Y.get();
7220
}
7321
}

src/main/java/com/robotgryphon/compactmachines/block/walls/TunnelWallBlock.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import javax.annotation.Nullable;
3131
import java.util.Optional;
3232

33-
public class TunnelWallBlock extends Block implements IProbeDataProvider {
33+
public class TunnelWallBlock extends ProtectedWallBlock implements IProbeDataProvider {
3434
public static DirectionProperty TUNNEL_SIDE = DirectionProperty.create("tunnel_side", Direction.values());
3535
public static DirectionProperty CONNECTED_SIDE = DirectionProperty.create("connected_side", Direction.values());
3636

src/main/resources/assets/compactmachines/lang/en_us.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
"block.compactmachines.solid_wall": "Solid Compact Machine Wall",
2626
"block.compactmachines.wall": "Compact Machine Wall",
27-
"block.compactmachines.tunnel_wall": "Tunnel",
27+
"block.compactmachines.tunnel_wall": "Solid Compact Machine Wall (with Tunnel)",
2828

2929
"item.compactmachines.machine_tiny": "Compact Machine (Tiny)",
3030
"item.compactmachines.machine_small": "Compact Machine (Small)",

0 commit comments

Comments
 (0)