Working on drive design.

Several particle crash fixes.
This commit is contained in:
Sebastian Hartte
2020-06-15 22:20:29 +02:00
parent 2356a38898
commit d50dcc31fa
33 changed files with 748 additions and 760 deletions
@@ -22,6 +22,7 @@ package appeng.block.misc;
import appeng.api.AEApi;
import appeng.api.util.AEAxisAlignedBB;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.effects.ChargedOreFX;
import appeng.client.render.effects.LightningFX;
import appeng.client.render.renderable.ItemRenderable;
import appeng.client.render.tesr.ModularTESR;
@@ -121,9 +122,8 @@ public class BlockCharger extends AEBaseTileBlock<TileCharger>
{
if( AppEng.proxy.shouldAddParticles( r ) )
{
final LightningFX fx = new LightningFX( w, xOff + 0.5 + pos.getX(), yOff + 0.5 + pos.getY(), zOff + 0.5 + pos
.getZ(), 0.0, 0.0, 0.0 );
Minecraft.getInstance().particles.addEffect( fx );
Minecraft.getInstance().particles.addParticle(LightningFX.TYPE, xOff + 0.5 + pos.getX(), yOff + 0.5 + pos.getY(), zOff + 0.5 + pos
.getZ(), 0.0, 0.0, 0.0);
}
}
}
@@ -142,8 +142,7 @@ public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock<TileQuartzGrow
ry += dz * forward.getYOffset();
rz += dz * forward.getZOffset();
final LightningFX fx = new LightningFX( w, rx, ry, rz, 0.0D, 0.0D, 0.0D );
Minecraft.getInstance().particles.addEffect( fx );
Minecraft.getInstance().particles.addParticle(LightningFX.TYPE, rx, ry, rz, 0.0D, 0.0D, 0.0D);
}
}
@@ -0,0 +1,50 @@
/*
* 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.storage;
import net.minecraft.util.IStringSerializable;
/**
* Describes the type of cell present in a slot.
*/
public enum DriveSlotCellType implements IStringSerializable
{
EMPTY("empty"),
ITEM("item"),
FLUID("fluid");
private final String name;
DriveSlotCellType(String name )
{
this.name = name;
}
@Override
public String getName()
{
return this.name;
}
}
@@ -20,6 +20,9 @@ package appeng.block.storage;
import appeng.api.implementations.tiles.IChestOrDrive;
import com.google.common.base.Preconditions;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
/**
@@ -28,25 +31,37 @@ import appeng.api.implementations.tiles.IChestOrDrive;
public class DriveSlotsState
{
private final DriveSlotState[] slots;
private final Item[] cells;
private DriveSlotsState( DriveSlotState[] slots )
{
this.slots = slots;
private final DriveSlotState[] states;
public DriveSlotsState(Item[] cells, DriveSlotState[] states) {
Preconditions.checkArgument(cells.length == states.length);
this.cells = cells;
this.states = states;
}
public DriveSlotState getState( int index )
public DriveSlotState getState(int index )
{
if( index >= this.slots.length )
if( index >= this.states.length )
{
return DriveSlotState.EMPTY;
}
return this.slots[index];
return this.states[index];
}
public Item getCell(int index )
{
if( index >= this.cells.length )
{
return null;
}
return this.cells[index];
}
public int getSlotCount()
{
return this.slots.length;
return this.cells.length;
}
/**
@@ -54,35 +69,39 @@ public class DriveSlotsState
*/
public static DriveSlotsState fromChestOrDrive( IChestOrDrive chestOrDrive )
{
DriveSlotState[] slots = new DriveSlotState[chestOrDrive.getCellCount()];
DriveSlotState[] states = new DriveSlotState[chestOrDrive.getCellCount()];
Item[] cells = new Item[chestOrDrive.getCellCount()];
for( int i = 0; i < chestOrDrive.getCellCount(); i++ )
{
cells[i] = chestOrDrive.getCellItem(i);
if( !chestOrDrive.isPowered() )
{
if( chestOrDrive.getCellStatus( i ) != 0 )
{
slots[i] = DriveSlotState.OFFLINE;
states[i] = DriveSlotState.OFFLINE;
}
else
{
slots[i] = DriveSlotState.EMPTY;
states[i] = DriveSlotState.EMPTY;
}
}
else
{
slots[i] = DriveSlotState.fromCellStatus( chestOrDrive.getCellStatus( i ) );
states[i] = DriveSlotState.fromCellStatus( chestOrDrive.getCellStatus( i ) );
}
}
return new DriveSlotsState( slots );
return new DriveSlotsState( cells, states );
}
public static DriveSlotsState createEmpty( int slotCount )
{
DriveSlotState[] slots = new DriveSlotState[slotCount];
DriveSlotState[] states = new DriveSlotState[slotCount];
Item[] cells = new Item[slotCount];
for( int i = 0; i < slotCount; i++ )
{
slots[i] = DriveSlotState.EMPTY;
states[i] = DriveSlotState.EMPTY;
}
return new DriveSlotsState( slots );
return new DriveSlotsState( cells, states );
}
}