reformatted all src files (#141)

This commit is contained in:
YoungOnion
2022-09-17 05:08:02 -06:00
committed by GitHub
parent 3328bfcda2
commit 9011273229
1056 changed files with 88127 additions and 110597 deletions
+131 -167
View File
@@ -19,15 +19,6 @@
package appeng.facade;
import java.io.IOException;
import java.util.Optional;
import io.netty.buffer.ByteBuf;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import appeng.api.AEApi;
import appeng.api.parts.IFacadeContainer;
import appeng.api.parts.IFacadePart;
@@ -35,185 +26,158 @@ import appeng.api.parts.IPartHost;
import appeng.api.util.AEPartLocation;
import appeng.items.parts.ItemFacade;
import appeng.parts.CableBusStorage;
import io.netty.buffer.ByteBuf;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import java.io.IOException;
import java.util.Optional;
public class FacadeContainer implements IFacadeContainer
{
public class FacadeContainer implements IFacadeContainer {
private final int facades = 6;
private final CableBusStorage storage;
private final int facades = 6;
private final CableBusStorage storage;
public FacadeContainer( final CableBusStorage cbs )
{
this.storage = cbs;
}
public FacadeContainer(final CableBusStorage cbs) {
this.storage = cbs;
}
@Override
public boolean addFacade( final IFacadePart a )
{
if( this.getFacade( a.getSide() ) == null )
{
this.storage.setFacade( a.getSide().ordinal(), a );
return true;
}
return false;
}
@Override
public boolean addFacade(final IFacadePart a) {
if (this.getFacade(a.getSide()) == null) {
this.storage.setFacade(a.getSide().ordinal(), a);
return true;
}
return false;
}
@Override
public void removeFacade( final IPartHost host, final AEPartLocation side )
{
if( side != null && side != AEPartLocation.INTERNAL )
{
if( this.storage.getFacade( side.ordinal() ) != null )
{
this.storage.setFacade( side.ordinal(), null );
if( host != null )
{
host.markForUpdate();
}
}
}
}
@Override
public void removeFacade(final IPartHost host, final AEPartLocation side) {
if (side != null && side != AEPartLocation.INTERNAL) {
if (this.storage.getFacade(side.ordinal()) != null) {
this.storage.setFacade(side.ordinal(), null);
if (host != null) {
host.markForUpdate();
}
}
}
}
@Override
public IFacadePart getFacade( final AEPartLocation s )
{
return this.storage.getFacade( s.ordinal() );
}
@Override
public IFacadePart getFacade(final AEPartLocation s) {
return this.storage.getFacade(s.ordinal());
}
@Override
public void rotateLeft()
{
final IFacadePart[] newFacades = new FacadePart[6];
@Override
public void rotateLeft() {
final IFacadePart[] newFacades = new FacadePart[6];
newFacades[AEPartLocation.UP.ordinal()] = this.storage.getFacade( AEPartLocation.UP.ordinal() );
newFacades[AEPartLocation.DOWN.ordinal()] = this.storage.getFacade( AEPartLocation.DOWN.ordinal() );
newFacades[AEPartLocation.UP.ordinal()] = this.storage.getFacade(AEPartLocation.UP.ordinal());
newFacades[AEPartLocation.DOWN.ordinal()] = this.storage.getFacade(AEPartLocation.DOWN.ordinal());
newFacades[AEPartLocation.EAST.ordinal()] = this.storage.getFacade( AEPartLocation.NORTH.ordinal() );
newFacades[AEPartLocation.SOUTH.ordinal()] = this.storage.getFacade( AEPartLocation.EAST.ordinal() );
newFacades[AEPartLocation.EAST.ordinal()] = this.storage.getFacade(AEPartLocation.NORTH.ordinal());
newFacades[AEPartLocation.SOUTH.ordinal()] = this.storage.getFacade(AEPartLocation.EAST.ordinal());
newFacades[AEPartLocation.WEST.ordinal()] = this.storage.getFacade( AEPartLocation.SOUTH.ordinal() );
newFacades[AEPartLocation.NORTH.ordinal()] = this.storage.getFacade( AEPartLocation.WEST.ordinal() );
newFacades[AEPartLocation.WEST.ordinal()] = this.storage.getFacade(AEPartLocation.SOUTH.ordinal());
newFacades[AEPartLocation.NORTH.ordinal()] = this.storage.getFacade(AEPartLocation.WEST.ordinal());
for( int x = 0; x < this.facades; x++ )
{
this.storage.setFacade( x, newFacades[x] );
}
}
for (int x = 0; x < this.facades; x++) {
this.storage.setFacade(x, newFacades[x]);
}
}
@Override
public void writeToNBT( final NBTTagCompound c )
{
for( int x = 0; x < this.facades; x++ )
{
if( this.storage.getFacade( x ) != null )
{
final NBTTagCompound data = new NBTTagCompound();
this.storage.getFacade( x ).getItemStack().writeToNBT( data );
c.setTag( "facade:" + x, data );
}
}
}
@Override
public void writeToNBT(final NBTTagCompound c) {
for (int x = 0; x < this.facades; x++) {
if (this.storage.getFacade(x) != null) {
final NBTTagCompound data = new NBTTagCompound();
this.storage.getFacade(x).getItemStack().writeToNBT(data);
c.setTag("facade:" + x, data);
}
}
}
@Override
public boolean readFromStream( final ByteBuf out ) throws IOException
{
final int facadeSides = out.readByte();
@Override
public boolean readFromStream(final ByteBuf out) throws IOException {
final int facadeSides = out.readByte();
boolean changed = false;
boolean changed = false;
final int[] ids = new int[2];
for( int x = 0; x < this.facades; x++ )
{
final AEPartLocation side = AEPartLocation.fromOrdinal( x );
final int ix = ( 1 << x );
if( ( facadeSides & ix ) == ix )
{
ids[0] = out.readInt();
ids[1] = out.readInt();
ids[0] = Math.abs( ids[0] );
final int[] ids = new int[2];
for (int x = 0; x < this.facades; x++) {
final AEPartLocation side = AEPartLocation.fromOrdinal(x);
final int ix = (1 << x);
if ((facadeSides & ix) == ix) {
ids[0] = out.readInt();
ids[1] = out.readInt();
ids[0] = Math.abs(ids[0]);
Optional<Item> maybeFacadeItem = AEApi.instance().definitions().items().facade().maybeItem();
if( maybeFacadeItem.isPresent() )
{
final ItemFacade ifa = (ItemFacade) maybeFacadeItem.get();
final ItemStack facade = ifa.createFromIDs( ids );
if( facade != null )
{
changed = changed || this.storage.getFacade( x ) == null;
this.storage.setFacade( x, ifa.createPartFromItemStack( facade, side ) );
}
}
}
else
{
changed = changed || this.storage.getFacade( x ) != null;
this.storage.setFacade( x, null );
}
}
Optional<Item> maybeFacadeItem = AEApi.instance().definitions().items().facade().maybeItem();
if (maybeFacadeItem.isPresent()) {
final ItemFacade ifa = (ItemFacade) maybeFacadeItem.get();
final ItemStack facade = ifa.createFromIDs(ids);
if (facade != null) {
changed = changed || this.storage.getFacade(x) == null;
this.storage.setFacade(x, ifa.createPartFromItemStack(facade, side));
}
}
} else {
changed = changed || this.storage.getFacade(x) != null;
this.storage.setFacade(x, null);
}
}
return changed;
}
return changed;
}
@Override
public void readFromNBT( final NBTTagCompound c )
{
for( int x = 0; x < this.facades; x++ )
{
this.storage.setFacade( x, null );
@Override
public void readFromNBT(final NBTTagCompound c) {
for (int x = 0; x < this.facades; x++) {
this.storage.setFacade(x, null);
final NBTTagCompound t = c.getCompoundTag( "facade:" + x );
if( t != null )
{
final ItemStack is = new ItemStack( t );
if( !is.isEmpty() )
{
final Item i = is.getItem();
if( i instanceof IFacadeItem )
{
this.storage.setFacade( x, ( (IFacadeItem) i ).createPartFromItemStack( is, AEPartLocation.fromOrdinal( x ) ) );
}
}
}
}
}
final NBTTagCompound t = c.getCompoundTag("facade:" + x);
if (t != null) {
final ItemStack is = new ItemStack(t);
if (!is.isEmpty()) {
final Item i = is.getItem();
if (i instanceof IFacadeItem) {
this.storage.setFacade(x, ((IFacadeItem) i).createPartFromItemStack(is, AEPartLocation.fromOrdinal(x)));
}
}
}
}
}
@Override
public void writeToStream( final ByteBuf out ) throws IOException
{
int facadeSides = 0;
for( int x = 0; x < this.facades; x++ )
{
if( this.getFacade( AEPartLocation.fromOrdinal( x ) ) != null )
{
facadeSides |= ( 1 << x );
}
}
out.writeByte( (byte) facadeSides );
@Override
public void writeToStream(final ByteBuf out) throws IOException {
int facadeSides = 0;
for (int x = 0; x < this.facades; x++) {
if (this.getFacade(AEPartLocation.fromOrdinal(x)) != null) {
facadeSides |= (1 << x);
}
}
out.writeByte((byte) facadeSides);
for( int x = 0; x < this.facades; x++ )
{
final IFacadePart part = this.getFacade( AEPartLocation.fromOrdinal( x ) );
if( part != null )
{
final int itemID = Item.getIdFromItem( part.getItem() );
final int dmgValue = part.getItemDamage();
out.writeInt( itemID * ( part.notAEFacade() ? -1 : 1 ) );
out.writeInt( dmgValue );
}
}
}
for (int x = 0; x < this.facades; x++) {
final IFacadePart part = this.getFacade(AEPartLocation.fromOrdinal(x));
if (part != null) {
final int itemID = Item.getIdFromItem(part.getItem());
final int dmgValue = part.getItemDamage();
out.writeInt(itemID * (part.notAEFacade() ? -1 : 1));
out.writeInt(dmgValue);
}
}
}
@Override
public boolean isEmpty()
{
for( int x = 0; x < this.facades; x++ )
{
if( this.storage.getFacade( x ) != null )
{
return false;
}
}
return true;
}
@Override
public boolean isEmpty() {
for (int x = 0; x < this.facades; x++) {
if (this.storage.getFacade(x) != null) {
return false;
}
}
return true;
}
}
+88 -111
View File
@@ -19,6 +19,11 @@
package appeng.facade;
import appeng.api.AEApi;
import appeng.api.parts.IBoxProvider;
import appeng.api.parts.IFacadePart;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.util.AEPartLocation;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
@@ -27,136 +32,108 @@ import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.parts.IBoxProvider;
import appeng.api.parts.IFacadePart;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.util.AEPartLocation;
public class FacadePart implements IFacadePart, IBoxProvider {
public class FacadePart implements IFacadePart, IBoxProvider
{
private final ItemStack facade;
private final AEPartLocation side;
private final ItemStack facade;
private final AEPartLocation side;
public FacadePart(final ItemStack facade, final AEPartLocation side) {
if (facade == null) {
throw new IllegalArgumentException("Facade Part constructed on null item.");
}
this.facade = facade.copy();
this.facade.setCount(1);
this.side = side;
}
public FacadePart( final ItemStack facade, final AEPartLocation side )
{
if( facade == null )
{
throw new IllegalArgumentException( "Facade Part constructed on null item." );
}
this.facade = facade.copy();
this.facade.setCount( 1 );
this.side = side;
}
public static boolean isFacade(final ItemStack is) {
return is.getItem() instanceof IFacadeItem;
}
public static boolean isFacade( final ItemStack is )
{
return is.getItem() instanceof IFacadeItem;
}
@Override
public ItemStack getItemStack() {
return this.facade;
}
@Override
public ItemStack getItemStack()
{
return this.facade;
}
@Override
public void getBoxes(final IPartCollisionHelper ch, final Entity e) {
if (e instanceof EntityLivingBase) {
// prevent weird snag behavior
ch.addBox(0.0, 0.0, 14, 16.0, 16.0, 16.0);
} else {
// the box is 15.9 for transition planes to pick up collision events.
ch.addBox(0.0, 0.0, 14, 16.0, 16.0, 15.9);
}
}
@Override
public void getBoxes( final IPartCollisionHelper ch, final Entity e )
{
if( e instanceof EntityLivingBase )
{
// prevent weird snag behavior
ch.addBox( 0.0, 0.0, 14, 16.0, 16.0, 16.0 );
}
else
{
// the box is 15.9 for transition planes to pick up collision events.
ch.addBox( 0.0, 0.0, 14, 16.0, 16.0, 15.9 );
}
}
@Override
public AEPartLocation getSide() {
return this.side;
}
@Override
public AEPartLocation getSide()
{
return this.side;
}
@Override
public Item getItem() {
final ItemStack is = this.getTextureItem();
if (is.isEmpty()) {
return Items.AIR;
}
return is.getItem();
}
@Override
public Item getItem()
{
final ItemStack is = this.getTextureItem();
if( is.isEmpty() )
{
return Items.AIR;
}
return is.getItem();
}
@Override
public int getItemDamage() {
final ItemStack is = this.getTextureItem();
if (is.isEmpty()) {
return 0;
}
return is.getItemDamage();
}
@Override
public int getItemDamage()
{
final ItemStack is = this.getTextureItem();
if( is.isEmpty() )
{
return 0;
}
return is.getItemDamage();
}
@Override
public boolean notAEFacade() {
return !(this.facade.getItem() instanceof IFacadeItem);
}
@Override
public boolean notAEFacade()
{
return !( this.facade.getItem() instanceof IFacadeItem );
}
@Override
public boolean isTransparent() {
if (AEApi.instance().partHelper().getCableRenderMode().transparentFacades) {
return true;
}
@Override
public boolean isTransparent()
{
if( AEApi.instance().partHelper().getCableRenderMode().transparentFacades )
{
return true;
}
return this.getBlockState().isOpaqueCube();
}
return this.getBlockState().isOpaqueCube();
}
@Override
public ItemStack getTextureItem() {
final Item maybeFacade = this.facade.getItem();
@Override
public ItemStack getTextureItem()
{
final Item maybeFacade = this.facade.getItem();
// AE Facade
if (maybeFacade instanceof IFacadeItem) {
final IFacadeItem facade = (IFacadeItem) maybeFacade;
// AE Facade
if( maybeFacade instanceof IFacadeItem )
{
final IFacadeItem facade = (IFacadeItem) maybeFacade;
return facade.getTextureItem(this.facade);
}
return facade.getTextureItem( this.facade );
}
return ItemStack.EMPTY;
}
return ItemStack.EMPTY;
}
@Override
public IBlockState getBlockState() {
final Item maybeFacade = this.facade.getItem();
@Override
public IBlockState getBlockState()
{
final Item maybeFacade = this.facade.getItem();
// AE Facade
if (maybeFacade instanceof IFacadeItem) {
final IFacadeItem facade = (IFacadeItem) maybeFacade;
// AE Facade
if( maybeFacade instanceof IFacadeItem )
{
final IFacadeItem facade = (IFacadeItem) maybeFacade;
return facade.getTextureBlockState(this.facade);
}
return facade.getTextureBlockState( this.facade );
}
return Blocks.GLASS.getDefaultState();
}
return Blocks.GLASS.getDefaultState();
}
@Override
public void getBoxes( final IPartCollisionHelper bch )
{
this.getBoxes( bch, null );
}
@Override
public void getBoxes(final IPartCollisionHelper bch) {
this.getBoxes(bch, null);
}
}
+5 -7
View File
@@ -19,19 +19,17 @@
package appeng.facade;
import appeng.api.util.AEPartLocation;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import appeng.api.util.AEPartLocation;
public interface IFacadeItem {
public interface IFacadeItem
{
FacadePart createPartFromItemStack(ItemStack is, AEPartLocation side);
FacadePart createPartFromItemStack( ItemStack is, AEPartLocation side );
ItemStack getTextureItem(ItemStack is);
ItemStack getTextureItem( ItemStack is );
IBlockState getTextureBlockState( ItemStack is );
IBlockState getTextureBlockState(ItemStack is);
}