Skip to content

Commit

Permalink
Fix compatibility with Extended Cogwheels
Browse files Browse the repository at this point in the history
  • Loading branch information
hlysine committed Jul 19, 2024
1 parent be7d021 commit 6068e92
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.copycatsplus.copycats.foundation.copycat;

import com.copycatsplus.copycats.foundation.copycat.multistate.IMultiStateCopycatBlock;
import com.copycatsplus.copycats.utility.BlockEntityUtils;
import com.copycatsplus.copycats.utility.BlockFaceUtils;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems;
Expand Down Expand Up @@ -103,7 +104,7 @@ default InteractionResult toggleCT(BlockState pState, Level pLevel, BlockPos pPo
if (!canToggleCT(pState, pLevel, pPos))
return InteractionResult.PASS;
fbe.setCTEnabled(!fbe.isCTEnabled());
fbe.redraw();
BlockEntityUtils.redraw((BlockEntity) fbe);
return InteractionResult.SUCCESS;
}
return InteractionResult.PASS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ default void setMaterial(BlockState blockState) {
notifyUpdate();
return;
}
redraw();
BlockEntityUtils.redraw((BlockEntity) this);
}

default boolean cycleMaterial() {
Expand Down Expand Up @@ -196,7 +196,7 @@ static void read(ICopycatBlockEntity self, CompoundTag tag, boolean clientPacket
}

if (clientPacket && prevMaterial != self.getMaterial())
self.redraw();
BlockEntityUtils.redraw((BlockEntity) self); // not calling self.redraw() because Extended Cogwheels overwrites it to be protected
}

static void writeSafe(ICopycatBlockEntity self, CompoundTag tag) {
Expand All @@ -215,8 +215,4 @@ static void write(CompoundTag tag, ItemStack stack, BlockState material, boolean
tag.put("Material", NbtUtils.writeBlockState(material));
tag.putBoolean("EnableCT", enableCT);
}

default void redraw() {
BlockEntityUtils.redraw((BlockEntity) this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import com.copycatsplus.copycats.foundation.copycat.model.ScaledBlockAndTintGetter;
import com.copycatsplus.copycats.network.CCPackets;
import com.copycatsplus.copycats.network.FillCopycatPacket;
import com.copycatsplus.copycats.utility.BlockEntityUtils;
import com.copycatsplus.copycats.utility.BlockFaceUtils;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems;
import com.simibubi.create.AllKeys;
import com.simibubi.create.AllTags;
import com.simibubi.create.content.contraptions.StructureTransform;
import com.simibubi.create.foundation.block.IBE;
Expand Down Expand Up @@ -186,7 +186,7 @@ default InteractionResult toggleCT(BlockState state, Level level, BlockPos pos,
if (be == null)
return InteractionResult.PASS;
be.setEnableCT(property, !be.getMaterialItemStorage().getMaterialItem(property).enableCT());
be.redraw();
BlockEntityUtils.redraw((BlockEntity) be);
return InteractionResult.SUCCESS;
}
return InteractionResult.PASS;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.copycatsplus.copycats.foundation.copycat.multistate;

import com.copycatsplus.copycats.foundation.copycat.ICopycatBlockEntity;
import com.copycatsplus.copycats.utility.BlockEntityUtils;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.StructureTransform;
import com.simibubi.create.content.redstone.RoseQuartzLampBlock;
Expand All @@ -11,6 +12,7 @@
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.TrapDoorBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import org.jetbrains.annotations.ApiStatus;
Expand Down Expand Up @@ -115,7 +117,7 @@ default void setMaterial(String property, BlockState blockState) {
notifyUpdate();
return;
}
redraw();
BlockEntityUtils.redraw((BlockEntity) this);
}

default boolean cycleMaterial(String property) {
Expand Down Expand Up @@ -167,7 +169,7 @@ static void read(IMultiStateCopycatBlockEntity self, CompoundTag tag, boolean cl
boolean anyUpdated = self.getMaterialItemStorage().deserialize(tag.getCompound("material_data"));

if (clientPacket && anyUpdated)
self.redraw();
BlockEntityUtils.redraw((BlockEntity) self); // not calling self.redraw() because Extended Cogwheels overwrites it to be protected
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.copycatsplus.copycats.Copycats;
import com.copycatsplus.copycats.foundation.copycat.ICopycatBlockEntity;
import com.copycatsplus.copycats.utility.BlockEntityUtils;
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
import net.minecraft.MethodsReturnNonnullByDefault;
Expand Down Expand Up @@ -76,7 +77,7 @@ public void migrateData(ICopycatBlockEntity copycatBlockEntity) {
.orElse(null);
if (firstProperty == null) {
Copycats.LOGGER.error("Failed to convert block({}) at @{} to a multistate copycat: no valid properties found", blockId.toString(), copycatBlockEntity.getBlockPos().toShortString());
redraw();
BlockEntityUtils.redraw(this);
return;
}
MaterialItemStorage.MaterialItem materialItem = materialItemStorage.getMaterialItem(firstProperty);
Expand All @@ -93,7 +94,7 @@ public void migrateData(ICopycatBlockEntity copycatBlockEntity) {
}
}
}
redraw();
BlockEntityUtils.redraw(this);
}
}
}
1 change: 1 addition & 0 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ dependencies {
modImplementation("curse.maven:athena-841890:${athena_fabric_curse_id}")
modImplementation("curse.maven:indium-459496:${indium_fabric_curse_id}")
modLocalRuntime("maven.modrinth:sodium:${sodium_fabric_version}")
modLocalRuntime("maven.modrinth:extended-cogwheels:${extended_cogwheels_fabric_version}")

annotationProcessor(implementation(include("io.github.llamalad7:mixinextras-fabric:${mixin_extras_version}")))

Expand Down
1 change: 1 addition & 0 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ dependencies {
modImplementation("curse.maven:additional-placements-674852:${additionalplacements_forge_curse_id}")
modImplementation("curse.maven:athena-841890:${athena_forge_curse_id}")
modLocalRuntime("curse.maven:create-industry-693815:${tfmg_forge_curse_id}")
modLocalRuntime("curse.maven:create-extended-cogs-739973:${extended_cogwheels_forge_curse_id}")

modCompileOnly("curse.maven:double-slabs-350179:${double_slabs_curse_id}")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ public CopycatBlockEntityMixin(BlockEntityType<?> type, BlockPos pos, BlockState
super(type, pos, state);
}

@Override
public void redraw() {
if (!isVirtual())
requestModelDataUpdate();
BlockEntityUtils.redraw(this);
}

@Override
public @NotNull ModelData getModelData() {
return KineticCopycatRendererImpl.mergeData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ public MultiStateCopycatBlockEntityMixin(BlockEntityType<?> type, BlockPos pos,
super(type, pos, state);
}

@Override
public void redraw() {
if (!isVirtual())
requestModelDataUpdate();
BlockEntityUtils.redraw(this);
}

@Override
public @NotNull ModelData getModelData() {
return KineticCopycatRendererImpl.mergeData(
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ parchment_version=2023.09.03

#Mod Loaders
enabled_platforms=fabric,forge
fabric_loader_version=0.15.7
fabric_loader_version=0.15.9
fabric_api_version=0.92.0+1.20.1
forge_version=1.20.1-47.2.20

Expand All @@ -43,6 +43,7 @@ additionalplacements_forge_curse_id=5142065
jade_forge_curse_id=5390389
athena_forge_curse_id=5176879
tfmg_forge_curse_id=5505872
extended_cogwheels_forge_curse_id=5229925

#Fabric Properties
create_fabric_version=0.5.1-f-build.1335+mc1.20.1
Expand All @@ -55,3 +56,4 @@ jade_fabric_curse_id=5339230
athena_fabric_curse_id=5176880
indium_fabric_curse_id=5493195
sodium_fabric_version=mc1.20.1-0.5.11
extended_cogwheels_fabric_version=2.1.1-1.20.1-0.5.1.f-fabric

0 comments on commit 6068e92

Please sign in to comment.