Skip to content

Commit 38473d1

Browse files
committed
change bedrock break tool
1 parent 9fbe4a2 commit 38473d1

9 files changed

Lines changed: 72 additions & 12 deletions

File tree

src/main/java/huige233/transcend/blocks/BlockBase.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77
import huige233.transcend.util.IHasModel;
88
import net.minecraft.block.Block;
99
import net.minecraft.block.material.Material;
10+
import net.minecraft.block.state.IBlockState;
1011
import net.minecraft.entity.Entity;
12+
import net.minecraft.init.Items;
1113
import net.minecraft.item.Item;
1214
import net.minecraft.item.ItemBlock;
1315
import net.minecraft.item.ItemStack;
1416
import net.minecraft.world.World;
1517

18+
import java.util.Random;
19+
1620
public class BlockBase extends Block implements IHasModel {
1721
public BlockBase(String name, Material material) {
1822
super(material);
@@ -23,6 +27,14 @@ public BlockBase(String name, Material material) {
2327
ModItems.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName()));
2428
}
2529

30+
@Override
31+
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
32+
if(state.getBlock() == ModBlock.NETHER_STAR_BLOCK) {
33+
return Items.NETHER_STAR;
34+
}
35+
return Item.getItemFromBlock(this);
36+
}
37+
2638
@Override
2739
public void registerModels() {
2840
Main.proxy.registerItemRenderer(Item.getItemFromBlock(this), 0, "inventory");

src/main/java/huige233/transcend/init/ModBlock.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ public class ModBlock {
1515
public static final Block FLAWLESS_BLOCK = new BlockBase("flawless_block", Material.ROCK);
1616
public static final Block BEDROCK_ORE = new bedrockorz("bedrock_ore", Material.ROCK);
1717
public static final Block CAST_MACHINE = new BlockVirusGenerator("cast_machine");
18+
public static final Block NETHER_STAR_BLOCK = new BlockBase("nether_star_block", Material.ROCK).setHardness(5.0F);
1819
}

src/main/java/huige233/transcend/items/tools/ToolPickaxe.java

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import net.minecraft.creativetab.CreativeTabs;
1313
import net.minecraft.enchantment.EnchantmentHelper;
1414
import net.minecraft.entity.Entity;
15-
import net.minecraft.entity.SharedMonsterAttributes;
1615
import net.minecraft.entity.ai.attributes.AttributeModifier;
1716
import net.minecraft.entity.player.EntityPlayer;
1817
import net.minecraft.init.Blocks;
@@ -21,15 +20,17 @@
2120
import net.minecraft.item.EnumRarity;
2221
import net.minecraft.item.ItemPickaxe;
2322
import net.minecraft.item.ItemStack;
24-
import net.minecraft.nbt.NBTTagCompound;
2523
import net.minecraft.tileentity.TileEntity;
2624
import net.minecraft.util.ActionResult;
2725
import net.minecraft.util.EnumActionResult;
2826
import net.minecraft.util.EnumHand;
2927
import net.minecraft.util.math.BlockPos;
28+
import net.minecraft.util.text.TextComponentString;
29+
import net.minecraft.util.text.translation.I18n;
3030
import net.minecraft.world.World;
3131
import net.minecraftforge.fml.common.Mod;
3232

33+
import java.util.Random;
3334
import java.util.UUID;
3435

3536
@Mod.EventBusSubscriber(modid = Reference.MOD_ID)
@@ -65,15 +66,42 @@ public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player
6566
public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, EntityPlayer player) {
6667
World world = player.world;
6768
IBlockState state = world.getBlockState(pos);
68-
Block block = state.getBlock();
69-
TileEntity tile = world.getTileEntity(pos);
69+
BlockPos blockpos1 = pos.add(1,-1,0);
70+
BlockPos blockpos2 = pos.add(0,-1,1);
71+
BlockPos blockpos3 = pos.add(-1,-1,0);
72+
BlockPos blockpos4 = pos.add(0,-1,-1);
73+
BlockPos blockPos = pos.add(0, -1, 0);
74+
int yi = 0;
7075
if (!world.isRemote) {
71-
if (state.getBlock() == Blocks.EMERALD_BLOCK && player.getHeldItem(EnumHand.MAIN_HAND).getItem() == ModItems.BREAK_BEDROCK_TOOL) {
72-
BlockPos blockPos = pos.add(0, -1, 0);
73-
IBlockState bedrockore = world.getBlockState(blockPos);
74-
bedrockore.getBlock().dropBlockAsItem(world, blockPos, bedrockore, 0);
75-
world.setBlockToAir(blockPos);
76-
world.setBlockToAir(pos);
76+
if (state.getBlock() == ModBlock.NETHER_STAR_BLOCK && player.getHeldItem(EnumHand.MAIN_HAND).getItem() == ModItems.BREAK_BEDROCK_TOOL) {
77+
if (world.getBlockState(blockpos1).getBlock() == Blocks.DRAGON_EGG) {
78+
world.setBlockToAir(blockpos1);
79+
yi++;
80+
}
81+
if (world.getBlockState(blockpos2).getBlock() == Blocks.PURPUR_PILLAR) {
82+
world.setBlockToAir(blockpos2);
83+
yi++;
84+
}
85+
if (world.getBlockState(blockpos3).getBlock() == Blocks.REDSTONE_BLOCK) {
86+
world.setBlockToAir(blockpos3);
87+
yi++;
88+
}
89+
if (world.getBlockState(blockpos4).getBlock() == Blocks.EMERALD_BLOCK) {
90+
world.setBlockToAir(blockpos4);
91+
yi++;
92+
}
93+
}
94+
95+
if(yi>=2) {
96+
Random ran = world.rand;
97+
double wa = yi*0.25f;
98+
if(wa >= ran.nextDouble()) {
99+
IBlockState bedrockore = world.getBlockState(blockPos);
100+
bedrockore.getBlock().dropBlockAsItem(world, blockPos, bedrockore, 0);
101+
world.setBlockToAir(blockPos);
102+
} else {
103+
player.sendMessage(new TextComponentString(I18n.translateToLocal("message.bedrock_ore_failed")));
104+
}
77105
}
78106
}
79107
return false;

src/main/java/huige233/transcend/util/TextUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ public TextUtils() {
1111
}
1212

1313
public static String makeFabulous(String input) {
14-
return ludicrousFormatting(input, fabulousness, 80.0D, 1, 1);
14+
return ludicrousFormatting(input, fabulousness, 60.0D, 1, 1);
1515
}
1616

1717
public static String makeSANIC(String input) {
18-
return ludicrousFormatting(input, sanic, 50.0D, 2, 1);
18+
return ludicrousFormatting(input, sanic, 50.0D, 1, 1);
1919
}
2020

2121
public static String ludicrousFormatting(String input, TextFormatting[] colours, double delay, int step, int posstep) {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"variants": {
3+
"normal": {"model": "transcend:nether_star_block"}
4+
}
5+
}

src/main/resources/assets/transcend/lang/en_US.lang

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ enchantment.flawless_enchantment=FLAWLESS
3131
tile.transcend_block.name=Transcend Block
3232
tile.flawless_block.name=Flawless Block
3333
tile.bedrock_ore.name=Bedrock Ore
34+
tile.nether_star_block.name=Nether Star Block
3435
tooltip.transcend_sword.desc=Everything will be shattered
36+
message.bedrock_ore_failed= "You failed to break the bedrock"
3537

3638
death.attack.transcend=%s A power beyond all things will wipe you out
3739
tip.transcend=Infinity

src/main/resources/assets/transcend/lang/zh_CN.lang

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ enchantment.flawless_enchantment=完美之力
3131
tile.flawless_block.name=完美合金块
3232
tile.transcend_block.name=超越合金块
3333
tile.bedrock_ore.name=基岩矿石
34+
tile.nether_star_block.name=下界之星块
3435
tooltip.transcend_sword.desc=万物终将被粉碎
36+
message.bedrock_ore_failed="挖掘基岩矿石失败"
37+
3538
death.attack.transcend=%s被超越万物的力量粉碎
3639
tip.transcend=Infinity
3740
container.cast_machine=基岩冶炼厂
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"parent": "block/cube_all",
3+
"textures": {
4+
"all": "transcend:blocks/nether_star_block"
5+
}
6+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"parent" : "transcend:block/nether_star_block"
3+
}

0 commit comments

Comments
 (0)