Skip to content

Commit

Permalink
version up summon tp
Browse files Browse the repository at this point in the history
  • Loading branch information
hrmcngs committed Dec 17, 2024
1 parent 95fcdbc commit 19725d4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"_fv": 43,
"_type": "procedure",
"definition": {
"procedurexml": "<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"event_trigger\" deletable=\"false\" x=\"60\" y=\"89\"><field name=\"trigger\">no_ext_trigger</field><next><block type=\"controls_if\"><value name=\"IF0\"><block type=\"logic_entity_compare\"><field name=\"entity\">EntityArmorStand</field><value name=\"compareTo\"><block type=\"entity_from_deps\"></block></value></block></value><statement name=\"DO0\"><block type=\"entity_execute_command\"><value name=\"command\"><block type=\"text\"><field name=\"TEXT\">tp @s ~ ~ ~ ~-.5 ~</field></block></value><value name=\"entity\"><block type=\"entity_from_deps\"></block></value><next><block type=\"entity_execute_command\"><value name=\"command\"><block type=\"text\"><field name=\"TEXT\">function minecraft_armor_weapon:alchemymod1</field></block></value><value name=\"entity\"><block type=\"entity_from_deps\"></block></value><next><block type=\"controls_if\"><value name=\"IF0\"><block type=\"logic_negate\"><value name=\"BOOL\"><block type=\"compare_mcblocks\"><value name=\"a\"><block type=\"world_data_blockat\"><value name=\"x\"><block type=\"entity_pos_x\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value><value name=\"y\"><block type=\"math_dual_ops\"><field name=\"OP\">MINUS</field><value name=\"A\"><block type=\"entity_pos_y\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value><value name=\"B\"><block type=\"math_number\"><field name=\"NUM\">0.5</field></block></value></block></value><value name=\"z\"><block type=\"entity_pos_z\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value></block></value><value name=\"b\"><block type=\"mcitem_allblocks\"><field name=\"value\">CUSTOM:AlchemyCraftBlock</field></block></value></block></value></block></value><statement name=\"DO0\"><block type=\"entity_despawn\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></statement></block></next></block></next></block></statement></block></next></block><block type=\"text\" x=\"290\" y=\"305\"><field name=\"TEXT\">tp @s ~ ~ ~ ~-.5 ~</field></block><block type=\"coord_y\" x=\"641\" y=\"357\"></block><block type=\"entity_pos_y\" x=\"779\" y=\"385\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block><block type=\"entity_pos_x\" x=\"749\" y=\"428\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block><block type=\"entity_pos_z\" x=\"1168\" y=\"418\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></xml>"
"procedurexml": "<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"event_trigger\" deletable=\"false\" x=\"60\" y=\"89\"><field name=\"trigger\">no_ext_trigger</field><next><block type=\"controls_if\"><value name=\"IF0\"><block type=\"logic_entity_compare\"><field name=\"entity\">EntityArmorStand</field><value name=\"compareTo\"><block type=\"entity_from_deps\"></block></value></block></value><statement name=\"DO0\"><block type=\"entity_execute_command\"><value name=\"command\"><block type=\"text\"><field name=\"TEXT\">tp @s ~ ~ ~ ~-.5 ~</field></block></value><value name=\"entity\"><block type=\"entity_from_deps\"></block></value><next><block type=\"entity_execute_command\"><value name=\"command\"><block type=\"text\"><field name=\"TEXT\">function minecraft_armor_weapon:alchemymod1</field></block></value><value name=\"entity\"><block type=\"entity_from_deps\"></block></value><next><block type=\"controls_if\"><value name=\"IF0\"><block type=\"logic_negate\"><value name=\"BOOL\"><block type=\"compare_mcblocks\"><value name=\"a\"><block type=\"world_data_blockat\"><value name=\"x\"><block type=\"entity_pos_x\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value><value name=\"y\"><block type=\"math_dual_ops\"><field name=\"OP\">MINUS</field><value name=\"A\"><block type=\"entity_pos_y\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value><value name=\"B\"><block type=\"math_number\"><field name=\"NUM\">0.5</field></block></value></block></value><value name=\"z\"><block type=\"entity_pos_z\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value></block></value><value name=\"b\"><block type=\"mcitem_allblocks\"><field name=\"value\">CUSTOM:AlchemyCraftBlock</field></block></value></block></value></block></value><statement name=\"DO0\"><block type=\"entity_despawn\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></statement><next><block type=\"world_entity_inrange_foreach\"><value name=\"_placeholder\"><block type=\"entity_iterator\"></block></value><value name=\"x\"><block type=\"coord_x\"></block></value><value name=\"y\"><block type=\"coord_y\"></block></value><value name=\"z\"><block type=\"coord_z\"></block></value><value name=\"range\"><block type=\"math_number\"><field name=\"NUM\">1</field></block></value><statement name=\"foreach\"><block type=\"controls_if\"><value name=\"IF0\"><block type=\"logic_entity_compare\"><field name=\"entity\">EntityItem</field><value name=\"compareTo\"><block type=\"entity_iterator\"></block></value></block></value><statement name=\"DO0\"><block type=\"move_entity\"><value name=\"entity\"><block type=\"entity_iterator\"></block></value><value name=\"x\"><block type=\"coord_x\"></block></value><value name=\"y\"><block type=\"coord_y\"></block></value><value name=\"z\"><block type=\"coord_z\"></block></value></block></statement></block></statement></block></next></block></next></block></next></block></statement></block></next></block><block type=\"text\" x=\"290\" y=\"305\"><field name=\"TEXT\">tp @s ~ ~ ~ ~-.5 ~</field></block><block type=\"coord_y\" x=\"641\" y=\"357\"></block><block type=\"entity_pos_y\" x=\"779\" y=\"385\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block><block type=\"entity_pos_x\" x=\"749\" y=\"428\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block><block type=\"entity_pos_z\" x=\"1168\" y=\"418\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></xml>"
}
}
12 changes: 12 additions & 0 deletions minecraft_armor_weapon.mcreator
Original file line number Diff line number Diff line change
Expand Up @@ -9042,6 +9042,18 @@
"name": "entity",
"type": "entity"
},
{
"name": "x",
"type": "number"
},
{
"name": "y",
"type": "number"
},
{
"name": "z",
"type": "number"
},
{
"name": "world",
"type": "world"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public String getDescriptionId() {

@Override
public void applyEffectTick(LivingEntity entity, int amplifier) {
AlchemyCraftBlockEffectOnEffectActiveTickProcedure.execute(entity.level, entity);
AlchemyCraftBlockEffectOnEffectActiveTickProcedure.execute(entity.level, entity.getX(), entity.getY(), entity.getZ(), entity);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
package minecraftarmorweapon.procedures;

import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.decoration.ArmorStand;
import net.minecraft.world.entity.Entity;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.CommandSource;

import minecraftarmorweapon.init.MinecraftArmorWeaponModBlocks;

import java.util.stream.Collectors;
import java.util.List;
import java.util.Comparator;

public class AlchemyCraftBlockEffectOnEffectActiveTickProcedure {
public static void execute(LevelAccessor world, Entity entity) {
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
if (entity == null)
return;
if (entity instanceof ArmorStand) {
Expand All @@ -33,6 +41,21 @@ public static void execute(LevelAccessor world, Entity entity) {
if (!entity.level.isClientSide())
entity.discard();
}
{
final Vec3 _center = new Vec3(x, y, z);
List<Entity> _entfound = world.getEntitiesOfClass(Entity.class, new AABB(_center, _center).inflate(1 / 2d), e -> true).stream().sorted(Comparator.comparingDouble(_entcnd -> _entcnd.distanceToSqr(_center)))
.collect(Collectors.toList());
for (Entity entityiterator : _entfound) {
if (entityiterator instanceof ItemEntity) {
{
Entity _ent = entityiterator;
_ent.teleportTo(x, y, z);
if (_ent instanceof ServerPlayer _serverPlayer)
_serverPlayer.connection.teleport(x, y, z, _ent.getYRot(), _ent.getXRot());
}
}
}
}
}
}
}

0 comments on commit 19725d4

Please sign in to comment.