mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-22 03:43:30 +01:00
it compiles!!
This commit is contained in:
parent
1ba1257569
commit
4914c5f3c0
5 changed files with 52 additions and 15 deletions
|
@ -62,7 +62,9 @@ import net.minecraft.world.item.CreativeModeTab;
|
|||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour.Properties;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
|
@ -114,10 +116,10 @@ public final class Registry {
|
|||
@SubscribeEvent
|
||||
public static void register(RegisterEvent event) {
|
||||
event.register(Registries.BLOCK, h -> {
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "pipe"), Registry.pipeBlock = new PipeBlock());
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "item_terminal"), Registry.itemTerminalBlock = new ItemTerminalBlock());
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "crafting_terminal"), Registry.craftingTerminalBlock = new CraftingTerminalBlock());
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "pressurizer"), Registry.pressurizerBlock = new PressurizerBlock());
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "pipe"), Registry.pipeBlock = new PipeBlock(Properties.of().strength(2).sound(SoundType.STONE).noOcclusion()));
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "item_terminal"), Registry.itemTerminalBlock = new ItemTerminalBlock(Properties.of().strength(3).sound(SoundType.STONE)));
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "crafting_terminal"), Registry.craftingTerminalBlock = new CraftingTerminalBlock(Properties.of().strength(3).sound(SoundType.STONE)));
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "pressurizer"), Registry.pressurizerBlock = new PressurizerBlock(Properties.of().strength(3).sound(SoundType.STONE)));
|
||||
});
|
||||
|
||||
event.register(Registries.ITEM, h -> {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package de.ellpeck.prettypipes.pipe;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import de.ellpeck.prettypipes.Registry;
|
||||
import de.ellpeck.prettypipes.Utility;
|
||||
import de.ellpeck.prettypipes.items.IModule;
|
||||
import de.ellpeck.prettypipes.network.PipeNetwork;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
|
@ -22,6 +22,7 @@ import net.minecraft.world.level.block.*;
|
|||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
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;
|
||||
|
@ -46,6 +47,8 @@ import java.util.function.Function;
|
|||
|
||||
public class PipeBlock extends BaseEntityBlock {
|
||||
|
||||
public static final MapCodec<PipeBlock> CODEC = BlockBehaviour.simpleCodec(PipeBlock::new);
|
||||
|
||||
public static final Map<Direction, EnumProperty<ConnectionType>> DIRECTIONS = new HashMap<>();
|
||||
private static final Map<Pair<BlockState, BlockState>, VoxelShape> SHAPE_CACHE = new HashMap<>();
|
||||
private static final Map<Pair<BlockState, BlockState>, VoxelShape> COLL_SHAPE_CACHE = new HashMap<>();
|
||||
|
@ -64,8 +67,8 @@ public class PipeBlock extends BaseEntityBlock {
|
|||
PipeBlock.DIRECTIONS.put(dir, EnumProperty.create(dir.getName(), ConnectionType.class));
|
||||
}
|
||||
|
||||
public PipeBlock() {
|
||||
super(Block.Properties.of().strength(2).sound(SoundType.STONE).noOcclusion());
|
||||
public PipeBlock(Block.Properties properties) {
|
||||
super(properties);
|
||||
|
||||
var state = this.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, false);
|
||||
for (var prop : PipeBlock.DIRECTIONS.values())
|
||||
|
@ -294,6 +297,11 @@ public class PipeBlock extends BaseEntityBlock {
|
|||
return new PipeBlockEntity(pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends BaseEntityBlock> codec() {
|
||||
return PipeBlock.CODEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderShape getRenderShape(BlockState state) {
|
||||
return RenderShape.MODEL;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package de.ellpeck.prettypipes.pressurizer;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import de.ellpeck.prettypipes.Registry;
|
||||
import de.ellpeck.prettypipes.Utility;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
@ -15,7 +15,6 @@ import net.minecraft.world.level.BlockGetter;
|
|||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.BaseEntityBlock;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
|
@ -28,8 +27,15 @@ import java.util.List;
|
|||
|
||||
public class PressurizerBlock extends BaseEntityBlock {
|
||||
|
||||
public PressurizerBlock() {
|
||||
super(BlockBehaviour.Properties.of().strength(3).sound(SoundType.STONE));
|
||||
public static final MapCodec<PressurizerBlock> CODEC = BlockBehaviour.simpleCodec(PressurizerBlock::new);
|
||||
|
||||
public PressurizerBlock(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends BaseEntityBlock> codec() {
|
||||
return PressurizerBlock.CODEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.prettypipes.terminal;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import de.ellpeck.prettypipes.Registry;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
@ -7,10 +8,22 @@ import net.minecraft.world.level.block.BaseEntityBlock;
|
|||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class CraftingTerminalBlock extends ItemTerminalBlock {
|
||||
|
||||
public static final MapCodec<CraftingTerminalBlock> CODEC = BlockBehaviour.simpleCodec(CraftingTerminalBlock::new);
|
||||
|
||||
public CraftingTerminalBlock(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends BaseEntityBlock> codec() {
|
||||
return CraftingTerminalBlock.CODEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @org.jetbrains.annotations.Nullable BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||
return new CraftingTerminalBlockEntity(pos, state);
|
||||
|
@ -21,4 +34,5 @@ public class CraftingTerminalBlock extends ItemTerminalBlock {
|
|||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
|
||||
return BaseEntityBlock.createTickerHelper(type, Registry.craftingTerminalBlockEntity, ItemTerminalBlockEntity::tick);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package de.ellpeck.prettypipes.terminal;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import de.ellpeck.prettypipes.Registry;
|
||||
import de.ellpeck.prettypipes.Utility;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
@ -16,10 +16,10 @@ import net.minecraft.world.level.BlockGetter;
|
|||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.BaseEntityBlock;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
||||
|
@ -28,8 +28,15 @@ import java.util.List;
|
|||
|
||||
public class ItemTerminalBlock extends BaseEntityBlock {
|
||||
|
||||
public ItemTerminalBlock() {
|
||||
super(Properties.of().strength(3).sound(SoundType.STONE));
|
||||
public static final MapCodec<ItemTerminalBlock> CODEC = BlockBehaviour.simpleCodec(ItemTerminalBlock::new);
|
||||
|
||||
public ItemTerminalBlock(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends BaseEntityBlock> codec() {
|
||||
return ItemTerminalBlock.CODEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue