net.minecraft.entity.vehicle.AbstractMinecartEntity Java Examples

The following examples show how to use net.minecraft.entity.vehicle.AbstractMinecartEntity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CarpetDispenserBehaviours.java    From carpet-extra with GNU Lesser General Public License v3.0 6 votes vote down vote up
private ItemStack defaultBehaviour(BlockPointer source, ItemStack stack)
{
    if (this.minecartType == AbstractMinecartEntity.Type.TNT)
    {
        World world = source.getWorld();
        BlockPos pos = source.getBlockPos().offset((Direction) source.getBlockState().get(DispenserBlock.FACING));
        TntEntity tntEntity = new TntEntity(world, (double)pos.getX() + 0.5D, (double)pos.getY(), (double)pos.getZ() + 0.5D, (LivingEntity)null);
        world.spawnEntity(tntEntity);
        world.playSound((PlayerEntity)null, tntEntity.getX(), tntEntity.getY(), tntEntity.getZ(), SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F);
        stack.decrement(1);
        return stack;
    }
    else
    {
        return super.dispenseSilently(source, stack);
    }
}
 
Example #2
Source File: CarpetDispenserBehaviours.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected ItemStack dispenseSilently(BlockPointer source, ItemStack stack)
{
    if (!CarpetExtraSettings.dispensersFillMinecarts)
    {
        return defaultBehaviour(source, stack);
    }
    else
    {
        BlockPos pos = source.getBlockPos().offset((Direction) source.getBlockState().get(DispenserBlock.FACING));
        List<MinecartEntity> list = source.getWorld().<MinecartEntity>getEntities(MinecartEntity.class, new Box(pos), null);
    
        if (list.isEmpty())
        {
            return defaultBehaviour(source, stack);
        }
        else
        {
            MinecartEntity minecart = list.get(0);
            minecart.remove();
            AbstractMinecartEntity minecartEntity = AbstractMinecartEntity.create(minecart.world, minecart.getX(), minecart.getY(), minecart.getZ(), this.minecartType);
            minecartEntity.setVelocity(minecart.getVelocity());
            minecartEntity.pitch = minecart.pitch;
            minecartEntity.yaw = minecart.yaw;
            
            minecart.world.spawnEntity(minecartEntity);
            stack.decrement(1);
            return stack;
        }
    }
}
 
Example #3
Source File: ESP.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onTick(EventTick event) {
	for (Entity e: mc.world.getEntities()) {
		if (e instanceof PlayerEntity && e != mc.player && getSettings().get(0).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.RED, "players");
		}
		
		else if (e instanceof Monster && getSettings().get(1).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.DARK_BLUE, "mobs");
		}
		
		else if (EntityUtils.isAnimal(e) && getSettings().get(2).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.GREEN, "passive");
		}
		
		else if (e instanceof ItemEntity && getSettings().get(3).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.GOLD, "items");
		}
		
		else if (e instanceof EnderCrystalEntity && getSettings().get(4).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.LIGHT_PURPLE, "crystals");
		}
		
		else if ((e instanceof BoatEntity || e instanceof AbstractMinecartEntity) && getSettings().get(5).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.GRAY, "vehicles");
		}
		else {
		    e.setGlowing(false);
		}
	}
}
 
Example #4
Source File: Tracers.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onRender(Event3DRender event) {
	final float thick = (float) getSettings().get(6).toSlider().getValue();
	
	for (Entity e: mc.world.getEntities()) {
		Vec3d vec = e.getPos();
		
		Vec3d vec2 = new Vec3d(0, 0, 75).rotateX(-(float) Math.toRadians(mc.cameraEntity.pitch))
				.rotateY(-(float) Math.toRadians(mc.cameraEntity.yaw))
				.add(mc.cameraEntity.getPos().add(0, mc.cameraEntity.getEyeHeight(mc.cameraEntity.getPose()), 0));
		
		if (e instanceof PlayerEntity && e != mc.player && e != mc.cameraEntity && getSettings().get(0).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f,0f,0f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f,0f,0f,thick);
		}
		else if (e instanceof Monster && getSettings().get(1).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0f,0f,0f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0f,0f,0f,thick);
		}
		else if (EntityUtils.isAnimal(e) && getSettings().get(2).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0f,1f,0f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0f,1f,0f,thick);
		}
		else if (e instanceof ItemEntity && getSettings().get(3).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f,0.7f,0f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f,0.7f,0f,thick);
		}
		else if (e instanceof EnderCrystalEntity && getSettings().get(4).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f, 0f, 1f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f, 0f, 1f,thick);
		}
		else if ((e instanceof BoatEntity || e instanceof AbstractMinecartEntity) && getSettings().get(5).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0.5f, 0.5f, 0.5f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0.5f, 0.5f, 0.5f,thick);
		}
	}
}
 
Example #5
Source File: ESP.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onTick(EventTick event) {
	for (Entity e: mc.world.getEntities()) {
		if (e instanceof PlayerEntity && e != mc.player && getSettings().get(0).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.RED, "players");
		}
		
		else if (e instanceof Monster && getSettings().get(1).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.DARK_BLUE, "mobs");
		}
		
		else if (EntityUtils.isAnimal(e) && getSettings().get(2).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.GREEN, "passive");
		}
		
		else if (e instanceof ItemEntity && getSettings().get(3).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.GOLD, "items");
		}
		
		else if (e instanceof EndCrystalEntity && getSettings().get(4).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.LIGHT_PURPLE, "crystals");
		}
		
		else if ((e instanceof BoatEntity || e instanceof AbstractMinecartEntity) && getSettings().get(5).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.GRAY, "vehicles");
		}
		else {
		    e.setGlowing(false);
		}
	}
}
 
Example #6
Source File: Tracers.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onRender(Event3DRender event) {
	final float thick = (float) getSettings().get(6).toSlider().getValue();
	
	for (Entity e: mc.world.getEntities()) {
		Vec3d vec = e.getPos();
		
		Vec3d vec2 = new Vec3d(0, 0, 75).rotateX(-(float) Math.toRadians(mc.cameraEntity.pitch))
				.rotateY(-(float) Math.toRadians(mc.cameraEntity.yaw))
				.add(mc.cameraEntity.getPos().add(0, mc.cameraEntity.getEyeHeight(mc.cameraEntity.getPose()), 0));
		
		if (e instanceof PlayerEntity && e != mc.player && e != mc.cameraEntity && getSettings().get(0).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f,0f,0f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f,0f,0f,thick);
		}
		else if (e instanceof Monster && getSettings().get(1).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0f,0f,0f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0f,0f,0f,thick);
		}
		else if (EntityUtils.isAnimal(e) && getSettings().get(2).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0f,1f,0f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0f,1f,0f,thick);
		}
		else if (e instanceof ItemEntity && getSettings().get(3).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f,0.7f,0f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f,0.7f,0f,thick);
		}
		else if (e instanceof EndCrystalEntity && getSettings().get(4).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f, 0f, 1f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f, 0f, 1f,thick);
		}
		else if ((e instanceof BoatEntity || e instanceof AbstractMinecartEntity) && getSettings().get(5).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0.5f, 0.5f, 0.5f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0.5f, 0.5f, 0.5f,thick);
		}
	}
}
 
Example #7
Source File: ESP.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onTick(EventTick event) {
	for (Entity e: mc.world.getEntities()) {
		if (e instanceof PlayerEntity && e != mc.player && getSettings().get(0).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.RED, "players");
		}
		
		else if (e instanceof Monster && getSettings().get(1).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.DARK_BLUE, "mobs");
		}
		
		else if (EntityUtils.isAnimal(e) && getSettings().get(2).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.GREEN, "passive");
		}
		
		else if (e instanceof ItemEntity && getSettings().get(3).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.GOLD, "items");
		}
		
		else if (e instanceof EnderCrystalEntity && getSettings().get(4).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.LIGHT_PURPLE, "crystals");
		}
		
		else if ((e instanceof BoatEntity || e instanceof AbstractMinecartEntity) && getSettings().get(5).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.GRAY, "vehicles");
		}
		else {
		    e.setGlowing(false);
		}
	}
}
 
Example #8
Source File: Tracers.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onRender(Event3DRender event) {
	final float thick = (float) getSettings().get(6).toSlider().getValue();
	
	for (Entity e: mc.world.getEntities()) {
		Vec3d vec = e.getPos();
		
		Vec3d vec2 = new Vec3d(0, 0, 75).rotateX(-(float) Math.toRadians(mc.cameraEntity.pitch))
				.rotateY(-(float) Math.toRadians(mc.cameraEntity.yaw))
				.add(mc.cameraEntity.getPos().add(0, mc.cameraEntity.getEyeHeight(mc.cameraEntity.getPose()), 0));
		
		if (e instanceof PlayerEntity && e != mc.player && e != mc.cameraEntity && getSettings().get(0).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f,0f,0f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f,0f,0f,thick);
		}
		else if (e instanceof Monster && getSettings().get(1).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0f,0f,0f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0f,0f,0f,thick);
		}
		else if (EntityUtils.isAnimal(e) && getSettings().get(2).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0f,1f,0f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0f,1f,0f,thick);
		}
		else if (e instanceof ItemEntity && getSettings().get(3).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f,0.7f,0f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f,0.7f,0f,thick);
		}
		else if (e instanceof EnderCrystalEntity && getSettings().get(4).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f, 0f, 1f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f, 0f, 1f,thick);
		}
		else if ((e instanceof BoatEntity || e instanceof AbstractMinecartEntity) && getSettings().get(5).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0.5f, 0.5f, 0.5f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0.5f, 0.5f, 0.5f,thick);
		}
	}
}
 
Example #9
Source File: Protocol_1_12_2.java    From multiconnect with MIT License 4 votes vote down vote up
@Override
public boolean acceptEntityData(Class<? extends Entity> clazz, TrackedData<?> data) {
    if (!super.acceptEntityData(clazz, data))
        return false;

    if (clazz == AreaEffectCloudEntity.class && data == AreaEffectCloudEntityAccessor.getParticleId()) {
        DataTrackerManager.registerOldTrackedData(AreaEffectCloudEntity.class,
                OLD_AREA_EFFECT_CLOUD_PARTICLE_ID,
                Registry.PARTICLE_TYPE.getRawId(ParticleTypes.ENTITY_EFFECT),
                (entity, val) -> {
            ParticleType<?> type = Registry.PARTICLE_TYPE.get(val);
            if (type == null)
                type = ParticleTypes.ENTITY_EFFECT;
            setParticleType(entity, type);
        });
        DataTrackerManager.registerOldTrackedData(AreaEffectCloudEntity.class,
                OLD_AREA_EFFECT_CLOUD_PARTICLE_PARAM1,
                0,
                (entity, val) -> {
            ((IAreaEffectCloudEntity) entity).multiconnect_setParam1(val);
            setParticleType(entity, entity.getParticleType().getType());
        });
        DataTrackerManager.registerOldTrackedData(AreaEffectCloudEntity.class,
                OLD_AREA_EFFECT_CLOUD_PARTICLE_PARAM2,
                0,
                (entity, val) -> {
            ((IAreaEffectCloudEntity) entity).multiconnect_setParam2(val);
            setParticleType(entity, entity.getParticleType().getType());
        });
        return false;
    }

    if (clazz == Entity.class && data == EntityAccessor.getCustomName()) {
        DataTrackerManager.registerOldTrackedData(Entity.class, OLD_CUSTOM_NAME, "",
                (entity, val) -> entity.setCustomName(val.isEmpty() ? null : new LiteralText(val)));
        return false;
    }

    if (clazz == BoatEntity.class && data == BoatEntityAccessor.getBubbleWobbleTicks()) {
        return false;
    }

    if (clazz == ZombieEntity.class && data == ZombieEntityAccessor.getConvertingInWater()) {
        return false;
    }

    if (clazz == AbstractMinecartEntity.class) {
        TrackedData<Integer> displayTile = AbstractMinecartEntityAccessor.getCustomBlockId();
        if (data == displayTile) {
            DataTrackerManager.registerOldTrackedData(AbstractMinecartEntity.class, OLD_MINECART_DISPLAY_TILE, 0,
                    (entity, val) -> entity.getDataTracker().set(displayTile, Blocks_1_12_2.convertToStateRegistryId(val)));
            return false;
        }
    }

    if (clazz == WolfEntity.class) {
        TrackedData<Integer> collarColor = WolfEntityAccessor.getCollarColor();
        if (data == collarColor) {
            DataTrackerManager.registerOldTrackedData(WolfEntity.class, OLD_WOLF_COLLAR_COLOR, 1,
                    (entity, val) -> entity.getDataTracker().set(collarColor, 15 - val));
            return false;
        }
    }

    return true;
}
 
Example #10
Source File: CarpetDispenserBehaviours.java    From carpet-extra with GNU Lesser General Public License v3.0 4 votes vote down vote up
public MinecartDispenserBehaviour(AbstractMinecartEntity.Type minecartType)
{
    this.minecartType = minecartType;
}
 
Example #11
Source File: DispenserBlockMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Inject(method = "getBehaviorForItem", at = @At("HEAD"), cancellable = true)
private void getBehaviorForItem(ItemStack itemStack_1, CallbackInfoReturnable<DispenserBehavior> cir)
{
    Item item = itemStack_1.getItem();
    if (CarpetExtraSettings.dispenserPlacesBlocks && !BEHAVIORS.containsKey(item) && item instanceof BlockItem)
    {
        if (PlaceBlockDispenserBehavior.canPlace(((BlockItem) item).getBlock()))
        {
            cir.setReturnValue(PlaceBlockDispenserBehavior.getInstance());
            cir.cancel();
        }
    }
    //if (item == Items.GLASS_BOTTLE && CarpetExtraSettings.dispensersFillBottles) / implemented in vanilla 1.15
    //    cir.setReturnValue(new WaterBottleDispenserBehaviour());
    
    if (CarpetExtraSettings.dispensersFillMinecarts)
    {
        if (item == Items.CHEST)
            cir.setReturnValue(new MinecartDispenserBehaviour(AbstractMinecartEntity.Type.CHEST));

        if (item == Items.HOPPER)
            cir.setReturnValue(new MinecartDispenserBehaviour(AbstractMinecartEntity.Type.HOPPER));

        if (item == Items.FURNACE)
            cir.setReturnValue(new MinecartDispenserBehaviour(AbstractMinecartEntity.Type.FURNACE));

        if (item == Items.TNT)
            cir.setReturnValue(new MinecartDispenserBehaviour(AbstractMinecartEntity.Type.TNT));
    }

    if (CarpetExtraSettings.dispensersToggleThings && item == Items.STICK)
        cir.setReturnValue(new TogglingDispenserBehaviour());

    if (CarpetExtraSettings.dispensersPlayRecords && item instanceof MusicDiscItem)
        cir.setReturnValue(new DispenserRecords());
    
    if (CarpetExtraSettings.dispensersTillSoil && item instanceof HoeItem)
        cir.setReturnValue(new TillSoilDispenserBehaviour());

    if (CarpetExtraSettings.dispensersFeedAnimals &&  FeedableItems.ITEMS.contains(item.asItem()))
        cir.setReturnValue(new FeedAnimalDispenserBehaviour());
    
    if (CarpetExtraSettings.dragonsBreathConvertsCobbleToEndstone && item == Items.DRAGON_BREATH)
        cir.setReturnValue(new DragonsBreathDispenserBehaviour());
}