1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-09-28 07:08:20 +00:00

Use data generators in a few more places

As always, a massive diff which is largely just moving files between
projects. This does fix a couple of issues with advancements, but
otherwise should behave the same.

Speaking of which, should probably go and test some of these recipes...
This commit is contained in:
Jonathan Coates 2021-08-21 15:50:01 +01:00
parent cd8b8bbc74
commit 36a779dc18
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
127 changed files with 962 additions and 598 deletions

View File

@ -90,10 +90,11 @@ Before we get into writing tests, it's worth mentioning the various test suites
These tests are run by the '"Core" Java' test suite, and so are also run with `./gradlew test`. These tests are run by the '"Core" Java' test suite, and so are also run with `./gradlew test`.
- In-game (`./src/test/java/dan200/computercraft/ingame/`): These tests are run on an actual Minecraft server, using - In-game (`./src/testMod/java/dan200/computercraft/ingame/`): These tests are run on an actual Minecraft server and client,
[the same system Mojang do][mc-test]. The aim of these is to test in-game behaviour of blocks and peripherals. using [the same system Mojang do][mc-test]. The aim of these is to test in-game behaviour of blocks and peripherals.
These are run by `./gradlew testInGame`. These are run by `./gradlew testClient` and `./gradlew testServer`. You may want to run the client under `xvfb-run`
or similar when running in a headless environment.
## CraftOS tests ## CraftOS tests
CraftOS's tests are written using a test system called "mcfly", heavily inspired by [busted] (and thus RSpec). Groups of CraftOS's tests are written using a test system called "mcfly", heavily inspired by [busted] (and thus RSpec). Groups of

View File

@ -0,0 +1,19 @@
{
"variants": {
"facing=north": {
"model": "computercraft:block/speaker"
},
"facing=south": {
"model": "computercraft:block/speaker",
"y": 180
},
"facing=west": {
"model": "computercraft:block/speaker",
"y": 270
},
"facing=east": {
"model": "computercraft:block/speaker",
"y": 90
}
}
}

View File

@ -0,0 +1,19 @@
{
"variants": {
"facing=north": {
"model": "computercraft:block/turtle_advanced"
},
"facing=south": {
"model": "computercraft:block/turtle_advanced",
"y": 180
},
"facing=west": {
"model": "computercraft:block/turtle_advanced",
"y": 270
},
"facing=east": {
"model": "computercraft:block/turtle_advanced",
"y": 90
}
}
}

View File

@ -0,0 +1,19 @@
{
"variants": {
"facing=north": {
"model": "computercraft:block/turtle_normal"
},
"facing=south": {
"model": "computercraft:block/turtle_normal",
"y": 180
},
"facing=west": {
"model": "computercraft:block/turtle_normal",
"y": 270
},
"facing=east": {
"model": "computercraft:block/turtle_normal",
"y": 90
}
}
}

View File

@ -0,0 +1,16 @@
{
"variants": {
"modem=false,peripheral=false": {
"model": "computercraft:block/wired_modem_full_off"
},
"modem=true,peripheral=false": {
"model": "computercraft:block/wired_modem_full_on"
},
"modem=false,peripheral=true": {
"model": "computercraft:block/wired_modem_full_off_peripheral"
},
"modem=true,peripheral=true": {
"model": "computercraft:block/wired_modem_full_on_peripheral"
}
}
}

View File

@ -0,0 +1,54 @@
{
"variants": {
"facing=down,on=false": {
"model": "computercraft:block/wireless_modem_advanced_off",
"x": 90,
"y": 90
},
"facing=up,on=false": {
"model": "computercraft:block/wireless_modem_advanced_off",
"x": 270,
"y": 90
},
"facing=north,on=false": {
"model": "computercraft:block/wireless_modem_advanced_off"
},
"facing=south,on=false": {
"model": "computercraft:block/wireless_modem_advanced_off",
"y": 180
},
"facing=west,on=false": {
"model": "computercraft:block/wireless_modem_advanced_off",
"y": 270
},
"facing=east,on=false": {
"model": "computercraft:block/wireless_modem_advanced_off",
"y": 90
},
"facing=down,on=true": {
"model": "computercraft:block/wireless_modem_advanced_on",
"x": 90,
"y": 90
},
"facing=up,on=true": {
"model": "computercraft:block/wireless_modem_advanced_on",
"x": 270,
"y": 90
},
"facing=north,on=true": {
"model": "computercraft:block/wireless_modem_advanced_on"
},
"facing=south,on=true": {
"model": "computercraft:block/wireless_modem_advanced_on",
"y": 180
},
"facing=west,on=true": {
"model": "computercraft:block/wireless_modem_advanced_on",
"y": 270
},
"facing=east,on=true": {
"model": "computercraft:block/wireless_modem_advanced_on",
"y": 90
}
}
}

View File

@ -0,0 +1,54 @@
{
"variants": {
"facing=down,on=false": {
"model": "computercraft:block/wireless_modem_normal_off",
"x": 90,
"y": 90
},
"facing=up,on=false": {
"model": "computercraft:block/wireless_modem_normal_off",
"x": 270,
"y": 90
},
"facing=north,on=false": {
"model": "computercraft:block/wireless_modem_normal_off"
},
"facing=south,on=false": {
"model": "computercraft:block/wireless_modem_normal_off",
"y": 180
},
"facing=west,on=false": {
"model": "computercraft:block/wireless_modem_normal_off",
"y": 270
},
"facing=east,on=false": {
"model": "computercraft:block/wireless_modem_normal_off",
"y": 90
},
"facing=down,on=true": {
"model": "computercraft:block/wireless_modem_normal_on",
"x": 90,
"y": 90
},
"facing=up,on=true": {
"model": "computercraft:block/wireless_modem_normal_on",
"x": 270,
"y": 90
},
"facing=north,on=true": {
"model": "computercraft:block/wireless_modem_normal_on"
},
"facing=south,on=true": {
"model": "computercraft:block/wireless_modem_normal_on",
"y": 180
},
"facing=west,on=true": {
"model": "computercraft:block/wireless_modem_normal_on",
"y": 270
},
"facing=east,on=true": {
"model": "computercraft:block/wireless_modem_normal_on",
"y": 90
}
}
}

View File

@ -1,8 +1,8 @@
{ {
"parent": "block/orientable", "parent": "minecraft:block/orientable",
"textures": { "textures": {
"top": "computercraft:block/computer_advanced_top",
"side": "computercraft:block/computer_advanced_side", "side": "computercraft:block/computer_advanced_side",
"front": "computercraft:block/computer_advanced_front_blink" "front": "computercraft:block/computer_advanced_front_blink",
"top": "computercraft:block/computer_advanced_top"
} }
} }

View File

@ -1,8 +1,8 @@
{ {
"parent": "block/orientable", "parent": "minecraft:block/orientable",
"textures": { "textures": {
"top": "computercraft:block/computer_advanced_top",
"side": "computercraft:block/computer_advanced_side", "side": "computercraft:block/computer_advanced_side",
"front": "computercraft:block/computer_advanced_front" "front": "computercraft:block/computer_advanced_front",
"top": "computercraft:block/computer_advanced_top"
} }
} }

View File

@ -1,8 +1,8 @@
{ {
"parent": "block/orientable", "parent": "minecraft:block/orientable",
"textures": { "textures": {
"top": "computercraft:block/computer_advanced_top",
"side": "computercraft:block/computer_advanced_side", "side": "computercraft:block/computer_advanced_side",
"front": "computercraft:block/computer_advanced_front_on" "front": "computercraft:block/computer_advanced_front_on",
"top": "computercraft:block/computer_advanced_top"
} }
} }

View File

@ -1,8 +1,8 @@
{ {
"parent": "block/orientable", "parent": "minecraft:block/orientable",
"textures": { "textures": {
"top": "computercraft:block/computer_command_top",
"side": "computercraft:block/computer_command_side", "side": "computercraft:block/computer_command_side",
"front": "computercraft:block/computer_command_front_blink" "front": "computercraft:block/computer_command_front_blink",
"top": "computercraft:block/computer_command_top"
} }
} }

View File

@ -1,8 +1,8 @@
{ {
"parent": "block/orientable", "parent": "minecraft:block/orientable",
"textures": { "textures": {
"top": "computercraft:block/computer_command_top",
"side": "computercraft:block/computer_command_side", "side": "computercraft:block/computer_command_side",
"front": "computercraft:block/computer_command_front" "front": "computercraft:block/computer_command_front",
"top": "computercraft:block/computer_command_top"
} }
} }

View File

@ -1,8 +1,8 @@
{ {
"parent": "block/orientable", "parent": "minecraft:block/orientable",
"textures": { "textures": {
"top": "computercraft:block/computer_command_top",
"side": "computercraft:block/computer_command_side", "side": "computercraft:block/computer_command_side",
"front": "computercraft:block/computer_command_front_on" "front": "computercraft:block/computer_command_front_on",
"top": "computercraft:block/computer_command_top"
} }
} }

View File

@ -1,8 +1,8 @@
{ {
"parent": "block/orientable", "parent": "minecraft:block/orientable",
"textures": { "textures": {
"top": "computercraft:block/computer_normal_top",
"side": "computercraft:block/computer_normal_side", "side": "computercraft:block/computer_normal_side",
"front": "computercraft:block/computer_normal_front_blink" "front": "computercraft:block/computer_normal_front_blink",
"top": "computercraft:block/computer_normal_top"
} }
} }

View File

@ -1,8 +1,8 @@
{ {
"parent": "block/orientable", "parent": "minecraft:block/orientable",
"textures": { "textures": {
"top": "computercraft:block/computer_normal_top",
"side": "computercraft:block/computer_normal_side", "side": "computercraft:block/computer_normal_side",
"front": "computercraft:block/computer_normal_front" "front": "computercraft:block/computer_normal_front",
"top": "computercraft:block/computer_normal_top"
} }
} }

View File

@ -1,8 +1,8 @@
{ {
"parent": "block/orientable", "parent": "minecraft:block/orientable",
"textures": { "textures": {
"top": "computercraft:block/computer_normal_top",
"side": "computercraft:block/computer_normal_side", "side": "computercraft:block/computer_normal_side",
"front": "computercraft:block/computer_normal_front_on" "front": "computercraft:block/computer_normal_front_on",
"top": "computercraft:block/computer_normal_top"
} }
} }

View File

@ -0,0 +1,8 @@
{
"parent": "minecraft:block/orientable",
"textures": {
"side": "computercraft:block/monitor_advanced_4",
"front": "computercraft:block/monitor_advanced_15",
"top": "computercraft:block/monitor_advanced_0"
}
}

View File

@ -0,0 +1,8 @@
{
"parent": "minecraft:block/orientable",
"textures": {
"side": "computercraft:block/monitor_normal_4",
"front": "computercraft:block/monitor_normal_15",
"top": "computercraft:block/monitor_normal_0"
}
}

View File

@ -0,0 +1,8 @@
{
"parent": "minecraft:block/orientable",
"textures": {
"side": "computercraft:block/speaker_side",
"front": "computercraft:block/speaker_front",
"top": "computercraft:block/speaker_top"
}
}

View File

@ -0,0 +1,4 @@
{
"loader": "computercraft:turtle",
"model": "computercraft:block/turtle_advanced_base"
}

View File

@ -0,0 +1,6 @@
{
"parent": "computercraft:block/turtle_base",
"textures": {
"texture": "computercraft:block/turtle_advanced"
}
}

View File

@ -0,0 +1,4 @@
{
"loader": "computercraft:turtle",
"model": "computercraft:block/turtle_normal_base"
}

View File

@ -0,0 +1,6 @@
{
"parent": "computercraft:block/turtle_base",
"textures": {
"texture": "computercraft:block/turtle_normal"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "computercraft:block/wired_modem_face"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "computercraft:block/wired_modem_face_peripheral"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "computercraft:block/wired_modem_face_on"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "computercraft:block/wired_modem_face_peripheral_on"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "computercraft:block/modem",
"textures": {
"front": "computercraft:block/wired_modem_face",
"back": "computercraft:block/modem_back"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "computercraft:block/modem",
"textures": {
"front": "computercraft:block/wired_modem_face_peripheral",
"back": "computercraft:block/modem_back"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "computercraft:block/modem",
"textures": {
"front": "computercraft:block/wired_modem_face_on",
"back": "computercraft:block/modem_back"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "computercraft:block/modem",
"textures": {
"front": "computercraft:block/wired_modem_face_peripheral_on",
"back": "computercraft:block/modem_back"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "computercraft:block/modem",
"textures": {
"front": "computercraft:block/wireless_modem_advanced_face",
"back": "computercraft:block/modem_back"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "computercraft:block/modem",
"textures": {
"front": "computercraft:block/wireless_modem_advanced_face_on",
"back": "computercraft:block/modem_back"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "computercraft:block/modem",
"textures": {
"front": "computercraft:block/wireless_modem_normal_face",
"back": "computercraft:block/modem_back"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "computercraft:block/modem",
"textures": {
"front": "computercraft:block/wireless_modem_normal_face_on",
"back": "computercraft:block/modem_back"
}
}

View File

@ -0,0 +1,3 @@
{
"parent": "computercraft:block/computer_advanced_blinking"
}

View File

@ -0,0 +1,3 @@
{
"parent": "computercraft:block/computer_command_blinking"
}

View File

@ -0,0 +1,3 @@
{
"parent": "computercraft:block/computer_normal_blinking"
}

View File

@ -0,0 +1,3 @@
{
"parent": "computercraft:block/monitor_advanced_item"
}

View File

@ -0,0 +1,3 @@
{
"parent": "computercraft:block/monitor_normal_item"
}

View File

@ -0,0 +1,3 @@
{
"parent": "computercraft:block/speaker"
}

View File

@ -0,0 +1,3 @@
{
"parent": "computercraft:block/turtle_advanced"
}

View File

@ -0,0 +1,3 @@
{
"parent": "computercraft:block/turtle_normal"
}

View File

@ -0,0 +1,3 @@
{
"parent": "computercraft:block/wired_modem_off"
}

View File

@ -0,0 +1,3 @@
{
"parent": "computercraft:block/wired_modem_full_off"
}

View File

@ -0,0 +1,3 @@
{
"parent": "computercraft:block/wireless_modem_advanced_off"
}

View File

@ -0,0 +1,3 @@
{
"parent": "computercraft:block/wireless_modem_normal_off"
}

View File

@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"computercraft:printed_book"
]
},
"criteria": {
"has_printer": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "computercraft:printer"
}
]
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "computercraft:printed_book"
}
}
},
"requirements": [
[
"has_printer",
"has_the_recipe"
]
]
}

View File

@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"computercraft:printed_pages"
]
},
"criteria": {
"has_printer": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "computercraft:printer"
}
]
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "computercraft:printed_pages"
}
}
},
"requirements": [
[
"has_printer",
"has_the_recipe"
]
]
}

View File

@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"computercraft:skull_cloudy"
]
},
"criteria": {
"has_monitor": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "computercraft:monitor_normal"
}
]
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "computercraft:skull_cloudy"
}
}
},
"requirements": [
[
"has_monitor",
"has_the_recipe"
]
]
}

View File

@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"computercraft:skull_dan200"
]
},
"criteria": {
"has_computer": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "computercraft:computer_advanced"
}
]
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "computercraft:skull_dan200"
}
}
},
"requirements": [
[
"has_computer",
"has_the_recipe"
]
]
}

View File

@ -0,0 +1,52 @@
{
"type": "minecraft:block",
"pools": [
{
"name": "cable",
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "computercraft:cable"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
},
{
"condition": "minecraft:block_state_property",
"block": "computercraft:cable",
"properties": {
"cable": "true"
}
}
]
},
{
"name": "wired_modem",
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "computercraft:wired_modem"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
},
{
"condition": "minecraft:inverted",
"term": {
"condition": "minecraft:block_state_property",
"block": "computercraft:cable",
"properties": {
"modem": "none"
}
}
}
]
}
]
}

View File

@ -0,0 +1,3 @@
{
"type": "computercraft:colour"
}

View File

@ -0,0 +1,3 @@
{
"type": "computercraft:disk"
}

View File

@ -0,0 +1,3 @@
{
"type": "computercraft:pocket_computer_upgrade"
}

View File

@ -0,0 +1,17 @@
{
"type": "computercraft:impostor_shapeless",
"ingredients": [
{
"tag": "forge:leather"
},
{
"item": "computercraft:printed_page"
},
{
"tag": "forge:string"
}
],
"result": {
"item": "computercraft:printed_book"
}
}

View File

@ -0,0 +1,17 @@
{
"type": "computercraft:impostor_shapeless",
"ingredients": [
{
"item": "computercraft:printed_page"
},
{
"item": "computercraft:printed_page"
},
{
"tag": "forge:string"
}
],
"result": {
"item": "computercraft:printed_pages"
}
}

View File

@ -0,0 +1,3 @@
{
"type": "computercraft:printout"
}

View File

@ -0,0 +1,15 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{
"tag": "forge:heads"
},
{
"item": "computercraft:monitor_normal"
}
],
"result": {
"item": "minecraft:player_head",
"nbt": "{SkullOwner:{Id:\"6d074736-b1e9-4378-a99b-bd8777821c9c\",Name:\"Cloudhunter\"}}"
}
}

View File

@ -0,0 +1,15 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{
"tag": "forge:heads"
},
{
"item": "computercraft:computer_advanced"
}
],
"result": {
"item": "minecraft:player_head",
"nbt": "{SkullOwner:{Id:\"f3c8d69b-0776-4512-8434-d1b2165909eb\",Name:\"dan200\"}}"
}
}

View File

@ -0,0 +1,3 @@
{
"type": "computercraft:turtle_upgrade"
}

View File

@ -0,0 +1,44 @@
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2021. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
*/
package dan200.computercraft.data;
import com.google.gson.JsonObject;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.generators.CustomLoaderBuilder;
import net.minecraftforge.client.model.generators.ModelBuilder;
import net.minecraftforge.common.data.ExistingFileHelper;
import java.util.function.BiFunction;
import java.util.function.Consumer;
public class BasicCustomLoader<T extends ModelBuilder<T>> extends CustomLoaderBuilder<T>
{
private final Consumer<JsonObject> extra;
protected BasicCustomLoader( ResourceLocation loaderId, T parent, ExistingFileHelper existingFileHelper, Consumer<JsonObject> extra )
{
super( loaderId, parent, existingFileHelper );
this.extra = extra;
}
public static <T extends ModelBuilder<T>> BiFunction<T, ExistingFileHelper, CustomLoaderBuilder<T>> makeFactory( ResourceLocation id )
{
return makeFactory( id, j -> { } );
}
public static <T extends ModelBuilder<T>> BiFunction<T, ExistingFileHelper, CustomLoaderBuilder<T>> makeFactory( ResourceLocation id, Consumer<JsonObject> extra )
{
return ( parent, x ) -> new BasicCustomLoader<>( id, parent, x, extra );
}
@Override
public JsonObject toJson( JsonObject json )
{
super.toJson( json );
extra.accept( json );
return json;
}
}

View File

@ -9,21 +9,27 @@ import dan200.computercraft.ComputerCraft;
import dan200.computercraft.shared.Registry; import dan200.computercraft.shared.Registry;
import dan200.computercraft.shared.computer.blocks.BlockComputer; import dan200.computercraft.shared.computer.blocks.BlockComputer;
import dan200.computercraft.shared.computer.core.ComputerState; import dan200.computercraft.shared.computer.core.ComputerState;
import dan200.computercraft.shared.peripheral.modem.wired.BlockWiredModemFull;
import dan200.computercraft.shared.peripheral.modem.wireless.BlockWirelessModem;
import dan200.computercraft.shared.peripheral.monitor.BlockMonitor; import dan200.computercraft.shared.peripheral.monitor.BlockMonitor;
import dan200.computercraft.shared.peripheral.monitor.MonitorEdgeState; import dan200.computercraft.shared.peripheral.monitor.MonitorEdgeState;
import dan200.computercraft.shared.turtle.blocks.BlockTurtle;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.data.DataGenerator; import net.minecraft.data.DataGenerator;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.generators.*; import net.minecraftforge.client.model.generators.*;
import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.registries.IForgeRegistryEntry;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.Objects;
public class BlockModelProvider extends BlockStateProvider public class BlockModelProvider extends BlockStateProvider
{ {
private ModelFile monitorBase; private ModelFile monitorBase;
private ModelFile orientable; private ModelFile turtleBase;
private ModelFile modemBase;
public BlockModelProvider( DataGenerator generator, ExistingFileHelper existingFileHelper ) public BlockModelProvider( DataGenerator generator, ExistingFileHelper existingFileHelper )
{ {
@ -41,14 +47,33 @@ public class BlockModelProvider extends BlockStateProvider
protected void registerStatesAndModels() protected void registerStatesAndModels()
{ {
monitorBase = models().getExistingFile( new ResourceLocation( ComputerCraft.MOD_ID, "block/monitor_base" ) ); monitorBase = models().getExistingFile( new ResourceLocation( ComputerCraft.MOD_ID, "block/monitor_base" ) );
orientable = models().getExistingFile( new ResourceLocation( "block/orientable" ) ); turtleBase = models().getExistingFile( new ResourceLocation( ComputerCraft.MOD_ID, "block/turtle_base" ) );
modemBase = models().getExistingFile( new ResourceLocation( ComputerCraft.MOD_ID, "block/modem" ) );
registerMonitors( Registry.ModBlocks.MONITOR_NORMAL.get() );
registerMonitors( Registry.ModBlocks.MONITOR_ADVANCED.get() );
registerComputer( Registry.ModBlocks.COMPUTER_NORMAL.get() ); registerComputer( Registry.ModBlocks.COMPUTER_NORMAL.get() );
registerComputer( Registry.ModBlocks.COMPUTER_ADVANCED.get() ); registerComputer( Registry.ModBlocks.COMPUTER_ADVANCED.get() );
registerComputer( Registry.ModBlocks.COMPUTER_COMMAND.get() ); registerComputer( Registry.ModBlocks.COMPUTER_COMMAND.get() );
registerTurtle( Registry.ModBlocks.TURTLE_NORMAL.get() );
registerTurtle( Registry.ModBlocks.TURTLE_ADVANCED.get() );
registerWirelessModem( Registry.ModBlocks.WIRELESS_MODEM_NORMAL.get() );
registerWirelessModem( Registry.ModBlocks.WIRELESS_MODEM_ADVANCED.get() );
registerWiredModems();
registerMonitors( Registry.ModBlocks.MONITOR_NORMAL.get() );
registerMonitors( Registry.ModBlocks.MONITOR_ADVANCED.get() );
// Register the simple things.
ModelFile speaker = models().orientable(
name( Registry.ModBlocks.SPEAKER.get() ),
blockTexture( Registry.ModBlocks.SPEAKER.get(), "_side" ),
blockTexture( Registry.ModBlocks.SPEAKER.get(), "_front" ),
blockTexture( Registry.ModBlocks.SPEAKER.get(), "_top" )
);
horizontalBlock( Registry.ModBlocks.SPEAKER.get(), speaker );
simpleBlockItem( Registry.ModBlocks.SPEAKER.get(), speaker );
} }
private void registerComputer( BlockComputer block ) private void registerComputer( BlockComputer block )
@ -56,12 +81,12 @@ public class BlockModelProvider extends BlockStateProvider
VariantBlockStateBuilder builder = getVariantBuilder( block ); VariantBlockStateBuilder builder = getVariantBuilder( block );
for( ComputerState state : BlockComputer.STATE.getPossibleValues() ) for( ComputerState state : BlockComputer.STATE.getPossibleValues() )
{ {
BlockModelBuilder model = models() BlockModelBuilder model = models().orientable(
.getBuilder( suffix( block, "_" + state ) ) extendedName( block, "_" + state ),
.parent( orientable ) blockTexture( block, "_side" ),
.texture( "top", suffix( block, "_top" ) ) blockTexture( block, "_front" + state.getTexture() ),
.texture( "side", suffix( block, "_side" ) ) blockTexture( block, "_top" )
.texture( "front", suffix( block, "_front" + toSuffix( state ) ) ); );
for( Direction facing : BlockComputer.FACING.getPossibleValues() ) for( Direction facing : BlockComputer.FACING.getPossibleValues() )
{ {
@ -71,33 +96,118 @@ public class BlockModelProvider extends BlockStateProvider
.addModels( new ConfiguredModel( model, 0, toYAngle( facing ), false ) ); .addModels( new ConfiguredModel( model, 0, toYAngle( facing ), false ) );
} }
} }
simpleBlockItem( block, models().getBuilder( extendedName( block, "_blinking" ) ) );
}
private void registerTurtle( BlockTurtle block )
{
VariantBlockStateBuilder builder = getVariantBuilder( block );
BlockModelBuilder base = models()
.getBuilder( extendedName( block, "_base" ) )
.parent( turtleBase )
.texture( "texture", blockTexture( block ) );
BlockModelBuilder model = models()
.getBuilder( name( block ) )
.customLoader( BasicCustomLoader.makeFactory( new ResourceLocation( ComputerCraft.MOD_ID, "turtle" ), x -> {
x.addProperty( "model", base.getLocation().toString() );
} ) )
.end();
for( Direction facing : BlockTurtle.FACING.getPossibleValues() )
{
builder.partialState()
.with( BlockTurtle.FACING, facing )
.addModels( new ConfiguredModel( model, 0, toYAngle( facing ), false ) );
}
simpleBlockItem( block, models().getBuilder( name( block ) ) );
}
private void registerWirelessModem( BlockWirelessModem block )
{
VariantBlockStateBuilder builder = getVariantBuilder( block );
for( boolean on : BlockWirelessModem.ON.getPossibleValues() )
{
ModelFile model = modemModel( extendedName( block, on ? "_on" : "_off" ), blockTexture( block, "_face" + (on ? "_on" : "") ) );
for( Direction facing : BlockWirelessModem.FACING.getPossibleValues() )
{
builder.partialState()
.with( BlockWirelessModem.FACING, facing )
.with( BlockWirelessModem.ON, on )
.addModels( new ConfiguredModel( model, toXAngle( facing ), toYAngle( facing ), false ) );
}
}
simpleBlockItem( block, models().getBuilder( extendedName( block, "_off" ) ) );
}
private void registerWiredModems()
{
Block fullBlock = Registry.ModBlocks.WIRED_MODEM_FULL.get();
VariantBlockStateBuilder fullBlockState = getVariantBuilder( fullBlock );
for( boolean on : BlockWiredModemFull.MODEM_ON.getPossibleValues() )
{
for( boolean peripheral : BlockWiredModemFull.PERIPHERAL_ON.getPossibleValues() )
{
String suffix = (on ? "_on" : "_off") + (peripheral ? "_peripheral" : "");
ResourceLocation faceTexture = new ResourceLocation(
ComputerCraft.MOD_ID,
"block/wired_modem_face" + (peripheral ? "_peripheral" : "") + (on ? "_on" : "")
);
ModelFile fullBlockModel = models().cubeAll( blockTexture( fullBlock, suffix ).toString(), faceTexture );
fullBlockState.partialState()
.with( BlockWiredModemFull.MODEM_ON, on )
.with( BlockWiredModemFull.PERIPHERAL_ON, peripheral )
.addModels( new ConfiguredModel( fullBlockModel ) );
modemModel( "wired_modem" + suffix, faceTexture );
}
}
simpleBlockItem( fullBlock, models().getBuilder( extendedName( fullBlock, "_off" ) ) );
itemModels()
.getBuilder( name( Registry.ModItems.WIRED_MODEM.get() ) )
.parent( models().getBuilder( "wired_modem_off" ) );
}
private ModelFile modemModel( String name, ResourceLocation texture )
{
return models()
.getBuilder( name )
.parent( modemBase )
.texture( "front", texture )
.texture( "back", new ResourceLocation( ComputerCraft.MOD_ID, "block/modem_back" ) );
} }
private void registerMonitors( BlockMonitor block ) private void registerMonitors( BlockMonitor block )
{ {
String name = block.getRegistryName().getPath(); String name = blockTexture( block ).toString();
registerMonitorModel( name, "", 16, 4, 0, 32 ); monitorModel( name, "", 16, 4, 0, 32 );
registerMonitorModel( name, "_d", 20, 7, 0, 36 ); monitorModel( name, "_d", 20, 7, 0, 36 );
registerMonitorModel( name, "_l", 19, 4, 1, 33 ); monitorModel( name, "_l", 19, 4, 1, 33 );
registerMonitorModel( name, "_ld", 31, 7, 1, 45 ); monitorModel( name, "_ld", 31, 7, 1, 45 );
registerMonitorModel( name, "_lr", 18, 4, 2, 34 ); monitorModel( name, "_lr", 18, 4, 2, 34 );
registerMonitorModel( name, "_lrd", 30, 7, 2, 46 ); monitorModel( name, "_lrd", 30, 7, 2, 46 );
registerMonitorModel( name, "_lru", 24, 5, 2, 40 ); monitorModel( name, "_lru", 24, 5, 2, 40 );
registerMonitorModel( name, "_lrud", 27, 6, 2, 43 ); monitorModel( name, "_lrud", 27, 6, 2, 43 );
registerMonitorModel( name, "_lu", 25, 5, 1, 39 ); monitorModel( name, "_lu", 25, 5, 1, 39 );
registerMonitorModel( name, "_lud", 28, 6, 1, 42 ); monitorModel( name, "_lud", 28, 6, 1, 42 );
registerMonitorModel( name, "_r", 17, 4, 3, 35 ); monitorModel( name, "_r", 17, 4, 3, 35 );
registerMonitorModel( name, "_rd", 29, 7, 3, 47 ); monitorModel( name, "_rd", 29, 7, 3, 47 );
registerMonitorModel( name, "_ru", 23, 5, 3, 41 ); monitorModel( name, "_ru", 23, 5, 3, 41 );
registerMonitorModel( name, "_rud", 26, 6, 3, 44 ); monitorModel( name, "_rud", 26, 6, 3, 44 );
registerMonitorModel( name, "_u", 22, 5, 0, 38 ); monitorModel( name, "_u", 22, 5, 0, 38 );
registerMonitorModel( name, "_ud", 21, 6, 0, 37 ); monitorModel( name, "_ud", 21, 6, 0, 37 );
VariantBlockStateBuilder builder = getVariantBuilder( block ); VariantBlockStateBuilder builder = getVariantBuilder( block );
for( MonitorEdgeState edge : BlockMonitor.STATE.getPossibleValues() ) for( MonitorEdgeState edge : BlockMonitor.STATE.getPossibleValues() )
{ {
String suffix = edge == MonitorEdgeState.NONE ? "" : "_" + edge.getSerializedName(); String suffix = edge == MonitorEdgeState.NONE ? "" : "_" + edge.getSerializedName();
ModelFile model = models().getBuilder( suffix( block, suffix ) ); ModelFile model = models().getBuilder( extend( block.getRegistryName(), suffix ) );
for( Direction facing : BlockMonitor.FACING.getPossibleValues() ) for( Direction facing : BlockMonitor.FACING.getPossibleValues() )
{ {
@ -111,11 +221,18 @@ public class BlockModelProvider extends BlockStateProvider
} }
} }
} }
simpleBlockItem( block, models().orientable(
extendedName( block, "_item" ),
blockTexture( block, "_4" ),
blockTexture( block, "_15" ),
blockTexture( block, "_0" )
) );
} }
private void registerMonitorModel( String prefix, String corners, int front, int side, int top, int back ) private void monitorModel( String prefix, String corners, int front, int side, int top, int back )
{ {
String texturePrefix = ComputerCraft.MOD_ID + ":block/" + prefix + "_"; String texturePrefix = prefix + "_";
models().getBuilder( prefix + corners ) models().getBuilder( prefix + corners )
.parent( monitorBase ) .parent( monitorBase )
.texture( "front", texturePrefix + front ) .texture( "front", texturePrefix + front )
@ -142,23 +259,27 @@ public class BlockModelProvider extends BlockStateProvider
return ((int) direction.toYRot() + 180) % 360; return ((int) direction.toYRot() + 180) % 360;
} }
private static String toSuffix( ComputerState state ) private static ResourceLocation blockTexture( Block block, String suffix )
{
switch( state )
{
default:
case OFF:
return "";
case ON:
return "_on";
case BLINKING:
return "_blink";
}
}
private static String suffix( Block block, String suffix )
{ {
ResourceLocation id = block.getRegistryName(); ResourceLocation id = block.getRegistryName();
return new ResourceLocation( id.getNamespace(), "block/" + id.getPath() + suffix ).toString(); return new ResourceLocation( id.getNamespace(), "block/" + id.getPath() + suffix );
}
@Nonnull
private String name( @Nonnull IForgeRegistryEntry<?> term )
{
return Objects.requireNonNull( term.getRegistryName() ).toString();
}
@Nonnull
private String extendedName( @Nonnull IForgeRegistryEntry<?> term, @Nonnull String suffix )
{
return extend( Objects.requireNonNull( term.getRegistryName() ), suffix );
}
@Nonnull
private String extend( @Nonnull ResourceLocation location, @Nonnull String suffix )
{
return new ResourceLocation( location.getNamespace(), location.getPath() + suffix ).toString();
} }
} }

View File

@ -11,10 +11,14 @@ import dan200.computercraft.shared.Registry;
import dan200.computercraft.shared.data.BlockNamedEntityLootCondition; import dan200.computercraft.shared.data.BlockNamedEntityLootCondition;
import dan200.computercraft.shared.data.HasComputerIdLootCondition; import dan200.computercraft.shared.data.HasComputerIdLootCondition;
import dan200.computercraft.shared.data.PlayerCreativeLootCondition; import dan200.computercraft.shared.data.PlayerCreativeLootCondition;
import dan200.computercraft.shared.peripheral.modem.wired.BlockCable;
import dan200.computercraft.shared.peripheral.modem.wired.CableModemVariant;
import net.minecraft.advancements.criterion.StatePropertiesPredicate;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.data.DataGenerator; import net.minecraft.data.DataGenerator;
import net.minecraft.loot.*; import net.minecraft.loot.*;
import net.minecraft.loot.conditions.Alternative; import net.minecraft.loot.conditions.Alternative;
import net.minecraft.loot.conditions.BlockStateProperty;
import net.minecraft.loot.conditions.SurvivesExplosion; import net.minecraft.loot.conditions.SurvivesExplosion;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.fml.RegistryObject;
@ -46,6 +50,30 @@ public class LootTables extends LootTableProvider
computerDrop( add, Registry.ModBlocks.TURTLE_NORMAL ); computerDrop( add, Registry.ModBlocks.TURTLE_NORMAL );
computerDrop( add, Registry.ModBlocks.TURTLE_ADVANCED ); computerDrop( add, Registry.ModBlocks.TURTLE_ADVANCED );
add.accept( Registry.ModBlocks.CABLE.get().getLootTable(), LootTable
.lootTable()
.setParamSet( LootParameterSets.BLOCK )
.withPool( LootPool.lootPool()
.name( "cable" )
.setRolls( ConstantRange.exactly( 1 ) )
.add( ItemLootEntry.lootTableItem( Registry.ModItems.CABLE.get() ) )
.when( SurvivesExplosion.survivesExplosion() )
.when( BlockStateProperty.hasBlockStateProperties( Registry.ModBlocks.CABLE.get() )
.setProperties( StatePropertiesPredicate.Builder.properties().hasProperty( BlockCable.CABLE, true ) )
)
)
.withPool( LootPool.lootPool()
.name( "wired_modem" )
.setRolls( ConstantRange.exactly( 1 ) )
.add( ItemLootEntry.lootTableItem( Registry.ModItems.WIRED_MODEM.get() ) )
.when( SurvivesExplosion.survivesExplosion() )
.when( BlockStateProperty.hasBlockStateProperties( Registry.ModBlocks.CABLE.get() )
.setProperties( StatePropertiesPredicate.Builder.properties().hasProperty( BlockCable.MODEM, CableModemVariant.None ) )
.invert()
)
)
.build() );
add.accept( CommonHooks.LOOT_TREASURE_DISK, LootTable add.accept( CommonHooks.LOOT_TREASURE_DISK, LootTable
.lootTable() .lootTable()
.setParamSet( LootParameterSets.ALL_PARAMS ) .setParamSet( LootParameterSets.ALL_PARAMS )

View File

@ -10,10 +10,15 @@ import dan200.computercraft.data.Tags.CCTags;
import dan200.computercraft.shared.PocketUpgrades; import dan200.computercraft.shared.PocketUpgrades;
import dan200.computercraft.shared.Registry; import dan200.computercraft.shared.Registry;
import dan200.computercraft.shared.TurtleUpgrades; import dan200.computercraft.shared.TurtleUpgrades;
import dan200.computercraft.shared.common.ColourableRecipe;
import dan200.computercraft.shared.common.IColouredItem; import dan200.computercraft.shared.common.IColouredItem;
import dan200.computercraft.shared.computer.core.ComputerFamily; import dan200.computercraft.shared.computer.core.ComputerFamily;
import dan200.computercraft.shared.media.recipes.DiskRecipe;
import dan200.computercraft.shared.media.recipes.PrintoutRecipe;
import dan200.computercraft.shared.pocket.items.PocketComputerItemFactory; import dan200.computercraft.shared.pocket.items.PocketComputerItemFactory;
import dan200.computercraft.shared.pocket.recipes.PocketComputerUpgradeRecipe;
import dan200.computercraft.shared.turtle.items.TurtleItemFactory; import dan200.computercraft.shared.turtle.items.TurtleItemFactory;
import dan200.computercraft.shared.turtle.recipes.TurtleUpgradeRecipe;
import dan200.computercraft.shared.util.Colour; import dan200.computercraft.shared.util.Colour;
import dan200.computercraft.shared.util.ImpostorRecipe; import dan200.computercraft.shared.util.ImpostorRecipe;
import dan200.computercraft.shared.util.ImpostorShapelessRecipe; import dan200.computercraft.shared.util.ImpostorShapelessRecipe;
@ -22,6 +27,9 @@ import net.minecraft.advancements.criterion.ItemPredicate;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.data.*; import net.minecraft.data.*;
import net.minecraft.item.*; import net.minecraft.item.*;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.SpecialRecipeSerializer;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tags.ITag; import net.minecraft.tags.ITag;
import net.minecraft.util.IItemProvider; import net.minecraft.util.IItemProvider;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@ -45,6 +53,12 @@ public class Recipes extends RecipeProvider
diskColours( add ); diskColours( add );
pocketUpgrades( add ); pocketUpgrades( add );
turtleUpgrades( add ); turtleUpgrades( add );
addSpecial( add, PrintoutRecipe.SERIALIZER );
addSpecial( add, DiskRecipe.SERIALIZER );
addSpecial( add, ColourableRecipe.SERIALIZER );
addSpecial( add, TurtleUpgradeRecipe.SERIALIZER );
addSpecial( add, PocketComputerUpgradeRecipe.SERIALIZER );
} }
/** /**
@ -303,6 +317,41 @@ public class Recipes extends RecipeProvider
.unlockedBy( "has_computer", inventoryChange( CCTags.COMPUTER ) ) .unlockedBy( "has_computer", inventoryChange( CCTags.COMPUTER ) )
.unlockedBy( "has_wireless", inventoryChange( Registry.ModBlocks.WIRELESS_MODEM_NORMAL.get() ) ) .unlockedBy( "has_wireless", inventoryChange( Registry.ModBlocks.WIRELESS_MODEM_NORMAL.get() ) )
.save( add ); .save( add );
ShapelessRecipeBuilder
.shapeless( Items.PLAYER_HEAD )
.requires( Tags.Items.HEADS )
.requires( Registry.ModItems.MONITOR_NORMAL.get() )
.unlockedBy( "has_monitor", inventoryChange( Registry.ModItems.MONITOR_NORMAL.get() ) )
.save(
RecipeWrapper.wrap( IRecipeSerializer.SHAPELESS_RECIPE, add, playerHead( "Cloudhunter", "6d074736-b1e9-4378-a99b-bd8777821c9c" ) ),
new ResourceLocation( ComputerCraft.MOD_ID, "skull_cloudy" )
);
ShapelessRecipeBuilder
.shapeless( Items.PLAYER_HEAD )
.requires( Tags.Items.HEADS )
.requires( Registry.ModItems.COMPUTER_ADVANCED.get() )
.unlockedBy( "has_computer", inventoryChange( Registry.ModItems.COMPUTER_ADVANCED.get() ) )
.save(
RecipeWrapper.wrap( IRecipeSerializer.SHAPELESS_RECIPE, add, playerHead( "dan200", "f3c8d69b-0776-4512-8434-d1b2165909eb" ) ),
new ResourceLocation( ComputerCraft.MOD_ID, "skull_dan200" )
);
ShapelessRecipeBuilder
.shapeless( Registry.ModItems.PRINTED_PAGES.get() )
.requires( Registry.ModItems.PRINTED_PAGE.get(), 2 )
.requires( Tags.Items.STRING )
.unlockedBy( "has_printer", inventoryChange( Registry.ModBlocks.PRINTER.get() ) )
.save( RecipeWrapper.wrap( ImpostorShapelessRecipe.SERIALIZER, add ) );
ShapelessRecipeBuilder
.shapeless( Registry.ModItems.PRINTED_BOOK.get() )
.requires( Tags.Items.LEATHER )
.requires( Registry.ModItems.PRINTED_PAGE.get(), 1 )
.requires( Tags.Items.STRING )
.unlockedBy( "has_printer", inventoryChange( Registry.ModBlocks.PRINTER.get() ) )
.save( RecipeWrapper.wrap( ImpostorShapelessRecipe.SERIALIZER, add ) );
} }
private static DyeColor ofColour( Colour colour ) private static DyeColor ofColour( Colour colour )
@ -319,4 +368,20 @@ public class Recipes extends RecipeProvider
{ {
return InventoryChangeTrigger.Instance.hasItems( stack ); return InventoryChangeTrigger.Instance.hasItems( stack );
} }
private static CompoundNBT playerHead( String name, String uuid )
{
CompoundNBT owner = new CompoundNBT();
owner.putString( "Name", name );
owner.putString( "Id", uuid );
CompoundNBT tag = new CompoundNBT();
tag.put( "SkullOwner", owner );
return tag;
}
private static void addSpecial( Consumer<IFinishedRecipe> add, SpecialRecipeSerializer<?> special )
{
CustomRecipeBuilder.special( special ).save( add, special.getRegistryName().toString() );
}
} }

View File

@ -98,5 +98,5 @@ public final class ColourableRecipe extends SpecialRecipe
return SERIALIZER; return SERIALIZER;
} }
public static final IRecipeSerializer<?> SERIALIZER = new SpecialRecipeSerializer<>( ColourableRecipe::new ); public static final SpecialRecipeSerializer<?> SERIALIZER = new SpecialRecipeSerializer<>( ColourableRecipe::new );
} }

View File

@ -11,15 +11,17 @@ import javax.annotation.Nonnull;
public enum ComputerState implements IStringSerializable public enum ComputerState implements IStringSerializable
{ {
OFF( "off" ), OFF( "off", "" ),
ON( "on" ), ON( "on", "_on" ),
BLINKING( "blinking" ); BLINKING( "blinking", "_blink" );
private final String name; private final String name;
private final String texture;
ComputerState( String name ) ComputerState( String name, String texture )
{ {
this.name = name; this.name = name;
this.texture = texture;
} }
@Nonnull @Nonnull
@ -34,4 +36,10 @@ public enum ComputerState implements IStringSerializable
{ {
return name; return name;
} }
@Nonnull
public String getTexture()
{
return texture;
}
} }

View File

@ -14,20 +14,16 @@ import net.minecraft.item.DyeColor;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.SpecialRecipe; import net.minecraft.item.crafting.SpecialRecipe;
import net.minecraft.item.crafting.SpecialRecipeSerializer; import net.minecraft.item.crafting.SpecialRecipeSerializer;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.Tags;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
public class DiskRecipe extends SpecialRecipe public class DiskRecipe extends SpecialRecipe
{ {
private final Ingredient paper = Ingredient.of( Items.PAPER );
private final Ingredient redstone = Ingredient.of( Items.REDSTONE );
// TODO: Ingredient.fromTag( Tags.Items.DUSTS_REDSTONE );
public DiskRecipe( ResourceLocation id ) public DiskRecipe( ResourceLocation id )
{ {
super( id ); super( id );
@ -45,12 +41,12 @@ public class DiskRecipe extends SpecialRecipe
if( !stack.isEmpty() ) if( !stack.isEmpty() )
{ {
if( paper.test( stack ) ) if( stack.getItem() == Items.PAPER )
{ {
if( paperFound ) return false; if( paperFound ) return false;
paperFound = true; paperFound = true;
} }
else if( redstone.test( stack ) ) else if( Tags.Items.DUSTS_REDSTONE.contains( stack.getItem() ) )
{ {
if( redstoneFound ) return false; if( redstoneFound ) return false;
redstoneFound = true; redstoneFound = true;
@ -77,7 +73,7 @@ public class DiskRecipe extends SpecialRecipe
if( stack.isEmpty() ) continue; if( stack.isEmpty() ) continue;
if( !paper.test( stack ) && !redstone.test( stack ) ) if( stack.getItem() != Items.PAPER && !Tags.Items.DUSTS_REDSTONE.contains( stack.getItem() ) )
{ {
DyeColor dye = ColourUtils.getStackColour( stack ); DyeColor dye = ColourUtils.getStackColour( stack );
if( dye != null ) tracker.addColour( dye ); if( dye != null ) tracker.addColour( dye );
@ -107,5 +103,5 @@ public class DiskRecipe extends SpecialRecipe
return SERIALIZER; return SERIALIZER;
} }
public static final IRecipeSerializer<DiskRecipe> SERIALIZER = new SpecialRecipeSerializer<>( DiskRecipe::new ); public static final SpecialRecipeSerializer<DiskRecipe> SERIALIZER = new SpecialRecipeSerializer<>( DiskRecipe::new );
} }

View File

@ -10,20 +10,16 @@ import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.SpecialRecipe; import net.minecraft.item.crafting.SpecialRecipe;
import net.minecraft.item.crafting.SpecialRecipeSerializer; import net.minecraft.item.crafting.SpecialRecipeSerializer;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.Tags;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
public final class PrintoutRecipe extends SpecialRecipe public final class PrintoutRecipe extends SpecialRecipe
{ {
private final Ingredient paper = Ingredient.of( net.minecraft.item.Items.PAPER );
private final Ingredient leather = Ingredient.of( net.minecraft.item.Items.LEATHER );
private final Ingredient string = Ingredient.of( Items.STRING );
private PrintoutRecipe( ResourceLocation id ) private PrintoutRecipe( ResourceLocation id )
{ {
super( id ); super( id );
@ -77,7 +73,7 @@ public final class PrintoutRecipe extends SpecialRecipe
numPrintouts++; numPrintouts++;
printoutFound = true; printoutFound = true;
} }
else if( paper.test( stack ) ) else if( stack.getItem() == Items.PAPER )
{ {
if( printouts == null ) if( printouts == null )
{ {
@ -87,11 +83,11 @@ public final class PrintoutRecipe extends SpecialRecipe
numPages++; numPages++;
numPrintouts++; numPrintouts++;
} }
else if( string.test( stack ) && !stringFound ) else if( Tags.Items.STRING.contains( stack.getItem() ) && !stringFound )
{ {
stringFound = true; stringFound = true;
} }
else if( leather.test( stack ) && !leatherFound ) else if( Tags.Items.LEATHER.contains( stack.getItem() ) && !leatherFound )
{ {
leatherFound = true; leatherFound = true;
} }
@ -163,5 +159,5 @@ public final class PrintoutRecipe extends SpecialRecipe
return SERIALIZER; return SERIALIZER;
} }
public static final IRecipeSerializer<?> SERIALIZER = new SpecialRecipeSerializer<>( PrintoutRecipe::new ); public static final SpecialRecipeSerializer<?> SERIALIZER = new SpecialRecipeSerializer<>( PrintoutRecipe::new );
} }

View File

@ -30,7 +30,7 @@ import javax.annotation.Nullable;
public class BlockDiskDrive extends BlockGeneric public class BlockDiskDrive extends BlockGeneric
{ {
static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
static final EnumProperty<DiskDriveState> STATE = EnumProperty.create( "state", DiskDriveState.class ); public static final EnumProperty<DiskDriveState> STATE = EnumProperty.create( "state", DiskDriveState.class );
public BlockDiskDrive( Properties settings ) public BlockDiskDrive( Properties settings )
{ {

View File

@ -113,5 +113,5 @@ public final class PocketComputerUpgradeRecipe extends SpecialRecipe
return SERIALIZER; return SERIALIZER;
} }
public static final IRecipeSerializer<PocketComputerUpgradeRecipe> SERIALIZER = new SpecialRecipeSerializer<>( PocketComputerUpgradeRecipe::new ); public static final SpecialRecipeSerializer<PocketComputerUpgradeRecipe> SERIALIZER = new SpecialRecipeSerializer<>( PocketComputerUpgradeRecipe::new );
} }

View File

@ -185,5 +185,5 @@ public final class TurtleUpgradeRecipe extends SpecialRecipe
return SERIALIZER; return SERIALIZER;
} }
public static final IRecipeSerializer<TurtleUpgradeRecipe> SERIALIZER = new SpecialRecipeSerializer<>( TurtleUpgradeRecipe::new ); public static final SpecialRecipeSerializer<TurtleUpgradeRecipe> SERIALIZER = new SpecialRecipeSerializer<>( TurtleUpgradeRecipe::new );
} }

View File

@ -1,8 +0,0 @@
{
"variants": {
"facing=north": { "model": "computercraft:block/speaker" },
"facing=south": { "model": "computercraft:block/speaker", "y": 180 },
"facing=west": { "model": "computercraft:block/speaker", "y": 270 },
"facing=east": { "model": "computercraft:block/speaker", "y": 90 }
}
}

View File

@ -1,8 +0,0 @@
{
"variants": {
"facing=north": { "model": "computercraft:block/turtle_advanced" },
"facing=south": { "model": "computercraft:block/turtle_advanced", "y": 180 },
"facing=west": { "model": "computercraft:block/turtle_advanced", "y": 270 },
"facing=east": { "model": "computercraft:block/turtle_advanced", "y": 90 }
}
}

View File

@ -1,8 +0,0 @@
{
"variants": {
"facing=north": { "model": "computercraft:block/turtle_normal" },
"facing=south": { "model": "computercraft:block/turtle_normal", "y": 180 },
"facing=west": { "model": "computercraft:block/turtle_normal", "y": 270 },
"facing=east": { "model": "computercraft:block/turtle_normal", "y": 90 }
}
}

View File

@ -1,8 +0,0 @@
{
"variants": {
"facing=north": { "model": "computercraft:turtle_normal" },
"facing=south": { "model": "computercraft:turtle_normal", "y": 180 },
"facing=west": { "model": "computercraft:turtle_normal", "y": 270 },
"facing=east": { "model": "computercraft:turtle_normal", "y": 90 }
}
}

View File

@ -1,8 +0,0 @@
{
"variants": {
"modem=false,peripheral=false": { "model": "computercraft:block/wired_modem_full_off" },
"modem=false,peripheral=true": { "model": "computercraft:block/wired_modem_full_off_peripheral" },
"modem=true,peripheral=false": { "model": "computercraft:block/wired_modem_full_on" },
"modem=true,peripheral=true": { "model": "computercraft:block/wired_modem_full_on_peripheral" }
}
}

View File

@ -1,17 +0,0 @@
{
"variants": {
"facing=up,on=false": { "model": "computercraft:block/wireless_modem_advanced_off", "x": 270 },
"facing=down,on=false": { "model": "computercraft:block/wireless_modem_advanced_off", "x": 90 },
"facing=north,on=false": { "model": "computercraft:block/wireless_modem_advanced_off" },
"facing=south,on=false": { "model": "computercraft:block/wireless_modem_advanced_off", "y": 180 },
"facing=west,on=false": { "model": "computercraft:block/wireless_modem_advanced_off", "y": 270 },
"facing=east,on=false": { "model": "computercraft:block/wireless_modem_advanced_off", "y": 90 },
"facing=up,on=true": { "model": "computercraft:block/wireless_modem_advanced_on", "x": 270 },
"facing=down,on=true": { "model": "computercraft:block/wireless_modem_advanced_on", "x": 90 },
"facing=north,on=true": { "model": "computercraft:block/wireless_modem_advanced_on" },
"facing=south,on=true": { "model": "computercraft:block/wireless_modem_advanced_on", "y": 180 },
"facing=west,on=true": { "model": "computercraft:block/wireless_modem_advanced_on", "y": 270 },
"facing=east,on=true": { "model": "computercraft:block/wireless_modem_advanced_on", "y": 90 }
}
}

View File

@ -1,17 +0,0 @@
{
"variants": {
"facing=up,on=false": { "model": "computercraft:block/wireless_modem_normal_off", "x": 270 },
"facing=down,on=false": { "model": "computercraft:block/wireless_modem_normal_off", "x": 90 },
"facing=north,on=false": { "model": "computercraft:block/wireless_modem_normal_off" },
"facing=south,on=false": { "model": "computercraft:block/wireless_modem_normal_off", "y": 180 },
"facing=west,on=false": { "model": "computercraft:block/wireless_modem_normal_off", "y": 270 },
"facing=east,on=false": { "model": "computercraft:block/wireless_modem_normal_off", "y": 90 },
"facing=up,on=true": { "model": "computercraft:block/wireless_modem_normal_on", "x": 270 },
"facing=down,on=true": { "model": "computercraft:block/wireless_modem_normal_on", "x": 90 },
"facing=north,on=true": { "model": "computercraft:block/wireless_modem_normal_on" },
"facing=south,on=true": { "model": "computercraft:block/wireless_modem_normal_on", "y": 180 },
"facing=west,on=true": { "model": "computercraft:block/wireless_modem_normal_on", "y": 270 },
"facing=east,on=true": { "model": "computercraft:block/wireless_modem_normal_on", "y": 90 }
}
}

View File

@ -1,8 +0,0 @@
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:block/monitor_advanced_15",
"side": "computercraft:block/monitor_advanced_4",
"top": "computercraft:block/monitor_advanced_0"
}
}

View File

@ -1,9 +0,0 @@
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:block/monitor_normal_20",
"side": "computercraft:block/monitor_normal_36",
"top": "computercraft:block/monitor_normal_0",
"back": "computercraft:block/monitor_normal_36"
}
}

View File

@ -1,8 +0,0 @@
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:block/monitor_normal_15",
"side": "computercraft:block/monitor_normal_4",
"top": "computercraft:block/monitor_normal_0"
}
}

View File

@ -1,8 +0,0 @@
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:block/speaker_front",
"side": "computercraft:block/speaker_side",
"top": "computercraft:block/speaker_top"
}
}

View File

@ -1,4 +0,0 @@
{
"loader": "computercraft:turtle",
"model": "computercraft:block/turtle_advanced_base"
}

View File

@ -1,6 +0,0 @@
{
"parent": "computercraft:block/turtle_base",
"textures": {
"texture": "computercraft:block/turtle_advanced"
}
}

View File

@ -1,4 +0,0 @@
{
"loader": "computercraft:turtle",
"model": "computercraft:block/turtle_normal_base"
}

View File

@ -1,6 +0,0 @@
{
"parent": "computercraft:block/turtle_base",
"textures": {
"texture": "computercraft:block/turtle_normal"
}
}

View File

@ -1,6 +0,0 @@
{
"parent": "block/cube_all",
"textures": {
"all": "computercraft:block/wired_modem_face"
}
}

View File

@ -1,6 +0,0 @@
{
"parent": "block/cube_all",
"textures": {
"all": "computercraft:block/wired_modem_face_peripheral"
}
}

View File

@ -1,6 +0,0 @@
{
"parent": "block/cube_all",
"textures": {
"all": "computercraft:block/wired_modem_face_on"
}
}

View File

@ -1,6 +0,0 @@
{
"parent": "block/cube_all",
"textures": {
"all": "computercraft:block/wired_modem_face_peripheral_on"
}
}

View File

@ -1,7 +0,0 @@
{
"parent": "computercraft:block/modem",
"textures": {
"front": "computercraft:block/wired_modem_face",
"back": "computercraft:block/modem_back"
}
}

View File

@ -1,7 +0,0 @@
{
"parent": "computercraft:block/modem",
"textures": {
"front": "computercraft:block/wired_modem_face_peripheral",
"back": "computercraft:block/modem_back"
}
}

View File

@ -1,7 +0,0 @@
{
"parent": "computercraft:block/modem",
"textures": {
"front": "computercraft:block/wired_modem_face_on",
"back": "computercraft:block/modem_back"
}
}

View File

@ -1,7 +0,0 @@
{
"parent": "computercraft:block/modem",
"textures": {
"front": "computercraft:block/wired_modem_face_peripheral_on",
"back": "computercraft:block/modem_back"
}
}

View File

@ -1,7 +0,0 @@
{
"parent": "computercraft:block/modem",
"textures": {
"front": "computercraft:block/wireless_modem_advanced_face",
"back": "computercraft:block/modem_back"
}
}

View File

@ -1,7 +0,0 @@
{
"parent": "computercraft:block/modem",
"textures": {
"front": "computercraft:block/wireless_modem_advanced_face_on",
"back": "computercraft:block/modem_back"
}
}

View File

@ -1,7 +0,0 @@
{
"parent": "computercraft:block/modem",
"textures": {
"front": "computercraft:block/wireless_modem_normal_face",
"back": "computercraft:block/modem_back"
}
}

View File

@ -1,7 +0,0 @@
{
"parent": "computercraft:block/modem",
"textures": {
"front": "computercraft:block/wireless_modem_normal_face_on",
"back": "computercraft:block/modem_back"
}
}

View File

@ -1,3 +0,0 @@
{
"parent": "computercraft:block/computer_advanced_blinking"
}

Some files were not shown because too many files have changed in this diff Show More