Skip to content

Commit

Permalink
Fix a CT bug that should exist in all versions but for some reason do…
Browse files Browse the repository at this point in the history
…esn't happen in 1.20
  • Loading branch information
hlysine committed Jun 28, 2024
1 parent 6f1ef90 commit effbda4
Show file tree
Hide file tree
Showing 16 changed files with 145 additions and 2 deletions.
7 changes: 7 additions & 0 deletions common/src/main/java/com/copycatsplus/copycats/CCBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.copycatsplus.copycats.config.FeatureCategory;
import com.copycatsplus.copycats.config.FeatureToggle;
import com.copycatsplus.copycats.content.copycat.base.functional.WrappedCopycatBlock;
import com.copycatsplus.copycats.content.copycat.base.model.SimpleCopycatPart;
import com.copycatsplus.copycats.content.copycat.base.model.ToggleableCopycatModel;
import com.copycatsplus.copycats.content.copycat.base.model.multistate.SimpleMultiStateCopycatPart;
Expand Down Expand Up @@ -68,6 +69,7 @@
import com.copycatsplus.copycats.content.copycat.wall.CopycatWallModel;
import com.copycatsplus.copycats.content.copycat.wall.WrappedWallBlock;
import com.copycatsplus.copycats.datagen.CCLootGen;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllTags;
import com.simibubi.create.content.kinetics.BlockStressDefaults;
import com.simibubi.create.foundation.data.*;
Expand Down Expand Up @@ -102,6 +104,11 @@ public class CCBlocks {

private static final CopycatRegistrate REGISTRATE = Copycats.getRegistrate();

public static final BlockEntry<WrappedCopycatBlock> WRAPPED_COPYCAT =
REGISTRATE.block("wrapped_copycat", WrappedCopycatBlock::new)
.transform(BuilderTransformers.copycat())
.register();

public static final BlockEntry<CopycatBlockBlock> COPYCAT_BLOCK =
REGISTRATE.block("copycat_block", CopycatBlockBlock::new)
.transform(BuilderTransformers.copycat())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.copycatsplus.copycats.content.copycat.base.functional;

import com.simibubi.create.content.decoration.copycat.CopycatBlock;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;

public class WrappedCopycatBlock extends CopycatBlock {

private final ThreadLocal<IFunctionalCopycatBlock> wrapped = new ThreadLocal<>();

public WrappedCopycatBlock(Properties pProperties) {
super(pProperties);
}

public IFunctionalCopycatBlock getWrapped() {
return wrapped.get();
}

public void setWrapped(IFunctionalCopycatBlock wrapped) {
this.wrapped.set(wrapped);
}

@Override
public boolean isIgnoredConnectivitySide(BlockAndTintGetter reader, BlockState state, Direction face, BlockPos fromPos, BlockPos toPos) {
return wrapped.get().isIgnoredConnectivitySide(reader, state, face, fromPos, toPos);
}

@Override
public boolean canConnectTexturesToward(BlockAndTintGetter reader, BlockPos fromPos, BlockPos toPos, BlockState state) {
return wrapped.get().canConnectTexturesToward(reader, fromPos, toPos, state);
}

@Override
public boolean canFaceBeOccluded(BlockState state, Direction face) {
return wrapped.get().canFaceBeOccluded(state, face);
}

@Override
public boolean shouldFaceAlwaysRender(BlockState state, Direction face) {
return wrapped.get().shouldFaceAlwaysRender(state, face);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.copycatsplus.copycats.mixin.copycat.base.functional;

import com.copycatsplus.copycats.CCBlocks;
import com.copycatsplus.copycats.content.copycat.base.functional.IFunctionalCopycatBlock;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.simibubi.create.foundation.block.connected.CTModel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(CTModel.class)
public class CTModelMixin {
@WrapOperation(
method = "createCTData",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;getBlock()Lnet/minecraft/world/level/block/Block;")
)
private Block createCTData(BlockState instance, Operation<Block> original) {
if (instance.getBlock() instanceof IFunctionalCopycatBlock fcb) {
CCBlocks.WRAPPED_COPYCAT.get().setWrapped(fcb);
return CCBlocks.WRAPPED_COPYCAT.get();
}
return original.call(instance);
}
}
1 change: 1 addition & 0 deletions common/src/main/resources/copycats-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"feature_toggle.CreativeModeTabsAccessor"
],
"client": [
"copycat.base.functional.CTModelMixin",
"copycat.base.multistate.ModelBlockRendererMixin"
],
"injectors": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "minecraft:block/air"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
"block.copycats.copycat_wooden_pressure_plate.tooltip.behaviour1": "˙ןɐıɹǝʇɐɯ ǝɥʇ ‾ʇǝsǝɹ‾ oʇ ‾ɥɔuǝɹM‾ ɐ ǝs∩ ˙ǝʇɐʇs ‾pǝɹǝʍod‾ ɹo ‾uoıʇɐʇuǝıɹo‾ ǝןɔʎɔ oʇ ‾uıɐbɐ ʞɔıןƆ‾ ˙ǝןqıssod ɟı ‾ןɐıɹǝʇɐɯ‾ sʇı sɐ ‾ɯǝʇı pןǝɥ‾ sǝıןddⱯ",
"block.copycats.copycat_wooden_pressure_plate.tooltip.condition1": "pǝʞɔıןƆ-ᴚ uǝɥM",
"block.copycats.copycat_wooden_pressure_plate.tooltip.summary": "˙ǝʇɐןd ǝɹnssǝɹd uǝpooʍ ןɐuoıʇɔunɟ ɐ oʇuı ‾ʞɔoןq ןןnɟ‾ ʎuɐ ‾sʇɹǝʌuoƆ‾",
"block.copycats.wrapped_copycat": "ʇɐɔʎdoƆ pǝddɐɹM",
"block.copycats.wrapped_copycat_fence": "ǝɔuǝℲ ʇɐɔʎdoƆ pǝddɐɹM",
"block.copycats.wrapped_copycat_fence_gate": "ǝʇɐ⅁ ǝɔuǝℲ ʇɐɔʎdoƆ pǝddɐɹM",
"block.copycats.wrapped_copycat_heavy_weighted_pressure_plate": "ǝʇɐןԀ ǝɹnssǝɹԀ pǝʇɥbıǝM ʎʌɐǝH ʇɐɔʎdoƆ pǝddɐɹM",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
"block.copycats.copycat_wooden_pressure_plate.tooltip.behaviour1": "Applies _held item_ as its _material_ if possible. _Click again_ to cycle _orientation_ or _powered_ state. Use a _Wrench_ to _reset_ the material.",
"block.copycats.copycat_wooden_pressure_plate.tooltip.condition1": "When R-Clicked",
"block.copycats.copycat_wooden_pressure_plate.tooltip.summary": "_Converts_ any _full block_ into a functional wooden pressure plate.",
"block.copycats.wrapped_copycat": "Wrapped Copycat",
"block.copycats.wrapped_copycat_fence": "Wrapped Copycat Fence",
"block.copycats.wrapped_copycat_fence_gate": "Wrapped Copycat Fence Gate",
"block.copycats.wrapped_copycat_heavy_weighted_pressure_plate": "Wrapped Copycat Heavy Weighted Pressure Plate",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:air"
}
],
"rolls": 1.0
}
],
"random_sequence": "copycats:blocks/wrapped_copycat"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"replace": false,
"values": [
"copycats:wrapped_copycat",
"copycats:copycat_block",
"copycats:copycat_beam",
"copycats:copycat_board",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"replace": false,
"values": [
"copycats:wrapped_copycat",
"copycats:copycat_block",
"copycats:copycat_beam",
"copycats:copycat_board",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "minecraft:block/air"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
"block.copycats.copycat_wooden_pressure_plate.tooltip.behaviour1": "˙ןɐıɹǝʇɐɯ ǝɥʇ ‾ʇǝsǝɹ‾ oʇ ‾ɥɔuǝɹM‾ ɐ ǝs∩ ˙ǝʇɐʇs ‾pǝɹǝʍod‾ ɹo ‾uoıʇɐʇuǝıɹo‾ ǝןɔʎɔ oʇ ‾uıɐbɐ ʞɔıןƆ‾ ˙ǝןqıssod ɟı ‾ןɐıɹǝʇɐɯ‾ sʇı sɐ ‾ɯǝʇı pןǝɥ‾ sǝıןddⱯ",
"block.copycats.copycat_wooden_pressure_plate.tooltip.condition1": "pǝʞɔıןƆ-ᴚ uǝɥM",
"block.copycats.copycat_wooden_pressure_plate.tooltip.summary": "˙ǝʇɐןd ǝɹnssǝɹd uǝpooʍ ןɐuoıʇɔunɟ ɐ oʇuı ‾ʞɔoןq ןןnɟ‾ ʎuɐ ‾sʇɹǝʌuoƆ‾",
"block.copycats.wrapped_copycat": "ʇɐɔʎdoƆ pǝddɐɹM",
"block.copycats.wrapped_copycat_fence": "ǝɔuǝℲ ʇɐɔʎdoƆ pǝddɐɹM",
"block.copycats.wrapped_copycat_fence_gate": "ǝʇɐ⅁ ǝɔuǝℲ ʇɐɔʎdoƆ pǝddɐɹM",
"block.copycats.wrapped_copycat_heavy_weighted_pressure_plate": "ǝʇɐןԀ ǝɹnssǝɹԀ pǝʇɥbıǝM ʎʌɐǝH ʇɐɔʎdoƆ pǝddɐɹM",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
"block.copycats.copycat_wooden_pressure_plate.tooltip.behaviour1": "Applies _held item_ as its _material_ if possible. _Click again_ to cycle _orientation_ or _powered_ state. Use a _Wrench_ to _reset_ the material.",
"block.copycats.copycat_wooden_pressure_plate.tooltip.condition1": "When R-Clicked",
"block.copycats.copycat_wooden_pressure_plate.tooltip.summary": "_Converts_ any _full block_ into a functional wooden pressure plate.",
"block.copycats.wrapped_copycat": "Wrapped Copycat",
"block.copycats.wrapped_copycat_fence": "Wrapped Copycat Fence",
"block.copycats.wrapped_copycat_fence_gate": "Wrapped Copycat Fence Gate",
"block.copycats.wrapped_copycat_heavy_weighted_pressure_plate": "Wrapped Copycat Heavy Weighted Pressure Plate",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:air"
}
],
"rolls": 1.0
}
],
"random_sequence": "copycats:blocks/wrapped_copycat"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"values": [
"copycats:wrapped_copycat",
"copycats:copycat_block",
"copycats:copycat_beam",
"copycats:copycat_board",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"values": [
"copycats:wrapped_copycat",
"copycats:copycat_block",
"copycats:copycat_beam",
"copycats:copycat_board",
Expand All @@ -26,8 +27,8 @@
"copycats:copycat_vertical_step",
"copycats:copycat_wall",
"copycats:copycat_slope",
"copycats:copycat_shaft",
"copycats:copycat_vertical_slope",
"copycats:copycat_slope_layer"
"copycats:copycat_slope_layer",
"copycats:copycat_shaft"
]
}

0 comments on commit effbda4

Please sign in to comment.