Skip to content

Commit

Permalink
fix mod PatternDetails hashCode & equals, allow CircuitProvider provi…
Browse files Browse the repository at this point in the history
…de empty circuit
  • Loading branch information
reobf committed Mar 27, 2024
1 parent 8c43473 commit 1ded322
Show file tree
Hide file tree
Showing 36 changed files with 2,755 additions and 113 deletions.
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ autoUpdateBuildScript = false
DISABLE_BUILDSCRIPT_GRADLE_UPDATE=true
minecraftVersion = 1.7.10
forgeVersion = 10.13.4.1614

org.gradle.daemon=false
org.gradle.parallel=false
# Specify a MCP channel and mappings version for dependency deobfuscation and the deobfParams task.
channel = stable
mappingsVersion = 12
Expand Down Expand Up @@ -71,7 +72,7 @@ mixinsPackage = mixin.mixins
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
# This parameter is for legacy compatibility only
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
coreModClass =
coreModClass =
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
containsMixinsAndOrCoreModOnly = false
Expand Down
26 changes: 3 additions & 23 deletions src/main/java/reobf/proghatches/block/BlockIOHub.java
Original file line number Diff line number Diff line change
@@ -1,46 +1,25 @@
package reobf.proghatches.block;

import java.util.Optional;
import java.util.Random;

import com.gtnewhorizons.modularui.api.UIInfos;
import com.gtnewhorizons.modularui.common.internal.network.NetworkUtils;

import appeng.core.AppEng;
import appeng.core.sync.GuiBridge;
import appeng.items.tools.quartz.ToolQuartzCuttingKnife;
import appeng.util.Platform;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.api.gui.modularui.GT_UIInfos;
import gregtech.api.interfaces.tileentity.ICoverable;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.BaseMetaTileEntity;
import gregtech.api.metatileentity.CoverableTileEntity;
import gregtech.api.objects.GT_ItemStack;
import gregtech.common.blocks.GT_Material_Machines;

import li.cil.oc.api.network.ManagedEnvironment;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.ForgeEventFactory;

public class BlockIOHub extends BlockContainer {


public BlockIOHub() {
super(new GT_Material_Machines());

Expand All @@ -52,10 +31,11 @@ public BlockIOHub() {

@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {

return new TileIOHub();
}
@SideOnly(Side.CLIENT)
@Override
@SideOnly(Side.CLIENT)
protected String getTextureName()
{
return this.textureName = "proghatches:iohub";
Expand Down
183 changes: 183 additions & 0 deletions src/main/java/reobf/proghatches/eucrafting/BlockEUInterface.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
package reobf.proghatches.eucrafting;

import java.util.EnumSet;
import java.util.List;

import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.render.RenderBlockFluidInterface;
import com.glodblock.github.common.block.BlockFluidInterface;
import com.glodblock.github.common.block.FCBaseBlock;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.NameConst;
import com.gtnewhorizons.modularui.api.UIInfos;
import com.gtnewhorizons.modularui.common.internal.network.NetworkUtils;

import appeng.api.util.IOrientable;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.BlockRenderInfo;
import appeng.core.features.AEFeature;
import appeng.core.features.ActivityState;
import appeng.core.features.BlockStackSrc;
import appeng.tile.AEBaseTile;
import appeng.tile.misc.TileInterface;
import appeng.util.Platform;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import com.glodblock.github.client.textures.FCPartsTexture;
import com.glodblock.github.common.block.BlockFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;

public class BlockEUInterface extends AEBaseTileBlock{



@Override
protected boolean hasCustomRotation() {
return true;
}

@Override
protected void customRotateBlock(final IOrientable rotatable, final ForgeDirection axis) {
if (rotatable instanceof TileInterface) {
((TileInterface) rotatable).setSide(axis);
}
}

@Override
@SideOnly(Side.CLIENT)
protected BaseBlockRender<BlockEUInterface, TileFluidInterface_EU> getRenderer() {
return new BaseBlockRender<BlockEUInterface, TileFluidInterface_EU>(false, 20){





@Override
public boolean renderInWorld(final BlockEUInterface block, final IBlockAccess world, final int x, final int y,
final int z, final RenderBlocks renderer) {
final TileInterface ti = block.getTileEntity(world, x, y, z);
final BlockRenderInfo info = block.getRendererInstance();

if (ti != null && ti.getForward() != ForgeDirection.UNKNOWN) {
final IIcon side = FCPartsTexture.BlockFluidInterfaceAlternate_Arrow.getIcon();
info.setTemporaryRenderIcons(
FCPartsTexture.BlockInterfaceAlternate.getIcon(),
block.getIcon(0, 0),
side,
side,
side,
side);
}

final boolean fz = super.renderInWorld(block, world, x, y, z, renderer);

info.setTemporaryRenderIcon(null);

return fz;
}
};

};


@Override
public boolean onActivated(final World world, final int x, final int y, final int z, final EntityPlayer player,
final int facing, final float hitX, final float hitY, final float hitZ) {
if (player.isSneaking()) {


b:{
if (NetworkUtils.isClient()) break b;
UIInfos.TILE_MODULAR_UI.open(player, world, x, y, z);
}return true;
}
final TileInterface tg = this.getTileEntity(world, x, y, z);
if (tg != null) {
if (Platform.isServer()) {
InventoryHandler.openGui(
player,
world,
new BlockPos(x, y, z),
ForgeDirection.getOrientation(facing),
GuiType.DUAL_INTERFACE);
}
return true;
}
return false;
}
public BlockEUInterface(Material mat, String name) {
super(mat);
this.setBlockName(name);
setFullBlock(true);
setOpaque(true);
setTileEntity(TileFluidInterface_EU.class);
setFeature(EnumSet.of(AEFeature.Core));
// this.setBlockTextureName(FluidCraft.MODID + ":" + name);
}

@Override
public void setTileEntity(final Class<? extends TileEntity> clazz) {
AEBaseTile.registerTileItem(clazz, new BlockStackSrc(this, 0, ActivityState.Enabled));
super.setTileEntity(clazz);
}

public void setOpaque(boolean opaque) {
this.isOpaque = opaque;
}

public void setFullBlock(boolean full) {
this.isFullSize = full;
}

@Override
public void setFeature(final EnumSet<AEFeature> f) {
super.setFeature(f);
}

@SideOnly(Side.CLIENT)
public void addInformation(final ItemStack itemStack, final EntityPlayer player, final List<String> toolTip,
final boolean advancedToolTips) {}

public void addCheckedInformation(ItemStack itemStack, EntityPlayer player, List<String> toolTip,
boolean advancedToolTips) {
this.addInformation(itemStack, player, toolTip, advancedToolTips);
}

public ItemStack stack(int size) {
return new ItemStack(this, size);
}

public ItemStack stack() {
return new ItemStack(this, 1);
}



@Override
public void addCollisionBoxesToList(World w, int x, int y, int z, AxisAlignedBB bb, List out,
Entity e) {
// TODO Auto-generated method stub
super.addCollisionBoxesToList(w, x, y, z, bb, out, e);
}


}
132 changes: 132 additions & 0 deletions src/main/java/reobf/proghatches/eucrafting/EUUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
package reobf.proghatches.eucrafting;

import java.util.Optional;

import javax.annotation.Nullable;

import com.gtnewhorizons.modularui.ModularUI;
import com.gtnewhorizons.modularui.api.screen.IContainerCreator;
import com.gtnewhorizons.modularui.api.screen.IGuiCreator;
import com.gtnewhorizons.modularui.api.screen.IItemWithModularUI;
import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI;
import com.gtnewhorizons.modularui.api.screen.ModularUIContext;
import com.gtnewhorizons.modularui.api.screen.ModularWindow;
import com.gtnewhorizons.modularui.api.screen.UIBuildContext;
import com.gtnewhorizons.modularui.common.builder.UIBuilder;
import com.gtnewhorizons.modularui.common.builder.UIInfo;
import com.gtnewhorizons.modularui.common.internal.InternalUIMapper;
import com.gtnewhorizons.modularui.common.internal.network.NetworkUtils;
import com.gtnewhorizons.modularui.common.internal.wrapper.ModularGui;
import com.gtnewhorizons.modularui.common.internal.wrapper.ModularUIContainer;

import appeng.api.AEApi;
import appeng.api.implementations.tiles.ISegmentedInventory;
import appeng.api.parts.IPartHost;
import appeng.tile.AEBaseTile;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.ForgeDirection;
import reobf.proghatches.eucrafting.IEUSource.EUSource;
import reobf.proghatches.main.MyMod;
import reobf.proghatches.net.OpenPartGuiMessage;

public class EUUtil {
public static void register(){
AEApi.instance().registries().gridCache().registerGridCache(IEUSource.class, EUSource.class);



}
public static boolean check(ISegmentedInventory inv){

IInventory sub = inv.getInventoryByName("upgrades");

for(int i=0;i<sub.getSizeInventory();i++){
if(
Optional.ofNullable(sub.getStackInSlot(i))
.map(ItemStack::getItem)
.filter(s->s==MyMod.euupgrade)
.isPresent()
){
return true;
}



}


return false;
}

@Nullable
public static IGuiProvidingPart select(EntityPlayer player ,int x, int y, int z){

NBTTagCompound tag = player.getEntityData();
if(tag.hasKey(key)==false)return null;
int i=tag.getInteger(key);
//tag.removeTag(key);
TileEntity tt= player.getEntityWorld().getTileEntity(x, y, z);
if(tt instanceof IPartHost){
IPartHost ae=(IPartHost) tt;

return (IGuiProvidingPart) Optional.ofNullable(ae.getPart(ForgeDirection.getOrientation(i)))
.filter(s->s instanceof IGuiProvidingPart)
.get();


}
return null;
}public static final String key="proghatches.last.part.direction";

public static void open(EntityPlayer player, World world, int x, int y, int z,ForgeDirection dir) {
if (NetworkUtils.isClient()==false||player instanceof FakePlayer) {return;}
NBTTagCompound tag = player.getEntityData();
tag.setInteger(key,dir.ordinal());



MyMod.net.sendToServer(new OpenPartGuiMessage(x,y,z,dir));
}

public static final UIInfo<?, ?> PART_MODULAR_UI = UIBuilder.of().container((player, world, x, y, z) -> {
return Optional.ofNullable(select(player, x, y, z)).map(part->{

UIBuildContext buildContext = new UIBuildContext(player);
ModularWindow window = part.createWindow(buildContext);
return new ModularUIContainer(
new ModularUIContext(buildContext, () -> {
player.inventoryContainer.detectAndSendChanges();
part.markDirty();
}),
window,
null);



}).orElse(null)
;

}).gui((player, world, x, y, z) -> {
return Optional.ofNullable(select(player, x, y, z)).map(part->{

UIBuildContext buildContext = new UIBuildContext(player);
ModularWindow window = part.createWindow(buildContext);
return new ModularGui(new ModularUIContainer(
new ModularUIContext(buildContext, () -> player.inventoryContainer.detectAndSendChanges()),
window,
null));



}).orElse(null)
;
}).build();
}
Loading

0 comments on commit 1ded322

Please sign in to comment.