1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-25 22:53:22 +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
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
38 changed files with 112 additions and 131 deletions

View File

@ -159,8 +159,8 @@ accessTransformer file('src/testMod/resources/META-INF/accesstransformer.cfg')
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
annotationProcessor 'org.spongepowered:mixin:0.8.4:processor'
compileOnly fg.deobf("mezz.jei:jei-1.18.1:9.1.0.47:api")
runtimeOnly fg.deobf("mezz.jei:jei-1.18.1:9.1.0.47")
compileOnly fg.deobf("mezz.jei:jei-1.18.2:9.4.1.116:api")
runtimeOnly fg.deobf("mezz.jei:jei-1.18.2:9.4.1.116")
shade 'org.squiddev:Cobalt:0.5.2-SNAPSHOT'

View File

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

View File

@ -22,8 +22,7 @@
"cable": "true"
}
}
],
"functions": []
]
},
{
"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"
}
],
"functions": []
]
}
]
}

View File

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

View File

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

View File

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

View File

@ -15,8 +15,7 @@
{
"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"
}
],
"functions": []
]
}
]
}

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
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.level.block.Block;
@ -20,47 +20,47 @@ public class ComputerCraftTags
{
public static class Items
{
public static final Tag.Named<Item> COMPUTER = make( "computer" );
public static final Tag.Named<Item> TURTLE = make( "turtle" );
public static final Tag.Named<Item> WIRED_MODEM = make( "wired_modem" );
public static final Tag.Named<Item> MONITOR = make( "monitor" );
public static final TagKey<Item> COMPUTER = make( "computer" );
public static final TagKey<Item> TURTLE = make( "turtle" );
public static final TagKey<Item> WIRED_MODEM = make( "wired_modem" );
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 final Tag.Named<Block> COMPUTER = make( "computer" );
public static final Tag.Named<Block> TURTLE = make( "turtle" );
public static final Tag.Named<Block> WIRED_MODEM = make( "wired_modem" );
public static final Tag.Named<Block> MONITOR = make( "monitor" );
public static final TagKey<Block> COMPUTER = make( "computer" );
public static final TagKey<Block> TURTLE = make( "turtle" );
public static final TagKey<Block> WIRED_MODEM = make( "wired_modem" );
public static final TagKey<Block> MONITOR = make( "monitor" );
/**
* 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.
*/
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.
*/
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.
*/
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.upgrades.UpgradeDataProvider;
import net.minecraft.data.DataGenerator;
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.item.Item;
import net.minecraft.world.level.block.Block;
@ -42,7 +42,7 @@ public TurtleUpgradeDataProvider( DataGenerator generator )
*
* @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
* 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,
*/
@Nonnull
@ -64,7 +64,7 @@ public static class ToolBuilder
private String adjective;
private Item craftingItem;
private Float damageMultiplier = null;
private Tag.Named<Block> breakable;
private TagKey<Block> breakable;
ToolBuilder( ResourceLocation id, TurtleUpgradeSerialiser<?> serialiser, Item toolItem )
{
@ -123,7 +123,7 @@ public ToolBuilder damageMultiplier( float damageMultiplier )
* @return The tool builder, for further use.
* @see ComputerCraftTags.Blocks
*/
public ToolBuilder breakable( @Nonnull Tag.Named<Block> breakable )
public ToolBuilder breakable( @Nonnull TagKey<Block> breakable )
{
this.breakable = breakable;
return this;
@ -141,7 +141,7 @@ public void add( @Nonnull Consumer<Upgrade<TurtleUpgradeSerialiser<?>>> add )
if( adjective != null ) s.addProperty( "adjective", adjective );
if( craftingItem != null ) s.addProperty( "craftItem", craftingItem.getRegistryName().toString() );
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.recipes.*;
import net.minecraft.nbt.CompoundTag;
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.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.SimpleRecipeSerializer;
@ -370,7 +370,7 @@ private static DyeColor ofColour( Colour colour )
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() );
}

View File

@ -32,7 +32,7 @@ public static boolean isPlayer( CommandSourceStack output )
}
@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();
if( !(source instanceof SharedSuggestionProvider) )
@ -45,7 +45,7 @@ else if( source instanceof CommandSourceStack )
}
else
{
return ((SharedSuggestionProvider) source).customSuggestion( (CommandContext<SharedSuggestionProvider>) context, builder );
return ((SharedSuggestionProvider) source).customSuggestion( context );
}
}

View File

@ -121,7 +121,7 @@ public <S> CompletableFuture<Suggestions> listSuggestions( CommandContext<S> con
}
// 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( "@" ) )
{
suggestComputers( builder, remaining, x -> {

View File

@ -16,7 +16,6 @@
import net.minecraft.commands.Commands;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
@ -81,7 +80,7 @@ private Object[] doCommand( String command )
Map<String, Object> table = BlockData.fill( new HashMap<>(), state );
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;
}

View File

@ -96,7 +96,7 @@ public void onRuntimeAvailable( IJeiRuntime runtime )
IRecipeCategory<?> category = registry.getRecipeCategory( VanillaRecipeCategoryUid.CRAFTING, false );
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;
ResourceLocation id = ((Recipe<?>) wrapper).getId();

View File

@ -97,10 +97,10 @@ private boolean hasUpgrade( @Nonnull ItemStack stack )
@Override
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();
switch( focus.getMode() )
switch( focus.getRole() )
{
case INPUT:
return stack.getItem() instanceof ITurtleItem || stack.getItem() instanceof ItemPocketComputer ||
@ -120,12 +120,12 @@ public <V> List<ResourceLocation> getRecipeCategoryUids( @Nonnull IFocus<V> focu
@Override
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();
}
switch( focus.getMode() )
switch( focus.getRole() )
{
case INPUT:
return cast( findRecipesWithInput( stack ) );

View File

@ -46,7 +46,7 @@ public boolean matches( @Nonnull CraftingContainer inv, @Nonnull Level world )
if( paperFound ) return false;
paperFound = true;
}
else if( Tags.Items.DUSTS_REDSTONE.contains( stack.getItem() ) )
else if( stack.is( Tags.Items.DUSTS_REDSTONE ) )
{
if( redstoneFound ) return false;
redstoneFound = true;
@ -73,7 +73,7 @@ public ItemStack assemble( @Nonnull CraftingContainer inv )
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 );
if( dye != null ) tracker.addColour( dye );

View File

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

View File

@ -26,7 +26,7 @@ public static <T extends Map<? super String, Object>> T fill( @Nonnull T data, @
stateTable.put( property.getName(), getPropertyValue( property, entry.getValue() ) );
}
data.put( "state", stateTable );
data.put( "tags", DataHelpers.getTags( state.getBlock().getTags() ) );
data.put( "tags", DataHelpers.getTags( state.getTags() ) );
return data;
}

View File

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

View File

@ -24,7 +24,10 @@ public static <T extends Map<? super String, Object>> T fillBasic( @Nonnull T da
public static <T extends Map<? super String, Object>> T fill( @Nonnull T data, @Nonnull FluidStack 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;
}
}

View File

@ -65,7 +65,7 @@ public static <T extends Map<? super String, Object>> T fill( @Nonnull T data, @
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();
if( tag != null && tag.contains( "display", Tag.TAG_COMPOUND ) )

View File

@ -22,7 +22,7 @@
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
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.entity.Entity;
import net.minecraft.world.entity.ai.attributes.Attributes;
@ -60,16 +60,13 @@ public class TurtleTool extends AbstractTurtleUpgrade
final ItemStack item;
final float damageMulitiplier;
@Nullable
final ResourceLocation breakableName;
@Nullable
final Tag<Block> breakable;
final TagKey<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 ) );
item = toolItem;
this.damageMulitiplier = damageMulitiplier;
this.breakableName = breakableName;
this.breakable = breakable;
}
@ -124,7 +121,7 @@ protected TurtleCommandResult checkBlockBreakable( BlockState state, Level world
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;
}

View File

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

View File

@ -5,7 +5,7 @@
*/
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.Item;
import net.minecraft.world.item.ItemStack;
@ -14,7 +14,7 @@
public final class ColourUtils
{
@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_ORANGE,
Tags.Items.DYES_MAGENTA,
@ -41,8 +41,8 @@ public static DyeColor getStackColour( ItemStack stack )
for( int i = 0; i < DYES.length; i++ )
{
Tag<Item> dye = DYES[i];
if( dye.contains( stack.getItem() ) ) return DyeColor.byId( i );
TagKey<Item> dye = DYES[i];
if( stack.is( dye ) ) return DyeColor.byId( i );
}
return null;

View File

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

View File

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

View File

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

View File

@ -17,12 +17,10 @@
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.GameType;
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.block.Blocks;
import net.minecraft.world.level.dimension.DimensionType;
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.flat.FlatLayerInfo;
import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorSettings;
@ -79,22 +77,23 @@ private static void openWorld()
{
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<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(
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(
dimensions,
DimensionType.defaultDimensions( registries, 0 ),
new FlatLevelSource( flatSettings )
new FlatLevelSource( structures, flatSettings )
) );
LevelSettings settings = new LevelSettings(