1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-11-02 06:32:59 +00:00

Compare commits

...

22 Commits

Author SHA1 Message Date
Jonathan Coates
70c5cbafec Merge branch 'mc-1.16.x' into mc-1.17.x 2022-03-23 08:39:39 +00:00
Jonathan Coates
2c64186965 Bump version to 1.100.4 2022-03-23 08:36:09 +00:00
Jonathan Coates
31ba17d085 Don't wait for the chunk to be loaded when checking for monitors
There's a couple of alternative ways to solve this. Ideally we'd send
our network messages at the same time as MC does
(ChunkManager.playerLoadedChunk), but this'd require a mixin.

Instead we just rely on the fact that if the chunk isn't loaded,
monitors won't have done anything and so we don't need to send their
contents!

Fixes #1047, probably doesn't cause any regressions. I've not seen any
issues on 1.16, but I also hadn't before so ¯\_(ツ)_/¯.
2022-03-18 19:59:02 +00:00
Jonathan Coates
6353e8d930 Merge branch 'mc-1.16.x' into mc-1.17.x 2022-03-03 10:45:25 +00:00
Jonathan Coates
bcc7dd6991 Fix typo in Javadoc 2022-03-02 12:54:59 +00:00
Jonathan Coates
4a4e8bb4b6 Merge branch 'mc-1.16.x' into mc-1.17.x 2022-02-28 16:25:33 +00:00
Jonathan Coates
bd36185662 Bump version
Holding off until Forge releases for 1.18.2
2022-02-28 15:35:16 +00:00
Jonathan Coates
045c4fc88c Merge pull request #1027 from Toad-Dev/issue-1026
Fix large file uploads producing oversized packets.
2022-02-28 11:06:59 +00:00
Jonathan Coates
e0fcc425c6 Prevent id map being null when file is empty
Fixes #1030
2022-02-28 11:01:04 +00:00
Jonathan Coates
e01895d719 Remove turtle_player EntityType
This was added in the 1.13 update and I'm still not sure why. Other mods
seem to get away without it, so I think it's fine to remove.

Also remove the fake net manager, as that's part of Forge nowadays.

Fixes #1044.
2022-02-28 10:34:41 +00:00
Jonathan Coates
87b38f4249 Fix incorrect recipe name in turtle advancement 2022-02-28 10:32:33 +00:00
Toad-Dev
60d1d1bb18 Fix large file uploads producing oversized packets.
- Fixes #1026
- The remaining bytes counter wasn't being decremented, so the code that
  splits off smaller packets was unreachable. Thus all file slices were
  being put into a single UploadFileMessage packet.
2022-01-23 22:31:27 -08:00
Jonathan Coates
cdf8b77ffd Merge pull request #1017 from Possseidon/patch-1
Fix table with mouse button codes in documentation.
2022-01-20 12:40:09 +00:00
Possseidon
e2ce52fe81 Fix table with mouse button codes.
Codes for right and middle mouse buttons were swapped.
2022-01-19 17:39:19 +01:00
Jonathan Coates
e05588c662 Merge branch 'mc-1.16.x' into mc-1.17.x 2022-01-14 23:00:17 +00:00
Jonathan Coates
9cf70b10ef Bump version 2022-01-14 22:58:19 +00:00
Jonathan Coates
9ac8f3aeea Fix wired modems having incorrect blockstate
Fixes #1010
2022-01-14 15:37:49 +00:00
Jonathan Coates
e191b08eb5 Use Guava instead of commons-codec for hex encoding
The latter was removed in 1.18 on the server side.

Fixes #1011.
2022-01-14 15:35:58 +00:00
Jonathan Coates
a1221b99e1 Remove debugging log line
Fixes #1014
2022-01-14 14:45:55 +00:00
Jonathan Coates
85bced6b1d Merge pull request #1015 from Paspartout/patch-1
speaker_audio.md: Fix missing add/sum typo
2022-01-14 10:55:08 +00:00
Paspartout
fc4569e0cc speaker_audio.md: Fix missing add/sum typo 2022-01-13 17:36:26 +01:00
Weblate
e7f08313d9 Translations for Danish
Co-authored-by: Christian L.W <christianlw@hotmail.dk>
Co-authored-by: Christian L.W. <christianlw@hotmail.dk>
2022-01-02 23:29:24 +00:00
17 changed files with 77 additions and 62 deletions

View File

@@ -19,8 +19,8 @@ numerical value depending on which button on your mouse was last pressed when th
<!-- Our markdown parser doesn't work on tables!? Guess I'll have to roll my own soonish :/. -->
<tr><th>Button code</th><th>Mouse button</th></tr>
<tr><td align="right">1</td><td>Left button</td></tr>
<tr><td align="right">2</td><td>Middle button</td></tr>
<tr><td align="right">3</td><td>Right button</td></tr>
<tr><td align="right">2</td><td>Right button</td></tr>
<tr><td align="right">3</td><td>Middle button</td></tr>
</table>
## Example

View File

@@ -18,7 +18,7 @@ representable value.
This representation of sound - a long, uniformally sampled list of amplitudes is referred to as [Pulse-code
Modulation][PCM] (PCM). PCM can be thought of as the "standard" audio format, as it's incredibly easy to work with. For
instance, to mix two pieces of audio together, you can just samples from the two tracks together and take the average.
instance, to mix two pieces of audio together, you can just add samples from the two tracks together and take the average.
CC: Tweaked's speakers also work with PCM audio. It plays back 48,000 samples a second, where each sample is an integer
between -128 and 127. This is more commonly referred to as 48kHz and an 8-bit resolution.

View File

@@ -1,7 +1,7 @@
org.gradle.jvmargs=-Xmx3G
# Mod properties
mod_version=1.100.1
mod_version=1.100.4
# Minecraft properties (update mods.toml when changing)
mc_version=1.17.1

View File

@@ -111,7 +111,7 @@ public final class ComputerCraftAPI
}
/**
* rers a peripheral provider to convert blocks into {@link IPeripheral} implementations.
* Registers a peripheral provider to convert blocks into {@link IPeripheral} implementations.
*
* @param provider The peripheral provider to register.
* @see IPeripheral

View File

@@ -10,7 +10,6 @@ import dan200.computercraft.client.gui.*;
import dan200.computercraft.client.render.TileEntityMonitorRenderer;
import dan200.computercraft.client.render.TileEntityTurtleRenderer;
import dan200.computercraft.client.render.TurtleModelLoader;
import dan200.computercraft.client.render.TurtlePlayerRenderer;
import dan200.computercraft.shared.Registry;
import dan200.computercraft.shared.common.IColouredItem;
import dan200.computercraft.shared.computer.inventory.ContainerComputerBase;
@@ -30,7 +29,6 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.ColorHandlerEvent;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.client.model.ModelLoaderRegistry;
@@ -122,12 +120,6 @@ public final class ClientRegistry
);
}
@SubscribeEvent
public static void registerEntityRenderers( EntityRenderersEvent.RegisterRenderers event )
{
event.registerEntityRenderer( Registry.ModEntities.TURTLE_PLAYER.get(), TurtlePlayerRenderer::new );
}
@SubscribeEvent
public static void setupClient( FMLClientSetupEvent event )
{

View File

@@ -21,6 +21,7 @@ import dan200.computercraft.shared.peripheral.modem.wireless.WirelessNetwork;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
import net.minecraft.world.level.storage.loot.LootPool;
@@ -161,4 +162,14 @@ public final class CommonHooks
NetworkHandler.sendToPlayer( event.getPlayer(), packet );
}
}
@SubscribeEvent
public static void onMissingEntityMappingsEvent( RegistryEvent.MissingMappings<EntityType<?>> event )
{
ResourceLocation id = new ResourceLocation( ComputerCraft.MOD_ID, "turtle_player" );
for( RegistryEvent.MissingMappings.Mapping<EntityType<?>> mapping : event.getMappings( ComputerCraft.MOD_ID ) )
{
if( mapping.key.equals( id ) ) mapping.ignore();
}
}
}

View File

@@ -61,7 +61,6 @@ import dan200.computercraft.shared.pocket.peripherals.PocketSpeaker;
import dan200.computercraft.shared.pocket.recipes.PocketComputerUpgradeRecipe;
import dan200.computercraft.shared.turtle.blocks.BlockTurtle;
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
import dan200.computercraft.shared.turtle.core.TurtlePlayer;
import dan200.computercraft.shared.turtle.inventory.ContainerTurtle;
import dan200.computercraft.shared.turtle.items.ItemTurtle;
import dan200.computercraft.shared.turtle.recipes.TurtleRecipe;
@@ -73,8 +72,6 @@ import dan200.computercraft.shared.util.ImpostorRecipe;
import dan200.computercraft.shared.util.ImpostorShapelessRecipe;
import net.minecraft.core.cauldron.CauldronInteraction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab;
@@ -285,18 +282,6 @@ public final class Registry
SERIALISERS.register( "wireless_modem_advanced", () -> PocketUpgradeSerialiser.simpleWithCustomItem( ( id, item ) -> new PocketModem( id, item, true ) ) );
}
public static class ModEntities
{
static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create( ForgeRegistries.ENTITIES, ComputerCraft.MOD_ID );
public static final RegistryObject<EntityType<TurtlePlayer>> TURTLE_PLAYER = ENTITIES.register( "turtle_player", () ->
EntityType.Builder.<TurtlePlayer>createNothing( MobCategory.MISC )
.noSave()
.noSummon()
.sized( 0, 0 )
.build( ComputerCraft.MOD_ID + ":turtle_player" ) );
}
public static class ModContainers
{
static final DeferredRegister<MenuType<?>> CONTAINERS = DeferredRegister.create( ForgeRegistries.CONTAINERS, ComputerCraft.MOD_ID );
@@ -425,7 +410,6 @@ public final class Registry
ModItems.ITEMS.register( bus );
ModTurtleSerialisers.SERIALISERS.register( bus );
ModPocketUpgradeSerialisers.SERIALISERS.register( bus );
ModEntities.ENTITIES.register( bus );
ModContainers.CONTAINERS.register( bus );
}
}

View File

@@ -160,6 +160,7 @@ public class UploadFileMessage extends ComputerServerMessage
contents.position( currentOffset ).limit( currentOffset + canWrite );
slices.add( new FileSlice( fileId, currentOffset, contents.slice() ) );
currentOffset += canWrite;
remaining -= canWrite;
}
contents.position( 0 ).limit( capacity );

View File

@@ -59,7 +59,7 @@ public enum CableModemVariant implements StringRepresentable
@Nonnull
public static CableModemVariant from( Direction facing, boolean modem, boolean peripheral )
{
int state = (modem ? 2 : 0) + (peripheral ? 1 : 0);
int state = (modem ? 1 : 0) + (peripheral ? 2 : 0);
return facing == null ? None : VALUES[1 + 6 * state + facing.get3DDataValue()];
}

View File

@@ -15,7 +15,6 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.world.ChunkWatchEvent;
@@ -47,8 +46,10 @@ public final class MonitorWatcher
@SubscribeEvent
public static void onWatch( ChunkWatchEvent.Watch event )
{
// Get the current chunk if it has been loaded. This is safe as, if the chunk hasn't been loaded yet, then the
// monitor will have no contents, and so we won't need to send an update anyway.
ChunkPos chunkPos = event.getPos();
LevelChunk chunk = (LevelChunk) event.getWorld().getChunk( chunkPos.x, chunkPos.z, ChunkStatus.FULL, false );
LevelChunk chunk = event.getWorld().getChunkSource().getChunkNow( chunkPos.x, chunkPos.z );
if( chunk == null ) return;
for( BlockEntity te : chunk.getBlockEntities().values() )

View File

@@ -8,7 +8,6 @@ package dan200.computercraft.shared.turtle.core;
import com.mojang.authlib.GameProfile;
import dan200.computercraft.ComputerCraft;
import dan200.computercraft.api.turtle.ITurtleAccess;
import dan200.computercraft.shared.Registry;
import dan200.computercraft.shared.util.DirectionUtil;
import dan200.computercraft.shared.util.InventoryUtil;
import dan200.computercraft.shared.util.WorldUtil;
@@ -22,7 +21,6 @@ import net.minecraft.world.MenuProvider;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityDimensions;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.entity.animal.horse.AbstractHorse;
import net.minecraft.world.item.ItemStack;
@@ -197,13 +195,6 @@ public final class TurtlePlayer extends FakePlayer
getInventory().setChanged();
}
@Nonnull
@Override
public EntityType<?> getType()
{
return Registry.ModEntities.TURTLE_PLAYER.get();
}
@Override
public Vec3 position()
{

View File

@@ -45,21 +45,17 @@ public final class IDAssigner
return ServerLifecycleHooks.getCurrentServer().getWorldPath( FOLDER ).toFile();
}
private static MinecraftServer getCachedServer()
private static boolean hasServerChanged()
{
if( server == null ) return null;
if( server == null ) return true;
MinecraftServer currentServer = server.get();
if( currentServer == null ) return null;
if( currentServer != ServerLifecycleHooks.getCurrentServer() ) return null;
return currentServer;
return currentServer == null || currentServer != ServerLifecycleHooks.getCurrentServer();
}
public static synchronized int getNextId( String kind )
{
MinecraftServer currentServer = getCachedServer();
if( currentServer == null )
if( hasServerChanged() )
{
// The server has changed, refetch our ID map
server = new WeakReference<>( ServerLifecycleHooks.getCurrentServer() );
@@ -68,23 +64,22 @@ public final class IDAssigner
dir.mkdirs();
// Load our ID file from disk
Map<String, Integer> newIds = null;
idFile = new File( dir, "ids.json" ).toPath();
if( Files.isRegularFile( idFile ) )
{
try( Reader reader = Files.newBufferedReader( idFile, StandardCharsets.UTF_8 ) )
{
ids = GSON.fromJson( reader, ID_TOKEN );
newIds = GSON.fromJson( reader, ID_TOKEN );
}
catch( Exception e )
{
ComputerCraft.log.error( "Cannot load id file '" + idFile + "'", e );
ids = new HashMap<>();
}
}
else
{
ids = new HashMap<>();
}
if( newIds == null ) newIds = new HashMap<>();
ids = newIds;
}
Integer existing = ids.get( kind );

View File

@@ -5,9 +5,9 @@
*/
package dan200.computercraft.shared.util;
import com.google.common.io.BaseEncoding;
import dan200.computercraft.ComputerCraft;
import net.minecraft.nbt.*;
import org.apache.commons.codec.binary.Hex;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -22,6 +22,8 @@ import java.util.Map;
public final class NBTUtil
{
private static final BaseEncoding ENCODING = BaseEncoding.base16().lowerCase();
private NBTUtil() {}
private static Tag toNBTTag( Object object )
@@ -177,7 +179,7 @@ public final class NBTUtil
DataOutput output = new DataOutputStream( new DigestOutputStream( digest ) );
NbtIo.write( tag, output );
byte[] hash = digest.digest();
return new String( Hex.encodeHex( hash ) );
return ENCODING.encode( hash );
}
catch( NoSuchAlgorithmException | IOException e )
{

View File

@@ -39,5 +39,25 @@
"chat.computercraft.wired_modem.peripheral_disconnected": "Perifer enhed \"%s\" koblet fra netværk",
"gui.computercraft.tooltip.copy": "Kopier til udklipsholder",
"gui.computercraft.tooltip.computer_id": "Computer-ID: %s",
"gui.computercraft.tooltip.disk_id": "Disk-ID: %s"
"gui.computercraft.tooltip.disk_id": "Disk-ID: %s",
"gui.computercraft.tooltip.turn_on": "Tænd denne computer",
"gui.computercraft.tooltip.turn_off": "Sluk denne computer",
"gui.computercraft.tooltip.terminate.key": "Hold Ctrl+T nede",
"gui.computercraft.tooltip.turn_off.key": "Hold Ctrl+S nede",
"gui.computercraft.tooltip.terminate": "Stop den igangværende kode",
"gui.computercraft.tooltip.turn_on.key": "Hold Ctrl+R nede",
"gui.computercraft.upload.overwrite_button": "Overskriv",
"gui.computercraft.upload.overwrite.detail": "Følgende filer vil blive overskrevet ved upload. Fortsæt?%s",
"gui.computercraft.upload.success": "Upload Lykkedes",
"gui.computercraft.upload.overwrite": "Filer ville blive overskrevet",
"gui.computercraft.upload.failed.out_of_space": "Ikke nok plads på computeren til disse filer.",
"gui.computercraft.upload.failed.computer_off": "Du skal tænde computeren, før du kan uploade filer.",
"gui.computercraft.upload.failed.too_much": "Dine filer er for store til at blive uploadet.",
"gui.computercraft.upload.failed.overwrite_dir": "Kan ikke uploade %s, da der allerede er en mappe med det samme navn.",
"gui.computercraft.upload.success.msg": "%d filer uploadet.",
"gui.computercraft.upload.failed": "Upload Fejlede",
"gui.computercraft.upload.failed.name_too_long": "Filnavne er for lange til at blive uploadet.",
"gui.computercraft.upload.failed.too_many_files": "Kan ikke uploade så mange filer.",
"gui.computercraft.pocket_computer_overlay": "Lommecomputer åben. Tryk ESC for at lukke.",
"itemGroup.computercraft": "ComputerCraft"
}

View File

@@ -1,7 +1,7 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [ "computercraft:normal_turtle_normal" ]
"recipes": [ "computercraft:turtle_normal" ]
},
"criteria": {
"has_normal": {

View File

@@ -1,3 +1,22 @@
# New features in CC: Tweaked 1.100.4
Several bug fixes:
* Fix the monitor watching blocking the main thread when chunks are slow to load.
# New features in CC: Tweaked 1.100.3
Several bug fixes:
* Fix client disconnect when uploading large files.
* Correctly handling empty computer ID file.
* Fix the normal turtle recipe not being unlocked.
* Remove turtle fake EntityType.
# New features in CC: Tweaked 1.100.2
Several bug fixes:
* Fix wired modems swapping the modem/peripheral block state.
* Remove debugging logging line from `turtle.attack`.
# New features in CC: Tweaked 1.100.1
Several bug fixes:

View File

@@ -1,7 +1,6 @@
New features in CC: Tweaked 1.100.1
New features in CC: Tweaked 1.100.4
Several bug fixes:
* Fix `peripheral.hasType` not working with wired modems (Toad-Dev).
* Fix crashes when noisy pocket computer are shutdown.
* Fix the monitor watching blocking the main thread when chunks are slow to load.
Type "help changelog" to see the full version history.