diff --git a/build.gradle b/build.gradle index 126ba6b..d4d6b65 100644 --- a/build.gradle +++ b/build.gradle @@ -10,13 +10,13 @@ buildscript { } plugins { - id 'net.minecraftforge.gradle' version '5.1.+' + id 'net.minecraftforge.gradle' version '[6.0.16,6.2)' } apply plugin: 'org.spongepowered.mixin' group = 'de.saschat' -version = '1.0.0-pre3' +version = '1.1.0' java { archivesBaseName = 'createcomputing' @@ -37,7 +37,7 @@ minecraft { // // Use non-default mappings at your own risk. They may not always work. // Simply re-run your setup task after changing the mappings to update your workspace. - mappings channel: 'official', version: '1.18.2' + mappings channel: 'official', version: '1.20.1' // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') @@ -149,18 +149,28 @@ repositories { includeGroup "curse.maven" } } + maven { + // Location of the maven for mixed mappings, Registrate, and Flywheel + name 'tterrag maven' + url 'https://maven.tterrag.com' + } } dependencies { // Specify the version of Minecraft to use. If this is any group other than 'net.minecraft' it is assumed // that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied. // The userdev artifact is a special name and will get all sorts of transformations applied to it. - minecraft 'net.minecraftforge:forge:1.18.2-40.1.10' + minecraft 'net.minecraftforge:forge:1.20.1-47.2.0' + jarJar(group: 'com.tterrag.registrate', name: 'Registrate', version: '[MC1.20-1.3.3,)') { + jarJar.pin(it, "MC1.20-1.3.3") + } + + implementation fg.deobf("com.simibubi.create:create-${create_minecraft_version}:${create_version}:slim") { transitive = false } + implementation fg.deobf("com.jozufozu.flywheel:flywheel-forge-${flywheel_minecraft_version}:${flywheel_version}") + implementation fg.deobf("com.tterrag.registrate:Registrate:${registrate_version}") - implementation fg.deobf("curse.maven:create-328085:3872145") - implementation fg.deobf("curse.maven:flywheel-486392:3871082") - implementation fg.deobf("curse.maven:cc-tweaked-282001:3709268") - implementation fg.deobf("curse.maven:jade-324717:3865918") + implementation fg.deobf("curse.maven:cc-tweaked-282001:5379173") + implementation fg.deobf("curse.maven:jade-324717:5390389") // Real mod deobf dependency examples - these get remapped to your current mappings // compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency diff --git a/gradle.properties b/gradle.properties index 29b2ac4..a5081cd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,7 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false +create_minecraft_version = 1.20.1 +flywheel_minecraft_version = 1.20.1 +create_version = 0.5.1.f-26 +flywheel_version = 0.6.10-7 +registrate_version = MC1.20-1.3.3 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index aa991fc..0d18421 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/de/saschat/createcomputing/Behaviours.java b/src/main/java/de/saschat/createcomputing/Behaviours.java index 1a6c403..eb174dc 100644 --- a/src/main/java/de/saschat/createcomputing/Behaviours.java +++ b/src/main/java/de/saschat/createcomputing/Behaviours.java @@ -1,27 +1,28 @@ package de.saschat.createcomputing; -import com.simibubi.create.content.logistics.block.display.AllDisplayBehaviours; +import com.simibubi.create.content.redstone.displayLink.AllDisplayBehaviours; +import com.simibubi.create.foundation.utility.RegisteredObjects; import de.saschat.createcomputing.behaviour.source.TextDisplayBehaviour; import de.saschat.createcomputing.behaviour.target.TextPassBehaviour; import net.minecraft.resources.ResourceLocation; public class Behaviours { public static void register() { - AllDisplayBehaviours.assignTile( + AllDisplayBehaviours.assignBlock( AllDisplayBehaviours.register( new ResourceLocation(CreateComputingMod.MOD_ID, "computerized_display_source"), new TextDisplayBehaviour() ), - Registries.COMPUTERIZED_DISPLAY_SOURCE_TILE.get().delegate + RegisteredObjects.getKeyOrThrow(Registries.COMPUTERIZED_DISPLAY_SOURCE_TILE.get()) ); - AllDisplayBehaviours.assignTile( + AllDisplayBehaviours.assignBlock( AllDisplayBehaviours.register( new ResourceLocation(CreateComputingMod.MOD_ID, "computerized_display_target"), new TextPassBehaviour() ), - Registries.COMPUTERIZED_DISPLAY_TARGET_TILE.get().delegate + RegisteredObjects.getKeyOrThrow(Registries.COMPUTERIZED_DISPLAY_TARGET_TILE.get()) ); } } diff --git a/src/main/java/de/saschat/createcomputing/Registries.java b/src/main/java/de/saschat/createcomputing/Registries.java index 5d9705d..0e9faaf 100644 --- a/src/main/java/de/saschat/createcomputing/Registries.java +++ b/src/main/java/de/saschat/createcomputing/Registries.java @@ -1,7 +1,7 @@ package de.saschat.createcomputing; -import com.simibubi.create.content.logistics.trains.management.edgePoint.TrackTargetingBlockItem; -import com.simibubi.create.repack.registrate.util.nullness.NonNullBiFunction; +import com.simibubi.create.content.trains.track.TrackTargetingBlockItem; +import com.tterrag.registrate.util.nullness.NonNullBiFunction; import de.saschat.createcomputing.blocks.ComputerizedDisplaySourceBlock; import de.saschat.createcomputing.blocks.ComputerizedDisplayTargetBlock; import de.saschat.createcomputing.blocks.ComputerizedRedstoneLinkBlock; @@ -13,20 +13,21 @@ import de.saschat.createcomputing.tiles.renderer.TrainNetworkObserverRenderer; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.RenderType; +import net.minecraft.network.chat.Component; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.CreativeModeTabs; 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.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraftforge.client.event.EntityRenderersEvent; +import net.minecraftforge.data.event.GatherDataEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; -import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; @@ -37,8 +38,9 @@ public class Registries { public static DeferredRegister ITEM_REGISTRY = DeferredRegister.create(ForgeRegistries.ITEMS, CreateComputingMod.MOD_ID); public static DeferredRegister BLOCK_REGISTRY = DeferredRegister.create(ForgeRegistries.BLOCKS, CreateComputingMod.MOD_ID); - public static DeferredRegister> TILE_REGISTRY = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, CreateComputingMod.MOD_ID); + public static DeferredRegister> TILE_REGISTRY = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, CreateComputingMod.MOD_ID); + private static final DeferredRegister TAB_REGISTERY =DeferredRegister.create(net.minecraft.core.registries.Registries.CREATIVE_MODE_TAB, CreateComputingMod.MOD_ID); public static RegistryObject registerBlock(String name, Supplier blockSupplier) { CreateComputingMod.LOGGER.info("Queuing block: " + name); return BLOCK_REGISTRY.register(name, blockSupplier); @@ -65,13 +67,6 @@ public static RegistryObject> registe }); } - public static CreativeModeTab TAB = new CreativeModeTab("createcomputing.tab") { - @Override - public ItemStack makeIcon() { - return new ItemStack(COMPUTERIZED_DISPLAY_TARGET_ITEM.get()); - } - }; - // Computerized Display Source public static RegistryObject COMPUTERIZED_DISPLAY_SOURCE = registerBlock( "computerized_display_source", @@ -80,7 +75,7 @@ public ItemStack makeIcon() { public static RegistryObject COMPUTERIZED_DISPLAY_SOURCE_ITEM = registerBlockItem( "computerized_display_source", COMPUTERIZED_DISPLAY_SOURCE, - new Item.Properties().tab(TAB) + new Item.Properties() ); public static RegistryObject> COMPUTERIZED_DISPLAY_SOURCE_TILE = registerTile( "computerized_display_source", @@ -97,7 +92,7 @@ public ItemStack makeIcon() { public static RegistryObject COMPUTERIZED_DISPLAY_TARGET_ITEM = registerBlockItem( "computerized_display_target", COMPUTERIZED_DISPLAY_TARGET, - new Item.Properties().tab(TAB) + new Item.Properties() ); public static RegistryObject> COMPUTERIZED_DISPLAY_TARGET_TILE = registerTile( "computerized_display_target", @@ -113,7 +108,7 @@ public ItemStack makeIcon() { public static RegistryObject COMPUTERIZED_REDSTONE_LINK_ITEM = registerBlockItem( "computerized_redstone_link", COMPUTERIZED_REDSTONE_LINK, - new Item.Properties().tab(TAB) + new Item.Properties() ); public static RegistryObject> COMPUTERIZED_REDSTONE_LINK_TILE = registerTile( "computerized_redstone_link", @@ -129,8 +124,8 @@ public ItemStack makeIcon() { public static RegistryObject TRAIN_NETWORK_OBSERVER_ITEM = registerBlockItem( "train_network_observer", TRAIN_NETWORK_OBSERVER, - new Item.Properties().tab(TAB), - TrackTargetingBlockItem.ofType(TrainNetworkObserverTile.NETWORK_OBSERVER) + new Item.Properties() + ,TrackTargetingBlockItem.ofType(TrainNetworkObserverTile.NETWORK_OBSERVER) ); public static RegistryObject> TRAIN_NETWORK_OBSERVER_TILE = registerTile( "train_network_observer", @@ -138,6 +133,20 @@ public ItemStack makeIcon() { TRAIN_NETWORK_OBSERVER ); + public static final RegistryObject TAB = TAB_REGISTERY.register("base", + () -> CreativeModeTab.builder() + .title(Component.translatable("itemGroup.createcomputing.tab")) + .withTabsBefore(CreativeModeTabs.SPAWN_EGGS) + .icon(() -> Registries.COMPUTERIZED_DISPLAY_TARGET_ITEM.get().getDefaultInstance()) + .displayItems((displayParams, output) -> + { + output.accept(Registries.COMPUTERIZED_DISPLAY_TARGET_ITEM.get()); + output.accept(Registries.COMPUTERIZED_DISPLAY_SOURCE_ITEM.get()); + output.accept(Registries.COMPUTERIZED_REDSTONE_LINK_ITEM.get()); + output.accept(Registries.TRAIN_NETWORK_OBSERVER_ITEM.get()); + }) + .build()); + // Events @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents { @@ -160,38 +169,16 @@ public static void modRenderer(final EntityRenderersEvent.RegisterRenderers even } public static void modData(final GatherDataEvent event) { } - } - /*@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE) - public static class ForgeEvents { - @SubscribeEvent - public static void modCommands(final RegisterCommandsEvent event) { - System.out.println("REGISTER COMMANDS"); - event.getDispatcher().register( - Commands.literal("redstone_link").executes(context -> { - Map, Set> coupleSetMap = Create.REDSTONE_LINK_NETWORK_HANDLER.networksIn(context.getSource().getLevel()); - coupleSetMap.forEach((frequencies, iRedstoneLinkables) -> { - System.out.println("Frequency: " + frequencies.get(true).getStack().getItem().getRegistryName().toString() + ", " + frequencies.get(false).getStack().getItem().getRegistryName().toString()); - for (IRedstoneLinkable iRedstoneLinkable : iRedstoneLinkables) { - System.out.println("\tAt " + iRedstoneLinkable.getLocation().toString() + ", listening: " + iRedstoneLinkable.isListening() + ", alive: " + iRedstoneLinkable.isAlive() + ", strength: " + iRedstoneLinkable.getTransmittedStrength()); - } - }); - return 0; - }) - ); - } - }*/ - - + } + // Real loading - public static void init(IEventBus modEventBus) { CreateComputingMod.LOGGER.info("Registering all registries."); BLOCK_REGISTRY.register(modEventBus); ITEM_REGISTRY.register(modEventBus); TILE_REGISTRY.register(modEventBus); + TAB_REGISTERY.register(modEventBus); CreateComputingMod.LOGGER.info("Registered all registries."); } // For loading. - - } diff --git a/src/main/java/de/saschat/createcomputing/Utils.java b/src/main/java/de/saschat/createcomputing/Utils.java index d4444c0..ebd4a9b 100644 --- a/src/main/java/de/saschat/createcomputing/Utils.java +++ b/src/main/java/de/saschat/createcomputing/Utils.java @@ -1,5 +1,6 @@ package de.saschat.createcomputing; +import com.simibubi.create.foundation.utility.RegisteredObjects; import net.minecraft.core.Direction; import net.minecraft.nbt.*; import net.minecraft.resources.ResourceLocation; @@ -15,7 +16,7 @@ public class Utils { public static Item getByName(ResourceLocation loc) { var itemRegistryObject = ForgeRegistries.ITEMS.getEntries().stream().filter(a -> { - return a.getValue().getRegistryName().equals(loc); + return RegisteredObjects.getKeyOrThrow(a.getValue()).equals(loc); }).findFirst().orElseGet(() -> null); if (itemRegistryObject == null) return Items.AIR; diff --git a/src/main/java/de/saschat/createcomputing/behaviour/source/TextDisplayBehaviour.java b/src/main/java/de/saschat/createcomputing/behaviour/source/TextDisplayBehaviour.java index c1b0b44..64ba480 100644 --- a/src/main/java/de/saschat/createcomputing/behaviour/source/TextDisplayBehaviour.java +++ b/src/main/java/de/saschat/createcomputing/behaviour/source/TextDisplayBehaviour.java @@ -1,23 +1,22 @@ package de.saschat.createcomputing.behaviour.source; -import com.simibubi.create.content.logistics.block.display.DisplayLinkContext; -import com.simibubi.create.content.logistics.block.display.source.DisplaySource; -import com.simibubi.create.content.logistics.block.display.target.DisplayTargetStats; -import com.simibubi.create.content.logistics.trains.management.display.FlapDisplayTileEntity; +import com.simibubi.create.content.redstone.displayLink.DisplayLinkContext; +import com.simibubi.create.content.redstone.displayLink.source.DisplaySource; +import com.simibubi.create.content.redstone.displayLink.target.DisplayTargetStats; import de.saschat.createcomputing.tiles.ComputerizedDisplaySourceTile; +import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; -import net.minecraft.network.chat.TextComponent; import java.util.List; public class TextDisplayBehaviour extends DisplaySource { - public static MutableComponent NIL_TEXT = new TextComponent(""); + public static MutableComponent NIL_TEXT = Component.literal(""); @Override public List provideText(DisplayLinkContext displayLinkContext, DisplayTargetStats displayTargetStats) { /* Maybe some events in the future? */ - return ((ComputerizedDisplaySourceTile) displayLinkContext.getSourceTE()).getFromPos(displayLinkContext.te().getBlockPos()).toDisplay; + return ((ComputerizedDisplaySourceTile) displayLinkContext.getSourceBlockEntity()).getFromPos(displayLinkContext.blockEntity().getBlockPos()).toDisplay; } @Override diff --git a/src/main/java/de/saschat/createcomputing/behaviour/target/TextPassBehaviour.java b/src/main/java/de/saschat/createcomputing/behaviour/target/TextPassBehaviour.java index 804ed55..92b3ff3 100644 --- a/src/main/java/de/saschat/createcomputing/behaviour/target/TextPassBehaviour.java +++ b/src/main/java/de/saschat/createcomputing/behaviour/target/TextPassBehaviour.java @@ -1,8 +1,8 @@ package de.saschat.createcomputing.behaviour.target; -import com.simibubi.create.content.logistics.block.display.DisplayLinkContext; -import com.simibubi.create.content.logistics.block.display.target.DisplayTarget; -import com.simibubi.create.content.logistics.block.display.target.DisplayTargetStats; +import com.simibubi.create.content.redstone.displayLink.DisplayLinkContext; +import com.simibubi.create.content.redstone.displayLink.target.DisplayTarget; +import com.simibubi.create.content.redstone.displayLink.target.DisplayTargetStats; import de.saschat.createcomputing.tiles.ComputerizedDisplayTargetTile; import net.minecraft.network.chat.MutableComponent; @@ -11,13 +11,14 @@ public class TextPassBehaviour extends DisplayTarget { @Override public void acceptText(int line, List list, DisplayLinkContext displayLinkContext) { - ComputerizedDisplayTargetTile tile = (ComputerizedDisplayTargetTile) displayLinkContext.getTargetTE(); + ComputerizedDisplayTargetTile tile = (ComputerizedDisplayTargetTile) displayLinkContext.getTargetBlockEntity(); + tile.acceptText(line, list, displayLinkContext); tile.acceptText(line, list, displayLinkContext); } @Override public DisplayTargetStats provideStats(DisplayLinkContext displayLinkContext) { - ComputerizedDisplayTargetTile tile = (ComputerizedDisplayTargetTile) displayLinkContext.getTargetTE(); + ComputerizedDisplayTargetTile tile = (ComputerizedDisplayTargetTile) displayLinkContext.getTargetBlockEntity(); return new DisplayTargetStats(tile.maxHeight, tile.maxHeight, this); } } diff --git a/src/main/java/de/saschat/createcomputing/behaviour/tile/TrainNetworkObserver.java b/src/main/java/de/saschat/createcomputing/behaviour/tile/TrainNetworkObserver.java index 45338f1..2fd2748 100644 --- a/src/main/java/de/saschat/createcomputing/behaviour/tile/TrainNetworkObserver.java +++ b/src/main/java/de/saschat/createcomputing/behaviour/tile/TrainNetworkObserver.java @@ -1,7 +1,7 @@ package de.saschat.createcomputing.behaviour.tile; -import com.simibubi.create.content.logistics.trains.management.edgePoint.signal.SingleTileEdgePoint; +import com.simibubi.create.content.trains.signal.SingleBlockEntityEdgePoint; -public class TrainNetworkObserver extends SingleTileEdgePoint { +public class TrainNetworkObserver extends SingleBlockEntityEdgePoint { } diff --git a/src/main/java/de/saschat/createcomputing/blocks/ComputerizedDisplaySourceBlock.java b/src/main/java/de/saschat/createcomputing/blocks/ComputerizedDisplaySourceBlock.java index a686c66..b12526d 100644 --- a/src/main/java/de/saschat/createcomputing/blocks/ComputerizedDisplaySourceBlock.java +++ b/src/main/java/de/saschat/createcomputing/blocks/ComputerizedDisplaySourceBlock.java @@ -16,7 +16,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.DirectionProperty; -import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MapColor; import net.minecraft.world.phys.shapes.BooleanOp; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; @@ -29,7 +29,7 @@ public class ComputerizedDisplaySourceBlock extends Block implements EntityBlock public static DirectionProperty FACING = HorizontalDirectionalBlock.FACING; public ComputerizedDisplaySourceBlock() { - super(BlockBehaviour.Properties.of(Material.WOOD).destroyTime(1)); + super(BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).destroyTime(1)); registerDefaultState(this.getStateDefinition().any().setValue(FACING, Direction.NORTH)); } diff --git a/src/main/java/de/saschat/createcomputing/blocks/ComputerizedDisplayTargetBlock.java b/src/main/java/de/saschat/createcomputing/blocks/ComputerizedDisplayTargetBlock.java index c67fe71..74fc3f6 100644 --- a/src/main/java/de/saschat/createcomputing/blocks/ComputerizedDisplayTargetBlock.java +++ b/src/main/java/de/saschat/createcomputing/blocks/ComputerizedDisplayTargetBlock.java @@ -13,7 +13,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.DirectionProperty; -import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MapColor; import net.minecraft.world.phys.shapes.BooleanOp; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; @@ -26,7 +26,7 @@ public class ComputerizedDisplayTargetBlock extends Block implements EntityBlock public static DirectionProperty FACING = HorizontalDirectionalBlock.FACING; public ComputerizedDisplayTargetBlock() { - super(Properties.of(Material.WOOD).destroyTime(1)); + super(Properties.of().mapColor(MapColor.WOOD).destroyTime(1)); registerDefaultState(this.getStateDefinition().any().setValue(FACING, Direction.NORTH)); } diff --git a/src/main/java/de/saschat/createcomputing/blocks/ComputerizedRedstoneLinkBlock.java b/src/main/java/de/saschat/createcomputing/blocks/ComputerizedRedstoneLinkBlock.java index a1695e6..d4bd784 100644 --- a/src/main/java/de/saschat/createcomputing/blocks/ComputerizedRedstoneLinkBlock.java +++ b/src/main/java/de/saschat/createcomputing/blocks/ComputerizedRedstoneLinkBlock.java @@ -1,6 +1,6 @@ package de.saschat.createcomputing.blocks; -import com.simibubi.create.foundation.block.ITE; +import com.simibubi.create.foundation.block.IBE; import de.saschat.createcomputing.Registries; import de.saschat.createcomputing.tiles.ComputerizedRedstoneLinkTile; import net.minecraft.core.BlockPos; @@ -9,22 +9,22 @@ 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.material.Material; +import net.minecraft.world.level.material.MapColor; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; -public class ComputerizedRedstoneLinkBlock extends Block implements ITE { +public class ComputerizedRedstoneLinkBlock extends Block implements IBE { public ComputerizedRedstoneLinkBlock() { - super(BlockBehaviour.Properties.of(Material.WOOD).destroyTime(1)); + super(BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).destroyTime(1)); } @Override - public Class getTileEntityClass() { + public Class getBlockEntityClass() { return ComputerizedRedstoneLinkTile.class; } @Override - public BlockEntityType getTileEntityType() { + public BlockEntityType getBlockEntityType() { return Registries.COMPUTERIZED_REDSTONE_LINK_TILE.get(); } diff --git a/src/main/java/de/saschat/createcomputing/blocks/TrainNetworkObserverBlock.java b/src/main/java/de/saschat/createcomputing/blocks/TrainNetworkObserverBlock.java index 823df15..09bed97 100644 --- a/src/main/java/de/saschat/createcomputing/blocks/TrainNetworkObserverBlock.java +++ b/src/main/java/de/saschat/createcomputing/blocks/TrainNetworkObserverBlock.java @@ -1,6 +1,6 @@ package de.saschat.createcomputing.blocks; -import com.simibubi.create.foundation.block.ITE; +import com.simibubi.create.foundation.block.IBE; import de.saschat.createcomputing.Registries; import de.saschat.createcomputing.tiles.TrainNetworkObserverTile; import net.minecraft.core.BlockPos; @@ -9,7 +9,7 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MapColor; import net.minecraft.world.phys.shapes.BooleanOp; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; @@ -17,18 +17,18 @@ import java.util.stream.Stream; -public class TrainNetworkObserverBlock extends Block implements ITE { +public class TrainNetworkObserverBlock extends Block implements IBE { public TrainNetworkObserverBlock() { - super(Properties.of(Material.WOOD).destroyTime(1)); + super(Properties.of().mapColor(MapColor.WOOD).destroyTime(1)); } @Override - public Class getTileEntityClass() { + public Class getBlockEntityClass() { return TrainNetworkObserverTile.class; } @Override - public BlockEntityType getTileEntityType() { + public BlockEntityType getBlockEntityType() { return Registries.TRAIN_NETWORK_OBSERVER_TILE.get(); } diff --git a/src/main/java/de/saschat/createcomputing/mixin/TrackTargetingClientMixin.java b/src/main/java/de/saschat/createcomputing/mixin/TrackTargetingClientMixin.java index cd1b0d5..c25e682 100644 --- a/src/main/java/de/saschat/createcomputing/mixin/TrackTargetingClientMixin.java +++ b/src/main/java/de/saschat/createcomputing/mixin/TrackTargetingClientMixin.java @@ -1,10 +1,11 @@ package de.saschat.createcomputing.mixin; import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.content.logistics.trains.management.edgePoint.EdgePointType; -import com.simibubi.create.content.logistics.trains.management.edgePoint.TrackTargetingClient; +import com.simibubi.create.content.trains.graph.EdgePointType; +import com.simibubi.create.content.trains.track.TrackTargetingClient; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import de.saschat.createcomputing.tiles.TrainNetworkObserverTile; +import net.minecraft.world.phys.Vec3; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -16,7 +17,7 @@ public class TrackTargetingClientMixin { @Shadow(remap = false) private static EdgePointType lastType; @Inject(method = "render", at=@At("HEAD"), remap = false) - private static void render(PoseStack ms, SuperRenderTypeBuffer buffer, CallbackInfo ci) { + private static void render(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, CallbackInfo ci) { if(lastType == TrainNetworkObserverTile.NETWORK_OBSERVER) lastType = EdgePointType.OBSERVER; } diff --git a/src/main/java/de/saschat/createcomputing/peripherals/ComputerizedDisplayTargetPeripheral.java b/src/main/java/de/saschat/createcomputing/peripherals/ComputerizedDisplayTargetPeripheral.java index c5b8670..fe79d31 100644 --- a/src/main/java/de/saschat/createcomputing/peripherals/ComputerizedDisplayTargetPeripheral.java +++ b/src/main/java/de/saschat/createcomputing/peripherals/ComputerizedDisplayTargetPeripheral.java @@ -1,7 +1,7 @@ package de.saschat.createcomputing.peripherals; import com.google.gson.Gson; -import com.simibubi.create.content.logistics.block.display.DisplayLinkContext; +import com.simibubi.create.content.redstone.displayLink.DisplayLinkContext; import dan200.computercraft.api.lua.IArguments; import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.lua.LuaException; @@ -90,7 +90,7 @@ public void acceptText(int line, List list, DisplayLinkContext } computers.forEach(a -> { a.queueEvent("display_link_data", - displayLinkContext.te().activeSource.id.toString(), + displayLinkContext.blockEntity().activeSource.id.toString(), displayLinkContext.getSourcePos().getX(), displayLinkContext.getSourcePos().getY(), displayLinkContext.getSourcePos().getZ(), diff --git a/src/main/java/de/saschat/createcomputing/peripherals/ComputerizedRedstoneLinkPeripheral.java b/src/main/java/de/saschat/createcomputing/peripherals/ComputerizedRedstoneLinkPeripheral.java index d1df71a..6aaae68 100644 --- a/src/main/java/de/saschat/createcomputing/peripherals/ComputerizedRedstoneLinkPeripheral.java +++ b/src/main/java/de/saschat/createcomputing/peripherals/ComputerizedRedstoneLinkPeripheral.java @@ -23,20 +23,13 @@ public class ComputerizedRedstoneLinkPeripheral extends SmartPeripheral { public HashMap handles = new HashMap<>(); public void removeHandle(UUID hd) { - handles.values().forEach(a -> { - if (a.handle.equals(hd)) { - a.close(); - handles.remove(hd, a); - } - }); - } - - public void killHandles(UUID hd) { - handles.values().forEach(a -> { - if (a.handle.equals(hd)) { - a.close(); - handles.remove(a.handle, a); - } + parent.tasks.add(() -> { + handles.entrySet().removeIf(entry -> entry.getKey().equals(hd)); + parent.pairs.forEach((b,a) -> { + if (b.equals(hd)) { + parent.remove(a); + } + }); }); } diff --git a/src/main/java/de/saschat/createcomputing/peripherals/TrainNetworkObserverPeripheral.java b/src/main/java/de/saschat/createcomputing/peripherals/TrainNetworkObserverPeripheral.java index c84a325..de6918d 100644 --- a/src/main/java/de/saschat/createcomputing/peripherals/TrainNetworkObserverPeripheral.java +++ b/src/main/java/de/saschat/createcomputing/peripherals/TrainNetworkObserverPeripheral.java @@ -3,22 +3,23 @@ import com.google.gson.Gson; import com.simibubi.create.AllItems; import com.simibubi.create.Create; -import com.simibubi.create.content.logistics.item.filter.AttributeFilterContainer; -import com.simibubi.create.content.logistics.item.filter.FilterItem; -import com.simibubi.create.content.logistics.trains.BezierConnection; -import com.simibubi.create.content.logistics.trains.GraphLocation; -import com.simibubi.create.content.logistics.trains.TrackNodeLocation; -import com.simibubi.create.content.logistics.trains.entity.Carriage; -import com.simibubi.create.content.logistics.trains.entity.CarriageContraptionEntity; -import com.simibubi.create.content.logistics.trains.entity.Train; -import com.simibubi.create.content.logistics.trains.management.display.GlobalTrainDisplayData; -import com.simibubi.create.content.logistics.trains.management.edgePoint.EdgePointType; -import com.simibubi.create.content.logistics.trains.management.edgePoint.observer.TrackObserver; -import com.simibubi.create.content.logistics.trains.management.edgePoint.signal.SignalBoundary; -import com.simibubi.create.content.logistics.trains.management.edgePoint.signal.SignalTileEntity; -import com.simibubi.create.content.logistics.trains.management.edgePoint.station.GlobalStation; -import com.simibubi.create.content.logistics.trains.management.schedule.ScheduleEntry; -import com.simibubi.create.content.logistics.trains.management.schedule.condition.ScheduleWaitCondition; + +import com.simibubi.create.content.logistics.filter.AttributeFilterMenu; +import com.simibubi.create.content.logistics.filter.FilterItem; +import com.simibubi.create.content.trains.track.BezierConnection; +import com.simibubi.create.content.trains.graph.TrackGraphLocation; +import com.simibubi.create.content.trains.graph.TrackNodeLocation; +import com.simibubi.create.content.trains.entity.Carriage; +import com.simibubi.create.content.trains.entity.CarriageContraptionEntity; +import com.simibubi.create.content.trains.entity.Train; +import com.simibubi.create.content.trains.display.GlobalTrainDisplayData; +import com.simibubi.create.content.trains.graph.EdgePointType; +import com.simibubi.create.content.trains.observer.TrackObserver; +import com.simibubi.create.content.trains.signal.SignalBoundary; +import com.simibubi.create.content.trains.signal.SignalBlockEntity; +import com.simibubi.create.content.trains.station.GlobalStation; +import com.simibubi.create.content.trains.schedule.ScheduleEntry; +import com.simibubi.create.content.trains.schedule.condition.ScheduleWaitCondition; import dan200.computercraft.api.lua.MethodResult; import dan200.computercraft.api.peripheral.IPeripheral; import de.saschat.createcomputing.CreateComputingMod; @@ -43,7 +44,7 @@ public class TrainNetworkObserverPeripheral extends SmartPeripheral { public List getTrains() { List trainList = new LinkedList<>(); - GraphLocation graphLocation = parent.getGraphLocation(); + TrackGraphLocation graphLocation = parent.getGraphLocation(); for (Train train : Create.RAILWAYS.trains.values()) { if (train.graph.id.equals(graphLocation.graph.id)) trainList.add(train); @@ -74,7 +75,7 @@ public TrainNetworkObserverPeripheral(TrainNetworkObserverTile tile) { String b = iArguments.getString(0); Optional first = getTrains().stream().filter(a -> a.id.toString().equals(b)).findFirst(); if (first.isEmpty()) - return MethodResult.of(null); + return MethodResult.of((Object) null); Train train = first.get(); return MethodResult.of(new Gson().fromJson(Component.Serializer.toJson(train.name), Map.class)); }); @@ -82,11 +83,11 @@ public TrainNetworkObserverPeripheral(TrainNetworkObserverTile tile) { String b = iArguments.getString(0); Optional first = getTrains().stream().filter(a -> a.id.toString().equals(b)).findFirst(); if (first.isEmpty()) - return MethodResult.of(null); + return MethodResult.of((Object) null); Train train = first.get(); Map map = new HashMap<>(); if (train.runtime.getSchedule() == null) - return MethodResult.of(null); + return MethodResult.of((Object) null); int bidx = 1; for (ScheduleEntry entry : train.runtime.getSchedule().entries) { Map data = new HashMap<>(); @@ -117,7 +118,7 @@ public TrainNetworkObserverPeripheral(TrainNetworkObserverTile tile) { String b = iArguments.getString(0); Optional first = getTrains().stream().filter(a -> a.id.toString().equals(b)).findFirst(); if (first.isEmpty()) - return MethodResult.of(null); + return MethodResult.of((Object) null); Train train = first.get(); Optional carr = Optional.empty(); @@ -129,16 +130,16 @@ public TrainNetworkObserverPeripheral(TrainNetworkObserverTile tile) { carr = Optional.of(a1); if (carr.isEmpty()) - return MethodResult.of(null); + return MethodResult.of((Object) null); Carriage.DimensionalCarriageEntity car = carr.get(); CarriageContraptionEntity ent = car.entity.get(); - return MethodResult.of(ent.getX(), ent.getY(), ent.getZ(), ent.getLevel().dimension().getRegistryName().toString()); + return MethodResult.of(ent.getX(), ent.getY(), ent.getZ(), ent.level().dimension().registry().toString()); }); addMethod("getTrainSpeed", (iComputerAccess, iLuaContext, iArguments) -> { String b = iArguments.getString(0); Optional first = getTrains().stream().filter(a -> a.id.toString().equals(b)).findFirst(); if (first.isEmpty()) - return MethodResult.of(null); + return MethodResult.of((Object) null); Train train = first.get(); return MethodResult.of(train.speed); }); @@ -146,12 +147,12 @@ public TrainNetworkObserverPeripheral(TrainNetworkObserverTile tile) { String b = iArguments.getString(0); Optional first = getTrains().stream().filter(a -> a.toString().equals(b)).findFirst(); if (first.isEmpty()) - return MethodResult.of(null); + return MethodResult.of((Object) null); Train train = first.get(); GlobalStation currentStation = train.getCurrentStation(); if (currentStation != null) return MethodResult.of(currentStation.getId().toString(), currentStation.name); - return MethodResult.of(null); + return MethodResult.of((Object) null); }); // STOPS addMethod("getStops", ((iComputerAccess, iLuaContext, iArguments) -> { @@ -162,7 +163,7 @@ public TrainNetworkObserverPeripheral(TrainNetworkObserverTile tile) { String b = iArguments.getString(0); Optional first = getStations().stream().filter(a -> a.id.toString().equals(b)).findFirst(); if (first.isEmpty()) - return MethodResult.of(null); + return MethodResult.of((Object) null); GlobalStation station = first.get(); return MethodResult.of(station.name); }); @@ -170,15 +171,16 @@ public TrainNetworkObserverPeripheral(TrainNetworkObserverTile tile) { String b = iArguments.getString(0); Optional first = getStations().stream().filter(a -> a.id.toString().equals(b)).findFirst(); if (first.isEmpty()) - return MethodResult.of(null); + return MethodResult.of((Object) null); GlobalStation station = first.get(); - return MethodResult.of(station.tilePos.getX(), station.tilePos.getY(), station.tilePos.getZ()); + BlockPos pos = station.getBlockEntityPos(); + return MethodResult.of(pos.getX(), pos.getY(), pos.getZ()); }); addMethod("getStopExpectedTrain", (iComputerAccess, iLuaContext, iArguments) -> { String b = iArguments.getString(0); Optional first = getStations().stream().filter(a -> a.id.toString().equals(b)).findFirst(); if (first.isEmpty()) - return MethodResult.of(null); + return MethodResult.of((Object) null); GlobalStation station = first.get(); List prepare = GlobalTrainDisplayData.prepare(station.name, 200); Map> data = new HashMap(); @@ -203,7 +205,7 @@ public TrainNetworkObserverPeripheral(TrainNetworkObserverTile tile) { String b = iArguments.getString(0); Optional first = getSignals().stream().filter(a -> a.id.toString().equals(b)).findFirst(); if (first.isEmpty()) - return MethodResult.of(null); + return MethodResult.of((Object) null); SignalBoundary signal = first.get(); Map> returned = new HashMap<>(); int idx = 1; @@ -231,9 +233,9 @@ public TrainNetworkObserverPeripheral(TrainNetworkObserverTile tile) { boolean toPos = iArguments.getBoolean(1); Optional first = getSignals().stream().filter(a -> a.id.toString().equals(b)).findFirst(); if (first.isEmpty()) - return MethodResult.of(null); + return MethodResult.of((Object) null); SignalBoundary signal = first.get(); - SignalTileEntity.SignalState stateFor = signal.cachedStates.get(toPos); + SignalBlockEntity.SignalState stateFor = signal.cachedStates.get(toPos); return switch (stateFor) { case RED -> MethodResult.of(0); case YELLOW -> MethodResult.of(1); @@ -250,17 +252,18 @@ public TrainNetworkObserverPeripheral(TrainNetworkObserverTile tile) { String b = iArguments.getString(0); Optional first = getObservers().stream().filter(a -> a.id.toString().equals(b)).findFirst(); if (first.isEmpty()) - return MethodResult.of(null); + return MethodResult.of((Object) null); TrackObserver obs = first.get(); - return MethodResult.of(obs.tilePos.getX(), obs.tilePos.getY(), obs.tilePos.getZ()); + BlockPos pos = obs.getBlockEntityPos(); + return MethodResult.of(pos.getX(), pos.getY(), pos.getZ()); }); addMethod("getObserverFilter", ((iComputerAccess, iLuaContext, iArguments) -> { String b = iArguments.getString(0); Optional first = getObservers().stream().filter(a -> a.id.toString().equals(b)).findFirst(); if (first.isEmpty()) - return MethodResult.of(null); + return MethodResult.of((Object) null); TrackObserver obs = first.get(); - return MethodResult.of(blowFilter(obs.getFilter())); + return MethodResult.of(blowFilter(obs.getFilter().item())); })); // GRAPH addMethod("getGraph", ((iComputerAccess, iLuaContext, iArguments) -> { @@ -318,7 +321,7 @@ private static Map blowFilter(ItemStack filter) { } if (filter.is(AllItems.ATTRIBUTE_FILTER.get())) { ret.put("type", "attribute"); - AttributeFilterContainer.WhitelistMode whitelistMode = AttributeFilterContainer.WhitelistMode.values()[filter.getTag().getInt("WhitelistMode")]; + AttributeFilterMenu.WhitelistMode whitelistMode = AttributeFilterMenu.WhitelistMode.values()[filter.getTag().getInt("WhitelistMode")]; ret.put("allowmode", whitelistMode.toString()); ListTag tag = filter.getTag().getList("MatchedAttributes", Tag.TAG_COMPOUND); int idx = 1; @@ -331,7 +334,7 @@ private static Map blowFilter(ItemStack filter) { } ret.put("type", "item"); ret.put("count", filter.getCount()); - ret.put("id", filter.getItem().getRegistryName().toString()); + ret.put("id", filter.getItem().getDescriptionId()); ret.put("nbt", blowNBT(filter.getTag())); return ret; } diff --git a/src/main/java/de/saschat/createcomputing/peripherals/handles/DisplayLinkHandle.java b/src/main/java/de/saschat/createcomputing/peripherals/handles/DisplayLinkHandle.java index 524bdc8..6e27e9e 100644 --- a/src/main/java/de/saschat/createcomputing/peripherals/handles/DisplayLinkHandle.java +++ b/src/main/java/de/saschat/createcomputing/peripherals/handles/DisplayLinkHandle.java @@ -1,9 +1,9 @@ package de.saschat.createcomputing.peripherals.handles; import com.google.gson.Gson; -import com.simibubi.create.content.logistics.block.display.DisplayLinkTileEntity; -import com.simibubi.create.content.logistics.block.display.target.DisplayTarget; -import com.simibubi.create.content.logistics.trains.management.display.FlapDisplayTileEntity; +import com.simibubi.create.content.redstone.displayLink.DisplayLinkBlockEntity; +import com.simibubi.create.content.redstone.displayLink.target.DisplayTarget; +import com.simibubi.create.content.trains.display.FlapDisplayBlockEntity; import dan200.computercraft.api.lua.IArguments; import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.lua.LuaFunction; @@ -58,7 +58,7 @@ public final void close() throws LuaException { public DisplayTarget getTarget() throws LuaException { ComputerizedDisplaySourceTile.DisplayData data = getData(); - return data.tileEntity.activeTarget; + return data.blockEntity.activeTarget; } @LuaFunction @@ -66,7 +66,7 @@ public final Object[] getTargetType(IArguments arg) throws LuaException { checkOpen(); ComputerizedDisplaySourceTile.DisplayData data = getData(); - DisplayLinkTileEntity te = data.tileEntity; + DisplayLinkBlockEntity te = data.blockEntity; if(getTarget() != null) return new Object[]{getTarget().id.toString()}; @@ -129,7 +129,7 @@ public final Object[] getWidth() throws LuaException { switch (getTarget().id.toString()) { // @todo more target sizes case "create:display_board_target": { - FlapDisplayTileEntity d = (FlapDisplayTileEntity) data.tileEntity.getLevel().getBlockEntity(data.tileEntity.getTargetPosition()); + FlapDisplayBlockEntity d = (FlapDisplayBlockEntity) data.blockEntity.getLevel().getBlockEntity(data.blockEntity.getTargetPosition()); d = d.getController(); return new Object[]{d.getMaxCharCount()}; } @@ -145,7 +145,7 @@ public final Object[] getHeight() throws LuaException { switch (getTarget().id.toString()) { // @todo more target sizes case "create:display_board_target": { - FlapDisplayTileEntity d = (FlapDisplayTileEntity) data.tileEntity.getLevel().getBlockEntity(data.tileEntity.getTargetPosition()); + FlapDisplayBlockEntity d = (FlapDisplayBlockEntity) data.blockEntity.getLevel().getBlockEntity(data.blockEntity.getTargetPosition()); d = d.getController(); return new Object[]{d.getLines().size()}; } diff --git a/src/main/java/de/saschat/createcomputing/peripherals/handles/RedstoneHandle.java b/src/main/java/de/saschat/createcomputing/peripherals/handles/RedstoneHandle.java index 8b40641..ccf2ea4 100644 --- a/src/main/java/de/saschat/createcomputing/peripherals/handles/RedstoneHandle.java +++ b/src/main/java/de/saschat/createcomputing/peripherals/handles/RedstoneHandle.java @@ -1,5 +1,6 @@ package de.saschat.createcomputing.peripherals.handles; +import com.simibubi.create.foundation.utility.RegisteredObjects; import dan200.computercraft.api.lua.IArguments; import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.lua.LuaFunction; @@ -37,14 +38,13 @@ public ComputerizedRedstoneLinkTile.LinkPair getHandle() throws LuaException { return linkPair; } - @LuaFunction(mainThread = true) + @LuaFunction(mainThread = false) public final void setSignal(IArguments arguments) throws LuaException { isOpen(); int value = arguments.getInt(0); - System.out.println("sx: " + value); getHandle().provideSignal(value); } - @LuaFunction(mainThread = true) + @LuaFunction(mainThread = false) public final int getSignal(IArguments arguments) throws LuaException { isOpen(); return getHandle().retrieveSignal(); @@ -53,7 +53,7 @@ public final int getSignal(IArguments arguments) throws LuaException { public final String getId() throws LuaException { return this.handle.toString(); } - @LuaFunction(mainThread = true) + @LuaFunction(mainThread = false) public final void setItems(IArguments arguments) throws LuaException { isOpen(); String _item1 = arguments.getString(0); @@ -70,9 +70,9 @@ public final void setItems(IArguments arguments) throws LuaException { throw new LuaException(_item2 + " is banned from the Computerized Redstone Link! This can be changed in the config."); getHandle().setFrequency(new Item[] {item1, item2}); } - @LuaFunction(mainThread = true) + @LuaFunction(mainThread = false) public final String[] getItems(IArguments arguments) throws LuaException { - return Arrays.stream(getHandle().items).map(a -> a.getRegistryName().toString()).collect(Collectors.toList()).toArray(new String[0]); + return Arrays.stream(getHandle().items).map(a -> RegisteredObjects.getKeyOrThrow(a.asItem())).collect(Collectors.toList()).toArray(new String[0]); } @LuaFunction public final void close() { diff --git a/src/main/java/de/saschat/createcomputing/tiles/ComputerizedDisplaySourceTile.java b/src/main/java/de/saschat/createcomputing/tiles/ComputerizedDisplaySourceTile.java index cb104a1..8f83179 100644 --- a/src/main/java/de/saschat/createcomputing/tiles/ComputerizedDisplaySourceTile.java +++ b/src/main/java/de/saschat/createcomputing/tiles/ComputerizedDisplaySourceTile.java @@ -1,7 +1,8 @@ package de.saschat.createcomputing.tiles; import com.simibubi.create.AllBlocks; -import com.simibubi.create.content.logistics.block.display.DisplayLinkTileEntity; +import com.simibubi.create.content.redstone.displayLink.DisplayLinkBlock; +import com.simibubi.create.content.redstone.displayLink.DisplayLinkBlockEntity; import dan200.computercraft.shared.Capabilities; import de.saschat.createcomputing.Registries; import de.saschat.createcomputing.blocks.ComputerizedDisplaySourceBlock; @@ -10,7 +11,6 @@ import net.minecraft.core.Direction; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; -import net.minecraft.network.chat.TextComponent; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; @@ -41,10 +41,10 @@ public DisplayData getFromPos(BlockPos pos) { } public static class DisplayData { - public DisplayLinkTileEntity tileEntity; + public DisplayLinkBlockEntity blockEntity; public List toDisplay = new ArrayList<>(); - public DisplayData(DisplayLinkTileEntity te) { - this.tileEntity = te; + public DisplayData(DisplayLinkBlockEntity be) { + this.blockEntity = be; } } @@ -72,7 +72,7 @@ public void onNeighborChange(BlockState state, LevelReader level, BlockPos pos, BlockPos location = pos.relative(dir); BlockState blockState = level.getBlockState(location); if (blockState.is(AllBlocks.DISPLAY_LINK.get())) { - display_links.put(dir, new DisplayData((DisplayLinkTileEntity) level.getBlockEntity(location))); + display_links.put(dir, new DisplayData((DisplayLinkBlockEntity) level.getBlockEntity(location))); addLink(dir); } else { if (display_links.containsKey(dir)) { diff --git a/src/main/java/de/saschat/createcomputing/tiles/ComputerizedDisplayTargetTile.java b/src/main/java/de/saschat/createcomputing/tiles/ComputerizedDisplayTargetTile.java index 289ef3a..0807aa1 100644 --- a/src/main/java/de/saschat/createcomputing/tiles/ComputerizedDisplayTargetTile.java +++ b/src/main/java/de/saschat/createcomputing/tiles/ComputerizedDisplayTargetTile.java @@ -1,6 +1,6 @@ package de.saschat.createcomputing.tiles; -import com.simibubi.create.content.logistics.block.display.DisplayLinkContext; +import com.simibubi.create.content.redstone.displayLink.DisplayLinkContext; import dan200.computercraft.shared.Capabilities; import de.saschat.createcomputing.Registries; import de.saschat.createcomputing.blocks.ComputerizedDisplaySourceBlock; diff --git a/src/main/java/de/saschat/createcomputing/tiles/ComputerizedRedstoneLinkTile.java b/src/main/java/de/saschat/createcomputing/tiles/ComputerizedRedstoneLinkTile.java index 3e0ee02..6cd9056 100644 --- a/src/main/java/de/saschat/createcomputing/tiles/ComputerizedRedstoneLinkTile.java +++ b/src/main/java/de/saschat/createcomputing/tiles/ComputerizedRedstoneLinkTile.java @@ -1,10 +1,11 @@ package de.saschat.createcomputing.tiles; -import com.simibubi.create.content.logistics.block.redstone.RedstoneLinkFrequencySlot; -import com.simibubi.create.foundation.tileEntity.SmartTileEntity; -import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; -import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform; -import com.simibubi.create.foundation.tileEntity.behaviour.linked.LinkBehaviour; +import com.simibubi.create.content.redstone.link.RedstoneLinkFrequencySlot; +import com.simibubi.create.foundation.blockEntity.SmartBlockEntity; +import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour; +import com.simibubi.create.foundation.blockEntity.behaviour.ValueBoxTransform; +import com.simibubi.create.content.redstone.link.LinkBehaviour; +import com.simibubi.create.foundation.utility.RegisteredObjects; import dan200.computercraft.shared.Capabilities; import de.saschat.createcomputing.Registries; import de.saschat.createcomputing.Utils; @@ -27,7 +28,7 @@ import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.ConcurrentHashMap; -public class ComputerizedRedstoneLinkTile extends SmartTileEntity { +public class ComputerizedRedstoneLinkTile extends SmartBlockEntity { public ConcurrentHashMap pairs = new ConcurrentHashMap<>(); public List deferred = new LinkedList<>(); public Queue tasks = new ArrayBlockingQueue<>(32); @@ -74,13 +75,13 @@ public void addDeferred(LinkPair pair) { } public void remove(LinkPair pair) { - if (PERIPHERAL.isPresent()) - PERIPHERAL.resolve().get().killHandles(pair.index); + /*if (PERIPHERAL.isPresent()) + PERIPHERAL.resolve().get().removeHandle(pair.index);*/ pairs.remove(pair.index, pair); pair.sendSignal = 0; pair.transmit.notifySignalChange(); - pair.transmit.remove(); - pair.receive.remove(); + pair.transmit.unload(); + pair.receive.unload(); } @@ -115,7 +116,7 @@ protected void read(CompoundTag tag, boolean clientPacket) { } */ @Override - public void addBehavioursDeferred(List behaviours) { + public void addBehavioursDeferred(List behaviours) { super.addBehavioursDeferred(behaviours); for (LinkPair linkPair : deferred) { pairs.put(linkPair.index, linkPair); @@ -126,14 +127,14 @@ public void addBehavioursDeferred(List behaviours) { public static boolean checkItem(Item stack) { for (String loc : CreateComputingConfigServer.get().BANNED_LINK_ITEMS.get()) { - if (loc.equals(stack.getRegistryName().toString())) + if (loc.equals(RegisteredObjects.getKeyOrThrow(stack.asItem()).toString())) return false; } return true; } @Override - public void addBehaviours(List list) { + public void addBehaviours(List list) { } private static boolean firstRun = true; @@ -154,6 +155,7 @@ public static class LinkPair { public boolean registered = false; + public boolean dirty = false; public int sendSignal = 0; public int recvSignal = 0; ComputerizedRedstoneLinkTile parent; @@ -217,13 +219,17 @@ public int retrieveSignal() { private void dirty() { if (parent.getLevel().isClientSide()) return; + if (dirty) return; + dirty = true; parent.tasks.add(this::_dirty); parent.setChanged(); } private void _dirty() { + dirty = false; transmit.notifySignalChange(); receive.notifySignalChange(); + parent.setChanged(); } private void setSignal(int i) { diff --git a/src/main/java/de/saschat/createcomputing/tiles/TrainNetworkObserverTile.java b/src/main/java/de/saschat/createcomputing/tiles/TrainNetworkObserverTile.java index ebdc21d..bd049ce 100644 --- a/src/main/java/de/saschat/createcomputing/tiles/TrainNetworkObserverTile.java +++ b/src/main/java/de/saschat/createcomputing/tiles/TrainNetworkObserverTile.java @@ -1,14 +1,14 @@ package de.saschat.createcomputing.tiles; import com.simibubi.create.AllBlocks; -import com.simibubi.create.content.contraptions.components.structureMovement.ITransformableTE; -import com.simibubi.create.content.contraptions.components.structureMovement.StructureTransform; -import com.simibubi.create.content.logistics.trains.GraphLocation; -import com.simibubi.create.content.logistics.trains.TrackGraphHelper; -import com.simibubi.create.content.logistics.trains.management.edgePoint.EdgePointType; -import com.simibubi.create.content.logistics.trains.management.edgePoint.TrackTargetingBehaviour; -import com.simibubi.create.foundation.tileEntity.SmartTileEntity; -import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; +import com.simibubi.create.content.contraptions.ITransformableBlockEntity; +import com.simibubi.create.content.contraptions.StructureTransform; +import com.simibubi.create.content.trains.graph.TrackGraphLocation; +import com.simibubi.create.content.trains.graph.TrackGraphHelper; +import com.simibubi.create.content.trains.graph.EdgePointType; +import com.simibubi.create.content.trains.track.TrackTargetingBehaviour; +import com.simibubi.create.foundation.blockEntity.SmartBlockEntity; +import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour; import dan200.computercraft.shared.Capabilities; import de.saschat.createcomputing.CreateComputingMod; import de.saschat.createcomputing.Registries; @@ -26,15 +26,15 @@ import java.util.List; -public class TrainNetworkObserverTile extends SmartTileEntity implements ITransformableTE { +public class TrainNetworkObserverTile extends SmartBlockEntity implements ITransformableBlockEntity { public TrackTargetingBehaviour edgePoint; public static final EdgePointType NETWORK_OBSERVER = EdgePointType.register(new ResourceLocation( CreateComputingMod.MOD_ID, "network_observer" ), TrainNetworkObserver::new); - public GraphLocation getGraphLocation() { - GraphLocation l = null; + public TrackGraphLocation getGraphLocation() { + TrackGraphLocation l = null; if (edgePoint.getTargetBezier() != null) { l = TrackGraphHelper.getBezierGraphLocationAt(getLevel(), edgePoint.getGlobalPosition(), Direction.AxisDirection.POSITIVE, edgePoint.getTargetBezier()); } else { @@ -71,7 +71,7 @@ public void tick() { } @Override - public void addBehaviours(List behaviours) { + public void addBehaviours(List behaviours) { behaviours.add(edgePoint = new TrackTargetingBehaviour<>(this, NETWORK_OBSERVER)); } diff --git a/src/main/java/de/saschat/createcomputing/tiles/renderer/TrainNetworkObserverRenderer.java b/src/main/java/de/saschat/createcomputing/tiles/renderer/TrainNetworkObserverRenderer.java index 14eb986..11f9b46 100644 --- a/src/main/java/de/saschat/createcomputing/tiles/renderer/TrainNetworkObserverRenderer.java +++ b/src/main/java/de/saschat/createcomputing/tiles/renderer/TrainNetworkObserverRenderer.java @@ -1,10 +1,10 @@ package de.saschat.createcomputing.tiles.renderer; import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.content.logistics.trains.ITrackBlock; -import com.simibubi.create.content.logistics.trains.management.edgePoint.TrackTargetingBehaviour; -import com.simibubi.create.content.logistics.trains.management.edgePoint.TrackTargetingBehaviour.RenderedTrackOverlayType; -import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer; +import com.simibubi.create.content.trains.track.ITrackBlock; +import com.simibubi.create.content.trains.track.TrackTargetingBehaviour; +import com.simibubi.create.content.trains.track.TrackTargetingBehaviour.RenderedTrackOverlayType; +import com.simibubi.create.foundation.blockEntity.renderer.SmartBlockEntityRenderer; import de.saschat.createcomputing.behaviour.tile.TrainNetworkObserver; import de.saschat.createcomputing.tiles.TrainNetworkObserverTile; import net.minecraft.client.renderer.MultiBufferSource; @@ -14,7 +14,7 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; -public class TrainNetworkObserverRenderer extends SmartTileEntityRenderer { +public class TrainNetworkObserverRenderer extends SmartBlockEntityRenderer { public TrainNetworkObserverRenderer(BlockEntityRendererProvider.Context context) { super(context); diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index abdf37c..cdb18c4 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -44,7 +44,7 @@ modId = "forge" #mandatory # Does this dependency have to exist - if not, ordering below must be specified mandatory = true #mandatory # The version range of the dependency -versionRange = "[40,)" #mandatory +versionRange = "[47,)" #mandatory # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory ordering = "NONE" # Side this dependency is applied on - BOTH, CLIENT or SERVER @@ -54,13 +54,13 @@ side = "BOTH" modId = "minecraft" mandatory = true # This version range declares a minimum of the current minecraft version up to but not including the next major version -versionRange = "[1.18.2,1.19)" +versionRange = "[1.20.1]" ordering = "NONE" side = "BOTH" [[dependencies.createcomputing]] modId = "create" mandatory = true -versionRange = "[0.5.0c,)" +versionRange = "[0.5.1.f,)" [[dependencies.createcomputing]] modId = "computercraft" mandatory = true diff --git a/src/main/resources/assets/createcomputing/lang/zh_cn.json b/src/main/resources/assets/createcomputing/lang/zh_cn.json new file mode 100644 index 0000000..1beb6c7 --- /dev/null +++ b/src/main/resources/assets/createcomputing/lang/zh_cn.json @@ -0,0 +1,8 @@ +{ + "itemGroup.createcomputing.tab": "Create: Computing", + "createcomputing.display_source.computerized_display_source": "来自计算机的文本", + "block.createcomputing.computerized_display_source": "计算机化显示源", + "block.createcomputing.computerized_display_target": "计算机化显示目标", + "block.createcomputing.computerized_redstone_link": "计算机化无线红石信号终端", + "block.createcomputing.train_network_observer": "列车网络侦测器" +} diff --git a/src/main/resources/assets/createcomputing/models/block/computerized_display_source.json b/src/main/resources/assets/createcomputing/models/block/computerized_display_source.json index e9d5124..ecbdf55 100644 --- a/src/main/resources/assets/createcomputing/models/block/computerized_display_source.json +++ b/src/main/resources/assets/createcomputing/models/block/computerized_display_source.json @@ -1,11 +1,9 @@ { "credit": "Made with Blockbench", "textures": { - "0": "create:block/filtered_detector_front", - "1": "create:block/brass_casing_side", + "1": "create:block/threshold_switch_front", "2": "create:block/brass_casing", - "3": "create:block/brass_casing_inner", - "particle": "create:block/filtered_detector_front" + "particle": "create:block/threshold_switch_front" }, "elements": [ { @@ -13,12 +11,12 @@ "from": [2, 2, -1], "to": [14, 14, 1], "faces": { - "north": {"uv": [0, 0, 10, 10], "texture": "#0"}, - "east": {"uv": [0, 0, 1, 10], "texture": "#0"}, + "north": {"uv": [3, 3, 13, 13], "texture": "#1"}, + "east": {"uv": [5, 3, 3, 13], "texture": "#1"}, "south": {"uv": [0, 0, 1, 12], "texture": "#missing"}, - "west": {"uv": [0, 0, 1, 10], "texture": "#0"}, - "up": {"uv": [0, 0, 12, 1], "texture": "#0"}, - "down": {"uv": [0, 0, 12, 1], "texture": "#0"} + "west": {"uv": [13, 3, 11, 13], "texture": "#1"}, + "up": {"uv": [13, 3, 3, 5], "texture": "#1"}, + "down": {"uv": [13, 11, 3, 13], "texture": "#1"} } }, { @@ -26,10 +24,10 @@ "from": [0, 0, 0], "to": [16, 2, 16], "faces": { - "north": {"uv": [0, 0, 16, 2], "texture": "#1"}, - "east": {"uv": [0, 0, 16, 2], "texture": "#1"}, - "south": {"uv": [0, 0, 16, 2], "texture": "#1"}, - "west": {"uv": [0, 0, 16, 2], "texture": "#1"}, + "north": {"uv": [0, 2, 16, 0], "texture": "#2"}, + "east": {"uv": [0, 2, 16, 0], "texture": "#2"}, + "south": {"uv": [0, 2, 16, 0], "texture": "#2"}, + "west": {"uv": [0, 2, 16, 0], "texture": "#2"}, "up": {"uv": [0, 0, 16, 16], "texture": "#2"}, "down": {"uv": [0, 0, 16, 16], "texture": "#2"} } @@ -39,10 +37,10 @@ "from": [0, 14, 0], "to": [16, 16, 16], "faces": { - "north": {"uv": [0, 0, 16, 2], "texture": "#1"}, - "east": {"uv": [0, 0, 16, 2], "texture": "#1"}, - "south": {"uv": [0, 0, 16, 2], "texture": "#1"}, - "west": {"uv": [0, 0, 16, 2], "texture": "#1"}, + "north": {"uv": [0, 0, 16, 2], "texture": "#2"}, + "east": {"uv": [0, 0, 16, 2], "texture": "#2"}, + "south": {"uv": [0, 0, 16, 2], "texture": "#2"}, + "west": {"uv": [0, 0, 16, 2], "texture": "#2"}, "up": {"uv": [0, 0, 16, 16], "texture": "#2"}, "down": {"uv": [0, 0, 16, 16], "texture": "#2"} } @@ -52,10 +50,10 @@ "from": [1, 2, 1], "to": [15, 14, 15], "faces": { - "north": {"uv": [0, 0, 14, 12], "texture": "#3"}, - "east": {"uv": [0, 0, 14, 12], "texture": "#3"}, - "south": {"uv": [0, 0, 14, 12], "texture": "#3"}, - "west": {"uv": [0, 0, 14, 12], "texture": "#3"}, + "north": {"uv": [1, 2, 15, 14], "texture": "#2"}, + "east": {"uv": [1, 2, 15, 14], "texture": "#2"}, + "south": {"uv": [1, 2, 15, 14], "texture": "#2"}, + "west": {"uv": [1, 2, 15, 14], "texture": "#2"}, "up": {"uv": [0, 0, 14, 14], "texture": "#missing"}, "down": {"uv": [0, 0, 14, 14], "texture": "#missing"} } @@ -97,8 +95,6 @@ "name": "VoxelShapes", "origin": [0, 0, 0], "color": 0, - "nbt": "{}", - "armAnimationEnabled": false, "children": [0, 1, 2, 3] } ] diff --git a/src/main/resources/assets/createcomputing/models/block/computerized_display_target.json b/src/main/resources/assets/createcomputing/models/block/computerized_display_target.json index bb72336..9237ae6 100644 --- a/src/main/resources/assets/createcomputing/models/block/computerized_display_target.json +++ b/src/main/resources/assets/createcomputing/models/block/computerized_display_target.json @@ -1,11 +1,11 @@ { "credit": "Made with Blockbench", "textures": { - "0": "create:block/filtered_detector_front", "1": "create:block/brass_casing", "3": "createcomputing:block/brass_casing_slab", "4": "create:block/redstone_antenna", - "particle": "create:block/filtered_detector_front" + "5": "create:block/threshold_switch_front", + "particle": "create:block/threshold_switch_front" }, "elements": [ { @@ -52,12 +52,12 @@ "from": [2, 2, -2], "to": [14, 14, 0], "faces": { - "north": {"uv": [0, 0, 10, 10], "texture": "#0"}, - "east": {"uv": [0, 0, 1, 10], "texture": "#0"}, - "south": {"uv": [0, 0, 3, 3], "texture": "#0"}, - "west": {"uv": [0, 0, 1, 10], "texture": "#0"}, - "up": {"uv": [0, 0, 12, 1], "texture": "#0"}, - "down": {"uv": [0, 0, 12, 1], "texture": "#0"} + "north": {"uv": [3, 3, 13, 13], "texture": "#5"}, + "east": {"uv": [5, 3, 3, 13], "texture": "#5"}, + "south": {"uv": [0, 0, 3, 3], "texture": "#missing"}, + "west": {"uv": [13, 3, 11, 13], "texture": "#5"}, + "up": {"uv": [13, 3, 3, 5], "texture": "#5"}, + "down": {"uv": [13, 11, 3, 13], "texture": "#5"} } }, { @@ -112,8 +112,6 @@ "name": "VoxelShapes", "origin": [0, 0, 0], "color": 0, - "nbt": "{}", - "armAnimationEnabled": false, "children": [2, 3, 4] } ] diff --git a/src/main/resources/assets/createcomputing/models/block/computerized_redstone_link.json b/src/main/resources/assets/createcomputing/models/block/computerized_redstone_link.json index 7b537eb..5d1c3da 100644 --- a/src/main/resources/assets/createcomputing/models/block/computerized_redstone_link.json +++ b/src/main/resources/assets/createcomputing/models/block/computerized_redstone_link.json @@ -1,11 +1,9 @@ { "credit": "Made with Blockbench", "textures": { - "1": "create:block/brass_casing_side", - "2": "create:block/brass_casing", "3": "create:block/redstone_antenna_powered", - "4": "create:block/filtered_detector_front", - "particle": "create:block/brass_casing_inner" + "5": "create:block/brass_casing", + "6": "create:block/threshold_switch_front" }, "elements": [ { @@ -25,12 +23,12 @@ "from": [2, -1, 2], "to": [14, 0, 14], "faces": { - "north": {"uv": [0, 0, 12, 1], "texture": "#4"}, - "east": {"uv": [0, 0, 12, 1], "texture": "#4"}, - "south": {"uv": [0, 0, 12, 1], "texture": "#4"}, - "west": {"uv": [0, 0, 12, 1], "texture": "#4"}, + "north": {"uv": [2, 15, 14, 16], "texture": "#5"}, + "east": {"uv": [2, 15, 14, 16], "texture": "#5"}, + "south": {"uv": [2, 15, 14, 16], "texture": "#5"}, + "west": {"uv": [2, 15, 14, 16], "texture": "#5"}, "up": {"uv": [0, 0, 12, 12], "texture": "#missing"}, - "down": {"uv": [0, 0, 10, 10], "texture": "#4"} + "down": {"uv": [3, 3, 13, 13], "texture": "#6"} } }, { @@ -64,12 +62,12 @@ "from": [1, 0, 1], "to": [15, 2, 15], "faces": { - "north": {"uv": [0, 0, 14, 2], "texture": "#1"}, - "east": {"uv": [0, 0, 14, 2], "texture": "#1"}, - "south": {"uv": [0, 0, 14, 2], "texture": "#1"}, - "west": {"uv": [0, 0, 14, 2], "texture": "#1"}, - "up": {"uv": [1, 1, 15, 15], "texture": "#2"}, - "down": {"uv": [1, 1, 15, 15], "texture": "#2"} + "north": {"uv": [0, 0, 14, 2], "texture": "#5"}, + "east": {"uv": [0, 0, 14, 2], "texture": "#5"}, + "south": {"uv": [0, 0, 14, 2], "texture": "#5"}, + "west": {"uv": [0, 0, 14, 2], "texture": "#5"}, + "up": {"uv": [1, 1, 15, 15], "texture": "#5"}, + "down": {"uv": [1, 1, 15, 15], "texture": "#5"} } } ], @@ -109,24 +107,18 @@ "name": "antenna 1", "origin": [0, 0, 0], "color": 0, - "nbt": "{}", - "armAnimationEnabled": false, "children": [0, 1] }, { "name": "antenna 1", "origin": [0, 0, 0], "color": 0, - "nbt": "{}", - "armAnimationEnabled": false, "children": [2, 3] }, { "name": "VoxelShapes", "origin": [0, 0, 0], "color": 0, - "nbt": "{}", - "armAnimationEnabled": false, "children": [4] } ] diff --git a/src/main/resources/assets/createcomputing/models/block/train_network_observer.json b/src/main/resources/assets/createcomputing/models/block/train_network_observer.json index 7f872f7..a645520 100644 --- a/src/main/resources/assets/createcomputing/models/block/train_network_observer.json +++ b/src/main/resources/assets/createcomputing/models/block/train_network_observer.json @@ -3,7 +3,7 @@ "textures": { "0": "create:block/signal_box_top", "1": "createcomputing:block/train_network_observer_side", - "2": "create:block/filtered_detector_front", + "3": "create:block/threshold_switch_front", "particle": "create:block/signal_box_top" }, "elements": [ @@ -12,11 +12,11 @@ "from": [2, 15, 2], "to": [14, 17, 14], "faces": { - "north": {"uv": [10, 0, 12, 10], "rotation": 90, "texture": "#2"}, - "east": {"uv": [10, 0, 12, 10], "rotation": 90, "texture": "#2"}, - "south": {"uv": [10, 0, 12, 10], "rotation": 90, "texture": "#2"}, - "west": {"uv": [10, 0, 12, 10], "rotation": 90, "texture": "#2"}, - "up": {"uv": [0, 0, 10, 10], "texture": "#2"}, + "north": {"uv": [3, 3, 5, 13], "rotation": 90, "texture": "#3"}, + "east": {"uv": [3, 3, 5, 13], "rotation": 90, "texture": "#3"}, + "south": {"uv": [3, 3, 5, 13], "rotation": 90, "texture": "#3"}, + "west": {"uv": [3, 3, 5, 13], "rotation": 90, "texture": "#3"}, + "up": {"uv": [3, 3, 13, 13], "texture": "#3"}, "down": {"uv": [0, 0, 12, 12], "texture": "#missing"} } }, @@ -30,7 +30,7 @@ "south": {"uv": [0, 14, 16, 16], "texture": "#1"}, "west": {"uv": [0, 14, 16, 16], "texture": "#1"}, "up": {"uv": [0, 0, 16, 16], "texture": "#0"}, - "down": {"uv": [0, 0, 16, 16], "texture": "#missing"} + "down": {"uv": [0, 0, 16, 16], "texture": "#0"} } }, { @@ -148,8 +148,6 @@ "name": "VoxelShapes", "origin": [0, 0, 0], "color": 0, - "nbt": "{}", - "armAnimationEnabled": false, "children": [] }, 0,