-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
81 changed files
with
1,632 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/main/java/supersymmetry/api/metatileentity/MetaTileEntityGuiFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package supersymmetry.api.metatileentity; | ||
|
||
import com.cleanroommc.modularui.api.IGuiHolder; | ||
import com.cleanroommc.modularui.factory.AbstractUIFactory; | ||
import com.cleanroommc.modularui.factory.GuiManager; | ||
import com.cleanroommc.modularui.factory.PosGuiData; | ||
import gregtech.api.metatileentity.MetaTileEntity; | ||
import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.entity.player.EntityPlayerMP; | ||
import net.minecraft.network.PacketBuffer; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.util.math.BlockPos; | ||
import org.jetbrains.annotations.ApiStatus; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* Copied from CEu master branch | ||
*/ | ||
@Deprecated | ||
@ApiStatus.ScheduledForRemoval(inVersion = "Next CEu update") | ||
public class MetaTileEntityGuiFactory extends AbstractUIFactory<PosGuiData> { | ||
|
||
public static final MetaTileEntityGuiFactory INSTANCE = new MetaTileEntityGuiFactory(); | ||
|
||
private MetaTileEntityGuiFactory() { | ||
super("gregtech:mte"); | ||
} | ||
|
||
public static <T extends MetaTileEntity & IGuiHolder<PosGuiData>> void open(EntityPlayer player, T mte) { | ||
Objects.requireNonNull(player); | ||
Objects.requireNonNull(mte); | ||
if (!mte.isValid()) { | ||
throw new IllegalArgumentException("Can't open invalid MetaTileEntity GUI!"); | ||
} | ||
if (player.world != mte.getWorld()) { | ||
throw new IllegalArgumentException("MetaTileEntity must be in same dimension as the player!"); | ||
} | ||
BlockPos pos = mte.getPos(); | ||
PosGuiData data = new PosGuiData(player, pos.getX(), pos.getY(), pos.getZ()); | ||
GuiManager.open(INSTANCE, data, (EntityPlayerMP) player); | ||
} | ||
|
||
@Override | ||
public @NotNull IGuiHolder<PosGuiData> getGuiHolder(PosGuiData data) { | ||
TileEntity te = data.getTileEntity(); | ||
if (te instanceof IGregTechTileEntity gtte) { | ||
MetaTileEntity mte = gtte.getMetaTileEntity(); | ||
return Objects.requireNonNull(castGuiHolder(mte), "Found MetaTileEntity is not a gui holder!"); | ||
} | ||
throw new IllegalStateException("Found TileEntity is not a MetaTileEntity!"); | ||
} | ||
|
||
@Override | ||
public void writeGuiData(PosGuiData guiData, PacketBuffer buffer) { | ||
buffer.writeVarInt(guiData.getX()); | ||
buffer.writeVarInt(guiData.getY()); | ||
buffer.writeVarInt(guiData.getZ()); | ||
} | ||
|
||
@Override | ||
public @NotNull PosGuiData readGuiData(EntityPlayer player, PacketBuffer buffer) { | ||
return new PosGuiData(player, buffer.readVarInt(), buffer.readVarInt(), buffer.readVarInt()); | ||
} | ||
} |
112 changes: 112 additions & 0 deletions
112
src/main/java/supersymmetry/api/metatileentity/Mui2MetaTileEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package supersymmetry.api.metatileentity; | ||
|
||
import codechicken.lib.raytracer.CuboidRayTraceResult; | ||
import com.cleanroommc.modularui.api.IGuiHolder; | ||
import com.cleanroommc.modularui.drawable.UITexture; | ||
import com.cleanroommc.modularui.factory.PosGuiData; | ||
import com.cleanroommc.modularui.screen.ModularPanel; | ||
import com.cleanroommc.modularui.utils.Alignment; | ||
import com.cleanroommc.modularui.value.sync.PanelSyncManager; | ||
import com.cleanroommc.modularui.widgets.ButtonWidget; | ||
import gregtech.api.GTValues; | ||
import gregtech.api.gui.ModularUI; | ||
import gregtech.api.metatileentity.MetaTileEntity; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.util.EnumFacing; | ||
import net.minecraft.util.EnumHand; | ||
import net.minecraft.util.ResourceLocation; | ||
import org.jetbrains.annotations.ApiStatus; | ||
import org.jetbrains.annotations.NotNull; | ||
import supersymmetry.api.gui.SusyGuiTextures; | ||
|
||
@Deprecated | ||
@ApiStatus.ScheduledForRemoval(inVersion = "Next CEu update") | ||
public abstract class Mui2MetaTileEntity extends MetaTileEntity implements IGuiHolder<PosGuiData> { | ||
|
||
public Mui2MetaTileEntity(ResourceLocation metaTileEntityId) { | ||
super(metaTileEntityId); | ||
} | ||
|
||
@NotNull | ||
public static UITexture getLogo() { | ||
return GTValues.XMAS.get() ? SusyGuiTextures.GREGTECH_LOGO_XMAS : SusyGuiTextures.GREGTECH_LOGO; | ||
} | ||
|
||
public static ModularPanel createPanel(String name, int width, int height) { | ||
return ModularPanel.defaultPanel(name, width, height); | ||
} | ||
|
||
public static ModularPanel createPanel(MetaTileEntity mte, int width, int height) { | ||
return createPanel(mte.metaTileEntityId.getPath(), width, height); | ||
} | ||
|
||
public static ModularPanel defaultPanel(MetaTileEntity mte) { | ||
return createPanel(mte, 176, 166); | ||
} | ||
|
||
public static ModularPanel createPopupPanel(String name, int width, int height) { | ||
return createPopupPanel(name, width, height, false, false); | ||
} | ||
|
||
public static ModularPanel createPopupPanel(String name, int width, int height, boolean disableBelow, | ||
boolean closeOnOutsideClick) { | ||
return new PopupPanel(name, width, height, disableBelow, closeOnOutsideClick); | ||
} | ||
|
||
protected ModularUI createUI(EntityPlayer player) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public abstract ModularPanel buildUI(PosGuiData guiData, PanelSyncManager syncManager); | ||
|
||
public boolean useMui() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean onRightClick(EntityPlayer playerIn, EnumHand hand, EnumFacing facing, | ||
CuboidRayTraceResult hitResult) { | ||
if (useMui() && !playerIn.isSneaking() && openGUIOnRightClick()) { | ||
if (getWorld() != null && !getWorld().isRemote) { | ||
MetaTileEntityGuiFactory.open(playerIn, this); | ||
} | ||
return true; | ||
} else { | ||
return super.onRightClick(playerIn, hand, facing, hitResult); | ||
} | ||
} | ||
|
||
private static class PopupPanel extends ModularPanel { | ||
|
||
private final boolean disableBelow; | ||
private final boolean closeOnOutsideClick; | ||
|
||
public PopupPanel(@NotNull String name, int width, int height, boolean disableBelow, | ||
boolean closeOnOutsideClick) { | ||
super(name); | ||
size(width, height).align(Alignment.Center); | ||
background(SusyGuiTextures.BACKGROUND_POPUP); | ||
child(ButtonWidget.panelCloseButton().top(5).right(5) | ||
.onMousePressed(mouseButton -> { | ||
if (mouseButton == 0 || mouseButton == 1) { | ||
this.closeIfOpen(true); | ||
return true; | ||
} | ||
return false; | ||
})); | ||
this.disableBelow = disableBelow; | ||
this.closeOnOutsideClick = closeOnOutsideClick; | ||
} | ||
|
||
@Override | ||
public boolean disablePanelsBelow() { | ||
return disableBelow; | ||
} | ||
|
||
@Override | ||
public boolean closeOnOutOfBoundsClick() { | ||
return closeOnOutsideClick; | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/supersymmetry/api/stockinteraction/IStockInteractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package supersymmetry.api.stockinteraction; | ||
|
||
import net.minecraft.util.math.AxisAlignedBB; | ||
|
||
// Is this really necessary? | ||
public interface IStockInteractor { | ||
|
||
// Defines the area in which the machine can find and interact with stocks | ||
AxisAlignedBB getInteractionBoundingBox(); | ||
} |
Oops, something went wrong.