Skip to content

Commit

Permalink
Fix block dropping on invalidate
Browse files Browse the repository at this point in the history
  • Loading branch information
Cassiobsk8 committed Apr 13, 2020
1 parent 53fdae7 commit 92ff2a5
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 38 deletions.
14 changes: 0 additions & 14 deletions .vscode/launch.json

This file was deleted.

8 changes: 0 additions & 8 deletions .vscode/settings.json

This file was deleted.

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Industrial Renewal
<p align="center">
<a href="https://www.curseforge.com/minecraft/mc-mods/industrial-renewal">
<img src="https://cf.way2muchnoise.eu/full_industrial-renewal_downloads.svg">
</a>
<a href="">
<img src="http://cf.way2muchnoise.eu/versions/For%20MC_industrial-renewal_all.svg">
</a>
</p>

![alt text](images/Logo.png)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package cassiokf.industrialrenewal.blocks.abstracts;

import cassiokf.industrialrenewal.tileentity.abstracts.TEBase;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
Expand Down Expand Up @@ -36,6 +38,14 @@ protected BlockStateContainer createBlockState()
return new ExtendedBlockState(this, listedProperties, unlistedProperties);
}

@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
TileEntity te = worldIn.getTileEntity(pos);
if (te instanceof TEBase) ((TEBase) te).onBlockBreak();
super.breakBlock(worldIn, pos, state);
}

@Override
public boolean hasTileEntity(IBlockState state)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ private void initializeNetworkIfNecessary()
Stack<TileEntityHVConnectorBase> traversingCables = new Stack<TileEntityHVConnectorBase>();
IConnectorHV inTransformerT = null;
IConnectorHV outTransformerT = null;
TileEntityHVConnectorBase master = (TileEntityHVConnectorBase) this;
traversingCables.add((TileEntityHVConnectorBase) this);
TileEntityHVConnectorBase master = this;
traversingCables.add(this);
while (!traversingCables.isEmpty())
{
TileEntityHVConnectorBase storage = traversingCables.pop();
Expand Down Expand Up @@ -221,9 +221,8 @@ public boolean isRightConnected()
}

@Override
public void invalidate()
public void onBlockBreak()
{
super.invalidate();
if (isLeftConnected())
{
removeCableAndSpawn(leftConnectionPos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ private int getMultiplier()
}

@Override
public void invalidate()
public void onBlockBreak()
{
if (panelInv) Utils.spawnItemStack(world, pos, new ItemStack(ModBlocks.spanel));
super.invalidate();
super.onBlockBreak();
}

public boolean hasPanel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@

public abstract class TEBase extends TileEntity
{
public void onBlockBreak()
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ public void refreshConnections()
}

@Override
public void invalidate()
public void onBlockBreak()
{
spawnBlocks(null);
super.invalidate();
super.onBlockBreak();
refreshConnections();
}

Expand Down
8 changes: 0 additions & 8 deletions vscode.code-workspace

This file was deleted.

0 comments on commit 92ff2a5

Please sign in to comment.