Skip to content

Commit

Permalink
Cursed flame, #192
Browse files Browse the repository at this point in the history
  • Loading branch information
NightKosh committed Dec 9, 2018
1 parent 24972e1 commit c12be59
Show file tree
Hide file tree
Showing 28 changed files with 437 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
package nightkosh.gravestone_extended.block;

import net.minecraft.block.Block;
import net.minecraft.block.BlockFire;
import net.minecraft.block.BlockTNT;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import nightkosh.gravestone_extended.core.GSTabs;
import nightkosh.gravestone_extended.core.ModInfo;
import nightkosh.gravestone_extended.helper.GameRuleHelper;

import java.util.Random;

/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
public class BlockCursedFlame extends BlockFire {

public BlockCursedFlame() {
super();
this.setUnlocalizedName("cursed_flame");
this.setCreativeTab(GSTabs.otherItemsTab);
this.setRegistryName(ModInfo.ID, "cursed_flame");
}

@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
entity.setFire(8);//TODO !!!!!!!!!!!!!!!!!!!
}

@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
if (GameRuleHelper.checkFireTick(world)) {
if (world.isAreaLoaded(pos, 2)) { // Forge: prevent loading unloaded chunks when spreading fire
Block block = world.getBlockState(pos.down()).getBlock();
boolean flag = block.isFireSource(world, pos.down(), EnumFacing.UP);

int i = state.getValue(AGE);

if (!flag && world.isRaining() && this.canDie(world, pos) && rand.nextFloat() < 0.2F + i * 0.03F) {
} else {
if (i < 15) {
state = state.withProperty(AGE, i + rand.nextInt(3) / 2);
world.setBlockState(pos, state, 4);
}

world.scheduleUpdate(pos, this, this.tickRate(world) + rand.nextInt(10));

if (!flag) {
if (!this.canNeighborCatchFire(world, pos)) {
return;
}

if (!this.canCatchFire(world, pos.down(), EnumFacing.UP) && i == 15 && rand.nextInt(4) == 0) {
return;
}
}

boolean flag1 = world.isBlockinHighHumidity(pos);
int j = 0;

if (flag1) {
j = -50;
}

this.tryCatchFire(world, pos.east(), 300 + j, rand, i, EnumFacing.WEST);
this.tryCatchFire(world, pos.west(), 300 + j, rand, i, EnumFacing.EAST);
this.tryCatchFire(world, pos.down(), 250 + j, rand, i, EnumFacing.UP);
this.tryCatchFire(world, pos.up(), 250 + j, rand, i, EnumFacing.DOWN);
this.tryCatchFire(world, pos.north(), 300 + j, rand, i, EnumFacing.SOUTH);
this.tryCatchFire(world, pos.south(), 300 + j, rand, i, EnumFacing.NORTH);

for (int k = -1; k <= 1; ++k) {
for (int l = -1; l <= 1; ++l) {
for (int i1 = -1; i1 <= 4; ++i1) {
if (k != 0 || i1 != 0 || l != 0) {
int j1 = 100;

if (i1 > 1) {
j1 += (i1 - 1) * 100;
}

BlockPos blockpos = pos.add(k, i1, l);
int k1 = this.getNeighborEncouragement(world, blockpos);

if (k1 > 0) {
int l1 = (k1 + 40 + world.getDifficulty().getDifficultyId() * 7) / (i + 30);

if (flag1) {
l1 /= 2;
}

if (l1 > 0 && rand.nextInt(j1) <= l1 && (!world.isRaining() || !this.canDie(world, blockpos))) {
int i2 = i + rand.nextInt(5) / 4;

if (i2 > 15) {
i2 = 15;
}

world.setBlockState(blockpos, state.withProperty(AGE, i2), 3);
}
}
}
}
}
}
}
}
}
}

@Override
protected boolean canDie(World world, BlockPos pos) {
return false;
}

protected void tryCatchFire(World world, BlockPos pos, int chance, Random random, int age, EnumFacing face) {
int i = world.getBlockState(pos).getBlock().getFlammability(world, pos, face);

if (random.nextInt(chance) < i) {
IBlockState iblockstate = world.getBlockState(pos);

if (random.nextInt(age + 10) < 5 && !world.isRainingAt(pos)) {
int j = age + random.nextInt(5) / 4;

if (j > 15) {
j = 15;
}

world.setBlockState(pos, this.getDefaultState().withProperty(AGE, j), 3);
} else {
world.setBlockToAir(pos);
}

if (iblockstate.getBlock() == Blocks.TNT) {
Blocks.TNT.onBlockDestroyedByPlayer(world, pos, iblockstate.withProperty(BlockTNT.EXPLODE, true));
}
}
}
}
7 changes: 5 additions & 2 deletions src/main/java/nightkosh/gravestone_extended/core/GSBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ public class GSBlock extends nightkosh.gravestone.core.GSBlock {
public static final Block FROZEN_LAVA = new BlockFrozenLava();
public static final ItemBlock FROZEN_LAVA_IB = new IBFrozenLava(FROZEN_LAVA);

public static final Block CURSED_FLAME = new BlockCursedFlame();
public static final ItemBlock CURSED_FLAME_IB = new IBCursedFlame(CURSED_FLAME);

public static final BlockFluidToxicWater TOXIC_WATER = new BlockFluidToxicWater();

@Mod.EventBusSubscriber(modid = ModInfo.ID)
Expand All @@ -93,7 +96,7 @@ public static void registerBlocks(final RegistryEvent.Register<Block> event) {
final IForgeRegistry<Block> registry = event.getRegistry();
registry.registerAll(MEMORIAL, EXECUTION, SPAWNER, TRAP, WITHERED_GLASS, PILE_OF_BONES, WITHERED_GLASS_PANE,
BONE_BLOCK, BONE_SLAB, BONE_STAIRS, HAUNTED_CHEST, CANDLE, SKULL_CANDLE_SKELETON, SKULL_CANDLE_ZOMBIE, SKULL_CANDLE_WITHER,
ALTAR, INVISIBLE_WALL, CORPSE, TOXIC_WATER, CATACOMBS_PORTAL, FROZEN_LAVA);
ALTAR, INVISIBLE_WALL, CORPSE, TOXIC_WATER, CATACOMBS_PORTAL, FROZEN_LAVA, CURSED_FLAME);
}

@SubscribeEvent
Expand All @@ -102,7 +105,7 @@ public static void registerItemBlocks(final RegistryEvent.Register<Item> event)
registry.registerAll(MEMORIAL_IB, EXECUTION_IB, SPAWNER_IB, TRAP_IB, WITHERED_GLASS_IB, WITHERED_GLASS_PANE_IB,
PILE_OF_BONES_IB, BONE_BLOCK_IB, BONE_SLAB_IB, BONE_STAIRS_IB, HAUNTED_CHEST_IB, CANDLE_IB,
SKULL_CANDLE_SKELETON_IB, SKULL_CANDLE_ZOMBIE_IB, SKULL_CANDLE_WITHER_IB,
ALTAR_IB, CORPSE_IB, CATACOMBS_PORTAL_IB, FROZEN_LAVA_IB);
ALTAR_IB, CORPSE_IB, CATACOMBS_PORTAL_IB, FROZEN_LAVA_IB, CURSED_FLAME_IB);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ public static void registerModels(final ModelRegistryEvent event) {
//frozen lava
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(GSBlock.FROZEN_LAVA), 0, ResourcesModels.FROZEN_LAVA);

//cursed flame
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(GSBlock.CURSED_FLAME), 0, ResourcesModels.CURSED_FLAME);

//portal
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(GSBlock.CATACOMBS_PORTAL), 0, ResourcesModels.CATACOMBS_PORTAL);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,6 @@ public class ResourcesModels extends Resources {
public static final ModelResourceLocation CATACOMBS_PORTAL = new ModelResourceLocation(ModInfo.ID + ":block/catacombs_portal", "inventory");

public static final ModelResourceLocation FROZEN_LAVA = new ModelResourceLocation(ModInfo.ID + ":block/frozen_lava", "inventory");

public static final ModelResourceLocation CURSED_FLAME = new ModelResourceLocation(ModInfo.ID + ":block/cursed_flame", "inventory");
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class GameRuleHelper {

public static final String RULE_MOB_GRIEFING = "mobGriefing";
public static final String RULE_KEEP_INVENTORY = "keepInventory";
public static final String RULE_DO_FIRE_TICK = "doFireTick";

public static boolean checkRule(World world, String rule) {
return world.getGameRules().getBoolean(rule);
Expand All @@ -24,4 +25,8 @@ public static boolean checkMobGriefing(World world) {
public static boolean checkKeepInventory(World world) {
return checkRule(world, RULE_KEEP_INVENTORY);
}

public static boolean checkFireTick(World world) {
return checkRule(world, RULE_DO_FIRE_TICK);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package nightkosh.gravestone_extended.item.itemblock;

import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import nightkosh.gravestone_extended.core.GSBlock;

/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
public class IBCursedFlame extends ItemBlock {

public IBCursedFlame(Block block) {
super(block);
this.setRegistryName(GSBlock.CURSED_FLAME.getRegistryName());
}
}
4 changes: 3 additions & 1 deletion src/main/resources/META-INF/Gravestone_mod_Extended_at.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ public net.minecraft.util/EnumParticleTypes field_186837_Z #BY_NAME
public net.minecraft.entity.player/EntityPlayerMP field_184851_cj #invulnerableDimensionChange
public net.minecraft.client.renderer.block.model/ModelRotation field_177546_q #MAP_ROTATIONS
public net.minecraft.client.renderer.block.model/ModelRotation field_177545_r #combinedXY
public net.minecraft.entity/Entity field_70134_J #isInWeb
public net.minecraft.entity/Entity field_70134_J #isInWeb
public net.minecraft.block/BlockFire func_176533_e(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)Z #canNeighborCatchFire
public net.minecraft.block/BlockFire func_176538_m(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)I #getNeighborEncouragement
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"multipart": [
{ "when": {"north": false, "east": false, "south": false, "west": false, "up": false},
"apply": [
{ "model": "gravestone-extended:cursed_flame/floor0" },
{ "model": "gravestone-extended:cursed_flame/floor1" }
]
},
{ "when": {"OR": [{"north": true}, {"north": false, "east": false, "south": false, "west": false, "up": false}]},
"apply": [
{ "model": "gravestone-extended:cursed_flame/side0" },
{ "model": "gravestone-extended:cursed_flame/side1" },
{ "model": "gravestone-extended:cursed_flame/side_alt0" },
{ "model": "gravestone-extended:cursed_flame/side_alt1" }
]
},
{ "when": {"OR": [{"east": true}, {"north": false, "east": false, "south": false, "west": false, "up": false}]},
"apply": [
{ "model": "gravestone-extended:cursed_flame/side0", "y": 90 },
{ "model": "gravestone-extended:cursed_flame/side1", "y": 90 },
{ "model": "gravestone-extended:cursed_flame/side_alt0", "y": 90 },
{ "model": "gravestone-extended:cursed_flame/side_alt1", "y": 90 }
]
},
{ "when": {"OR": [{"south": true}, {"north": false, "east": false, "south": false, "west": false, "up": false}]},
"apply": [
{ "model": "gravestone-extended:cursed_flame/side0", "y": 180 },
{ "model": "gravestone-extended:cursed_flame/side1", "y": 180 },
{ "model": "gravestone-extended:cursed_flame/side_alt0", "y": 180 },
{ "model": "gravestone-extended:cursed_flame/side_alt1", "y": 180 }
]
},
{ "when": {"OR": [{"west": true}, {"north": false, "east": false, "south": false, "west": false, "up": false}]},
"apply": [
{ "model": "gravestone-extended:cursed_flame/side0", "y": 270 },
{ "model": "gravestone-extended:cursed_flame/side1", "y": 270 },
{ "model": "gravestone-extended:cursed_flame/side_alt0", "y": 270 },
{ "model": "gravestone-extended:cursed_flame/side_alt1", "y": 270 }
]
},
{ "when": {"up": true},
"apply": [
{ "model": "gravestone-extended:cursed_flame/up0" },
{ "model": "gravestone-extended:cursed_flame/up1" },
{ "model": "gravestone-extended:cursed_flame/up_alt0" },
{ "model": "gravestone-extended:cursed_flame/up_alt1" }
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"ambientocclusion": false,
"elements": [
{ "from": [ 0, 0, 8.8 ],
"to": [ 16, 22.4, 8.8 ],
"rotation": { "origin": [ 8, 8, 8 ], "axis": "x", "angle": -22.5, "rescale": true },
"shade": false,
"faces": { "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#fire" }}
},
{ "from": [ 0, 0, 7.2 ],
"to": [ 16, 22.4, 7.2 ],
"rotation": { "origin": [ 8, 8, 8 ], "axis": "x", "angle": 22.5, "rescale": true },
"shade": false,
"faces": { "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#fire" }}
},
{ "from": [ 8.8, 0, 0 ],
"to": [ 8.8, 22.4, 16 ],
"rotation": { "origin": [ 8, 8, 8 ], "axis": "z", "angle": -22.5, "rescale": true },
"shade": false,
"faces": { "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#fire" }}
},
{ "from": [ 7.2, 0, 0 ],
"to": [ 7.2, 22.4, 16 ],
"rotation": { "origin": [ 8, 8, 8 ], "axis": "z", "angle": 22.5, "rescale": true },
"shade": false,
"faces": { "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#fire" }}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "gravestone-extended:block/cursed_flame/floor",
"textures": {
"particle": "gravestone-extended:blocks/cursed_flame/layer_0",
"fire": "gravestone-extended:blocks/cursed_flame/layer_0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "gravestone-extended:block/cursed_flame/floor",
"textures": {
"particle": "gravestone-extended:blocks/cursed_flame/layer_1",
"fire": "gravestone-extended:blocks/cursed_flame/layer_1"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"ambientocclusion": false,
"elements": [
{ "from": [ 0, 0, 0.01 ],
"to": [ 16, 22.4, 0.01 ],
"shade": false,
"faces": {
"south": { "uv": [ 0, 0, 16, 16 ], "texture": "#fire" },
"north": { "uv": [ 0, 0, 16, 16 ], "texture": "#fire" }
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "gravestone-extended:block/cursed_flame/side",
"textures": {
"particle": "gravestone-extended:blocks/cursed_flame/layer_0",
"fire": "gravestone-extended:blocks/cursed_flame/layer_0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "gravestone-extended:block/cursed_flame/side",
"textures": {
"particle": "gravestone-extended:blocks/cursed_flame/layer_1",
"fire": "gravestone-extended:blocks/cursed_flame/layer_1"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"ambientocclusion": false,
"elements": [
{ "from": [ 0, 0, 0.01 ],
"to": [ 16, 22.4, 0.01 ],
"shade": false,
"faces": {
"south": { "uv": [ 16, 0, 0, 16 ], "texture": "#fire" },
"north": { "uv": [ 16, 0, 0, 16 ], "texture": "#fire" }
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "gravestone-extended:block/cursed_flame/side_alt",
"textures": {
"particle": "gravestone-extended:blocks/cursed_flame/layer_0",
"fire": "gravestone-extended:blocks/cursed_flame/layer_0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "gravestone-extended:block/cursed_flame/side_alt",
"textures": {
"particle": "gravestone-extended:blocks/cursed_flame/layer_1",
"fire": "gravestone-extended:blocks/cursed_flame/layer_1"
}
}
Loading

0 comments on commit c12be59

Please sign in to comment.