Move all SysOut references to debug logging

This commit is contained in:
Nicholas Ignoffo 2018-03-01 18:23:56 -08:00
parent b1be099d67
commit 0dd0854bd9
11 changed files with 21 additions and 151 deletions

View file

@ -1,97 +0,0 @@
package WayofTime.bloodmagic.block.base;
import WayofTime.bloodmagic.block.property.PropertyString;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.ArrayUtils;
/**
* Creates a block that has multiple meta-based states.
* <p>
* These states will be named after the given string array. Somewhere along the
* way, each value is {@code toLowerCase()}'ed, so the blockstate JSON needs all
* values to be lowercase.
*/
public class BlockString extends Block {
private final int maxMeta;
private final String[] types;
private final PropertyString property;
private final BlockStateContainer realStateContainer;
public BlockString(Material material, String[] values, String propName) {
super(material);
this.maxMeta = values.length;
this.types = values;
this.property = PropertyString.create(propName, values);
this.realStateContainer = createStateContainer();
setDefaultState(getBlockState().getBaseState());
}
public BlockString(Material material, String[] values) {
this(material, values, "type");
}
@Override
protected final BlockStateContainer createBlockState() {
return new BlockStateContainer.Builder(this).build(); // Blank to avoid crashes
}
@Override
public final BlockStateContainer getBlockState() {
return realStateContainer;
}
@Override
public IBlockState getStateFromMeta(int meta) {
return getDefaultState().withProperty(property, types[meta]);
}
@Override
public int getMetaFromState(IBlockState state) {
return ArrayUtils.indexOf(types, state.getValue(property));
}
@Override
public int damageDropped(IBlockState state) {
return getMetaFromState(state);
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> subBlocks) {
for (int i = 0; i < maxMeta; i++)
subBlocks.add(new ItemStack(this, 1, i));
}
protected BlockStateContainer createStateContainer() {
System.out.println("");
BlockStateContainer ctn = new BlockStateContainer.Builder(this).add(property).build();
System.out.println("Number of states: " + ctn.getValidStates().size());
return ctn;
}
public int getMaxMeta() {
return maxMeta;
}
public String[] getTypes() {
return types;
}
public PropertyString getProperty() {
return property;
}
public BlockStateContainer getRealStateContainer() {
return realStateContainer;
}
}

View file

@ -1,41 +0,0 @@
package WayofTime.bloodmagic.block.property;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSet;
import net.minecraft.block.properties.PropertyHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.Collection;
public class PropertyString extends PropertyHelper<String> {
private final ImmutableSet<String> allowedValues;
protected PropertyString(String name, String[] values) {
super(name, String.class);
allowedValues = ImmutableSet.copyOf(values);
}
@SideOnly(Side.CLIENT)
public Optional<String> parseValue(String value) {
return allowedValues.contains(value) ? Optional.of(value) : Optional.<String>absent();
}
@Override
public Collection<String> getAllowedValues() {
return allowedValues;
}
public String getName0(String value) {
return value;
}
@Override
public String getName(String value) {
return this.getName0(value);
}
public static PropertyString create(String name, String[] values) {
return new PropertyString(name, values);
}
}