mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 13:42:59 +00:00 
			
		
		
		
	Fixed pocket and turtle upgrades. (Turtle tools render weird in inventories)
This commit is contained in:
		| @@ -154,23 +154,4 @@ public final class ComputerCraft implements ModInitializer { | ||||
|         init(); | ||||
|     } | ||||
|  | ||||
|     public static final class TurtleUpgrades { | ||||
|         public static TurtleModem wirelessModemNormal; | ||||
|         public static TurtleModem wirelessModemAdvanced; | ||||
|         public static TurtleSpeaker speaker; | ||||
|  | ||||
|         public static TurtleCraftingTable craftingTable; | ||||
|         public static TurtleSword diamondSword; | ||||
|         public static TurtleShovel diamondShovel; | ||||
|         public static TurtleTool diamondPickaxe; | ||||
|         public static TurtleAxe diamondAxe; | ||||
|         public static TurtleHoe diamondHoe; | ||||
|     } | ||||
|  | ||||
|     public static final class PocketUpgrades { | ||||
|         public static PocketModem wirelessModemNormal; | ||||
|         public static PocketModem wirelessModemAdvanced; | ||||
|         public static PocketSpeaker speaker; | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -66,12 +66,15 @@ public final class TransformedModel { | ||||
|     public void push(MatrixStack matrixStack) { | ||||
|         matrixStack.push(); | ||||
|  | ||||
|         matrixStack.translate(this.matrix.translation.getX(), this.matrix.translation.getY(), this.matrix.translation.getZ()); | ||||
|         if (matrix.translation != null) | ||||
|             matrixStack.translate(this.matrix.translation.getX(), this.matrix.translation.getY(), this.matrix.translation.getZ()); | ||||
|  | ||||
|         matrixStack.multiply(this.matrix.getRotation2()); | ||||
|  | ||||
|         matrixStack.scale(this.matrix.scale.getX(), this.matrix.scale.getY(), this.matrix.scale.getZ()); | ||||
|         if (matrix.scale != null) | ||||
|             matrixStack.scale(this.matrix.scale.getX(), this.matrix.scale.getY(), this.matrix.scale.getZ()); | ||||
|  | ||||
|         matrixStack.multiply(this.matrix.rotation1); | ||||
|         if (matrix.rotation1 != null) | ||||
|             matrixStack.multiply(this.matrix.rotation1); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -159,22 +159,22 @@ public class TileEntityTurtleRenderer extends BlockEntityRenderer<TileTurtle> { | ||||
|         Identifier overlay = turtle.getOverlay(); | ||||
|  | ||||
|         VertexConsumer buffer = renderer.getBuffer(TexturedRenderLayers.getEntityTranslucentCull()); | ||||
|         this.renderModel(transform, buffer, lightmapCoord, overlayLight, getTurtleModel(family, colour != -1), colour == -1 ? null : new int[] {colour}); | ||||
|         renderModel(transform, buffer, lightmapCoord, overlayLight, getTurtleModel(family, colour != -1), colour == -1 ? null : new int[] {colour}); | ||||
|  | ||||
|         // Render the overlay | ||||
|         ModelIdentifier overlayModel = getTurtleOverlayModel(overlay, HolidayUtil.getCurrentHoliday() == Holiday.CHRISTMAS); | ||||
|         if (overlayModel != null) { | ||||
|             this.renderModel(transform, buffer, lightmapCoord, overlayLight, overlayModel, null); | ||||
|             renderModel(transform, buffer, lightmapCoord, overlayLight, overlayModel, null); | ||||
|         } | ||||
|  | ||||
|         // Render the upgrades | ||||
|         this.renderUpgrade(transform, buffer, lightmapCoord, overlayLight, turtle, TurtleSide.LEFT, partialTicks); | ||||
|         this.renderUpgrade(transform, buffer, lightmapCoord, overlayLight, turtle, TurtleSide.RIGHT, partialTicks); | ||||
|         renderUpgrade(transform, buffer, lightmapCoord, overlayLight, turtle, TurtleSide.LEFT, partialTicks); | ||||
|         renderUpgrade(transform, buffer, lightmapCoord, overlayLight, turtle, TurtleSide.RIGHT, partialTicks); | ||||
|  | ||||
|         transform.pop(); | ||||
|     } | ||||
|  | ||||
|     private void renderUpgrade(@Nonnull MatrixStack transform, @Nonnull VertexConsumer renderer, int lightmapCoord, int overlayLight, TileTurtle turtle, | ||||
|     public static void renderUpgrade(@Nonnull MatrixStack transform, @Nonnull VertexConsumer renderer, int lightmapCoord, int overlayLight, TileTurtle turtle, | ||||
|                                TurtleSide side, float f) { | ||||
|         ITurtleUpgrade upgrade = turtle.getUpgrade(side); | ||||
|         if (upgrade == null) { | ||||
| @@ -189,27 +189,28 @@ public class TileEntityTurtleRenderer extends BlockEntityRenderer<TileTurtle> { | ||||
|  | ||||
|         TransformedModel model = upgrade.getModel(turtle.getAccess(), side); | ||||
|         model.push(transform); | ||||
|         this.renderModel(transform, renderer, lightmapCoord, overlayLight, model.getModel(), null); | ||||
|         TileEntityTurtleRenderer.renderModel(transform, renderer, lightmapCoord, overlayLight, model.getModel(), null); | ||||
|         transform.pop(); | ||||
|  | ||||
|         transform.pop(); | ||||
|     } | ||||
|  | ||||
|     private void renderModel(@Nonnull MatrixStack transform, @Nonnull VertexConsumer renderer, int lightmapCoord, int overlayLight, | ||||
|     public static void renderModel(@Nonnull MatrixStack transform, @Nonnull VertexConsumer renderer, int lightmapCoord, int overlayLight, | ||||
|                              ModelIdentifier modelLocation, int[] tints) { | ||||
|         BakedModelManager modelManager = MinecraftClient.getInstance() | ||||
|                                                         .getItemRenderer() | ||||
|                                                         .getModels() | ||||
|                                                         .getModelManager(); | ||||
|         this.renderModel(transform, renderer, lightmapCoord, overlayLight, modelManager.getModel(modelLocation), tints); | ||||
|         renderModel(transform, renderer, lightmapCoord, overlayLight, modelManager.getModel(modelLocation), tints); | ||||
|     } | ||||
|  | ||||
|     private void renderModel(@Nonnull MatrixStack transform, @Nonnull VertexConsumer renderer, int lightmapCoord, int overlayLight, BakedModel model, | ||||
|     public static void renderModel(@Nonnull MatrixStack transform, @Nonnull VertexConsumer renderer, int lightmapCoord, int overlayLight, BakedModel model, | ||||
|                              int[] tints) { | ||||
|         this.random.setSeed(0); | ||||
|         renderQuads(transform, renderer, lightmapCoord, overlayLight, model.getQuads(null, null, this.random), tints); | ||||
|         Random random = new Random(); | ||||
|         random.setSeed(0); | ||||
|         renderQuads(transform, renderer, lightmapCoord, overlayLight, model.getQuads(null, null, random), tints); | ||||
|         for (Direction facing : DirectionUtil.FACINGS) { | ||||
|             renderQuads(transform, renderer, lightmapCoord, overlayLight, model.getQuads(null, facing, this.random), tints); | ||||
|             renderQuads(transform, renderer, lightmapCoord, overlayLight, model.getQuads(null, facing, random), tints); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -14,6 +14,7 @@ import java.util.function.Function; | ||||
| import java.util.function.Supplier; | ||||
|  | ||||
| import dan200.computercraft.ComputerCraft; | ||||
| import dan200.computercraft.api.ComputerCraftAPI; | ||||
| import dan200.computercraft.shared.common.ContainerHeldItem; | ||||
| import dan200.computercraft.shared.computer.blocks.BlockComputer; | ||||
| import dan200.computercraft.shared.computer.blocks.TileCommandComputer; | ||||
| @@ -44,11 +45,14 @@ import dan200.computercraft.shared.peripheral.speaker.BlockSpeaker; | ||||
| import dan200.computercraft.shared.peripheral.speaker.TileSpeaker; | ||||
| import dan200.computercraft.shared.pocket.inventory.ContainerPocketComputer; | ||||
| import dan200.computercraft.shared.pocket.items.ItemPocketComputer; | ||||
| import dan200.computercraft.shared.pocket.peripherals.PocketModem; | ||||
| import dan200.computercraft.shared.pocket.peripherals.PocketSpeaker; | ||||
| 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.upgrades.*; | ||||
| import dan200.computercraft.shared.util.FixedPointTileEntityType; | ||||
|  | ||||
| import net.minecraft.block.Block; | ||||
| @@ -61,6 +65,7 @@ import net.minecraft.entity.SpawnGroup; | ||||
| import net.minecraft.item.BlockItem; | ||||
| import net.minecraft.item.Item; | ||||
| import net.minecraft.item.ItemGroup; | ||||
| import net.minecraft.item.Items; | ||||
| import net.minecraft.screen.ScreenHandler; | ||||
| import net.minecraft.screen.ScreenHandlerType; | ||||
| import net.minecraft.util.Identifier; | ||||
| @@ -68,6 +73,7 @@ import net.minecraft.util.registry.Registry; | ||||
|  | ||||
| import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; | ||||
| import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry; | ||||
| import org.apache.http.client.utils.Idn; | ||||
|  | ||||
| public final class ComputerCraftRegistry { | ||||
|     public static final String MOD_ID = ComputerCraft.MOD_ID; | ||||
| @@ -80,6 +86,9 @@ public final class ComputerCraftRegistry { | ||||
|             ModEntities.TURTLE_PLAYER, | ||||
|             ModContainers.COMPUTER, | ||||
|             }; | ||||
|  | ||||
|         TurtleUpgrades.registerTurtleUpgrades(); | ||||
|         PocketUpgrades.registerPocketUpgrades(); | ||||
|     } | ||||
|  | ||||
|     public static final class ModBlocks { | ||||
| @@ -247,5 +256,43 @@ public final class ComputerCraftRegistry { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public static final class TurtleUpgrades { | ||||
|         public static TurtleModem wirelessModemNormal = new TurtleModem(false, new Identifier(ComputerCraft.MOD_ID, "wireless_modem_normal")); | ||||
|         public static TurtleModem wirelessModemAdvanced = new TurtleModem(true, new Identifier(ComputerCraft.MOD_ID, "wireless_modem_advanced")); | ||||
|         public static TurtleSpeaker speaker = new TurtleSpeaker(new Identifier(ComputerCraft.MOD_ID, "speaker")); | ||||
|  | ||||
|         public static TurtleCraftingTable craftingTable = new TurtleCraftingTable(new Identifier("minecraft", "crafting_table")); | ||||
|         public static TurtleSword diamondSword = new TurtleSword(new Identifier("minecraft", "diamond_sword"), Items.DIAMOND_SWORD); | ||||
|         public static TurtleShovel diamondShovel = new TurtleShovel(new Identifier("minecraft", "diamond_shovel"), Items.DIAMOND_SHOVEL); | ||||
|         public static TurtleTool diamondPickaxe = new TurtleTool(new Identifier("minecraft", "diamond_pickaxe"), Items.DIAMOND_PICKAXE); | ||||
|         public static TurtleAxe diamondAxe = new TurtleAxe(new Identifier("minecraft", "diamond_axe"), Items.DIAMOND_AXE); | ||||
|         public static TurtleHoe diamondHoe = new TurtleHoe(new Identifier("minecraft", "diamond_hoe"), Items.DIAMOND_HOE); | ||||
|  | ||||
|         public static void registerTurtleUpgrades() { | ||||
|             ComputerCraftAPI.registerTurtleUpgrade(wirelessModemNormal); | ||||
|             ComputerCraftAPI.registerTurtleUpgrade(wirelessModemAdvanced); | ||||
|             ComputerCraftAPI.registerTurtleUpgrade(speaker); | ||||
|  | ||||
|             ComputerCraftAPI.registerTurtleUpgrade(craftingTable); | ||||
|             ComputerCraftAPI.registerTurtleUpgrade(diamondSword); | ||||
|             ComputerCraftAPI.registerTurtleUpgrade(diamondShovel); | ||||
|             ComputerCraftAPI.registerTurtleUpgrade(diamondPickaxe); | ||||
|             ComputerCraftAPI.registerTurtleUpgrade(diamondAxe); | ||||
|             ComputerCraftAPI.registerTurtleUpgrade(diamondHoe); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public static final class PocketUpgrades { | ||||
|         public static PocketModem wirelessModemNormal = new PocketModem(false); | ||||
|         public static PocketModem wirelessModemAdvanced = new PocketModem(true); | ||||
|         public static PocketSpeaker speaker = new PocketSpeaker(); | ||||
|  | ||||
|         public static void registerPocketUpgrades() { | ||||
|             ComputerCraftAPI.registerPocketUpgrade(wirelessModemNormal); | ||||
|             ComputerCraftAPI.registerPocketUpgrade(wirelessModemAdvanced); | ||||
|             ComputerCraftAPI.registerPocketUpgrade(speaker); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -74,9 +74,9 @@ public final class PocketUpgrades { | ||||
|  | ||||
|     public static Iterable<IPocketUpgrade> getVanillaUpgrades() { | ||||
|         List<IPocketUpgrade> vanilla = new ArrayList<>(); | ||||
|         vanilla.add(ComputerCraft.PocketUpgrades.wirelessModemNormal); | ||||
|         vanilla.add(ComputerCraft.PocketUpgrades.wirelessModemAdvanced); | ||||
|         vanilla.add(ComputerCraft.PocketUpgrades.speaker); | ||||
|         vanilla.add(ComputerCraftRegistry.PocketUpgrades.wirelessModemNormal); | ||||
|         vanilla.add(ComputerCraftRegistry.PocketUpgrades.wirelessModemAdvanced); | ||||
|         vanilla.add(ComputerCraftRegistry.PocketUpgrades.speaker); | ||||
|         return vanilla; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -108,18 +108,18 @@ public final class TurtleUpgrades { | ||||
|         if (vanilla == null) { | ||||
|             vanilla = new ITurtleUpgrade[] { | ||||
|                 // ComputerCraft upgrades | ||||
|                 ComputerCraft.TurtleUpgrades.wirelessModemNormal, | ||||
|                 ComputerCraft.TurtleUpgrades.wirelessModemAdvanced, | ||||
|                 ComputerCraft.TurtleUpgrades.speaker, | ||||
|                 ComputerCraftRegistry.TurtleUpgrades.wirelessModemNormal, | ||||
|                 ComputerCraftRegistry.TurtleUpgrades.wirelessModemAdvanced, | ||||
|                 ComputerCraftRegistry.TurtleUpgrades.speaker, | ||||
|  | ||||
|                 // Vanilla Minecraft upgrades | ||||
|                 ComputerCraft.TurtleUpgrades.diamondPickaxe, | ||||
|                 ComputerCraft.TurtleUpgrades.diamondAxe, | ||||
|                 ComputerCraft.TurtleUpgrades.diamondSword, | ||||
|                 ComputerCraft.TurtleUpgrades.diamondShovel, | ||||
|                 ComputerCraft.TurtleUpgrades.diamondHoe, | ||||
|                 ComputerCraft.TurtleUpgrades.craftingTable, | ||||
|                 }; | ||||
|                 ComputerCraftRegistry.TurtleUpgrades.diamondPickaxe, | ||||
|                 ComputerCraftRegistry.TurtleUpgrades.diamondAxe, | ||||
|                 ComputerCraftRegistry.TurtleUpgrades.diamondSword, | ||||
|                 ComputerCraftRegistry.TurtleUpgrades.diamondShovel, | ||||
|                 ComputerCraftRegistry.TurtleUpgrades.diamondHoe, | ||||
|                 ComputerCraftRegistry.TurtleUpgrades.craftingTable, | ||||
|             }; | ||||
|         } | ||||
|  | ||||
|         return Arrays.stream(vanilla) | ||||
|   | ||||
| @@ -159,6 +159,9 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc | ||||
|  | ||||
|     @Override | ||||
|     public void onBreak(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull PlayerEntity player) { | ||||
|         // Call super as it is what provides sound and block break particles. Does not do anything else. | ||||
|         super.onBreak(world, pos, state, player); | ||||
|  | ||||
|         if (!(world instanceof ServerWorld)) { | ||||
|             return; | ||||
|         } | ||||
| @@ -182,7 +185,5 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc | ||||
|  | ||||
|             state.onStacksDropped(serverWorld, pos, player.getMainHandStack()); | ||||
|         } | ||||
|         // Call super as it is what provides sound and block break particles. Does not do anything else. | ||||
|         super.onBreak(world, pos, state, player); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -29,6 +29,8 @@ import dan200.computercraft.shared.util.DropConsumer; | ||||
| import dan200.computercraft.shared.util.FillableMatrix4f; | ||||
| import dan200.computercraft.shared.util.InventoryUtil; | ||||
| import dan200.computercraft.shared.util.WorldUtil; | ||||
| import net.minecraft.client.util.math.Vector3f; | ||||
| import net.minecraft.util.math.*; | ||||
| import org.apache.commons.lang3.tuple.Pair; | ||||
|  | ||||
| import net.minecraft.block.Block; | ||||
| @@ -46,10 +48,6 @@ import net.minecraft.item.ItemStack; | ||||
| import net.minecraft.util.ActionResult; | ||||
| import net.minecraft.util.Hand; | ||||
| import net.minecraft.util.Identifier; | ||||
| import net.minecraft.util.math.BlockPos; | ||||
| import net.minecraft.util.math.Direction; | ||||
| import net.minecraft.util.math.Matrix4f; | ||||
| import net.minecraft.util.math.Vec3d; | ||||
| import net.minecraft.world.World; | ||||
|  | ||||
| import net.fabricmc.api.EnvType; | ||||
| @@ -93,25 +91,7 @@ public class TurtleTool extends AbstractTurtleUpgrade { | ||||
|     @Environment (EnvType.CLIENT) | ||||
|     public TransformedModel getModel(ITurtleAccess turtle, @Nonnull TurtleSide side) { | ||||
|         float xOffset = side == TurtleSide.LEFT ? -0.40625f : 0.40625f; | ||||
|         Matrix4f transform = new FillableMatrix4f(new float[] { | ||||
|             0.0f, | ||||
|             0.0f, | ||||
|             -1.0f, | ||||
|             1.0f + xOffset, | ||||
|             1.0f, | ||||
|             0.0f, | ||||
|             0.0f, | ||||
|             0.0f, | ||||
|             0.0f, | ||||
|             -1.0f, | ||||
|             0.0f, | ||||
|             1.0f, | ||||
|             0.0f, | ||||
|             0.0f, | ||||
|             0.0f, | ||||
|             1.0f, | ||||
|             }); | ||||
|         return TransformedModel.of(this.getCraftingItem(), new AffineTransformation(transform)); | ||||
|         return TransformedModel.of(this.getCraftingItem(), new AffineTransformation(new Vector3f(xOffset, 0, 1), Vector3f.POSITIVE_Y.getDegreesQuaternion(90), new Vector3f(1, 1, 1), Quaternion.IDENTITY)); | ||||
|     } | ||||
|  | ||||
|     private TurtleCommandResult attack(final ITurtleAccess turtle, Direction direction, TurtleSide side) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jacob Farley
					Jacob Farley