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;
import java.util.EnumSet;
import appeng.block.AEBaseTileBlock;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
@ -10,10 +12,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.EnumSet;
public class BlockTerminal extends AEBaseTileBlock {
public BlockTerminal() {
super(Material.iron);
this.setTileEntity(TileTerminal.class);
@ -21,15 +20,26 @@ public class BlockTerminal extends AEBaseTileBlock {
}
@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);
if (tile != null && !player.isSneaking()) {
if( Platform.isClient() )
{
if (Platform.isClient()) {
return true;
}
Platform.openGUI(player, tile, ForgeDirection.getOrientation(side), GuiBridge.GUI_ME);
Platform.openGUI(
player, tile, ForgeDirection.getOrientation(side), GuiBridge.GUI_ME
);
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;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.blocks.RenderBlockWireless;
@ -35,16 +20,8 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
{
public BlockWireless()
{
public class BlockWireless extends AEBaseTileBlock implements ICustomCollision {
public BlockWireless() {
super(AEGlassMaterial.INSTANCE);
this.setTileEntity(TileWireless.class);
this.setLightOpacity(0);
@ -55,21 +32,29 @@ public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
@Override
@SideOnly(Side.CLIENT)
protected RenderBlockWireless getRenderer()
{
protected RenderBlockWireless getRenderer() {
return new RenderBlockWireless();
}
@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 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);
if( tg != null && !p.isSneaking() )
{
if( Platform.isServer() )
{
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_WIRELESS );
if (tg != null && !p.isSneaking()) {
if (Platform.isServer()) {
Platform.openGUI(
p, tg, ForgeDirection.getOrientation(side), GuiBridge.GUI_WIRELESS
);
}
return true;
}
@ -78,11 +63,16 @@ public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( final World w, final int x, final int y, final int z, final Entity e, final boolean isVisual )
{
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(
final World w,
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 )
{
if (tile != null) {
final ForgeDirection forward = tile.getForward();
double minX = 0;
@ -92,8 +82,7 @@ public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
double maxY = 1;
double maxZ = 1;
switch( forward )
{
switch (forward) {
case DOWN:
minZ = minX = 3.0 / 16.0;
maxZ = maxX = 13.0 / 16.0;
@ -134,17 +123,27 @@ public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
break;
}
return Collections.singletonList( AxisAlignedBB.getBoundingBox( minX, minY, minZ, maxX, maxY, maxZ ) );
return Collections.singletonList(
AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ)
);
}
return Collections.singletonList( AxisAlignedBB.getBoundingBox( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) );
return Collections.singletonList(
AxisAlignedBB.getBoundingBox(0.0, 0, 0.0, 1.0, 1.0, 1.0)
);
}
@Override
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 )
{
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
) {
final TileWireless tile = this.getTileEntity(w, x, y, z);
if( tile != null )
{
if (tile != null) {
final ForgeDirection forward = tile.getForward();
double minX = 0;
@ -154,8 +153,7 @@ public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
double maxY = 1;
double maxZ = 1;
switch( forward )
{
switch (forward) {
case DOWN:
minZ = minX = 3.0 / 16.0;
maxZ = maxX = 13.0 / 16.0;
@ -197,9 +195,7 @@ public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
}
out.add(AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ));
}
else
{
} 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.BlockLegacyController;
import appeng.block.legacy.BlockTerminal;
import appeng.block.legacy.BlockWirelessAccessPoint;
import appeng.block.misc.*;
import appeng.block.networking.*;
import appeng.block.qnb.BlockQuantumLinkChamber;
@ -138,6 +139,7 @@ public final class ApiBlocks implements IBlocks
private final ITileDefinition craftTerminal;
private final ITileDefinition craftMonitor;
private final ITileDefinition legacyController;
private final ITileDefinition legacyWirelessAccessPoint;
public ApiBlocks( final DefinitionConstructor constructor )
{
@ -233,7 +235,7 @@ public final class ApiBlocks implements IBlocks
this.craftTerminal = constructor.registerTileDefinition( new BlockCraftTerminal() );
this.craftMonitor = constructor.registerTileDefinition( new BlockCraftMonitor() );
this.legacyController = constructor.registerTileDefinition( new BlockLegacyController() );
this.legacyWirelessAccessPoint = constructor.registerTileDefinition(new BlockWirelessAccessPoint());
}
@Override

View file

@ -29,6 +29,7 @@ import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.util.AECableType;
import appeng.api.util.DimensionalCoord;
import appeng.block.legacy.BlockWirelessAccessPoint;
import appeng.core.AEConfig;
import appeng.me.GridAccessException;
import appeng.tile.TileEvent;
@ -66,8 +67,12 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
public void setOrientation( final ForgeDirection inForward, final ForgeDirection 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() ) );
}
}
@MENetworkEventSubscribe
public void chanRender( final MENetworkChannelsChanged c )

View file

@ -56,6 +56,7 @@ tile.appliedenergistics2.BlockTerminal.name=ME Access Terminal
tile.appliedenergistics2.BlockCraftTerminal.name=ME Crafting Terminal
tile.appliedenergistics2.BlockCraftMonitor.name=ME Crafting Monitor
tile.appliedenergistics2.BlockLegacyController.name=ME Controller (W.I.P)
tile.appliedenergistics2.BlockWirelessAccessPoint.name=Wireless Access Point
item.appliedenergistics2.ItemMaterial.ConversionMatrix.name=Conversion Matrix

View file

@ -33,3 +33,9 @@ shaped=
fluixCrystal ae2:ItemMaterial.EngProcessor fluixCrystal,
oredictionary:ingotIron fluixCrystal oredictionary:ingotIron
-> 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