1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-10-24 18:37:38 +00:00

Merge branch 'mc-1.16.x' into mc-1.17.x

This commit is contained in:
Jonathan Coates
2021-08-22 17:50:33 +01:00
195 changed files with 1367 additions and 784 deletions

View File

@@ -137,8 +137,8 @@ public class RedstoneAPI implements ILuaAPI
*
* @param side The side to get.
* @return The output signal strength, between 0 and 15.
* @see #setAnalogOutput
* @cc.since 1.51
* @see #setAnalogOutput
*/
@LuaFunction( { "getAnalogOutput", "getAnalogueOutput" } )
public final int getAnalogOutput( ComputerSide side )

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.resources.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.computer.blocks.BlockComputer;
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.MonitorEdgeState;
import dan200.computercraft.shared.turtle.blocks.BlockTurtle;
import net.minecraft.core.Direction;
import net.minecraft.data.DataGenerator;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.client.model.generators.*;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.registries.IForgeRegistryEntry;
import javax.annotation.Nonnull;
import java.util.Objects;
public class BlockModelProvider extends BlockStateProvider
{
private ModelFile monitorBase;
private ModelFile orientable;
private ModelFile turtleBase;
private ModelFile modemBase;
public BlockModelProvider( DataGenerator generator, ExistingFileHelper existingFileHelper )
{
@@ -41,14 +47,33 @@ public class BlockModelProvider extends BlockStateProvider
protected void registerStatesAndModels()
{
monitorBase = models().getExistingFile( new ResourceLocation( ComputerCraft.MOD_ID, "block/monitor_base" ) );
orientable = models().getExistingFile( new ResourceLocation( "block/orientable" ) );
registerMonitors( Registry.ModBlocks.MONITOR_NORMAL.get() );
registerMonitors( Registry.ModBlocks.MONITOR_ADVANCED.get() );
turtleBase = models().getExistingFile( new ResourceLocation( ComputerCraft.MOD_ID, "block/turtle_base" ) );
modemBase = models().getExistingFile( new ResourceLocation( ComputerCraft.MOD_ID, "block/modem" ) );
registerComputer( Registry.ModBlocks.COMPUTER_NORMAL.get() );
registerComputer( Registry.ModBlocks.COMPUTER_ADVANCED.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 )
@@ -56,12 +81,12 @@ public class BlockModelProvider extends BlockStateProvider
VariantBlockStateBuilder builder = getVariantBuilder( block );
for( ComputerState state : BlockComputer.STATE.getPossibleValues() )
{
BlockModelBuilder model = models()
.getBuilder( suffix( block, "_" + state ) )
.parent( orientable )
.texture( "top", suffix( block, "_top" ) )
.texture( "side", suffix( block, "_side" ) )
.texture( "front", suffix( block, "_front" + toSuffix( state ) ) );
BlockModelBuilder model = models().orientable(
extendedName( block, "_" + state ),
blockTexture( block, "_side" ),
blockTexture( block, "_front" + state.getTexture() ),
blockTexture( block, "_top" )
);
for( Direction facing : BlockComputer.FACING.getPossibleValues() )
{
@@ -71,33 +96,118 @@ public class BlockModelProvider extends BlockStateProvider
.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 )
{
String name = block.getRegistryName().getPath();
registerMonitorModel( name, "", 16, 4, 0, 32 );
registerMonitorModel( name, "_d", 20, 7, 0, 36 );
registerMonitorModel( name, "_l", 19, 4, 1, 33 );
registerMonitorModel( name, "_ld", 31, 7, 1, 45 );
registerMonitorModel( name, "_lr", 18, 4, 2, 34 );
registerMonitorModel( name, "_lrd", 30, 7, 2, 46 );
registerMonitorModel( name, "_lru", 24, 5, 2, 40 );
registerMonitorModel( name, "_lrud", 27, 6, 2, 43 );
registerMonitorModel( name, "_lu", 25, 5, 1, 39 );
registerMonitorModel( name, "_lud", 28, 6, 1, 42 );
registerMonitorModel( name, "_r", 17, 4, 3, 35 );
registerMonitorModel( name, "_rd", 29, 7, 3, 47 );
registerMonitorModel( name, "_ru", 23, 5, 3, 41 );
registerMonitorModel( name, "_rud", 26, 6, 3, 44 );
registerMonitorModel( name, "_u", 22, 5, 0, 38 );
registerMonitorModel( name, "_ud", 21, 6, 0, 37 );
String name = blockTexture( block ).toString();
monitorModel( name, "", 16, 4, 0, 32 );
monitorModel( name, "_d", 20, 7, 0, 36 );
monitorModel( name, "_l", 19, 4, 1, 33 );
monitorModel( name, "_ld", 31, 7, 1, 45 );
monitorModel( name, "_lr", 18, 4, 2, 34 );
monitorModel( name, "_lrd", 30, 7, 2, 46 );
monitorModel( name, "_lru", 24, 5, 2, 40 );
monitorModel( name, "_lrud", 27, 6, 2, 43 );
monitorModel( name, "_lu", 25, 5, 1, 39 );
monitorModel( name, "_lud", 28, 6, 1, 42 );
monitorModel( name, "_r", 17, 4, 3, 35 );
monitorModel( name, "_rd", 29, 7, 3, 47 );
monitorModel( name, "_ru", 23, 5, 3, 41 );
monitorModel( name, "_rud", 26, 6, 3, 44 );
monitorModel( name, "_u", 22, 5, 0, 38 );
monitorModel( name, "_ud", 21, 6, 0, 37 );
VariantBlockStateBuilder builder = getVariantBuilder( block );
for( MonitorEdgeState edge : BlockMonitor.STATE.getPossibleValues() )
{
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() )
{
@@ -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 )
.parent( monitorBase )
.texture( "front", texturePrefix + front )
@@ -142,23 +259,27 @@ public class BlockModelProvider extends BlockStateProvider
return ((int) direction.toYRot() + 180) % 360;
}
private static String toSuffix( ComputerState state )
{
switch( state )
{
default:
case OFF:
return "";
case ON:
return "_on";
case BLINKING:
return "_blink";
}
}
private static String suffix( Block block, String suffix )
private static ResourceLocation blockTexture( Block block, String suffix )
{
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,6 +11,9 @@ import dan200.computercraft.shared.Registry;
import dan200.computercraft.shared.data.BlockNamedEntityLootCondition;
import dan200.computercraft.shared.data.HasComputerIdLootCondition;
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.critereon.StatePropertiesPredicate;
import net.minecraft.data.DataGenerator;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
@@ -21,6 +24,7 @@ import net.minecraft.world.level.storage.loot.entries.LootItem;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
import net.minecraft.world.level.storage.loot.predicates.AlternativeLootItemCondition;
import net.minecraft.world.level.storage.loot.predicates.ExplosionCondition;
import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition;
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
import net.minecraftforge.fmllegacy.RegistryObject;
@@ -51,6 +55,30 @@ public class LootTables extends LootTableProvider
computerDrop( add, Registry.ModBlocks.TURTLE_NORMAL );
computerDrop( add, Registry.ModBlocks.TURTLE_ADVANCED );
add.accept( Registry.ModBlocks.CABLE.get().getLootTable(), LootTable
.lootTable()
.setParamSet( LootContextParamSets.BLOCK )
.withPool( LootPool.lootPool()
.name( "cable" )
.setRolls( ConstantValue.exactly( 1 ) )
.add( LootItem.lootTableItem( Registry.ModItems.CABLE.get() ) )
.when( ExplosionCondition.survivesExplosion() )
.when( LootItemBlockStatePropertyCondition.hasBlockStateProperties( Registry.ModBlocks.CABLE.get() )
.setProperties( StatePropertiesPredicate.Builder.properties().hasProperty( BlockCable.CABLE, true ) )
)
)
.withPool( LootPool.lootPool()
.name( "wired_modem" )
.setRolls( ConstantValue.exactly( 1 ) )
.add( LootItem.lootTableItem( Registry.ModItems.WIRED_MODEM.get() ) )
.when( ExplosionCondition.survivesExplosion() )
.when( LootItemBlockStatePropertyCondition.hasBlockStateProperties( Registry.ModBlocks.CABLE.get() )
.setProperties( StatePropertiesPredicate.Builder.properties().hasProperty( BlockCable.MODEM, CableModemVariant.None ) )
.invert()
)
)
.build() );
add.accept( CommonHooks.LOOT_TREASURE_DISK, LootTable
.lootTable()
.setParamSet( LootContextParamSets.ALL_PARAMS )

View File

@@ -10,23 +10,28 @@ import dan200.computercraft.data.Tags.CCTags;
import dan200.computercraft.shared.PocketUpgrades;
import dan200.computercraft.shared.Registry;
import dan200.computercraft.shared.TurtleUpgrades;
import dan200.computercraft.shared.common.ColourableRecipe;
import dan200.computercraft.shared.common.IColouredItem;
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.recipes.PocketComputerUpgradeRecipe;
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.ImpostorRecipe;
import dan200.computercraft.shared.util.ImpostorShapelessRecipe;
import net.minecraft.advancements.critereon.InventoryChangeTrigger;
import net.minecraft.advancements.critereon.ItemPredicate;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.data.recipes.RecipeProvider;
import net.minecraft.data.recipes.ShapedRecipeBuilder;
import net.minecraft.data.recipes.ShapelessRecipeBuilder;
import net.minecraft.data.recipes.*;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.Tag;
import net.minecraft.world.item.*;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.SimpleRecipeSerializer;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.Blocks;
import net.minecraftforge.common.Tags;
@@ -49,6 +54,12 @@ public class Recipes extends RecipeProvider
diskColours( add );
pocketUpgrades( add );
turtleUpgrades( add );
addSpecial( add, PrintoutRecipe.SERIALIZER );
addSpecial( add, DiskRecipe.SERIALIZER );
addSpecial( add, ColourableRecipe.SERIALIZER );
addSpecial( add, TurtleUpgradeRecipe.SERIALIZER );
addSpecial( add, PocketComputerUpgradeRecipe.SERIALIZER );
}
/**
@@ -307,6 +318,41 @@ public class Recipes extends RecipeProvider
.unlockedBy( "has_computer", inventoryChange( CCTags.COMPUTER ) )
.unlockedBy( "has_wireless", inventoryChange( Registry.ModBlocks.WIRELESS_MODEM_NORMAL.get() ) )
.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( RecipeSerializer.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( RecipeSerializer.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 )
@@ -323,4 +369,20 @@ public class Recipes extends RecipeProvider
{
return InventoryChangeTrigger.TriggerInstance.hasItems( stack );
}
private static CompoundTag playerHead( String name, String uuid )
{
CompoundTag owner = new CompoundTag();
owner.putString( "Name", name );
owner.putString( "Id", uuid );
CompoundTag tag = new CompoundTag();
tag.put( "SkullOwner", owner );
return tag;
}
private static void addSpecial( Consumer<FinishedRecipe> add, SimpleRecipeSerializer<?> special )
{
SpecialRecipeBuilder.special( special ).save( add, special.getRegistryName().toString() );
}
}

View File

@@ -88,6 +88,7 @@ public abstract class BlockGeneric extends BaseEntityBlock
@Nonnull
@Override
@Deprecated
public RenderShape getRenderShape( @Nonnull BlockState state )
{
return RenderShape.MODEL;

View File

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

View File

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

View File

@@ -15,18 +15,15 @@ import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.CustomRecipe;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.SimpleRecipeSerializer;
import net.minecraft.world.level.Level;
import net.minecraftforge.common.Tags;
import javax.annotation.Nonnull;
public class DiskRecipe extends CustomRecipe
{
private final Ingredient paper = Ingredient.of( Items.PAPER );
private final Ingredient redstone = Ingredient.of( Items.REDSTONE );
public DiskRecipe( ResourceLocation id )
{
super( id );
@@ -44,12 +41,12 @@ public class DiskRecipe extends CustomRecipe
if( !stack.isEmpty() )
{
if( paper.test( stack ) )
if( stack.getItem() == Items.PAPER )
{
if( paperFound ) return false;
paperFound = true;
}
else if( redstone.test( stack ) )
else if( Tags.Items.DUSTS_REDSTONE.contains( stack.getItem() ) )
{
if( redstoneFound ) return false;
redstoneFound = true;
@@ -76,7 +73,7 @@ public class DiskRecipe extends CustomRecipe
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 );
if( dye != null ) tracker.addColour( dye );
@@ -106,5 +103,5 @@ public class DiskRecipe extends CustomRecipe
return SERIALIZER;
}
public static final RecipeSerializer<DiskRecipe> SERIALIZER = new SimpleRecipeSerializer<>( DiskRecipe::new );
public static final SimpleRecipeSerializer<DiskRecipe> SERIALIZER = new SimpleRecipeSerializer<>( DiskRecipe::new );
}

View File

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

View File

@@ -33,7 +33,7 @@ import javax.annotation.Nullable;
public class BlockDiskDrive extends BlockGeneric
{
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 );
private static final BlockEntityTicker<TileDiskDrive> serverTicker = ( level, pos, state, drive ) -> drive.serverTick();

View File

@@ -113,5 +113,5 @@ public final class PocketComputerUpgradeRecipe extends CustomRecipe
return SERIALIZER;
}
public static final RecipeSerializer<PocketComputerUpgradeRecipe> SERIALIZER = new SimpleRecipeSerializer<>( PocketComputerUpgradeRecipe::new );
public static final SimpleRecipeSerializer<PocketComputerUpgradeRecipe> SERIALIZER = new SimpleRecipeSerializer<>( PocketComputerUpgradeRecipe::new );
}

View File

@@ -185,5 +185,5 @@ public final class TurtleUpgradeRecipe extends CustomRecipe
return SERIALIZER;
}
public static final RecipeSerializer<TurtleUpgradeRecipe> SERIALIZER = new SimpleRecipeSerializer<>( TurtleUpgradeRecipe::new );
public static final SimpleRecipeSerializer<TurtleUpgradeRecipe> SERIALIZER = new SimpleRecipeSerializer<>( TurtleUpgradeRecipe::new );
}