1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-07-01 01:23:30 +00:00

Bump Forge version

- Clean up NBT constants, replace with built-in ones
 - Switch over to the new capability system
This commit is contained in:
Jonathan Coates 2021-10-06 18:28:28 +01:00
parent 29ece2a6e3
commit 0b5fe990e5
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
11 changed files with 40 additions and 44 deletions

View File

@ -157,6 +157,7 @@
</module> </module>
<module name="WhitespaceAround"> <module name="WhitespaceAround">
<property name="allowEmptyConstructors" value="true" /> <property name="allowEmptyConstructors" value="true" />
<property name="allowEmptyTypes" value="true" />
<property name="ignoreEnhancedForColon" value="false" /> <property name="ignoreEnhancedForColon" value="false" />
<property name="tokens" value="ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN,BXOR,BXOR_ASSIGN,COLON,DIV,DIV_ASSIGN,EQUAL,GE,GT,LAMBDA,LAND,LCURLY,LE,LITERAL_RETURN,LOR,LT,MINUS,MINUS_ASSIGN,MOD,MOD_ASSIGN,NOT_EQUAL,PLUS,PLUS_ASSIGN,QUESTION,RCURLY,SL,SLIST,SL_ASSIGN,SR,SR_ASSIGN,STAR,STAR_ASSIGN,LITERAL_ASSERT,TYPE_EXTENSION_AND" /> <property name="tokens" value="ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN,BXOR,BXOR_ASSIGN,COLON,DIV,DIV_ASSIGN,EQUAL,GE,GT,LAMBDA,LAND,LCURLY,LE,LITERAL_RETURN,LOR,LT,MINUS,MINUS_ASSIGN,MOD,MOD_ASSIGN,NOT_EQUAL,PLUS,PLUS_ASSIGN,QUESTION,RCURLY,SL,SLIST,SL_ASSIGN,SR,SR_ASSIGN,STAR,STAR_ASSIGN,LITERAL_ASSERT,TYPE_EXTENSION_AND" />
</module> </module>

View File

@ -5,6 +5,6 @@ mod_version=1.98.2
# Minecraft properties (update mods.toml when changing) # Minecraft properties (update mods.toml when changing)
mc_version=1.17.1 mc_version=1.17.1
mapping_version=2021.08.15 mapping_version=2021.09.05
forge_version=37.0.69 forge_version=37.0.82
# NO SERIOUSLY, UPDATE mods.toml WHEN CHANGING # NO SERIOUSLY, UPDATE mods.toml WHEN CHANGING

View File

@ -8,15 +8,14 @@
import dan200.computercraft.api.network.wired.IWiredElement; import dan200.computercraft.api.network.wired.IWiredElement;
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheral;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.common.capabilities.CapabilityToken;
public final class Capabilities public final class Capabilities
{ {
@CapabilityInject( IPeripheral.class ) public static final Capability<IPeripheral> CAPABILITY_PERIPHERAL = CapabilityManager.get( new CapabilityToken<>() {} );
public static Capability<IPeripheral> CAPABILITY_PERIPHERAL = null;
@CapabilityInject( IWiredElement.class ) public static final Capability<IWiredElement> CAPABILITY_WIRED_ELEMENT = CapabilityManager.get( new CapabilityToken<>() {} );
public static Capability<IWiredElement> CAPABILITY_WIRED_ELEMENT = null;
private Capabilities() private Capabilities()
{ {

View File

@ -15,7 +15,6 @@
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraftforge.common.util.Constants;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -69,12 +68,12 @@ public static <T extends Map<? super String, Object>> T fill( @Nonnull T data, @
data.put( "tags", DataHelpers.getTags( stack.getItem().getTags() ) ); data.put( "tags", DataHelpers.getTags( stack.getItem().getTags() ) );
CompoundTag tag = stack.getTag(); CompoundTag tag = stack.getTag();
if( tag != null && tag.contains( "display", Constants.NBT.TAG_COMPOUND ) ) if( tag != null && tag.contains( "display", Tag.TAG_COMPOUND ) )
{ {
CompoundTag displayTag = tag.getCompound( "display" ); CompoundTag displayTag = tag.getCompound( "display" );
if( displayTag.contains( "Lore", Constants.NBT.TAG_LIST ) ) if( displayTag.contains( "Lore", Tag.TAG_LIST ) )
{ {
ListTag loreTag = displayTag.getList( "Lore", Constants.NBT.TAG_STRING ); ListTag loreTag = displayTag.getList( "Lore", Tag.TAG_STRING );
data.put( "lore", loreTag.stream() data.put( "lore", loreTag.stream()
.map( ItemData::parseTextComponent ) .map( ItemData::parseTextComponent )
.filter( Objects::nonNull ) .filter( Objects::nonNull )

View File

@ -12,9 +12,9 @@
import net.minecraft.core.BlockPos; 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.nbt.Tag;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.common.util.NonNullConsumer; import net.minecraftforge.common.util.NonNullConsumer;
@ -131,10 +131,10 @@ public void write( @Nonnull CompoundTag tag, @Nonnull String suffix )
public void read( @Nonnull CompoundTag tag, @Nonnull String suffix ) public void read( @Nonnull CompoundTag tag, @Nonnull String suffix )
{ {
id = tag.contains( NBT_PERIPHERAL_ID + suffix, Constants.NBT.TAG_ANY_NUMERIC ) id = tag.contains( NBT_PERIPHERAL_ID + suffix, Tag.TAG_ANY_NUMERIC )
? tag.getInt( NBT_PERIPHERAL_ID + suffix ) : -1; ? tag.getInt( NBT_PERIPHERAL_ID + suffix ) : -1;
type = tag.contains( NBT_PERIPHERAL_TYPE + suffix, Constants.NBT.TAG_STRING ) type = tag.contains( NBT_PERIPHERAL_TYPE + suffix, Tag.TAG_STRING )
? tag.getString( NBT_PERIPHERAL_TYPE + suffix ) : null; ? tag.getString( NBT_PERIPHERAL_TYPE + suffix ) : null;
} }

View File

@ -16,6 +16,7 @@
import dan200.computercraft.shared.network.NetworkHandler; import dan200.computercraft.shared.network.NetworkHandler;
import dan200.computercraft.shared.pocket.items.ItemPocketComputer; import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -24,7 +25,6 @@
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraftforge.common.util.Constants;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -83,7 +83,7 @@ public void setColour( int colour )
public int getLight() public int getLight()
{ {
CompoundTag tag = getUserData(); CompoundTag tag = getUserData();
return tag.contains( NBT_LIGHT, Constants.NBT.TAG_ANY_NUMERIC ) ? tag.getInt( NBT_LIGHT ) : -1; return tag.contains( NBT_LIGHT, Tag.TAG_ANY_NUMERIC ) ? tag.getInt( NBT_LIGHT ) : -1;
} }
@Override @Override
@ -92,13 +92,13 @@ public void setLight( int colour )
CompoundTag tag = getUserData(); CompoundTag tag = getUserData();
if( colour >= 0 && colour <= 0xFFFFFF ) if( colour >= 0 && colour <= 0xFFFFFF )
{ {
if( !tag.contains( NBT_LIGHT, Constants.NBT.TAG_ANY_NUMERIC ) || tag.getInt( NBT_LIGHT ) != colour ) if( !tag.contains( NBT_LIGHT, Tag.TAG_ANY_NUMERIC ) || tag.getInt( NBT_LIGHT ) != colour )
{ {
tag.putInt( NBT_LIGHT, colour ); tag.putInt( NBT_LIGHT, colour );
updateUserData(); updateUserData();
} }
} }
else if( tag.contains( NBT_LIGHT, Constants.NBT.TAG_ANY_NUMERIC ) ) else if( tag.contains( NBT_LIGHT, Tag.TAG_ANY_NUMERIC ) )
{ {
tag.remove( NBT_LIGHT ); tag.remove( NBT_LIGHT );
updateUserData(); updateUserData();

View File

@ -28,6 +28,7 @@
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
@ -43,7 +44,6 @@
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.wrapper.InvWrapper; import net.minecraftforge.items.wrapper.InvWrapper;
@ -271,7 +271,7 @@ public void load( @Nonnull CompoundTag nbt )
super.load( nbt ); super.load( nbt );
// Read inventory // Read inventory
ListTag nbttaglist = nbt.getList( "Items", Constants.NBT.TAG_COMPOUND ); ListTag nbttaglist = nbt.getList( "Items", Tag.TAG_COMPOUND );
inventory.clear(); inventory.clear();
previousInventory.clear(); previousInventory.clear();
for( int i = 0; i < nbttaglist.size(); i++ ) for( int i = 0; i < nbttaglist.size(); i++ )

View File

@ -26,6 +26,7 @@
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.particles.ParticleTypes; import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.FluidTags; import net.minecraft.tags.FluidTags;
import net.minecraft.world.Container; import net.minecraft.world.Container;
@ -40,7 +41,6 @@
import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.wrapper.InvWrapper; import net.minecraftforge.items.wrapper.InvWrapper;
@ -206,7 +206,7 @@ public void readFromNBT( CompoundTag nbt )
selectedSlot = nbt.getInt( NBT_SLOT ); selectedSlot = nbt.getInt( NBT_SLOT );
// Read owner // Read owner
if( nbt.contains( "Owner", Constants.NBT.TAG_COMPOUND ) ) if( nbt.contains( "Owner", Tag.TAG_COMPOUND ) )
{ {
CompoundTag owner = nbt.getCompound( "Owner" ); CompoundTag owner = nbt.getCompound( "Owner" );
owningPlayer = new GameProfile( owningPlayer = new GameProfile(

View File

@ -19,6 +19,7 @@
import net.minecraft.core.BlockPos; 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.nbt.Tag;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -36,7 +37,6 @@
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.event.entity.player.AttackEntityEvent; import net.minecraftforge.event.entity.player.AttackEntityEvent;
import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.event.world.BlockEvent;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
@ -75,8 +75,8 @@ public boolean isItemSuitable( @Nonnull ItemStack stack )
// Check we've not got anything vaguely interesting on the item. We allow other mods to add their // Check we've not got anything vaguely interesting on the item. We allow other mods to add their
// own NBT, with the understanding such details will be lost to the mist of time. // own NBT, with the understanding such details will be lost to the mist of time.
if( stack.isDamaged() || stack.isEnchanted() || stack.hasCustomHoverName() ) return false; if( stack.isDamaged() || stack.isEnchanted() || stack.hasCustomHoverName() ) return false;
if( tag.contains( "AttributeModifiers", Constants.NBT.TAG_LIST ) && if( tag.contains( "AttributeModifiers", Tag.TAG_LIST ) &&
!tag.getList( "AttributeModifiers", Constants.NBT.TAG_COMPOUND ).isEmpty() ) !tag.getList( "AttributeModifiers", Tag.TAG_COMPOUND ).isEmpty() )
{ {
return false; return false;
} }

View File

@ -7,7 +7,6 @@
import dan200.computercraft.ComputerCraft; import dan200.computercraft.ComputerCraft;
import net.minecraft.nbt.*; import net.minecraft.nbt.*;
import net.minecraftforge.common.util.Constants;
import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.binary.Hex;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@ -21,8 +20,6 @@
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static net.minecraftforge.common.util.Constants.NBT.*;
public final class NBTUtil public final class NBTUtil
{ {
private NBTUtil() {} private NBTUtil() {}
@ -74,14 +71,14 @@ private static Object fromNBTTag( Tag tag )
if( tag == null ) return null; if( tag == null ) return null;
switch( tag.getId() ) switch( tag.getId() )
{ {
case TAG_BYTE: case Tag.TAG_BYTE:
return ((ByteTag) tag).getAsByte() > 0; return ((ByteTag) tag).getAsByte() > 0;
case TAG_DOUBLE: case Tag.TAG_DOUBLE:
return ((DoubleTag) tag).getAsDouble(); return ((DoubleTag) tag).getAsDouble();
default: default:
case TAG_STRING: case Tag.TAG_STRING:
return tag.getAsString(); return tag.getAsString();
case TAG_COMPOUND: case Tag.TAG_COMPOUND:
{ {
CompoundTag c = (CompoundTag) tag; CompoundTag c = (CompoundTag) tag;
int len = c.getInt( "len" ); int len = c.getInt( "len" );
@ -104,17 +101,17 @@ public static Object toLua( Tag tag )
byte typeID = tag.getId(); byte typeID = tag.getId();
switch( typeID ) switch( typeID )
{ {
case Constants.NBT.TAG_BYTE: case Tag.TAG_BYTE:
case Constants.NBT.TAG_SHORT: case Tag.TAG_SHORT:
case Constants.NBT.TAG_INT: case Tag.TAG_INT:
case Constants.NBT.TAG_LONG: case Tag.TAG_LONG:
return ((NumericTag) tag).getAsLong(); return ((NumericTag) tag).getAsLong();
case Constants.NBT.TAG_FLOAT: case Tag.TAG_FLOAT:
case Constants.NBT.TAG_DOUBLE: case Tag.TAG_DOUBLE:
return ((NumericTag) tag).getAsDouble(); return ((NumericTag) tag).getAsDouble();
case Constants.NBT.TAG_STRING: // String case Tag.TAG_STRING: // String
return tag.getAsString(); return tag.getAsString();
case Constants.NBT.TAG_COMPOUND: // Compound case Tag.TAG_COMPOUND: // Compound
{ {
CompoundTag compound = (CompoundTag) tag; CompoundTag compound = (CompoundTag) tag;
Map<String, Object> map = new HashMap<>( compound.size() ); Map<String, Object> map = new HashMap<>( compound.size() );
@ -125,21 +122,21 @@ public static Object toLua( Tag tag )
} }
return map; return map;
} }
case Constants.NBT.TAG_LIST: case Tag.TAG_LIST:
{ {
ListTag list = (ListTag) tag; ListTag list = (ListTag) tag;
Map<Integer, Object> map = new HashMap<>( list.size() ); Map<Integer, Object> map = new HashMap<>( list.size() );
for( int i = 0; i < list.size(); i++ ) map.put( i, toLua( list.get( i ) ) ); for( int i = 0; i < list.size(); i++ ) map.put( i, toLua( list.get( i ) ) );
return map; return map;
} }
case Constants.NBT.TAG_BYTE_ARRAY: case Tag.TAG_BYTE_ARRAY:
{ {
byte[] array = ((ByteArrayTag) tag).getAsByteArray(); byte[] array = ((ByteArrayTag) tag).getAsByteArray();
Map<Integer, Byte> map = new HashMap<>( array.length ); Map<Integer, Byte> map = new HashMap<>( array.length );
for( int i = 0; i < array.length; i++ ) map.put( i + 1, array[i] ); for( int i = 0; i < array.length; i++ ) map.put( i + 1, array[i] );
return map; return map;
} }
case Constants.NBT.TAG_INT_ARRAY: case Tag.TAG_INT_ARRAY:
{ {
int[] array = ((IntArrayTag) tag).getAsIntArray(); int[] array = ((IntArrayTag) tag).getAsIntArray();
Map<Integer, Integer> map = new HashMap<>( array.length ); Map<Integer, Integer> map = new HashMap<>( array.length );

View File

@ -20,6 +20,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="[37.0.69,38)" versionRange="[37.0.82,38)"
ordering="NONE" ordering="NONE"
side="BOTH" side="BOTH"