Skip to content

Commit

Permalink
Update CC and fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Jun 2, 2024
1 parent 8d1ceab commit 5ed76d0
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 41 deletions.
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// 1.109.6
modImplementation "maven.modrinth:cc-tweaked:7U8gSlIr"
modImplementation "cc.tweaked:cc-tweaked-1.20.5-fabric:1.110.3"
//modImplementation "maven.modrinth:cc-tweaked:7U8gSlIr"
modImplementation "cc.tweaked:cc-tweaked-1.20.6-fabric:1.111.0"

modImplementation include('eu.pb4:sgui:1.5.1+1.20.5')
modImplementation include('eu.pb4:player-data-api:0.5.0+1.20.5')
modImplementation include('eu.pb4:map-canvas-api:0.3.0+1.20.6')
modImplementation include('eu.pb4:factorytools:0.2.0+1.20.6')
modImplementation 'eu.pb4:polymer-core:0.8.0-pre.1+1.20.6'
modImplementation 'eu.pb4:polymer-resource-pack:0.8.0-pre.1+1.20.6'
modImplementation 'eu.pb4:polymer-autohost:0.8.0-pre.1+1.20.6'
modImplementation 'eu.pb4:polymer-virtual-entity:0.8.0-pre.1+1.20.6'
modImplementation include('eu.pb4:factorytools:0.2.2+1.20.6')
modImplementation 'eu.pb4:polymer-core:0.8.2+1.20.6'
modImplementation 'eu.pb4:polymer-resource-pack:0.8.2+1.20.6'
modImplementation 'eu.pb4:polymer-autohost:0.8.2+1.20.6'
modImplementation 'eu.pb4:polymer-virtual-entity:0.8.2+1.20.6'


modCompileOnly ("nl.theepicblock:PolyMc:5.6.1+1.20.4") {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn_mappings=1.20.6+build.1
loader_version=0.15.10

# Mod Properties
mod_version=1.110.3.0+1.20.6
mod_version=1.111.0.0+1.20.6
maven_group=eu.pb4.cctpatch
archives_base_name=cc-tweaked-polymer-patch

Expand Down
20 changes: 2 additions & 18 deletions src/main/java/eu/pb4/cctpatch/impl/poly/model/TurtleModel.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
package eu.pb4.cctpatch.impl.poly.model;

import dan200.computercraft.api.ComputerCraftAPI;
import dan200.computercraft.api.turtle.AbstractTurtleUpgrade;
import dan200.computercraft.api.turtle.ITurtleUpgrade;
import dan200.computercraft.api.turtle.TurtleAnimation;
import dan200.computercraft.api.turtle.TurtleSide;
import dan200.computercraft.shared.ComputerCraft;
import dan200.computercraft.shared.ModRegistry;
import dan200.computercraft.shared.turtle.blocks.TurtleBlock;
import dan200.computercraft.shared.turtle.blocks.TurtleBlockEntity;
import dan200.computercraft.shared.turtle.core.TurtleBrain;
import dan200.computercraft.shared.turtle.upgrades.TurtleCraftingTable;
import dan200.computercraft.shared.turtle.upgrades.TurtleModem;
import dan200.computercraft.shared.turtle.upgrades.TurtleSpeaker;
import dan200.computercraft.shared.turtle.upgrades.TurtleTool;
import dan200.computercraft.shared.util.Holiday;
import eu.pb4.cctpatch.impl.poly.model.generic.BlockStateModelManager;
import eu.pb4.cctpatch.mixin.TurtleModemAccessor;
import eu.pb4.cctpatch.mixin.TurtleToolAccessor;
import eu.pb4.factorytools.api.resourcepack.BaseItemProvider;
import eu.pb4.factorytools.api.virtualentity.BlockModel;
import eu.pb4.factorytools.api.virtualentity.ItemDisplayElementUtil;
import eu.pb4.polymer.virtualentity.api.ElementHolder;
import eu.pb4.polymer.virtualentity.api.VirtualEntityUtils;
import eu.pb4.polymer.virtualentity.api.attachment.BlockBoundAttachment;
import eu.pb4.polymer.virtualentity.api.attachment.ChunkAttachment;
import eu.pb4.polymer.virtualentity.api.elements.ItemDisplayElement;
import it.unimi.dsi.fastutil.ints.IntList;
import net.minecraft.block.BlockState;
Expand All @@ -32,20 +24,14 @@
import net.minecraft.component.type.FireworkExplosionComponent;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtIntArray;
import net.minecraft.network.listener.ClientPlayPacketListener;
import net.minecraft.network.packet.Packet;
import net.minecraft.registry.tag.ItemTags;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Identifier;
import net.minecraft.util.Pair;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RotationAxis;
import net.minecraft.util.math.Vec3d;
import org.joml.Vector3f;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -148,11 +134,9 @@ private ItemStack getUpgradeModel(ITurtleUpgrade upgrade, TurtleBrain brain, Tur
return SPEAKER_MODEL.get(turtleSide);
} else if (upgrade instanceof TurtleCraftingTable) {
return CRAFTING_MODEL.get(turtleSide);
} else if (upgrade instanceof TurtleToolAccessor tool) {
return tool.getItem();
}

return ItemStack.EMPTY;
return upgrade.getCraftingItem();
}

public void update(TurtleBrain turtleBrain) {
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/eu/pb4/cctpatch/mixin/TurtleToolAccessor.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package eu.pb4.cctpatch.mixin.mod.item;

import dan200.computercraft.shared.computer.items.AbstractComputerItem;
import net.minecraft.block.Block;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket;
import net.minecraft.registry.Registries;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundCategory;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.Vec3d;
import org.spongepowered.asm.mixin.Mixin;

@Mixin(AbstractComputerItem.class)
public abstract class AbstractComputerItemMixin extends BlockItem {
public AbstractComputerItemMixin(Block block, Settings settings) {
super(block, settings);
}

@Override
public ActionResult useOnBlock(ItemUsageContext context) {
var x = super.useOnBlock(context);
if (x == ActionResult.CONSUME) {
if (context.getPlayer() instanceof ServerPlayerEntity player) {
var pos = Vec3d.ofCenter(context.getBlockPos().offset(context.getSide()));
var blockSoundGroup = this.getBlock().getDefaultState().getSoundGroup();
player.networkHandler.sendPacket(new PlaySoundS2CPacket(Registries.SOUND_EVENT.getEntry(this.getPlaceSound(this.getBlock().getDefaultState())), SoundCategory.BLOCKS, pos.x, pos.y, pos.z, (blockSoundGroup.getVolume() + 1.0F) / 2.0F, blockSoundGroup.getPitch() * 0.8F, context.getPlayer().getRandom().nextLong()));
}
return ActionResult.SUCCESS;
}
return x;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package eu.pb4.cctpatch.mixin.poly;

import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import eu.pb4.cctpatch.impl.poly.gui.MapGui;
import eu.pb4.sgui.virtual.VirtualScreenHandlerInterface;
import net.minecraft.network.ClientConnection;
Expand All @@ -14,6 +15,7 @@
import net.minecraft.server.network.ServerCommonNetworkHandler;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.math.Vec3d;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -22,6 +24,7 @@

import java.util.EnumSet;
import java.util.Optional;
import java.util.Set;

@Mixin(ServerPlayNetworkHandler.class)
public abstract class ServerPlayNetworkHandlerMixin extends ServerCommonNetworkHandler {
Expand All @@ -36,10 +39,16 @@ public ServerPlayNetworkHandlerMixin(MinecraftServer server, ClientConnection co

@Shadow protected abstract void handleMessageChainException(MessageChain.MessageChainException exception);

@Shadow protected abstract void validateMessage(String message, Runnable callback);

@Shadow protected abstract Optional<LastSeenMessageList> validateAcknowledgment(LastSeenMessageList.Acknowledgment acknowledgment);

@Shadow public abstract void syncWithPlayerPosition();

@Shadow private double lastTickX;

@Shadow private double lastTickY;

@Shadow private double lastTickZ;

@Inject(method = "onChatMessage", at = @At("HEAD"), cancellable = true)
private void ccp_onChat(ChatMessageC2SPacket packet, CallbackInfo ci) {
if (this.player.currentScreenHandler instanceof VirtualScreenHandlerInterface handler && handler.getGui() instanceof MapGui computerGui) {
Expand Down Expand Up @@ -71,6 +80,28 @@ private void ccp_onChat(CommandExecutionC2SPacket packet, CallbackInfo ci) {
}
}

@WrapWithCondition(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;updatePositionAndAngles(DDDFF)V"))
private boolean ccp_allowMovement(ServerPlayerEntity instance, double x, double y, double z, float p, float yaw) {
if (this.player.currentScreenHandler instanceof VirtualScreenHandlerInterface handler && handler.getGui() instanceof MapGui computerGui) {
double l = instance.getX() - this.lastTickX;
double m = instance.getY() - this.lastTickY;
double n = instance.getZ() - this.lastTickZ;
this.player.getServerWorld().getChunkManager().updatePosition(this.player);
this.player.handleFall(l, m , n, player.isOnGround());
this.player.setOnGround(player.isOnGround(), new Vec3d(l, m , n));
this.syncWithPlayerPosition();
return false;
}
return true;
}

@Inject(method = "requestTeleport(DDDFFLjava/util/Set;)V", at = @At("HEAD"), cancellable = true)
private void ccp_noTeleport(double x, double y, double z, float yaw, float pitch, Set<PositionFlag> flags, CallbackInfo ci) {
if (this.player.currentScreenHandler instanceof VirtualScreenHandlerInterface handler && handler.getGui() instanceof MapGui computerGui) {
ci.cancel();
}
}

@Inject(method = "onPlayerMove", at = @At("HEAD"), cancellable = true)
private void ccp_onMove(PlayerMoveC2SPacket packet, CallbackInfo ci) {
if (this.player.currentScreenHandler instanceof VirtualScreenHandlerInterface handler && handler.getGui() instanceof MapGui computerGui) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/cc-tweaked-polymer-patch.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"mixins": [
"ServerPlayNetworkHandlerAccessor",
"TurtleModemAccessor",
"TurtleToolAccessor",
"mod.PlatformHelperImplRegistryEntryImplMixin",
"mod.ServerNetworkingMixin",
"mod.block.GenericBlockModelMixin",
Expand All @@ -20,6 +19,7 @@
"mod.ext.ServerInputStateMixin",
"mod.ext.ServerMonitorMixin",
"mod.ext.TerminalMixin",
"mod.item.AbstractComputerItemMixin",
"mod.item.GenericItemMixin",
"mod.item.ModRegistryCreativeTabsMixin",
"mod.item.ModRegistryDataComponentsMixin",
Expand Down

0 comments on commit 5ed76d0

Please sign in to comment.