Started by
SqueezeTheC4
on
Topic category: Help with MCreator software
Hello there, I am making a Mod in where everytime a certain block is clicked, it will remove a chunk of it. Like a cake!!. However, I cannot seem to make this work. Its not food, it is a block. So does anyone know how to take away chunks of a block when clicked, like cake. Thank You :)
You'll need to make each chunk a separate block (For example, here are the blocks you'd need for a four slice cake:
Full Cake
3/4 Cake
1/2 Cake
1/4 Cake, etc.)
Then use events to make the block be replaced with another chunk when right-clicked. I don't know how to make the hunger replenish though.
Or just extend BlockCake and edit the blocksate .json file (it will look simply like the vanilla cake one , just use path to your models)
@#2 Where would I find that ???
in code it is the line extends Block
I have no idea on how to do that but thank you for the help :)
Just open the source of your block and look for part "static class YOURBLOCKNAME extends Block" and change the "Block" to "BlockCake"
I tried it, this is what happens (method does not override or implement a method from a supertype)
Can I see the full log? It should print what is name of the method.
Executing gradle command: clean runClient
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.
C:\Pylo\MCreator170>cd forge
C:\Pylo\MCreator170\forge>SET "JAVA_HOME=C:\Pylo\MCreator170\jdk64\"
C:\Pylo\MCreator170\forge>SET JAVA_EXE=%JAVA_HOME%\bin\java.exe
C:\Pylo\MCreator170\forge>SET PATH=%JAVA_HOME%\bin\;%PATH%
C:\Pylo\MCreator170\forge>gradlew -Dorg.gradle.jvmargs="-Xms625m -Xmx2048m" clean runClient
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/2.7/userguide/gradle_daemon.html.
This mapping 'snapshot_20160518' was designed for MC 1.9.4! Use at your own peril.
#################################################
ForgeGradle 2.2-SNAPSHOT-c438b06
https://github.com/MinecraftForge/ForgeGradle
#################################################
Powered by MCP unknown
http://modcoderpack.com
by: Searge, ProfMobius, Fesh0r,
R4wk, ZeuX, IngisKahn, bspkrs
#################################################
:clean
:deobfCompileDummyTask
:deobfProvidedDummyTask
:getVersionJson
:extractUserdev UP-TO-DATE
:downloadClient SKIPPED
:downloadServer SKIPPED
:splitServerJar SKIPPED
:mergeJars SKIPPED
:applyBinaryPatches SKIPPED
:extractDependencyATs SKIPPED
:extractMcpData SKIPPED
:extractMcpMappings SKIPPED
:genSrgs SKIPPED
:deobfMcMCP SKIPPED
:sourceApiJava
:compileApiJava UP-TO-DATE
:processApiResources UP-TO-DATE
:apiClasses UP-TO-DATE
:sourceMainJava
C:\Pylo\MCreator170\forge\build\sources\main\java\mod\mcreator\mcreator_greenAppleTub.java:80: error: cannot find symbol
static class BlockGreenAppleTub extends BlockCake {
^
symbol: class BlockCake
location: class mcreator_greenAppleTub
C:\Pylo\MCreator170\forge\build\sources\main\java\mod\mcreator\mcreator_greenAppleTub.java:56: error: incompatible types: BlockGreenAppleTub cannot be converted to Block
.register(Item.getItemFromBlock(block), 0, new ModelResourceLocation("TestEnvironmentMod:GreenAppleTub", "inventory"));
^
C:\Pylo\MCreator170\forge\build\sources\main\java\mod\mcreator\mcreator_greenAppleTub.java:59: error: no suitable constructor found for ItemStack(BlockGreenAppleTub,int)
GameRegistry.addRecipe(new ItemStack(block, 1),
^
constructor ItemStack.ItemStack(Block,int) is not applicable
(argument mismatch; BlockGreenAppleTub cannot be converted to Block)
constructor ItemStack.ItemStack(Item,int) is not applicable
(argument mismatch; BlockGreenAppleTub cannot be converted to Item)
C:\Pylo\MCreator170\forge\build\sources\main\java\mod\mcreator\mcreator_greenAppleTub.java:69: error: cannot find symbol
block = (BlockGreenAppleTub) (new BlockGreenAppleTub().setHardness(2.0F).setResistance(10.0F).setLightLevel(0.0F)
^
symbol: method setHardness(float)
location: class BlockGreenAppleTub
C:\Pylo\MCreator170\forge\build\sources\main\java\mod\mcreator\mcreator_greenAppleTub.java:71: error: cannot find symbol
block.setHarvestLevel("pickaxe", 0);
^
symbol: method setHarvestLevel(String,int)
location: variable block of type BlockGreenAppleTub
C:\Pylo\MCreator170\forge\build\sources\main\java\mod\mcreator\mcreator_greenAppleTub.java:89: error: no suitable method found for registerBlock(BlockGreenAppleTub,String)
GameRegistry.registerBlock(this, "GreenAppleTub");
^
method GameRegistry.registerBlock(Block,String) is not applicable
(argument mismatch; BlockGreenAppleTub cannot be converted to Block)
method GameRegistry.registerBlock(Block,Class<? extends ItemBlock>) is not applicable
(argument mismatch; BlockGreenAppleTub cannot be converted to Block)
method GameRegistry.registerBlock(Block,Class<? extends ItemBlock>,Object...) is not applicable
(argument mismatch; BlockGreenAppleTub cannot be converted to Block)
method GameRegistry.registerBlock(Block,Class<? extends ItemBlock>,String,Object...) is not applicable
(argument mismatch; BlockGreenAppleTub cannot be converted to Block)
C:\Pylo\MCreator170\forge\build\sources\main\java\mod\mcreator\mcreator_greenAppleTub.java:90: error: cannot find symbol
setSoundType(SoundType.WOOD);
^
symbol: method setSoundType(SoundType)
location: class BlockGreenAppleTub
C:\Pylo\MCreator170\forge\build\sources\main\java\mod\mcreator\mcreator_greenAppleTub.java:94: error: method does not override or implement a method from a supertype
@Override
^
C:\Pylo\MCreator170\forge\build\sources\main\java\mod\mcreator\mcreator_greenAppleTub.java:100: error: incompatible types: BlockGreenAppleTub cannot be converted to Block
world.scheduleUpdate(new BlockPos(i, j, k), this, this.tickRate(world));
^
C:\Pylo\MCreator170\forge\build\sources\main\java\mod\mcreator\mcreator_greenAppleTub.java:104: error: method does not override or implement a method from a supertype
@Override
^
C:\Pylo\MCreator170\forge\build\sources\main\java\mod\mcreator\mcreator_greenAppleTub.java:109: error: method does not override or implement a method from a supertype
@Override
^
C:\Pylo\MCreator170\forge\build\sources\main\java\mod\mcreator\mcreator_greenAppleTub.java:114: error: method does not override or implement a method from a supertype
@Override
^
C:\Pylo\MCreator170\forge\build\sources\main\java\mod\mcreator\mcreator_greenAppleTub.java:129: error: method does not override or implement a method from a supertype
@Override
^
C:\Pylo\MCreator170\forge\build\sources\main\java\mod\mcreator\mcreator_greenAppleTub.java:134: error: method does not override or implement a method from a supertype
@Override
^
C:\Pylo\MCreator170\forge\build\sources\main\java\mod\mcreator\mcreator_greenAppleTub.java:139: error: method does not override or implement a method from a supertype
@Override
^
C:\Pylo\MCreator170\forge\build\sources\main\java\mod\mcreator\mcreator_greenAppleTub.java:144: error: method does not override or implement a method from a supertype
@Override
^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
16 errors
:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1 mins 6.162 secs
C:\Pylo\MCreator170\forge>
Task completed with return code 0 in 68306 milliseconds
Can I see your code I am not sure what imports sets mcreator
If you mean code for the block then here it is:
package mod.mcreator;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraft.world.World;
import net.minecraft.world.IBlockAccess;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Item;
import net.minecraft.init.Items;
import net.minecraft.init.Blocks;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.Minecraft;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.material.Material;
import net.minecraft.block.SoundType;
import net.minecraft.block.Block;
import java.util.Random;
public class mcreator_blueIceTub {
public mcreator_blueIceTub() {
}
public static BlockBlueIceTub block;
public static Object instance;
public int addFuel(ItemStack fuel) {
return 0;
}
public void serverLoad(FMLServerStartingEvent event) {
}
public void preInit(FMLPreInitializationEvent event) {
}
public void registerRenderers() {
}
public void load(FMLInitializationEvent event) {
if (event.getSide() == Side.CLIENT) {
Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
.register(Item.getItemFromBlock(block), 0, new ModelResourceLocation("TestEnvironmentMod:BlueIceTub", "inventory"));
}
GameRegistry.addRecipe(new ItemStack(block, 1),
new Object[]{"012", "345", "678", Character.valueOf('0'), new ItemStack(Blocks.WOOL, 1, 15), Character.valueOf('1'),
new ItemStack(Blocks.WOOL, 1, 15), Character.valueOf('2'), new ItemStack(Blocks.WOOL, 1, 15), Character.valueOf('3'),
new ItemStack(Items.DYE, 1, 12), Character.valueOf('4'), Blocks.ICE, Character.valueOf('5'), new ItemStack(Items.DYE, 1, 12),
Character.valueOf('6'), new ItemStack(Blocks.WOOL, 1, 15), Character.valueOf('7'), new ItemStack(Blocks.WOOL, 1, 15),
Character.valueOf('8'), new ItemStack(Blocks.WOOL, 1, 15),});
}
static {
block = (BlockBlueIceTub) (new BlockBlueIceTub().setHardness(2.0F).setResistance(10.0F).setLightLevel(0.0F).setUnlocalizedName("BlueIceTub")
.setLightOpacity(0).setCreativeTab(mcreator_gfuel.tab));
block.setHarvestLevel("pickaxe", 0);
}
public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
}
public void generateNether(World world, Random random, int chunkX, int chunkZ) {
}
static class BlockBlueIceTub extends Block {
int a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0;
boolean red = false;
protected BlockBlueIceTub() {
super(Material.IRON);
GameRegistry.registerBlock(this, "BlueIceTub");
setSoundType(SoundType.WOOD);
}
@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
int i = pos.getX();
int j = pos.getY();
int k = pos.getZ();
EntityPlayer entity = Minecraft.getMinecraft().thePlayer;
world.scheduleUpdate(new BlockPos(i, j, k), this, this.tickRate(world));
}
@Override
public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
return red ? 15 : 0;
}
@Override
public int getStrongPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
return red ? 15 : 0;
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entity, EnumHand hand, ItemStack heldItem,
EnumFacing side, float hitX, float hitY, float hitZ) {
int i = pos.getX();
int j = pos.getY();
int k = pos.getZ();
if (true) {
if (entity instanceof EntityPlayer)
((EntityPlayer) entity).inventory.addItemStackToInventory(new ItemStack(mcreator_blueIcePowder.block, 1));
}
return true;
}
@SideOnly(Side.CLIENT)
@Override
public BlockRenderLayer getBlockLayer() {
return BlockRenderLayer.SOLID;
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
return new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
}
@Override
public int tickRate(World world) {
return 10;
}
@Override
public int quantityDropped(Random par1Random) {
return 1;
}
}
}
This could work (but you will also must edit blockstate .json file , else you will get black-purple block, you can take a look on the vanilla cake .json file):
[spoiler]
package mod.mcreator;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraft.world.World;
import net.minecraft.world.IBlockAccess;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Item;
import net.minecraft.init.Items;
import net.minecraft.init.Blocks;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.Minecraft;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.material.Material;
import net.minecraft.block.SoundType;
import net.minecraft.block.Block;
import java.util.Random;
import javax.annotation.Nullable;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import java.util.Random;
public class mcreator_blueIceTub {
public mcreator_blueIceTub() {
}
public static BlockBlueIceTub block;
public static Object instance;
public int addFuel(ItemStack fuel) {
return 0;
}
public void serverLoad(FMLServerStartingEvent event) {
}
public void preInit(FMLPreInitializationEvent event) {
}
public void registerRenderers() {
}
public void load(FMLInitializationEvent event) {
if (event.getSide() == Side.CLIENT) {
Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
.register(Item.getItemFromBlock(block), 0, new ModelResourceLocation("TestEnvironmentMod:BlueIceTub", "inventory"));
}
GameRegistry.addRecipe(new ItemStack(block, 1),
new Object[]{"012", "345", "678", Character.valueOf('0'), new ItemStack(Blocks.WOOL, 1, 15), Character.valueOf('1'),
new ItemStack(Blocks.WOOL, 1, 15), Character.valueOf('2'), new ItemStack(Blocks.WOOL, 1, 15), Character.valueOf('3'),
new ItemStack(Items.DYE, 1, 12), Character.valueOf('4'), Blocks.ICE, Character.valueOf('5'), new ItemStack(Items.DYE, 1, 12),
Character.valueOf('6'), new ItemStack(Blocks.WOOL, 1, 15), Character.valueOf('7'), new ItemStack(Blocks.WOOL, 1, 15),
Character.valueOf('8'), new ItemStack(Blocks.WOOL, 1, 15),});
}
static {
block = (BlockBlueIceTub) (new BlockBlueIceTub().setHardness(2.0F).setResistance(10.0F).setLightLevel(0.0F).setUnlocalizedName("BlueIceTub")
.setLightOpacity(0).setCreativeTab(mcreator_gfuel.tab));
block.setHarvestLevel("pickaxe", 0);
}
public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
}
public void generateNether(World world, Random random, int chunkX, int chunkZ) {
}
static class BlockBlueIceTub extends Block {
int a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0;
public static final PropertyInteger BITES = PropertyInteger.create("bites", 0, 6);
boolean red = false;
protected BlockBlueIceTub() {
super(Material.IRON);
this.setDefaultState(this.blockState.getBaseState().withProperty(BITES, Integer.valueOf(0)));
this.setTickRandomly(true);
GameRegistry.registerBlock(this, "BlueIceTub");
setSoundType(SoundType.WOOD);
}
@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
int i = pos.getX();
int j = pos.getY();
int k = pos.getZ();
EntityPlayer entity = Minecraft.getMinecraft().thePlayer;
world.scheduleUpdate(new BlockPos(i, j, k), this, this.tickRate(world));
}
public boolean isFullCube(IBlockState state)
{
return false;
}
public boolean isOpaqueCube(IBlockState state)
{
return false;
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entity, EnumHand hand, ItemStack heldItem,
EnumFacing side, float hitX, float hitY, float hitZ) {
int i = pos.getX();
int j = pos.getY();
int k = pos.getZ();
if (true) {
if (entity instanceof EntityPlayer)
((EntityPlayer) entity).inventory.addItemStackToInventory(new ItemStack(mcreator_blueIcePowder.block, 1));
int i = ((Integer)state.getValue(BITES)).intValue();
if (i < 6)
{
world.setBlockState(pos, state.withProperty(BITES, Integer.valueOf(i + 1)), 3);
}
else
{
world.setBlockToAir(pos);
}
}
return true;
}
@SideOnly(Side.CLIENT)
@Override
public BlockRenderLayer getBlockLayer() {
return BlockRenderLayer.SOLID;
}
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(BITES, Integer.valueOf(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return ((Integer)state.getValue(BITES)).intValue();
}
protected BlockStateContainer createBlockState()
{
return new BlockStateContainer(this, new IProperty[] {BITES});
}
public int getComparatorInputOverride(IBlockState blockState, World worldIn, BlockPos pos)
{
return (7 - ((Integer)blockState.getValue(BITES)).intValue()) * 2;
}
}
}
[/spoiler]
@#9 when i did it it gave me a error
@#9.1 oh nvm