mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-14 04:00: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:
parent
29ece2a6e3
commit
0b5fe990e5
@ -157,6 +157,7 @@
|
||||
</module>
|
||||
<module name="WhitespaceAround">
|
||||
<property name="allowEmptyConstructors" value="true" />
|
||||
<property name="allowEmptyTypes" value="true" />
|
||||
<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" />
|
||||
</module>
|
||||
|
@ -5,6 +5,6 @@ mod_version=1.98.2
|
||||
|
||||
# Minecraft properties (update mods.toml when changing)
|
||||
mc_version=1.17.1
|
||||
mapping_version=2021.08.15
|
||||
forge_version=37.0.69
|
||||
mapping_version=2021.09.05
|
||||
forge_version=37.0.82
|
||||
# NO SERIOUSLY, UPDATE mods.toml WHEN CHANGING
|
||||
|
@ -8,15 +8,14 @@ package dan200.computercraft.shared;
|
||||
import dan200.computercraft.api.network.wired.IWiredElement;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
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
|
||||
{
|
||||
@CapabilityInject( IPeripheral.class )
|
||||
public static Capability<IPeripheral> CAPABILITY_PERIPHERAL = null;
|
||||
public static final Capability<IPeripheral> CAPABILITY_PERIPHERAL = CapabilityManager.get( new CapabilityToken<>() {} );
|
||||
|
||||
@CapabilityInject( IWiredElement.class )
|
||||
public static Capability<IWiredElement> CAPABILITY_WIRED_ELEMENT = null;
|
||||
public static final Capability<IWiredElement> CAPABILITY_WIRED_ELEMENT = CapabilityManager.get( new CapabilityToken<>() {} );
|
||||
|
||||
private Capabilities()
|
||||
{
|
||||
|
@ -15,7 +15,6 @@ import net.minecraft.world.item.EnchantedBookItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -69,12 +68,12 @@ public class ItemData
|
||||
data.put( "tags", DataHelpers.getTags( stack.getItem().getTags() ) );
|
||||
|
||||
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" );
|
||||
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()
|
||||
.map( ItemData::parseTextComponent )
|
||||
.filter( Objects::nonNull )
|
||||
|
@ -12,9 +12,9 @@ import dan200.computercraft.shared.util.IDAssigner;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.common.util.NonNullConsumer;
|
||||
|
||||
@ -131,10 +131,10 @@ public final class WiredModemLocalPeripheral
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@ import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.network.NetworkHandler;
|
||||
import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
@ -24,7 +25,6 @@ import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -83,7 +83,7 @@ public class PocketServerComputer extends ServerComputer implements IPocketAcces
|
||||
public int getLight()
|
||||
{
|
||||
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
|
||||
@ -92,13 +92,13 @@ public class PocketServerComputer extends ServerComputer implements IPocketAcces
|
||||
CompoundTag tag = getUserData();
|
||||
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 );
|
||||
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 );
|
||||
updateUserData();
|
||||
|
@ -28,6 +28,7 @@ import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
@ -43,7 +44,6 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import net.minecraftforge.items.wrapper.InvWrapper;
|
||||
@ -271,7 +271,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
super.load( nbt );
|
||||
|
||||
// Read inventory
|
||||
ListTag nbttaglist = nbt.getList( "Items", Constants.NBT.TAG_COMPOUND );
|
||||
ListTag nbttaglist = nbt.getList( "Items", Tag.TAG_COMPOUND );
|
||||
inventory.clear();
|
||||
previousInventory.clear();
|
||||
for( int i = 0; i < nbttaglist.size(); i++ )
|
||||
|
@ -26,6 +26,7 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.world.Container;
|
||||
@ -40,7 +41,6 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import net.minecraftforge.items.wrapper.InvWrapper;
|
||||
|
||||
@ -206,7 +206,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
selectedSlot = nbt.getInt( NBT_SLOT );
|
||||
|
||||
// Read owner
|
||||
if( nbt.contains( "Owner", Constants.NBT.TAG_COMPOUND ) )
|
||||
if( nbt.contains( "Owner", Tag.TAG_COMPOUND ) )
|
||||
{
|
||||
CompoundTag owner = nbt.getCompound( "Owner" );
|
||||
owningPlayer = new GameProfile(
|
||||
|
@ -19,6 +19,7 @@ import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
@ -36,7 +37,6 @@ import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@ -75,8 +75,8 @@ public class TurtleTool extends AbstractTurtleUpgrade
|
||||
// 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.
|
||||
if( stack.isDamaged() || stack.isEnchanted() || stack.hasCustomHoverName() ) return false;
|
||||
if( tag.contains( "AttributeModifiers", Constants.NBT.TAG_LIST ) &&
|
||||
!tag.getList( "AttributeModifiers", Constants.NBT.TAG_COMPOUND ).isEmpty() )
|
||||
if( tag.contains( "AttributeModifiers", Tag.TAG_LIST ) &&
|
||||
!tag.getList( "AttributeModifiers", Tag.TAG_COMPOUND ).isEmpty() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ package dan200.computercraft.shared.util;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@ -21,8 +20,6 @@ import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.minecraftforge.common.util.Constants.NBT.*;
|
||||
|
||||
public final class NBTUtil
|
||||
{
|
||||
private NBTUtil() {}
|
||||
@ -74,14 +71,14 @@ public final class NBTUtil
|
||||
if( tag == null ) return null;
|
||||
switch( tag.getId() )
|
||||
{
|
||||
case TAG_BYTE:
|
||||
case Tag.TAG_BYTE:
|
||||
return ((ByteTag) tag).getAsByte() > 0;
|
||||
case TAG_DOUBLE:
|
||||
case Tag.TAG_DOUBLE:
|
||||
return ((DoubleTag) tag).getAsDouble();
|
||||
default:
|
||||
case TAG_STRING:
|
||||
case Tag.TAG_STRING:
|
||||
return tag.getAsString();
|
||||
case TAG_COMPOUND:
|
||||
case Tag.TAG_COMPOUND:
|
||||
{
|
||||
CompoundTag c = (CompoundTag) tag;
|
||||
int len = c.getInt( "len" );
|
||||
@ -104,17 +101,17 @@ public final class NBTUtil
|
||||
byte typeID = tag.getId();
|
||||
switch( typeID )
|
||||
{
|
||||
case Constants.NBT.TAG_BYTE:
|
||||
case Constants.NBT.TAG_SHORT:
|
||||
case Constants.NBT.TAG_INT:
|
||||
case Constants.NBT.TAG_LONG:
|
||||
case Tag.TAG_BYTE:
|
||||
case Tag.TAG_SHORT:
|
||||
case Tag.TAG_INT:
|
||||
case Tag.TAG_LONG:
|
||||
return ((NumericTag) tag).getAsLong();
|
||||
case Constants.NBT.TAG_FLOAT:
|
||||
case Constants.NBT.TAG_DOUBLE:
|
||||
case Tag.TAG_FLOAT:
|
||||
case Tag.TAG_DOUBLE:
|
||||
return ((NumericTag) tag).getAsDouble();
|
||||
case Constants.NBT.TAG_STRING: // String
|
||||
case Tag.TAG_STRING: // String
|
||||
return tag.getAsString();
|
||||
case Constants.NBT.TAG_COMPOUND: // Compound
|
||||
case Tag.TAG_COMPOUND: // Compound
|
||||
{
|
||||
CompoundTag compound = (CompoundTag) tag;
|
||||
Map<String, Object> map = new HashMap<>( compound.size() );
|
||||
@ -125,21 +122,21 @@ public final class NBTUtil
|
||||
}
|
||||
return map;
|
||||
}
|
||||
case Constants.NBT.TAG_LIST:
|
||||
case Tag.TAG_LIST:
|
||||
{
|
||||
ListTag list = (ListTag) tag;
|
||||
Map<Integer, Object> map = new HashMap<>( list.size() );
|
||||
for( int i = 0; i < list.size(); i++ ) map.put( i, toLua( list.get( i ) ) );
|
||||
return map;
|
||||
}
|
||||
case Constants.NBT.TAG_BYTE_ARRAY:
|
||||
case Tag.TAG_BYTE_ARRAY:
|
||||
{
|
||||
byte[] array = ((ByteArrayTag) tag).getAsByteArray();
|
||||
Map<Integer, Byte> map = new HashMap<>( array.length );
|
||||
for( int i = 0; i < array.length; i++ ) map.put( i + 1, array[i] );
|
||||
return map;
|
||||
}
|
||||
case Constants.NBT.TAG_INT_ARRAY:
|
||||
case Tag.TAG_INT_ARRAY:
|
||||
{
|
||||
int[] array = ((IntArrayTag) tag).getAsIntArray();
|
||||
Map<Integer, Integer> map = new HashMap<>( array.length );
|
||||
|
@ -20,6 +20,6 @@ CC: Tweaked is a fork of ComputerCraft, adding programmable computers, turtles a
|
||||
[[dependencies.computercraft]]
|
||||
modId="forge"
|
||||
mandatory=true
|
||||
versionRange="[37.0.69,38)"
|
||||
versionRange="[37.0.82,38)"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
Loading…
Reference in New Issue
Block a user