Compare commits
2 Commits
metrics
...
v8.0.0-beta.3
| Author | SHA1 | Date | |
|---|---|---|---|
| d07937fa93 | |||
| 65f58913a4 |
@@ -28,4 +28,9 @@ public enum GridNotification {
|
|||||||
* the visible connections for this node have changed, useful for cable.
|
* the visible connections for this node have changed, useful for cable.
|
||||||
*/
|
*/
|
||||||
CONNECTIONS_CHANGED,
|
CONNECTIONS_CHANGED,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the owner of the grid node has changed, and the node needs to be re-saved
|
||||||
|
*/
|
||||||
|
OWNER_CHANGED
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,8 @@ public interface IGridBlock {
|
|||||||
AEColor getGridColor();
|
AEColor getGridColor();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifies your IGridBlock that changes were made to your connections
|
* Called by the {@link IGridNode} to notify its {@link IGridBlock} about
|
||||||
|
* events.
|
||||||
*/
|
*/
|
||||||
void onGridNotification(@Nonnull GridNotification notification);
|
void onGridNotification(@Nonnull GridNotification notification);
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ import net.minecraft.item.BlockItemUseContext;
|
|||||||
import net.minecraft.item.DyeColor;
|
import net.minecraft.item.DyeColor;
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.state.IntegerProperty;
|
||||||
|
import net.minecraft.state.StateContainer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
@@ -82,8 +84,12 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
|
|||||||
|
|
||||||
private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer();
|
private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer();
|
||||||
|
|
||||||
|
private static final IntegerProperty LIGHT_LEVEL = IntegerProperty.create("light_level", 0, 15);
|
||||||
|
|
||||||
public CableBusBlock() {
|
public CableBusBlock() {
|
||||||
super(defaultProps(AEMaterials.GLASS).notSolid().noDrops().variableOpacity());
|
super(defaultProps(AEMaterials.GLASS).notSolid().noDrops().variableOpacity()
|
||||||
|
.setLightLevel(state -> state.get(LIGHT_LEVEL)));
|
||||||
|
setDefaultState(getDefaultState().with(LIGHT_LEVEL, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -126,11 +132,9 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLightValue(final BlockState state, final IBlockReader world, final BlockPos pos) {
|
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||||
if (state.getBlock() != this) {
|
super.fillStateContainer(builder);
|
||||||
return state.getBlock().getLightValue(state, world, pos);
|
builder.add(LIGHT_LEVEL);
|
||||||
}
|
|
||||||
return this.cb(world, pos).getLightValue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -386,4 +390,13 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, CableBusTileEntity te) {
|
||||||
|
if (currentState.getBlock() != this) {
|
||||||
|
return currentState;
|
||||||
|
}
|
||||||
|
int lightLevel = te.getCableBus().getLightValue();
|
||||||
|
return super.updateBlockStateFromTileEntity(currentState, te).with(LIGHT_LEVEL, lightLevel);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -327,8 +327,9 @@ public class GridNode implements IGridNode, IPathItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerID(final int playerID) {
|
public void setPlayerID(final int playerID) {
|
||||||
if (playerID >= 0) {
|
if (playerID >= 0 && this.playerID != playerID) {
|
||||||
this.playerID = playerID;
|
this.playerID = playerID;
|
||||||
|
gridProxy.onGridNotification(GridNotification.OWNER_CHANGED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+14
-2
@@ -81,8 +81,16 @@ public class SecurityCache implements ISecurityGrid {
|
|||||||
private void updateSecurityKey() {
|
private void updateSecurityKey() {
|
||||||
final long lastCode = this.securityKey;
|
final long lastCode = this.securityKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Placing a security station will propagate the security station's owner to all
|
||||||
|
* connected grid nodes to prevent the network from not reforming due to
|
||||||
|
* different owners later.
|
||||||
|
*/
|
||||||
|
int newOwner = -1;
|
||||||
if (this.securityProvider.size() == 1) {
|
if (this.securityProvider.size() == 1) {
|
||||||
this.securityKey = this.securityProvider.get(0).getSecurityKey();
|
ISecurityProvider securityProvider = this.securityProvider.get(0);
|
||||||
|
this.securityKey = securityProvider.getSecurityKey();
|
||||||
|
newOwner = securityProvider.getOwner();
|
||||||
} else {
|
} else {
|
||||||
this.securityKey = -1;
|
this.securityKey = -1;
|
||||||
}
|
}
|
||||||
@@ -90,7 +98,11 @@ public class SecurityCache implements ISecurityGrid {
|
|||||||
if (lastCode != this.securityKey) {
|
if (lastCode != this.securityKey) {
|
||||||
this.getGrid().postEvent(new MENetworkSecurityChange());
|
this.getGrid().postEvent(new MENetworkSecurityChange());
|
||||||
for (final IGridNode n : this.getGrid().getNodes()) {
|
for (final IGridNode n : this.getGrid().getNodes()) {
|
||||||
((GridNode) n).setLastSecurityKey(this.securityKey);
|
GridNode gridNode = (GridNode) n;
|
||||||
|
gridNode.setLastSecurityKey(this.securityKey);
|
||||||
|
if (gridNode.getPlayerID() != newOwner) {
|
||||||
|
gridNode.setPlayerID(newOwner);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,7 +167,6 @@ public class AENetworkProxy implements IGridBlock {
|
|||||||
* short cut!
|
* short cut!
|
||||||
*
|
*
|
||||||
* @return grid of node
|
* @return grid of node
|
||||||
*
|
|
||||||
* @throws GridAccessException of node or grid is null
|
* @throws GridAccessException of node or grid is null
|
||||||
*/
|
*/
|
||||||
public IGrid getGrid() throws GridAccessException {
|
public IGrid getGrid() throws GridAccessException {
|
||||||
@@ -280,6 +279,11 @@ public class AENetworkProxy implements IGridBlock {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGridNotification(final GridNotification notification) {
|
public void onGridNotification(final GridNotification notification) {
|
||||||
|
if (notification == GridNotification.OWNER_CHANGED) {
|
||||||
|
gp.saveChanges();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.gp instanceof CablePart) {
|
if (this.gp instanceof CablePart) {
|
||||||
((CablePart) this.gp).markForUpdate();
|
((CablePart) this.gp).markForUpdate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,4 +28,7 @@ public interface IGridProxyable extends IGridHost {
|
|||||||
DimensionalCoord getLocation();
|
DimensionalCoord getLocation();
|
||||||
|
|
||||||
void gridChanged();
|
void gridChanged();
|
||||||
|
|
||||||
|
void saveChanges();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,10 +39,13 @@ import net.minecraft.network.play.server.SUpdateTileEntityPacket;
|
|||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.tileentity.TileEntityType;
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.client.model.data.IModelData;
|
import net.minecraftforge.client.model.data.IModelData;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
@@ -458,4 +461,15 @@ public class AEBaseTileEntity extends TileEntity implements IOrientable, ICommon
|
|||||||
return new AEModelData(up, forward);
|
return new AEModelData(up, forward);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AE Tile Entities will generally confine themselves to rendering within the
|
||||||
|
* bounding block. Forge however would retrieve the collision box here, which is
|
||||||
|
* very expensive.
|
||||||
|
*/
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
@Override
|
||||||
|
public AxisAlignedBB getRenderBoundingBox() {
|
||||||
|
return new AxisAlignedBB(pos, pos.add(1, 1, 1));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user