Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.20.1 #2

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
26 changes: 18 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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')

Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
11 changes: 6 additions & 5 deletions src/main/java/de/saschat/createcomputing/Behaviours.java
Original file line number Diff line number Diff line change
@@ -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())
);
}
}
71 changes: 29 additions & 42 deletions src/main/java/de/saschat/createcomputing/Registries.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -37,8 +38,9 @@
public class Registries {
public static DeferredRegister<Item> ITEM_REGISTRY = DeferredRegister.create(ForgeRegistries.ITEMS, CreateComputingMod.MOD_ID);
public static DeferredRegister<Block> BLOCK_REGISTRY = DeferredRegister.create(ForgeRegistries.BLOCKS, CreateComputingMod.MOD_ID);
public static DeferredRegister<BlockEntityType<?>> TILE_REGISTRY = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, CreateComputingMod.MOD_ID);
public static DeferredRegister<BlockEntityType<?>> TILE_REGISTRY = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, CreateComputingMod.MOD_ID);

private static final DeferredRegister<CreativeModeTab> TAB_REGISTERY =DeferredRegister.create(net.minecraft.core.registries.Registries.CREATIVE_MODE_TAB, CreateComputingMod.MOD_ID);
public static RegistryObject<Block> registerBlock(String name, Supplier<Block> blockSupplier) {
CreateComputingMod.LOGGER.info("Queuing block: " + name);
return BLOCK_REGISTRY.register(name, blockSupplier);
Expand All @@ -65,13 +67,6 @@ public static <T extends BlockEntity> RegistryObject<BlockEntityType<T>> 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<Block> COMPUTERIZED_DISPLAY_SOURCE = registerBlock(
"computerized_display_source",
Expand All @@ -80,7 +75,7 @@ public ItemStack makeIcon() {
public static RegistryObject<Item> COMPUTERIZED_DISPLAY_SOURCE_ITEM = registerBlockItem(
"computerized_display_source",
COMPUTERIZED_DISPLAY_SOURCE,
new Item.Properties().tab(TAB)
new Item.Properties()
);
public static RegistryObject<BlockEntityType<ComputerizedDisplaySourceTile>> COMPUTERIZED_DISPLAY_SOURCE_TILE = registerTile(
"computerized_display_source",
Expand All @@ -97,7 +92,7 @@ public ItemStack makeIcon() {
public static RegistryObject<Item> COMPUTERIZED_DISPLAY_TARGET_ITEM = registerBlockItem(
"computerized_display_target",
COMPUTERIZED_DISPLAY_TARGET,
new Item.Properties().tab(TAB)
new Item.Properties()
);
public static RegistryObject<BlockEntityType<ComputerizedDisplayTargetTile>> COMPUTERIZED_DISPLAY_TARGET_TILE = registerTile(
"computerized_display_target",
Expand All @@ -113,7 +108,7 @@ public ItemStack makeIcon() {
public static RegistryObject<Item> COMPUTERIZED_REDSTONE_LINK_ITEM = registerBlockItem(
"computerized_redstone_link",
COMPUTERIZED_REDSTONE_LINK,
new Item.Properties().tab(TAB)
new Item.Properties()
);
public static RegistryObject<BlockEntityType<ComputerizedRedstoneLinkTile>> COMPUTERIZED_REDSTONE_LINK_TILE = registerTile(
"computerized_redstone_link",
Expand All @@ -129,15 +124,29 @@ public ItemStack makeIcon() {
public static RegistryObject<Item> 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<BlockEntityType<TrainNetworkObserverTile>> TRAIN_NETWORK_OBSERVER_TILE = registerTile(
"train_network_observer",
TrainNetworkObserverTile::new,
TRAIN_NETWORK_OBSERVER
);

public static final RegistryObject<CreativeModeTab> 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 {
Expand All @@ -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<Couple<RedstoneLinkNetworkHandler.Frequency>, Set<IRedstoneLinkable>> 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.


}
3 changes: 2 additions & 1 deletion src/main/java/de/saschat/createcomputing/Utils.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<MutableComponent> 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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -11,13 +11,14 @@
public class TextPassBehaviour extends DisplayTarget {
@Override
public void acceptText(int line, List<MutableComponent> 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);
}
}
Original file line number Diff line number Diff line change
@@ -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 {

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
}

Expand Down
Loading