added monster hoarder
This commit is contained in:
		| @@ -0,0 +1,89 @@ | ||||
| package de.jottyfan.quickiemod.block; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| import net.minecraft.block.AbstractBlock; | ||||
| import net.minecraft.block.Block; | ||||
| import net.minecraft.block.BlockState; | ||||
| import net.minecraft.entity.Entity; | ||||
| import net.minecraft.entity.LivingEntity; | ||||
| import net.minecraft.entity.mob.HostileEntity; | ||||
| import net.minecraft.entity.player.PlayerEntity; | ||||
| import net.minecraft.item.ItemStack; | ||||
| import net.minecraft.registry.RegistryKey; | ||||
| import net.minecraft.registry.RegistryKeys; | ||||
| import net.minecraft.server.world.ServerWorld; | ||||
| import net.minecraft.sound.SoundCategory; | ||||
| import net.minecraft.sound.SoundEvents; | ||||
| import net.minecraft.state.StateManager.Builder; | ||||
| import net.minecraft.state.property.IntProperty; | ||||
| import net.minecraft.text.Text; | ||||
| import net.minecraft.util.ActionResult; | ||||
| import net.minecraft.util.Identifier; | ||||
| import net.minecraft.util.hit.BlockHitResult; | ||||
| import net.minecraft.util.math.BlockPos; | ||||
| import net.minecraft.util.math.Box; | ||||
| import net.minecraft.util.math.random.Random; | ||||
| import net.minecraft.world.World; | ||||
| import net.minecraft.world.tick.OrderedTick; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * @author jotty | ||||
|  * | ||||
|  */ | ||||
| public class BlockMonsterhoarder extends Block { | ||||
|  | ||||
| 	private static final IntProperty SUCKRADIUS = IntProperty.of("suckradius", 1, 15); | ||||
|  | ||||
| 	public BlockMonsterhoarder(Identifier identifier) { | ||||
| 		super(AbstractBlock.Settings.create().hardness(2.5f).luminance(state -> state.get(BlockMonsterhoarder.SUCKRADIUS)) | ||||
| 				.registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier))); | ||||
| 		setDefaultState(getDefaultState().with(SUCKRADIUS, 8)); | ||||
| 	} | ||||
|  | ||||
| 	@Override | ||||
| 	protected void appendProperties(Builder<Block, BlockState> builder) { | ||||
| 		builder.add(SUCKRADIUS); | ||||
| 		super.appendProperties(builder); | ||||
| 	} | ||||
|  | ||||
| 	@Override | ||||
| 	protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) { | ||||
| 		if (!world.isClient()) { | ||||
| 			world.setBlockState(pos, state.cycle(SUCKRADIUS)); | ||||
| 		} else { | ||||
| 			player.sendMessage(Text.translatable("msg.monsterhoarder.size", state.get(SUCKRADIUS)), false); | ||||
| 		} | ||||
| 		return ActionResult.SUCCESS; | ||||
| 	} | ||||
|  | ||||
| 	@Override | ||||
| 	protected void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { | ||||
| 		if (!world.isClient) { | ||||
| 			Box box = new Box(pos).expand(Double.valueOf(state.get(SUCKRADIUS))); | ||||
| 			List<Entity> entities = world.getOtherEntities(null, box); | ||||
| 			for (Entity entity : entities) { | ||||
| 				if (entity instanceof HostileEntity hostile) { | ||||
| 					if (hostile.isFireImmune()) { | ||||
| 						if (world instanceof ServerWorld serverWorld) { | ||||
| 							hostile.kill(serverWorld); | ||||
| 						} | ||||
| 					} else { | ||||
| 						hostile.setOnFireFor(90); | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		world.getBlockTickScheduler().scheduleTick(OrderedTick.create(this, pos)); | ||||
| 	} | ||||
|  | ||||
| 	@Override | ||||
| 	public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) { | ||||
| 		if (!world.isClient) { | ||||
| 			world.getBlockTickScheduler().scheduleTick(OrderedTick.create(this, pos)); | ||||
| 			world.playSound(null, pos, SoundEvents.UI_TOAST_CHALLENGE_COMPLETE, SoundCategory.PLAYERS, 1f, 1f); | ||||
| 		} | ||||
| 		super.onPlaced(world, pos, state, placer, itemStack); | ||||
| 	} | ||||
| } | ||||
| @@ -31,6 +31,8 @@ public class ModBlocks { | ||||
| 			ModIdentifiers.BLOCK_SALPETER, 1.5f, 1.5f, new ItemStack[] { new ItemStack(ModItems.ITEM_SALPETER, 9) })); | ||||
| 	public static final Block BLOCK_SULFOR = registerBlock(ModIdentifiers.BLOCK_SULFOR, new BlockBreakByTool( | ||||
| 			ModIdentifiers.BLOCK_SULFOR, 1.5f, 1.5f, new ItemStack[] { new ItemStack(ModItems.ITEM_SULFOR, 9) })); | ||||
| 	public static final Block BLOCK_MONSTERHOARDER = registerBlock(ModIdentifiers.BLOCK_MONSTERHOARDER, | ||||
| 			new BlockMonsterhoarder(ModIdentifiers.BLOCK_MONSTERHOARDER)); | ||||
|  | ||||
| 	private static final Block registerBlock(Identifier identifier, Block block) { | ||||
| 		Registry.register(Registries.ITEM, identifier, new BlockItem(block, new Item.Settings() | ||||
| @@ -46,6 +48,7 @@ public class ModBlocks { | ||||
| 		blocks.add(BLOCK_SPEEDPOWDER); | ||||
| 		blocks.add(BLOCK_SALPETER); | ||||
| 		blocks.add(BLOCK_SULFOR); | ||||
| 		blocks.add(BLOCK_MONSTERHOARDER); | ||||
| 		return blocks; | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -24,4 +24,5 @@ public class ModIdentifiers { | ||||
| 	public static final Identifier BLOCK_SPEEDPOWDER = Identifier.of(Quickiemod.MOD_ID, "blockspeedpowder"); | ||||
| 	public static final Identifier BLOCK_SALPETER = Identifier.of(Quickiemod.MOD_ID, "blocksalpeter"); | ||||
| 	public static final Identifier BLOCK_SULFOR = Identifier.of(Quickiemod.MOD_ID, "blocksulphor"); | ||||
| 	public static final Identifier BLOCK_MONSTERHOARDER = Identifier.of(Quickiemod.MOD_ID, "monsterhoarder"); | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,7 @@ | ||||
| { | ||||
| 	"variants": { | ||||
| 		"": { | ||||
| 			"model": "quickiemod:block/monsterhoarder" | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @@ -103,6 +103,7 @@ | ||||
| 	"msg.buildingplan.failonblock": "Der Bau wurde abgelehnt, es ist im Weg: %s", | ||||
| 	"msg.buildingplan.failonplayer": "Der Bau wurde abgelehnt, um Spieler %s nicht zu gefährden.", | ||||
| 	"msg.itemhoarder.summary": "Der Itemsauger enthält: %s", | ||||
| 	"msg.monsterhoarder.size": "Der Radius für diesen Monstersauger beträgt jetzt %d.", | ||||
| 	"msg.notyetimplemented": "leider noch nicht verfügbar", | ||||
| 	"msg.backpack.transfer.filled": "Der Rucksack wurde befüllt.", | ||||
| 	"msg.backpack.transfer.cleared": "Der Rucksackinhalt wurde soweit möglich geleert.", | ||||
|   | ||||
| @@ -103,6 +103,7 @@ | ||||
| 	"msg.buildingplan.failonblock": "The building execution was rejected because of %s", | ||||
| 	"msg.buildingplan.failonplayer": "The building execution was rejected because of %s who could be injured.", | ||||
| 	"msg.itemhoarder.summary": "The item hoarder contains: %s", | ||||
|   "msg.monsterhoarder.size": "The radius for this monster hoarder is %d from now on.", | ||||
| 	"msg.notyetimplemented": "not yet implemented", | ||||
| 	"msg.backpack.transfer.filled": "Filled the backpack.", | ||||
| 	"msg.backpack.transfer.cleared": "Cleared the backpack as much as possible.", | ||||
|   | ||||
| @@ -0,0 +1,6 @@ | ||||
| { | ||||
| 		"parent": "block/cube_all", | ||||
| 		"textures": { | ||||
| 				"all": "quickiemod:block/monsterhoarder" | ||||
| 		} | ||||
| } | ||||
| @@ -0,0 +1,10 @@ | ||||
| { | ||||
| 		"parent": "quickiemod:block/monsterhoarder", | ||||
| 		"display": { | ||||
| 				"thirdperson": { | ||||
| 						"rotation": [ 10, -45, 170 ], | ||||
| 						"translation": [ 0, 1.5, -2.75 ], | ||||
| 						"scale": [ 0.375, 0.375, 0.375 ] | ||||
| 				} | ||||
| 		} | ||||
| } | ||||
| @@ -5,7 +5,4 @@ | ||||
| 		"id": "quickiemod:oxidizedcopperpowder"}, | ||||
| 	"experience": 0.1, | ||||
| 	"cookingtime": 200 | ||||
| }, | ||||
|     "experience": 0.1, | ||||
|     "cookingtime": 200 | ||||
| } | ||||
| @@ -0,0 +1,17 @@ | ||||
| { | ||||
| 	"type": "minecraft:crafting_shaped", | ||||
| 	"pattern": [ | ||||
| 		"oqo", | ||||
| 		"qtq", | ||||
| 		"oqo" | ||||
| 	], | ||||
| 	"key": { | ||||
| 		"q": "quickiemod:quickieingot", | ||||
| 		"t": "minecraft:torch", | ||||
| 		"o": "minecraft:obsidian" | ||||
| 	}, | ||||
| 	"result": { | ||||
| 		"id": "quickiemod:monsterhoarder", | ||||
| 		"count": 1 | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user