feat: add legacy wireless access point

This commit is contained in:
LordMZTE 2022-12-02 17:39:49 +01:00
parent 6eebb86acb
commit ed0cc5f181
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
8 changed files with 254 additions and 187 deletions

View file

@ -1,5 +1,7 @@
package appeng.block.legacy; package appeng.block.legacy;
import java.util.EnumSet;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
import appeng.core.features.AEFeature; import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge; import appeng.core.sync.GuiBridge;
@ -10,26 +12,34 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import java.util.EnumSet;
public class BlockTerminal extends AEBaseTileBlock { public class BlockTerminal extends AEBaseTileBlock {
public BlockTerminal() { public BlockTerminal() {
super(Material.iron); super(Material.iron);
this.setTileEntity(TileTerminal.class); this.setTileEntity(TileTerminal.class);
this.setFeature( EnumSet.of(AEFeature.Legacy) ); this.setFeature(EnumSet.of(AEFeature.Legacy));
} }
@Override @Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { public boolean onActivated(
World w,
int x,
int y,
int z,
EntityPlayer player,
int side,
float hitX,
float hitY,
float hitZ
) {
final TileTerminal tile = this.getTileEntity(w, x, y, z); final TileTerminal tile = this.getTileEntity(w, x, y, z);
if( tile != null && !player.isSneaking() ) { if (tile != null && !player.isSneaking()) {
if( Platform.isClient() ) if (Platform.isClient()) {
{
return true; return true;
} }
Platform.openGUI(player, tile, ForgeDirection.getOrientation(side), GuiBridge.GUI_ME); Platform.openGUI(
player, tile, ForgeDirection.getOrientation(side), GuiBridge.GUI_ME
);
return true; return true;
} }

View file

@ -0,0 +1,47 @@
package appeng.block.legacy;
import java.util.EnumSet;
import appeng.block.AEBaseTileBlock;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
import appeng.tile.networking.TileWireless;
import appeng.util.Platform;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockWirelessAccessPoint extends AEBaseTileBlock {
public BlockWirelessAccessPoint() {
super(Material.iron);
this.isOpaque = true;
this.setTileEntity(TileWireless.class);
this.setFeature(EnumSet.of(AEFeature.Legacy));
}
@Override
public boolean onBlockActivated(
World w,
int x,
int y,
int z,
EntityPlayer p,
int side,
// useless parameters
float alec1,
float alec2,
float alec3
) {
TileEntity tileEntity = w.getTileEntity(x, y, z);
if (tileEntity != null && !p.isSneaking()) {
Platform.openGUI(
p, tileEntity, ForgeDirection.getOrientation(side), GuiBridge.GUI_WIRELESS
);
return true;
} else {
return false;
}
}
}

View file

@ -1,23 +1,8 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.block.networking; package appeng.block.networking;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
import appeng.client.render.blocks.RenderBlockWireless; import appeng.client.render.blocks.RenderBlockWireless;
@ -35,172 +20,183 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import java.util.Collections; public class BlockWireless extends AEBaseTileBlock implements ICustomCollision {
import java.util.EnumSet; public BlockWireless() {
import java.util.List; super(AEGlassMaterial.INSTANCE);
this.setTileEntity(TileWireless.class);
this.setLightOpacity(0);
this.isFullSize = false;
this.isOpaque = false;
this.setFeature(EnumSet.of(AEFeature.Core, AEFeature.WirelessAccessTerminal));
}
@Override
@SideOnly(Side.CLIENT)
protected RenderBlockWireless getRenderer() {
return new RenderBlockWireless();
}
public class BlockWireless extends AEBaseTileBlock implements ICustomCollision @Override
{ public boolean onBlockActivated(
final World w,
final int x,
final int y,
final int z,
final EntityPlayer p,
final int side,
final float hitX,
final float hitY,
final float hitZ
) {
final TileWireless tg = this.getTileEntity(w, x, y, z);
public BlockWireless() if (tg != null && !p.isSneaking()) {
{ if (Platform.isServer()) {
super( AEGlassMaterial.INSTANCE ); Platform.openGUI(
this.setTileEntity( TileWireless.class ); p, tg, ForgeDirection.getOrientation(side), GuiBridge.GUI_WIRELESS
this.setLightOpacity( 0 ); );
this.isFullSize = false; }
this.isOpaque = false; return true;
this.setFeature( EnumSet.of( AEFeature.Core, AEFeature.WirelessAccessTerminal ) ); }
}
@Override return super.onBlockActivated(w, x, y, z, p, side, hitX, hitY, hitZ);
@SideOnly( Side.CLIENT ) }
protected RenderBlockWireless getRenderer()
{
return new RenderBlockWireless();
}
@Override @Override
public boolean onBlockActivated( final World w, final int x, final int y, final int z, final EntityPlayer p, final int side, final float hitX, final float hitY, final float hitZ ) public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(
{ final World w,
final TileWireless tg = this.getTileEntity( w, x, y, z ); final int x,
final int y,
final int z,
final Entity e,
final boolean isVisual
) {
final TileWireless tile = this.getTileEntity(w, x, y, z);
if (tile != null) {
final ForgeDirection forward = tile.getForward();
if( tg != null && !p.isSneaking() ) double minX = 0;
{ double minY = 0;
if( Platform.isServer() ) double minZ = 0;
{ double maxX = 1;
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_WIRELESS ); double maxY = 1;
} double maxZ = 1;
return true;
}
return super.onBlockActivated( w, x, y, z, p, side, hitX, hitY, hitZ ); switch (forward) {
} case DOWN:
minZ = minX = 3.0 / 16.0;
maxZ = maxX = 13.0 / 16.0;
maxY = 1.0;
minY = 5.0 / 16.0;
break;
case EAST:
minZ = minY = 3.0 / 16.0;
maxZ = maxY = 13.0 / 16.0;
maxX = 11.0 / 16.0;
minX = 0.0;
break;
case NORTH:
minY = minX = 3.0 / 16.0;
maxY = maxX = 13.0 / 16.0;
maxZ = 1.0;
minZ = 5.0 / 16.0;
break;
case SOUTH:
minY = minX = 3.0 / 16.0;
maxY = maxX = 13.0 / 16.0;
maxZ = 11.0 / 16.0;
minZ = 0.0;
break;
case UP:
minZ = minX = 3.0 / 16.0;
maxZ = maxX = 13.0 / 16.0;
maxY = 11.0 / 16.0;
minY = 0.0;
break;
case WEST:
minZ = minY = 3.0 / 16.0;
maxZ = maxY = 13.0 / 16.0;
maxX = 1.0;
minX = 5.0 / 16.0;
break;
default:
break;
}
@Override return Collections.singletonList(
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( final World w, final int x, final int y, final int z, final Entity e, final boolean isVisual ) AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ)
{ );
final TileWireless tile = this.getTileEntity( w, x, y, z ); }
if( tile != null ) return Collections.singletonList(
{ AxisAlignedBB.getBoundingBox(0.0, 0, 0.0, 1.0, 1.0, 1.0)
final ForgeDirection forward = tile.getForward(); );
}
double minX = 0; @Override
double minY = 0; public void addCollidingBlockToList(
double minZ = 0; final World w,
double maxX = 1; final int x,
double maxY = 1; final int y,
double maxZ = 1; final int z,
final AxisAlignedBB bb,
final List<AxisAlignedBB> out,
final Entity e
) {
final TileWireless tile = this.getTileEntity(w, x, y, z);
if (tile != null) {
final ForgeDirection forward = tile.getForward();
switch( forward ) double minX = 0;
{ double minY = 0;
case DOWN: double minZ = 0;
minZ = minX = 3.0 / 16.0; double maxX = 1;
maxZ = maxX = 13.0 / 16.0; double maxY = 1;
maxY = 1.0; double maxZ = 1;
minY = 5.0 / 16.0;
break;
case EAST:
minZ = minY = 3.0 / 16.0;
maxZ = maxY = 13.0 / 16.0;
maxX = 11.0 / 16.0;
minX = 0.0;
break;
case NORTH:
minY = minX = 3.0 / 16.0;
maxY = maxX = 13.0 / 16.0;
maxZ = 1.0;
minZ = 5.0 / 16.0;
break;
case SOUTH:
minY = minX = 3.0 / 16.0;
maxY = maxX = 13.0 / 16.0;
maxZ = 11.0 / 16.0;
minZ = 0.0;
break;
case UP:
minZ = minX = 3.0 / 16.0;
maxZ = maxX = 13.0 / 16.0;
maxY = 11.0 / 16.0;
minY = 0.0;
break;
case WEST:
minZ = minY = 3.0 / 16.0;
maxZ = maxY = 13.0 / 16.0;
maxX = 1.0;
minX = 5.0 / 16.0;
break;
default:
break;
}
return Collections.singletonList( AxisAlignedBB.getBoundingBox( minX, minY, minZ, maxX, maxY, maxZ ) ); switch (forward) {
} case DOWN:
return Collections.singletonList( AxisAlignedBB.getBoundingBox( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) ); minZ = minX = 3.0 / 16.0;
} maxZ = maxX = 13.0 / 16.0;
maxY = 1.0;
minY = 5.0 / 16.0;
break;
case EAST:
minZ = minY = 3.0 / 16.0;
maxZ = maxY = 13.0 / 16.0;
maxX = 11.0 / 16.0;
minX = 0.0;
break;
case NORTH:
minY = minX = 3.0 / 16.0;
maxY = maxX = 13.0 / 16.0;
maxZ = 1.0;
minZ = 5.0 / 16.0;
break;
case SOUTH:
minY = minX = 3.0 / 16.0;
maxY = maxX = 13.0 / 16.0;
maxZ = 11.0 / 16.0;
minZ = 0.0;
break;
case UP:
minZ = minX = 3.0 / 16.0;
maxZ = maxX = 13.0 / 16.0;
maxY = 11.0 / 16.0;
minY = 0.0;
break;
case WEST:
minZ = minY = 3.0 / 16.0;
maxZ = maxY = 13.0 / 16.0;
maxX = 1.0;
minX = 5.0 / 16.0;
break;
default:
break;
}
@Override out.add(AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ));
public void addCollidingBlockToList( final World w, final int x, final int y, final int z, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e ) } else {
{ out.add(AxisAlignedBB.getBoundingBox(0.0, 0.0, 0.0, 1.0, 1.0, 1.0));
final TileWireless tile = this.getTileEntity( w, x, y, z ); }
if( tile != null ) }
{
final ForgeDirection forward = tile.getForward();
double minX = 0;
double minY = 0;
double minZ = 0;
double maxX = 1;
double maxY = 1;
double maxZ = 1;
switch( forward )
{
case DOWN:
minZ = minX = 3.0 / 16.0;
maxZ = maxX = 13.0 / 16.0;
maxY = 1.0;
minY = 5.0 / 16.0;
break;
case EAST:
minZ = minY = 3.0 / 16.0;
maxZ = maxY = 13.0 / 16.0;
maxX = 11.0 / 16.0;
minX = 0.0;
break;
case NORTH:
minY = minX = 3.0 / 16.0;
maxY = maxX = 13.0 / 16.0;
maxZ = 1.0;
minZ = 5.0 / 16.0;
break;
case SOUTH:
minY = minX = 3.0 / 16.0;
maxY = maxX = 13.0 / 16.0;
maxZ = 11.0 / 16.0;
minZ = 0.0;
break;
case UP:
minZ = minX = 3.0 / 16.0;
maxZ = maxX = 13.0 / 16.0;
maxY = 11.0 / 16.0;
minY = 0.0;
break;
case WEST:
minZ = minY = 3.0 / 16.0;
maxZ = maxY = 13.0 / 16.0;
maxX = 1.0;
minX = 5.0 / 16.0;
break;
default:
break;
}
out.add( AxisAlignedBB.getBoundingBox( minX, minY, minZ, maxX, maxY, maxZ ) );
}
else
{
out.add( AxisAlignedBB.getBoundingBox( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
}
}
} }

View file

@ -31,6 +31,7 @@ import appeng.block.legacy.BlockCraftMonitor;
import appeng.block.legacy.BlockCraftTerminal; import appeng.block.legacy.BlockCraftTerminal;
import appeng.block.legacy.BlockLegacyController; import appeng.block.legacy.BlockLegacyController;
import appeng.block.legacy.BlockTerminal; import appeng.block.legacy.BlockTerminal;
import appeng.block.legacy.BlockWirelessAccessPoint;
import appeng.block.misc.*; import appeng.block.misc.*;
import appeng.block.networking.*; import appeng.block.networking.*;
import appeng.block.qnb.BlockQuantumLinkChamber; import appeng.block.qnb.BlockQuantumLinkChamber;
@ -133,11 +134,12 @@ public final class ApiBlocks implements IBlocks
private final Set<IOrientableBlock> orientables; private final Set<IOrientableBlock> orientables;
//Legacy // Legacy
private final ITileDefinition terminal; private final ITileDefinition terminal;
private final ITileDefinition craftTerminal; private final ITileDefinition craftTerminal;
private final ITileDefinition craftMonitor; private final ITileDefinition craftMonitor;
private final ITileDefinition legacyController; private final ITileDefinition legacyController;
private final ITileDefinition legacyWirelessAccessPoint;
public ApiBlocks( final DefinitionConstructor constructor ) public ApiBlocks( final DefinitionConstructor constructor )
{ {
@ -228,12 +230,12 @@ public final class ApiBlocks implements IBlocks
this.phantomNode = constructor.registerBlockDefinition( new BlockPhantomNode() ); this.phantomNode = constructor.registerBlockDefinition( new BlockPhantomNode() );
this.cubeGenerator = constructor.registerBlockDefinition( new BlockCubeGenerator() ); this.cubeGenerator = constructor.registerBlockDefinition( new BlockCubeGenerator() );
//Legacy // Legacy
this.terminal = constructor.registerTileDefinition( new BlockTerminal() ); this.terminal = constructor.registerTileDefinition( new BlockTerminal() );
this.craftTerminal = constructor.registerTileDefinition( new BlockCraftTerminal() ); this.craftTerminal = constructor.registerTileDefinition( new BlockCraftTerminal() );
this.craftMonitor = constructor.registerTileDefinition( new BlockCraftMonitor() ); this.craftMonitor = constructor.registerTileDefinition( new BlockCraftMonitor() );
this.legacyController = constructor.registerTileDefinition( new BlockLegacyController() ); this.legacyController = constructor.registerTileDefinition( new BlockLegacyController() );
this.legacyWirelessAccessPoint = constructor.registerTileDefinition(new BlockWirelessAccessPoint());
} }
@Override @Override

View file

@ -29,6 +29,7 @@ import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange; import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.util.AECableType; import appeng.api.util.AECableType;
import appeng.api.util.DimensionalCoord; import appeng.api.util.DimensionalCoord;
import appeng.block.legacy.BlockWirelessAccessPoint;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.me.GridAccessException; import appeng.me.GridAccessException;
import appeng.tile.TileEvent; import appeng.tile.TileEvent;
@ -66,7 +67,11 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
public void setOrientation( final ForgeDirection inForward, final ForgeDirection inUp ) public void setOrientation( final ForgeDirection inForward, final ForgeDirection inUp )
{ {
super.setOrientation( inForward, inUp ); super.setOrientation( inForward, inUp );
if (this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord) instanceof BlockWirelessAccessPoint) {
this.getProxy().setValidSides( EnumSet.allOf(ForgeDirection.class) );
} else {
this.getProxy().setValidSides( EnumSet.of( this.getForward().getOpposite() ) ); this.getProxy().setValidSides( EnumSet.of( this.getForward().getOpposite() ) );
}
} }
@MENetworkEventSubscribe @MENetworkEventSubscribe

View file

@ -51,11 +51,12 @@ tile.appliedenergistics2.BlockCraftingAccelerator.name=Crafting Co-Processing Un
tile.appliedenergistics2.BlockCraftingUnit.name=Crafting Unit tile.appliedenergistics2.BlockCraftingUnit.name=Crafting Unit
tile.appliedenergistics2.BlockMolecularAssembler.name=Molecular Assembler tile.appliedenergistics2.BlockMolecularAssembler.name=Molecular Assembler
#Legacy # Legacy
tile.appliedenergistics2.BlockTerminal.name=ME Access Terminal tile.appliedenergistics2.BlockTerminal.name=ME Access Terminal
tile.appliedenergistics2.BlockCraftTerminal.name=ME Crafting Terminal tile.appliedenergistics2.BlockCraftTerminal.name=ME Crafting Terminal
tile.appliedenergistics2.BlockCraftMonitor.name=ME Crafting Monitor tile.appliedenergistics2.BlockCraftMonitor.name=ME Crafting Monitor
tile.appliedenergistics2.BlockLegacyController.name=ME Controller (W.I.P) tile.appliedenergistics2.BlockLegacyController.name=ME Controller (W.I.P)
tile.appliedenergistics2.BlockWirelessAccessPoint.name=Wireless Access Point
item.appliedenergistics2.ItemMaterial.ConversionMatrix.name=Conversion Matrix item.appliedenergistics2.ItemMaterial.ConversionMatrix.name=Conversion Matrix

View file

@ -33,3 +33,9 @@ shaped=
fluixCrystal ae2:ItemMaterial.EngProcessor fluixCrystal, fluixCrystal ae2:ItemMaterial.EngProcessor fluixCrystal,
oredictionary:ingotIron fluixCrystal oredictionary:ingotIron oredictionary:ingotIron fluixCrystal oredictionary:ingotIron
-> ae2:BlockLegacyController -> ae2:BlockLegacyController
shaped=
oredictionary:ingotIron glass oredictionary:ingotIron,
ae2:CableGlass.Fluix ae2:ItemMaterial.Wireless glass,
oredictionary:ingotIron glass oredictionary:ingotIron,
-> ae2:BlockWirelessAccessPoint

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B