Skip to content

Commit

Permalink
Fix crash when copycats from other mods interact with multistates
Browse files Browse the repository at this point in the history
  • Loading branch information
hlysine committed Jun 27, 2024
1 parent 4b8705a commit a321561
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import net.minecraft.world.level.block.state.BlockState;

public interface IFunctionalCopycatBlockEntity extends CTCopycatBlockEntity, ISpecialBlockEntityItemRequirement, ITransformableBlockEntity, IPartialSafeNBT {
CopycatBlockEntity getCopycatBlockEntity();
default CopycatBlockEntity getCopycatBlockEntity() {
return this instanceof CopycatBlockEntity be ? be : null;
}

default Level getLevel() {
return getCopycatBlockEntity().getLevel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.copycatsplus.copycats.Copycats;
import com.copycatsplus.copycats.config.CCConfigs;
import com.copycatsplus.copycats.content.copycat.base.functional.IFunctionalCopycatBlockEntity;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.ITransformableBlockEntity;
import com.simibubi.create.content.contraptions.StructureTransform;
import com.simibubi.create.content.decoration.copycat.CopycatBlockEntity;
Expand Down Expand Up @@ -50,6 +51,14 @@ public CopycatBlockEntity getCopycatBlockEntity() {
return null;
}

@Override
public BlockState getMaterial() {
return materialItemStorage.getAllMaterials().stream()
.filter(x -> !x.is(AllBlocks.COPYCAT_BASE.get()))
.findFirst()
.orElse(AllBlocks.COPYCAT_BASE.getDefaultState());
}

@Override
public void setLevel(@NotNull Level level) {
super.setLevel(level);
Expand Down

0 comments on commit a321561

Please sign in to comment.