-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix mod PatternDetails hashCode & equals, allow CircuitProvider provi…
…de empty circuit
- Loading branch information
Showing
36 changed files
with
2,755 additions
and
113 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
183 changes: 183 additions & 0 deletions
183
src/main/java/reobf/proghatches/eucrafting/BlockEUInterface.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,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); | ||
} | ||
|
||
|
||
} |
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,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(); | ||
} |
Oops, something went wrong.