Skip to content

Commit

Permalink
- Fix MagicPrimer#addManaInput method conflict with gugu-utils.
Browse files Browse the repository at this point in the history
- Fix client-side issue that sometimes did not hide controller rendering correctly.
- Optimize the rendering range of controller Geo models.
  • Loading branch information
KasumiNova committed Nov 23, 2023
1 parent 0b2718a commit ea9ef66
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 12 deletions.
7 changes: 5 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {

// Project properties
group = "hellfirepvp.modularmachinery"
version = "1.12.2-1.11.1-r52-dev"
version = "1.12.2-1.11.1-r53-dev"

// Set the toolchain version to decouple the Java we run Gradle with from the Java used to compile and run the mod
java {
Expand Down Expand Up @@ -115,6 +115,9 @@ repositories {
maven {
url = uri("https://maven.blamejared.com/")
}
maven {
url = uri("https://repo.spongepowered.org/maven")
}
maven {
name = "OvermindDL1 Maven"
url = uri("https://gregtech.overminddl1.com/")
Expand Down Expand Up @@ -180,7 +183,7 @@ dependencies {
implementation(rfg.deobf("software.bernie.geckolib:geckolib-forge-1.12.2:3.0.31"))

// Multiblocked
compileOnly(rfg.deobf("curse.maven:multiblocked-604054:4753960"))
implementation(rfg.deobf("curse.maven:multiblocked-604054:4753960"))

// Modular Magic compact
compileOnly(rfg.deobf("curse.maven:astral-sorcery-241721:3044416"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public static void onWorldUnloadPlugin() {
MultiblockWorldSavedData.clearDisabled();
}

@SuppressWarnings("DuplicatedCode")
@Optional.Method(modid = "multiblocked")
private static void hideOrShowBlocksMBD(TileMultiblockMachineController ctrl) {
DynamicMachine foundMachine = ctrl.getFoundMachine();
Expand All @@ -69,6 +70,7 @@ private static void hideOrShowBlocksMBD(TileMultiblockMachineController ctrl) {
}
}

@SuppressWarnings("DuplicatedCode")
@Optional.Method(modid = "component_model_hider")
private static void hideOrShowBlocksPlugin(TileMultiblockMachineController ctrl) {
DynamicMachine foundMachine = ctrl.getFoundMachine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,30 @@ public boolean canConnectRedstone(@Nonnull IBlockState state, @Nonnull IBlockAcc
public EnumBlockRenderType getRenderType(@Nonnull IBlockState state) {
if (parentMachine != null && DynamicMachineModelRegistry.INSTANCE.getMachineDefaultModel(parentMachine) != null) {
if (state.getValue(FORMED)) {
return EnumBlockRenderType.ENTITYBLOCK_ANIMATED;
return EnumBlockRenderType.INVISIBLE;
}
}
return EnumBlockRenderType.MODEL;
}

@Override
public boolean doesSideBlockRendering(@Nonnull final IBlockState state, @Nonnull final IBlockAccess blockAccess, @Nonnull final BlockPos pos, @Nonnull final EnumFacing face) {
if (parentMachine != null && DynamicMachineModelRegistry.INSTANCE.getMachineDefaultModel(parentMachine) != null) {
return !state.getValue(FORMED);
}
return true;
}

@Override
public boolean shouldSideBeRendered(@Nonnull final IBlockState state, @Nonnull final IBlockAccess blockAccess, @Nonnull final BlockPos pos, @Nonnull final EnumFacing side) {
if (parentMachine != null && DynamicMachineModelRegistry.INSTANCE.getMachineDefaultModel(parentMachine) != null) {
if (state.getValue(FORMED)) {
return false;
}
}
return super.shouldSideBeRendered(state, blockAccess, pos, side);
}

@Override
public boolean isOpaqueCube(@Nonnull final IBlockState state) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3i;
import net.minecraft.util.text.TextFormatting;
Expand Down Expand Up @@ -540,7 +541,7 @@ public void notifyStructureFormedState(boolean formed) {
}

if (world.isRemote) {
world.setBlockState(getPos(), newState, 8);
world.setBlockState(getPos(), newState, 2);
} else {
world.setBlockState(getPos(), newState, 3);
}
Expand Down Expand Up @@ -1036,10 +1037,8 @@ public void readCustomNBT(NBTTagCompound compound) {

if (FMLCommonHandler.instance().getSide().isClient()) {
ClientProxy.clientScheduler.addRunnable(() -> {
if (getWorld().isRemote) {
BlockModelHider.hideOrShowBlocks(this);
notifyStructureFormedState(isStructureFormed());
}
BlockModelHider.hideOrShowBlocks(this);
notifyStructureFormedState(isStructureFormed());
}, 1);
if (!isStructureFormed()) {
animationFactory = null;
Expand Down Expand Up @@ -1179,6 +1178,16 @@ public void setWorkMode(final WorkMode workMode) {
this.workMode = workMode;
}

@Nonnull
@Override
public AxisAlignedBB getRenderBoundingBox() {
if (!isStructureFormed()) {
return super.getRenderBoundingBox();
}
BlockPos pos = getPos();
return new AxisAlignedBB(pos.add(foundPattern.getMin()), pos.add(foundPattern.getMax()));
}

@Override
@net.minecraftforge.fml.common.Optional.Method(modid = "geckolib3")
public void registerControllers(final AnimationData data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,19 +208,19 @@ public static RecipePrimer addWillOutput(RecipePrimer primer, String willTypeStr
}

@ZenMethod
public static RecipePrimer addManaInput(RecipePrimer primer, int amount) {
public static RecipePrimer addManaInput(RecipePrimer primer, int amount, boolean perTick) {
if (amount > 0)
primer.appendComponent(new RequirementMana(IOType.INPUT, amount, false));
primer.appendComponent(new RequirementMana(IOType.INPUT, amount, perTick));
else
CraftTweakerAPI.logError("Invalid Mana amount : " + amount + " (need to be positive and not null)");

return primer;
}

@ZenMethod
public static RecipePrimer addManaOutput(RecipePrimer primer, int amount) {
public static RecipePrimer addManaOutput(RecipePrimer primer, int amount, boolean perTick) {
if (amount > 0)
primer.appendComponent(new RequirementMana(IOType.OUTPUT, amount, false));
primer.appendComponent(new RequirementMana(IOType.OUTPUT, amount, perTick));
else
CraftTweakerAPI.logError("Invalid Mana amount : " + amount + " (need to be positive and not null)");

Expand Down

0 comments on commit ea9ef66

Please sign in to comment.