mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 13:42:59 +00:00 
			
		
		
		
	Fix incorrect Lua list indexes in NBT tags (#1678)
This commit is contained in:
		| @@ -20,28 +20,24 @@ import net.minecraft.world.level.block.state.BlockState; | |||||||
| import net.minecraft.world.phys.Vec2; | import net.minecraft.world.phys.Vec2; | ||||||
| import net.minecraft.world.phys.Vec3; | import net.minecraft.world.phys.Vec3; | ||||||
| 
 | 
 | ||||||
| import java.util.HashMap; | import java.util.ArrayList; | ||||||
| import java.util.Map; | import java.util.List; | ||||||
| 
 | 
 | ||||||
| public class CommandComputerBlockEntity extends ComputerBlockEntity { | public class CommandComputerBlockEntity extends ComputerBlockEntity { | ||||||
|     public class CommandReceiver implements CommandSource { |     public class CommandReceiver implements CommandSource { | ||||||
|         private final Map<Integer, String> output = new HashMap<>(); |         private final List<String> output = new ArrayList<>(); | ||||||
| 
 | 
 | ||||||
|         public void clearOutput() { |         public void clearOutput() { | ||||||
|             output.clear(); |             output.clear(); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         public Map<Integer, String> getOutput() { |         public List<String> copyOutput() { | ||||||
|             return output; |             return new ArrayList<>(output); | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         public Map<Integer, String> copyOutput() { |  | ||||||
|             return new HashMap<>(output); |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         @Override |         @Override | ||||||
|         public void sendSystemMessage(Component textComponent) { |         public void sendSystemMessage(Component textComponent) { | ||||||
|             output.put(output.size() + 1, textComponent.getString()); |             output.add(textComponent.getString()); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         @Override |         @Override | ||||||
|   | |||||||
| @@ -19,9 +19,7 @@ import java.io.IOException; | |||||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||||
| import java.security.MessageDigest; | import java.security.MessageDigest; | ||||||
| import java.security.NoSuchAlgorithmException; | import java.security.NoSuchAlgorithmException; | ||||||
| import java.util.Arrays; | import java.util.*; | ||||||
| import java.util.HashMap; |  | ||||||
| import java.util.Map; |  | ||||||
| 
 | 
 | ||||||
| public final class NBTUtil { | public final class NBTUtil { | ||||||
|     private static final Logger LOG = LoggerFactory.getLogger(NBTUtil.class); |     private static final Logger LOG = LoggerFactory.getLogger(NBTUtil.class); | ||||||
| @@ -149,20 +147,20 @@ public final class NBTUtil { | |||||||
|             } |             } | ||||||
|             case Tag.TAG_LIST: { |             case Tag.TAG_LIST: { | ||||||
|                 var list = (ListTag) tag; |                 var list = (ListTag) tag; | ||||||
|                 Map<Integer, Object> map = new HashMap<>(list.size()); |                 List<Object> map = new ArrayList<>(list.size()); | ||||||
|                 for (var i = 0; i < list.size(); i++) map.put(i, toLua(list.get(i))); |                 for (var value : list) map.add(toLua(value)); | ||||||
|                 return map; |                 return map; | ||||||
|             } |             } | ||||||
|             case Tag.TAG_BYTE_ARRAY: { |             case Tag.TAG_BYTE_ARRAY: { | ||||||
|                 var array = ((ByteArrayTag) tag).getAsByteArray(); |                 var array = ((ByteArrayTag) tag).getAsByteArray(); | ||||||
|                 Map<Integer, Byte> map = new HashMap<>(array.length); |                 List<Byte> map = new ArrayList<>(array.length); | ||||||
|                 for (var i = 0; i < array.length; i++) map.put(i + 1, array[i]); |                 for (var b : array) map.add(b); | ||||||
|                 return map; |                 return map; | ||||||
|             } |             } | ||||||
|             case Tag.TAG_INT_ARRAY: { |             case Tag.TAG_INT_ARRAY: { | ||||||
|                 var array = ((IntArrayTag) tag).getAsIntArray(); |                 var array = ((IntArrayTag) tag).getAsIntArray(); | ||||||
|                 Map<Integer, Integer> map = new HashMap<>(array.length); |                 List<Integer> map = new ArrayList<>(array.length); | ||||||
|                 for (var i = 0; i < array.length; i++) map.put(i + 1, array[i]); |                 for (var j : array) map.add(j); | ||||||
|                 return map; |                 return map; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 lonevox
					lonevox