Skip to content

Commit

Permalink
Add option to prevent specified states from reverting to blocks (impl…
Browse files Browse the repository at this point in the history
…ements #374)
  • Loading branch information
AlgorithmX2 committed Feb 28, 2018
1 parent fb05003 commit e6e2b58
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -677,9 +677,12 @@ public void setBlob(
.withProperty( BlockChiseled.UProperty_VoxelBlob, new VoxelBlobStateReference( common.mostCommonState, getPositionRandom( pos ) ) ) );

final IBlockState newState = ModUtil.getStateById( common.mostCommonState );
if ( !MinecraftForge.EVENT_BUS.post( new EventFullBlockRestoration( worldObj, pos, newState ) ) )
if ( ChiselsAndBits.getConfig().canRevertToBlock( newState ) )
{
worldObj.setBlockState( pos, newState, triggerUpdates ? 3 : 0 );
if ( !MinecraftForge.EVENT_BUS.post( new EventFullBlockRestoration( worldObj, pos, newState ) ) )
{
worldObj.setBlockState( pos, newState, triggerUpdates ? 3 : 0 );
}
}
}
else if ( common.mostCommonState != 0 )
Expand Down
26 changes: 24 additions & 2 deletions src/main/java/mod/chiselsandbits/config/ModConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
import java.util.Map.Entry;
import java.util.Set;

import mod.chiselsandbits.chiseledblock.serialization.StringStates;
import mod.chiselsandbits.core.ChiselsAndBits;
import mod.chiselsandbits.helpers.LocalStrings;
import mod.chiselsandbits.helpers.ModUtil;
import mod.chiselsandbits.modes.ChiselMode;
import mod.chiselsandbits.modes.PositivePatternMode;
import mod.chiselsandbits.modes.TapeMeasureModes;
import mod.chiselsandbits.registry.ModRegistry;
import mod.chiselsandbits.render.chiseledblock.tesr.GfxRenderState.UseVBO;
import net.minecraft.block.state.IBlockState;
import net.minecraft.launchwrapper.Launch;
import net.minecraftforge.common.config.ConfigCategory;
import net.minecraftforge.common.config.Configuration;
Expand Down Expand Up @@ -296,10 +299,10 @@ public class ModConfig extends Configuration

@Configured( category = "Balance Settings" )
public boolean fullBlockCrafting;

@Configured( category = "Balance Settings" )
public boolean requireBagSpace;

@Configured( category = "Balance Settings" )
public boolean voidExcessBits;

Expand All @@ -326,6 +329,20 @@ public boolean isEnabled(
return out;
}

public boolean canRevertToBlock(
IBlockState newState )
{
final Property p = get( "Revertible States", StringStates.getNameFromStateID( ModUtil.getStateId( newState ) ), true );
final boolean out = p.getBoolean( true );

if ( hasChanged() )
{
save();
}

return out;
}

private void setDefaults()
{
final long mem = Runtime.getRuntime().maxMemory() / ( 1024 * 1024 ); // mb
Expand Down Expand Up @@ -551,6 +568,11 @@ else if ( Enum.class.isAssignableFrom( f.getType() ) )
continue;
}

if ( s.equals( "revertible states" ) )
{
continue;
}

final ConfigCategory cc = getCategory( s );
final List<String> removeThis = new ArrayList<String>();

Expand Down

0 comments on commit e6e2b58

Please sign in to comment.