Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better support for multis with configurable channels #17

Merged
merged 8 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

dependencies {
api('com.github.GTNewHorizons:StructureLib:1.3.1:dev')
api("com.github.GTNewHorizons:NotEnoughEnergistics:1.6.0:dev")

implementation("com.github.GTNewHorizons:GT5-Unofficial:5.09.48.64:dev")
compileOnly("com.github.GTNewHorizons:NotEnoughEnergistics:1.6.0:dev")

runtimeOnlyNonPublishable("com.github.GTNewHorizons:StructureCompat:0.6.3:dev")
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ apiPackage =
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
# There can be multiple files in a space-separated list.
# Example value: mymodid_at.cfg nei_at.cfg
accessTransformersFile =
accessTransformersFile = blockrenderer6343_at.cfg

# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = false
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/blockrenderer6343/BlockRenderer6343.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class BlockRenderer6343 {

public static boolean isGTLoaded;
public static boolean isBartworksLoaded;
public static boolean isNEELoaded;

@Mod.EventHandler
// preInit "Run before anything else. Read your config, create blocks, items,
Expand All @@ -39,6 +40,7 @@ public void preInit(FMLPreInitializationEvent event) {
proxy.preInit(event);
isGTLoaded = Loader.isModLoaded("gregtech");
isBartworksLoaded = Loader.isModLoaded("bartworks");
isNEELoaded = Loader.isModLoaded("neenergistics");
}

@Mod.EventHandler
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/blockrenderer6343/client/utils/TooltipButton.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package blockrenderer6343.client.utils;

import java.util.function.BooleanSupplier;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.Tessellator;

Expand All @@ -10,13 +13,27 @@
public class TooltipButton extends GuiButtonExt {

public final String hoverString;
private final BooleanSupplier supplier;

public TooltipButton(int id, int xPos, int yPos, int width, int height, String displayString, String hoverString) {
this(id, xPos, yPos, width, height, displayString, hoverString, null);
}

public TooltipButton(int id, int xPos, int yPos, int width, int height, String displayString, String hoverString,
BooleanSupplier supplier) {
super(id, xPos, yPos, width, height, displayString);
this.hoverString = hoverString;
this.supplier = supplier;
}

@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
if (supplier != null && !supplier.getAsBoolean()) return;
super.drawButton(mc, mouseX, mouseY);
}

public boolean isMouseOver(int mouseX, int mouseY) {
if (supplier != null && !supplier.getAsBoolean()) return false;
return this.enabled && this.visible
&& mouseX >= this.xPosition
&& mouseY >= this.yPosition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.stats.StatBase;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.DamageSource;
import net.minecraft.util.IChatComponent;
import net.minecraft.world.World;

import com.mojang.authlib.GameProfile;

import blockrenderer6343.integration.nei.GUI_MultiblockHandler;

public class ClientFakePlayer extends EntityPlayer {

private static final String CHANNEL_KEY = "structurelib.autoplace.warning.no_explicit_channel";

public ClientFakePlayer(World world, GameProfile name) {
super(world, name);
}
Expand All @@ -29,7 +34,11 @@ public ChunkCoordinates getPlayerCoordinates() {
}

@Override
public void addChatComponentMessage(IChatComponent chatmessagecomponent) {}
public void addChatComponentMessage(IChatComponent message) {
if (message instanceof ChatComponentTranslation msg && msg.getKey().equals(CHANNEL_KEY)) {
GUI_MultiblockHandler.channels.add(msg.getFormatArgs()[0].toString());
}
}

@Override
public void addStat(StatBase par1StatBase, int par2) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@ protected void placeMultiblock() {
}
structureElements.clear();

if (mte instanceof ISurvivalConstructable) {
if (mte instanceof ISurvivalConstructable survivalConstructable) {
int result, iterations = 0;
do {
result = ((ISurvivalConstructable) mte).survivalConstruct(
getTriggerStack(),
result = survivalConstructable.survivalConstruct(
getBuildTriggerStack(),
Integer.MAX_VALUE,
ISurvivalBuildEnvironment.create(CreativeItemSource.instance, fakeMultiblockBuilder));
iterations++;
} while (result > 0 && iterations < MAX_PLACE_ROUNDS);
} else if (tTileEntity instanceof IConstructableProvider) {
constructable = ((IConstructableProvider) tTileEntity).getConstructable();
} else if (tTileEntity instanceof IConstructable) {
constructable = (IConstructable) tTileEntity;
} else if (tTileEntity instanceof IConstructableProvider iConstructableProvider) {
constructable = iConstructableProvider.getConstructable();
} else if (tTileEntity instanceof IConstructable iConstructable) {
constructable = iConstructable;
}
if (constructable != null) {
constructable.construct(getTriggerStack(), false);
constructable.construct(getBuildTriggerStack(), false);
}

if (StructureLibAPI.isInstrumentEnabled()) {
Expand Down
Loading