1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-12-12 00:38:05 +00:00

Update to 1.18.2

Did not enjoy, would not recommend.
This commit is contained in:
Jonathan Coates
2022-03-03 09:17:18 +00:00
parent f994696161
commit 6735cfd12e
38 changed files with 112 additions and 131 deletions

View File

@@ -159,8 +159,8 @@ dependencies {
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}" minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
annotationProcessor 'org.spongepowered:mixin:0.8.4:processor' annotationProcessor 'org.spongepowered:mixin:0.8.4:processor'
compileOnly fg.deobf("mezz.jei:jei-1.18.1:9.1.0.47:api") compileOnly fg.deobf("mezz.jei:jei-1.18.2:9.4.1.116:api")
runtimeOnly fg.deobf("mezz.jei:jei-1.18.1:9.1.0.47") runtimeOnly fg.deobf("mezz.jei:jei-1.18.2:9.4.1.116")
shade 'org.squiddev:Cobalt:0.5.2-SNAPSHOT' shade 'org.squiddev:Cobalt:0.5.2-SNAPSHOT'

View File

@@ -4,7 +4,7 @@ org.gradle.jvmargs=-Xmx3G
mod_version=1.100.3 mod_version=1.100.3
# Minecraft properties (update mods.toml when changing) # Minecraft properties (update mods.toml when changing)
mc_version=1.18.1 mc_version=1.18.2
mapping_version=2021.09.05 mapping_version=2022.02.13
forge_version=39.0.0 forge_version=40.0.2
# NO SERIOUSLY, UPDATE mods.toml WHEN CHANGING # NO SERIOUSLY, UPDATE mods.toml WHEN CHANGING

View File

@@ -22,8 +22,7 @@
"cable": "true" "cable": "true"
} }
} }
], ]
"functions": []
}, },
{ {
"name": "wired_modem", "name": "wired_modem",
@@ -49,8 +48,7 @@
} }
} }
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -29,8 +29,7 @@
} }
] ]
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -29,8 +29,7 @@
} }
] ]
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -29,8 +29,7 @@
} }
] ]
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -15,8 +15,7 @@
{ {
"condition": "minecraft:survives_explosion" "condition": "minecraft:survives_explosion"
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -15,8 +15,7 @@
{ {
"condition": "minecraft:survives_explosion" "condition": "minecraft:survives_explosion"
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -15,8 +15,7 @@
{ {
"condition": "minecraft:survives_explosion" "condition": "minecraft:survives_explosion"
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -15,8 +15,7 @@
{ {
"condition": "minecraft:survives_explosion" "condition": "minecraft:survives_explosion"
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -15,8 +15,7 @@
{ {
"condition": "minecraft:survives_explosion" "condition": "minecraft:survives_explosion"
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -29,8 +29,7 @@
} }
] ]
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -29,8 +29,7 @@
} }
] ]
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -15,8 +15,7 @@
{ {
"condition": "minecraft:survives_explosion" "condition": "minecraft:survives_explosion"
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -15,8 +15,7 @@
{ {
"condition": "minecraft:survives_explosion" "condition": "minecraft:survives_explosion"
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -15,8 +15,7 @@
{ {
"condition": "minecraft:survives_explosion" "condition": "minecraft:survives_explosion"
} }
], ]
"functions": []
} }
] ]
} }

View File

@@ -30,7 +30,6 @@ import dan200.computercraft.shared.wired.WiredNode;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ReloadableResourceManager;
import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
@@ -59,7 +58,7 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
public static InputStream getResourceFile( String domain, String subPath ) public static InputStream getResourceFile( String domain, String subPath )
{ {
ReloadableResourceManager manager = (ReloadableResourceManager) ServerLifecycleHooks.getCurrentServer().getResourceManager(); var manager = ServerLifecycleHooks.getCurrentServer().getResourceManager();
try try
{ {
return manager.getResource( new ResourceLocation( domain, subPath ) ).getInputStream(); return manager.getResource( new ResourceLocation( domain, subPath ) ).getInputStream();

View File

@@ -9,7 +9,7 @@ import dan200.computercraft.ComputerCraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags; import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags; import net.minecraft.tags.ItemTags;
import net.minecraft.tags.Tag; import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
@@ -20,47 +20,47 @@ public class ComputerCraftTags
{ {
public static class Items public static class Items
{ {
public static final Tag.Named<Item> COMPUTER = make( "computer" ); public static final TagKey<Item> COMPUTER = make( "computer" );
public static final Tag.Named<Item> TURTLE = make( "turtle" ); public static final TagKey<Item> TURTLE = make( "turtle" );
public static final Tag.Named<Item> WIRED_MODEM = make( "wired_modem" ); public static final TagKey<Item> WIRED_MODEM = make( "wired_modem" );
public static final Tag.Named<Item> MONITOR = make( "monitor" ); public static final TagKey<Item> MONITOR = make( "monitor" );
private static Tag.Named<Item> make( String name ) private static TagKey<Item> make( String name )
{ {
return ItemTags.bind( new ResourceLocation( ComputerCraft.MOD_ID, name ).toString() ); return ItemTags.create( new ResourceLocation( ComputerCraft.MOD_ID, name ) );
} }
} }
public static class Blocks public static class Blocks
{ {
public static final Tag.Named<Block> COMPUTER = make( "computer" ); public static final TagKey<Block> COMPUTER = make( "computer" );
public static final Tag.Named<Block> TURTLE = make( "turtle" ); public static final TagKey<Block> TURTLE = make( "turtle" );
public static final Tag.Named<Block> WIRED_MODEM = make( "wired_modem" ); public static final TagKey<Block> WIRED_MODEM = make( "wired_modem" );
public static final Tag.Named<Block> MONITOR = make( "monitor" ); public static final TagKey<Block> MONITOR = make( "monitor" );
/** /**
* Blocks which can be broken by any turtle tool. * Blocks which can be broken by any turtle tool.
*/ */
public static final Tag.Named<Block> TURTLE_ALWAYS_BREAKABLE = make( "turtle_always_breakable" ); public static final TagKey<Block> TURTLE_ALWAYS_BREAKABLE = make( "turtle_always_breakable" );
/** /**
* Blocks which can be broken by the default shovel tool. * Blocks which can be broken by the default shovel tool.
*/ */
public static final Tag.Named<Block> TURTLE_SHOVEL_BREAKABLE = make( "turtle_shovel_harvestable" ); public static final TagKey<Block> TURTLE_SHOVEL_BREAKABLE = make( "turtle_shovel_harvestable" );
/** /**
* Blocks which can be broken with the default sword tool. * Blocks which can be broken with the default sword tool.
*/ */
public static final Tag.Named<Block> TURTLE_SWORD_BREAKABLE = make( "turtle_sword_harvestable" ); public static final TagKey<Block> TURTLE_SWORD_BREAKABLE = make( "turtle_sword_harvestable" );
/** /**
* Blocks which can be broken with the default hoe tool. * Blocks which can be broken with the default hoe tool.
*/ */
public static final Tag.Named<Block> TURTLE_HOE_BREAKABLE = make( "turtle_hoe_harvestable" ); public static final TagKey<Block> TURTLE_HOE_BREAKABLE = make( "turtle_hoe_harvestable" );
private static Tag.Named<Block> make( String name ) private static TagKey<Block> make( String name )
{ {
return BlockTags.bind( new ResourceLocation( ComputerCraft.MOD_ID, name ).toString() ); return BlockTags.create( new ResourceLocation( ComputerCraft.MOD_ID, name ) );
} }
} }
} }

View File

@@ -10,7 +10,7 @@ import dan200.computercraft.api.ComputerCraftTags;
import dan200.computercraft.api.upgrades.UpgradeDataProvider; import dan200.computercraft.api.upgrades.UpgradeDataProvider;
import net.minecraft.data.DataGenerator; import net.minecraft.data.DataGenerator;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.Tag; import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
@@ -42,7 +42,7 @@ public abstract class TurtleUpgradeDataProvider extends UpgradeDataProvider<ITur
* *
* @param id The ID of this tool. * @param id The ID of this tool.
* @param item The item used for tool actions. Note, this doesn't inherit all properties of the tool, you may need * @param item The item used for tool actions. Note, this doesn't inherit all properties of the tool, you may need
* to specify {@link ToolBuilder#damageMultiplier(float)} and {@link ToolBuilder#breakable(Tag.Named)}. * to specify {@link ToolBuilder#damageMultiplier(float)} and {@link ToolBuilder#breakable(TagKey)}.
* @return A tool builder, * @return A tool builder,
*/ */
@Nonnull @Nonnull
@@ -64,7 +64,7 @@ public abstract class TurtleUpgradeDataProvider extends UpgradeDataProvider<ITur
private String adjective; private String adjective;
private Item craftingItem; private Item craftingItem;
private Float damageMultiplier = null; private Float damageMultiplier = null;
private Tag.Named<Block> breakable; private TagKey<Block> breakable;
ToolBuilder( ResourceLocation id, TurtleUpgradeSerialiser<?> serialiser, Item toolItem ) ToolBuilder( ResourceLocation id, TurtleUpgradeSerialiser<?> serialiser, Item toolItem )
{ {
@@ -123,7 +123,7 @@ public abstract class TurtleUpgradeDataProvider extends UpgradeDataProvider<ITur
* @return The tool builder, for further use. * @return The tool builder, for further use.
* @see ComputerCraftTags.Blocks * @see ComputerCraftTags.Blocks
*/ */
public ToolBuilder breakable( @Nonnull Tag.Named<Block> breakable ) public ToolBuilder breakable( @Nonnull TagKey<Block> breakable )
{ {
this.breakable = breakable; this.breakable = breakable;
return this; return this;
@@ -141,7 +141,7 @@ public abstract class TurtleUpgradeDataProvider extends UpgradeDataProvider<ITur
if( adjective != null ) s.addProperty( "adjective", adjective ); if( adjective != null ) s.addProperty( "adjective", adjective );
if( craftingItem != null ) s.addProperty( "craftItem", craftingItem.getRegistryName().toString() ); if( craftingItem != null ) s.addProperty( "craftItem", craftingItem.getRegistryName().toString() );
if( damageMultiplier != null ) s.addProperty( "damageMultiplier", damageMultiplier ); if( damageMultiplier != null ) s.addProperty( "damageMultiplier", damageMultiplier );
if( breakable != null ) s.addProperty( "breakable", breakable.getName().toString() ); if( breakable != null ) s.addProperty( "breakable", breakable.location().toString() );
} ) ); } ) );
} }
} }

View File

@@ -27,7 +27,7 @@ import net.minecraft.data.DataGenerator;
import net.minecraft.data.recipes.*; import net.minecraft.data.recipes.*;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.Tag; import net.minecraft.tags.TagKey;
import net.minecraft.world.item.*; import net.minecraft.world.item.*;
import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.SimpleRecipeSerializer; import net.minecraft.world.item.crafting.SimpleRecipeSerializer;
@@ -370,7 +370,7 @@ class RecipeGenerator extends RecipeProvider
return DyeColor.byId( 15 - colour.ordinal() ); return DyeColor.byId( 15 - colour.ordinal() );
} }
private static InventoryChangeTrigger.TriggerInstance inventoryChange( Tag<Item> stack ) private static InventoryChangeTrigger.TriggerInstance inventoryChange( TagKey<Item> stack )
{ {
return InventoryChangeTrigger.TriggerInstance.hasItems( ItemPredicate.Builder.item().of( stack ).build() ); return InventoryChangeTrigger.TriggerInstance.hasItems( ItemPredicate.Builder.item().of( stack ).build() );
} }

View File

@@ -32,7 +32,7 @@ public final class CommandUtils
} }
@SuppressWarnings( "unchecked" ) @SuppressWarnings( "unchecked" )
public static CompletableFuture<Suggestions> suggestOnServer( CommandContext<?> context, SuggestionsBuilder builder, Function<CommandContext<CommandSourceStack>, CompletableFuture<Suggestions>> supplier ) public static CompletableFuture<Suggestions> suggestOnServer( CommandContext<?> context, Function<CommandContext<CommandSourceStack>, CompletableFuture<Suggestions>> supplier )
{ {
Object source = context.getSource(); Object source = context.getSource();
if( !(source instanceof SharedSuggestionProvider) ) if( !(source instanceof SharedSuggestionProvider) )
@@ -45,7 +45,7 @@ public final class CommandUtils
} }
else else
{ {
return ((SharedSuggestionProvider) source).customSuggestion( (CommandContext<SharedSuggestionProvider>) context, builder ); return ((SharedSuggestionProvider) source).customSuggestion( context );
} }
} }

View File

@@ -121,7 +121,7 @@ public final class ComputersArgumentType implements ArgumentType<ComputersArgume
} }
// Verify we've a command source and we're running on the server // Verify we've a command source and we're running on the server
return suggestOnServer( context, builder, s -> { return suggestOnServer( context, s -> {
if( remaining.startsWith( "@" ) ) if( remaining.startsWith( "@" ) )
{ {
suggestComputers( builder, remaining, x -> { suggestComputers( builder, remaining, x -> {

View File

@@ -16,7 +16,6 @@ import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands; import net.minecraft.commands.Commands;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
@@ -81,7 +80,7 @@ public class CommandAPI implements ILuaAPI
Map<String, Object> table = BlockData.fill( new HashMap<>(), state ); Map<String, Object> table = BlockData.fill( new HashMap<>(), state );
BlockEntity tile = world.getBlockEntity( pos ); BlockEntity tile = world.getBlockEntity( pos );
if( tile != null ) table.put( "nbt", NBTUtil.toLua( tile.save( new CompoundTag() ) ) ); if( tile != null ) table.put( "nbt", NBTUtil.toLua( tile.saveWithFullMetadata() ) );
return table; return table;
} }

View File

@@ -96,7 +96,7 @@ public class JEIComputerCraft implements IModPlugin
IRecipeCategory<?> category = registry.getRecipeCategory( VanillaRecipeCategoryUid.CRAFTING, false ); IRecipeCategory<?> category = registry.getRecipeCategory( VanillaRecipeCategoryUid.CRAFTING, false );
if( category != null ) if( category != null )
{ {
for( Object wrapper : registry.getRecipes( category, null, false ) ) for( Object wrapper : registry.getRecipes( category, List.of(), false ) )
{ {
if( !(wrapper instanceof Recipe) ) continue; if( !(wrapper instanceof Recipe) ) continue;
ResourceLocation id = ((Recipe<?>) wrapper).getId(); ResourceLocation id = ((Recipe<?>) wrapper).getId();

View File

@@ -97,10 +97,10 @@ class RecipeResolver implements IRecipeManagerPlugin
@Override @Override
public <V> List<ResourceLocation> getRecipeCategoryUids( @Nonnull IFocus<V> focus ) public <V> List<ResourceLocation> getRecipeCategoryUids( @Nonnull IFocus<V> focus )
{ {
V value = focus.getValue(); V value = focus.getTypedValue().getIngredient();
if( !(value instanceof ItemStack stack) ) return Collections.emptyList(); if( !(value instanceof ItemStack stack) ) return Collections.emptyList();
switch( focus.getMode() ) switch( focus.getRole() )
{ {
case INPUT: case INPUT:
return stack.getItem() instanceof ITurtleItem || stack.getItem() instanceof ItemPocketComputer || return stack.getItem() instanceof ITurtleItem || stack.getItem() instanceof ItemPocketComputer ||
@@ -120,12 +120,12 @@ class RecipeResolver implements IRecipeManagerPlugin
@Override @Override
public <T, V> List<T> getRecipes( @Nonnull IRecipeCategory<T> recipeCategory, @Nonnull IFocus<V> focus ) public <T, V> List<T> getRecipes( @Nonnull IRecipeCategory<T> recipeCategory, @Nonnull IFocus<V> focus )
{ {
if( !(focus.getValue() instanceof ItemStack stack) || !recipeCategory.getUid().equals( VanillaRecipeCategoryUid.CRAFTING ) ) if( !(focus.getTypedValue().getIngredient() instanceof ItemStack stack) || !recipeCategory.getUid().equals( VanillaRecipeCategoryUid.CRAFTING ) )
{ {
return Collections.emptyList(); return Collections.emptyList();
} }
switch( focus.getMode() ) switch( focus.getRole() )
{ {
case INPUT: case INPUT:
return cast( findRecipesWithInput( stack ) ); return cast( findRecipesWithInput( stack ) );

View File

@@ -46,7 +46,7 @@ public class DiskRecipe extends CustomRecipe
if( paperFound ) return false; if( paperFound ) return false;
paperFound = true; paperFound = true;
} }
else if( Tags.Items.DUSTS_REDSTONE.contains( stack.getItem() ) ) else if( stack.is( Tags.Items.DUSTS_REDSTONE ) )
{ {
if( redstoneFound ) return false; if( redstoneFound ) return false;
redstoneFound = true; redstoneFound = true;
@@ -73,7 +73,7 @@ public class DiskRecipe extends CustomRecipe
if( stack.isEmpty() ) continue; if( stack.isEmpty() ) continue;
if( stack.getItem() != Items.PAPER && !Tags.Items.DUSTS_REDSTONE.contains( stack.getItem() ) ) if( stack.getItem() != Items.PAPER && !stack.is( Tags.Items.DUSTS_REDSTONE ) )
{ {
DyeColor dye = ColourUtils.getStackColour( stack ); DyeColor dye = ColourUtils.getStackColour( stack );
if( dye != null ) tracker.addColour( dye ); if( dye != null ) tracker.addColour( dye );

View File

@@ -80,11 +80,11 @@ public final class PrintoutRecipe extends CustomRecipe
numPages++; numPages++;
numPrintouts++; numPrintouts++;
} }
else if( Tags.Items.STRING.contains( stack.getItem() ) && !stringFound ) else if( stack.is( Tags.Items.STRING ) && !stringFound )
{ {
stringFound = true; stringFound = true;
} }
else if( Tags.Items.LEATHER.contains( stack.getItem() ) && !leatherFound ) else if( stack.is( Tags.Items.LEATHER ) && !leatherFound )
{ {
leatherFound = true; leatherFound = true;
} }

View File

@@ -26,7 +26,7 @@ public class BlockData
stateTable.put( property.getName(), getPropertyValue( property, entry.getValue() ) ); stateTable.put( property.getName(), getPropertyValue( property, entry.getValue() ) );
} }
data.put( "state", stateTable ); data.put( "state", stateTable );
data.put( "tags", DataHelpers.getTags( state.getBlock().getTags() ) ); data.put( "tags", DataHelpers.getTags( state.getTags() ) );
return data; return data;
} }

View File

@@ -5,26 +5,31 @@
*/ */
package dan200.computercraft.shared.peripheral.generic.data; package dan200.computercraft.shared.peripheral.generic.data;
import net.minecraft.core.Holder;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraftforge.registries.IForgeRegistryEntry; import net.minecraftforge.registries.IForgeRegistryEntry;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public final class DataHelpers public final class DataHelpers
{ {
private DataHelpers() private DataHelpers()
{} {}
@Nonnull public static <T> Map<String, Boolean> getTags( Holder.Reference<T> object )
public static Map<String, Boolean> getTags( @Nonnull Collection<ResourceLocation> tags )
{ {
Map<String, Boolean> result = new HashMap<>( tags.size() ); return getTags( object.tags() );
for( ResourceLocation location : tags ) result.put( location.toString(), true ); }
return result;
@Nonnull
public static <T> Map<String, Boolean> getTags( @Nonnull Stream<TagKey<T>> tags )
{
return tags.collect( Collectors.toMap( x -> x.location().toString(), x -> true ) );
} }
@Nullable @Nullable

View File

@@ -24,7 +24,10 @@ public class FluidData
public static <T extends Map<? super String, Object>> T fill( @Nonnull T data, @Nonnull FluidStack stack ) public static <T extends Map<? super String, Object>> T fill( @Nonnull T data, @Nonnull FluidStack stack )
{ {
fillBasic( data, stack ); fillBasic( data, stack );
data.put( "tags", DataHelpers.getTags( stack.getFluid().getTags() ) ); // FluidStack doesn't have a getTags method, so we need to use the deprecated builtInRegistryHolder.
@SuppressWarnings( "deprecation" )
var holder = stack.getFluid().builtInRegistryHolder();
data.put( "tags", DataHelpers.getTags( holder ) );
return data; return data;
} }
} }

View File

@@ -65,7 +65,7 @@ public class ItemData
data.put( "durability", stack.getItem().getBarWidth( stack ) / 13.0 ); data.put( "durability", stack.getItem().getBarWidth( stack ) / 13.0 );
} }
data.put( "tags", DataHelpers.getTags( stack.getItem().getTags() ) ); data.put( "tags", DataHelpers.getTags( stack.getTags() ) );
CompoundTag tag = stack.getTag(); CompoundTag tag = stack.getTag();
if( tag != null && tag.contains( "display", Tag.TAG_COMPOUND ) ) if( tag != null && tag.contains( "display", Tag.TAG_COMPOUND ) )

View File

@@ -22,7 +22,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.Tag; import net.minecraft.tags.TagKey;
import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.attributes.Attributes;
@@ -60,16 +60,13 @@ public class TurtleTool extends AbstractTurtleUpgrade
final ItemStack item; final ItemStack item;
final float damageMulitiplier; final float damageMulitiplier;
@Nullable @Nullable
final ResourceLocation breakableName; final TagKey<Block> breakable;
@Nullable
final Tag<Block> breakable;
public TurtleTool( ResourceLocation id, String adjective, Item craftItem, ItemStack toolItem, float damageMulitiplier, @Nullable ResourceLocation breakableName, @Nullable Tag<Block> breakable ) public TurtleTool( ResourceLocation id, String adjective, Item craftItem, ItemStack toolItem, float damageMulitiplier, @Nullable TagKey<Block> breakable )
{ {
super( id, TurtleUpgradeType.TOOL, adjective, new ItemStack( craftItem ) ); super( id, TurtleUpgradeType.TOOL, adjective, new ItemStack( craftItem ) );
item = toolItem; item = toolItem;
this.damageMulitiplier = damageMulitiplier; this.damageMulitiplier = damageMulitiplier;
this.breakableName = breakableName;
this.breakable = breakable; this.breakable = breakable;
} }
@@ -124,7 +121,7 @@ public class TurtleTool extends AbstractTurtleUpgrade
return UNBREAKABLE; return UNBREAKABLE;
} }
return breakable == null || breakable.contains( state.getBlock() ) || isTriviallyBreakable( world, pos, state ) return breakable == null || state.is( breakable ) || isTriviallyBreakable( world, pos, state )
? TurtleCommandResult.success() : INEFFECTIVE; ? TurtleCommandResult.success() : INEFFECTIVE;
} }

View File

@@ -6,14 +6,12 @@
package dan200.computercraft.shared.turtle.upgrades; package dan200.computercraft.shared.turtle.upgrades;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
import dan200.computercraft.api.turtle.TurtleUpgradeSerialiser; import dan200.computercraft.api.turtle.TurtleUpgradeSerialiser;
import dan200.computercraft.api.upgrades.IUpgradeBase; import dan200.computercraft.api.upgrades.IUpgradeBase;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.SerializationTags; import net.minecraft.tags.TagKey;
import net.minecraft.tags.Tag;
import net.minecraft.util.GsonHelper; import net.minecraft.util.GsonHelper;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
@@ -36,18 +34,14 @@ public final class TurtleToolSerialiser extends TurtleUpgradeSerialiser.Base<Tur
var craftingItem = GsonHelper.getAsItem( object, "craftingItem", toolItem ); var craftingItem = GsonHelper.getAsItem( object, "craftingItem", toolItem );
var damageMultiplier = GsonHelper.getAsFloat( object, "damageMultiplier", 3.0f ); var damageMultiplier = GsonHelper.getAsFloat( object, "damageMultiplier", 3.0f );
ResourceLocation breakableName = null; TagKey<Block> breakable = null;
Tag<Block> breakable = null;
if( object.has( "breakable" ) ) if( object.has( "breakable" ) )
{ {
breakableName = new ResourceLocation( GsonHelper.getAsString( object, "breakable" ) ); ResourceLocation tag = new ResourceLocation( GsonHelper.getAsString( object, "breakable" ) );
breakable = SerializationTags.getInstance().getTagOrThrow( breakable = TagKey.create( Registry.BLOCK_REGISTRY, tag );
Registry.BLOCK_REGISTRY, breakableName,
tagId -> new JsonSyntaxException( "Unknown item tag '" + tagId + "'" )
);
} }
return new TurtleTool( id, adjective, craftingItem, new ItemStack( toolItem ), damageMultiplier, breakableName, breakable ); return new TurtleTool( id, adjective, craftingItem, new ItemStack( toolItem ), damageMultiplier, breakable );
} }
@Nonnull @Nonnull
@@ -61,14 +55,8 @@ public final class TurtleToolSerialiser extends TurtleUpgradeSerialiser.Base<Tur
// as otherwise syncing on an SP world will overwrite the (shared) upgrade registry with an invalid upgrade! // as otherwise syncing on an SP world will overwrite the (shared) upgrade registry with an invalid upgrade!
var damageMultiplier = buffer.readFloat(); var damageMultiplier = buffer.readFloat();
ResourceLocation breakableName = null; TagKey<Block> breakable = buffer.readBoolean() ? TagKey.create( Registry.BLOCK_REGISTRY, buffer.readResourceLocation() ) : null;
Tag<Block> breakable = null; return new TurtleTool( id, adjective, craftingItem, toolItem, damageMultiplier, breakable );
if( buffer.readBoolean() )
{
breakableName = buffer.readResourceLocation();
breakable = SerializationTags.getInstance().getOrEmpty( Registry.BLOCK_REGISTRY ).getTagOrEmpty( breakableName );
}
return new TurtleTool( id, adjective, craftingItem, toolItem, damageMultiplier, breakableName, breakable );
} }
@Override @Override
@@ -78,7 +66,7 @@ public final class TurtleToolSerialiser extends TurtleUpgradeSerialiser.Base<Tur
buffer.writeRegistryIdUnsafe( ForgeRegistries.ITEMS, upgrade.getCraftingItem().getItem() ); buffer.writeRegistryIdUnsafe( ForgeRegistries.ITEMS, upgrade.getCraftingItem().getItem() );
buffer.writeItem( upgrade.item ); buffer.writeItem( upgrade.item );
buffer.writeFloat( upgrade.damageMulitiplier ); buffer.writeFloat( upgrade.damageMulitiplier );
buffer.writeBoolean( upgrade.breakableName != null ); buffer.writeBoolean( upgrade.breakable != null );
if( upgrade.breakableName != null ) buffer.writeResourceLocation( upgrade.breakableName ); if( upgrade.breakable != null ) buffer.writeResourceLocation( upgrade.breakable.location() );
} }
} }

View File

@@ -5,7 +5,7 @@
*/ */
package dan200.computercraft.shared.util; package dan200.computercraft.shared.util;
import net.minecraft.tags.Tag; import net.minecraft.tags.TagKey;
import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@@ -14,7 +14,7 @@ import net.minecraftforge.common.Tags;
public final class ColourUtils public final class ColourUtils
{ {
@SuppressWarnings( { "unchecked", "rawtypes" } ) @SuppressWarnings( { "unchecked", "rawtypes" } )
private static final Tag<Item>[] DYES = new Tag[] { private static final TagKey<Item>[] DYES = new TagKey[] {
Tags.Items.DYES_WHITE, Tags.Items.DYES_WHITE,
Tags.Items.DYES_ORANGE, Tags.Items.DYES_ORANGE,
Tags.Items.DYES_MAGENTA, Tags.Items.DYES_MAGENTA,
@@ -41,8 +41,8 @@ public final class ColourUtils
for( int i = 0; i < DYES.length; i++ ) for( int i = 0; i < DYES.length; i++ )
{ {
Tag<Item> dye = DYES[i]; TagKey<Item> dye = DYES[i];
if( dye.contains( stack.getItem() ) ) return DyeColor.byId( i ); if( stack.is( dye ) ) return DyeColor.byId( i );
} }
return null; return null;

View File

@@ -1,5 +1,5 @@
modLoader="javafml" modLoader="javafml"
loaderVersion="[39,40)" loaderVersion="[40,41)"
issueTrackerURL="https://github.com/cc-tweaked/CC-Tweaked/issues" issueTrackerURL="https://github.com/cc-tweaked/CC-Tweaked/issues"
logoFile="pack.png" logoFile="pack.png"
@@ -21,6 +21,6 @@ CC: Tweaked is a fork of ComputerCraft, adding programmable computers, turtles a
[[dependencies.computercraft]] [[dependencies.computercraft]]
modId="forge" modId="forge"
mandatory=true mandatory=true
versionRange="[39.0.0,40)" versionRange="[40.0.2,41)"
ordering="NONE" ordering="NONE"
side="BOTH" side="BOTH"

View File

@@ -1,6 +1,6 @@
{ {
"pack": { "pack": {
"pack_format": 7, "pack_format": 9,
"description": "CC: Tweaked" "description": "CC: Tweaked"
} }
} }

View File

@@ -6,9 +6,11 @@
package dan200.computercraft.core.filesystem; package dan200.computercraft.core.filesystem;
import dan200.computercraft.api.filesystem.IMount; import dan200.computercraft.api.filesystem.IMount;
import net.minecraft.Util;
import net.minecraft.server.packs.FolderPackResources; import net.minecraft.server.packs.FolderPackResources;
import net.minecraft.server.packs.PackType; import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.resources.SimpleReloadableResourceManager; import net.minecraft.server.packs.resources.ReloadableResourceManager;
import net.minecraft.util.Unit;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@@ -18,6 +20,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
@@ -28,8 +31,11 @@ public class ResourceMountTest
@BeforeEach @BeforeEach
public void before() public void before()
{ {
SimpleReloadableResourceManager manager = new SimpleReloadableResourceManager( PackType.SERVER_DATA ); ReloadableResourceManager manager = new ReloadableResourceManager( PackType.SERVER_DATA );
manager.add( new FolderPackResources( new File( "src/main/resources" ) ) ); CompletableFuture<Unit> done = new CompletableFuture<>();
manager.createReload( Util.backgroundExecutor(), Util.backgroundExecutor(), done, List.of(
new FolderPackResources( new File( "src/main/resources" ) )
) );
mount = ResourceMount.get( "computercraft", "lua/rom", manager ); mount = ResourceMount.get( "computercraft", "lua/rom", manager );
} }

View File

@@ -17,12 +17,10 @@ import net.minecraft.world.level.DataPackConfig;
import net.minecraft.world.level.GameRules; import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.GameType; import net.minecraft.world.level.GameType;
import net.minecraft.world.level.LevelSettings; import net.minecraft.world.level.LevelSettings;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.Biomes; import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.levelgen.FlatLevelSource; import net.minecraft.world.level.levelgen.FlatLevelSource;
import net.minecraft.world.level.levelgen.StructureSettings;
import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraft.world.level.levelgen.WorldGenSettings;
import net.minecraft.world.level.levelgen.flat.FlatLayerInfo; import net.minecraft.world.level.levelgen.flat.FlatLayerInfo;
import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorSettings; import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorSettings;
@@ -79,22 +77,23 @@ public final class ClientHooks
{ {
LOG.info( "World does not exist, creating it for the first time" ); LOG.info( "World does not exist, creating it for the first time" );
RegistryAccess.RegistryHolder registries = RegistryAccess.builtin(); RegistryAccess registries = RegistryAccess.builtinCopy();
Registry<DimensionType> dimensions = registries.registryOrThrow( Registry.DIMENSION_TYPE_REGISTRY ); Registry<DimensionType> dimensions = registries.registryOrThrow( Registry.DIMENSION_TYPE_REGISTRY );
Registry<Biome> biomes = registries.registryOrThrow( Registry.BIOME_REGISTRY ); var biomes = registries.registryOrThrow( Registry.BIOME_REGISTRY );
var structures = registries.registryOrThrow( Registry.STRUCTURE_SET_REGISTRY );
FlatLevelGeneratorSettings flatSettings = FlatLevelGeneratorSettings.getDefault( biomes ) FlatLevelGeneratorSettings flatSettings = FlatLevelGeneratorSettings.getDefault( biomes, structures )
.withLayers( .withLayers(
Collections.singletonList( new FlatLayerInfo( 4, Blocks.WHITE_CONCRETE ) ), Collections.singletonList( new FlatLayerInfo( 4, Blocks.WHITE_CONCRETE ) ),
new StructureSettings( Optional.empty(), Collections.emptyMap() ) Optional.empty()
); );
flatSettings.setBiome( () -> biomes.get( Biomes.DESERT ) ); flatSettings.setBiome( biomes.getHolderOrThrow( Biomes.DESERT ) );
WorldGenSettings generator = new WorldGenSettings( 0, false, false, withOverworld( WorldGenSettings generator = new WorldGenSettings( 0, false, false, withOverworld(
dimensions, dimensions,
DimensionType.defaultDimensions( registries, 0 ), DimensionType.defaultDimensions( registries, 0 ),
new FlatLevelSource( flatSettings ) new FlatLevelSource( structures, flatSettings )
) ); ) );
LevelSettings settings = new LevelSettings( LevelSettings settings = new LevelSettings(